akhauriyash/Code-Regression huggingface dataset:
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int P, Q, R;
    cin >> P >> Q >> R;
    int mx = max(P, max(Q, R));
    cout << P + Q + R - mx << endl;
    return 0;
    
}



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

using namespace std;
using ll = long long;

struct C {
    ll H_{};
    vector<ll> a_{};
    vector<ll> b_{};
    explicit C(ll H, vector<pair<ll, ll>> v) : H_(H) {
        for (auto&& p : v) {
            a_.emplace_back(p.first);
            b_.emplace_back(p.second);
        }
    }
    ll resolve() {
        ll N = a_.size();
        sort(a_.begin(), a_.end());
        ll maxA = a_[N-1];
        b_.erase(remove_if(b_.begin(), b_.end(), [&maxA](auto x) { return x <= maxA ;}), b_.end());
        sort(b_.begin(), b_.end(), greater<>());
        ll count = 0;
        for(auto x : b_) {
            H_ -= x;
            count++;
            if (H_ <= 0) {
                break;
            }
        }
        if (H_ > 0) {
            count += (H_ + maxA - 1) / maxA;
        }
        return count;
    }
};

int main() {
    ll N, H;
    cin >> N >> H ;
    vector<pair<ll, ll>> v{};
    for (int i=0; i < N; ++i) {
        ll a, b;
        cin >> a >> b;
        v.emplace_back(make_pair(a, b));
    }
    C c{H, move(v)};
    cout << c.resolve() << endl;
    return 0;
}


