akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int N, M;  cin >> N >> M;
    vector<int> X(M);
    for(int i=0; i<M; i++)  cin >> X[i];
    sort(X.begin(), X.end());

    if(N>=M){
        cout << 0 << endl;
        return 0;
    }

    vector<int> dX(M-1);
    for(int i=0; i<M-1; i++){
        dX[i] = X[i+1] - X[i];
    }
    sort(dX.begin(), dX.end());

    int ans = 0;
    for(int i=0; i<M-N; i++){
        ans += dX[i];
    }
    cout << ans << endl;
}

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

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

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//const int mod = 1e9 + 7;
const int N = 310000;
vector < int > v;
int x[N], y[N];
void solve(int k, int x, int y){
    if (k == v.size()){
        //cout << endl;
       // cout << x << " --- " << y << endl;
        return;
    }
    int val = v[k];
    if (abs(x) > abs(y)){
        if (abs(x - val) < abs(x + val)){
            cout << "R";
            solve(k + 1, x - val, y);
        } else{
            cout << "L";
            solve(k + 1, x + val, y);
        }
    } else
    if (abs(y) >= abs(x)){
        if (abs(y - val) < abs(y + val)){
            cout << "U";
            solve(k + 1, x, y - val);
        } else{
            cout << "D";
            solve(k + 1, x, y + val);
        }
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    int c = -1;
    for (int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
        if (c != -1 && (abs(x[i]) + abs(y[i])) % 2 != c){
            cout << -1;
            return 0;
        }
        c = (abs(x[i]) + abs(y[i])) % 2;
    }
    if (c == 0) v.pb(1);
    for (int i = 0; i < 32; i++){
      //  if (i % 4 == 0) v.pb((1LL << i));
        v.pb((1LL << i));
    }
    reverse(v.begin(), v.end());
    cout << v.size() << endl;
    for (auto i: v) cout << i << " ";
    cout << endl;
    for (int i = 1; i <= n; i++){
        solve(0, x[i], y[i]);
        cout << endl;
    }
}


Measured memory_bytes: 2304
import heapq
N,M=map(int,input().split())
a=list(map(int,input().split()))

A=[]
for i in range(N):
    A.append(a[i]*(-1))
heapq.heapify(A)

for i in range(M):
    q=(A[0])*(-1)
    heapq.heappop(A)
    heapq.heappush(A,(q//2)*(-1))
    
ans=0
for i in range(N):
    ans+=heapq.heappop(A)
    
print(-ans)

Measured memory_bytes: 14180
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

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

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 300000 + 5;

int op(int a, int b) {
	return max(a, b);
}

int e() {
	return (int)(0);
}




int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	segtree<int, op, e> seg(MAX);

	for (int i = 0; i < n; i++) {
		int l = max(a[i] - k, 0);
		int r = min(a[i] + k + 1, MAX);
		int m = seg.prod(l, r);
		seg.set(a[i], m + 1);
	}
	cout << seg.all_prod() << endl;
}

Measured memory_bytes: 9628
#define TCI ll t;cin>>t;while(t--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define cinl for(int i=0;i<n;i++)
#define vpair vector< pair <ll,ll> >
#define vll vector<ll>
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
        a[i]=0;
        else
        a[i]=i;
    }
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        sum+=a[i];
    }
    cout<<sum;
}
int main()
{
    solve();
    // ll n,f=0;
    // cin>>n;
    // for(;n!=0;n/=10)
    // {
    //     ll x=n%10;
    //     if(x==7)
    //     {
    //         f=1;
    //         break;
    //     }
    // }
    // if(f)
    // cout<<"Yes";
    // else
    // cout<<"No";
}

Measured memory_bytes: 11404
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    long[] A = new long[N + 1];
    long sum = 0;
    long single = 0;
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextLong();
      sum += A[i];
      single += i + 1;
    }
    if (sum % single != 0) {
      System.out.println("NO");
      return;
    }
    A[N] = A[0];
    long count = sum / single;
    long use = 0;
    boolean ok = true;
    for (int i = 0; i < N; i++) {
      long diff = A[i + 1] - A[i] - count;
      if (diff > 0 || -diff % N != 0) {
        ok = false;
        break;
      }
      use += -diff / N;
    }
    ok &= use == count;
    System.out.println(ok ? "YES" : "NO");
  }

}


Measured memory_bytes: 46896
package main

import (
	"fmt"
	// "math"
)

func main() {
	var N int
	fmt.Scan(&N)

	var ans float64
	if N%2 == 0 {
		ans = float64(N/2) / float64(N)
	} else {
		var x int = N / 2
		ans = float64(x+1) / float64(N)
	}
	fmt.Println(ans)

	// if N % 2 == 1 {
	// 	fmt.Println((float64(N/2) + 1) / float64(N))
	// } else {
	// 	fmt.Println(float64(N/2) / float64(N))
	// }
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	string S;
	cin >> S;

	string T;
	cin >> T;

	vector<int> conv_s(26, -1);
	vector<int> conv_t(26, -1);

	for (int i = 0; i < S.size(); i++)
	{
		int s_char = S[i] - 'a';
		int t_char = T[i] - 'a';

		if (conv_s[s_char] != -1 || conv_t[t_char] != -1)
		{
			if (conv_s[s_char] != t_char || conv_t[t_char] != s_char)
			{
				cout << "No";
				return 0;
			}
		}
		else
		{
			conv_s[s_char] = t_char;
			conv_t[t_char] = s_char;
		}
	}

	cout << "Yes";

	return 0;
}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

