akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	D := make([]int, N)
	for i := range D {
		D[i] = readInt()
	}

	if D[0] != 0 {
		println(0)
		return
	}

	// 7
	// 0 3 2 1 2 2 1
	// 1 2 3 4 5 6 7
	//
	// 1
	// 4 7        // => 1^2 = 1
	// 3 5 6      // => 2^3 = 8
	// 2          // => 3^1 = 3

	var maxd int
	for _, v := range D {
		maxd = max(maxd, v)
	}
	a := make([]int64, maxd+1)
	for _, v := range D {
		a[int(v)]++
	}

	if 1 < a[0] {
		println(0)
		return
	}

	ans := int64(1)
	INF := int64(998244353)
	for i := 1; i < len(a); i++ {
		for j := int64(0); j < a[i]; j++ {
			ans = (ans * a[i-1]) % INF
		}
	}
	println(ans)

}

// -----------------------------------------------------------------------------


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];

    int ans=1;
    int hmax=h[0];
    for(int i=1;i<n;i++){
        if(hmax<=h[i]){
            ans++;
            hmax=h[i];
        }
    }
    cout << ans << endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),Q=in();
	vector<vector<int>> V(N);
	REP(i,Q){
		int q=in();
		int t=in();
		if(!q){
			V[t].push_back(in());
		}
		else if(q==1){
			for(int j=0,ej=V[t].size()-1;j<ej;j++){
				cout << V[t][j] << ' ';
			}
			if(!V[t].empty()) out(V[t].back());
			else out();
		}
		else{
			V[t].clear();
		}
	}

	return 0;
}


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

int main() {
  int N,K,ans=0;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (vec.at(i) >= K) {
      ans++;
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 640
def main():
    All = [i*(i+1)*(i+2)//6 for i in range(1, 182)]
    inf = 10**18
    n = 10**6
    dp = [inf]*(n+1)
    dpo = [inf]*(n+1)
    dp[0] = 0
    dpo[0] = 0
    for j in All:
        lim = min(j*5, n)
        for i in range(j, lim+1):
            dp[i] = min(dp[i-j]+1, dp[i])
        for i in range(j, n):
            if j%2==1:
                dpo[i] = min(dpo[i-j]+1, dpo[i])
    
    while 1:
        q = int(input())
        if q==0:
            break
        print(dp[q], dpo[q])

main()


Measured memory_bytes: 52828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define all(v) v.begin(), v.end()
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; }
typedef int64_t lint;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;

struct edge {
	int from; //出発点
	int to;   //到達点
	lint cost; //移動コスト
};

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

	vector<edge> v(M);
	rep(i, M) {
		cin >> v.at(i).from >> v.at(i).to >> v.at(i).cost;
		v.at(i).from--, v.at(i).to--;
	}

	vector<lint> d(N);
	fill(all(d), -LINF);
	d.at(0) = 0;

	int x, y, z;
	bool f;
	rep(i, N) {
		rep(j, M) {
			x = v.at(j).from;
			y = v.at(j).to;
			z = v.at(j).cost;
			f = chmax(d.at(y), d.at(x) + z);
			if (f && i == N-1 && y == N-1) {
				cout << "inf" << '\n';
				return 0;
			}
		}
	}
	cout << d.at(N-1) << '\n';
}


Measured memory_bytes: 3624
from collections import defaultdict
import bisect
N,M = map(int, input().split())
dic = defaultdict(list)
cities = []
for _ in range(M):
  p,y = map(int,input().split())
  cities.append([p,y])
for item in sorted(cities):
  dic[item[0]].append(item[1])
for item in cities:
  print("%06d%06d"%(item[0],bisect.bisect(dic[item[0]],item[1])))

Measured memory_bytes: 41712
using System;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
          int s, h, m;
          s = int.Parse(Console.ReadLine());
          h = s/ 3600;
          s = s% 3600;
          m = s /60;
          s = s% 60;
          Console.WriteLine(h + ":" + m + ":" +s);
        }
    }
}
                                         


Measured memory_bytes: 15964
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
using namespace std;
int main(){
	int h, w, n;
	cin >> h >> w >> n;
	if (h >= w) {
		if (n % h == 0) {
			cout << n / h << endl;
		}
		else {
			cout << n / h + 1 << endl;
		}
	}
	else {
		if (n % w == 0) {
			cout << n / w << endl;
		}
		else {
			cout << n / w + 1 << endl;
		}
	}
	return 0;
}



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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<": ";REP(i,v.size())cout<<" "<<v[i];cout<<endl

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))


