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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll N ; cin >> N;
   Vi a(N); ll sum = 0;
   REP(i, N) {cin >> a[i]; sum += a[i];}
   Vi b(N + 1, 0);
   REP(i, N) b[i + 1] = b[i] + a[i];
   REP(i, N + 1) b[i] = abs(b[i] * 2 - sum);
   ll ans = INF;
   REP(i, N - 1) chmin(ans , b[i + 1]);
   cout << ans << endl;

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  	int i,flag=0;
	string s;
  	cin>>s;
  	int n=s.length();
  	
  	if(s[0]=='A' && (s[1]-'0')>=('a'-'0') &&(s[n-1]-'0')>=('a'-'0')){
		for(i=2;i<n-1;i++){
          	if(s[i]=='C'){
              flag++;
            }else if((s[1]-'0')<('a'-'0')){
              flag+=2;
            }
        }
    }



  	if(flag==1){
		cout<<"AC"<<endl;
    }else{
		cout<<"WA"<<endl;

    }
}



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

int main() {
  int f=0, g=0;
  string S,T;
  cin>>S;
  T=S;
  for(int i=1;i<S.size();i++){
    if(S.at(i)!=S.at(i-1)) continue;
    else if(S.at(i)=='0') {
      S.at(i)='1';
      f++;
    }
    else{
     S.at(i)='0';
      f++;
    }
  }
  reverse(T.begin(), T.end());
  for(int i=1;i<T.size();i++){  
    if(T.at(i)!=T.at(i-1)) continue;
    else if(T.at(i)=='0') {
      T.at(i)='1';
      g++;
    }
    else{
     T.at(i)='0';
      g++;
    }
  }
    cout<<min(f, g)<<endl;
} 

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

	int m, k;
	cin >> m >> k;

	if (m == 1 and k == 1) {
		cout << "-1\n";
		return 0;
	}

	if (0 <= k and k < (1<<m)) {
		if (k == 0) {
			for (int i = 0; i < (1<<m); i++) {
				cout << i << " " << i << " ";
			}
		} else {
			for (int i = (1<<m) - 1; i >= 0; i--) {
				if (i == k) {
					continue;
				}
				cout << i << " ";
			}
			cout << k << " ";
			for (int i = 0; i < (1<<m); i++) {
				if (i == k) {
					continue;
				}
				cout << i << " ";
			}
			cout << k << "\n";
		}
	} else {
		cout << "-1\n";
	}

    return 0;
}

Measured memory_bytes: 1792
//*********************Cr!TikaL**********************//
//*****|||||******|||||*******||||||******|||||*****//

#include<iostream>
#include<algorithm>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define endl "\n"
#define si(x)    scanf("%d",&x)
#define sl(x)    scanf("%lld",&x)
#define ss(s)    scanf("%s",s)
#define pi(x)    printf("%d\n",x)
#define pl(x)    printf("%lld\n",x)
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define rep(qqq,ttt,www) for(int qqq = ttt; qqq < www; qqq++)
#define repe(qqq,ttt,www) for(int qqq = ttt; qqq <= www; qqq++)
#define rev(qqq,ttt,www) for(int qqq = www; qqq > 0; qqq--)
#define reve(qqq,ttt,www) for(int qqq = www; qqq >= 0; qqq--)

#define setp(x,y) cout << setprecision(x) << y << endl
#define deb(x) cout << #x << " --- " << x << endl
#define TT template<class T
#define Tt template<typename... T

Tt> void read(T&... a){((cin >> a), ... );}
Tt> void write(T&... a){((cout << a << " "), ... );cout << endl;}

ll getInt(string s){stringstream ss;ss << s;int p;ss >> p;return p;}
string getStr(long long int a){stringstream ss;ss << a;string s;ss >> s;return s;}
TT> T inline min(T& a,T& b){if( a <= b)return a;else return b;}
TT> T inline max(T& a,T& b){if( a >= b)return a;else return b;}
TT> T inline min3(T& a,T& b,T& c){if (a <= b && a <= c)return a;else if (b <= a && b <= c)return b;else return c;}
TT> T inline max3(T& a,T& b,T& c){if (a >= b && a >= c)return a;else if (b >= a && b >= c)return b;else return c;}

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18;


int main()
{

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a,b,c;

    cin >> a >> b >> c;

    if(a%b == 0)
    {
        cout << (a/b)*c << endl;
    }
    else
    {
        cout << ((a/b)+1)*c << endl;
    }


    return 0;

}


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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int h,w;
vector<string> v;
int sx,sy,dx,dy;
int dis[1005][1005];
const int INF=1e9;

