akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from itertools import accumulate

def main():
    N = II()
    P = LI()
    T = [1] * N
    for i, p in enumerate(P):
        T[p - 1] += i
    A = list(accumulate(T))
    B = list(accumulate(T[::-1]))[::-1]
    print(*A)
    print(*B)

    return 0

main()

Measured memory_bytes: 45752
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int, int> P;

int main() {
	int n, m;
	cin >> n >> m;
	vector< vector<int> > data(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> data[i][j];
		}
	}
	int dx[] = {1, 0, -1, 0};
	int dy[] = {0, 1, 0, -1};
	for (int i = 0; i < m; i++) {
		int o;
		cin >> o;
		if (o == 0) {
			int r, c, s, a;
			cin >> r >> c >> s >> a;
			r--;
			c--;
			vector< vector<int> > data2(s, vector<int>(s));
			if (a == 90) {
				for (int j = 0; j < s; j++) {
					for (int k = 0; k < s; k++) {
						data2[j][k] = data[r+s-1-k][c+j];
					}
				}
			} else if (a == 180) {
				for (int j = 0; j < s; j++) {
					for (int k = 0; k < s; k++) {
						data2[j][k] = data[r+s-1-j][c+s-1-k];
					}
				}
			} else if (a == 270) {
				for (int j = 0; j < s; j++) {
					for (int k = 0; k < s; k++) {
						data2[j][k] = data[r+k][c+s-1-j];
					}
				}
			} else {
				for (int j = 0; j < s; j++) {
					for (int k = 0; k < s; k++) {
						data2[j][k] = data[j+r][k+c];
					}
				}
			}
			for (int j = 0; j < s; j++) {
				for (int k = 0; k < s; k++) {
					data[j+r][k+c] = data2[j][k];
				}
			}
		} else if (o == 1) {
			int r, c, s;
			cin >> r >> c >> s;
			r--;
			c--;
			for (int j = r; j < r+s; j++) {
				for (int k = c; k < c+s; k++) {
					data[j][k] = 1 - data[j][k];
				}
			}
		} else if (o == 2) {
			int r;
			cin >> r;
			r--;
			int kari = data[r][0];
			for (int j = 0; j < n-1; j++) {
				data[r][j] = data[r][j+1];
			}
			data[r][n-1] = kari;
		} else if (o == 3) {
			int r;
			cin >> r;
			r--;
			int kari = data[r][n-1];
			for (int j = n-1; j > 0 ; j--) {
				data[r][j] = data[r][j-1];
			}
			data[r][0] = kari;
		} else {
			int r, c;
			cin >> r >> c;
			r--;
			c--;
			int k = data[r][c];
			data[r][c] = 1 - k;
			vector< vector<int> > data2(n, vector<int>(n, 0));
			data2[r][c] = 1;
			queue<P> q;
			q.push(P(r, c));
			while (!q.empty()) {
				P p = q.front();
				q.pop();
				for (int i = 0; i < 4; i++) {
					if (p.first+dx[i] >= 0 && p.first+dx[i] < n && p.second+dy[i] >= 0 && p.second+dy[i] < n) {
						if (data2[p.first+dx[i]][p.second+dy[i]] == 0 && data[p.first+dx[i]][p.second+dy[i]] == k) {
							data[p.first+dx[i]][p.second+dy[i]] = 1-k;
							data2[p.first+dx[i]][p.second+dy[i]] = 1;
							q.push(P(p.first+dx[i], p.second+dy[i]));
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j == 0) {
				cout << data[i][j];
			} else {
				cout << ' ' << data[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int x = Integer.parseInt(chr[0]);
			int a = Integer.parseInt(chr[1]);
			int b = Integer.parseInt(chr[2]);
			int ax=Math.abs(x-a);
			int bx=Math.abs(x-b);
			System.out.println(ax<bx?"A":"B");

		}
	}
}

Measured memory_bytes: 25392
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}
int main(){
  int N,M,X,Y;cin>>N>>M>>X>>Y;
  vi x(N);vi y(M);
  rep(i,N)cin>>x[i];  
  rep(i,M)cin>>y[i];
  sort(all(x));sort(all(y));
  bool ok=false;
  for(int i=x[N-1]+1 ;i<=y[0];i++){
      if(X<i && i<=Y){
        ok=true;break;
      }    
  } 
  if(ok)cout<<"No War"<<endl;
  else cout<<"War"<<endl;
  
  
  
  
  
  
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}


int main(void){
    int n, m;
    cin >> n >> m;

    vector<int> x(m);

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

     if(n >= m){
        cout << 0 << endl;
        return 0;
    }

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

    vector<int> dist(m - 1);
    for(int i = 0; i < m - 1; i++){
        dist[i] = x[i + 1] - x[i];
    }

    sort(dist.begin(), dist.end(), greater<int>());

    int total = 0;
    for(int i = 0; i < n - 1; i++){
        total += dist[i];
    }

    cout << (x[m - 1] - x[0]) - total<< endl;
}



Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a, b, c, d = map(int, input().split())
    diff = b - a
    for k in range(n):
        mi = k * c - (n - 1 - k) * d
        ma = k * d - (n - 1 - k) * c
        if mi <= diff <= ma:
            print("YES")
            break
    else:
        print("NO")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9180
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;
  string ans = "";
  while(n != 0) {
    if(n % 2 != 0) {
      n--;
      ans = '1' + ans;
    } else {
      ans = '0' + ans;
    }
    n /= -2;
  }
  if(ans == "") ans = "0";

  cout << ans << endl;
}


Measured memory_bytes: 256
/*
[abc130] F - Minimum Bounding Box
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;
const int MAX_XY = 1e8;
const ll INF = 1e18;

int dxy[2][4] = {{0, 1, 0, -1}, {1, 0, -1, 0}};

int N;
int xy[2][MAX_N];
int d[MAX_N];

ll solve() {
    int l[2][3], r[2][3];
    for (int c = 0; c < 2; c++) {
        for (int k = 0; k < 3; k++) {
            l[c][k] = MAX_XY + 1;
            r[c][k] = -MAX_XY - 1;
            for (int i = 0; i < N; i++) {
                if (dxy[c][d[i]] + 1 == k) {
                    l[c][k] = min(l[c][k], xy[c][i]);
                    r[c][k] = max(r[c][k], xy[c][i]);
                }
            }
        }
    }

    vector<int> ts = {0};
    for (int c = 0; c < 2; c++) {
        ts.push_back((l[c][0] - l[c][1]) * 2);
        ts.push_back((l[c][1] - l[c][2]) * 2);
        ts.push_back(l[c][0] - l[c][2]);
        ts.push_back((r[c][0] - r[c][1]) * 2);
        ts.push_back((r[c][1] - r[c][2]) * 2);
        ts.push_back(r[c][0] - r[c][2]);
    }

    ll ans = INF;
    for (int t : ts) {
        if (t < 0 || INF <= t) {
            continue;
        }
        int xmax = max(max(2 * r[0][0] - t, 2 * r[0][1]), 2 * r[0][2] + t);
        int xmin = min(min(2 * l[0][0] - t, 2 * l[0][1]), 2 * l[0][2] + t);
        int ymax = max(max(2 * r[1][0] - t, 2 * r[1][1]), 2 * r[1][2] + t);
        int ymin = min(min(2 * l[1][0] - t, 2 * l[1][1]), 2 * l[1][2] + t);
        ans = min(ans, (ll)(xmax - xmin) * (ll)(ymax - ymin));
    }

    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        char d_raw;
        cin >> xy[0][i] >> xy[1][i] >> d_raw;
        switch (d_raw) {
            case 'U':
                d[i] = 0;
                break;
            case 'R':
                d[i] = 1;
                break;
            case 'D':
                d[i] = 2;
                break;
            case 'L':
                d[i] = 3;
                break;
        }
    }

    ll ans = solve();
    ll m = ans % 4;
    cout << ans / 4 << "." << setfill('0') << setw(2) << m * 25
         << "00000000000000" << endl;

    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10) cout<<a*b<<endl;
    else cout<<-1<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,y;
    cin>>n>>y;
    bool flag=false;
    int i,j,k;
    for(i=0;i<=n;i++){
        for(j=0;j<=n;j++){
            k=n-i-j;
            if(i+j+k==n&&10000*i+5000*j+1000*k==y&&k>=0){
                flag=true;
            }
            if(flag)break;
        }
        if(flag)break;
    }
    if(flag)cout<<i<<" "<<j<<" "<<k<<endl;
    else cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b=int(input())
print(a[b-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  map<ll, ll> mp;
  ll res = 0;
  rep(i,n) {
    ll a;
    cin >> a;
    mp[a]++;
    res += a;
  }

  ll q;
  cin >> q;

  for (int i = 0; i < q; i++) {
    ll b, c;
    cin >> b >> c;
    ll num = mp[b];
    mp[b] = 0;
    mp[c] += num;

    res += (c-b) * num;
    cout << res << endl;
  }

  return 0;
}



Measured memory_bytes: 9424
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 100005;
int a[maxn];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a+n);

    int side[2] = {0, 0}, flag = 0;
    for(int i = n-1; i >= 0; ) {
        if(flag == 2) break;
        if(i-1 >= 0 && a[i] == a[i-1]) { side[flag] = a[i]; flag ++; i-=2; }
        else i--;
    }

    long long ans = (long long)side[0] * side[1];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
char ip[2][3];
int main()
{
	int i,j;
	char a;
	for( i = 1;i<=2;i++)
	{
		for( j = 1; j<=3 ; j++ )
		{
			if(j!=3)
			scanf("%c",&ip[i][j]);
			else
			scanf("%c%c",&ip[i][j],&a);
		}
	}
	if (ip[1][1]==ip[2][3]  && ip[1][2]==ip[2][2]  &&  ip[1][3]==ip[2][1] )
		printf("YES\n");
	else
		printf("NO\n");
}

Measured memory_bytes: 128
#include <iostream>

const int MAXN=1e6+11;

using namespace std;

int next(int n){
	return n%2==0 ? n/2 : 3*n+1;
}

int get_rep_idx(int s){
	bool occ[MAXN]={};
	occ[s]=true;
	for (int i = 2; i < MAXN; ++i)
	{
		s = next(s);
		if(occ[s])
			return i;
		occ[s]=true;
	}
	return -1;
}

int main(int argc, char const *argv[])
{
	int s;
	cin>>s;
	cout<<get_rep_idx(s)<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
//#define int long long

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    long long M;
    scanf("%d%lld", &N, &M);
    vector<long long> A(N);
    vector<long long> sum(N+1, 0);
    for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) sum[i+1] = sum[i] + A[i];
    
    long long ok = 0LL, ng = 200200;
    while (ok + 1 < ng) {
        long long mid = (ok + ng) / 2;
        long long cnt = 0;
        for (int i = 0; i < N; i++) {
            long long L = mid - A[i];
            cnt += (A.end() - lower_bound(A.begin(), A.end(), L));
        }
        if (M <= cnt) ok = mid;
        else ng = mid;
    }
    
    long long ans = 0, cnt = 0;
    for (int i = 0; i < N; i++) {
        long long L = ok - A[i];
        if (A[N-1] <= L) continue;
        int idx = upper_bound(A.begin(), A.end(), L) - A.begin();
        cnt += N - idx;
        ans += (sum[N] - sum[idx]) + ((N-idx) * A[i]);
    }
    
    ans += (ok * (M - cnt));
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define FINISH {cout<<"No"<<endl;return 0;}
using ll = long long;
const ll MOD = 998244353;

int main(){
	int N, a;
	cin >> N;
	vector<pair<int, int>> X(N + 1, { -1,-1 });
	int Y[250010];
	for (int i = 1;i <= N;i++) {
		cin >> a;
		X[i] = { a,i };
	}
	for (int i = 0;i < 250010;i++)Y[i] = 0;
	a = 1;
	sort(all(X));
	
	int d, e;
	queue<pair<int,int>> Q;
	for (int i = 1;i <= N;i++) {
		tie(d, e) = X[i];
		Y[d] = e;
		for (int j = 0;j < e - 1;a++) {
			if (Y[a]) {
				if (Y[a] == e)FINISH;
				if (Y[a] != N) Q.push({ Y[a],Y[a] });
			}
			else {
				Y[a] = e;
				j++;
			}
		}
	}

	for (int i = a;i <= N * N;i++) {
		if (Y[i]) {
			if (Y[i] != N) Q.push({ Y[i],Y[i] });
			continue;
		}
		if (Q.empty())FINISH;
		tie(d, e) = Q.front();
		Q.front() = { d,e };
		Y[i] = d;e++;
		if (e == N)Q.pop();
		else Q.front() = { d,e };
	}
	cout << "Yes" << endl;
	for (int i = 1;i <= N * N;i++) {
		cout << Y[i];
		if (i == N * N)cout << endl;
		else cout << " ";
	}
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	cin >> n;
	int ans = (int)-2e9;
	vector<int>vp, vm;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		vp.push_back(a + b);
		vm.push_back(a - b);
	}
	sort(vp.begin(), vp.end());
	sort(vm.begin(), vm.end());
	ans = max(vp[n - 1] - vp[0], vm[n - 1] - vm[0]);
	cout << ans;
}

Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#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)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main(){
    int n,m;cin >> n >> m;
    n++;
    string s;cin >> s;
    vector<int> ans;
    int j=n-1;
    for(int i=n-1;i>=0;i--){
        if(j<i) continue;
        if(i==0) continue;
        int d=0;
        int rd=0;
        while(d<=m){
            if(j-d<0) break;
            if(s[j-d]=='1'){
                if(d==m) break;
                else{
                    d++;
                }
            }
            else{
                if(d==m){
                    rd=m;
                    break;
                }
                else{
                    rd=d;
                    d++;
                }
            }
        }
        j-=rd;
        if(rd!=0) ans.push_back(rd);
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    reverse(ans.begin(),ans.end());
    rep(i,(int)ans.size()){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1144
/* Warshall-Floyd + DP (O(n^3)+O(r*n^2)) */

#include<cstdio>
#include<algorithm>

using namespace std;

const int inf=1000000000;
int wf_l[200][200],wf_s[200][200],memo[1000][200];

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n;){
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)	wf_l[i][j]=wf_s[i][j]=(i==j?0:inf);
		for(int i=0;i<m;i++){
			int x,y,t;
			char sl;	scanf("%d%d%d %c",&x,&y,&t,&sl);
			x--;	y--;
			if(sl=='S')	wf_s[x][y]=wf_s[y][x]=min(wf_s[x][y],t);
			if(sl=='L')	wf_l[x][y]=wf_l[y][x]=min(wf_l[x][y],t);
		}

		for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)wf_l[i][j]=min(wf_l[i][j],wf_l[i][k]+wf_l[k][j]);
		for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)wf_s[i][j]=min(wf_s[i][j],wf_s[i][k]+wf_s[k][j]);

		int r,from,to;	scanf("%d%d",&r,&from);	from--;
		for(int j=0;j<n;j++)	memo[0][j]=(j==from?0:inf);
		for(int i=1;i<r;i++){
			scanf("%d",&to);	to--;
			for(int j=0;j<n;j++){
				memo[i][j]=inf;
				for(int k=0;k<n;k++){
					if(j==k)	memo[i][j]=min(memo[i][j],memo[i-1][k]+wf_l[from][to]);
					long long dis=1LL*wf_l[from][k]+wf_s[k][j]+wf_l[j][to];
					if(dis<inf)	memo[i][j]=min(memo[i][j],memo[i-1][k]+(int)dis);
				}
			}
			from=to;
		}

		int tmin=inf;
		for(int j=0;j<n;j++)	tmin=min(tmin,memo[r-1][j]);
		printf("%d\n",tmin);
	}

	return 0;
}

