akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,m;
  cin >> n >> m;
  vector<long>a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  long ans = 0;
  vector<long>s(n);
  s[0] = a[0];
  for(i=1;i<n;i++){
    s[i] = s[i-1] + a[i];
  }
  set<long>ss;
  map<long,long>mm;
  for(i=0;i<n;i++){
    ss.insert(s[i]%m);
    mm[s[i]%m]++;
  }
  ans += mm[0];
  for(auto j:ss){
    if(mm[j]>=2){
      ans += mm[j]*(mm[j]-1)/2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001
typedef long long ll;

int n;
// int a;

// ll dp[51][51][2510];
// int a[114514];
vector<int> a;

// ll acc[114514];
// // char X[100][100];
// // int dp[1000000001];
// ll dp[114514];

ll acc[114514];
int main(void){
    cin >> n;
    REP(i,0,n) {
        int temp;
        cin >> temp;
        a.push_back(temp);
        // if (i >= 1) acc[i] = a[i] + acc[i-1];
        // else acc[i] = a[i];
    }
    
    sort(a.begin(),a.end());
    
    acc[0] = a[0];
    REP(i,1,n) {
        acc[i] = acc[i-1] + a[i];
    }
    
    int ans = 0;
    REP(i,0,n-1) {
        if (a[i+1] > 2 * acc[i]) {
            ans = i + 1;
        }
    }
    
    cout << n - ans << endl;
    // REP(i,0,n) {
    // //     cout << acc[i] << endl;
    // // }
    
    // ll ans1 = 0;
    // ll ans2 = 0;
    
    // ll s = 0;
    // REP(i,0,n) {
    //     s += a[i];
    //     if (i % 2 == 1 && s >= 0) {
    //         ans1 += s + 1;
    //         s = -1;
    //     }
    //     else if (i % 2 == 0 && s <= 0) {
    //         ans1 += 1 - s;
    //         s = 1;
    //     }
    // }
    
    // s = 0;
    // REP(i,0,n) {
    //     s += a[i];
    //     if (i % 2 == 0 && s >= 0) {
    //         ans2 += s + 1;
    //         s = -1;
    //     }
    //     else if (i % 2 == 1 &&  s <= 0) {
    //         ans2 += 1 - s;
    //         s = 1;
    //     }
    // }
    
    // cout << min(ans1,ans2) << endl;
 

}

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

int main()
{
  int n; cin >> n;
  int a[n];
  int count = 0;
  
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] % 2 == 1) count++;
  }
  
  if(count == 0) cout << "second" << endl;
  else cout << "first" << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, a, num[125252];
	cin>>n;
	REP(i, n){
		cin>>a;
		num[a-1]=i+1;
	}
	REP(i, n){
		cout<<num[i]<<" \n"[i==n-1];
	}
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<x2-(y2-y1)<<" "<<y2+(x2-x1)<<" "<<x1-(y2-y1)<<" "<<y1+(x2-x1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    ll k,t,a[100010],cnt,M,m;
    cin>>k>>t;
    rep(i,t) cin>>a[i];
    sort(a,a+t);
    M=a[t-1],m=k-M;
    if(M-m<=1 && M>=m){
        cout<<0<<endl;
    }
    else if(M>m){
        cout<<M-m-1<<endl;
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}


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

#define ff first
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

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



int main() {
	fastio();

	ll n, k, q; cin >> n >> k >> q;

	ll points[n + 1]; f(i, 1, n) points[i] = k;

	ll a[q + 1]; f(i, 1, q) cin >> a[i];

	ll m[n + 2] = {0};


	f(i, 1, q) {
		ll ind = a[i];

		if (ind == 1) {
			m[ind + 1] -= 1, m[n + 1] += 1;
		}

		else if (ind == n) {
			m[1] -= 1, m[ind] += 1;
		}

		else {
			m[ind + 1] -= 1, m[n + 1] += 1;
			m[1] -= 1, m[ind] += 1;
		}
	}

	f(i, 2, n) {
		m[i] += m[i - 1];
	}

	f(i, 1, n) {
		points[i] += m[i];
		if (points[i] > 0) cout << "Yes\n";
		else cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 2944
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
//#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

signed main (){
    int k;cin>>k;
    int a=0,b=0;
    rep(i,1,k+1){
        if(i%2==0)a++;
        else b++;
    }
    cout<<a*b<<endl;

    
}
/*
1-21-2
*/


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
const long Max = pow(10,2) + 1;
vector< vector<long> > p( Max, vector<long>(2, 0));
int main(){
    long q;
    cin >> q;
    long a,b,c;
    long res;
    for(int i=0; i<q; i++){
        cin >> p[i][0] >> p[i][1];
    }
    for( int i=0; i<q; i++){
        a = p[i][0];
        b = p[i][1];
        if( a > b){
            long tmp = a;
            a=b;
            b=tmp;
        }

        if( a == b){
            res = 2*a - 2;
        }else if( a+1 == b){
            res = 2*a - 2;
        }else{
            c = sqrt(a*b);
            if( c*c == a*b) c--;
            if( c*c+c >= a*b) res = 2*c-2;
            else res = 2*c-1;
        }
            cout << res <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> l(n);
  for(int i=0;i<n;i++)
    cin>>l.at(i);
  int c=0;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      for(int k=j+1;k<n;k++)
        if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]&&l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j])
          c++;
  cout<<c<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

vector<int> fun(ll a){
    vector<int> ret(41, 0);
    if(a == 0)
        return ret;
    ll curr = 1;
    for(ll i = 0; i < 41; i++){
        ll nxt = (curr << 1ll);
        ret[i] += (a / nxt * curr);
        ll to = (a % nxt);
        if(to >= curr) ret[i] += to - curr + 1;
        curr <<= 1ll;
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    ll a, b;
    cin>>a>>b;
    vector<int> ret = fun(b);
    vector<int> go = fun(a - 1);
//    f(i, 41){
//        cout<<ret[i]<<' ';
//    }
    f(i, 41) ret[i] -= go[i];
    ll ans = 0, curr = 1;
    f(i, 41){
        if(ret[i] & 1) ans += curr;
        curr <<= 1ll;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

h,w = map(int,input().split())
maze = [input() for _ in range(h)]
check = [[-1]*w for _ in range(h)]

def BFS(maze,check,si,sj):
    queue = deque([[si,sj]])
    check[si][sj] = 0
    maxd = 0
    while queue:
        x,y = queue.popleft()
        for k,l in ([0,1], [0,-1], [1,0], [-1,0]):
            i2, j2= x+k, y+l
            if i2<0 or i2>=h or j2<0 or j2>=w:
                continue
            if maze[i2][j2] == '.' and check[i2][j2] == -1:
                check[i2][j2] = check[x][y] + 1
                maxd = max(maxd,check[i2][j2])
                queue.append([i2,j2])
    return maxd

ans = 0
for i in range(h):
    for j in range(w):
        check = [[-1]*w for _ in range(h)]
        if maze[i][j] == '.':
            si , sj = i, j
            ans = max(ans,BFS(maze,check,si,sj))
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
int main(){
	int i,n,k,q,question,check;
	scanf("%d%d%d",&n,&k,&q);
	int a[n+1];
	for(i=0;i<n;i++)
		a[i]=0;
	for(i=0;i<q;i++){
		scanf("%d",&question);
		a[question-1]++; 
	}
	for(i=0;i<n;i++){
		check=k-(q-a[i]);
		if(check>0)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
} 

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
int a[100];

int main() {
	cin >> N;
	rep(i, N) cin >> a[i];

	int ret = 200 * 200 * 1000;
	for(int x = -100; x<= 100; x++){
		int r = 0;
		rep(i, N) r += (a[i] - x) * (a[i] - x);
		ret = min(ret, r);
	}

	cout << ret << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;

int main()
{
  ll N;cin>>N;
  ll wari = pow(10, 9)+7;
  ll power = 1;

  for(ll i = 1; i < N+1; i ++) {
    power *= i;
    power %= wari;
  }

  cout << power << endl;
  return 0;
}

Measured memory_bytes: 3544
def build_stairs(n, h)
  h[0] -= 1
  1.upto(n - 2) do |i|
    if h[i - 1] < h[i]
      h[i] -= 1
    end
    return 'No' if h[i] > h[i + 1]
  end
  'Yes'
end

n = gets.chomp.to_i
h = gets.split.map(&:to_i)
puts build_stairs(n, h)

Measured memory_bytes: 8580
import numpy as np

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

N =  int(input())

for line in range(N):
	b=int(input())
	for a in range(3):
		for a_1 in range(3):
			if A[a][a_1]==b:
				A[a][a_1]=0
ans=[]
A_r=np.array(A).T.tolist()
ANS="No"
for k in range(3):
	if sum(A[k])==0 or sum(A_r[k])==0:
		ANS="Yes"
		break

if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
	ANS="Yes"
if A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
	ANS="Yes"

print(ANS)



Measured memory_bytes: 12504
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1000000007;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

void solve(){
    ll n,m;
    cin >> n >> m;
    cout << (3*n+m)/2 << ln;
}


int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve();
    return 0;
}

Measured memory_bytes: 256
a = [list(map(int, input().rstrip().split())) for _ in range(3)]
c = [[0]*3 for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for x in b:
  for i in range(3):
    for j in range(3):
      c[j][i] = c[j][i] or (a[j][i] == x)

bingo = 0
for j in range(3):
  bingo = bingo or all(c[j])
for i in range(3):
  bingo = bingo or all([c[j][i] for j in range(3)])

bingo = bingo or all([c[i][i] for i in range(3)]) or all([c[i][2-i] for i in range(3)])

if bingo:
  print("Yes")
else:
  print("No")

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

#define all(a) (a).begin(), (a).end()

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

int main(){
	int n;
	cin>>n;
	int a[100002];

	a[0]=0;
	a[n+1]=0;
	ll total=0;
	for (int i = 1; i <= n; ++i){
		cin>>a[i];
		total+=abs(a[i-1]-a[i]);
	}
	total+=abs(a[n]-a[n+1]);

	for (int i = 1; i <= n; ++i){
			cout<<total+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))<<endl;
		}	

}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	long long K, S;
	long long counter = 0;
	cin >> K >> S;
 
	for (int X = 0; X <= K; X++) {
		for (int Y = 0; Y <= K; Y++) {
			if (S - X - Y <= K && S - X - Y >= 0) {
				counter++;
			}
		}
	}
 
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
  d = []
  for j in range(M):
    d.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]))
  print(d.index(min(d)) + 1)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

string dir = "RDLU";

bool solve(int curr, int d, vector<vector<int> >& neighbor, int n, string& ret)
{
    if(n == 1)
        return true;

    for(int i=0; i<4; ++i){
        if((i ^ 2) == d)
            continue;

        int next = neighbor[curr][i];
        if(next == -1)
            continue;

        for(int j=0; j<4; ++j){
            if(neighbor[curr][j] != -1)
                neighbor[neighbor[curr][j]][j^2] = neighbor[curr][j^2];
        }
        ret += dir[i];

        if(solve(next, i, neighbor, n-1, ret))
            return true;

        ret.resize(ret.size() - 1);
        for(int j=0; j<4; ++j){
            if(neighbor[curr][j] != -1)
                neighbor[neighbor[curr][j]][j^2] = curr;
        }
    }

    return false;
}

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> s(h, string(w, ' '));
    vector<vector<int> > index(h, vector<int>(w, -1));
    int n = 0;
    int start, sd;
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            cin >> s[y][x];
            if(s[y][x] == 'o'){
                index[y][x] = n;
                ++ n;
            }else if(isalpha(s[y][x])){
                index[y][x] = n;
                start = n;
                ++ n;
                if(s[y][x] == 'R')
                    sd = 0;
                else if(s[y][x] == 'D')
                    sd = 1;
                else if(s[y][x] == 'L')
                    sd = 2;
                else
                    sd = 3;
            }
        }
    }

    vector<vector<int> > neighbor(n, vector<int>(4, -1));
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            if(index[y][x] == -1)
                continue;

            for(int i=0; i<4; ++i){
                int y2 = y;
                int x2 = x;
                do{
                    y2 += dy[i];
                    x2 += dx[i];
                }while(0 <= y2 && y2 < h && 0 <= x2 && x2 < w && index[y2][x2] == -1);

                if(0 <= y2 && y2 < h && 0 <= x2 && x2 < w)
                    neighbor[index[y][x]][i] = index[y2][x2];
            }
        }
    }

    string ret;
    solve(start, sd, neighbor, n, ret);
    cout << ret << endl;

    return 0;
}

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

