akhauriyash/Code-Regression huggingface dataset:
//
/*
ID: kfoozmi1
LANG: C++
TASK:
*/
#include <bits/stdc++.h>
using namespace std;

#ifdef kfoozminus
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu() {
	cerr << endl;
}

template <typename T>
void faltu(T a[], int n) {
	for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename First, typename ... hello>
void faltu(First arg, const hello&... rest) {
	cerr << arg << ' ';
	faltu(rest...);
}
#else
#define dbg(args...)
#endif

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define SQR(a) ((a) * (a))
#define vsort(v) sort(v.begin(), v.end())
#define memset(a, b) memset(a, b, sizeof a)
#define PQ priority_queue
#define PI acos(-1)
#define EPS 1e-9

#define B1 43
#define B2 43

#define MOD1 1000000007
#define MOD2 1000000009

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

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

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~ (1LL << i)); }
inline bool EQ(double a, double b) { return fabs(a-b) < EPS; }
inline double dist(double ix, double iy, double jx, double jy) { return sqrt(SQR(ix - jx) + SQR(iy - jy)); }

#define PMX 1000000

int marked[PMX/64+2];

#define mark(x) marked[x>>6] |= (1<<((x&63)>>1))
#define check(x) (marked[x>>6] & (1<<((x&63)>>1)))

bool isPrime(int x)
{
    return (x>1) && ((x==2) || ((x&1) && (!(check(x)))));
}

void seive(int n)
{
    int i, j;
    for(i=3; i*i<=n; i+=2)
    {
        if(!check(i))
        {
            for(j=i*i; j<=n; j+=i<<1)
            {
                mark(j);
            }
        }
    }
}

ll bigMod(ll a, ll b, ll MOD)
{
	ll r = 1;
	while(b) {
		if(b & 1) (r *= a) %= MOD;
		b >>= 1;
		(a *= a) %= MOD;
	}
	return r;
}

ll add(ll a, ll b, ll MOD)
{
	ll ret = a + b;
	if(ret >= MOD) ret -= MOD;
	return ret;
}

ll sub(ll a, ll b, ll MOD)
{
	ll ret = a - b;
	if(ret < 0) ret += MOD;
	return ret;
}

ll mul(ll a, ll b, ll MOD)
{
	ll ret = a * b;
	if(ret >= MOD) ret %= MOD;
	return ret;
}

#define INF 100000000
#define MX 100007

map< pll, ll > mp;
ll ans;
vector<int> edge[MX];

pll dfs(int nd)
{
	dbg(nd);
	pll h = {0, 0};
	for(int k = 0; k < edge[nd].size(); k ++) {

		pll p = dfs(edge[nd][k]);
		h.F = add(h.F, p.F, MOD1);
		h.S = add(h.S, p.S, MOD2);
	}
	h.F = add(mul(h.F, B1, MOD1), 1, MOD1);
	h.S = add(mul(h.S, B2, MOD2), 1, MOD1);
	ans += mp[h];
	mp[h] ++;
	return h;
}

int main()
{
#ifdef kfoozminus
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
#endif
	int n, i, u, v;

	scanf("%d", &n);
	for(i = 1; i < n; i ++) {

		scanf("%d %d", &u, &v);
		edge[u].PB(v);
	}
	dfs(1);
	printf("%lld\n", ans);
        return 0;
}

Measured memory_bytes: 22712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC153A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, n, h;
			var word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			h = int.Parse(word[1]);

			if (a % h == 0)
			{
				n = a / h;
				Console.WriteLine(n);
			}
			else
			{
				n = a / h;
				Console.WriteLine(n + 1);
			}

				Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int n;