int using_dijkstra(){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)dis[i][j]=INF;
    }
    dis[sx][sy]=0;
    priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pq;
    auto legal=[&](int r,int c)->bool{
        if(r<0 || c<0 || r>=h || c>=w || v[r][c]=='#')return 0;
        return 1;
    };
    pq.push({0,{sx,sy}});
    while(sz(pq)){
        int x=pq.top().second.first;
        int y=pq.top().second.second;
        pq.pop();
        for(pair<int,int> P:vector<pair<int,int>>({{x,y+1},{x,y-1},{x+1,y},{x-1,y}})){
            if(legal(P.first,P.second)){
                if(dis[x][y]<dis[P.first][P.second]){
                    dis[P.first][P.second]=dis[x][y];
                    pq.push({dis[P.first][P.second],{P.first,P.second}});
                }
            }
        }
        for(int i=x-2;i<=x+2;i++){
            for(int j=y-2;j<=y+2;j++){
                if(legal(i,j)){
                    if(dis[x][y]+1<dis[i][j]){
                        dis[i][j]=dis[x][y]+1;
                        pq.push({dis[i][j],{i,j}});
                    }
                }
            }
        }
    }
    return dis[dx][dy]==INF?-1:dis[dx][dy];
}

void solve()
{
    cin>>h>>w;
    cin>>sx>>sy>>dx>>dy;
    --sx;--sy;--dx;--dy;
    v.resize(h);
    for(auto &x:v)cin>>x;
    cout<<using_dijkstra()<<"\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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


int main() {
  int n, m;
  int a[50], b[50];
  scanf("%d %d", &n, &m);
  int i;
  for (i = 0; i	< m; i++)
    scanf("%d %d", &a[i], &b[i]);
  int count = 0;
  int j;
  for (i = 1; i <= n; i++) {
    for (j = 0;	j < m; j++) {
      if (a[j]	== i ||	b[j] ==	i)
	count++;
    }
    printf("%d\n", count);
    count = 0;
  }
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 500005
using namespace std;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int n, L;
double t[N], v[N];
int q[N], h, b;

int main(){
	n = read(), L = read();
	for(int i = 1; i <= n; i++)
		scanf("%lf%lf", t + i, v + i), t[i] *= v[i];
	h = 1; b = 0;
	double Sv = 0, St = 0;
	for(int j, i = 1; i <= n; i++){
		double left = L - v[i];
		for(j = q[h]; h <= b && Sv > left ; j = q[++h]){
			Sv -= v[j];
			St -= t[j];
			if(Sv < left){
				double c = (left - Sv) / v[j];
				Sv += (v[j] *= c);
				St += (t[j] *= c);
				break;
			}
		}
		printf("%.10lf\n", (St + t[i]) / L);
		double t0 = t[i], v0 = v[i];
		for(j = q[b]; h <= b && t[j] / v[j] >= t0 / v0; j = q[--b]){
			t0 += t[j];
			v0 += v[j];
		}
		q[++b] = i;
		St += t[i]; t[i] = t0;
		Sv += v[i]; v[i] = v0;
	}
}


Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i, a, b) for(int i = a; i < b; i++)

int main(){
    int N; cin >> N;
    vector<pii> P(N+1), K(N+1);
    vector<double> CM(N+1);
    rep(i, 1, N+1) cin >> P[i].first >> P[i].second;
    rep(i, 1, N + 1) K[i] = {P[i].first, i};
    CM[0] = 1;
    rep(i, 1, N +1) CM[i] = (100.0 - P[i].second *10) / 100.0 * CM[i-1];
    int Q; cin >> Q;
    vector<pii> query(N);
    rep(i, 0, Q) cin >> query[i].first >> query[i].second;

    rep(i, 0, Q){
        int L = query[i].first, R = query[i].second;

        auto it1 = lower_bound(K.begin(), K.end(), make_pair(L,0));
        auto it2 = lower_bound(K.begin(), K.end(), make_pair(R,0));
        it1--,it2--;
        cout << fixed << setprecision(10) << 1e9 * CM[(*it2).second]  / CM[(*it1).second]  << endl;
    }
    
}


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

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	x,a= map(int, io().split())
	return 0 if x < a else 10

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))
	

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

using namespace std;