//===


int gcd(int x, int y)
{
	if (x < y) swap(x, y);
	if (y == 0) return x;
	int r = x % y;
	while (r) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}


int main()
{
	int N;
	cin >> N;
	Vi A(N);
	REP(i, N) cin >> A[i];
	Vi L(N+1), R(N+1);
	REP(i, N) {
		L[i + 1] = gcd(L[i], A[i]);
		R[N - i - 1] = gcd(R[N - i], A[N - i - 1]);
	}
	int ans = 0;
	REP(i, N) {
		int g = gcd(L[i], R[i + 1]);
		CHMAX(ans, g);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
K,S = map(int,input().split(" "))
ans = 0
if S == 3*K:
  print(1)
  exit()
for z in range(K+1):
  tmp = S-z
  if tmp <= 2*K:
    for y in range(K+1):
      ttmp = tmp-y
      if 0 <= ttmp <= K:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,m; cin >> n >> m;
    using ps = pair<ll, string>;
    vector<ps> vec(m);
    rep(i,m){
        ll p; cin >> p;
        p--;
        string s;cin >> s;
        vec[i] = {p,s};
    }
    vector<ll> count(n,0);
    bitset<n_max> bs(0);
    rep(i,m){
        ll p = vec[i].first;
        string s = vec[i].second;
        if(s == "WA"){
            if(bs[p] == 0)count[p]++;
        }
        else{
            bs[p] = 1;
        }
    }
    ll wa = 0;
    rep(i,n)if(bs[i] == 1)wa += count[i];

    cout << bs.count() << " " << wa << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

int n, A[50];

int saiki(int i, int m){
    // ちょうどmが0になるとき1を返す
    if(m == 0) return 1;
    // iがnに達したら0を返す
    if(i >= n) return 0;
    // i番目を使わない　or　i番目を使う(i番目の要素をmから引く)
    int res = saiki(i+1, m) || saiki(i+1, m - A[i]);
    return res;
}

void solve(){
    int q, M;
    cin >> n;
    rep(i, 0, n) cin >> A[i];
    cin >> q;
    rep(i, 0, q){
        cin >> M;
        if(saiki(0, M)) cout << "yes" << "\n";
        else cout << "no" << "\n";
    }
    return;
}


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

    solve();
    return 0;
}



Measured memory_bytes: 3232
N,M=map(int,input().split())
ans1=[]
ans2=[]
ans3=[]
ans4=[]
ans5=[]
ans6=[]
ans7=[]
ans8=[]

ANS1=0
ANS2=0
ANS3=0
ANS4=0
ANS5=0
ANS6=0
ANS7=0
ANS8=0


for i in range(N):
    A,B,C=map(int,input().split())
    
    ans1.append(A+B+C)
    ans2.append(-A+B+C)
    ans3.append(A-B+C)
    ans4.append(A+B-C)
    ans5.append(-A-B+C)
    ans6.append(A-B-C)
    ans7.append(-A+B-C)
    ans8.append(-A-B-C)
    
re_ans1=sorted(ans1)
re_ans2=sorted(ans2)
re_ans3=sorted(ans3)
re_ans4=sorted(ans4)
re_ans5=sorted(ans5)
re_ans6=sorted(ans6)
re_ans7=sorted(ans7)
re_ans8=sorted(ans8)
for j in range(1,M+1):
    ANS1+=re_ans1[(-1)*j]
    ANS2+=re_ans2[(-1)*j]
    ANS3+=re_ans3[(-1)*j]
    ANS4+=re_ans4[(-1)*j]   
    ANS5+=re_ans5[(-1)*j]
    ANS6+=re_ans6[(-1)*j]
    ANS7+=re_ans7[(-1)*j]
    ANS8+=re_ans8[(-1)*j]
print(max(ANS1,ANS2,ANS3,ANS4,ANS5,ANS6,ANS7,ANS8))

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// 参考: https://drken1215.hatenablog.com/entry/2019/06/29/182300

class UnionFind{
private:
  vector<int> Parent; 
public:  
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    
    if(size(A) < size(B)) swap(A, B);
    
    Parent[A] += Parent[B];
    Parent[B] = A;
    
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,k,l; cin>>n>>k>>l;
  UnionFind uf1(n), uf2(n);
  rep(i,k){
    int a,b; cin>>a>>b; a--,b--;
    uf1.connect(a,b);
  }
  rep(i,l){
    int a,b; cin>>a>>b; a--,b--;
    uf2.connect(a,b);
  }
  
  map<pii,int> m;
  rep(i,n){
    pii p={uf1.root(i),uf2.root(i)};
    m[p]++;
  }
  rep(i,n){
    pii p={uf1.root(i),uf2.root(i)};
    cout<<m[p];
    if(i==n-1)cout<<endl;
    else cout<<" ";
  }
}


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

int main(){
    int a, b, c;
cin >> a >> b >> c;
    if (a==b && a!=c) {
        cout << "Yes" << endl;
    } else if( b==c && b!=a) {
        cout << "Yes" << endl;
    } else if (c==a && c!=b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define minimum(a,b) if(a>b) a=b;
typedef vector<vector<ll>> matrix;
const ll INF = 1e9+5;
const int MAX = 2e5+4;
const int MOD = 1e9+7;
//vector<vector<ll>> dp(MAX,vector<ll>(3));
//vector<ll> dp(MAX,INF);
template <typename T> void max_self(T& a,T b)
{
	a=max(a,b);
}
bool first_row_or_column(pair<int,int> p)
{
	return p.first==0 || p.second==0;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string a,b;
	cin >> a >> b;
	vector<vector<pair<int,pair<int,int>>>> dp(a.size()+1,vector<pair<int,pair<int,int>>>(b.size()+1,{-INF,{0,0}}));
	dp[0][0]={0,{0,0}};
	// dp[i][j] - max total length so far
	for(int i=0;i<a.size();i++)
	{
		for(int j=0;j<b.size();j++)
		{
			if(a[i]==b[j])
			{
				max_self(dp[i+1][j+1],mp(dp[i][j].first+1,mp(i,j)));
			}
			max_self(dp[i][j+1],mp(dp[i][j].first,mp(i,j)));
			max_self(dp[i+1][j],mp(dp[i][j].first,mp(i,j)));
		}
	}
	string s;
	pair<int,pair<int,int>> answer={0,{0,0}};
	for(int i=0;i<=a.size();i++)
	{
		for(int j=0;j<=b.size();j++)
		{
			max_self(answer,mp(dp[i][j].first,mp(i,j)));
		}
	}
	pair<int,int> cur=answer.second;
	while(!first_row_or_column(cur))
	{
		int i=cur.first;
		int j=cur.second;
		pair<int,int> previous=dp[i][j].second;
		if(previous==mp(i-1,j-1))
		{
			s+=a[i-1];
		}
		cur=previous;
	}
	reverse(s.begin(),s.end());
	cout << s;
	return 0;
}

Measured memory_bytes: 105984
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=1e5+11,INF=~0u>>2;
int n,l,q,dp[20][N],a[N];
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int bs(int x){
	int l=0,r=n-1,ret;
	while(l<=r){
		int mid=(l+r)>>1;
		if(a[mid]<=x) l=mid+1,ret=mid;
		else r=mid-1;
	}
	return ret;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();
	rep(i,n) a[i]=read();
	l=read();q=read();
	rep(i,n) dp[0][i]=bs(a[i]+l);
	rep(k,19) rep(i,n) dp[k+1][i]=dp[k][dp[k][i]];
	rep(i,q){
		int a=read(),b=read();a--;b--;
		if(a>b) swap(a,b);
		int ans=0;
		for(int j=19;j>=0;j--){
			if(dp[j][a]<b){
				a=dp[j][a];
				ans+=1<<j;
			}
		}
		printf("%d\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<algorithm>
#include<string>
#include<ctype.h>
using namespace std;

char chgcase(char c);

int main()
{
	int i=0;
	string str;

	getline(cin,str);

	for(i=0;i<str.size();i++)
	{
		str[i] = chgcase(str[i]);

		cout << str[i] ;
	} 

	cout << endl;

	return 0;
}

char chgcase(char c) {
  if ((c >= 'A') && (c <= 'Z')) {
    return (c + 0x20);
  }
  else if ((c >= 'a') && (c <= 'z')) {
    return (c - 0x20);
  }
  else {
    return (c);
  }
}

Measured memory_bytes: 1172
import java.util.Scanner;
class Main {
	int[][] s = new int [5][11];
	int[][] t = new int [5][11];
	int[][] c = new int [5][11];
	int[][] d = new int [5][11];
	int n = 0, b = 0, f = 0, r = 0, v = 0, i = 0, k = 0;
	public void of() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		for(i = 1; i <= n; i++) {
			b = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
			v = sc.nextInt();
			switch(b) {
				case 1:
					s[f][r] += v;
					break;
				case 2:
					t[f][r] += v;
					break;
				case 3:
					c[f][r] += v;
					break;
				case 4:
					d[f][r] += v;
					break;
				default:
					break;
			}
		}
		
		for(n = 1; n <= 4; n++) {
			for(i = 1; i < 4; i++) {
				for(k = 1; k < 11; k++) {
					switch(n) {
						case 1:
							System.out.printf(" %d",s[i][k]);
							break;
						case 2:
							System.out.printf(" %d",t[i][k]);
							break;
						case 3:
							System.out.printf(" %d",c[i][k]);
							break;
						case 4:
							System.out.printf(" %d",d[i][k]);
							break;
						default:
							break;
					}
				}
				System.out.println();
			}
			if(n < 4) {
			System.out.println("####################");
			}
		}
	}
	public static void main(String[] args) {
		new Main().of();
	}
}

Measured memory_bytes: 23212
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int dp[100005];
int h[100005];
int n, k;

int func(int i)
{
    if(i>=n-1) return 0;
    if(dp[i]!=-1) return dp[i];
    int a=1e18;
    for(int j=1; j<=k; j++) {
        if(i<n-j) a=min(a, abs(h[i+j]-h[i])+func(i+j));
    }
    dp[i]=a;
    return dp[i];
}

main()
{
    fastio;
    cin>>n>>k;
    for(int i=0; i<n; i++) cin>>h[i];
    memset(dp, -1, sizeof(dp));
    cout<<func(0);
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main()
{
  string s; cin >> s;
  
  reverse(ALL(s));
  REP(i,4) reverse(ALL(divide[i]));
  
  bool can = true;
  for(int i = 0;i < s.size();){
    bool can2 = false;
    REP(j,4){
      string d = divide[j];
      if(s.substr(i,d.size())==d){
        can2 = true;
        i += d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  
  int s;
  cin >> s;
  
  vector<int> a;
  a.push_back(s);
  
  bool bul = true;
  int cnt = 1;
  while(bul){
    
    int now;
    if (a.at(cnt - 1) % 2== 0)
      now = a.at(cnt - 1) / 2;
    else
      now = 3 * a.at(cnt - 1) + 1;
      
    for (as : a){
      if (as == now){
        cout << cnt + 1 << endl;
        bul = false;
      }
    }
    
    a.push_back(now);
    cnt++;
    
  }
}

Measured memory_bytes: 256
N=int(input())
bou=list(map(int,input().split()))
count=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            max_bou=max(bou[i],bou[j],bou[k])
            if ((bou[i]!=bou[j]) and (bou[j]!=bou[k]) and (bou[k]!=bou[i])):
                if bou[i]+bou[j]+bou[k]-max_bou>max_bou:
                    count=count+1
print(count)


Measured memory_bytes: 9204
a = [int(_) for _ in input().split()]
if len(a) == 3 and 1 <= a[0] <= 100 and 1 <= a[1] <= 100 and 1 <= a[2] <= 200:
    if a[0] <= a[2] <= a[0] + a[1]:
        print('YES')
    else:
        print('NO')
else:
    print('hoge!')

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

const int INF = 1000000000;

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

    vector<vector<int>> dp(N + 1, vector<int>(H + 10000, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < H + 10000; j++) {
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
        }
    }

    int res = INF;
    for (int j = H; j < H + 10000; j++) {
        res = min(res, dp[N][j]);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, r;std::cin >> n >> r;
  if(n>=10){
    std::cout << r << '\n';
  }else{
    std::cout << r + 100*(10 - n) << '\n';
  }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

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

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

  int n, l;
  cin >> n >> l;

  int sum = n * l + n * (n + 1) / 2 - n;
  int ans = sum - (l + 1 - 1);
  for(int i = 1; i < n; i++){
    int tmp = sum - (l + (i + 1) - 1);
    if(abs(sum - tmp) < abs(sum - ans)) ans = tmp;
  }

  cout << ans << endl;

  return 0;
}


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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int n;
	cin >> n;
	ll a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int count = 0;
	int num = 0;
	while(true){
		if(!(a[num] % 2)){
			a[num] /= 2;
			count++;
		}
		else{
			num++;
		}

		if(num == n){
			break;
		}
	}
	cout << count << endl;
	return 0; 
}

Measured memory_bytes: 384
import java.util.*;
public class Main
{
	public static  void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=Integer.parseInt(sc.nextLine());
		HashSet<String>set=new HashSet<>();
		for(int i=0;i<n;i++){set.add(sc.nextLine());}
			System.out.println(set.size());
	}
}

Measured memory_bytes: 82988
#include<stdio.h>

int main()
{
  int n,i;
  int w,h;
  scanf("%d%d%d",&n,&w,&h);
  int s=0;
  for (i=0;i<n;i++) {
    int a,b;
    scanf("%d%d",&a,&b);
    if (a>=w&&b>=h) s++;
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 128
import sys
import math

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    mi = [A[-1]]
    ma = [A[-1]]
    for i in reversed(range(n)):
        mi.append(math.ceil(mi[-1] / 2) + A[i])
        ma.append(ma[-1] + A[i])

    mi = mi[::-1]
    ma = ma[::-1]

    res = []
    for i in range(n + 1):
        if i == 0:
            if mi[i] <= 1 <= ma[i]:
                res.append(1)
                continue
            else:
                break

        if mi[i] <= (res[-1] - A[i - 1]) * 2 <= ma[i]:
            res.append((res[-1] - A[i - 1]) * 2)
        else:
            res.append(ma[i])

    print(sum(res) if len(res) != 0 else -1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 26920
N,W = map(int,input().split())
w_v = [list(map(int,input().split())) for i in range(N)]
INF = float("inf")
dp = [[INF]*100001 for i in range(N+1)]
dp[0][0]=0

for i in range(N):
  for j in range(100001):
    if j >= w_v[i][1]:
      dp[i+1][j] = min(dp[i][j],dp[i][j-w_v[i][1]]+w_v[i][0])
    else:
      dp[i+1][j] = dp[i][j]
    
ans = 0
for j in range(100001):
  if dp[-1][j] <= W:
    ans = max(ans,j)
print(ans)

Measured memory_bytes: 310808
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

D = [(0,1),(0,-1),(1,0),(-1,0),(1,1),(1,-1),(-1,1),(-1,-1)]
def solve(w,h):
    def bfs(y,x):
        q = deque([(y,x)])
        while q:
            y,x = q.popleft()
            for dx,dy in D:
                ny,nx = y+dy,x+dx
                if 0 <= ny < h and 0 <= nx < w:
                    if c[ny][nx] and not d[ny][nx]:
                        d[ny][nx] = 1
                        q.append((ny,nx))
    c = LIR(h)
    d = [[0]*w for i in range(h)]
    ans = 0
    for y in range(h):
        for x in range(w):
            if c[y][x] and not d[y][x]:
                ans += 1
                d[y][x] = 1
                bfs(y,x)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    while 1:
        w,h = LI()
        if w == h == 0:
            break
        solve(w,h)



Measured memory_bytes: 6076
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a[3005];
int mod=998244353;
int dp[3004][3005];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

    int n,s;
    cin>>n>>s;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][a[i]]+=i;
        dp[i][a[i]]%=mod;
        for(int j=1;j<=s;j++)
        {
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=mod;
        }
        for(int j=1;j<=s-a[i];j++)
        {
            dp[i][j+a[i]]+=dp[i-1][j];
            dp[i][j+a[i]]%=mod;
        }
        ans=(ans+dp[i][s])%mod;
    }
    cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	cout << n * n* n << endl;
	return 0;
}


Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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 * b) / gcd(a,b); }
int solve(){ 
  ll n,k;
  cin >> n >> k;
  vector<int>v(n);
  ll ans = 0;
  rep(i,n)cin >> v[i];
  rep(i,n)REP(j,i+1,n){
    if(v[i] > v[j]){
      ans += k * (k + 1) / 2;
      ans %= INF;
    }
    else if(v[i] < v[j]){
      ans += (k) * (k - 1) / 2;
      ans %= INF;
    }
  }
  cout << ans << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, std::vector<long long> a, std::vector<long long> b){
  vector<int> ret(N-1, -1);
  vector<vector<pair<long long, long long>>> G(N);
  for (int i = 0; i < N-1; i++) {
    G[a[i]-1].emplace_back(b[i]-1, i);
    G[b[i]-1].emplace_back(a[i]-1, i);
  }
  queue<pair<long long, int>> q;
  q.push(make_pair(0, -1));
  pair<long long, int> t;
  pair<long long, long long> e;
  long long u, v;
  int c, cp;
  int cn = 0;
  while(!q.empty()) {
    c = 0;
    t = q.front();
    u = t.first;
    cp = t.second;
    q.pop();
    for (int i = 0; i < G[u].size(); i++) {
      e = G[u][i];
      v = e.first;
      if (ret[e.second] == -1) {
        if (c == cp) c++;
        ret[e.second] = c;
        q.push(make_pair(v, c));
        c++;
      }
    }
    cn = max(c, cn);
  }
  std::cout << cn << std::endl;
  for (int i = 0; i < N-1; i++) {
    std::cout << ret[i]+1 << std::endl;
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N-1);
  std::vector<long long> b(N-1);
  for(int i = 0 ; i < N-1 ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  solve(N, std::move(a), std::move(b));
  return 0;
}


Measured memory_bytes: 10112
#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;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    //cout<<w*h<<endl;
    printf("%.15lf\n",(w*h)*1.0/2);
    if(x*2==w && y*2==h) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

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

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a>b)
    {

        for(int i=0;i<a;i++)
            cout<<b;
        cout<<'\n';
    }
    else
    {

        for(int i=0;i<b;i++)
            cout<<a;
        cout<<'\n';
    }









}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int):
    N = str(N)
    if N[0] == N[1] == N[2] \
       or N[1] == N[2] == N[3]:
        yes()
        return
    no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    bool x = false;

    for (int i = 0; i < B; i++)
    {
        if ((A * i) % B == C)
        {
            x = true;
            break;
        }
    }

    if(x)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}

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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair

const int N = (int)3e2 + 7;
const int inf = (int)1e9 + 7;

int dp[N][N][N];

main() {
  string s;
  cin >> s;
  int n = s.size();
  int k;
  scanf("%d", &k);
  for (int l = n - 1; l >= 0; l--) {
    for (int r = l; r < n; r++) {
      for (int i = 0; i <= k; i++) {
        if (l == r) {
          dp[l][r][i] = 1;
          continue;
        }
        if (l + 1 == r) {
          dp[l][r][i] = (s[l] == s[r] || i > 0) ? 2 : 1;
          continue;
        }
        dp[l][r][i] = max(dp[l + 1][r][i], dp[l][r - 1][i]);
        if (s[l] == s[r]) {
          dp[l][r][i] = max(dp[l][r][i], dp[l + 1][r - 1][i] + 2);
        }
        if (i > 0) {
          dp[l][r][i] = max(dp[l][r][i], dp[l + 1][r - 1][i - 1] + 2);
        }
      }
    }
  }
  cout << dp[0][n - 1][k];
}


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

int main(){
	int n,a,b;
  	cin >> n>>a>>b;
  int sum = 0;
  for(int i=1;i<=n;i++){
    int x = i/10000 + (i%10000)/1000 + (i%1000)/100 + (i%100)/10 + (i%10);
    if(a <= x && x <= b){
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
 int A,B,C;
  
  scanf("%d %d %d",&A,&B,&C);
  
  if(A==B&&B==C){
    printf("No");
  }else if(A!=B&&B!=C&&A!=C){
    printf("No");
  }else printf("Yes");
  
  return 0;
}


Measured memory_bytes: 128
def Cramer(coef):
	deno = coef[0]*coef[4] - coef[1]*coef[3]
	return [(coef[2]*coef[4] - coef[1]*coef[5]) / deno, (coef[0]*coef[5] - coef[2]*coef[3]) / deno]

while True:
	try:
		coeflist = [float(item) for item in input().split()]
		ans1, ans2 = Cramer(coeflist)
		if abs(ans1) < 1e-4:
			ans1 = 0.0
		if abs(ans2) < 1e-4:
			ans2 = 0.0
		print('%.3f %.3f' %(ans1, ans2))
	except EOFError:
		break

Measured memory_bytes: 7544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define INF 1000000

int dp[100][1000][1000];

int main(void){
	int n, ma, mb;
	int ans = INF;
	cin >> n >> ma >> mb;
	vector<int> a, b, c;
	a.resize(n); b.resize(n); c.resize(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i] >> b[i] >> c[i];
	}
	
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j < 1000; ++j){
			for(int k = 0; k < 1000; ++k){
				if(i == 0 && j == 0 && k == 0){
					dp[i][j][k] = 0;
				}else{
					dp[i][j][k] = INF;
				}
			}
		}
	}
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j < 1000; ++j){
			for(int k = 0; k < 1000; ++k){
				if(dp[i][j][k] == INF) continue;
				dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
				dp[i+1][j+a[i]][k+b[i]] = min(dp[i][j][k] + c[i], dp[i+1][j+a[i]][k+b[i]]);
				
			}
		}
	}
	for(int j = 1; j < 1000; ++j){
		for(int k = 1; k < 1000; ++k){
			if((j * mb) == (k * ma)) ans = min(ans, dp[n][j][k]);
			//cout << dp[n][j][k] << " ";
		}
	}
	
	if(ans == INF){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 162048
import Data.List

main = do
  (n:z:w:ws) <- map (read :: String -> Int) . words <$> getLine
  a <- map (read :: String -> Int) . words <$> getLine
  if length a < 2 then print $ abs $ (head a) - w
                  else print $ maximum . map abs $ [(last a) - w, last a - (last . init $ a)]


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

namespace ABC_157b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] up = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] middle = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] down = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int kazu = int.Parse(Console.ReadLine());

            for (int i = 0; i < kazu; i++)
            {
                int number = int.Parse(Console.ReadLine());
                up = Bingoprocess(number, up);
                middle = Bingoprocess(number, middle);
                down = Bingoprocess(number, down);
            }

            if ((up.Count(n => n == 0) + middle.Count(n => n == 0) + down.Count(n => n == 0)) > 6)
            {
                Console.WriteLine("Yes");
                Console.Read();
                return;
            }

            bool judge = Bingoresult(up, middle, down);

            if (judge)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.Read();
        }
        public static int[] Bingoprocess(int number, int[] bingo)
        {
            for (int i = 0; i < bingo.Length; i++)
            {
                if (number == bingo[i])
                {
                    bingo[i] = 0;
                }
            }
            return bingo;
        }
        public static bool Bingoresult(int[] bingo1, int[] bingo2, int[] bingo3)
        {
            bool result = false;
            if (bingo1.Sum() == 0 || bingo2.Sum() == 0 || bingo3.Sum() == 0)
            {
                result = true;
                return result;
            }
            else if (bingo1[0] + bingo2[0] + bingo3[0] == 0 || bingo1[1] + bingo2[1] + bingo3[1] == 0 || bingo1[2] + bingo2[2] + bingo3[2] == 0)
            {
                result = true;
                return result;
            }
            else if (bingo1[0] + bingo2[1] + bingo3[2] == 0 || bingo1[2] + bingo2[1] + bingo3[0] == 0)
            {
                result = true;
                return result;
            }

            return result;
        }
    }
}


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

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

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