Measured memory_bytes: 1856
import java.util.*;
class RMQ {
	private int size_, dat[];
	private int query_(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return 2147483647;
		if(a <= l && r <= b) return dat[k];
		int lc = query_(a, b, 2 * k, l, (l + r) / 2);
		int rc = query_(a, b, 2 * k + 1, (l + r) / 2, r);
		return Math.min(lc, rc);
	}
	RMQ(int s) {
		for(size_ = 1; size_ < s;) size_ *= 2;
		dat = new int[size_ * 2];
		for(int i = 0; i < size_ * 2; i++) dat[i] = 2147483647;
	}
	public void update(int pos, int x) {
		pos += size_; dat[pos] = x;
		while(pos > 1) {
			pos /= 2;
			dat[pos] = Math.min(dat[2 * pos], dat[2 * pos + 1]);
		}
	}
	public int query(int l, int r) {
		return query_(l, r, 1, 0, size_);
	}
}
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), q = sc.nextInt();
		RMQ r = new RMQ(n);
		for(int i = 0; i < q; i++) {
			int c = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();
			if(c == 0) r.update(x, y);
			else System.out.println(r.query(x, y + 1));
		}
	}
}

Measured memory_bytes: 104048
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
 
using namespace std;
 
typedef long long LL;
 
const int inf = 1 << 30;
const int mod=1e9+7,base=2001;
int n;
int a[200005],b[200005],dp[4005][4005];
int fac[200005],inv[200005]; 
 