using namespace std;

int
main(void){
	char a; cin >> a;
	if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'){
		cout << "vowel";
	}
	else cout << "consonant";
}

Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
kosuu = [0]*N
for i in range(N):
    kosuu[D[i]] += 1
if D[0] != 0 or kosuu[0] != 1:
    print(0)
    exit()
ans = 1
for i in range(1,N):
    ans = (ans * kosuu[D[i]-1]) % 998244353
print(ans)

Measured memory_bytes: 14396
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main(void)
{
	int a,b,mx;
	double v;
	scanf("%d %d",&a,&b);
	mx=max(a,b);
	v=4.0/3.0*M_PI*mx*mx*mx;
	printf("%lf\n",v);
	return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,k;
  cin >> n >> k;
  if(k>(n-2)*(n-1)/2) {
    cout << -1 << endl;
    return 0;
  }
  LL ans = n*(n-1)/2 - k;
  cout << ans << endl;
  for(LL i=n;i>0;--i) {
    FOR(j,1,i) {
      if(!ans) return 0;
      cout << i << " " << j << endl;
      --ans;
    }
  }
  return 0;
}


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

int main() {
  int a,b,c,d,e,f;
  scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
  a*=100;
  b*=100;

  set<int> se_s,se_w;
  for (int i=0; c*i<=f; i++) {
    for (int j=0; c*i+d*j<=f; j++) {
      se_s.insert(c*i+d*j);
    }
  }
  for (int i=0; a*i<=f; i++) {
    for (int j=0; a*i+b*j<=f; j++) {
      if (i+j==0) continue;
      se_w.insert(a*i+b*j);
    }
  }
  
  int ans_w=a,ans_s=0,water,suger,n=se_w.size();
  set<int>::iterator it_s=se_s.begin(),it_w=se_w.begin();
  for (int i=0; i<n; i++) {
    while (*it_s*100<=*it_w*e&&*it_s+*it_w<=f) {
      it_s++;
    }
    it_s--;
    if (ans_s*(*it_w+*it_s)<(ans_s+ans_w)*(*it_s)) {
      ans_s=*it_s;
      ans_w=*it_w;
    }
    it_w++;
  }

  printf("%d %d\n",ans_w+ans_s,ans_s);
  return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))