inline int popcount(int x){
	x=((x>>1)&0x55555555)+(x&0x55555555);
	x=((x>>2)&0x33333333)+(x&0x33333333);
	x=((x>>4)+x)&0x0f0f0f0f;
	x+=(x>>8);
	x+=(x>>16);
	return x&0x3f;
}

int main(){
	int n,A[21][21]; scanf("%d",&n);
	rep(u,n) rep(v,n) scanf("%d",&A[u][v]);

	static mint dp[1<<21];
	dp[0]=1;
	rep(S,1<<n){
		int u=popcount(S);
		rep(v,n) if((S>>v&1)==0 && A[u][v]==1) dp[S|1<<v]+=dp[S];
	}
	printf("%d\n",dp[(1<<n)-1].to_int());

	return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

#define ll long long
#define ull unsigned long long

using namespace std;

const long long mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int m, d;
    cin >> m >> d;

    int counter = 0;
    for(int i = 1; i <= m; ++i){
        for(int j = 1; j <= d; ++j){
            int d10 = j/10;
            int d1 = j-(10*d10);

            if(d1 >= 2 && d10 >= 2 && d1*d10 == i){
                ++counter;
            }
        }
    }

    cout << counter << "\n";
}

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

int main() {
	int a,b,c,x;//xは50の倍数
	cin >> a >> b >> c >> x;

	int n = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if ((500*i + 100*j + 50*k) == x)n++;
			}
		}
	}
	
	cout << n;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int A , B , d[20][20] , mn[20][20];

int main(){
  cin >> A >> B;
  rep(i,1,A+1) rep(j,1,B+1)
    cin >> d[i][j];
  rep(i,1,A+1) rep(j,1,B+1)
    mn[i][j] = d[i][j] + 1;
  vi X , Y;
  int _ = 0;
  rep(i,0,101) X.pb(++_) , Y.pb(++_);
  vector<pair<pii,int> > edge;
  rep(i,1,sz(X)) edge.pb(mp(mp(X[i - 1] , X[i]) , -1));
  rep(i,1,sz(Y)) edge.pb(mp(mp(Y[i] , Y[i - 1]) , -2));
  rep(i,0,sz(X)) rep(j,0,sz(Y)) {
    int add = 0;
    rep(x,1,A+1) rep(y,1,B+1) {
      int cost = i * x + j * y;
      if(cost < d[x][y])
        add = max(add , d[x][y] - cost);
    }
    edge.pb(mp(mp(X[i] , Y[j]) , add));
    rep(x,1,A+1) rep(y,1,B+1) {
      mn[x][y] = min(mn[x][y] , i * x + j * y + add);
    }
  }
  bool ok = true;
  rep(i,1,A+1) rep(j,1,B+1) ok &= mn[i][j] == d[i][j];
  if(!ok) cout << "Impossible" << endl;
  else {
    cout << "Possible" << endl;
    cout << sz(X) + sz(Y) << " " << sz(edge) << endl;
    for(auto e : edge) {
      cout << e.fi.fi << " " << e.fi.se << " ";
      if(e.se == -1) cout << "X" << endl;
      else if(e.se == -2) cout << "Y" << endl;
      else cout << e.se << endl;
    }
    cout << X[0] << " " << Y[0] << endl;
  }
  return 0;
}


Measured memory_bytes: 576
#include <stdio.h>

int main(){
	int i,w,n,a,b,tmp,line[30];
	scanf("%d",&w);
	scanf("%d",&n);
	for(i = 0;i < w;i++) line[i] = i + 1;
	for(i = 0;i < n;i++){
		scanf("%d,%d",&a,&b);
		tmp = line[a - 1];
		line[a - 1] = line[b - 1];
		line[b - 1] = tmp;
	}
	for(i = 0;i < w;i++) printf("%d\n",line[i]);
}

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