int pw(int x,int y){
	if(!y)return 1;if(y==1)return x;
	int mid=pw(x,y>>1);
	if(y&1)return 1ll*mid*mid%mod*x%mod;
	return 1ll*mid*mid%mod;
}
 
int C(int x,int y){
	return 1ll*fac[x]*inv[x-y]%mod*inv[y]%mod;
}
 
int main(){
	fac[0]=inv[0]=1;for(int i=1;i<=200000;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[200000]=pw(fac[200000],mod-2);
	for(int i=199999;i>=1;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),++ dp[base-a[i]][base-b[i]];
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++)
			dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%mod,
			dp[i][j]%=mod;
	
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=dp[a[i]+base][b[i]+base];
		ans-=C((a[i]+b[i])<<1,a[i]<<1);
		ans=(ans%mod+mod)%mod;
	}
	printf("%d\n",1ll*ans*pw(2,mod-2)%mod);
 
	return 0;
}

Measured memory_bytes: 66048
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>

using namespace std;

const int N = 500003;
struct query{
	int l, r, id;
	query()
	{}
	query(int ll, int rr, int d)
	{
		l = ll, r = rr, id = d;
	}
	bool operator < (const query& x)
	{
		return r < x.r;
	}
};
int n, k, Q, c[N], ans[N], s[N];
query q[N];