a2 = {}
for i in a:
    a2.setdefault(i, 0)
    a2[i] += 1
for i in a2.keys():
    a2[i] = (a2[i] - 1) % 2 + 1
total = sum(a2.values())
num = list(a2.values()).count(2)
total -= ((num - 1) // 2 + 1) * 2
print(total)

Measured memory_bytes: 18272
// 時間計算量の見積もりが出来ません
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

int v[9][9], win[9], lose[9];
int ans, n;

void dfs(int i, int j){
    while(i == j || v[i][j] != 0){
        j++;
        if(j == n)  i++, j = 0;
        if(i == n){
            ans++;
            return;
        }
    }
    if(win[i]+1 <= n/2 && lose[j]+1 <= n/2){
        v[i][j] = 1; v[j][i] = -1;
        win[i]++;   lose[j]++;
        dfs(i, j);
        win[i]--;   lose[j]--;
        v[i][j] = v[j][i] = 0;
    }
    swap(i, j);
    if(win[i]+1 <= n/2 && lose[j]+1 <= n/2){
        v[i][j] = 1; v[j][i] = -1;
        win[i]++;   lose[j]++;
        dfs(j, i);
        win[i]--;   lose[j]--;
        v[i][j] = v[j][i] = 0;
    }
}

int main(){
    while(cin >> n, n){
        memset(v, 0, sizeof(v));
        memset(win, 0, sizeof(win));
        memset(lose, 0, sizeof(lose));
        int m;
        cin >> m;
        bool ini = true;
        while(m-- > 0){
            int x, y;
            cin >> x >> y;
            x--, y--;
            v[x][y] = 1; v[y][x] = -1;
            win[x]++, lose[y]++;
            ini &= win[x] <= n/2 && lose[y] <= n/2;
        }
        if(!ini){
            cout << 0 << endl;
            continue;
        }
        ans = 0;
        dfs(0, 0);
        cout << ans << endl;
    }
    return 0;
}


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

const ll INF = 1LL << 60;

ll N;
vector<ll> A;
int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) {
        cin >> A[i];
    }

    multiset<ll> st;
    rep(i, N) {
        // auto iter = lower_bound(st.begin(), st.end(), A[i]);
        auto iter = st.lower_bound(A[i]);

        if (iter == st.begin()) {
            st.insert(A[i]);
        } else {
            // 置き換え
            iter--;
            st.erase(iter);

            st.insert(A[i]);
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll labs(ll x){
	if(x<0LL)return -x;
	return x;
}

int zcnt(ll x){
	int cnt=0;
	while(x>0){
		x/=10LL;
		cnt++;
	}
	return cnt;
}

ll n,m,a,b,p,q;
ll num[51];
vector<ll> vec;

int main(void){
	scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&a,&b,&p,&q);
	if(a==1LL && b==1LL){
		ll dist=p+q;
		ll cnt=m/dist;
		printf("%lld\n",min(labs(m-min(cnt,n)*dist),labs(m-(min(cnt+1LL,n))*dist)));
	}else{
		ll v=0;
		ll np=p,nq=q;
		while(np+nq<=m){
			num[v]=np+nq;
			if(zcnt(np)+zcnt(a)>=zcnt(m)+4 || zcnt(nq)+zcnt(b)>=zcnt(m)+4)break;
			np*=a;
			nq*=b;
			v++;
		}
		num[v]=np+nq;
		v++;
		ll res=m;
		v=min(v,n);
		if(v==0){
			res=min(res,labs(m-p-q));
			printf("%lld\n",res);
			return 0;
		}
		int v2=(int)v/2;
		for(int bit=0;bit<(1<<v2);bit++){
			ll now=0;
			for(int i=0;i<v2;i++){
				if((bit>>i) & 1){
					now+=num[i];
				}
			}
			vec.push_back(now);
		}
		sort(vec.begin(),vec.end());
		vec.erase(unique(vec.begin(),vec.end()),vec.end());
		int v3=v-v2;
		for(int bit=0;bit<(1<<v3);bit++){
			ll now=0;
			for(int i=0;i<v3;i++){
				if((bit>>i) & 1){
					now+=num[i+v2];
				}
			}
			int l=lower_bound(vec.begin(),vec.end(),m-now)-vec.begin();
			if(l<vec.size())res=min(res,labs(m-now-vec[l]));
			if(l>0 || l==vec.size()){
				res=min(res,labs(m-now-vec[l-1]));
			}
		}
		printf("%lld\n",res);
	}
	return 0;
}

Measured memory_bytes: 11200
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			double v = sc.nextDouble();
			for(int i=1; ; i++)
				if(98*(i-1) >= v*v){
					System.out.println(i);
					break;
					}
			}

	}

}