int main(){
    int n,m,p,t;
    while(true){
        cin>>n>>m>>t>>p;
        if(n==0&&m==0&&t==0&&p==0){
            break;
        }
        int d,c,x,y;
        int pp[40][40];
        for(int i=0;i<m;++i){
            for(int j=0;j<n;++j){
                pp[i][j]=1;
            }
        }
        int h=m,w=n;
        for(int i=0;i<t;++i){
            cin>>d>>c;
            int a[40][40]={0},b[40][40]={0};
            if(d==1){
                for(int j=0;j<h;++j){
                    for(int k=0;k<c;++k){
                        a[j][c-1-k]=pp[j][k];
                    }
                    for(int k=0;k<w-c;++k){
                        b[j][k]=pp[j][k+c];
                    }
                }
                w=max(c,w-c);
                for(int j=0;j<w;++j){
                    for(int k=0;k<h;++k){
                        pp[k][j]=a[k][j]+b[k][j];
                        //cout<<pp[0][0]<<endl;
                    }
                }
            }
            else{
                for(int j=0;j<w;++j){
                    for(int k=0;k<c;++k){
                        a[c-1-k][j]=pp[k][j];
                    }
                    for(int k=0;k<h-c;++k){
                        b[k][j]=pp[k+c][j];
                    }
                }
                h=max(c,h-c);
                for(int j=0;j<w;++j){
                    for(int k=0;k<h;++k){
                        pp[k][j]=a[k][j]+b[k][j];
                        //cout<<pp[0][0]<<endl;
                    }
                }
            }
        }
        
        for(int i=0;i<p;++i){
            cin>>x>>y;
            cout<<pp[y][x]<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int k,x,i;
  cin >> k >> x;
  for (i=0;i<k*2-1;i++){
    cout << x-k+i+1;
    if (i==k*2-2) cout << endl;
    else cout << ' ';
  }
  return 0;
}

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

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v.begin(), v.end())
#define V vector<int>

using namespace std;
using ll = long long;

int main() {
    int N;
    IN(N);
    vector<int> a(N);
    map<int, int> m;
    int i, j, max_a = 0;
    for(i = 0; i < N; i++) {
        IN(a[i]);
        if(max_a < a[i]) max_a = a[i];
        m[a[i]]++;
    }

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

    vector<int> wa;

    for(i = 0; i <= max_a; i++) {
        if(i == 0) {
            wa.push_back(m[i] + m[i+1]);
        }
        else if(i == max_a) {
            wa.push_back(m[i-1] + m[i]);
        }
        else wa.push_back(m[i-1] + m[i] + m[i+1]);
    }

    size_t size = wa.size();
    int max = 0;
    for(i = 0; i < size; i++) {
        if(max < wa[i]) max = wa[i];
    }

    OUT(max);


}

Measured memory_bytes: 5752
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0, h, w;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
int main() {
    int n; cin >> n; vector<ll> v(n); int ans = 0;
    rep(i, n) cin >> v[i];
    rep(i, 1 << n) {
        if (i == 0)continue;
        bool f = 1;ll g = 1;
        rep(j, n) if (i & (1 << j)) g = lcm(g, v[j]);
        rep(j, n) if (!(i & (1 << j))) if (!(g % v[j])) f = 0;
        if (f) ans++;
    }cout << ans << endl;
}


Measured memory_bytes: 3128
#include <stdio.h>
#include <assert.h>
#define int long long
#define N_MAX (100000)
#define min(a,b) (((a)<(b))?(a):(b))
typedef struct {
	int pos,value;
} Info;

signed main(){
	int damage_total[N_MAX]={};
	Info deque[N_MAX];
	int head=0,tail=0;
	int N,H;
	int answer = 0;

	scanf("%lld%lld",&N,&H);	
	int currentHP = H;
	for(int i = 0 ; i < N-1 ; i++){
		int d,h;
		scanf("%lld%lld",&d,&h);
		while( head != tail && deque[tail-1].value <= h ) tail--;

		deque[tail++] = (Info){i,h};
		while( head != tail ){
			int maximumRecover = H - (damage_total[i] - damage_total[deque[head].pos]);
			if( maximumRecover > 0 ) break;
			head++;
		}

		for(int j = head ; j < tail && currentHP <= d ; j++){
			// ????????§???????????§????????????
			int maximumRecover = H - (damage_total[i] - damage_total[deque[j].pos]);
			
			if( maximumRecover <= currentHP) continue;

			// j??????????????§?????????????????? needRecover ????¨????
			int needRecover = min( maximumRecover - currentHP , d - currentHP + 1);  
			// ???????????? needRecover ?????????????????????????????° useCount ????±???????
			int useCount = (needRecover+deque[j].value-1) / deque[j].value - 1;
			answer += useCount;
			currentHP += useCount*deque[j].value;
			// ????°??????????????¬????????´?????????£?????´?????¨??????????´?????????£?????´??????????????????????????????????????????????´??????????			
			if( j+1 ==  tail || maximumRecover > currentHP + deque[j+1].value ){
				currentHP = min(currentHP+deque[j].value,maximumRecover);
				answer++;
			}
		}
		currentHP -= d;
		damage_total[i+1] = damage_total[i] + d;

	}
	printf("%lld\n",answer);

}

Measured memory_bytes: 2240
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string a;
  cin >> a;
  for(char i : a)
  {
    if(i == '7')
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m % n);
}

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

