akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#define ll long long
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define val 1000000000000000000
using namespace std;
int main()
{
    ll n,s=1;
    cin>>n;
    if(n%2!=0)
    cout<<"0"<<endl;
    else
    {
        ll ss=5,sum=0;
        s=n/2;
        while(ss<=s)
        {
            sum+=s/ss;
            //cout<<"hi "<<s/ss<<endl;
            //cout<<"sum is "<<sum<<endl;
            ss=ss*5;
            //cout<<"di "<<ss<<endl;
        }
        cout<<sum<<endl;
    }
    
}

Measured memory_bytes: 256
//
//  atcoder.cpp
//  
//
//  Created by 中川阿津志 on 2018/12/05.
//
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

//#include "atcoder.hpp"

long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}
int main() {
    long long   P, r = 0;
    vector<int> w(1, 1);
    int N,A,B;
    cin >> N >> A >> B;


    cout << min(A, B) << " " << max(A+B - N, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#ABC-123-A
antenna_list = []
ans = "Yay!"

for _ in range(5):
    antenna = int(input())
    antenna_list.append(antenna)
    
k = int(input())
    
for i in range(4):
    if ans == ":(":
        break
    for j in range(i+1, 5):
        if abs(antenna_list[i] - antenna_list[j]) > k:
            ans = ":("
            break
            
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){

int a,b;						//変数を宣言

cin>>a>>b;						//外部入力から変数を２つ読み込む

								//面積・空白スペース・周の長さ・改行を出力

cout<<a*b<<" "<<2*(a+b)<<endl;

return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

struct uf{
  private:
    vi par, rank, size;
  public:
    uf(i64 n){ init(n); }
    void init(i64 n){
      par.resize(n);
      rank.resize(n,0);
      size.resize(n,1);
      rep(i,n) par[i] = i;
    }
    i64 root(i64 x){
      if(par[x] == x) return x;
      return par[x] = root(par[x]);
    }
    bool same(i64 x, i64 y){ return root(x) == root(y); }
    void unite(i64 x, i64 y){
      x = root(x), y = root(y);
      if(x==y) return;
      if(rank[x]==rank[y]) rank[x]++;
      if(rank[x]<rank[y]) swap(x,y);
      par[y] = x;
      size[x] += size[y];
    }
    i64 num(i64 x){ return size[root(x)]; }
};

void Main()
{
  i64 x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vi p(a);
  rep(i,a) cin >> p[i];
  vi q(b);
  rep(i,b) cin >> q[i];
  vi r(c);
  rep(i,c) cin >> r[i];

  sort(rng(p),greater<i64>());
  sort(rng(q),greater<i64>());
  sort(rng(r),greater<i64>());

  i64 red = x;
  i64 blue = y;
  i64 nxt = 0;
  while(nxt<c){
    i64 nxt_red = INF;
    i64 nxt_blue = INF;

    if(red>0) nxt_red = p[red-1];
    if(blue>0) nxt_blue = q[blue-1];

    if(nxt_red <= nxt_blue and r[nxt]>nxt_red){
      nxt += 1;
      red -= 1;
    }else if(nxt_red > nxt_blue and r[nxt]>nxt_blue){
      nxt += 1;
      blue -= 1;
    }else{
      break;
    }
  }

  i64 ans = 0;
  rep(i,red) ans += p[i];
  rep(i,blue) ans += q[i];
  rep(i,nxt) ans += r[i];

  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}



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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

//template<int MOD>
//class modint{
//    int val;
//public:
//    modint(std::istream &is){ is >> val; }
//    modint(int val) : val(val) {}
//    modint &operator=(const modint &a){
//        val = a.val;
//        return *this;
//    }
//    modint &operator+=(const modint &a){
//        val += a.val;
//        if(val >= MOD) val -= MOD;
//        return *this;
//    }
//    modint &operator-=(const modint &a){
//        if(val < a) val += MOD;
//        val -= a.val;
//        return *this;
//    }
//    modint &operator*=(const modint &a){
//        val = (val * a.val) % MOD;
//        return *this;
//    }
//    modint &operator^=(modint a){
//        modint<MOD> tmp(val);
//        val = 1;
//        while(a.val){
//            if(a.val & 1) ＊this＊ = tmp;
//            tmp *= tmp;
//            a.val >>= 1;
//        }
//        return *this;
//    }
//    friend std::istream &operator>>(std::istream &is, modint a){
//      return is >> a.val;
//    }
//    friend std::ostream &operator<<(std::ostream &os, modint a){ return os << a.val; }
//};
//
//using Int = modint<1000000007>;

const int MAX_N = 100010;
ll K[MAX_N+1];
ll inv[MAX_N+1];

ll mul(ll _a, ll _b) {
  if (_b == 0) return 1LL;
  if (_b == 1) return _a;
  ll ans = mul(_a, _b/2);
  ans *= ans;
  ans %= MOD;
  if (_b&1) ans *= _a;
  return ans % MOD;
}

ll C(ll _n, ll _k) {
  return (K[_n] * ((inv[_k] * inv[_n-_k]) % MOD)) % MOD;
}

void init() {
  K[1] = 1;
  inv[1] = 1;
  inv[0] = 1;
  for (ll i = 2; i <= MAX_N; i++) {
    K[i] = K[i-1]*i;
    K[i] %= MOD;
    inv[i] = mul(K[i], MOD-2);
  }
}

int main(){
  int N;
  init();

  while (cin >> N,N) {
    int q;
    cin >> q;
    vector<int> v(N+1);
    set<int> st;
    REP(i,N + 1) {
      v[i] = i;
    }
    while (q--) {
      int a,b;
      cin >> a >> b;
      swap(v[a], v[b]);
    }

    ll ans = 0;
    ll no = N - 1;

    ll seg[100010] = {};
    for (int i = 1; i <= N; i++) {
      int tmp = v[i];
      ll bit = 0;
      while (tmp) {
        bit += seg[tmp];
        tmp -= tmp & -tmp;
      }
      tmp = v[i];
      while (tmp <= N) {
        seg[tmp]++;
        tmp += tmp & -tmp;
      }
      ans += K[no] * (v[i] - 1 - bit);
      ans %= MOD;
      no--;
    }

    cout << ans << endl;
  }
}




Measured memory_bytes: 5752
#include <iostream>
#include <string>

int main()
{
    int n, x;
    std::cin >> n >> x;

    int num = n;

    for (int i = 0; i <= n; i++) {
        
        for (int p = 0; p <= n - i; p++) {
            int sum = 10000 * i + 5000 * p;

            int q = num - i - p;
            sum += 1000 * q;
            if (sum == x) {
                std::cout << i << " " << p << " " << q << std::endl;
                return 0;
            }
        }
    }

    std::cout << "-1 -1 -1" << std::endl;
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(void){
    int h, w, d, a[300][300], s[90001];
    P p[90001];
    cin>>h>>w>>d;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            p[a[i][j]]=P(i, j);
        }
    }
    for(int i=1;i<=h*w;i++){
        if(i<=d){
            s[i]=0;
        }else{
            s[i]=s[i-d];
            s[i]+=abs(p[i].first-p[i-d].first);
            s[i]+=abs(p[i].second-p[i-d].second);
        }
        
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int l, r;
        cin>>l>>r;
        cout<<s[r]-s[l]<<endl;
    }
}


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

using namespace std;

int find(vector<int>& P, int x) {
	if (P[x] == x) {
		return x;
	}
	P[x] = find(P, P[x]);
	return P[x];
}

void unite(vector<int>& P, int x, int y) {
	P[find(P, x)] = find(P, y);
}

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

	vector<pair<int, int>> points(n);
	for (int i = 0; i < n; ++ i) {
		cin >> points[i].first >> points[i].second;
	}

	multimap<int, pair<int, int>> m;

	vector<tuple<int, int, int>> vec(n);
	for (int i = 0; i < n; ++ i) {
		vec[i] = make_tuple(points[i].first, points[i].second, i);
	}

	sort(vec.begin(), vec.end());
	for (int i = 1; i < n; ++ i) {
		m.insert({get<0>(vec[i]) - get<0>(vec[i - 1]), {get<2>(vec[i]), get<2>(vec[i - 1])}});
	}

	sort(vec.begin(), vec.end(), [](const auto &a, const auto &b) {
		return get<1>(a) < get<1>(b);
	});
	for (int i = 1; i < n; ++ i) {
		m.insert({get<1>(vec[i]) - get<1>(vec[i - 1]), {get<2>(vec[i]), get<2>(vec[i - 1])}});
	}

	vector<int> P(n);
	for (int i = 0; i < n; ++ i) {
		P[i] = i;
	}

	int ans = 0;
	for (auto val : m) {
		if (find(P, val.second.first) !=  find(P, val.second.second)) {
			ans += val.first;
			unite(P, val.second.first, val.second.second);
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 15232
N, M = list(map(int, input().split()))
rooms = [list() for _ in range(N+1)]

for i in range(M):
    a, b = list(map(int, input().split()))
    rooms[a].append(b)
    rooms[b].append(a)

from collections import deque

INF = 10**9+1
steps = [INF] * (N+1)
mk = [0] * (N+1)
ck = deque([1])
steps[1] = 0

while len(ck)>0:
    i = ck.popleft()
    current = steps[i]
    for j in rooms[i]:
        if steps[j] > current+1:
            ck.append(j)
            steps[j] = current+1
            mk[j] = i

print('Yes')
for i in range(2, N+1):
    print(mk[i])


Measured memory_bytes: 94680
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int vis[30];
char a[30],b[30];
int s[30];
int main()
{
    int i,j,k,t;
    scanf("%s",a);
    k=strlen(a);
    if(k==26)
    {
        for(i=0;i<k;i++)
          s[i]=a[i]-'a';
        strcpy(b,a);
        while(next_permutation(s,s+k))
        {
            for(i=0;i<k;i++)
                b[i]=s[i]+'a';
            break;
        }
        if(strcmp(a,b)==0)
        {
            printf("-1\n");
            return 0;
        }
        for(i=0;i<k;i++)
        {
        if(a[i]!=b[i])
            break;
        printf("%c",b[i]);
        }
        if(i!=k)
            printf("%c",b[i]);
        printf("\n");
        return 0;
    }
    else
    {
        for(i=0;i<k;i++)
        {
            j=a[i]-'a';
            vis[j]++;
        }
        t=30;
        for(i=0;i<26;i++)
        {
            if(vis[i]==0)
            t=min(t,i);
            if(vis[i]>1)
            t=-1;
        }
        a[k]=t+'a';
        a[k+1]='\0';
        printf("%s\n",a);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
vector<vector <char> > str;
vector<vector <char> > str1;

int main(){
    int H,W;
    cin >> H >> W;
    str = vector<vector <char> > (H,vector<char>(W,0));
    str1 = vector<vector <char> > (2*H,vector<char>(W,0));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> str.at(i).at(j);
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            str1.at(2*i).at(j)=str.at(i).at(j);
            str1.at(2*i+1).at(j)=str.at(i).at(j);
        }
    }
    for(int i=0;i<2*H;i++){
        for(int j=0;j<W;j++){
            cout << str1.at(i).at(j);
            if(j==(W-1))cout << endl;
        }
    }
    return 0;
}

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

int main() {
    int n,k;
    string s;
    cin >> n;
    cin >> s;
    cin >> k;
    for(int i=0; i< n; i++){
        if(s[i] != s[k-1]) s[i] = '*';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
N, D = input().split()
N = int(N)
D = int(D)
X = list()
Y = list()
s = 0
for i in range(N):
    x, y = input().split()
    x = int(x)
    y = int(y)
    if x ** 2 + y ** 2 <= D ** 2:
        s = s + 1
print(s)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define inf (int)(1e9)

int main(){
	int N, K, C, i;
	scanf("%d%d%d", &N, &K, &C);
	string S;
	cin >> S;
	S.insert(S.begin(), '#');
	vector<int> last(N + 2, -inf), count(N + 2, 0), last_rev(N + 2, inf), count_rev(N + 2, 0);
	for(i = 1; i <= N; i++){
		if(S[i] == 'o' && last[i - 1] + C < i){
			last[i] = i;
			count[i] = count[i - 1] + 1;
		}
		else{
			last[i] = last[i - 1];
			count[i] = count[i - 1];
		}
	}
	for(i = N; i >= 1; i--){
		if(S[i] == 'o' && last_rev[i + 1] - C > i){
			last_rev[i] = i;
			count_rev[i] = count_rev[i + 1] + 1;
		}
		else{
			last_rev[i] = last_rev[i + 1];
			count_rev[i] = count_rev[i + 1];
		}
	}
	for(i = 1; i <= N; i++){
		if(last[i] == i && last_rev[i] == i && count[i] + count_rev[i] == K + 1){
			printf("%d\n", i);
		}
	}
	return 0;
}

Measured memory_bytes: 4996
import java.io.*;
import java.util.*;
public class Main
{
	long sum[][];
	private void solve()throws IOException
	{
		init();
		int n=nextInt();
		int c=nextInt();
		int a[]=new int[n+1];
		int b[]=new int[n+1];
		for(int i=1;i<=n;i++)
			a[i]=nextInt();
		for(int i=1;i<=n;i++)
			b[i]=nextInt();
		//dp[i][j] is the sum obtained by distributing j candies among [1..i] students
		long dp[][]=new long[n+1][c+1];
		dp[0][0]=1;
		for(int i=1;i<=n;i++)
			for(int j=0;j<=c;j++)
				for(int k=0;k<=j;k++)
					dp[i][j]=(dp[i][j]+(dp[i-1][j-k]*sum(a[i],b[i],k))%mod)%mod;
		out.println(dp[n][c]);
	}
	void init()
	{
		int maxn=400;
		sum=new long[maxn+1][maxn+1];
		for(int k=0;k<=maxn;k++)
			for(int i=1;i<=maxn;i++)
				sum[k][i]=(sum[k][i-1]+modpow(i,k))%mod;
	}
	//sum of a^k+(a+1)^k+...+b^k
	long sum(int a,int b,int k)
	{
		return (sum[k][b]-sum[k][a-1]+mod)%mod;
	}
	final long mod=(long)(1e9+7);
	long modpow(long a,long b){
	    long ret=1;
	    while(b!=0)
	    {
	        if(b%2==1)
	            ret=(ret*a)%mod;
	        a=(a*a)%mod;
	        b=b/2;
	    }
	    return ret;
	} 

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007


int main() {
    int A, B, K; cin >> A >> B >> K;
    int ans, num = 0;
    for(int i= 100; i >0 ; i-- ){
        if(A % i == 0 && B % i == 0) num++;
        if(num == K){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
    int n, c;
    cin >> n >> c;

    vector<vector<long long>> d(c, vector<long long>(c));
    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            cin >> d[i][j];
        }
    }

    vector<vector<int>> cr(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> cr[i][j];
        }
    }

    vector<vector<long long>> dsum(3, vector<long long>(c, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < c; k++) {
                dsum[(i + j + 2) % 3][k] += d[cr[i][j] - 1][k];
            }
        }
    }

    long long res = (1LL << 48);
    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            for (int k = 0; k < c; k++) {
                if (i == j || j == k || k == i) {
                    continue;
                }

                if (res > dsum[0][i] + dsum[1][j] + dsum[2][k]) {
                    res = dsum[0][i] + dsum[1][j] + dsum[2][k];
                }
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    if(n%2) {
        cout << 0 << endl;
    } else {
        int t = 10;
        int res = 0;
        while(t <= n) {
            res += n/t;
            t *= 5;
        }
        cout << res << endl;
    }
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define pb push_back

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k;
    scanf("%d %d", &n, &k);
    ld res = 0;
    for (int i = 1; i <= n; i++) {
        ld temp = 1.0 / n;
        for (int j = i; j < k; j *= 2) {
            temp *= 0.5;
        }
        res += temp;
    }
    printf("%.12Lf", res);
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
   string s;
   cin>>s;
   int diff, t=753;
   for (int i = 0; i < s.size() -2 ; i++)
   {
       diff = 753 - (s[i]-'0') * 100 - (s[i+1] - '0')*10 - (s[i+2] - '0');
       t = min(t, abs(diff)); 
   }
   cout<<t;
   

   return 0;
}


Measured memory_bytes: 3580
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    final int n = sc.nextInt();
    int count = 0;
    for(int i = 0,min = n,p;i<n;i++){
      p = sc.nextInt();
      if(p<=min){
        count++;
        min = p;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 62860
from collections import deque
H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
operations = []
have_coin = False
for h in range(H):
    if h%2 == 0:
        for w in range(W):
            if have_coin == False and A[h][w]%2!=0:
                have_coin = True
                prev_w = w
                prev_h = h

            elif have_coin and A[h][w]%2 == 0:
                operations.append([prev_h+1,prev_w+1,h+1,w+1])
                prev_h = h
                prev_w = w

            elif have_coin and A[h][w]%2 != 0:
                have_coin = False
                operations.append([prev_h+1, prev_w+1, h+1, w+1])

            else:
                pass





    else:
        for w in range(W-1,-1,-1):
            if have_coin == False and A[h][w] % 2 != 0:
                have_coin = True
                prev_w = w
                prev_h = h

            elif have_coin and A[h][w] % 2 == 0:
                operations.append([prev_h+1, prev_w+1, h+1, w+1])
                prev_h = h
                prev_w = w

            elif have_coin and A[h][w] % 2 != 0:
                have_coin = False
                operations.append([prev_h+1, prev_w+1, h+1, w+1])

            else:
                pass

print(len(operations))
for operation in operations:
    print(*operation)


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll a,b,c,ans=0;
	cin >> a >> b >> c;
	if(a==b && b==c){
		if(a%2==0 && b%2==0 && c%2==0) cout << -1 << endl;
		else cout << 0 << endl;
	}
	else{
		while(a%2==0 && b%2==0 && c%2==0){
			ans++;
			ll aa=(b+c)/2;
			ll bb=(a+c)/2;
			ll cc=(a+b)/2;
			a=aa;
			b=bb;
			c=cc;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++){
		ans+=s[i]-'0';
		ans%=9;
	}
	if(!ans)printf("Yes");
	else printf("No");
}

Measured memory_bytes: 3800
'use strict';

function main(input) {
  const lines = input.split('\n');
  const n = lines[0].split(' ').shift() | 0;
  const d = lines[1].split(' ').map((x) => x | 0);

  let ans = n;
  const reg = RegExp(d.join('|'));
  while (reg.test(ans)) {
    ans += 1;
  }
  console.log(ans);
}

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


Measured memory_bytes: 22572
def extgcd(a, b):
    if b:
        d, y, x = extgcd(b, a%b)
        y -= (a/b)*x
        return d, x, y
    else:
        return a, 1, 0
N = int(input())
grundy = 0
for i in range(N):
    a, k = map(int, input().split())
    while a % k:
        p, q = divmod(a, k)
        a -= (p + 1)*((q+p)//(p+1))

    grundy ^= a // k
print('Takahashi' if grundy else 'Aoki')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
	while(1){
	int n; cin >> n ;
	if(n==0) break;
	int suma=0;int sumb=0;
	for(int i=0;i<n;i++){
		int a,b; cin >> a >> b ;
		if(a>b) suma+=a+b;
		else if(b>a) sumb+=a+b;
		else suma+=a,sumb+=b;
	};
	cout << suma << ' ' << sumb << '\n' ;
	};
}

Measured memory_bytes: 1160
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
	long long i; long long j;
};


string s;
string t;
ll const MAX = 1e5 + 5;
ll ps[MAX] = {}, pt[MAX] = {};

int main() {
	cin >> s >> t;
	ll q;
	REP(i, 1, SIZE(s)) {
		ps[i] = ps[i - 1] + 1 + (s[i - 1] - 'A');
	}
	REP(i, 1, SIZE(t)) {
		pt[i] = pt[i - 1] + 1 + (t[i - 1] - 'A');
	}
	cin >> q;
	REP(i, 1, q) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		if ((ps[b] - ps[a - 1]) % 3 == (pt[d] - pt[c - 1]) % 3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 2432
import java.util.*;
import java.math.BigInteger;
 
public class Main{
  
  public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
  
    BigInteger ans  = BigInteger.ONE;
    long l = (long)Math.pow(10,18);
    BigInteger L = BigInteger.valueOf(l);

    while(sc.hasNext()){
      long a = sc.nextLong();
      if (a == 0) {
        ans = BigInteger.ZERO;
      } else if (ans.compareTo(L) <= 0) {
        ans = ans.multiply(BigInteger.valueOf(a));
      }
    }
  
    if(ans.compareTo(L) <= 0){
      System.out.println(ans);
    }else{
      System.out.println(-1);
    }
  }  
}

Measured memory_bytes: 62552
def check(s):
  for i in (0, 3, 6): #横
    if s[i] != "s" and s[i] == s[i + 1] and s[i + 1] == s[i + 2]:
      print(s[i])
      return

  for i in (0, 1, 2): #縦
    if s[i] != "s" and s[i] == s[i + 3] and s[i + 3] == s[i + 6]:
      print(s[i])
      return

  if s[0] != "s" and s[0] == s[4] and s[4] == s[8]: #斜め1
      print(s[0])
      return

  if s[2] != "s" and s[2] == s[4] and s[4] == s[6]: #斜め2
      print(s[2])
      return

  print("d")  #それ以外なら引き分け

while True:
  try:
    check(input())

  except EOFError:
    break



Measured memory_bytes: 5564
#include <iostream>
#include <queue>
#include <algorithm>

#define ll long long
using namespace std;

int main() {
    int q;
    cin >> q;
    ll _, y, z;
    cin >> _ >> y >> z;

    ll teisuu = z;

    ll kijun = y;
    priority_queue<ll> under;
    ll undersum = 0;
    priority_queue<ll, vector<ll>, greater<>> over;
    ll oversum = 0;
    for (int i = 1; i < q; i++) {
        int a;
        cin >> a;
        if (a == 1) {
            ll b, c;
            cin >> b >> c;
            teisuu += c;
            if (kijun >= b) {
                under.push(b);
                undersum += b;
                if (under.size() - over.size() >= 1) {
                    over.push(kijun);
                    oversum += kijun;

                    kijun = under.top();
                    under.pop();
                    undersum -= kijun;
                }
            } else {
                over.push(b);
                oversum += b;
                if (over.size() - under.size() >= 2) {
                    under.push(kijun);
                    undersum += kijun;

                    kijun = over.top();
                    over.pop();
                    oversum -= kijun;
                }
            }
        } else {
            ll ret = 0;
            if (!over.empty())ret += oversum - kijun * over.size();
            if (!under.empty())ret += kijun * under.size() - undersum;

            cout << kijun << " " << ret + teisuu << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3828
import std.stdio;
import std.algorithm;
import std.array;
import std.string;
import std.math;
import std.conv;

// 昇順に並んだリスト
int solve(int[] list) {
  if ((pow(list[0], 2) + pow(list[1], 2)) ==  pow(list[2], 2)) return 0;
  else if (list[0] == list[1]) return 1;
  return -1;
}

void main() {
  string line;
  int[] table = new int[](2);
  while((line = readln.chomp) != null) {
    int n = line.split(",").map!(to!(int)).array.solve;
    if (n >= 0) table[n]++;
  }
  foreach(t; table) writeln(t);
}

Measured memory_bytes: 1080
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[sc.nextInt()];
        for(int i = 0,n = a.length;i < n;i++) a[i] = sc.nextInt();
        print(a);
        insertSort(a);
        sc.close();
    }

    private static void insertSort(int[] a){
        for(int i = 1,l = a.length;i < l;i++){
            int v = a[i],j = i - 1;
            while(j >= 0 && a[j] > v){
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = v;
            print(a);
        }
    }

    private static void print(int[] a){
        System.out.print(a[0]);
        for(int k = 1,l = a.length;k < l;k++) System.out.print(" " + a[k]);
        System.out.println();
    }

}

Measured memory_bytes: 31188
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 INF = 100005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<P> v;
    int a, b;
    rep(i,m){
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());
    int ans = 1;
    int l = 1, r = INF;
    rep(i,m){
        if(min(r, v[i].second) <= max(l, v[i].first)){
            ans++;
            l = 1; r = INF;
        }
        chmax(l, v[i].first);
        chmin(r, v[i].second);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,i;
cin>>a;
string s;
long long b=0,c=0,d=0,e=0;
while(a--){
    cin>>s;
    if(s[0]=='A')
        b++;
    else if(s[0]=='W')
        c++;
    else if(s[0]=='T')
        d++;
    else if(s[0]=='R')
        e++;
}
cout<<"AC"<<" "<<"x"<<" "<<b<<endl;
cout<<"WA"<<" "<<"x"<<" "<<c<<endl;
cout<<"TLE"<<" "<<"x"<<" "<<d<<endl;
cout<<"RE"<<" "<<"x"<<" "<<e<<endl;

return 0;}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;



int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50
#define PI 3.141592653589793238462643383279502884197169

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a/g * b; //prevent overflow
}

   ////////////////////////  END OF TEMPLATE ////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map<int, int> mp;
    while(n--)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto x: mp)
    {
        if(x.second % 2 == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 8264
loop {
    n, m, a = gets.split.map &:to_i
    break if n == 0
    result = (0..n).to_a
    h_lines = (1..m).map{ gets.split.map &:to_i }.sort_by(&:first).reverse
    h_lines.each{|h, p, q|
        tmp = result[p]
        result[p] = result[q]
        result[q] = tmp
    }
    p result.index(a)
}

Measured memory_bytes: 6136
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
long long n,a[1000000],f[1000000];
int main()
{
    cin>>n;
    for(long i=0;i<n;i++) cin>>a[i];
	f[0]=0;
	f[1]=abs(a[1]-a[0]);
	for(int i=0;i<n;i++)
    {
		if(i>1)
		{
			f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
		}
	}
	cout<<f[n-1]<< endl;
	return 0;
}


Measured memory_bytes: 5120
n,*aa = map(int, open(0).read().split())
MOD = 10**9+7

from collections import defaultdict
from math import sqrt, ceil
def factors(x):
    d = defaultdict(int)
    while x % 2 == 0:
        d[2] += 1
        x //= 2
    for i in range(3, ceil(sqrt(x)) + 2, 2):
        while x % i == 0:
            d[i] += 1
            x //= i
    if x > 1:
        d[x] += 1
    return d

factors_of_aa = list(map(factors, aa))

factors_of_lcm = defaultdict(int)
for factors_of_a in factors_of_aa:
    for k in factors_of_a:
        factors_of_lcm[k] = max(factors_of_lcm[k], factors_of_a[k])
lcm = 1
for factor, cnt in factors_of_lcm.items():
    lcm *= pow(factor, cnt, MOD)

ans = 0
for factors_of_a in factors_of_aa:
    to_add = lcm
    for factor, cnt in factors_of_a.items():
        to_add *= pow(factor, -cnt, MOD)
        to_add %= MOD
    ans += to_add
    ans %= MOD

print(ans)

Measured memory_bytes: 13076
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main :: IO ()
main = do
  ah <- BS.unpack <$> BS.getLine :: IO String
  bh <- BS.unpack <$> BS.getLine :: IO String
  ch <- BS.unpack <$> BS.getLine :: IO String
  let table = (P A ah, P B bh, P C ch)
  putStr $ game table A

type Hands = String 
type Card = Char
data Name = A | B | C deriving Show
data Player = P Name Hands deriving Show
type Table = (Player, Player, Player)

class Play p where
  nextCard :: p -> Maybe Card
  nextHands :: p -> Hands

instance Play Player where
  nextCard (P _ "") = Nothing
  nextCard (P _ (x:_)) = Just x
  nextHands (P _ "") = ""
  nextHands (P _ (_:xs)) = xs
  
showNext :: Maybe Char -> Name
showNext Nothing = A
showNext (Just 'a') = A
showNext (Just 'b') = B
showNext (Just 'c') = C
showNext _ = A

game :: Table -> Name -> String
game (a,b,c) A 
  | isNothing card = "A"
  | otherwise = game (P A hands, b, c) (showNext card)
    where card = nextCard a
          hands = nextHands a
game (a,b,c) B
  | isNothing card = "B"
  | otherwise = game (a, P B hands, c) (showNext card)
    where card = nextCard b
          hands = nextHands b
game (a,b,c) C
  | isNothing card = "C"
  | otherwise = game (a, b, P C hands) (showNext card)
    where card = nextCard c
          hands = nextHands c


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

using namespace std;

int n;

bool isSymmetry(int a, int b, vector<string> s) {
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            if (s.at((i + a) % n).at((j + b) % n) != s.at((j + a) % n).at((i + b) % n)) return false;
        }
    }
    return true;
}

int main() {
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s.at(i);
    int cnt = 0;
    for (int a = 0; a < n; a++) {
        if (isSymmetry(a, 0, s)) cnt++;
    }
    cout << cnt * n << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll N, K, ans;

int main()
{
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (a[i] > a[j])
            {
                if (i < j)
                    ans += K * (K + 1) / 2;
                else
                    ans += K * (K - 1) / 2;
            }
            ans %= mod;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<double> a(n);
	double summ=0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		summ += a[i];
	}
	summ /= n;
	int summm;
	summm = round(summ);

	int summmm=0;
	for (int i = 0; i < n; i++) {
		summmm += (a[i] - summm)*(a[i] - summm);
	}
	cout << summmm << endl;
}

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


int query(int a, int b){
    printf("? %d %d\n", a, b);
    fflush(stdout);
    int d;
    cin >> d;
    return d;
}

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    if (n == 1){
        cout << "! 1" << endl;
        return 0;
    }
    vector<int> A(3 * n);

    int m = 3 * n / 2;
    A[m] = 1;
    int d12 = query(1, 2);
    A[m + d12] = 2;

    for (int i = 3; i <= n; i++){
        int d1, d2;
        d1 = query(1, i);
        d2 = query(2, i);
        if (d1 + d12 == d2)
            A[m - d1] = i;
        else
            A[m + d1] = i;
    }

    auto a = A.begin();
    while (*a == 0) a++;
    cout << "! ";
    for (int i = 0; i < n - 1; i++){
        cout << *a << " ";
        a++;
    }
    cout << *a << endl;

    
}


Measured memory_bytes: 3644
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;

const int N = 1e5 + 5;
const int Mod = 1e9 + 7;


int n;
vector<int> g[N];
int dp[N][2];

void dfs(int u, int p) {
  dp[u][0] = dp[u][1] = 1;
  for(int v : g[u]) {
    if(v != p) {
      dfs(v, u);
      dp[u][0] = (1LL * dp[u][0] * dp[v][1]) % Mod;
      dp[u][1] = (1LL * dp[u][1] * (dp[v][0] + dp[v][1])) % Mod;
    }
  }
}

int main()
{
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].pb(y);
    g[y].pb(x);
  }
  dfs(0, -1);
  int ans = (dp[0][0] + dp[0][1]) % Mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 13440
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    long long Z,W;
    cin >> N >> Z >> W;
    vector<long long> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    
    
    
    
    
    long long a = abs( W - A[N-1] );
    long long b = N >= 2 ? abs( A[N-1] - A[N-2] ) : abs( W - A[N-1] );
    
    cout << ( a >= b ? a : b ) << endl;
    
    
    return 0;
}

Measured memory_bytes: 888
use std::f64;

#[allow(unused)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
#[allow(unused)]
fn round_to_integer(a: f64, digit: u8) -> i64 {
    let mut ai: i64;
    let mut d = digit;
    let mut p = 1;

    while d > 0 {
        p *= 10;
        d -= 1;
    }
    ai = (a * p as f64) as i64;

    while ai as f64 / p as f64 - a > 0.5 / p as f64 {
        ai -= 1;
    }
    while ai as f64 / p as f64 - a < -0.5 / p as f64 {
        ai += 1;
    }
    ai
}

fn main() {
    input! {
        a: u64,
        b: f64,
    }

    let bi = round_to_integer(b, 2);

    let c: u64 = a * bi as u64 / 100;
    println!("{}", c);
}
//664706138336385 9.79
//6507473094313209


Measured memory_bytes: 2204
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}



int main(){
    LL N,M;
    cin >> N >> M;

    LL ans=0;
    LL num_min=min(N,M);
    LL num_max=max(N,M); 
    if(num_min==1 && num_max==1){
        ans=1;
    }
    else{
    if(N==1 || M==1){
        ans=N*M-2;
    }
    else{
    if(num_min>=2){
        ans=(N-2)*(M-2);
    }
    }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


void solve() {
    int n;
    cin >> n;
    using psi = pair<string, int>;
    vector<psi> v(n);
    rep(i, n) cin >> v[i].F >> v[i].S;
    string t;
    cin >> t;
    
    int flg = 0;
    int sum = 0;
    rep(i, n) {
        if (v[i].F == t) {
            flg = 1;
            continue;
        }
        if (flg) sum += v[i].S;
    }
    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}





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

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> Map(N);
	vector<int> Ans(N - 1, -1);
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		Map[A - 1].push_back(B - 1);
		Map[B - 1].push_back(A - 1);
	}
	queue<pair<int, int>> Q;
	Q.push({ 0,-1 });
	while (!Q.empty()) {
		auto p = Q.front();
		int v = p.first, before = p.second;
		Q.pop();
		if (v > 0) {
			if (Ans[v - 1] >= 0) continue;
			Ans[v - 1] = before;
		}
		for (int u : Map[v]) if (Ans[u - 1] < 0) Q.push({ u,v });
	}

	bool OK = true;
	for (int a : Ans) if (a < 0) OK = false;
	if (!OK) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		for (int a : Ans) cout << a + 1 << endl;
	}

}

Measured memory_bytes: 10856
while 1:
    try:
        a=input()
    except:
        break
    b = 0
    c = 0
    for i in range(len(a)-2):
        if a[i:i+3]=='JOI':
            b+=1
        elif a[i:i+3]=='IOI':
            c+=1
        else:
            pass
    print(b)
    print(c)


Measured memory_bytes: 5568
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int ans=1;
    
    for(int i=0;i<n;i++){
        ans=min(ans*2,ans+k);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

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

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

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());    
    int n, m;
    cin >> n >> m;
    ll ans = 100 * (n - m) + 1900 * m;
    forn(i, 0, m) ans *= 2;
    cout << ans << '\n';
}


Measured memory_bytes: 892
#include<stdio.h>
int main()
{
    int x;
    scanf("%d",&x);
    for(int i=-120;i<=120;i++)
    {
        for(int j=-120;j<=120;j++)
        {
            if(i*i*i*i*i-j*j*j*j*j==x)
            {
                printf("%d %d\n",i,j);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 1736