Measured memory_bytes: 11000
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#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,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int m, f, r;
    while (cin >> m >> f >> r, m != -1 || f != -1 || r != -1) {
        if (m == -1 || f == -1) puts("F");
        else {
            int sum = m + f;
            if (sum >= 80) puts("A");
            else if (sum >= 65) puts("B");
            else if (sum >= 50) puts("C");
            else if (sum >= 30) {
                if (r >= 50) puts("C");
                else puts("D");
            } else puts("F");
        }
    }
}



Measured memory_bytes: 3096
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e+5+5;

int n,m;
int pre[N],suf[N];
int pc[N],sc[N];
int pv[N];

int main(){
	n=get();m=get();
	fo(i,1,n){
		int l=get(),r=get();
		pre[l]++,pre[r]++;
		suf[l]++,suf[r]++;
		pc[r]++,sc[l]++;
	}
	pv[0]=pre[0]-pc[0];
	fo(i,1,m){
		pre[i]+=pre[i-1];
		pc[i]+=pc[i-1];
		pv[i]=max(pv[i-1],pre[i]-i-pc[i]);
	}
	int ans=max(ans,suf[m+1]+pv[m]);
	fd(i,m,1){
		suf[i]+=suf[i+1];
		sc[i]+=sc[i+1];
		ans=max(ans,pv[i-1]+suf[i]-sc[i]-(m-i+1));
	}
	ans-=n;
	ans=max(ans,n-m);
	ans=max(ans,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static int two(int a) {
		int tmp = a;
		int cnt = 0;
		while(tmp % 2 == 0) {
			tmp /= 2;
			++cnt;
		}
		return cnt;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int min = 30;
		for(int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			int tmp = two(a[i]);
			min = Math.min(min,  tmp);
		}
		sc.close();
		System.out.println(min);
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[5];
  int k;

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

  cin >> k;

  if(a[4] - a[0] <= k){
	cout << "Yay!" << endl;
  }else{
	cout << ":(" << endl;
  }
  return 0;
}

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

#define N 1001

struct Node {
    int x,y;
};
deque<Node>q;
int sx,sy,tx,ty;
int n,m,dis[N][N];
int dx[4]= {1,-1,0,0};
int dy[4]= {0,0,1,-1};

char str[N][N],vis[N][N];

int main(void) {
    int i,dir,j;
    Node x,y;
    memset(dis,0x3f,sizeof dis);
    scanf("%d%d%d%d%d%d",&n,&m,&sx,&sy,&tx,&ty);
    for(i=1; i<=n; ++i)
		scanf("%s",str[i]+1);
    q.push_back({sx,sy});
	dis[sx][sy]=0;
    while(!q.empty()) {
        x=q.front();
		q.pop_front();
        if(vis[x.x][x.y])continue;
        vis[x.x][x.y]=1;
        for(dir=0; dir<4; ++dir) {
            y= {x.x+dx[dir],x.y+dy[dir]};
            if(y.x&&y.x<=n&&y.y&&y.y<=m&&str[y.x][y.y]^'#'&&dis[y.x][y.y]>dis[x.x][x.y])
				dis[y.x][y.y]=dis[x.x][x.y],q.push_front(y);
        }
        for(i=-2; i<=2; ++i) {
            for(j=-2; j<=2; ++j) {
                y= {x.x+i,x.y+j};
                if(y.x>=1&&y.x<=n&&y.y>=1&&y.y<=m&&str[y.x][y.y]^'#'&&dis[y.x][y.y]>dis[x.x][x.y]+1)
					dis[y.x][y.y]=dis[x.x][x.y]+1,q.push_back(y);
            }
        }
    }
    printf("%d\n",dis[tx][ty]^0x3f3f3f3f?dis[tx][ty]:-1);
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }

    int cnt = 0;
    for (int i = 0; i < m; i++) {
        if (a[i] < x) cnt++;
    }

    cout << min(cnt, m-cnt) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)cout << s;
	else cout << "red";
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val h = readLine.split(" ").map(_.toInt)

  val dp = Array.fill[Int](n)(Int.MaxValue)
  dp(0) = 0
  dp(1) = math.abs(h(1) - h(0))
  for (i <- 2 to n - 1) {
    val d1 = dp(i - 1) + math.abs(h(i - 1) - h(i))
    val d2 = dp(i - 2) + math.abs(h(i - 2) - h(i))
    dp(i) = math.min(d1, d2)
  }

  println(dp(n - 1))
}