long long values[maxn];
vector<long long > acc_sum(maxn,0);
vector<long long > acc_xor(maxn,0);
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>values[i];
	for(int i=0;i<n;i++)
	{
		acc_sum[i+1]=acc_sum[i]+values[i];
		acc_xor[i+1]=acc_xor[i]^values[i];
	}
	long long ans=0;
	for(int start=0;start<n;start++)
	{
		int l=start,r=n-1;
		while(l<r)
		{
			int mid=l+(r-l+1)/2;
			long long  _sum=acc_sum[mid+1]-acc_sum[start];
			long long  _xor=acc_xor[mid+1]^acc_xor[start];
			if(_sum==_xor)
				l=mid;
			else
				r=mid-1;
		}
		ans+=l-start+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(){
	int a,b,c,output;
	while (scanf("%d %d", &a, &b) != EOF) {
		c = a + b;
		output = 0;
		while(c>0){
			c /= 10;
			output++;
		}
		printf("%d\n", output);
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 1001000;
char c[N];
int n,s[N],mx[N];
int solve(int lim){
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+(c[i]=='1'?1:-1);
		if(s[i]>lim) return -1;
	}
	mx[n]=s[n];
	for(int i=n-1;i;i--)
		mx[i]=max(mx[i+1],s[i]);
	int tag=0,mn=0;
	for(int i=1;i<=n;i++){
		if(c[i]!='?'){mn=min(mn,tag+s[i]);continue;}
		if(mx[i]+tag+2<=lim) tag+=2;
		mn=min(mn,tag+s[i]);
	}
	return lim-mn;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>c+1;
	n=strlen(c+1);
	int P=0,now=0;
	for(int i=1;i<=n;i++)
		now+=(c[i]=='1'?1:-1),P=max(P,now);
	int ans=1e9;
	for(int i=P;i<=P+1;i++)
		ans=min(ans,solve(i));
	cout<<ans<<'\n';
	return 0;
}



Measured memory_bytes: 12436
import math

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

x_min = math.ceil(a / 0.08)
x_sup = math.ceil((a+1) / 0.08) 
y_min = math.ceil(b / 0.1)
y_sup  = math.ceil((b+1) / 0.1) 

u = set(range(x_min, x_sup))
v = set(range(y_min, y_sup))


w = u & v

s = 0

if len(w) == 0:
    s = -1
else:
    s = min(w)

print(s)


Measured memory_bytes: 3064
N, K = map(int,input().split())
ans = 0
if K <= N:
    ans += (1/N)*(N-K+1)
    dp = [0] + [1/N] * K
else:
    dp = [0] + [1/N] * N + [0] * (K-N)
for i in range(1,K):
    if i % 2 == 0:
        dp[i] += dp[i//2] * (1/2)
if K % 2 == 0:
    ans += sum(dp[K//2:K])*(1/2)
else:
    ans += sum(dp[K//2+1:K])*(1/2)
print(ans)


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll S[3005][3005][5];
ll A[3005][3005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll R, C, N;
    cin >> R >> C >> N;

    memset(S, 0, sizeof(S));
    memset(A, 0, sizeof(A));
    REP(i, N) {
        ll r, c, v;
        cin >> r >> c >> v;
        r--;
        c--;
        A[r][c] = v;
    }

    REP(i, R) {
        REP(j, C) {
            for (ll k = 3; k >= 0; --k) {
                if (j > 0)
                    S[i][j][k] = std::max(S[i][j][k], S[i][j - 1][k]);
            }
            for (ll k = 3; k >= 0; --k) {
                if (k > 0)
                    S[i][j][k] = std::max(S[i][j][k], S[i][j][k - 1] + A[i][j]);
                S[i + 1][j][0] = std::max(S[i + 1][j][0], S[i][j][k]);
            }
        }
    }

    ll ans = 0;
    REP(i, 4) {
        ans = std::max(S[R - 1][C - 1][i], ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,t;
    cin >> n >> t;
    int table[n];
    for(int i=0; i<n; i++){
        cin >> table[i];
    }

    int max_table[n];
    max_table[n-1] = table[n-1];
    for(int i=n-2; i>=0; i--){
        max_table[i] = max(max_table[i+1], table[i]);
    }

    int max = 0;
    int same_count = 0;
    for(int i=0; i<n; i++){
        if(max < max_table[i]-table[i]){
            max = max_table[i] - table[i];
            same_count = 1;
        }else if(max == max_table[i] - table[i]){
            same_count ++;
        }
    }


    cout << same_count << endl;
}

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

int main()
{
	int a;
	cin >> a;
	if (a % 2 == 0)
	{
		cout << (a / 2)*(a / 2);
	}
	else
	{
		cout << (a / 2)*(a / 2 + 1);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll int n,a,b,l,m,x;
	
	cin>>n>>a>>b;
	
	

		l=n%(a+b);
		m=n/(a+b);
		if(l>=a)
		l=a;
	    x=(a*m)+l;
	    cout<<x;
	
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,n,sum=0,i=0;
  cin >> N;
  n = N;
  
  while(n != 1){
    if(n % 10 != 0){
      n -= 1;
      i += 1;
    }else{
      n /= 10;
      sum += i;
      i = 0;
    }
  }
  if(i != 0){
    sum += i;
  }
  sum += 1;
  
  if(N % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef struct directed_edge {
  int32_t vertex;
  int32_t next;
} graph_edge;

typedef struct directedGraph {
  graph_edge *edge;
  int32_t *start;
  int32_t pointer;
  int32_t vertex_num;
  int32_t max_size;
} graph;

graph* newGraph (const int vertex_num) {
  graph *g = (graph *) calloc (1, sizeof (graph));
  g->edge = (graph_edge *) calloc (1, sizeof (graph_edge));
  g->start = (int32_t *) calloc (vertex_num, sizeof (int32_t));
  g->pointer = 0;
  g->vertex_num = vertex_num;
  g->max_size = 1;
  for (int32_t i = 0; i < vertex_num; ++i) {
    g->start[i] = -1;
  }
  return g;
}

void addEdge (graph *g, int32_t from, int32_t to) {
  if (g->pointer == g->max_size) {
    g->max_size *= 2;
    g->edge = (graph_edge *) realloc (g->edge, sizeof (graph_edge) * g->max_size);
  }
  g->edge[g->pointer] = (graph_edge) {to, g->start[from]};
  g->start[from] = g->pointer++;
}

typedef int32_t i32;

void dfs (i32 v, uint8_t *used, graph *g) {
  for (i32 p = g->start[v]; p != -1; p= g->edge[p].next) {
    i32 u = g->edge[p].vertex;
    if (used[u]) continue;
    used[u] = 1;
    dfs (u, used, g);
  }
}

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  i32 *cnt = (i32 *) calloc (n, sizeof (i32));
  graph *g = newGraph (n);
  for (i32 i = 0; i < m; ++i) {
    i32 a, b;
    scanf ("%" SCNi32 "%" SCNi32, &a, &b);
    a--;b--;
    addEdge (g, a, b);
    addEdge (g, b, a);
    cnt[a]++;
    cnt[b]++;
  }
  for (i32 i = 0; i < n; ++i) {
    if (cnt[i] & 1) {
      puts ("No");
      return;
    }
  }
  i32 d = 0;
  for (i32 i = 0; i < n; ++i) {
    if (cnt[i] >= 6) {
      puts ("Yes");
      return;
    }
    if (cnt[i] == 4) {
      d++;
    }
  }
  if (d != 2) {
    puts(d >= 3 ? "Yes" : "No");
    return;
  }
  i32 k;
  for (k = 0; cnt[k] != 4; ++k);
  uint8_t *used = (uint8_t *) calloc (m, sizeof (uint8_t));
  used[k] = 1;
  dfs (k == 0 ? 1 : 0, used, g);
  for (k = 0; k < n && used[k]; ++k);
  puts (k < n ? "Yes" : "No");
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 3968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



namespace ConsoleApplication3
{

    class process
    {
        public string name;
        public int time;
    }

    class Program
    {


        static void Main(string[] args)
        {
            string temp;
            string[] input;
            var list = new List<process>();
            int position = 0,number,quantum,remaining,spent = 0,counter;
            temp = Console.ReadLine();
            input = temp.Split(' ');
            number = int.Parse(input[0]);
            quantum = int.Parse(input[1]);
            counter = number;
            
            for(int i=0;i<number;i++)
            {
                temp = Console.ReadLine();
                input = temp.Split(' ');
                process data = new process();
                list.Add(data);
                data.name = input[0];
                data.time = int.Parse(input[1]);
  
            }

            int location = 0;            
            while (counter != 0)
            {

               if (location >= list.Count)
                         location = 0;
                remaining = list[location].time;
                    if (remaining <= quantum)
                    {
                        spent += remaining;
                        Console.WriteLine("{0} {1}", list[location].name, spent);
                        counter--;
                        list.RemoveAt(location);
                    }
                    else
                    {
                        list[location].time = remaining - quantum;
                        spent += quantum;
                        location++;

                    }

            }

 



        }
    }
}



Measured memory_bytes: 26184
# -*- coding: utf-8 -*-                                                                                 
import sys, heapq                                                                                       
# ----------------------------------------------------------------                                      
# Use Solve Function                                                                                    
                                                                                                        
def solve(lines):                                                                                       
    N,M = map(int, lines.pop(0).split(' '))                                                             
    NLIST = []                                                                                          
    for i in range(N):                                                                                  
        A,B = map(int, lines.pop(0).split(' '))                                                         
        heapq.heappush(NLIST, (A, B))                                                                   
                                                                                                        
    res = 0                                                                                             
    while(True):                                                                                        
        p = heapq.heappop(NLIST)                                                                        
        if ( p[1] >= M ):                                                                               
            res += M * p[0]                                                                             
            break                                                                                       
        else:                                                                                           
            res += p[0] * p[1]                                                                          
            M -= p[1]                                                                                   
                                                                                                        
                                                                                                        
    print(res)                                                                                          
                                                                                                        
lines = [x.strip() for x in sys.stdin.readlines()]                                                      
                                                                                                        
#                                                                                                       
# solve !!                                                                                              
#                                                                                                       
solve(lines) 

Measured memory_bytes: 19028
//***********************
//Author:kibi11
//Quarantine Days
//***********************

#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fr(i, n) for(int i = 0; i < n; i++)
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,k) for(int i=a;i>=k;i--)
#define same int t;cin>>t;while(t--)
#define check(x) cout << (#x) << " is " << (x) << endl;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define f first
#define s second
#define XOX
#define pi = 3.14159265358979323846

//////////////////////////////////////////////////////////////////////////
/////////////////DEBUGING ZONE//////////////////////////////

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
///////////////////////////////////////////////////////////////////////////
 
ll powermod(ll base, ll exp, ll mod) {
	ll result = 1;
	while (exp != 0) {
		if ((exp % 2) == 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return result;
}

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

// check a cycle in a directed graph: source codeforces;

// void dfs(int v, int p){
//   color[v] = 1; // GREY
//   for(int w : g[v]){
//     if(color[w] == 1){
//       // you found a cycle, it's easy to recover it now.
//     }
//     if(color[w] == 0) dfs(w, v);
//   }
//   color[v] = 2; // BLACK
// }


///////////////////////////////////////////////////////////////////////////
//Fuctions if any:





///////////////////////////////////////////////////////////////////////////
int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = clock();
//ios_base& scientific (ios_base& str);

int n;
cin>>n;
int a[n];
ll sum=0;
fr(i,n)
{
	cin>>a[i];
}
int mx=0;
fr(i,n)
{
	mx=max(mx,a[i]);
	if(mx>a[i])
	{
		sum+=mx-a[i];
	}
}
cout<<sum<<endl;
cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
return 0;
}

Measured memory_bytes: 4520
#include<iostream>
#include<algorithm>
using namespace std;
int niz[100005],niz1[100005],niz2[100005];
int rj[100005],rj1[100005],rj2[100005];
int main () {
	
	int n;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>niz[i]>>niz1[i]>>niz2[i];
	}
	rj[0]=niz[0];
	rj1[0]=niz1[0];
	rj2[0]=niz2[0];
	for(int i=1; i<n; i++){
		rj2[i]=niz2[i]+max(rj1[i-1],rj[i-1]);
		rj1[i]=niz1[i]+max(rj[i-1],rj2[i-1]);
		rj[i]=niz[i]+max(rj1[i-1],rj2[i-1]);
	}
	cout<<max(rj[n-1],max(rj1[n-1],rj2[n-1]));
	
	return 0;
}

Measured memory_bytes: 2560
use proconio::{input, marker::Chars, source::line::LineSource};
use std::io::stdin;

fn main() {
    let stdin = stdin();
    let mut src = LineSource::new(stdin.lock());
    input! {
        from &mut src,
        t: usize,
    }
    for _ in 0..t {
        input! {
        from &mut src,
            n: usize,
            aa: [u64; n],
            s: Chars
        }
        solve(aa, s);
    }
}

fn solve(aa: Vec<u64>, s: Vec<char>) {
    let mut dp: Vec<u64> = vec![];
    for (mut a, c) in aa.into_iter().zip(s.into_iter()).rev() {
        for &v in dp.iter() {
            let t = 1 << v.trailing_zeros();
            if t & a != 0 {
                a ^= v;
            }
        }
        if c == '0' {
            if a != 0 {
                dp.push(a);
            }
        } else {
            if a != 0 {
                println!("1");
                return;
            }
        }
    }
    println!("0");
}


Measured memory_bytes: 2152
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;


int main() {
	ll n;
	string s;
	cin >>s;
	n = s.size();
	ll ans = 0;
	ll cnt = 0;
	rep(i, n) {
		if (s[i] == 'B') cnt++;
		else ans += cnt;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
string s, l;
signed main(){
	string s, l;
	int x=0;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0'){
			l[x]='0';
			x++;
		}
		if(s[i]=='1'){
			l[x]='1';
			x++;
		}
		if(s[i]=='B'){
			if(x-1>=0){
				l[x-1]=' ';
				x--;
			}
		}
	}
	for(int i=0;i<x;i++){
		cout << l[i];
	}
	cout << endl;
return 0;
}

Measured memory_bytes: 256
def solve():
    H, W = map(int, input().split())
    grid = [[] for _ in range(H)]
    for i in range(H):
        grid[i] = list(map(int, input().split()))
    
    ans = []
    for i in range(H):
        for j in range(W - 1):
            if grid[i][j] % 2 == 1:
                grid[i][j + 1] += 1
                ans += [(i + 1, j + 1, i + 1, j + 2)]
    for i in range(H - 1):
        if grid[i][W - 1] % 2 == 1:
            grid[i + 1][W - 1] += 1
            ans += [(i + 1, W, i + 2, W)]
    
    N = len(ans)
    print(N)
    for ans_i in ans:
        print(' '.join(map(str, ans_i)))


if __name__ == '__main__':
    solve()


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

long long int mky(long long int x, long long int y) {
  long long int M = max(x,y);
  long long int m = min(x,y);
  while (M%m!=0) {
    long long int p = m;
    m = M % m;
    M = p;
  }
  return m;
}

int main() {
  long long int x, y, z;
  cin >> x >> y;
  z = mky(x, y);
  int zz = sqrt(z);
  int q[zz+1];
  int s = 1;
  if (z ==1) {
    cout << 1 <<endl;
  }
  else if (z == 2 || z == 3) {
    cout << 2 <<endl;
  }
  else {
  for (int i = 2; i <= zz; i++) {
    int c = 0;
    while (z%i==0) {
      z/=i;
      c++;
      if (c == 1) {
        s++;
      }
    }
  }
  if (z != 1) {
    s++;
  }
  printf("%lld\n", s);
  }
}

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

string str[5]={"dream","dreamer","erase","eraser"},a;

void dfs(int pos)
{
	if(pos==a.size())
	{
		puts("YES");
		exit(0);
	}
	bool res=0;
	if(a.substr(pos,5)==str[0]) dfs(pos+5);
	if(a.substr(pos,5)==str[2]) dfs(pos+5);
	if(a.substr(pos,6)==str[3]) dfs(pos+6);
	if(a.substr(pos,7)==str[1]) dfs(pos+7);
}

int main()
{
	ll i,j,p,q;
	cin>>a;
	dfs(0);
	puts("NO");
}

Measured memory_bytes: 1792
import math
a=input().split()
n=int(a[0])
p=int(a[1])
d=dict()
rest=p
i=2
while i<=math.sqrt(rest):
    if rest%i==0:
        rest=rest/i
        d[i]=d.get(i,0)+1
        continue
    i=i+1

d[rest]=d.get(rest,0)+1

res=1
for key in d.keys():
    if d[key]>=n:
        tmp=math.pow(key,int(d[key]/n))
        res=res*tmp
print(int(res))

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>

#define ll long long
#define maxn 50
#define maxx 10000000000

ll a[maxn + 1], b[maxn + 1], c[maxn + 1], d[maxn + 1];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%lld%lld", &a[i], &b[i]);
    }
    for (int i = 1; i <= m; i++) {
        scanf("%lld%lld", &c[i], &d[i]);
    }
    for (int i = 1; i <= n; i++) {
        ll min = maxx + 2;
        ll rez = -1;
        for (int j = 1; j <= m; j++) {
            ll l = std::abs(a[i] - c[j]) + std::abs(b[i] - d[j]);
            if (min > l) {
                min = l;
                rez = j;
            }
        }
        printf("%lld", rez);
        printf("%c", '\n');
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,sum;
  string s;
  long long min,max;
  vector<int> S{1,2,3,4,5,6,7,8,9,10,11,12,13};
  vector<int> H{1,2,3,4,5,6,7,8,9,10,11,12,13};
  vector<int> C{1,2,3,4,5,6,7,8,9,10,11,12,13};
  vector<int> D{1,2,3,4,5,6,7,8,9,10,11,12,13};

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s >> x;
    if(s == "S"){
      S.erase(std::remove(S.begin(), S.end(), x), S.end());
    } else if (s == "H"){
      H.erase(std::remove(H.begin(), H.end(), x), H.end());    
    } else if (s == "C"){
      C.erase(std::remove(C.begin(), C.end(), x), C.end());   
    } else if (s == "D"){
      D.erase(std::remove(D.begin(), D.end(), x), D.end());   
    }
  } 
  
  for (int i = 0; i < S.size(); i++) {
    cout << "S " << S.at(i) << endl;
  } 
    for (int i = 0; i < H.size(); i++) {
    cout << "H " << H.at(i) << endl;
  } 
    for (int i = 0; i < C.size(); i++) {
    cout << "C " << C.at(i) << endl;
  } 
    for (int i = 0; i < D.size(); i++) {
    cout << "D " << D.at(i) << endl;
  } 
}


Measured memory_bytes: 3180
/*---> praveenojha33 <---> 03 September 2019 <--- > 14:05:01 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n;
	cin>>n;
	double sumi=0.0;
	int x;
	for(int i=0;i<n;i++){
		cin>>x;
		sumi+=((double)1/x);
	}
	cout<<setprecision(15)<<fixed<<(1.0/sumi)<<"\n";
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define INF 999999999999

int main(){
  ll N,K,cnt=2;
  cin>>N>>K;

  if(N<K){
    cout<<"1"<<endl;
    return 0;
  }else if(N<2*K){
    cout<<"2"<<endl;
    return 0;
  }else{
    while((N-N%K)/K>=K){
      cnt++;
      N=(N-N%K)/K;
    }
  }

  cout<<cnt<<endl;
return 0;
}


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

const int MAXN = 2e3 + 5;

int N, K, Q;
int a[MAXN];

void load() {
	scanf("%d%d%d", &N, &K, &Q);
	for (int i = 0; i < N; i++)
		scanf("%d", a + i);
}

bool check(int diff) {
	for (int i = 0; i < N; i++) {
		int block = 0, cnt = 0, taken = 0;		
		for (int j = 0; j <= N; j++)
			if (a[j] < a[i]) {
				taken += min(cnt, max(block - K + 1, 0));
				block = cnt = 0;
			}
			else {
				block++;
				cnt += a[j] <= a[i] + diff;
			}
		if (taken >= Q)
			return true;
	}
	return false;
}

int solve() {
	int lo = 0, hi = 1e9;
	while (lo < hi) {
		int mid = (lo + hi) / 2;
		if (check(mid))
			hi = mid;
		else
			lo = mid + 1;
	}
	return lo;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int D,G;
    cin>>D>>G;
    
    int p[D],c[D];
    for(int i=0;i<D;i++) cin>>p[i]>>c[i];
    
    int ans=1e9;
    for(int mask=0;mask<(1<<D);mask++){
        int s=0,num=0,rest_max=0;
        for(int i=0;i<D;i++){
            if(mask>>i&1){
                s+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }else{
                rest_max=i;
            }
        }
        if(s<G){
            int s1=100*(rest_max+1);
            int need=(G-s+s1-1)/s1;
            if(need>p[rest_max])continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;


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

    vector<int>a(n+2);
    rep2(i,1,n)cin>>a[i];

    vector<int>l(n+2),r(n+2);
    l[0]=a[0];
    r[n+1]=a[n+1];

    rep2(i,1,n+1)l[i]=max(l[i-1],a[i]);
    repr(i,n,1)r[i]=max(r[i+1],a[i]);

    rep2(i,1,n){
        cout<<max(l[i-1],r[i+1])<<endl;
    }

}


Measured memory_bytes: 3968
import java.util.Scanner;
public class Main{
    public static Scanner scn=new Scanner (System.in);
    public static void main(String []args){
        ans();
    }
    public static void ans(){
    int x=scn.nextInt();
    int a=(x/500 )*1000;
    int b=(x%500);
   b=b/5;
   b=b*5;
    System.out.print(a+b);

    
    }
}
  

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll H1, M1;
    ll H2, M2;
    cin >> H1 >> M1 >> H2 >> M2;

    const ll T = (H2 - H1) * 60 + (M2 - M1);

    ll K;
    cin >> K;

    cout << T - K << endl;

    return 0;
}


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

typedef long long ll;

ll f(ll x)
{
	return x + 3 * x * (x - 1) + x * (x - 1) * (x - 2);
}

int main()
{
	ll n, k;	cin >> n >> k;
	ll ans = 0;
	ll t1 = n / k;
	ans += f(t1);
	if(k % 2 == 0)
	{
		ll t2 = n / k;
		if(n % k >= k / 2)	t2 ++;
		ans += f(t2);
	}
	cout << ans << endl;
}

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

int main()
{
    int k;
    std::cin >> k;

    int sum = 0;
    for (int a = 1; a <= k; ++a)
    {
        for (int b = 1; b <= k; ++b)
        {
            int gcd_ab = std::gcd(a, b);
            for (int c = 1; c <= k; ++c)
            {
                sum += std::gcd(gcd_ab, c);
            }
        }
    }

    std::cout << sum << std::endl;
}


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

#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cerr << #x << " = " << x << endl;

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}

void solve(); signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\artma\\CLionProjects\\problems\\input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
    return 0;
}

const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;

void solve() {
    string s;
    cin >> s;
    int ans = 0;
    for (int mask = 0; mask < (1ll << (sz(s) - 1)); ++mask) {
        vec<int> id;
        for (int i = 0; i < sz(s) - 1; ++i) {
            if ((mask >> i) & 1) {
                id.pb(i);
            }
        }
        id.pb(sz(s) - 1);
        id.insert(id.beg(), -1);
        for (int i = 1; i < sz(id); ++i) {
            string t = s.substr(id[i - 1] + 1, id[i] - id[i - 1]);
            ans += stoll(t);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>
#include<random>
#include<thread>

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/rope>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define vpii vector<pair<int,int>>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-10;
const ll mod=1e9+7;


int main(){
    CPPinput;
    int a,b,c; cin>>a>>b;
    for(int c=1;c<=3;++c){
        if(a*b*c%2){
            Yes;
            exit(0);
        }
    }
    No;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

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

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    double n,m,d;
    cin >> n >> m >> d;

    if(d == 0){
        printf("%.10f\n",(m-1)*(1/n));
    }else{
        printf("%.10f\n",(m-1)*( (2*(n-d))/(n*n) ) );
    }
    
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>

typedef unsigned long long int ull;
typedef long long int ll;

using namespace std;

int main(void) {
    long pos[2] = {0},time = 0;
    long t,x,y,n;
    cin >> n;
    for(int i = 0;i <n;i++) {
        cin >> t >> x >> y;
        long distance = abs(pos[0] - x) + abs(pos[1] - y);
        if(distance > t - time || (distance - (t - time)) % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
        time = t;
        pos[0] = x;
        pos[1] = y;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;
map<int,int>mp;
int main()
{
	int a,b,f=0;
	double x,y;
	cin>>a>>b;
	x=a/0.08;y=(a+1)/0.08;
	for(int i=ceil(x);i<y;i++)mp[i]++;
	x=b/0.1;y=(b+1)/0.1;
	for(int i=ceil(x);i<y;i++)
	{
		mp[i]++;
		if(mp[i]>1)
		{
			cout<<i<<endl;
			f=1;
			break;
		}
	}
	if(f==0)cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N (1001)
using namespace std;
int n,a[N],Keg[N],maxn;
int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; ++i)
	{
		scanf("%d",&a[i]);
		Keg[a[i]]++; maxn=max(maxn,a[i]);
	}
	for (int i=(maxn+1)/2; i<=maxn; ++i)
	{
		if (maxn%2==0 && i==(maxn+1)/2) Keg[i]-=1;
		else Keg[i]-=2;
		if (Keg[i]<0){puts("Impossible"); return 0;}
	}
	for (int i=1; i<=(maxn+1)/2; ++i)
		if (Keg[i]) {puts("Impossible"); return 0;}
	puts("Possible");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a, b, i, k;
    cin >> a >> b;
    if (a <= b) {
        for (i = 0; i < b; i++) {
            cout << a;
        }
    }
    else {
        for (k = 0; k < a; k++) {
            cout << b;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
   int a[101][101]={0};
   int rows,columns,i,j,x,sum;
   sum=0;
   scanf("%d %d",&rows,&columns);

   for(i=0;i<rows;i++){
       for(j=0;j<columns;j++){
           scanf("%d",&a[i][j]);      
       }
   }

   for(i=0;i<rows;i++){
       sum=0;
       for(j=0;j<columns;j++){
           sum += a[i][j];
       }
       a[i][columns]=sum;
   }
   for(j=0;j<columns;j++){
       sum=0;
       for(i=0;i<rows;i++){
           sum += a[i][j];
       }
       a[rows][j]=sum;
   }
   sum=0;
   for(i=0;i<rows;i++){
       for(j=0;j<columns;j++){
           sum += a[i][j];
       }
       a[rows][columns]=sum;
   }
   for(i=0;i<rows+1;i++){
       for(j=0;j<columns+1;j++){
           if(j==columns){
               printf("%d",a[i][j]);
           }else{
               printf("%d ",a[i][j]);
           }
           
       }
       printf("\n");
   }

    return 0;
}


Measured memory_bytes: 2100
N = int(input())
A = sorted([int(input()) for i in range(N)])

a = [0] * N
b = [0] * N
j = 1

for i in range(N-1):    
    a[i] += -j
    a[i+1] += j
    b[i] += j
    b[i+1] += -j    
    j = -j

a.sort()
b.sort()
s1 = sum([i*j for i,j in zip(a, A)])
s2 = sum([i*j for i,j in zip(b, A)])
print(max(s1,s2))

Measured memory_bytes: 12600
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);
const gcd = (a, b) => b === 0 ? a : gcd(b, a%b);
console.log(gcd(...line[0].split(' ').map(x => parseInt(x))));


Measured memory_bytes: 17208
#include<stdio.h>

int main(void){

    long long N;
    long long i;
    long long sum=0;

    scanf("%lld",&N);

    for(i=1;i<=N;i+=1){

        if(i>2){
            if(i%3==0){
                continue;
            }else if(i%5==0){
                continue;
            }
        }
        sum+=i;

    }

    printf("%lld",sum);

    return 0 ;

}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define LL long long
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(x,l,r) for(int x=l,x##_=r;x<=x##_;x++)
#define FR(x,l,r) for(int x=l,x##_=r;x<x##_;x++)
#define DOR(x,r,l) for(int x=r,x##_=l;x>=x##_;x--)
using namespace std;
const int N=100005;
int n,A[N],ans[N];
LL s=0;
int main() {
	scanf("%d",&n);
	FOR(i,1,n){
		scanf("%d",&A[i]);
		s+=A[i];
	}
	A[n+1]=A[1];
	for(int i=2; i<=n; i+=2)s-=2*A[i];
	ans[1]=s;
	FOR(i,2,n)ans[i]=A[i-1]*2-ans[i-1];
	FOR(i,1,n)printf("%d ",ans[i]);
	return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
//typedef __int128_t Int;
#define DBG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define loop(n) rep(loop,(0),(n))
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
using pii = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);

  int N=3;
  vector<int> v(N); rep(i, 0, N){ cin >> v[i]; }
  sort(all(v));
  int ans=0;
  rep(i,0,2){
    ans+=v[i+1]-v[i];
  }
  cout<<ans<<endl;

    return 0;
}


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

int main() {

    int N, X, T;
    cin >> N >> X >> T;

    cout << ((N + X - 1) / X) * T << endl;

    return 0;
}


Measured memory_bytes: 3620
import fractions

a, b, c, d = map(int, input().split())
e = c*d//fractions.gcd(c,d)


i = (a-1) // c #aのcの約数の数
j = b // c #bのcの約数の数
k = (a-1) // d #aのdの約数の数
l = b // d #bのdの約数の数
m = (a-1) // (e) #aのc*dの約数の数
n = b // (e) #bのc*dの約数の数

x = (j-i) + (l-k) - (n-m)
y = b - a + 1
print(y-x)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

int n;
int c[500], s[500], f[500];
int ans = 0;

//時刻tに駅iを出発して、最初に駅Nに着く時刻
int func(int t, int i){
  if(i == n-1) return t;
  //次の電車の発車時刻
  int k = 0;
  while(t > s[i] + k * f[i]) k++;
  return func(s[i] + k*f[i] + c[i], i+1);
}
  

int main(){
  cin >> n;
  rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
  rep(i, n) cout << func(s[i], i) <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

   string S,T;
   cin >> S >> T;
   int flag=0;
   for(int i=0;i<S.length();i++){
      if(S[i]!=T[i]){
         flag=1;
         break;
      }
   }
   if(flag==1){
      cout << "No" << endl;
   }else{
      cout << "Yes" << endl;
   }
   
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;

long long arr[N];
int solve()
{
    string s;
    cin>>s;
    int n=s.size();
    stack<char> ans;
    for(int i=0;i<n;i++)
    {
       if(s[i]=='B') {
           if (ans.size())
               ans.pop();
       }
       else
           ans.push(s[i]);
    }
    s="";
    while(ans.size())
    {
        s+=ans.top();
        ans.pop();
    }
    reverse(s.begin(), s.end());
    cout<<s;
    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("input.txt" ,"r" ,stdin);
   // freopen("output.txt" ,"w" ,stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   // int t;
   // cin>>t;
   // while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3608