akhauriyash/Code-Regression huggingface dataset:
import sys
N=int(input())
po = []
zp = []
for i in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        zp.append( [x,y] )
    else:
        po.append( [x,y,h] )
for yt in range(101):
    for xt in range(101):
        k = -1
        for p in po:
            tmpH = p[2] + abs(p[0]-xt) + abs(p[1]-yt)
            if k == -1:
                k = tmpH
            else:
                if k != tmpH:
                    k = -1
                    break
        if k == -1:
            continue
        for p in zp:
            if (k - abs(p[0]-xt) - abs(p[1]-yt)) > 0:
                k = -1
                break
        if k != -1:
            print(xt,yt,k)
            sys.exit


Measured memory_bytes: 3064
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfLong()
    val T = A.reduce { acc, a ->  acc + a }
    var x = 0L
    var ans = Long.MAX_VALUE
    for (n in 0 until N - 1) {
        x += A[n]
        ans = Math.min(ans, Math.abs(x - (T - x)))
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong() = listOfString().map(String::toLong)



Measured memory_bytes: 82824
*a,=map(int,open(0).read().split());print('YNeos'[all(t-set(a.index(b)for b in a[10:])for t in({0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}))::2])

Measured memory_bytes: 3060
N = int(input())
A = [int(x) for x in input().split()]
cnt = [0]*(N+1)
ans = 1
mod=10**9+7
for i in range(N):
  if A[i]!=0:
    ans *=cnt[A[i]-1]-cnt[A[i]]
    cnt[A[i]]+=1
  else:
    ans *=(3-cnt[A[i]])
    cnt[A[i]]+=1
print(ans%mod)

Measured memory_bytes: 53428
#include <iostream>

int main(){
	int N,max;
  	int H[100000];
   	scanf("%d",&N);
  if(N==1){
  	printf("Yes");
    return 0;
  }
  for(int i=0;i<=N-1;i++){
  	scanf("%d",&H[i]);
  }
  max=H[0];
  for(int j=1;j<=N-1;j++){
  	if((max-2)>=H[j]){
    	printf("No");
      return 0;
    }
    else {
    	if(H[j]>max){
        	max=H[j];
        }
    }
  }
	printf("Yes");
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		int [] array = new int[101];
		int max = 0;
		
		Scanner stdin = new Scanner(System.in);
		
		
		while (stdin.hasNext()){
			int n = stdin.nextInt();
			array[n]++;
		}
		
		for (int i = 1; i < 101; i++){
			if (max < array[i]){
				max = array[i];
			}
		}
		for (int i = 1; i < 101; i++){
			if (array[i] == max){
				System.out.println(i);
			}
		}
		
	}
}

Measured memory_bytes: 16288
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const unsigned int mod = 1000000007;
//const unsigned int mod = 998244353;

struct mint {
  unsigned int x;
  mint():x(0) {}
  mint(int64_t x_) {
    int64_t v = int64_t(x_ % mod);
    if(v < 0) v += mod;
    x = (unsigned int)v;
  }
  static mint row(int v) {
    mint v_;
    v_.x = v;
    return v_;
  }
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    uint64_t z = x;
    z *= a.x;
    x = (unsigned int)(z % mod);
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  friend bool operator==(const mint &a, const mint &b) {return a.x == b.x;}
  friend bool operator!=(const mint &a, const mint &b) {return a.x != b.x;}
  mint &operator++() {
    x++;
    if(x == mod) x = 0;
    return *this;
  }
  mint &operator--() {
    if(x == 0) x = mod;
    x--;
    return *this;
  }
  mint operator++(int) {
    mint result = *this;
    ++*this;
    return result;
  }
  mint operator--(int) {
    mint result = *this;
    --*this;
    return result;
  }
  mint pow(int64_t t) const {
    mint x_ = *this, r = 1;
    while(t) {
      if(t&1) r *= x_;
      x_ *= x_;
      t >>= 1;
    }
    return r;
  }
  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//head



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  mint u = 8, v = 9, l = 10, ans = u.pow(n) - v.pow(n)*2 + l.pow(n);
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
	double a,b,c,d; cin >> a >> b >> c >> d;
	cout << fixed << setprecision(8) << 
	(double)sqrt((c-a)*(c-a)+(d-b)*(d-b)) << endl;