int main() {
    int N;
    cin >> N;
    ll p[N];
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    int n = 1<<N;
    set<ll> s;
    for (int i = 1; i < n; i++) {
        ll l = 1;
        for (int j = 0; j < N; j++) {
            if ((i & (1<<j)) != 0) {
                l = lcm(l, p[j]);
            }
        }
        s.insert(l);
    }
    cout << s.size() << "\n";
    return 0;
}


Measured memory_bytes: 3984
import java.security.cert.CollectionCertStoreParameters;
import  java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        Map<String, Integer> map = new TreeMap<>();
        for (int i = 0; i < N; i++){
            map.merge(sc.next(),1, Integer::sum);
        }
        int maxValueInMap = (Collections.max(map.values()));
        for (Map.Entry<String, Integer> entry : map.entrySet()){
            if (entry.getValue() == maxValueInMap){
                System.out.println(entry.getKey());
            }
        }
    }
}


Measured memory_bytes: 86200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;cin>>n>>k;
	int cpy = n - 2;
	cpy*=(cpy + 1);
	cpy/=2;
	if(k > cpy){
		cout<<-1<<endl;
	} else{
		vector<int> edges[n+1];
		int cnt = cpy;
		int y = 0;
		for(int i = 2;i <= n; ++i){
			edges[1].push_back(i);
			y++;
		}
		cnt -= k;
		for(int i = 2; i <= n&& cnt; ++i){
			for(int j = i + 1; j <=n && cnt; ++j){
				cnt--;
				edges[i].push_back(j);
				y++;
			}
		}
		cout<<y<<endl;
		for(int i = 1; i <= n; ++i){
			for(auto x : edges[i]){
				cout<<i<<" "<<x<<endl;
			}
		}

	}
	return 0;
}



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

vector<int> vi;

int ans;
signed main () {

    int n, x;
    scanf("%d %d", &n, &x);
    for ( int i = 0; i < n; i++ ) {
        int a;
        scanf("%d", &a);
        vi.push_back(a);
    }
    sort(vi.begin(), vi.end());
    for ( int i = 0; i < n; i++ ) {
        if ( i != n-1 ) {
            if ( vi[i] <= x ) {
                ans++;
                x -= vi[i];
            }
        }
        else {
            if ( vi[i] == x ) ans++;
        }

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

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int  n, a[200000] = {};
	long long sum = 0, b[200000] = {};
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		b[a[i]-1]++;
	}
	for (int i = 0; i < n; i++) {
		sum += b[i] * (b[i] - 1) / 2;
	}
	for (int i = 0; i < n; i++) {
		printf("%lld\n", sum-b[a[i]-1]+1);
	}

	return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>

long long san(long long a);

int main()
{
    long long n,k,x,y,num1,num2,ans;
    scanf("%lld %lld",&n,&k);
    x=n%k;
    num1=n/k;
    num2=num1;
    if(k/2<=x)num2++;
    if(k==1)printf("%lld",n*n*n);
    else
    {
        if(k%2==0)ans=(san(num1)+san(num2));
        else ans=san(num1);
    printf("%lld",ans);
    }
}
long long san(long long a)
{
    return (a*a*a);
}

Measured memory_bytes: 128
def main():
    n, k = map(int, input().split())
    inlis = list()

    for _ in range(n):
        alis = list(map(int, input().split()))
        inlis.append(alis)
    inlis.sort()
    tmp = k
    i = 0

    while tmp > 0:
        tmp -= inlis[i][1]

        if tmp > 0:
            i += 1    
        else:
            print(inlis[i][0])
            exit()



if __name__ == "__main__":
    main()

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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
string dv[8];
int main()
{
    string s;
    cin>>s;
    int a;
    if(s=="SUN")
        a=1;
    if(s=="MON")
        a=2;
    if(s=="TUE")
        a=3;
    if(s=="WED")
        a=4;
    if(s=="THU")
        a=5;
    if(s=="FRI")
        a=6;
    else if(s=="SAT")
        a=7;
    cout<<7-a+1;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define ll long long
ll x;int n;
int f(ll x){
	int q=0;
	while (x) q+=x%10,x/=10;
	return q;
}
int main(){
	scanf("%d",&n);x=1;ll la=1;
	printf("1\n");
	for (int i=2;i<=n;i++){
		if (la+x>x*f(la+x)) x*=10;
		printf("%lld\n",la+=x);
	}
	return 0;
}

Measured memory_bytes: 1656
n,m,k=map(int,input().split())

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

suma=sum(a)
ai=n-1
sumb=0
bi=-1

ans=0

while ai>=0:
    if ai ==n-1:
        while suma+sumb<=k:
            ans=max(ans,ai+1+bi+1)

            if bi+1<m:
                bi+=1
                sumb+=b[bi]
            else:
                break


    suma-=a[ai]
    ai-=1
    while suma+sumb<=k:
        ans=max(ans,ai+1+bi+1)

        if bi+1<m:
            bi+=1
            sumb+=b[bi]
        else:
            break
    #print(ai,bi)



print(ans)







Measured memory_bytes: 118180
def floyd_warshall(dist):
    v = len(dist)
    for k in range(v):
        for i in range(v):
            for j in range(v):
                dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])