void add(int i, int a)
{
	while(i <= n)
	{
		s[i] += a;
		i += i & -i;
	}
}
int getsum(int i)
{
	int ret = 0;
	while(i)
	{
		ret += s[i];
		i -= i & -i;
	}
	return ret;
}

int main()
{
	cin >> n >> Q;
	for(int i = 1; i <= n; ++i) scanf("%d", &c[i]);
	for(int i = 0, l, r; i < Q; ++i)
	{
		scanf("%d %d", &l, &r);
		q[i] = query(l, r, i);
	}
	unordered_map<int, int> mp;
	sort(q, q + Q);
	for(int i = 0, pre = 1; i < Q; ++i)
	{
		for(int j = pre; j <= q[i].r; ++j)
		{
			add(j, 1);
			auto ptr = mp.find(c[j]);
			if(ptr != mp.end()) add(mp[c[j]], -1);
			mp[c[j]] = j;
		}
		ans[q[i].id] = getsum(q[i].r) - getsum(q[i].l - 1);
		pre = q[i].r + 1;
	}
	for(int i = 0; i < Q; ++i)
		printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 35240
N = int(input())
A = sorted(list(map(int,input().split())))
def gcdaaaaaaaaa(L):
    nextminb = L[0]
    nextn = len(L)
    while True:
        n = nextn
        minb = nextminb
        for l in L[:n]:
            nextn = 0
            r= l % minb
            
            if r != 0:
                L[nextn] = r
                nextn += 1
                if r < nextminb :
                    nextminb = r
        if minb == nextminb:
            return minb
        
def gcd(a,b):
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b,r)
def gcdL(L):
    g = L[0]
    for l in L:
        g = gcd(g,l)
    return g