Measured memory_bytes: 40096
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

fac = [0] * 8
fac[1] = 1
for i in range(2, N):
    fac[i] = i * fac[i - 1]

a = 0
l = list(range(1, N + 1))
for i in range(N):
    a += l.index(P[i]) * fac[len(l) - 1]
    l.remove(P[i])

b = 0
l = list(range(1, N + 1))
for i in range(N):
    b += l.index(Q[i]) * fac[len(l) - 1]
    l.remove(Q[i])

print(abs(a - b))


Measured memory_bytes: 3064
n=int(input())
k=int(input())

def f(n,k):
    l=[int(i) for i in str(n)]
    if n<100000:
        cnt=0
        for i in range(1,n+1):
            s=str(i)
            if len(s)-s.count('0')==k:
                cnt+=1
        return cnt
    else:
        if k==1:
            cnt=(len(l)-1)*9
            cnt+=l[0]
        elif k==2:
            cnt=(len(l)-1)*(len(l)-2)//2*9*9
            cnt+=(l[0]-1)*(len(l)-1)*9
            cnt+=f(n-10**(len(l)-1)*l[0],1)
        elif k==3:
            cnt=(len(l)-1)*(len(l)-2)*(len(l)-3)//6*9*9*9
            cnt+=(l[0]-1)*(len(l)-1)*(len(l)-2)//2*9*9
            cnt+=f(n-10**(len(l)-1)*l[0],2)
        return cnt