h,w = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(10)]
floyd_warshall(c)
A = [list(map(int,input().split())) for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if A[i][j] != -1:
            ans += c[A[i][j]][1]
print(ans)

Measured memory_bytes: 73908
#include <bits/stdc++.h>
#define el_cucuy ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e6 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong dp[3001][3001], p[3001][3001];

string s, z;

vector <char> v;

int main(){
    el_cucuy
    cin >> s >> z;
    s = '#' + s;
    z = '@' + z;
    for (int i = 1; i < s.size(); i ++){
        for (int j = 1; j < z.size(); j ++){
            if(s[i] == z[j]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
                p[i][j] = 1;
            }else{
                if(dp[i - 1][j] < dp[i][j - 1]){
                    dp[i][j] = dp[i][j - 1];
                    p[i][j] = 2;
                }else{
                    dp[i][j] = dp[i - 1][j];
                    p[i][j] = 3;
                }
            }
        }
    }llong n = s.size() - 1, m = z.size() - 1;
    //cout << dp[n][m] << '\n';
    while (n >= 1 && m >= 1){
        if(p[n][m] == 1){
            v.pb(s[n]);
            n --;
            m --;
        }else if(p[n][m] == 2){
            m --;
        }else{
            n --;
        }
    }reverse(v.begin(), v.end());
    for (int i = 0; i < v.size(); i ++){
        cout << v[i];
    }
    return 0;
}


Measured memory_bytes: 140928
from collections import Counter
N = int(input())
#C = sorted(list(Counter(map(int, input().split())).values()))
C = list(Counter(map(int, input().split())).values())
C.sort()

rest = N
removed = 0
for K in range(1, N + 1):
    d = K - removed
    while C and C[- 1] > rest//d:
        rest -= C[- 1]
        C.pop()
        removed += 1
        d -= 1
    print(rest//d)

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

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

    string S;

    cin >> S;

    int cnt=0;

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

    cout << cnt << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define ff(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b) 
int main(){
    //FL;
    fin;
    int n;
    cin >> n;
    ll m[n + 2], h[n + 2];
    fore(i, 0, n + 1)
        cin >> m[i];
    fore(i, 0, n)cin >> h[i];
    ll ans = 0;
    fore(i, 0, n){
        ll aux = min(m[i], h[i]);
        h[i] -= aux;
        ans += aux;
        if(!h[i])
            continue;
        ll cur = m[i + 1] - h[i];
        if(cur <= 0){
            ans += m[i + 1];
            h[i] -= m[i + 1];
            m[i + 1] = 0;
        }
        else{
            m[i + 1] -= h[i];
            ans += h[i];
        }
    }
    cout << ans << '\n';
    time;
    return 0;
}   

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N int
	var S string
	var count, max int
	fmt.Scan(&N)
	fmt.Scan(&S)
	for i := 1; i < N; i++ {
		count = 0
		X := S[0:i]
		Y := S[i:len(S)]
		for j := 'a'; j <= 'z'; j++ {
			if strings.Contains(X, string(j)) && strings.Contains(Y, string(j)) {
				count++
			}
			if count > max {
				max = count
			}
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<long> s = new List<long>();
    static decimal result;
static Hashtable ht=new Hashtable();
static StringBuilder sb = new StringBuilder();
static int N,M,K;
static long[,] table;
    static void Main()
    {
Read3();
      s[0]--;
      long waru=Lcm(s[2],s[3]);
  long r1=s[1]-((long)(s[1]/s[2])+(long)(s[1]/s[3])-(long)(s[1]/waru));
  long r2=s[0]-((long)(s[0]/s[2])+(long)(s[0]/s[3])-(long)(s[0]/waru));
result=r1-r2;
      Console.WriteLine(result.ToString());

    }
    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }
      static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }

    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(long.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {

 
    }


}

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
using namespace std;
#define MAX_N 1121
#define MAX_K 15
typedef long long ll;

bool prime[MAX_N];
ll dp[MAX_N][MAX_K];

void Prime(){
  fill(prime,prime+MAX_N,true);
  prime[0] = prime[1] = false;

  for(int i = 2 ; i*i < MAX_N ; i++)
    if(prime[i])
      for(int j = i*i ; j < MAX_N ; j += i)
	prime[j] = false;
}

void init(){
  Prime();
  vector<int> P;
  for(int i = 0 ; i < MAX_N ; i++){
    if(prime[i]){
      P.push_back(i);
    }
  }

  dp[0][0] = 1;

  for(int i = 0 ; i < (int)P.size() ; i++){
    for(int j = MAX_K-2 ; j >= 0 ; j--){
      for(int k = 0 ; k < MAX_N-P[i] ; k++){
	dp[P[i]+k][j+1] += dp[k][j];
      }
    }
  }
}

int main(){
  int n,k;

  init();

  while(cin >> n >> k, n | k){
    cout << dp[n][k] << endl;
  }

  return 0;
}

Measured memory_bytes: 1348
#include <iostream>

using namespace std;

int main()
{
	int N, H[20],viewable = 0,highest=0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	highest = H[0];

	for (int i = 0; i < N ; i++) {
		if (H[i] >= highest) {
			highest = H[i];
			viewable++;
		}
	}
	cout << viewable  << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int N;
int A[100005];
map <long long, int> M;
long long ans = 0;
void Read()
{
    cin >> N;
    M[0] = 1;
    long long sum = 0;
    for(int i = 1; i <= N; i++)
    {
        int x;
        cin >> x;
        int val = 0;
        sum += x;
        if(M.find(sum) != M.end())
            val = M[sum];
        M[sum]++;
        ans += val;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    return 0;
}


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

int main(){
    long long i;
    long long N,H;
    long long result=0;
    cin>>N>>H;
    vector<long long>A(N);
    vector<long long>B(N);
    for(i=0;i<N;i++)cin>>A[i]>>B[i];

    sort(A.begin(),A.end(),greater<long long>());
    sort(B.begin(),B.end(),greater<long long>());

    for(i=0;i<N;i++){
        if(H<=0)break;
        if(B[i]>=A[0]){
            H-=B[i];
            result+=1;
        }else{
            break;
        }
    }

    if(H<=0){
        cout<<result<<endl;
    }else{
        if(H%A[0]==0){
            result+=H/A[0];
        }else{
            result+=H/A[0]+1;
        }

        cout<<result<<endl;
    }
}

Measured memory_bytes: 1792
a, b, c, x, y = gets.split.map(&:to_i)
sum = 0
if c * 2 < a + b
  nc = [x, y].min * 2
  sum += nc * c
  if x > y
    x -= y
    y = 0
    if a > 2 * c
      sum += x * 2 * c
    else
      sum += a * x
    end
  else
    y -= x
    x = 0
    if b > 2 * c
      sum += y * 2 * c
    else
      sum += b * y
    end
  end
else
  sum = a * x + y * b
end
puts sum


Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string S,pre="",now="";
int ans=0;

int main(){
    cin>>S;
    rep(i,S.size()){
        now+=S[i];
        if(now!=pre){
            ans++;
            pre=now;
            now="";
        }
    }
    out(ans);
    
    
    
}


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

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

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

int n, m, K;
char a[500][501];

inline void draw(int i, int j, char c){
	if (0 <= i && i < n && 0 <= j && j < m)
		a[i][j] = c;
}

int main(){
	scanf("%d%d%d", &n, &m, &K);
	if (K & 1){
		for (int i = 0; i < n; ++i){
			for (int j = 0; j < m; ++j)
				putchar("RG"[i + j & 1]);
			puts("");
		}
	}
	else{
		char cc[4] = {'R', 'Y', 'G', 'B'};
		int K0 = K >> 1;
		for (int j = -K; j < m + K; j += K){
			for (int i = -K; i < n + K; i += K << 1){
				for (int k = 0; k < K0; ++k){
					for (int l = -k; l <= k; ++l){
						draw(i + k, j - l, cc[0]);
						draw(i + k, j + l, cc[0]);
						draw(i + K - 1 - k, j - l, cc[0]);
						draw(i + K - 1 - k, j + l, cc[0]);

						draw(K + i + k, j - l, cc[1]);
						draw(K + i + k, j + l, cc[1]);
						draw(K + i + K - 1 - k, j - l, cc[1]);
						draw(K + i + K - 1 - k, j + l, cc[1]);

						draw(K0 + i + k, K0 + j - l, cc[2]);
						draw(K0 + i + k, K0 + j + l, cc[2]);
						draw(K0 + i + K - 1 - k, K0 + j - l, cc[2]);
						draw(K0 + i + K - 1 - k, K0 + j + l, cc[2]);

						draw(K + K0 + i + k, K0 + j - l, cc[3]);
						draw(K + K0 + i + k, K0 + j + l, cc[3]);
						draw(K + K0 + i + K - 1 - k, K0 + j - l, cc[3]);
						draw(K + K0 + i + K - 1 - k, K0 + j + l, cc[3]);
					}
				}
			}
			swap(cc[0], cc[1]);
			swap(cc[2], cc[3]);
		}
		for (int i = 0; i < n; ++i){
			for (int j = 0; j < m; ++j)
				putchar(a[i][j] ? a[i][j] : ' ');
			puts("");
		}
//			puts(a[i]);
	}
	return 0;
}



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

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define repi(i,j,N) for(int (i)=(j);(i)<(N);(i)++)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define ll long long
#define numberofdigits(x) floor(log10(x)) + 1

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    B *= 100; B += D;
    ll X = A*B; X /= 100;
    cout << X << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  string s;
  cin >> s;

  if(s <= "2019/04/30") cout << "Heisei" << endl;
  else cout << "TBD" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
ll dp[5001][5001];
ll A, B;
int N;
int p[5001];
const ll INF = 1e+18;

int main(){
    cin >> N >> A >> B;
    for(int i = 0; i < N; i++) cin >> p[i];
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= N; j++){
            if(dp[i][j] == INF) continue;
            if(j < p[i]){
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]+A);
                dp[i+1][p[i]] = min(dp[i+1][p[i]], dp[i][j]);
            }else{
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]+B);
            }
        }
    }
    ll ans = INF;
    for(int i = 0; i <= N; i++) ans = min(ans, dp[N][i]);
    cout << ans << endl;
}