lgcd = [0] * N
rgcd = [0] * N

lg = A[0]
rg = A[-1]
for i in range(N):
    
    lg = gcd(lg,A[i])
    lgcd[i] = lg
    rg = gcd(rg,A[N-i-1])
    rgcd[N-i-1] = rg
    
maxg = max(lgcd[N-2],rgcd[1])
for i in range(1,N-1):
    g = gcd(lgcd[i-1],rgcd[i+1])
    if maxg < g:
        maxg = g

print(maxg)


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> pp(H);
  for ( int i = 0 ; i < H ; i++ )
    cin >> pp.at(i);
  for ( int j = 0 ; j < W + 2 ; j++ )
    cout << '#';
  cout << endl;
  for ( int k = 0 ; k < H ; k++ )
    cout << '#' << pp.at(k) << '#' << endl;
  for ( int l = 0 ; l < W + 2 ; l++ )
    cout << '#';
  cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int A, B, C;
        cin >> A >> B >> C;

        cout << min({A + B, B + C, C + A}) << endl;

        return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append((i, n//i))

    # divisors.sort()
    return divisors


n = I()
ret = INF
for a, b in make_divisors(n):
    ret = min(ret, max(len(str(a)), len(str(b))))


print(ret)

Measured memory_bytes: 39920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> rate(N);
    for(int i=0;i<N;i++){
        cin >> rate[i];
    }
    vector<int> colors(9);
    int color_max=0;
    int color_min=0;
    for(int i=0;i<N;i++){
        if(rate[i]<=399){
            colors[0]++;
        }
        else if(rate[i]<=799){
            colors[1]++;
        }
        else if(rate[i]<=1199){
            colors[2]++;
        }
        else if(rate[i]<=1599){
            colors[3]++;
        }
        else if(rate[i]<=1999){
            colors[4]++;
        }
        else if(rate[i]<=2399){
            colors[5]++;
        }
        else if(rate[i]<=2799){
            colors[6]++;
        }
        else if(rate[i]<=3199){
            colors[7]++;
        }
        else if(rate[i]<=4800){
            colors[8]++;
        }
    }
    for(int i=0;i<8;i++){
        if(colors[i]>0){
            color_min++;
        }
    }
    color_max = color_min + colors[8];
    if(color_min==0&&colors[8]>0){
        color_min=1;// colors[8]>0であるとき
    }
    cout << color_min << " " << color_max << endl;
}

Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4],k,w;
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>k;
	w=a[3]-a[1];
	w+=(a[2]-a[0])*60-k;
	cout<<w;
	return 0;
} 

Measured memory_bytes: 3624
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;

pii f(int n){
	string s="";
	while(n){
		s+=char(n%10+'0');
		n/=10;
	}
	reverse(all(s));
	return {(int)s[0]-'0',(int)(s[sz(s)-1]-'0')};
}