	return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n,k,ans=0;
  cin >> n >> k;
  while(n>0){
    n/=k;
    ans++;
  }
  cout << ans << endl;
}

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

int N;

bool is_eight (int n) {
    int div = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) div++; 
    }
    return (div == 8);
} 

int main() {
    cin >> N;

    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        if (is_eight(i)) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

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

  sort(a, a + N, greater<int>());
  int A = 0;
  int B = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) A += a[i];
    else B += a[i];
  }
  cout << A - B << endl;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s.at(i);
  }
  vector<vector<int>> ans(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s.at(i).at(j) == '#') {
        for (int k = -1; k <= 1; k++) {
          for (int l = -1; l <= 1; l++) {
            if (0 <= i + k and i + k < h and 0 <= j + l and j + l < w and s.at(i + k).at(j + l) == '.') {
              ans.at(i + k).at(j + l)++;
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s.at(i).at(j) == '#') {
        cout << '#';
      } else {
        cout << ans.at(i).at(j);
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////

int main() {
	int N, M;
	cin >> N >> M;
	vector<pii>Q(M);
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		Q[i].first = b;
		Q[i].second = a;
	}
	sort(Q.begin(), Q.end());
	int ans = 1;
	int t = Q[0].first;
	for (int i = 1; i <M ; ++i) {
		if (Q[i].second >= t) {
			ans++;
			t = Q[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
C197 = (10**9)+7

input = gets.chomp.split('').reverse

dpc = Array.new(13, 0)
dpn = Array.new(13, 0)
dpc[0] = 1
cmod = 1

for i in 0..input.length-1 do
  if input[i] != '?' then # 固定桁
    m = (input[i].to_i)*cmod % 13
    for n in 0..12 do
      dpn[(n+m)%13] += dpc[n]
    end
  else                    # 可変桁
    (0..9).each do |v|
      m = v * cmod % 13
      (0..12).each do |n|
        dpn[(n+m)%13] += dpc[n]
      end
    end
    (0..12).each do |n|
      dpn[n] %= (C197)
    end
  end
  cmod = (cmod*10)%13
  dpc = dpn
  dpn = Array.new(13, 0)
end

print dpc[5]


Measured memory_bytes: 14076
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int cnt[100];

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

    int n;
    cin >> n;

    rep (i, n + 1)
    {
        int u = i;
        while (u >= 10) u /= 10;
        ++cnt[u * 10 + i % 10];
    }

    int ans = 0;
    for (int i = 1; i < 10; ++i)
    {
        for (int j = 1; j < 10; ++j)
        {
            ans += cnt[i * 10 + j] * cnt[j * 10 + i];
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	vector<int> N(3);
	for (int i = 0; i < 3; i++)
		cin >> N[i];
	sort(all(N));
	if (N[0] == N[1] && N[1] != N[2])
		puts("Yes");
	else if (N[0] != N[1] && N[1] == N[2])
		puts("Yes");
	else
		puts("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m; ll a[1005];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    ll m=1000;
    for(int i=2;i<=n;i++){
        if(a[i]>a[i-1]) m=m%a[i-1]+(m/a[i-1])*a[i];
        //cout<<m<<endl;
    }
    printf("%lld",m);
	return 0;
}


Measured memory_bytes: 3812
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto ab = readints;
    int a = ab[0], b = ab[1];

    if (a == 1) a += 13;
    if (b == 1) b += 13;
    if (a == b) writeln("Draw");
    else if (a > b) writeln("Alice");
    else writeln("Bob");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

static inline int dmax(int x, int y){ return x > y ? x : y;}
void trans(char *x, char *y, int v)
{
	while (v++ < 81) *x = '0', x++;
	strcat(x, y);
}

int main(void)
{
	int n;
	char a[128], b[128];
	char x[128], y[128];

	scanf("%d", &n);
	while (n--){
		scanf("%81s %81s", a, b);
		if (dmax(strlen(a), strlen(b)) < 81){
			int carry, i;

			memset(x, 0, sizeof(x));
			memset(y, 0, sizeof(y));

			trans(x, a, strlen(a));
			trans(y, b, strlen(b));
			
			for (carry = i = 0; i < 81; i++){
				int v = x[80 - i] - '0' + y[80 - i] - '0' + carry;
				carry = v > 9;
				x[80 - i] = v % 10 + '0';
			}
			for (i = 0; i < 80 && x[i] == '0'; i++);
			puts(i ? x + i : "overflow");
		}
		else puts("overflow");
	}
	return (0);
}

Measured memory_bytes: 592
#include <stdio.h>
int main(void){
	long a;
	// long double b;
	// scanf("%ld", &a);
	// scanf("%Lf", &b);
	// printf("%ld\n", (long)(a*b));
	char b[5];
	scanf("%ld", &a);
	scanf("%s", b);
	long long_b = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0');
	printf("%ld\n", a*long_b/100);
	return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
// constexpr long long MOD = 1000000007;

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



void Main(){
    COMinit();
    int s;
    cin >> s;
    ll ans = 0;
    REP(i, 1000) {
        int p = s - (i+1) * 3;
        if (p < 0) {
            break;
        }
        ans += COM(p+i, i);
        ans %= MOD;

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

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}



Measured memory_bytes: 15600
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    string S;
    cin >> S;
    string a[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    int b[] = {7,6,5,4,3,2,1};
    rep(i,7){
        if (a[i] == S){
            cout << b[i];
            rn 0;
        }
    }
    
    
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
// #define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int N,W;
vector<int> w[4];

signed main(){

    cin >> N >> W;
    int w0,a;
    cin >> w0 >> a;
    w[0].pb(a);
    for(int i = 1;i <= N-1; i++){
        int x,y;
        cin >> x >> y;
        w[x-w0].pb(y);
    }
    SORT(w[0]);
    SORT(w[1]);
    SORT(w[2]);
    SORT(w[3]);
    vector<int> s[4];
    rep(i,4){
        s[i].pb(0);
        rep(j,w[i].size()){
            int S = s[i][s[i].size()-1];
            s[i].pb(S + w[i][w[i].size() - 1 - j]);
        }
    }

    rep(i,4){
        for(auto x:s[i]) cerr << x << " ";
        cerr << endl;
    }
        cerr << endl;

    int ans = 0;
    rep(t,N+1){
        for(int t0 = 0;t0 <= w[0].size();t0++){
            // if(t0 > t)break;
            // if(t0*w0 > W)break;
            for(int t1 = 0;t1 <= w[1].size();t1++){
                // if(t0+t1 > t)break;
                // if(t0*w0 + t1*(w0+1) > W)break;
                for(int t2 = 0;t2 <= w[2].size();t2++){
                    if(t0+t1+t2 <= t && t - (t0+t1+t2) <= w[3].size() && t0*w0 + t1*(w0+1) + t2*(w0+2) + (t - (t0+t1+t2))*(w0+3) <= W)
                    // if(t0+t1+t2 > t)break;
                    // int t3 = t - (t0+t1+t2);
                    // if(t3 > w[3].size())break;
                    // // if(t0*w0 + t1*(w0+1) + t2*(w0+2) + t3*(w0+3) > W)break;
                    // cerr << "t t0 t1 t2 " << t << " " << t0 << " "<< t1 << " "<< t2 << " " << endl;
{                ans = max(ans,s[0][t0] + s[1][t1] + s[2][t2] + s[3][t - (t0+t1+t2)]);
}                }
            }
        }
    }
    cout  << ans <<endl;




    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include "math.h"
#include "stdio.h"

using namespace std;

int main() {
  int h,w;

  while(scanf("%d%d", &h,&w) && h != 0 && w != 0) {

    for(int i = 0; i< h; i++) {
      for(int j = 0; j<w; j++) {
        printf("#");
      }
      printf("\n");
    }

    printf("\n");
  }

}


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


 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define cins(s,n) rep(i,n)cin>>s.at[i];
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;



ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;cin>>a>>b>>c>>d;
    int x=a+b,y=c+d;
    if(x>y)cout<<"Left";
    else if(y>x)cout<<"Right";
    else cout<<"Balanced";


}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    vector<int> ad, bd;
    for (int i = 1; i <= a; i++) {
        if (a % i == 0)
            ad.push_back(i);
    }
    for (int i = 1; i <= b; i++) {
        if (b % i == 0)
            bd.push_back(i);
    }

    ad.insert(ad.end(), bd.begin(), bd.end());
    sort (ad.begin(), ad.end());

    vector<int> cd;
    for (int i = 0; i < ad.size()-1; i++) {
        if (ad[i] == ad[i+1]) {
            cd.push_back(ad[i]);
        }
    }

    reverse(cd.begin(), cd.end());
    cout << cd[k-1] << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<queue>
#include<stack>

using namespace std;

int main(){
    long long n;
    cin >> n;
    string s;
    cin >> s;

    queue<long long> white;
    stack<long long> red;
    long long i = 0;
    for(string::iterator itr = s.begin(); itr != s.end(); itr++){
        if(*itr == 'W') white.push(i);
        else red.push(i);
        i++;
    }
    long long count = 0;
    while(!white.empty() && !red.empty()){
        long long w = white.front(), r = red.top();
        white.pop(); red.pop();
        if(w > r) break;
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 5276
#include<stdio.h>
int main(void){
	int a;
  	int b;
  	int c;
  scanf("%d", &a);
  scanf("%d", &b);
  if(a+b==3){
    c=3;
  }
  else if(a+b==4){
  	c=2;
  }
  else{
  	c=1;
  }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 128
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        m: usize,
        x: [usize; n],
    }
    let len = 100_000 + 1;
    let mut cnt = vec![0; len];
    for x in x {
        cnt[x] += 1;
    }
    let mut rem = vec![0; m];
    let mut pair = vec![0; m];
    let mut ans = 0;
    for i in 0..len {
        let p = cnt[i] / 2;
        ans += p;
        pair[i % m] += p;
        rem[i % m] += cnt[i] % 2;
    }
    ans += rem[0] / 2;
    if m % 2 == 0 {
        ans += rem[m / 2] / 2;
    }
    for i in 1..m {
        if i >= m - i {
            break;
        }
        let v = std::cmp::min(rem[i], rem[m - i]);
        ans += v;
        rem[i] -= v;
        rem[m - i] -= v;
        for &(x, y) in &[(i, m - i), (m - i, i)] {
            while rem[x] >= 2 && pair[y] >= 1 {
                ans += 1;
                rem[x] -= 2;
                pair[y] -= 1;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int n,ma,ans=0;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    if(a[0]==1){//delete corner min=1
        if(a[1]==1)cout<<0;
        else cout<<1;
        return 0;
    }
    ma=a[n-1]+5;//max num+5=chart size
    vector<int>ch(ma);//ox chart
    rep(i,n){
        if(ch[a[i]])ch[a[i]]=2;
        else ch[a[i]]=1;
    }
    for(int i=2;i<ma;i++){
        if(ch[i]==0)continue;
        int j=2;
        while(i*j<ma){
            ch[i*j]=0;
            j++;
        }
        if(ch[i]>1)ch[i]=0;
    }
    rep(i,ma){//sum
        ans+=ch[i];
        //cout<<ch[i];
    }
    cout<<ans;
	return 0;
}


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

typedef long long ll;

const ll INF = 1e10;

int main(int argc, char* argv[])
{
  int N, Z, W;
  std::cin >> N >> Z >> W;

  std::vector< ll > va(N, 0);
  for (int i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll ans = -INF;
  if (N > 1) {
    ans = std::max(ans, (ll)std::fabs(va[N-2] - va[N-1]));
  }
  ans = std::max(ans, (ll)std::fabs(va[N-1] - W));

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


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)

def disp(x):
    return 0 if x%10==0 else x

def main():
    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    A.sort()

    asum = sum(A)
    vmax = disp(asum)
    for a in A:
        v = disp(asum - a)
        vmax = max(vmax, v)

    print(vmax)

if __name__ == "__main__": main()


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int n, d, x;

	cin >> n;
	cin >> d >> x;

	int a;
	int num = 0;

	for (int i = 0; i < n; i++)
	{
		int k = 1;
		cin >> a;
		num++;
		for (int j = 2; j <= d; j++)
		{
			if (j == a * k + 1)
			{
				num++;
				k++;
			}
		}
	}

	cout << num + x << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 1e5 + 5;

int n;
int a[N];
map<int, int> freq;
vector<int> v;

bool valid() {
    if(freq[0] == n) return true;
    if(n % 3 != 0) return false;
    if(v.size() == 2) {
        if(freq[0] == n / 3) return true;
        return false;
    }
    if(v.size() == 3) {
        if(freq[v[0]] == (n / 3) && freq[v[1]] == (n / 3) && freq[v[2]] == (n / 3)) {
            if((v[0] ^ v[1] ^ v[2]) == 0) {
                if(v[0] != v[1] && v[0] != v[2] && v[1] != v[2]) return true;
                return false;
            }
            return false;
        }
        return false;
    }
    return false;
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        freq[a[i]]++;
        if(freq[a[i]] == 1) v.pb(a[i]);
    }
    if(valid()) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 4472
n, m = map(int, input().split())
can_open = []
cost = []
for _ in range(m):
    a, b = map(int, input().split())
    cost.append(a)
    it = map(int, input().split())
    x = 0
    for c in it:
        x += 1 << (c-1)
    can_open.append(x)

n_bit = 1 << n
INF = 10**18
dp = [INF]*n_bit
dp[0] = 0

for j in range(n_bit):
    for i in range(m):
        dp[j | can_open[i]] = min(dp[j | can_open[i]], dp[j]+cost[i])

print(dp[-1] if dp[-1] != INF else -1)


Measured memory_bytes: 45272
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n,x;

  cin>>n>>x;

  int m[101];

  int i;

  for(i=0;i<n;i++){
    cin>>m[i];
    x-=m[i];
  }

  sort(m,m+n);

  int cnt=i;

  cnt+=x/m[0];

  


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


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const H = ~~arg[0].split(" ")[0];
    const W = ~~arg[0].split(" ")[1];
    
    const table = arg.slice(1, H + 1).map(n=>n.split(""));
    
    const dx = [0, 1, 1, 1, 0, -1, -1, -1];
    const dy = [-1, -1, 0, 1, 1, 1, 0, -1];
    
    for(let i=0; i<H; i++) {
        for(let j=0; j<W; j++) {
            let cnt = 0;
            for(let k=0; k<8; k++) {
                const nx = dx[k] + j;
                const ny = dy[k] + i;
                
                if(ny < 0 || nx < 0) {
                    continue;
                }
                
                if(ny > H - 1 || nx > W - 1) {
                    continue;
                }
                
                
                if(table[ny][nx] === "#") {
                    cnt++;
                }
            }
            
            if(table[i][j] === ".") {
                table[i][j] = cnt;
            }
        }
    }
    
    console.log(table.map(n=>n.join("")).join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
import collections

def main():
    N, M = map(int, input().split())
    d = collections.defaultdict(int)
    for _ in range(N):
        kA = list(map(int, input().split()))
        for i in range(1, kA[0]+1):
            d[kA[i]] += 1

    count = 0
    for A in d:
        if d[A] == N: count += 1
    return count

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

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const int INF = 2147483647;
int N, Q;

struct LazySegmentTree {
private:
    int n;
    vector <ll> node, lazy;

public:
    LazySegmentTree(vector <ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);
        for (int i = 0; i < sz; i++) node[i+n-1] = v[i];
        for (int i = n-2; i >= 0; i--) node[i] = node[2*i+1] + node[2*i+2];
    }

    void eval(int k, int l, int r) {
        if (lazy[k] > 0) {
            node[k] += lazy[k];
            if (r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, int val, int k=0, int l=0, int r=-1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] += val * (r - l);
            eval(k, l, r);
        } else {
            add(a, b, val, 2*k+1, l, (l+r)/2);
            add(a, b, val, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

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

    cin >> N >> Q;
    LazySegmentTree seg(vector<ll>(N, 0));
    for (int i = 0; i < Q; i++) {
        int c;
        cin >> c;
        if (c == 0) {
            int s, t;
            ll x;
            cin >> s >> t >> x;
            seg.add(s-1, t, x);
        } else {
            int s, t;
            cin >> s >> t;
            cout << seg.getsum(s-1, t) << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 7848
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
    ll x, y; cin >> x >> y;
    if (fabs(x - y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    string s; 
    cin>>s; 
    if(s[1]=='B'){
      s[1]='R'; 
    }
    else{
     s[1]='B'; 
    } 
    cout<<s<<endl; 
    //printclock;
    return 0;
}
    

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n;
vl b;
vl a;
ll ans;

int main(){
  cin >> n;
  b = vl(n);
  for(ll i = 1;i <= n-1;i++) cin >> b[i];
  a = vl(n);
  a[0] = b[1];
  for(ll i = 1;i < n-1;i++){
    a[i] = min(b[i],b[i+1]);
  }
  a[n-1] = b[n-1];
  for(ll i = 0;i < n;i++) ans += a[i];
  cout << ans << endl;

}


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

using namespace std;
using ll = unsigned long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a;
    double x;
    cin >> a >> x;
    
    ll test = (0.005 + x) * 1000 / 10;
    
    cout << (a * test) / 100;
}

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

using namespace std;

int n;
int main(){
    cin >> n;
    if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n %10 == 8){
        cout << "pon";
    }
    else if(n%10 == 3){
        cout << "bon";
    }
    else cout << "hon";
    return 0;
}

Measured memory_bytes: 3632
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

r, D, x_s = [ int(x) for x in input().split() ]

x = x_s
for _i in range(10):
    x = r * x - D
    print (x)


Measured memory_bytes: 23840
def main():
    import sys
    def MI():
        return map(int, sys.stdin.readline().rstrip().split())
    def LI():
        return list(map(int, sys.stdin.readline().rstrip().split()))  # 空白あり

    N,Q = MI()
    c = [0] + LI()
    lr = []
    for i in range(Q):
        l,r = MI()
        lr.append((i,l,r))

    from operator import itemgetter

    lr = sorted(lr,key=itemgetter(2))  # 右端rでソート
    a = 0
    d = {}  # d[i] = 玉iが現れた最も右の位置
    ANS = [0]*Q


    class BIT():
        def __init__(self, init_value):
            self.n = len(init_value)
            self.tree = [0] * (self.n + 1)
            for i in range(1, self.n + 1):
                x = init_value[i - 1]
                while i <= self.n:
                    self.tree[i] += x
                    i += i & (-i)

        def update(self, i, x):  # i(1-index)番目の値を+x
            while i <= self.n:
                self.tree[i] += x
                i += i & (-i)
            return

        def query(self, i):  # 1番目からi(1-index)番目までの和を返す
            res = 0
            while i > 0:
                res += self.tree[i]
                i -= i & (-i)
            return res


    bit = BIT([0]*N)  # 最も右に現れた玉の位置を管理
    for i in range(1,N+1):
        if not c[i] in d.keys():
            d[c[i]] = i
            bit.update(i,1)
        else:
            bit.update(d[c[i]],-1)
            d[c[i]] = i
            bit.update(i, 1)
        while a <= Q-1 and lr[a][2] == i:
            j,l,r = lr[a]
            ANS[j] = bit.query(r)-bit.query(l-1)
            a += 1

    print(*ANS,sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 251568
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    if(n%2==1){
        rep(i,m){
            cout << i+1 << " " << n-i <<endl;
        }
    }else{
        int p= 0;
        rep(i,m){
            if(2*i+1>=n/2) p=1;
            cout << n/2-1-i << " " << n/2 +i+p <<endl;
        }
    }
}

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine();
            Console.WriteLine(word + (word.Last() == 's' ? "es" : "s"));
        }
    }
}

Measured memory_bytes: 26224
r, c, n = map(int, input().split())
dots = []
num = 0
for i in range(n):
	x1, y1, x2, y2 = map(int, input().split())
	if (0 < x1 < r and 0 < y1 < c) or (0 < x2 < r and 0 < y2 < c):
		continue
	else:
		num += 1
		d1 = (x1, y1)
		d2 = (x2, y2)
		if x1 == 0:
			dots.append((y1, i))
		elif y1 == c:
			dots.append((c + x1, i))
		elif x1 == r:
			dots.append((2 * c + r - y1, i))
		else:
			dots.append((2 * (r + c) - x1, i))

		if x2 == 0:
			dots.append((y2, i))
		elif y2 == c:
			dots.append((c + x2, i))
		elif x2 == r:
			dots.append((2 * c + r - y2, i))
		else:
			dots.append((2 * (r + c) - x2, i))

#print(dots)
if num <= 1:
	print("YES")
else:
	dots.sort(key=lambda x: x[0])
	stack = []
	for i in range(num * 2):
		if stack == []:
			stack.append(dots[i][1])
		else:
			if stack[-1] == dots[i][1]:
				stack.pop()
			else:
				stack.append(dots[i][1])
	if stack:
		print("NO")
	else:
		print("YES")

Measured memory_bytes: 30244
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n >> y;
    rep(itiman, n + 1)
    {
        rep(gosen, n + 1)
        {
            ll sen = n - itiman - gosen;
            if (sen < 0)
                continue;
            ll money = 10000 * itiman + 5000 * gosen + 1000 * sen;
            if (money == y)
            {
                cout << itiman << " " << gosen << " " << sen << "\n";
                return 0;
            }
        }
    }
    cout << "-1 -1 -1\n";
    return 0;
}


Measured memory_bytes: 256
/*{{{*/
// think twice code once
// Start:[]
// End  :[]
#include <bits/stdc++.h>
using namespace std;

#define rep(i, x, y) for(int i = (x), _ = (y); i <= _; ++ i)
#define per(i, x, y) for(int i = (x), _ = (y); i >= _; -- i)
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
#define disp(x) cout << #x << " = " << x << "; "
#define x first
#define y second
#define mp make_pair
#ifdef __linux__
#define getchar getchar_unlocked
#define LLFORMAT "%lld"
#else
#define LLFORMAT "%I64d"
#endif

typedef long long LL;

template <class T> bool chkmin(T& a, T b) { return a > b ? a = b, true : false; }
template <class T> bool chkmax(T& a, T b) { return a < b ? a = b, true : false; }

template <class T> void read(T& a) {
	char c = getchar(); T f = 1; a = 0;
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) a = a * 10 + c - '0';
	a *= f;
}
/*}}}*/

const int maxN = 3e5 + 5;

priority_queue<int, vector<int>, greater<int> > q;
LL pre[maxN], suf[maxN];
LL sum;
int N, a[maxN], b[maxN];

int main()
{
#ifdef Leeson
	freopen("tmp.in", "r", stdin);
	freopen("tmp.out", "w", stdout);
#endif

	LL ans = LLONG_MIN;
	read(N);
	rep(i, 1, N * 3) read(a[i]), b[i] = -a[i];
	rep(i, 1, N * 3)
	{
		q.push(a[i]);
		sum += a[i];
		if((int)q.size() > N) 
			sum -= q.top(), q.pop();
		pre[i] = sum;
	}
	while(!q.empty()) q.pop();
	sum = 0;
	per(i, N*3, 1)
	{
		sum += b[i];
		q.push(b[i]);
		if((int)q.size() > N)
			sum -= q.top(), q.pop();
		suf[i] = sum;
	}
	rep(i, N, 2*N)
		chkmax(ans, pre[i] + suf[i + 1]);
	//rep(i, 1, N*3)
	//{
	//	printf("%lld\n", pre[i]);
	//}
	//per(i, N*3, 1)
	//{
	//	printf("%lld\n", suf[i]);
	//}

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


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

min_time = [0 for _ in range(N)]
for i in range(N-1):
    speed, start, interval = map(int, input().split())
    min_time[i] += start + speed
    for j in range(i):
        if min_time[j] - start < 0:
            min_time[j] = start
        else:
            while (min_time[j] - start) % interval != 0:
                min_time[j] += 1
        min_time[j] += speed

for ans in min_time:
    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define pl(a,b) a=(a+b)%mod;
#define N 5010
ll dpb[N][N],dpr[N][N];
ll cs1[N][N],cs2[N];
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	if(a>b)swap(a,b);
	rep(i,N)rep(j,N)dpb[i][j]=dpr[i][j]=0;
	rep(i,N)rep(j,N)cs1[i][j]=0;
	rep(i,N)cs2[i]=0;
	dpb[0][1]=1;
	ll ans=0;
	for(int i=0;i<=n;i++)for(int j=0;j<=n+1;j++){
		if(i-j+1>=b)continue;
		if(i)pl(cs1[j][i],cs1[j][i-1]);
		pl(dpr[i][j],cs1[j][i]);
		if(i+1==j){
			pl(cs2[i],cs2[i-1]);
			pl(dpr[i][j],cs2[i]);
		}
		if(i==n){
			pl(ans,dpb[i][j]);
			pl(ans,dpr[i][j]);
			continue;
		}
		pl(dpb[i+1][j],dpb[i][j]);
		pl(dpb[i+1][j],dpr[i][j]);
		pl(cs1[j][i+a],dpb[i][j]);
		pl(cs2[i+1],dpb[i][j]);
		pl(cs2[i+a],-dpb[i][j]);
		/*
		for(int k=1;i+k<=n;k++){
			if(k>=a)pl(dpr[i+k][j],dpb[i][j]);
			if(k<a)pl(dpr[i+k][i+k+1],dpb[i][j]);
		}*/
	}
	ll c=1;
	rep(i,n)c=c*2%mod;
	ans=c-ans;
	ans%=mod;
	if(ans<0)ans+=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 591960
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
	ll a,b,k;
	cin>>a>>b>>k;
	per(i,1,min(a,b)+1){
		if(a%i==0&&b%i==0)k--;
		if(k==0){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

struct db {
	ll f;
	ll s;
};

bool cmp(db x, db y) {
	return x.s > y.s;
}



ll n;

ll v[MAX];

int main() {

	cin >> n;
	repn(i, n) cin >> v[i];

	db cnto[200000];
	db cnte[200000];

	repn(i, 199999) {
		cnto[i] = { i,0 };
		cnte[i] = { i,0 };
	}

	for (int i = 1; i <= n / 2; i++) {
		cnto[v[2 * i - 1]].s++;
		cnte[v[2 * i]].s++;
	}

	sort(cnto + 1, cnto + 200000,cmp);
	sort(cnte + 1, cnte + 200000,cmp);

	if (cnto[1].f == cnte[1].f) {
		cout << n - max(cnto[1].s + cnte[2].s, cnto[2].s + cnte[1].s);
	}
	else { cout << n - cnto[1].s - cnte[1].s; }

	

	system("PAUSE");
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b, c;

int main(void) {
  // Here your code !
  scanf("%d %d %d", &a, &b, &c);

  set<int> visited;

  visited.insert(a % b);

  for (int i = 2; i <= 100; ++i) {
    int tmp = (a * i) % b;
    if (visited.find(tmp) != visited.end()) {
      break;
    }
    visited.insert(tmp);
  }

  if (visited.find(c) != visited.end()) {
    printf("YES\n");
  }
  else {
    printf("NO\n");
  }

  return 0;
}


Measured memory_bytes: 256