Measured memory_bytes: 195712
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    int sum = 0;
    for(auto i:mp){
        int num = i.first,num2 = i.second;
        if(num > num2)sum += num2;
        if(num < num2)sum += num2-num;
    }
    cout << sum << endl;
}


Measured memory_bytes: 4736
using System;
class P{
  static void Main(){
    var a=new char[][]{Console.ReadLine().ToCharArray(),Console.ReadLine().ToCharArray()};
   if(a[0].Length>a[1].Length){
     Console.WriteLine("GREATER");
    }else if(a[0].Length<a[1].Length){
      Console.WriteLine("LESS");
    }else{
      for(int i=0;i<a[0].Length;i++){
        if(a[0][i]>a[1][i]){Console.WriteLine("GREATER");return;}
        if(a[0][i]<a[1][i]){Console.WriteLine("LESS");return;}
      }
      Console.WriteLine("EQUAL");
    }
  }
}

Measured memory_bytes: 11220
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
  a = int(input())
  ans = 0
  for i in range(a):
    if (i+1)%3 == 0 or (i+1)%5 == 0:
      continue
    ans += (i+1)
  print(ans)
if __name__ == '__main__':
  main()

Measured memory_bytes: 9172
#include<stdio.h> 
#include<stdlib.h>
int main(void)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if((x + r <= W && x - r >= 0 )&&(y + r <= H && y - r >= 0))
	{   
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


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

int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  if(k<a){
    cout << a-k << " " << b << endl;
    return 0;
  }else if(k-a<b){
    cout << 0 << " " << b-(k-a) << endl;
    return 0;
  }else{
    cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

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

    ll N;
    string S;
    cin >> N;
    cin >> S;

    vector<ll> esum(N + 1, 0), wsum(N + 1, 0);
    for (ll i = 0; i < N; i++) {
        esum[i + 1] = esum[i];
        if (S[i] == 'E') {
            esum[i + 1]++;
        }
    }

    for (ll i = N - 1; i >= 0; i--) {
        wsum[i] = wsum[i + 1];
        if (S[i] == 'W') {
            wsum[i]++;
        }
    }

    ll ans = INF;
    for (ll i = 0; i < N; i++) {
        ans = min(ans, (N - esum[i + 1] - wsum[i]));
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    int q, com, i;
    cin >> q;
    bitset<64> bit;
    rep(j, q)
    {
        cin >> com;
        switch(com)
        {
            case 0:
                cin >> i;
                if (bit.test(i)) cout << 1 << endl;
                else cout << 0 << endl;
                break;
            case 1:
                cin >> i;
                bit.set(i, 1);
                break;
            case 2:
                cin >> i;
                bit.set(i, 0);
                break;
            case 3:
                cin >> i;
                bit.flip(i);
                break;
            case 4:
                if (bit.all()) cout << 1 << endl;
                else cout << 0 << endl;
                break;
            case 5:
                if (bit.any()) cout << 1 << endl;
                else cout << 0 << endl;
                break;
            case 6:
                if (bit.none()) cout << 1 << endl;
                else cout << 0 << endl;
                break;
            case 7:
                cout << bit.count() << endl;
                break;
            case 8:
                cout << bit.to_ulong() << endl;
                break;
        }
    }
}



Measured memory_bytes: 3100
a = [[0]*3 for i in range(3)]
for i in range(3):
    a[i] = list(map(int, input().split()))
n = int(input())
b = [0]*n
bingo = "No"
for i in range(n):
    b[i] = int(input())
    for k in range(3):
        if a[k][0] == b[i]:
            a[k][0] = 0
        if a[k][1] == b[i]:
            a[k][1] = 0
        if a[k][2] == b[i]:
            a[k][2] = 0
for i in range(3):
    if a[i][0]+a[i][1]+a[i][2] == 0:
        bingo = "Yes"
for i in range(3):
    if a[0][i]+a[1][i]+a[2][i] == 0:
        bingo = "Yes"
if a[0][0]+a[1][1]+a[2][2] == 0:
    bingo = "Yes"
if a[2][0]+a[1][1]+a[0][2] == 0:
    bingo = "Yes"

print(bingo)

Measured memory_bytes: 3064
s = gets.chomp
def ch(s)
  s1 = s[0...(s.size / 2)]
  s2 = s[(s.size / 2)...s.size]
  s1 == s2
end

s = s[0...s.size.pred]

s = s[0...s.size.pred] if s.size.odd?

while !ch(s)
  s = s[0...(s.size - 2)]
end
p s.size




Measured memory_bytes: 1916
N,M,K=map(int,input().split())
MOD=998244353

def inv(a):
  return pow(a,MOD-2,MOD)
fact=[0,1]
for i in range(2,N+1):
  fact.append((fact[-1]*i)%MOD)
def choose(n,r):
  if r==0 or r==n:
    return 1
  else:
    return fact[n]*inv(fact[r])*inv(fact[n-r])%MOD
exp=[1]

def pow_k(x,n):
    if n==0:
        return 1
    K=1
    while n>1:
        if n%2!=0:
            K=K*x%MOD
            x=x**2%MOD
            n=(n-1)//2
        else:
            x=x**2%MOD
            n=n//2
    return K*x%MOD 

ans=0
for i in range(K+1):
  ans+=(M*choose(N-1,i)*pow_k(M-1,N-1-i)%MOD)  
  ans%=MOD
print(ans)  



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


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = input_int()
    a = input_to_int_tuple()

    a_sum = 1
    check = 10 ** 18
    if 0 in a:
        return 0

    for _a in a:
        a_sum *= _a
        if a_sum > check:
            return -1

    return a_sum


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 22520
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#define INF 1000000000
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int S, W;
  ci(S, W);
  S <= W ? cout << "unsafe" << endl : cout << "safe" <<endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
// #define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

signed main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K - 1] = S[K - 1] - 'A' + 'a';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  cout<<0<<endl;
  string start;
  cin>>start;
  string vac="Vacant";
  if(start==vac){cout<<0<<endl;return 0;}
  int l=0,r=N;
  while(r-l>1){
    int mid=(l+r)/2;
    cout<<mid<<endl;
    string next;
    cin>>next;
    if(next==vac){cout<<mid<<endl;return 0;}
    else if(mid%2==l%2){
      if(next!=start){r=mid;}
      else{l=mid;start=next;}
    }
    else {
      if(next==start){r=mid;}
      else{l=mid;start=next;}
    }
  }

  return 0;  
}