void solve(){
	int n;
	cin>>n;
	int ans=0;
	map<pii,int>m;
	for(int i=1;i<=n;++i){
		int x=f(i).F,y=f(i).S;
		if(y==0)continue;
		if(x==y)ans++;
		ans+=m[{y,x}]*2;
		m[{x,y}]++;
	}
	cout<<ans;

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3608
function Main(input) {
	var str = input;
	var ans = 1;
	var str = str.split("\n");
	var a = BigInt(str[0].split(" ")[0]);
	var b = str[0].split(" ")[1];
	b = b.replace('.', '');
	b = BigInt(b);
	ans = a*b;
	ans = ans.toString();
	ans = ans.slice( 0, -2 );
	if(ans === ""){
		ans = "0";
	}
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29628
#include <stdio.h>

void Tree(int * ,int);
int main() {
  int i,h;
  int A[250];
  scanf("%d",&h);
  for (i = 0; i < h; i++) {
    scanf("%d",&A[i]);
  }
  Tree(A,h);
  return 0;
}
void Tree(int *A,int h){
  int i;
  for (i = 0; i < h; i++) {
    printf("node %d: key = %d, ",i+1,A[i]);
    if (i != 0) {
      printf("parent key = %d, ",A[(i-1)/2]);
    }
    if (2*i+1 < h) {
      printf("left key = %d, ",A[2*i+1]);
    }
    if (2*i+2 < h) {
      printf("right key = %d, ",A[2*i+2]);
    }
    printf("\n");
  }

}



Measured memory_bytes: 2048
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define nmax 200010
#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 1000000007

#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;
using namespace std::chrono;

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

int n, m, k;
int cur[1024];
int dp[15][1024];
char s[15][1024];

bool good(int l, int r, int bits)
{
    int pos = 0;

    for (int i = 0; i < n; i++)
        if (((bits >> i) & 1) == 1) {

            int sum = dp[i + 1][r] - dp[i + 1][l - 1] - dp[pos][r] + dp[pos][l - 1];

            if (sum > k) return false;

            pos = i + 1;
        }

    int sum = dp[n][r] - dp[n][l - 1] - dp[pos][r] + dp[pos][l - 1];

    return (sum <= k);
}

int nr_bits(int x)
{
    int nr = 0;

    for (int i = 0; i < n; i++)
        if (((x >> i) & 1) == 1) nr++;

    return nr;
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);

    for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (s[i][j] == '1') dp[i][j] = 1 + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]; else
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];

    // brute force which rows to cut

    int answer = INF;

    for (int i = 0; i < (1 << n); i++)
    {
        for (int j = 0; j <= m; j++) cur[j] = INF;

        cur[0] = 0;

        for (int j = 0; j <= m; j++)
            if (cur[j] != INF) {

                int sol = -1;
                int l = j + 1, r = m;

                while (l <= r) {

                    int mm = (l + r) / 2;

                    if (good(j + 1, mm, i)) { sol = mm; l = mm + 1; }
                    else
                        r = mm - 1;
                }

                if (sol != -1) cur[sol] = min(cur[sol], cur[j] + 1);
            }

        answer = min(answer, cur[m] + nr_bits(i) - 1);
    }

    printf("%d", answer);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

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

using namespace std;

typedef long long int ll;

int num[6000];
int p[6000];

int main()
{
    ios::sync_with_stdio(false);
    int x,n;
    cin>>x>>n;
    int i;
    vector<int> arr(n);
    set<int> s;
    for(i=0;i<n;++i){
        cin>>arr[i];
        s.insert(arr[i]);
    }
    int k1=x,k2=x;
    while(s.find(k1)!=s.end()){
        k1++;
        
    }
    while(s.find(k2)!=s.end()){
        k2--;
    }
    if(k1-x>=x-k2){
        cout<<k2;
    }
    else{
        cout<<k1;
    }

}


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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

int main(){
    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string k;
    cin >> k;
    if(k == s) {
        a--;
    } else {
        b--;
    }
    cout << a << " " << b;
}



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

#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define ll long long
using namespace std;

int inf = 1e18;
const int N = 5e5+5;
int mod = 1e9+7;
/*void dfs(int u,int par,int maxx)
{


    for(int v:adj[u])
    {
        if(v==par)
            continue;
        dfs(v,u,maxx);
    }
}


int ncr(int n , int r ){
	r = min(r,n-r);
	int res = 1 ;
	for(int i = 1 ; i <= r ; i++ ){
		( res *= n-i+1 )%= mod;
		res /= i ;
	}
	return res ;
}
*/
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll arr[N];
 int sumXOR(int n)
{
     ll sum = 0;
    for (int i = 0; i < 64; i++)
    {

        ll k = (1ll<<i);
        int ct = 0;
        for(int j=0;j<n;++j)
        {
            if(arr[j]&k)
                ct++;
        }
        sum+=  k%mod*ct%mod*(n-ct)%mod;
        sum%=mod;
    }
    return sum%mod;
}
int32_t main()
{
    io
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;

        rep(i,0,n)
        cin>>arr[i];
        ll ans = sumXOR(n);
        cout<<ans%mod<<el;

    }



    return 0;
}


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