Measured memory_bytes: 4720
#include<iostream>
using namespace std;
int search(int a[], int n, int key) {
    int i = 0;
    a[n] = key;
    if (a[0] == key) {
        return -1;
    }
    while (a[i] != key) {
        i++; //check i == n, and a[i]
    }
    if (i == n) {
        return 0;
    } else {
        return i;
    }
}
int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int q;
    cin >> q;
    int b[q];
    for (int i = 0; i < q; ++i) {
        cin >> b[i];
    }
    int sum = 0;
    for (int i = 0; i < q; ++i) {
        int key = b[i];
        if (search(a, n, key)) {
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}





Measured memory_bytes: 3124
def main():
    H,W = map(int, input().split())  
    M=[]
    x = [1,0,-1,0,1,-1,1,-1]
    y = [0,1,0,-1,1,-1,-1,1]
    for i in range(H):
        M.append(input())
    
    for i in range(H):
        for j in range(W):
            if M[i][j]=='.':
                cnt=0
                for k in range(8):
                    cx = j + x[k]
                    cy = i + y[k]
                    if cx >=0 and cx < W and cy>=0 and cy <H:
                        if M[cy][cx] == '#':
                            cnt+=1
                str_list = list(M[i])
                str_list[j] = str(cnt)
                str_changed = "".join(str_list)
                M[i] = "".join(str_list)
        
    for i in range(H):
        print(M[i])



if __name__ == '__main__':
    main()


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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK (cerr <<"OK"<< endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

const int MOD = 1E9 + 7;

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

int power(int x, int p, int MOD) {
  if(p == 0)
    return 1%MOD;
  if(p == 1) 
    return x%MOD;
  int res = power(x, p/2, MOD);
  res = (long long)res*res%MOD;
  if(p&1) 
    res = (long long)res*x%MOD;
  return res;
}

// A*B = x (mod m)
// B = x * A^(-1)
// Function to find modular inverse of a under modulo m 
// Assumption: m is prime 
int modInverse(int a, int mod) { 
  int g = gcd(a, mod); 
  if (g != 1) 
      return -1; 
  else
    // If a and m are relatively prime, then modulo inverse 
    // is a^(m-2) mod m 
    return power(a, mod-2, mod);
}

int mod(int n) {
  return ((n % MOD) + MOD) % MOD;
}

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

  int n, a, b;

  cin >> n >> a >> b;

  int ans = power(2, n, MOD);
  ans = mod(ans - 1);
  vector<int> fat(2e5 + 1, 1);
  for(int i = 1; i < fat.size(); i++) {
    fat[i] = i * fat[i - 1];
    fat[i] = mod(fat[i]);
  }

  {
    int aa = 1;
    for(int i = n, k = 0; k < a; k++, i--) {
      aa *= i;
      aa = mod(aa);
    }
    aa *= modInverse(fat[a], MOD);
    ans = mod(ans - mod(aa));
  }

  {
    swap(a, b);
    int aa = 1;
    for(int i = n, k = 0; k < a; k++, i--) {
      aa *= i;
      aa = mod(aa);
    }
    aa *= modInverse(fat[a], MOD);
    ans = mod(ans - mod(aa));
  }

  cout << ans << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll H,W;
    cin >> H >> W;
    if(H==1||W==1){
        cout << 1 << endl;
        return 0;
    }
    if(H*W%2==0){
        cout << H*W/2 << endl;
    }else{
        cout << (H*W+1)/2<<endl;
    }
}


Measured memory_bytes: 256
// A - Takoyaki
import { readFileSync } from 'fs';
const input = readFileSync('/dev/stdin', 'utf8');

const [N, X, T] = input.split(' ').map((s) => parseInt(s));

let now = N;
let time = 0;

while (now > 0) {
  now = now - X;
  time = time + T;
}

console.log(time);


Measured memory_bytes: 29676
from math import ceil
from fractions import Fraction

N = int(input())

t, a = 1, 1
for T, A in [tuple(map(int, input().split())) for _ in range(N)]:
    n = max(ceil(Fraction(t, T)), ceil(Fraction(a, A)))
    t, a = n * T, n * A
print(t + a)


Measured memory_bytes: 67436
//----------------------Shanu Garg here---------------------
//-------------Search on youtube : Shanu Garg---------------
//-Studying at National Institute of Technology Delhi(NITD)-
//---------------------From Delhi, India--------------------

#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define nl cout<<"\n";
#define chk(x) cout<<#x<<" : "<<x, nl
#define ll long long int
#define u unsigned
#define vi vector<int>
#define vvi vector<vi>
#define pr pair<ll, ll>
#define vii vector<pair<int, int>>
#define vll vector<pr>
#define vl vector<ll>
#define m(a,b) map<a, b>
#define ci m(char, ll)
#define ii m(ll, ll)
#define mid(a,b) ((a+b)/2)
#define pb push_back
#define LCM(a,b) ((a*b)/__gcd(x,y))
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;

class triplet{
    ll f, s, t;};

vl in(ll n){vl v;ll x;
    f(i,n)
    cin>>x, v.pb(x);
    return v;}
void out(vl v){
    fl(i,v)cout<<i;
}
void out(vl v, char ch){
    fl(i,v)
    cout<<i<<ch;
}

void solve(){
   ll N,ans=-1 ,size=1;
   cin>>N;
   vl v=in(N);
   f(i, N-1)
   if(v[i+1]<=v[i])
   size++;
   else{
       ans=max(ans, size);
       size=1;
   }

   cout<<max(ans, size)-1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
   return 0;
}

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

int fun(int h,int w,int i,int j){
	int a,b;
	a = h*h + w*w;
	b = i*i + j*j;
	if(a>b) return 1;
	else if(a == b && h>i) return 1;

  return 0;
}
int main(){
  int h,w,a,b;
  while(1){
	int mh = 150,mw = 150; 
	cin >> h >> w;
	if(h==0 && w==0) break;

	for(int i=1; i<150; i++){
	  for(int j=i+1; j<= 150; j++){
		if(h == i && w == j){
		} else if(fun(i,j,h,w) == 1){
			if(fun(mh,mw,i,j) == 1){
			  mh = i;
			  mw = j;
		  	}
		}
	  }
	}
	cout << mh << " " << mw << endl;
  }
  return 0;
}


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

b=0

for i in a:
    if(i==0):
        b=1

if b:
    print(0)
    exit()

ans=1

for i in a:
    ans*=i
    if(ans>1000000000000000000):
        print(-1)
        exit()

print(ans)



Measured memory_bytes: 21744
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 2; i < n; i++){
        if (s[i-2] == 'A' && s[i-1] == 'B' && s[i] == 'C') ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

money = 1000
ticket = 0
for i in range(N - 1):
    # buy
    if A[i] < A[i + 1]:
        ticket += money // A[i]
        money -= (money // A[i]) * A[i]
    elif A[i] == A[i + 1]:
        pass
    # sell
    else:
        money += A[i] * ticket
        ticket = 0

money += A[-1] * ticket

print(money)


Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int A,B,C;

int main(){
    cin>>A>>B>>C;
    
    cout<<max(0,B+C-A)<<endl;
}

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

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

using namespace std;

bool dfs(string s){
	if(s=="AKIHABARA") return true;
	if(s.length()>=9) return false;
	rep(i,s.length()+1) if(dfs(s.substr(0,i)+"A"+s.substr(i))) return true;
	return false;
}

int main(){
	string s; cin>>s;
	puts(dfs(s)?"YES":"NO");
	return 0;
}


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

int main(){
    int x;
    cin >> x ;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vll V[8];
  int n,m;
  cin >> n >> m;
  REP(i,n){
    ll x,y,z;
    cin >> x >> y >> z;
    V[0].push_back(x+y+z);
    V[1].push_back(x-y+z);
    V[2].push_back(x-y-z);
    V[3].push_back(x+y-z);
    V[4].push_back(-x+y-z);
    V[5].push_back(-x-y+z);
    V[6].push_back(-x+y+z);
    V[7].push_back(-x-y-z);
  }
 
  ll ans = 0;
  REP(i,8){
    sort(ALL(V[i]));
    reverse(ALL(V[i]));
    ll sum = 0;
    REP(j,m){
      sum += V[i][j];
    }
    ans = max(ans,sum);
  }
  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
int main(void){
    char a[105]={0},b[105]={0};
    int i,k,c=0,ans=0;
    while(scanf(" %s",a)!=EOF){
        for(i=104;i>=0;i--){
            if(a[i]!=0)break;
        }
        for(k=0;k<=i;k++){
            if(a[i-k]!=a[k])c++;
        }
        if(c==0)ans++;
        for(i=0;i<105;i++){
            a[i]=0;
        }
        c=0;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 540
#include<iostream>
#include<algorithm>
using namespace std;
//動的計画法で検索するとナップザック問題ばっかりでてくる…
int main() {
	int N, W, v[110], w[110], dp[110][10010] = {};

	cin >> N >> W;
	
	for (int i = 0; i < N; i++) cin >> v[i] >> w[i];

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j >= w[i]) dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
			else dp[i + 1][j] = dp[i][j];
		}
	}

	cout << dp[N][W] << endl;
	cin >> N;

	return 0;
}


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

int main() {
  int n;
  std::cin >> n;
  int max = 0;
  int maxnum = 1;
  for (int i = 1; i < n+1; i++) {
    int x = i;
    int c = 0;
    while (x % 2 == 0) {
      x /= 2;
      c++;
    }
    if (c > max) {
      max = c;
      maxnum = i;
    }
  }
  std::cout << maxnum << "\n";
}

Measured memory_bytes: 256
import math as m

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

z = a * b
s = x / a

if z / 2 >= s:
  ap = 2 * s / b
  at = m.degrees(m.atan(b/ap))
  print(at)
else:
  bp = 2 * (a * b - s) / a
  bt = m.degrees(m.atan(bp/a))
  print(bt)


Measured memory_bytes: 3060
import itertools
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
p_count = 0
q_count = 0
count = 0
k = []
for i in range(N):
    k.append(i+1)
for i in itertools.permutations(k,N):
    count += 1
    if i == P:
        p_count = count
    if i == Q:
        q_count = count

sum = abs(p_count-q_count)
print(sum)

Measured memory_bytes: 39280
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
ll x;

cin>>x;

x=1-x;

cout<<x<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3636
import java.io.PrintWriter

fun main() {
    val pw = PrintWriter(System.out)

    val mod = 1000000007L

    val (n, k) = readInputLine().split(" ").map { it.toLong() }

    var ans = 0L

    val cnt = LongArray(k.toInt() + 1)

    for (i in LongRange(1L, k).reversed()) {
        var arrCnt = pow(k / i, n, mod)

        for (j in LongRange(i * 2L, k) step i) {
            arrCnt = (arrCnt - cnt[j.toInt()] + mod) % mod
        }

        cnt[i.toInt()] = arrCnt

        // pw.println("$i $ans")

        ans = (ans + arrCnt * i % mod) % mod
    }

    pw.println(ans)

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}

fun pow(x: Long, n: Long, mod: Long): Long {
    var ret = 1L
    var base = x
    var nTmp = n

    while (nTmp != 0L) {
        if (nTmp % 2L != 0L) {
            ret = ret * base % mod
        }
        base = base * base % mod
        nTmp /= 2L
    }

    return ret
}


Measured memory_bytes: 46788
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int fora=(a/d)+((a%d)>0);
  int fort=(c/b)+((c%b)>0);
  if(fort<=fora)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 3632
#B問題
s = list(str(input()))
slen = len(s)
Anum = 0
cflag = 0
ans = 0
for i in range(slen):
    if s[i] == "A":
        if cflag == 0:
            Anum+=1
        else:
            Anum = 1
            cflag = 0
    elif s[i] == "B":
        if i > 0:
            if s[i-1] == "A":
                cflag = 1
            else:
                Anum = 0
                cflag = 0
        else:
            pass
    elif s[i] == "C":
        if cflag == 1:
            ans+=Anum
            s[i] = "A"
            cflag = 0
        else:
            Anum = 0
            
print(ans)

Measured memory_bytes: 4840
#include<stdio.h>
int main()
{
int n,i,t,min,max;
long long int sum;
scanf("%d",&n);
min=1000000; max=-1000000;
sum=0;
 
for(i=0;i<n;i++){
scanf("%d",&t);
if(min>t) min=t;
if(max<t) max=t;
sum+=t;
}
printf("%d %d %lld\n",min,max,sum);
return 0;
}
 
 
  

Measured memory_bytes: 600
from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]

move = ((1, 0), (-1, 0), (0, 1), (0, -1))
visited = [[False] * W for _ in range(H)]


def bfs(i, j):
    b, w = 0, 0
    visited[i][j] = True
    que = deque([(i, j)])

    while que:
        ci, cj = que.popleft()
        if S[ci][cj] == '#':
            b += 1
        else:
            w += 1

        for di, dj in move:
            ni, nj = ci + di, cj + dj
            if not (0 <= ni < H and 0 <= nj < W) or visited[ni][nj]:
                continue
            if S[ci][cj] != S[ni][nj]:
                visited[ni][nj] = True
                que.append((ni, nj))

    return b * w


result = 0
for i in range(H):
    for j in range(W):
        if visited[i][j]:
            continue
        result += bfs(i, j)
print(result)


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second


int main() {
	int t=1;
	//cin>>t;
	while(t--){
		float n;
		cin>>n;
		float val = 2*3.141592*n;
		printf("%.6f", val);
	}
	
}

Measured memory_bytes: 3812
while True:
    a,op,b =input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)

    elif op == "?":
        break


Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>
#include <math.h>
#include <sstream> 
 