void solve(){
    int n;
    cin>>n;
    vector<vector<int>> mat(n,vector<int>(3));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>mat[i][j];
        }
    }
    vector<vector<int>> dp(n,vector<int>(3));
    dp[0][0]=mat[0][0];dp[0][1]=mat[0][1];dp[0][2]=mat[0][2];
    for(int i=1;i<n;i++){
        dp[i][0]=mat[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=mat[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=mat[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

int main() {
	// your code goes here
	//freopen("inptmp0.txt","r",stdin);
	int T;
	
	//cin>>T;
	T=1;
	while(T--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
void solve()
{
  int x,n;
  cin>>x>>n;
  if(n==0)
  {
    cout<<x;
    return;
  }
  map<int,bool> um;
  vector<int> V(n);
  for(int i=0;i<n;i++)
  {
    cin>>V[i];
    um[V[i]]=true;
  }

  if(um[x]==false)
  {
    cout<<x;
    return;
  }
  int left=x-1,right=x+1;
  while(1)
  {
      if(um[left]==false)
      {
        cout<<left;
        break;
      }
      else if(um[right]==false)
      {
        cout<<right;
        break;
      }
      left--;
      right++;
  }
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3612
#(問3)ANS-1
import sys
lines = sys.stdin.readlines()
N = lines[0]
N = N.strip()
A = lines[1]
A_iter = map(int,A.split()) #イテレータを生成
A_list = []
for i in A_iter:
    A_list.append(i)

iter_num_list = []
for a in A_list:
    count = 0
    while a%2 == 0:
        a = a/2
        count += 1
    iter_num_list.append(count)
ans = sorted(iter_num_list)[0]
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define N 1000000

int binarySearch();

int main(){
  int i, n, A[N], a,b,c= 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &a);
  for(i = 0; i < a; i++){
    scanf("%d", &b);
    if( binarySearch(A,b,n) ) c++; 
  }
  printf("%d\n", c);
  return 0;
}

int binarySearch(int A[], int b, int n){
  int l,r,m;
  l = 0;
  r = n;
  while(l < r){
    m = (l + r) / 2;
    if(A[m] == b) return 1;
    if(b < A[m]) r = m;
    else if(b > A[m]) l = m + 1;

  }
  return 0;
}



Measured memory_bytes: 2136
n, k = gets.chomp.split(" ").map(&:to_i)
h = {}
list = []
n.times do
    a, b = gets.chomp.split(" ").map(&:to_i)
    if h.has_key?(a)
        h[a] += b
    else
        list << a
        h[a] = b
    end
end

list.sort.each do |v|
    k -= h[v]
    if k <= 0
        puts v
        exit
    end
end

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

int main(){
    bool A=1;
    while (A){
        int n;
        cin >> n;
        if (n==0) {return 0;}
        else{
            double m=0;
            vector<int> score(n);
            for(int i=0; i<n; i++){
                cin >> score.at(i);
                m+=score.at(i);
            }
            m/=n;
            double V=0;
            for(int i=0; i<n; i++){
                V+=(score.at(i)-m)*(score.at(i)-m);
                if (i==n-1) {V/=n;}
            }
        std::cout<<std::fixed<<std::setprecision(10) << sqrt(V) << endl;
        }
    }
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


int n, a[114514], b[114514];
signed main() {
	cin >> n; REP(i, n + 1)cin >> a[i];
	REP(i, n + 1)cin >> b[i];
	int ans = 1;
	REP(i, n + 1) {
		if (a[i] > a[i - 1] && a[i] > b[i])ans = 0;
		if (b[i] > b[i + 1] && b[i] > a[i])ans = 0;
		if (a[i] <= a[i - 1] && b[i] <= b[i + 1])ans *= min(a[i], b[i]);
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
# Cosmic rays
import math
import heapq

xs, ys, xt, yt = map(int, input().split())
N = int(input())

d = [((xs, ys), 0, 0)]
# node,radius

for _ in range(N):
    x, y, r = map(int, input().split())
    d.append(((x, y), _+1, r))

graph = {i: [] for i in range(N+2)}

d.append(((xt, yt), N+1, 0))
for i in range(N+2):
    for j in range(i+1, N+2):
        p, point, rad = d[i]
        q, point2, rad2 = d[j]
        D = math.hypot(p[0]-q[0], p[1]-q[1])
        if D > (rad+rad2):
            graph[i].append((D-rad-rad2, j))
            graph[j].append((D-rad-rad2, i))
        else:
            graph[i].append((0, j))
            graph[j].append((0, i))


def dijkstra(s, graph):
    n = len(graph)
    dist = [float("inf") for i in range(n+1)]
    dist[s] = 0
    pq = []
    heapq.heapify(pq)
    heapq.heappush(pq, (0, s))
    while pq:
        mini_dis, node = heapq.heappop(pq)
        if dist[node] < mini_dis:
            continue
        for w, point in graph[node]:
            if dist[point] < w:
                continue
            newlen = dist[node]+w
            if newlen < dist[point]:
                heapq.heappush(pq, (newlen, point))
                dist[point] = newlen
    return dist

K=dijkstra(0,graph)[N+1]
print(K)

Measured memory_bytes: 129032
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
        int ans;
        for(int i=1;i<=5;++i){
            int x;
            Int(x);
            if(x==0)ans=i;
        }
        printf("%d\n", ans);

        //printf("Case %d: ",++te);
    }
    return 0;
}






Measured memory_bytes: 3728
/*
  AUTHOR:SOURABH
  CREATED:07:03:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t;
    string s;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>s;
        if(s=="AAA" || s=="BBB")
            cout<<"No\n";
        else
            cout<<"Yes\n";
    }
    return 0;
}












Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

trait ToU8 {
    fn to_u8(&self) -> Option<u8>;
}

impl ToU8 for char {
    fn to_u8(&self) -> Option<u8> {
        let num = (*self) as u8 - b'0';
        if num > 9u8 {
            None
        } else {
            Some(num)
        }
    }
}

const MOD: usize = 1_000_000_007;

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();

    let mut dp = vec![vec![0; 13]; 100_005];

    dp[0][0] = 1;

    for (i, &c) in s.iter().enumerate() {
        
        for j in 0..10 {
            if let Some(c) = c.to_u8() {
                if c as usize != j {
                    continue;
                }
            }
            for ki in 0..13 {
                dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
            }
        }

        for j in 0..13 {
            dp[i+1][j] %= MOD;
        }
    }

    let res = dp[s.len()][5];
    println!("{:?}", res);
}


Measured memory_bytes: 18684
// Problem A

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(void) {
	int n;
	double sum;

	sum = 100000;

	cin >> n;

	for (int i; i < n; i++){
		sum = ceil((sum * 1.05)/1000) * 1000;
	}

	cout << (int)sum << endl;

	return 0;
}

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

int main(){
    int a, b, c, tmp;
    cin >> a >> b >> c;
    if (a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if (b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    if (a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    cout << a << ' ' << b << ' ' << c << endl;
    return 0;
}


Measured memory_bytes: 3072
import sys
from collections import deque
input = sys.stdin.readline
h, w = [int(x) for x in input().strip().split()]
g = [[x for x in list(input().strip())] for _ in range(h)]

ans = -1
q = []
for i in range(h):
    for j in range(w):
        if g[i][j] == '#':
            q.append((i, j))
vec = [(0, 1), (1, 0), (0, -1), (-1, 0)]
while q:
    q_ = deque(q)
    q = deque([])
    ans += 1
    while q_:
        i, j = q_.pop()
        for x, y in vec:
            ti, tj = i+x, j+y
            if 0 <= ti < h and 0 <= tj < w:
                if g[ti][tj] == '.':
                    g[ti][tj] = '#'
                    q.append((ti, tj))
print(ans)


Measured memory_bytes: 130464
#include<iostream>
#include<iomanip>
#include<vector>

using namespace std;

int main(){
int N; cin >> N; vector<double> p(N);
  for(int i = 0; i < N; i++){ cin >> p[i];}
  
  double dp[3000][3000];
  for(int i = 0; i < 3000; i++){
    for(int j = 0; j < 3000; j++){
      dp[i][j] = 0;}} //初期化
  
  dp[0][0] = 1.0;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= i; j++){
      dp[i+1][j+1] += dp[i][j] * p[i];
      dp[i+1][j]   += dp[i][j] * ( 1.0 - p[i]);}}
  
  double sum = 0;
  
  for(int j = ( N + 1) / 2; j <= N; j++){
    sum += dp[N][j];}
  
  cout << setprecision(10) << sum << endl; return 0;}
        
      


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0,max=0;
  string s;
  cin>>n;
  cin>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='I'){
      x++;
    }else if(s[i]=='D'){
      x--;
    }

    if(x>=max)max=x;
    
    
  }
  cout<<max<<endl;
}

  
  
  


Measured memory_bytes: 256
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(0, N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
        pass
      elif L[i] + L[j] > L[k]:
        ans += 1
      else:
        pass

print(ans)

Measured memory_bytes: 9196
#include<iostream>
#include <vector>
#include<algorithm>
#include<math.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()

using namespace std;
int main() {
	lli N, A[4],B[8],C[4];

	cin >> N;
	vector<lli> abc(4, 0), len(N, 0),ans;
	cin >> abc[0] >> abc[1] >> abc[2];
	for (int i = 0; i < N; i++) cin >> len[i];
	sort(rall(abc));
	sort(rall(len));
	
	for (int j = 0; j < N; j++) B[j] = (int)pow(4, j);

	for (int i = 0; i <= (int)pow(4, N); i++) {
		A[0] = A[1] = A[2] = A[3] = 0;
		C[0] = C[1] = C[2] = C[3] = 0;
		for (int j = 0; j < N; j++) {
			A[(i % (4 * B[j])) / B[j]] += len[j];
			C[(i % (4 * B[j])) / B[j]]++;
		}
		if (C[0] >= 1 && C[1] >= 1 && C[2] >= 1) {
			ans.push_back(abs(A[0] - abc[0]) + abs(A[1] - abc[1]) + abs(A[2] - abc[2]) + 10 * (max((int)C[0] - 1, 0) + max((int)C[1] - 1, 0) + max((int)C[2] - 1, 0)));
		}
	}
	sort(all(ans));
	cout << ans[0] << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <cmath>
#include <cassert>

#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, MOD = 1e9 + 7;

int N, a[23][23], dp[22][1 << 22];

int go(int cur, int mask) {
    if (~dp[cur][mask]) return dp[cur][mask];
    if (cur == N) return dp[cur][mask] = 1;
    int ret = 0;
    for (int i = 0; i < N; i++) {
        if (a[cur][i] && !(mask & (1 << i))) {
            ret = (ret + go(cur + 1, mask | (1 << i))) % MOD;
        }
    }
    return dp[cur][mask] = ret;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> a[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << go(0, 0) << '\n';
    return 0;
}

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

typedef pair<int, int> P;
const int INF = 60*60;

int main() {
    int row, col;
    int sy, sx, gy, gx;
    cin >> row >> col;
    sy = 0; sx = 0; 
    gy = row-1; gx = col-1;
    vector<string> course;
    course.resize(row);
    rep (i, row) {
        cin >> course[i];
    }

    int count_dot = 0;
    rep (i, row) {
        rep (j, col) {
            if (course[i][j] == '.') {
                count_dot += 1;
            } 
        }
    }

    queue<P> loc_queue;
    vector<vector<int>> distance(row, vector<int>(col, INF));

    loc_queue.push(P {sy, sx});
    distance[sy][sx] = 0;

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

    while (!loc_queue.empty()) {
        P temp_loc = loc_queue.front();
        loc_queue.pop();
        int y = temp_loc.first;
        int x = temp_loc.second;

        if (y==gy && x==gx) {
            break;
        }

        rep (i, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (0<=ny && 0<=nx && ny<row && nx<col && course[ny][nx]!='#' && distance[ny][nx]==INF) {
                loc_queue.push(P {ny, nx});
                distance[ny][nx] = distance[y][x] + 1;
            }
        }
    }

    if (distance[gy][gx]==INF) {
        cout << -1 << endl;
    } else {
        cout << count_dot - distance[gy][gx]  -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 4004;
int n, x, A[N], MN[N][N];
int main()
{
    scanf("%d%d", &n, &x);
    for (int i = n - 1; ~ i; i--)
        scanf("%d", &A[i]), A[i + n] = A[i];
    for (int i = 0; i < n; i++)
    {
        MN[i][0] = A[i];
        for (int j = 1; j < n; j++)
            MN[i][j] = min(MN[i][j - 1], A[i + j]);
    }
    long long Mn = LLONG_MAX;
    for (int i = 0; i < n; i++)
    {
        long long sum = 0;
        for (int j = 0; j < n; j++)
            sum += MN[j][i];
        Mn = min(Mn, sum + 1LL * x * i);
    }
    return !printf("%lld\n", Mn);
}

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



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

  int count = 0;
  for(int i = 0; i < N - 2; i++){
    if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C'){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}



 

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

vector<int> G[MAX_N], cnt[MAX_N];
int ans[MAX_N], mx[MAX_N];

void dfs(int u, int p, int val)
{
    mx[u] = val;
    each(v, G[u]){
        if(v != p){
            cnt[u].pb(0);
            dfs(v, u, max(val, u));
        }
    }
}

void redfs(int u, int p, const int val, int& num)
{
    num++;
    int id = 0, prv = 0;
    each(v,G[u]){
        if(v != p){
            prv = num;
            if(v < val) redfs(v, u, val, num);
            cnt[u][id++] = num-prv;
        }
    }
}

void dfs(int u, int p)
{
    if(p >= 0){
        if(mx[p] != mx[u] || u > mx[u]){
            int num = 0;
            redfs(u, p, mx[u], num);
        }
    }
    each(v,G[u]){
        if(v != p){
            dfs(v, u);
        }
    }
}

void redfs(int u, int p, int val)
{
    int id = 0, sm = accumulate(all(cnt[u]),0);
    ans[u] = val + sm;
    each(v,G[u]){
        if(v != p){
            redfs(v, u, val + sm - cnt[u][id++] + 1);
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a-1].pb(b-1), G[b-1].pb(a-1);
    }
    dfs(0,-1,-1);
    dfs(0,-1);
    redfs(0, -1, 0);
    srep(i,1,n){
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 40704
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 500
int n, m;
int a[N][N];
bool b[N];
int c[N];

int cou(void) {
	int k, km;
	k = 0;
	km = 0;
	f(i, N)c[i] = 0;
	f(i, n) {
		f(j, m) {
			if (b[a[i][j]]) {
				c[a[i][j]]++;
				if (km < c[a[i][j]]) {
					km = c[a[i][j]];
					k = a[i][j];
				}
				break;
			}
		}
	}
	return k;
}





int main() {

	int x, ans;
	scanf("%d %d", &n,&m);
	f(i, n) {
		f(j, m) {
			scanf("%d", &a[i][j]);
			a[i][j]--;
		}
	}
	f(i, N)b[i] = false;
	f(i, m)b[i] = true;
	ans = n;
	f(i,m){
		x = cou();
		ans = min(ans, c[x]);
		b[x] = false;
}

	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
const int INF = 0x3f3f3f3f;
ll N; 
int main()
{
 cin>>N;
	 if(N%2==0) 
	 {
	 	cout<<N<<" "<<N<<" "<<N/2;
		return 0; 
	 }
	for(ll h=1;h<=3500;h++)
	{
		for(ll n=1;n<=3500;n++)
		{ 
		    ll fz=N*h*n;
		    ll fm=4*h*n-N*n-N*h;
			if(fm<=0) continue;
			   if(fz%fm==0) 
			   {
			   	ll w=fz/fm;
				ll t1=4*h*n*w;
				ll t2=N*(h*w+n*w+h*n);
				if(t1==t2) 
				{
				    cout<<h<<" "<<n<<" "<<w;
					return 0;
				}	 
			   	
			   }
			 
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

using P = pair<string, pair<int, int>>;

int main(void){
    Cin(int, n, m);
    Vec2(int, m, 0, s);
    For(i, m){
        Cin(int, k);
        Rep(k){
            Cin(int, t);
            s[i].push_back(t-1);
        }
    }
    Cins(int, m, p);
    
    int ans = 0;
    For(d, 1 << n){
        For(i, m){
            bool f = p[i];
            for(auto j : s[i]) if(d & (1 << j)) f ^= true;
            if(f) goto next;
        }
        // Cout(d);
        ans ++;
        next:;
    }
    Cout(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <utility>

using namespace std;

const int MAXN = 100005;
const int MAXM = 200005;
const int MOD = 1e9 + 7;

struct Edge
{
	int to, next, c;
}e[MAXM * 2];
int head[MAXN], te = 1;

void addE(int u, int v, int c)
{
	e[++te] = (Edge){v, head[u], c}, head[u] = te;
}

int n, m, S, T, u, v, c;

priority_queue<pair<long long, int> > pq;
long long diss[MAXN], dist[MAXN], ds[MAXN], dt[MAXN];

void DPs()
{
	memset(ds, 0, sizeof(ds));
	memset(diss, -1, sizeof(diss));
	ds[S] = 1, diss[S] = 0;
	pq.push(make_pair(-diss[S], S));
	while (!pq.empty())
	{
		pair<long long, int> now = pq.top();
		pq.pop();
		int p = now.second;
		if (-now.first != diss[p])
			continue;
		for (int j = head[p]; j != 0; j = e[j].next)
		{
			int q = e[j].to;
			if (diss[q] == -1 || diss[q] > diss[p] + e[j].c)
			{
				diss[q] = diss[p] + e[j].c;
				ds[q] = ds[p];
				pq.push(make_pair(-diss[q], q));
			}
			else if (diss[q] == diss[p] + e[j].c)
				ds[q] += ds[p], ds[q] %= MOD;
		}
	}
}

void DPt()
{
	memset(dt, 0, sizeof(dt));
	memset(dist, -1, sizeof(dist));
	dt[T] = 1, dist[T] = 0;
	pq.push(make_pair(-dist[T], T));
	while (!pq.empty())
	{
		pair<long long, int> now = pq.top();
		pq.pop();
		int p = now.second;
		if (-now.first != dist[p])
			continue;
		for (int j = head[p]; j != 0; j = e[j].next)
		{
			int q = e[j].to;
			if (dist[q] == -1 || dist[q] > dist[p] + e[j].c)
			{
				dist[q] = dist[p] + e[j].c;
				dt[q] = dt[p];
				pq.push(make_pair(-dist[q], q));
			}
			else if (dist[q] == dist[p] + e[j].c)
				dt[q] += dt[p], dt[q] %= MOD;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m >> S >> T;
	for (int i = 1; i <= m; i++)
	{
		cin >> u >> v >> c;
		addE(u, v, c);
		addE(v, u, c);
	}
	DPs();
	DPt();
	long long D = diss[T];
	long long res = ds[T] * ds[T] % MOD;
	for (int i = 1; i <= n; i++)
		if (diss[i] == D / 2 && dist[i] == D / 2)
			res = (res - (ds[i] * ds[i] % MOD) * (dt[i] * dt[i] % MOD) % MOD + MOD) % MOD;
	//cout << "res: " << res << endl;
	for (int i = 2; i <= te; i++)
	{
		int x = e[i].to, y = e[i ^ 1].to, c = e[i].c;
		if (2 * diss[x] < D && 2 * dist[y] < D && diss[x] + dist[y] + c == D)
			res = (res - (ds[x] * ds[x] % MOD) * (dt[y] * dt[y] % MOD) % MOD + MOD) % MOD;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 10096
#include<stdio.h>
int main() {
    int a, b, c, i;
    scanf("%d%d%d", &a, &b, &c);
    for(i = 1; i <= 1000; ++i) {
        if(i * a % b == c) return printf("YES"), 0;
    }
    return printf("NO"), 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#define ll long long
int main(){
    ll n,min,k,s,i;
    scanf("%lld",&n);
    min=n;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            k=n/i;
            s=k+i-2;
            if(min>s)
                min=s;
        }
    }
    if(min!=n)
        printf("%lld\n",min);
    else
        printf("%lld\n",n-1);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int n;

int main() {
  cin >> n;
  int d[n];
  rep(i, n) cin >> d[i];
  
  int ans = 0;
  rep(i, n) {
    for (int j = i+1; j < n; j++) { 
      ans += d[i] * d[j];
    }
  }
  
  cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();

		for (int i = 0; i < M; i++) {
			N = N - scan.nextInt();
		}

		if (N >= 0) {
			System.out.println(N);
		} else {
			System.out.println("-1");
		}
		scan.close();
	}
}


Measured memory_bytes: 46140
n = int(input())
a = []
for i in range(1, n + 1):
    cnt = 0
    flag = True
    j = i
    while flag:
        if i % 2 == 0:
            i //= 2
            cnt += 1
        else:
            flag = False
    a.append([j, cnt])
print(sorted(a,key=lambda x: x[1])[-1][0])


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<functional>
#include<algorithm>
using namespace std;

//文章が与えられた時、出現頻度の高い単語と最長の単語を出力するもの。
//文章に現れる単語リストを作ってそれぞれの文字列をカウントすればよい。

int main(){
	string sentence[1000];
	int sentenceNum[1000];
	int array[1000];
	string input;
	int count = 0;
	bool flag; //単語リストから単語が見つかったどうか
	int maxLength = 0;

	for(int i=0; i < 1000; i++) sentenceNum[i] = 0;

	while(cin >> input){
		flag = false;

		//count == 0 文頭の単語の処理
		if(!count){
			sentence[0] = input;
			sentenceNum[0]++;
			count++;
			int inputSize = input.size();
			maxLength = max(maxLength, inputSize);
		}

		//文頭でない場合
		else {
			for(int i=0; i < count; i++){
				if(sentence[i] == input){
					sentenceNum[i]++;
					flag = true;
					break;
				}
			}
			if(!flag){
				sentence[count] = input;
				sentenceNum[count]++;
				count++;
				int inputSize = input.size();
				maxLength = max(maxLength, inputSize);
			}
		}
	}

	for(int i=0; i < 1000; i++) array[i] = sentenceNum[i];

	sort(array, array+1000, greater<int>());

	for(int i=0; i< count; i++){
		if(array[0] == sentenceNum[i]){
			cout << sentence[i];
		}
	}
	for(int i=0; i< count; i++){
		int sentenceSize = sentence[i].size();
		if(maxLength == sentenceSize){
			cout << " " << sentence[i] << endl;
		}
	}
}

Measured memory_bytes: 1220
using System;
using System.Linq;

class B
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var b = Enumerable.Repeat(1, h[0] + 1).ToArray();
		var r = new bool[h[0] + 1];
		r[1] = true;
		foreach (var o in new int[h[1]].Select(_ => read()))
		{
			int i = o[0], j = o[1];
			b[i]--;
			b[j]++;
			if (r[i]) r[j] = true;
			if (b[i] == 0) r[i] = false;
		}
		Console.WriteLine(r.Count(x => x));
	}
}


Measured memory_bytes: 19920
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n;
	cin >> n;
	if(n % 2 == 0) cout << n << endl;
	else cout << n * 2 << endl;
	return 0;
}

Measured memory_bytes: 256
// AOJ 0189
#include<cstdio>
#include<algorithm>
#include<numeric>
#define rep(i,a) for( int i = 0; i != (a); ++i )

const int INF = 1 << 29;

int d[10][10];

int main()
{
	int n;
	while( scanf( "%d", &n ), n )
	{
		rep( i, 10 )
			rep( j, 10 )
				d[i][j] = i==j?0:INF;

		int v = 0;
		rep( i, n )
		{
			int a, b, c;
			scanf( "%d%d%d", &a, &b, &c );
			d[a][b] = d[b][a] = c;
			v = std::max( v, std::max( a, b ) );
		}

		rep( k, v+1 )
			rep( i, v+1 )
				rep( j, v+1 )
					d[i][j] = std::min( d[i][j], d[i][k]+d[k][j] );
	
		int ans = INF, id;
		rep( i, v+1 )
		{
			int s = std::accumulate( d[i], d[i]+v+1, 0 );

			if( ans > s )
				ans = s, id = i;
		}

		printf( "%d %d\n", id, ans );
	}

	return 0;
}

Measured memory_bytes: 1028
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//"strings"
	"math"
)

const (
	initialBufSize = 10000
	maxBufSize     = 100000 + 1024
)

func main() {

	scanner := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)

	scanner.Scan()
	n, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	scanner.Scan()
	a, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	scanner.Scan()
	b, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	scanner.Scan()
	c, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	scanner.Scan()
	d, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	scanner.Scan()
	e, _ := strconv.ParseInt(scanner.Text(), 10, 64)

	nums := []int64{a, b, c, d, e}
	m := min(nums...)
	fmt.Println(4+int64(math.Ceil(float64(n) / float64(m))))

}

func min(nums ...int64) int64 {
	ret := int64(math.MaxInt64)
	for _, n := range nums {
		if n < ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
#define N 50015
const int inf=20040322;
struct edge{int to,nxxt,len;ll co;}e[N<<3];
int n,m,a[N][2],head[N],cnt=2;
ll va[N],cost[N],ans;
char ch[3];
queue<int>q;
bool inq[N];
int b[N][3],lx[N],rx[N],ly[N],ry[N],S,T,flow[N],pre[N],la[N];
inline void ins(int u,int v,int w,ll c)
{e[cnt].to=v;e[cnt].len=w;e[cnt].co=c;e[cnt].nxxt=head[u];head[u]=cnt++;}
inline bool spfa()
{
	for(int i=1;i<=T;i++)inq[i]=0,flow[i]=inf,cost[i]=-1e18;pre[T]=-1;
	q.push(S);cost[S]=0;inq[S]=1;
	while(!q.empty())
	{
		int a1=q.front();q.pop();inq[a1]=0;
		for(int i=head[a1];i;i=e[i].nxxt)
		{
			int t1=e[i].to;
			if(cost[t1]<cost[a1]+e[i].co&&e[i].len)
			{
				cost[t1]=cost[a1]+e[i].co;
				flow[t1]=min(flow[a1],e[i].len);
				pre[t1]=a1,la[t1]=i;
				if(!inq[t1])inq[t1]=1,q.push(t1);
			}
		}
	}return pre[T]!=-1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d%lld",&a[i][0],&a[i][1],&va[i]);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%s",ch);
		if(ch[0]=='L')b[i][0]=0;
		else if(ch[0]=='R')b[i][0]=1;
		else if(ch[0]=='D')b[i][0]=2;
		else b[i][0]=3;
		scanf("%d%d",&b[i][1],&b[i][2]);
	}
	for(int k=1;k<=n;k++)
	{//printf("%d times\n",k);
		for(int i=1;i<=k;i++)lx[i]=ly[i]=0,rx[i]=ry[i]=inf;
		for(int i=1;i<=m;i++)
		{
			if(b[i][0]==0)for(int j=b[i][2]+1;j<=k;j++)lx[j]=max(lx[j],b[i][1]+1);
			else if(b[i][0]==1)for(int j=1;j<=k-b[i][2];j++)rx[j]=min(rx[j],b[i][1]-1);
			else if(b[i][0]==2)for(int j=b[i][2]+1;j<=k;j++)ly[j]=max(ly[j],b[i][1]+1);
			else for(int j=1;j<=k-b[i][2];j++)ry[j]=min(ry[j],b[i][1]-1);
		}bool flag=true;
		for(int i=1;i<=k;i++)if(lx[i]>rx[i]||ly[i]>ry[i]){flag=false;break;}
		if(!flag)continue;
		S=2*k+2*n+1,T=S+1;
		for(int i=1;i<=T;i++)head[i]=0;cnt=2;
		for(int i=1;i<=k;i++)
		{
			ins(S,2*n+i,1,0);ins(2*n+i,S,0,0);
			ins(2*n+k+i,T,1,0);ins(T,2*n+k+i,0,0);
			for(int j=1;j<=n;j++)
			{
				if(lx[i]<=a[j][0]&&a[j][0]<=rx[i])ins(2*n+i,j,1,0),ins(j,2*n+i,0,0);
				if(ly[i]<=a[j][1]&&a[j][1]<=ry[i])ins(n+j,2*n+k+i,1,0),ins(2*n+k+i,n+j,0,0);
			}
		}
		for(int i=1;i<=n;i++)ins(i,n+i,1,va[i]),ins(n+i,i,0,-va[i]);
		ll sum=0;
		while(spfa())
		{
			sum+=cost[T]*flow[T];
			int x=T;
			while(x^S){e[la[x]].len-=flow[T],e[la[x]^1].len+=flow[T],x=pre[x];}
		}
		ans=max(ans,sum);
	}printf("%lld\n",ans);
}


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

int main(){
    int n,counter=0;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(a[i]%2==0){
            if(a[i]%5!=0 && a[i]%3!=0){
                cout << "DENIED" << "\n";
                ++counter;
                break;
            }
        }
    }
    if(counter==0){
        cout << "APPROVED" << "\n";
    }
    return 0;
}

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

long pow(long x, int n) {
  int m = n;
  n = abs(n);
  long long res = 1;
  while (n) {
    if (n & 1) res *= x;
    x *= x;
    n >>= 1;
  }
  long ans =  (m >= 0) ? res : 1.0 / res;
  return ans;
}

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

  int n;
  cin >> n;
  cout << pow(2, floor(log2(n))) << '\n';
  return 0;
}

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

void print(long n){
    long nn = n/26;
    if(nn==0){
        cout << (char)('a'+(n%26));
        return;
    }
    print(nn-1);
    cout << (char)('a'+(n%26));
}

int main(){
    long in;
    cin >> in;
    print(in-1);
}

Measured memory_bytes: 3620