long long g(long long A) {
	if (A == 0) return 0;
	if (A == 1) return 1;
	// long long cnt = 0;
	// for (long long i = 0; i < 60; i++) {
	// 	if (1&A>>i) cnt = i;
	// }
	// for (long long i = 0; i < cnt-1; i++) {
	// 	two *= 2;
	// }
	// cout << two << " " << cnt << "\n";
	// return (A-two-1)%2*two+1;
	// cout << A << "\n";
	long long res = 0, two = 2;
	if (A%4 == 1 || A%4 == 2) res = 1;
	for (long long i = 1; i < 60; i++) {
		if (A%(two*2)>=two && A%(two*2)%2 == 0) {
			res += two;
		}
		two *= 2;
		// cout << two << " " << res << "\n";
	}

	return res;
}

void solve(long long A, long long B){
	long long res;
	if (A>0) res = g(A-1) ^ g(B);
	if (A==0 && B>0) res = g(B);
	if (A==0 && B==0) res = 0;
	cout << res << "\n";
}

int main(){
	long long B;
	long long A;
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(A, B);
	return 0;
}


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

bool isPrime(int a){
  int i,n=sqrt(a);
  if (a==2)return true;
  if (a%2==0)return false;
  for (i=3;i<=n;i+=2){
    if (a%i==0)return false;
  }
  return true;
};

int main(){
  int n,i,a,count=0;
  cin>>n;
  for (i=0;i<n;i++){
    cin>>a;
    if (isPrime(a))count++;
  }
  cout<<count<<endl;
}



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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}

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


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

#define rep(i,start,n) for(int i=start;i<(int)(n);i++)
#define rrep(i,n,end) for(int i=n-1;i>=end;i--)
#define each(it,v) for(auto it : v)
#define all(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using vpii = vector<Pii>;
using vpll = vector<Pll>;

const ll mod=1e9+7;
const int intINF=INT_MAX;
const ll  longINF=LONG_LONG_MAX;

main()
{
        int n,k; cin>>n>>k;
        vll h(n);
        rep(i,0,n)cin>>h[i];
        sort(all(h));
        ll ans=longINF;
        rep(i,k-1,n)
        {
                ll hoge=h[i]-h[i-k+1];
                ans=min(ans,hoge);
        }
        cout<<ans<<endl;

}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
# 文字列の入力
A = []
B = []

for i in range(3):
    a1, a2, a3 = map(int, input().split())
    A.append([a1, a2, a3])

N = int(input())
for i in range(N):
    B.append(int(input()))

def isBingo():
    for i in range(3):
        if set(A[i]) <= set(B):
            return True
        if {A[0][i], A[1][i], A[2][i]} <= set(B):
            return True

    if {A[0][0], A[1][1], A[2][2]} <= set(B):
        return True
    if {A[2][0], A[1][1], A[0][2]} <= set(B):
        return True

    return False


if isBingo():
    print('Yes')