using namespace std;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(n*a<=b){
        cout<<n*a<<endl;
    }else{
        cout<<b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    double R;
    cin >> R;
    cout << setprecision(12) << 2 * R * M_PI;

    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define double long double
#define int long long 
#define f(z) for(int i=1;i<=z;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
int cl(int n ,int m) { if(n%m)return n/m + 1 ;else return n/m ;}
int pw(int a,int b,int M){a%=M;int r=1;while(b>0){if(b&1)r=r*a%M;a=a*a%M;b>>=1;}return r;}
#define mod  1000000007
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pr(r) cout <<"Case #"<<r <<": " ;
 
const int N = 1e5 + 9 ;

signed main(){
	int n;
	cin >> n ;
	int t = (pw(10,n,mod) -pw(9,n,mod)*2 + pw(8,n,mod) ) %mod ;
	cout << (t+mod)%mod << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
    int k,j,flag,n,i,m[200][3]={{0}},p[200]={0};

    scanf("%d",&n);
    for(i=0;i<n;i++)for(j=0;j<3;j++)scanf("%d",&m[i][j]);

    for(j=0;j<3;j++){
        for(i=0;i<n;i++){
            if(m[i][j]==0)continue;
            for(k=i+1,flag=0;k<n;k++){
                if(m[i][j]==m[k][j]){
                    flag=1;
                    m[k][j]=0;
                }
            }
            if(flag)m[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            p[i]+=m[i][j];
        }
    }
    for(i=0;i<n;i++)printf("%d\n",p[i]);
    return 0;
}

Measured memory_bytes: 600
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;
	// check
	int n = s.size();
	if(s.back()=='1' || s.front()=='0') {
		print(-1);
		return 0;
	}
	for(int i=0;i<n/2;i++) {
		if(s[i]!=s[n-2-i]) {
			print(-1);
			return 0;
		}
	}

	std::vector<std::pair<int,int> > g;
	int current = 0;
	rep(i,n-1) {
		if(s[i]=='1') {
			g.emplace_back(i+1,current);
			current = i+1;
		} else {
			g.emplace_back(i+1,current);
		}
	}
	for(auto i:g) {
		std::cout << i.first+1 << ' ' << i.second+1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

const int N = 100005;
int cnt[N];
int main(){
    int n;
    LL sum = 0;
    scanf("%d",&n);
    FOR(i, 1, n){
        int a;
        scanf("%d",&a);
        cnt[a]++; sum+=a;
    }
    int q;
    scanf("%d",&q);
    while(q--){
        int a, b;
        scanf("%d %d",&a,&b);
        sum -= a * 1ll * cnt[a];
        sum += b * 1ll * cnt[a];
        cnt[b] += cnt[a];
        cnt[a] = 0;
        printf("%lld\n",sum);
    }
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int A, B, X;
    cin >> A >> B >> X;
    if(A + B >= X && A <= X) { printf("YES\n"); }
    else { printf("NO\n"); }
    return 0;
}


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

const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};
string g[102][100];

void init() {
  g[1][0] = "#";
  g[2][0] = "##";
  g[2][1] = "# ";
  for(int k = 3; k <= 100; ++k) {
    for(int i = 0; i < k-2; ++i) {
      g[k][i] = g[k-2][i];
    }
    for(int i = 0; i < k-2; ++i) {
      g[k][i] += " #";
    }
    g[k][k-2] = string(k, ' ');
    g[k][k-2][0] = g[k][k-2][k-1] = '#';
    g[k][k-1] = string(k, '#');
    for(int i = 0; i < k; ++i) {
      for(int j = 0; j < k; ++j) {
        if(make_pair(i,j) < make_pair(k-i-1,k-j-1)) {
          swap(g[k][i][j], g[k][k-i-1][k-j-1]);
        }
      }
    }
  }
}

int main() {
  init();
  int d;
  cin >> d;
  for(int tc = 0; tc < d; ++tc) {
    int n;
    cin >> n;
    if(tc) cout << endl;
    for(int i = 0; i < n; ++i) {
      cout << g[n][i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>> n;
  vector<pair<char,int> > a(n);
  vector<pair<char,int> > b(n);
  for(int i=0;i<n;i++){
    cin >> a[i].first>>a[i].second;
    b[i]=a[i];
  }
  bool x=true;
  while(x){
    x=false;
    for(int i=n-1;i>0;i--){
      if(a[i].second<a[i-1].second){
        swap(a[i],a[i-1]);
        x=true;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout <<a[i].first<<a[i].second;
    if(i!=n-1)cout<<' ';
  }
  cout<<endl<<"Stable"<<endl;
  
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(b[minj].second>b[j].second)minj=j;
    }
    swap(b[i],b[minj]);
  }
  for(int i=0;i<n;i++){
    cout <<b[i].first<<b[i].second;
    if(i!=n-1)cout<<' ';
  }
  cout<<endl;
  for(int i=0;i<n;i++){
    if(a[i].first!=b[i].first){
      cout<<"Not stable"<<endl;
      return 0;
    }
  }
  cout<<"Stable"<<endl;
  return 0;
}
      


Measured memory_bytes: 3096
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

void debug_out(){cerr<<endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr<<(H)<<" ";debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr<<"#"<<#__VA_ARGS__<<":\n",debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,i,sm=0;
	cin>>n;
	vector<int> a(n),b(n);
	for(i=0;i<n;i++){
		cin>>a[i];
		sm^=a[i];
	}
	for(i=0;i<n;i++){
		b[i]=sm^a[i];
		cout<<b[i]<<" ";
	}
	cout<<"\n";
	return 0;
}


Measured memory_bytes: 4820
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int mxn = 1e5;
int cnt1[mxn+2],cnt2[mxn+2];

void solve(){
	string s;
	cin >> s;
	int n = s.length();
	if(s[n-1]=='1'){
		cout << -1 << endl;return;
	}
	if(n==2){
		if(s[0]=='1')
			cout << "1 2" << endl;
		else
			cout << -1 << endl;return;
	}
	for(int i =0;i<n/2;i++){
		if(s[i] != s[n-2-i]){
			cout << -1 << endl;return;
		}
	}
	if(s[0]=='0'){
		cout << -1 << endl;return;
	}
	int cur = 1;
	int nxt = 2;
	for(int i =0;i<n-1;i++){
		cout << cur << " " << nxt << endl;
		if(s[i]=='1'){
			cur = nxt;nxt++;
		}
		else{
			nxt++;
		}
	}


}

int main(){
	fast;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif

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


Measured memory_bytes: 1616
N = int(input())
H = list(map(int, input().split()))

ans = []
count = 0
for j in range(N):
    if (j == N - 1):
        ans.append(count)
        count = 0
        break
    if (H[j] < H[j + 1]):
        ans.append(count)
        count = 0
        continue
    elif (H[j] >= H[j + 1]):
        count += 1

print(max(ans))


Measured memory_bytes: 14224
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){

  int A, N, B;
  int P[100];
  int ans;
  int sma=0, mid=0, lar=0;
  string S;

  cin >> N;
  cin >> A >> B;
  for(int i=0; i<N; i++){
    cin >> P[i];
  }

  for(int j=0; j<N; j++){
    P[j] > B ? lar++ :
    P[j] > A ? mid++ : sma++;
  }

  ans = min(lar, mid);
  ans = min(ans, sma);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import math
S = input()

Slen = len(S)

ans = [0] * Slen

last = 0
r = 0
l = 0

for i in range(Slen-1):
    if S[i] == "R" and S[i+1] == "L":
        last = i
        r += 1
        tmp = math.ceil(r*0.5)
        ans[i] += tmp
        ans[i+1] += r - tmp
        r = 0
        if i+1 == Slen - 1:
            ans[i+1] += 1
    elif S[i] == "R" and S[i+1] == "R":
        r += 1
    elif S[i] == "L" and S[i+1] == "L":
        l += 1
        if i+1 == Slen - 1:
            l += 1
            tmp = math.ceil(l*0.5)
            ans[last+1] += tmp
            ans[last] += l - tmp
    elif (S[i] == "L" and S[i+1] == "R"):
        l += 1
        tmp = math.ceil(l*0.5)
        ans[last+1] += tmp
        ans[last] += l - tmp
        l = 0

print(*ans)


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
 
int dp[8001][16001];
int a[8001];
 
int main(){
	ios::sync_with_stdio(false);
	string s;
	int x,y;
	cin>>s>>x>>y;
	int k=0,w=0;
	for(int i=0;i<s.size();++i){
		if(s[i]=='T'){
			++k;
			a[k]=w;
			w=0;
		}else
			++w;
	}++k;
	a[k]=w;
	dp[1][a[1]+8000]=1;
	for(int i=3;i<=k;i+=2){
		for(int j=0;j<=16000;++j){
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	dp[0][8000]=1;
	for(int i=2;i<=k;i+=2){
		for(int j=0;j<=16000;++j){
			if(j+a[i]<=16000)
			dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
			dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	int ans;
	if(k%2==0){ 
		ans=dp[k][y+8000]&&dp[k-1][x+8000];
	}
	else{
		ans=dp[k][x+8000]&&dp[k-1][y+8000];
	}
	cout<<(ans==0?"No\n":"Yes\n");
	return 0;
}

Measured memory_bytes: 497792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111



	void solve(){


		ini(n);
		vi morty;
		morty.push_back(1);
		int tmp = 6;
		while(1){
			morty.push_back(tmp);
			tmp*=6;
			if(tmp>1e5)break;
		}
		tmp = 9;
		while(1){
			morty.push_back(tmp);
			tmp*=9;
			if(tmp>1e5)break;
		}
		vi dp(100007,inf);
		dp[0] = 0;
		FOR(i,0,100000){
			FORR(x,morty){
				if(i+x<=100000)dp[i+x] = min(dp[i+x],dp[i]+1); 
			}
		}
		out(dp[n]);










	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main() {
	string word;
	int n;

	cin >> word >> n;

	string order;
	int a, b;
	string str, sub1, sub2;
	for (int i = 0; i < n; i++) {
		cin >> order;
		cin >> a >> b;
		if (order == "print") {
			cout << word.substr(a, b -a + 1) << endl;
		}
		else if (order == "reverse") {
			sub1 = word.substr(a, b - a + 1);
			int c = sub1.size();
			for (int i = 0; i < c; i++) {
				word[i+a] = sub1[c-i-1];
			}
		}
		else if (order == "replace") {
			cin >> str;
			word = word.replace(a, b - a + 1, str);
		}
	}
	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

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

    int p[n];
    for(int i = 0; i < n; i++) cin >> p[i];
    sort(p, p + n);

    int ans = 0;
    for(int i = 0; i < k; i++) {
        ans += p[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
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;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;
vi X(N);
rep(i,N) cin >> X[i];

int m = INF;

for(int p = -100; p <= 100 ; ++p) {
    int now = 0;
    rep(i,N) {
        now += pow(X[i]-p, 2);
    }
    m = min(m, now);
}

cout << m << endl;


return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,ans = 0,a;
    cin >> n;
    vector<ll> b;
    rep(i,n){
        cin >> a;
        ll cnt = 0;
        while(a%2 == 0){
            cnt++;
            a /= 2;
        }
        b.push_back(cnt);
    }
    PRINT(*min_element(all(b)));
}


Measured memory_bytes: 256
order = [int(input()) for i in range(4)]
A = order[0]
B = order[1]
C = order[2]
X = order[3]
count = 0

for l in range(A+1):
  for m in range(B+1):
    for n in range(C+1):
      if X == l * 500 + m * 100 + n * 50:
        count += 1
print(count)     


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n;
char s[105];
main()
{
    int i,a,b,now;
    scanf("%d %s",&n,s);
    a = b = 0;
    now = 0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='(') now--;
        else now++;
        a = max(a,now);
    }
    now = 0;
    for(i=n-1;i>=0;i--)
    {
        if(s[i]==')') now--;
        else now++;
        b = max(b,now);
    }
    for(i=0;i<a;i++) printf("(");
    printf("%s",s);
    for(i=0;i<b;i++) printf(")");
}


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

int H, W;

void print(int i, int j) {
  if (i == H - 1) {
    cout << i + 1 << ' ' << j + 1 << ' ';
    cout << i + 1 << ' ' << j + 2 << endl;
  } else {
    cout << i + 1 << ' ' << j + 1 << ' ';
    cout << i + 2 << ' ' << j + 1 << endl;
  }
}

int main() {
  cin >> H >> W;
  vector<vector<int>> a(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }

  int ans = 0;
  queue<pair<int, int>> que;
  for (int i = 0; i < H - 1; i++) {
    for (int j = 0; j < W; j++) {
      if (a[i][j] % 2 == 1) {
        a[i + 1][j]++;
        ans++;
        que.push(make_pair(i, j));
      }
    }
  }

  for (int j = 0; j < W - 1; j++) {
    if (a[H - 1][j] % 2 == 1) {
      a[H - 1][j + 1]++;
      que.push(make_pair(H - 1, j));
      ans++;
    }
  }

  cout << ans << endl;
  for (int i = 0; i < ans; i++) {
    pair<int, int> p;
    p = que.front();
    que.pop();
    print(p.first, p.second);
  }

  return 0;
}

Measured memory_bytes: 4096
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s1 = readLine()!!.toMutableList()
    repeat(n - 1) {
        val sx = readLine()!!.toMutableList()
        s1.removeAll { c -> !sx.remove(c) }
    }
    println(s1.sorted().joinToString(""))
}


Measured memory_bytes: 37920
#include<stdio.h>


int main(){

  int n, i, j, k, l, cnt, x;

  for(x=0;x<50;x++){

    scanf("%d", &n);
    cnt=0;
    for(i=9;i>=0;i--){
      for(j=9;j>=0;j--){
	for(k=9;k>=0;k--){
	  for(l=9;l>=0;l--){
	    if(i+j+k+l==n){
	      cnt++;
	    }
	  }
	}
      }
    }

  printf("%d\n", cnt);
  }
  return 0;
  
}

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

const int MAX_N = 300000;
bool Prime[MAX_N + 10];

int main()
{
    // 初期化
    for (int i = 0; 7 * i <= MAX_N; ++i)
    {
        int p = 7 * i + 1;
        if (p <= MAX_N)
            Prime[p] = true;
        p = 7 * i + 6;
        if (p <= MAX_N)
            Prime[p] = true;
    }
    Prime[1] = false;
    for (int i = 0; i <= MAX_N; ++i)
    {
        if (Prime[i])
        {
            for (int j = 2 * i; j <= MAX_N; j += i)
            {
                Prime[j] = false;
            }
        }
    }

    set<int> Prime_factor;
    for (int i = 0; i <= MAX_N; ++i)
    {
        if (Prime[i])
            Prime_factor.insert(i);
    }

    /*
    for (auto p : Prime_factor)
    {
        cout << p << endl;
    }
    */

    // 開始
    int X;
    while (cin >> X, X != 1)
    {
        cout << X << ":";
        for (auto p : Prime_factor)
        {
            // if (!(p * p <= X))
            //     break;
            if (X % p == 0)
            {
                // 割った商が月曜土曜数
                cout << " " << p;
                // while (X % p == 0)
                //     X /= p;
            }
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;

int n;
typedef long long ll;
ll a[1000010];
int main() {

  cin >> n;

  for(int i = 0; i < n; i++) cin >> a[i];

  sort(a,a+n);
  reverse(a,a+n);

  set<ll> s;
  ll ans = 1;
  int count = 0;
  for(int i = 0; i < n+5; i++) {

    if(count == 2) break;
    if(s.empty()) {
      s.insert(a[i]);
    } 
    if(s.find(a[i+1]) != s.end()) {
      count++;
      ans = ans * (*s.begin());
      s.erase(s.begin());
      i++;
    }
    else {
    
      s.erase(s.begin());
    }
  }

 
  cout << ans << endl;

}
      
      
  


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

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

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	unsigned long long		a,c,h,i,j,k,l,m,n,x,y;
	unsigned long long		ans = 0;
	double	b;
	string	s;
	cin >> a >> b;
	ans = a * (ll)(b*1000.0);
	ans = ans / 1000;
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));
	if (a==0 || b==0.0) ans = 0;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3752
N = int(input())

S = input()

if len(S)%2 == 1:
    print("No")
    exit()

T1 = S[0:len(S)//2:1]
T2 = S[len(S)//2:len(S):1]

#print(T1)
#print(T2)

print("Yes" if T1 == T2 else "No")



Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int p[1<<15];
void dfs(int d,int j,int s){
  if(d==4){p[s]++;return;}
  for(int i=j;i*i+s<=(1<<15);i++)dfs(d+1,i,s+i*i);
}

int main(){
  dfs(0,0,0);
  int n;
  while(cin>>n&&n)cout<<p[n]<<endl;
  return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;
using int64 = long long;


int main() {
    int n;
    cin >> n;
    vector<int64> cnt(6, 0);
    set<string> names;
    map<char, int> to;
    to['M'] = 1;
    to['A'] = 2;
    to['R'] = 3;
    to['C'] = 4;
    to['H'] = 5;


    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        if (names.find(s) != names.end()) continue;
        names.insert(s);
        cnt[to[s[0]]]++;
    }

    for (int i=1; i<6; i++) cerr<<cnt[i]<<" ";cerr<<endl;
    int64 ans = 0;
    for (int i=1; i<6; i++) {
        for (int j=i+1; j<6; j++) {
            for (int k=j+1; k<6; k++) {
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << endl;

}

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

int main() {
    int c[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            std::cin >> c[i][j];
        }
    }
   
    // a0, b0 を決める 
    for (int i = 0; i <= 100; ++i) {
        for (int j = 0; j <= 100 - i; ++j) {
            const int a0 = i;
            const int b0 = j;
            if ((a0 + b0) != c[0][0]) {
                continue;
            }

            const int a1 = c[1][0] - b0;
            const int a2 = c[2][0] - b0;

            const int b1 = c[0][1] - a0;
            const int b2 = c[0][2] - a0;

            if ((a1 + b1) == c[1][1] && 
                (a1 + b2) == c[1][2] &&
                (a2 + b1) == c[2][1] && 
                (a2 + b2) == c[2][2]
            ) {
                std::cout << "Yes\n";
                return 0;
            }
        }
    }

    std::cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigDecimal;

public class Main{

    public static void main(String argv[])
    {
	Scanner scan = new Scanner(System.in);
	double r = scan.nextDouble();
	double S,L;

	S = Math.pow(r,2) * Math.PI;
	L = 2 * r * Math.PI;
	BigDecimal x = new BigDecimal(S);
x = x.setScale(6,BigDecimal.ROUND_HALF_UP);
	BigDecimal y = new BigDecimal(L);
y = y.setScale(6,BigDecimal.ROUND_HALF_UP);
	System.out.println(x+" "+y);
    }
}

Measured memory_bytes: 28476
#include <bits/stdc++.h>
#define int long long int
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL);
#define fr(i,a,b)  for(int i=a;i<=b;i++)
#define rf(j,b,a)  for(int j=b;j>=a;j--)
#define frr(k,a,b) for(int k=a;k<=b;k++)
#define mp make_pair
#define pb push_back
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
signed main()
{   
	IOS
  /*  #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/
int n,k;
cin>>n;
cin>>k;
int h[n+1];
for(int i=1;i<=n;i++)
{
	cin>>h[i];
}
int dp[n+1]={0};
dp[1]=dp[0]=0;
dp[2]= abs(h[2]-h[1]);
for(int i =3;i<=n;i++)
{
	int c = min(i-1,k);
	int ans = INT_MAX;
	for(int j = 1;j<=c;j++)
	{
		ans = min(ans,abs(h[i]-h[i-j])+dp[i-j]);
	}
    dp[i]=ans;

}
cout<<dp[n]<<endl;
}






Measured memory_bytes: 1792