Measured memory_bytes: 3864
a = int(input())
p,q= input().split()
b,c =(int(p), int(q))
d = input().split()
ans_list = []
for i in range(a):
    e = abs(c+0.006 * int(d[i])-b)
    ans_list.append(e)
for i in range(a):
    if ans_list[i] == min(ans_list):
        print(i+1)
        break

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

using namespace std;

double abso(double a) {
	if (a >= 0) return a;
	else return -1 * a;
}

int main() {
	int N;
	double T, A;
	cin >> N >> T >> A;
	double H[N];
	double t[N];
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	for (int i = 0; i < N; i++) t[i] = abso(T - (H[i] * 0.006) - A);


	double min = t[0];
	int best_place = 0;
	for (int i = 1; i < N; i++) {
		if (t[i] < min) {
			best_place = i;
			min = t[i];
		}
	}

	cout << best_place + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>C(N);
    for(int i=0;i<N;i++){
        cin>>C[i];
        C[i]--;
    }
    vector<int>edges[200000];
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<vector<int> >res(N);
    vector<int>cnt(N);
    vector<map<int,int> >dp(N);
    auto dfs=[&](auto&& dfs,int i,int p)->void{
        for(int j:edges[i])if(j!=p){
            dfs(dfs,j,i);
            cnt[i]+=cnt[j];
            int c=cnt[j];
            if(dp[j].count(C[i]))c-=dp[j][C[i]];
            res[C[i]].push_back(c);
            if(dp[i].size()<dp[j].size())swap(dp[i],dp[j]);
            for(auto& p:dp[j])dp[i][p.first]+=p.second;
        }
        cnt[i]++;
        dp[i][C[i]]=cnt[i];
    };
    dfs(dfs,0,-1);
    for(int i=0;i<N;i++)res[i].push_back(N-dp[0][i]);
    int64_t all=int64_t(N)*(N+1)/2;
    vector<int64_t>ans(N,all);
    for(int i=0;i<N;i++)for(int64_t a:res[i]) ans[i]-=a*(a+1)/2;
    for(auto a:ans)cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 80536