else:
    print('No')

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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  int sum = A+B+C;
  if(sum<=21){
    cout << "win" << endl;
  }else{
    cout << "bust" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
q = int(math.sqrt(n))
ans = 100000000
for i in range(1,q+1):
    if (n%i == 0):
        a = i
        b = n//i
        a = str(a)
        b = str(b)
        ans = min(ans,max(len(a), len(b)))
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using  namespace std;
  
  int main()
{
   string forcast;
   string real;
  cin >> forcast;
  cin >> real;
  
  int counting=0;
  for(int i=0;i<3;i++)
  {
    if(forcast.at(i)==real.at(i))
    {
      counting++;
    }
  }
  cout<<counting<<endl;
}

Measured memory_bytes: 256
n = int(input())
n = n-1
alfabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans = []
while n>=0:
    a = n%26
    n = n//26-1
    ans.append(alfabet[a])

ans.reverse()
print("".join(ans))


Measured memory_bytes: 9060
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
#define VSORT(v) sort(v.begin(), v.end());
typedef long long ll;
int main(){
    int ans[100][100] = {};
    REP(i,100){
        REP(j,50){
            ans[i][j] = true;
        }
    }
    int A,B;
    cin >> A >> B;
    int y = 1;
    int x = 1;
    while(B > 1){
        ans[y][x] = false;
        B--;
        x += 2;
        if(x == 49){
            x = 1;
            y += 2;
        }
    }
    y = 1;
    x = 51;
    while(A > 1){
        ans[y][x] = true;
        A--;
        x += 2;
        if(x == 99){
            x = 51;
            y += 2;
        }
    }
    cout << "100 100" << endl;
    REP(i,100){
        REP(j,100){
            if(ans[i][j]) cout << '.';
            else cout << '#';
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int A1, A2, A3;

int main() {
    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
 
const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;
 
int main() {
  int n, d;
  cin >> n >> d;
  cout << (n - 1) / (2*d + 1) + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
import math
import sys
n,m = map(int, raw_input().split())
x = map(int, raw_input().split())
if n >= m:
	print(0)
else:
	x.sort()
	memo = []
	for i in range(m-1):
		memo.append(x[i+1]-x[i])
	memo.sort()
	ans = 0
	for i in range(m-n):
		ans += memo[i]
	print(ans)

Measured memory_bytes: 11276
# include <bits/stdc++.h>
# define fi first
# define se second
# define int long long

using namespace std ;

const int N = 5000 ;
double dp[N][N], vc[N];
int n ;
int32_t main() {
    //freopen("cowsignal.in", "r", stdin ) ;
    //freopen("cowsignal.out", "w", stdout ) ;
	cin >> n ;
	for( int i = 1 ; i <= n ; i ++ ) {
        cin >> vc[i] ;
	}
	dp[1][1] = 1 - vc[1] ;
	dp[2][1] = vc[1] ;
	for( int i = 1 ; i <= n +1; i ++ ) {
        for( int j = 2 ; j <= n ; j ++ ) {
            //cout << dp[i-1][j-1] * vc[j] << ' ' << dp[i][j-1] * (1 - vc[j] ) << endl;
            dp[i][j] = dp[i-1][j-1] * vc[j] + dp[i][j-1] * ( 1 - vc[j] ) ;
        }
	}
	double ans = 0 ;
	for( int i = n/2+2 ; i <= n+1 ; i ++ ) ans += dp[i][n] ;
	cout << setprecision(9) << ans << endl;
}


Measured memory_bytes: 85724
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(M)]
Q = int(input())
VDC = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

color = [0] * (N+1)
visited = [[False] * 11 for _ in range(N+1)]
# 残り体力 x で訪れた
# 10で訪れたら、9,8,7も埋める

for v,d,c in VDC[::-1]:
    if visited[v][d]:
        continue
    if color[v] == 0:
        color[v] = c
    for i in range(d+1):
        visited[v][i] = True
    q = [v]
    for t in range(d-1,-1,-1):
        qq = []
        for v in q:
            for w in graph[v]:
                if visited[w][t]:
                    continue
                for i in range(t+1):
                    visited[w][i] = True
                if color[w] == 0:
                    color[w] = c
                qq.append(w)
        q = qq

print('\n'.join(map(str,color[1:])))

Measured memory_bytes: 75736
#include<bits/stdc++.h>
#define ll long long
const int N=1005;
using namespace std;
int n,k,a[N],ans;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) 
	    cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=k;i++)
	    ans+=a[i];
	cout<<ans;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char> > s(h, vector<char>(w));
    vector<vector<int> > res(h, vector<int>(w, -1));
    vector<int> row(h);
    rep (i, h) {
        rep (j, w) {
            cin >> s[i][j];
            if (s[i][j] == '#') row[i]++;
        }
    }

    int cnt = 1;
    rep (i, h) {
        if (row[i] == 0) continue;
        int tmp = 1;
        rep (j, w) {
            if (s[i][j] == '#') {
                if (tmp == 1) tmp++;
                else cnt++;
            }
            res[i][j] = cnt;
        }
        cnt++;
    }

    rep (i, h) {
        if (row[i] > 0) continue;
        if (i == 0) rep (j, w) res[i][j] = res[i + 1][j];
        else rep (j, w) res[i][j] = res[i - 1][j];
    }

    rrep (i, h) {
        if (row[i] > 0) continue;
        if (i == h - 1) {
            rep (j, w) if (res[i][j] == -1) res[i][j] = res[i - 1][j];
        } else {
            rep (j, w) if (res[i][j] == -1) res[i][j] = res[i + 1][j];
        }
    }

   
    rep (i, h) {
        rep (j, w) cout << res[i][j] << " ";
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 1280
loop do
  str = gets.chomp
  break if str == "-"
  count = gets.chomp.to_i
  ARGF.each.with_index(1) do |s, i|
    a = str.slice!(0, s.to_i)
    str = str + a
    break if (i == count)
  end
  puts str
end

Measured memory_bytes: 6120