int main(){
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    long long countC,countD,countCD,CD;
    CD = lcm(C,D);
    countC = (B / C) - ((A - 1) / C);
    countD = (B / D) - ((A - 1) / D);
    countCD = (B / CD) - ((A - 1) / CD);
    cout << (B - A + 1) - (countC + countD - countCD) << endl;
}

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

int main(){
  long int A,B;
  long int ans;

  cin >>A>>B;
  ans =max(A+B,A-B);
  ans = max(ans,A*B);



  cout <<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e18;
const int mod = 1e9 + 7;

signed main() {
    int N;
    string S;
    cin >> N >> S;
    vector<vector<int>> dp(N + 1, vector<int>(N + 1, 0));
    for (int i = N - 1; i >= 0; i--) {
        for (int j = N - 1; j >= 0; j--) {
            if (S[i] == S[j]) dp[i][j] = dp[i + 1][j + 1] + 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i + dp[i][j] <= j) ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int k,a[50],memo;

signed main() {
    cin >> k;
    rep(i,50) {
        a[i] = 49 + k/50;
        if (k%50 > i) a[i] += 1,memo++;
        else a[i] -= memo;
    }
    cout << 50 << endl;
    rep(i,49) cout << a[i] << " ";
    cout << a[49] << endl;
}



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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

const int MX = 1e4 + 1;
	int ans[MX];


int main() {
	int n;

	cin >> n;

	for(int x=1; x*x<MX; x++) {
		for(int y=1; y*y<MX; y++) {
			for(int z=1; z*z<MX; z++) {
				int val = x*x + y*y + z*z + x*y + y*z + z*x;
				if(val <= n) {
					ans[val]++;
				}

			}
		}
	}

	for(int i=1;i<=n;i++) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <complex>
using namespace std;
typedef complex<int> P;

string s;
int p;

bool overflow(const P &x) {
  return ( x.real() > 10000 || x.real() < -10000 ||
           x.imag() > 10000 || x.imag() < -10000 );
}

int toInt(const string &s) {
  int length = s.size();
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] != '0') break;
    --length;
  }
  if(length > 5) throw 0;
  int x = atoi(s.c_str());
  if(overflow(x)) throw 0;
  return x;
}

P fact();
P term();
P exp();

P fact() {
  P x;
  if(s[p] == '(') {
    ++p;
    x = exp();
    ++p;
  } else if(s[p] == 'i') {
    ++p;
    x = P(0,1);
  } else {
    string num = "";
    while(isdigit(s[p])) {
      num += s[p++];
    }
    x = P(toInt(num),0);
  }
  if(overflow(x)) throw 0;
  return x;
}

P term() {
  P x = fact();
  if(overflow(x)) throw 0;
  while(s[p] == '*') {
    ++p;
    x *= fact();
    if(overflow(x)) throw 0;
  }
  return x;
}

P exp() {
  P x = term();
  if(overflow(x)) throw 0;
  while(s[p] == '+' || s[p] == '-') {
    if(s[p] == '+') {
      ++p;
      x += term();
    } else if(s[p] == '-') {
      ++p;
      x -= term();
    }
    if(overflow(x)) throw 0;
  }
  return x;    
}

int main() {
  while(cin >> s) {
    s += "$";
    p = 0;
    try {
      P res = exp();
      if(res.real() == 0 && res.imag() == 0) {
        cout << 0 << endl;
      } else if(res.imag() == 0) {
        cout << res.real() << endl;
      } else if(res.real() == 0) {
        cout << res.imag() << "i" << endl;
      } else {
        cout << res.real();
        if(res.imag() > 0) cout << "+";
        cout << res.imag() << "i" << endl;
      }
    } catch(...) {
      cout << "overflow" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1272
#include <cstdio>
#include <iostream>
#include <queue>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
inline char nc()
{
    // return getchar();
    static char buf[100000],*l=buf,*r=buf;
    return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x)
{
    x=0; int f=1,ch=nc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
    x*=f;
}
typedef long long ll;
const int maxn=2e5+50;
int n;
int P[maxn];
int C[maxn][2];
struct node
{
    int C0,C1,id;
    node(int C0=0,int C1=0,int id=0):C0(C0),C1(C1),id(id){}
    inline bool operator <(const node &other) const
    {
        return (ll)C0*other.C1<(ll)other.C0*C1;
    }
};
priority_queue<node> q;
namespace us
{
    int fa[maxn];
    void init(int n)
    {
        for(int i=1;i<=n;++i) fa[i]=i;
    }
    int find(int a) {return a==fa[a]?a:find(fa[a]);}
    bool merge(int a,int b)
    {
        a=find(a),b=find(b);
        if(a==b) return 0;
        fa[a]=b; return 1;
    }
}
int main()
{
    read(n);
    for(int i=2;i<=n;++i) read(P[i]);
    for(int i=1;i<=n;++i)
    {
        int x; read(x);
        C[i][x]=1;
        if(i>1) q.push(node(C[i][0],C[i][1],i));
    }
    ll an=0;
    us::init(n);
    while(!q.empty())
    {
        node now=q.top(); q.pop();
        if(C[now.id][0]!=now.C0||C[now.id][1]!=now.C1) continue;
       int u=now.id,p=us::find(P[u]);
        an+=(ll)C[p][1]*C[u][0];
        C[p][0]+=C[u][0];
        C[p][1]+=C[u][1];
        us::merge(u,p);
        if(p!=1) q.push(node(C[p][0],C[p][1],p));
    }
    printf("%lld\n",an);
    return 0;
}

Measured memory_bytes: 6900
#include<stdio.h>
int main(void){
int X,Y;
  int maney=0;
  scanf("%d %d\n",&X,&Y);
  if((X==1)&&(Y==1)){
maney=maney+400000; 
  }
  
     if(X==1){
maney=maney+300000;
     }  
   if(Y==1){
maney=maney+300000;
     }
   if(X==2){
maney=maney+200000;
     }  
   if(Y==2){
maney=maney+200000;
     }
   if(X==3){
maney=maney+100000;
     }  
   if(Y==3){
maney=maney+100000;
     }
  
printf("%d\n",maney);
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int mod = 1e9+7;
const int inf = 1e8;
void solve(){
    ll a,b,n;
    cin>>a>>b>>n;
    n = min(n,b-1);
    ll xa = (a*n)/b;
    ll trt = n/b;
    ll xb = a*trt;
    cout<<xa-xb<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3652