print(f(n,k))

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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll temp,n,i;
	map<int,int> mp;
	cin >> n;
	for(i=2;i<=n;i++)
	{
		cin >> temp;
		mp[temp]++;
	}
	for(i=1;i<=n;i++)
	{
		cout << mp[i] << endl;
	}
}

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

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

    for (int i=0; i < 3; i++) {
        if (n[i] == '1') n[i] = '9';
        else if (n[i] == '9') n[i] = '1';
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
#include<random>
 
using namespace std;

int partition(vector<int>::iterator b, vector<int>::iterator e) {
	int i{ 1 };
	int j{ e - b - 1 };
	int x = *b;
	while (true) {
		while (b[i] <= x && i<j) i++;
		while (b[j] > x) j--;
		if (j <= i) break;
		swap(b[i], b[j]);
	}
	swap(b[0], b[j]);
	return j;
}


int select(vector<int>::iterator b, vector<int>::iterator e,int i) {
	sort(b, e);
	return b[i];
/*
    int mine = *min_element(b, e);
	int maxe = *max_element(b, e);
	if (i == 0||mine== maxe) return mine;
	if (i == e - b - 1) return maxe;
	int j = partition(b, e);
	if (i == j) return b[j];
	if (i < j) return select(b, b + j, i);
	else return select(b + j + 1, e, i - j - 1);
	*/
}




int main() {	
	int n;
	cin >> n;
	vector<int> a;
	int k;
	for (int i = 1; i <= n; i++) {
		cin >> k;
		a.push_back(k - i);
	}
	mt19937 get_rand_mt;
    shuffle( a.begin(), a.end(), get_rand_mt );
	int med = select(a.begin(), a.end(), n / 2);
	long long ans{ 0 };
	for (auto e : a) {
		ans += abs(e - med);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define per(i,a,b) for(int i = (a);i >= (b);i--)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,a[maxn],sum;
void solve(){
	rep(i,1,n){
		int tmp = sum ^ a[i];
		cout << tmp << " ";
	}
	cout << endl;
	return;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	cin >> a[1];
	sum = a[1];
	rep(i,2,n){
		cin >> a[i];
		sum ^= a[i];	
	}
	solve();		
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 4336
#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
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const ll inf = 1e17 + 7, MOD = 1e7 + 9;


int main() {
	fastio();
	ll a;
	cin >> a;
	string b;
	cin >> b;
	stringstream s1(b.substr(0, b.length()-3));
	stringstream s2(b.substr(b.length()-2, 2));
	int b_whole = 0, b_frac = 0;
	s1 >> b_whole;
	s2 >> b_frac;
	int b100 = b_whole * 100 + b_frac;
	ll ans = (a * b100) / 100;
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 3660
#include <stdio.h>
int main(void){
   int n, m, i, j;
   scanf("%d %d", &n, &m);
   int a[100][100];
   int b[100];
   int c[100] = {0};
   
   for(i=0; i<n; i++){
       for(j=0; j<m; j++){
           scanf("%d", &a[i][j]);
       }
   }
   for(j=0; j<m; j++){
       scanf("%d", &b[j]);
   }
   for(i=0; i<n; i++){
       for(j=0; j<m; j++){
           c[i]+=a[i][j]*b[j];
       }
       printf("%d\n", c[i]);
   }
   //printf("\n");
   return 0;
}


Measured memory_bytes: 2128
k,n=map(int,input().split())
arr=list(map(int,input().split()))
ans=10**18
for i in range(n):
  dist1=(arr[i-1]-arr[i])%k
  dist2=(arr[i]-arr[(i+1)%n])%k
  ans=min(ans,dist1,dist2)
print(ans)

Measured memory_bytes: 26420
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    set<int> s;
    int ans = 0;
    map<int, int> cnt;
    forn(i, n){
        cin >> a[i];
        s.insert(a[i]);
        cnt[a[i]]++;
    }
    forn(i, n){
        if (cnt[a[i]] > 1) continue;
        if (a[i] == 1){
            ans++;
            continue;
        }
        bool flag = true;
        for (int j = 1; j * j <= a[i]; ++j){
            if (a[i] % j == 0){
                if (s.count(j) || (j > 1 && s.count(a[i] / j))){
                    flag = false;
                    break;
                }
            }
        }
        if (flag) ans++;
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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

int main() {
    stack<ll> s1;
    string word;
    while( cin >> word ) {
        if ( (int) word.length() == 1 && !isdigit( word[0] ) ) {
            ll first = s1.top(); s1.pop();
            ll second = s1.top(); s1.pop();

            if ( word == "+" ) s1.push( first + second );
            else if ( word == "-" ) s1.push( second - first );
            else if ( word == "*" ) s1.push( second * first );
        } else {
            s1.push ( atoi(word.c_str()) );
        }
    }

    cout << s1.top() << endl;
    return 0;
}



Measured memory_bytes: 3084
def DecimalNumber(n, k):  # nをk進法にする
    bi = ''
    while n != 0:
        bi += str(n % abs(k))
        if k < 0:
            n = -(-n // k)
        else:
            n = n // k
    return bi[::-1]


def resolve():
    n, k = map(int, input().split())
    print(len(DecimalNumber(n, k)))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll h;//,n;
        cin>>h;
        // cout<<log2(h)<<"\n";
        ll x = (ll)(log2(h)+1);
        // cout<<x<<"\n";
        ll ans= (1<<x) - 1;
        cout<<(ll)pow(2,x)-1<<"\n";
        // cout<<ans;
    }
	return 0;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin >> n;
		int freq[n+1] = {};
		rep(i,0,n){
			int t;
			cin >> t;
			freq[t]++;
		}
		if(n%2==0){
			int sum = 0;
			for(int j = 1; j <= n-1; j+=2){
				sum += freq[j];
				if(freq[j]!=2){
					cout << 0;
					r0;
				}
			}
			if(sum!=n){
				cout << 0;
				r0;
			}
			else{
				cout << power(2, n/2, M);
			}
		}
		else{
			int sum = 0;
			for(int j = 0; j <= n-1; j+=2){
				sum += freq[j];
				if(freq[j]!=2 and j){
					cout << 0;
					r0;
				}
				else if(freq[j]!=1 and j==0){
					cout << 0;
					r0;
				}
			}
			if(sum!=n){
				cout << 0;
				r0;
			}
			else{
				cout << power(2, n/2, M);
			}
		}
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;

long long Sum[100005],A[100005];

long long extra(int poz, int len, int init)
{
    return (Sum[poz]-Sum[poz-len])-1LL*len*init;
}

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

	int n,m,v,p;
    cin>>n>>m>>v>>p;
    for(int i=1; i<=n; i++)
        cin>>A[i];

    sort(A+1,A+n+1);

    for(int i=1; i<=n; i++)
        Sum[i]=Sum[i-1]+A[i];

    int rez=0;
    int ind=1;
    for(int i=1; i<=n; i++)
    {
        while(A[ind+1]<=A[i]+m && ind+1<=n)
            ind++;

        if(n-ind+1>p)
            continue;

        long long cr=1LL*(i-1)*m+1LL*(n-ind+1)*m+1LL*(ind-i)*(A[i]+m)-(Sum[ind]-Sum[i]);
        long long total=1LL*m*v;
        if(cr>=total)
        {
            rez++;
            continue;
        }

        int add=0;
        for(int j=16; j>=0; j--)
            if(ind-(add+(1<<j))+1>i && cr+extra(ind,add+(1<<j),A[i])<total)
                add+=(1<<j);

        add++;
        if(n-ind+1+add<=p)
            rez++;
    }
    cout<<rez<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if ( a + b >= c ) printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,i=1;
    cin>>a>>b;
    c=b;
    while(c){
        c/=10;
        i*=10;
    }
    d=sqrt(a*i+b);
    if(d*d-a*i-b) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#problem C

import math

gcd = 0
gcd1 = 0
gcd2 = 0
gcd3 = 0

input_d31 = input()
K = int(input_d31)

gcd1 = sum(range(1,K+1))

for i in range(1,K+1):
    for j in range(i+1,K+1):
        gcd2 += math.gcd(i,j)
            
for i in range(1,K+1):
    for j in range(i+1,K+1):
        gcdd = math.gcd(i,j)
        for k in range(j+1,K+1):
            gcd3 += math.gcd(gcdd,k)
            
gcd = gcd1 + gcd2*6 + gcd3*6
            
print(gcd)


Measured memory_bytes: 9204