akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 6");
            WillReturn.Add("2 1");
            WillReturn.Add("3 4");
            WillReturn.Add("4 10");
            WillReturn.Add("3 4");
            //11
            //1,3個目の物を選ぶと良いです
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 6");
            WillReturn.Add("2 1");
            WillReturn.Add("3 7");
            WillReturn.Add("4 10");
            WillReturn.Add("3 6");
            //13
            //2,4個目の物を選ぶと良いです
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4 10");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            //400
            //すべての物が選べます
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("4 1");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            //0
            //1個も物が選べません
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct NimotuDef
    {
        internal int W;
        internal int V;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        int W = wkArr[1];

        var NimotuList = new List<NimotuDef>();
        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            NimotuList.Add(new NimotuDef() { W = wkArr[0], V = wkArr[1] });
        }

        //最大の価値[重さ合計]なDP表
        var DPDict = new Dictionary<int, int>();
        DPDict[0] = 0;

        foreach (NimotuDef EachNimotu in NimotuList) {
            foreach (int EachKey in DPDict.Keys.OrderByDescending(A => A).ToArray()) {
                int NewKey = EachKey + EachNimotu.W;
                if (NewKey > W) continue;

                int NewVal = DPDict[EachKey] + EachNimotu.V;

                if (DPDict.ContainsKey(NewKey)) {
                    if (DPDict[NewKey] < NewVal) {
                        DPDict[NewKey] = NewVal;
                    }
                }
                else DPDict[NewKey] = NewVal;
            }
        }
        Console.WriteLine(DPDict.Values.Max());
    }
}


Measured memory_bytes: 14048
def main():

    N, M, X = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    count1 = 0
    for i in range(M):
        if A[i] < X: count1 += 1
    return min(count1, len(A)-count1)



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


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n,m;
  cin >> n >> m;
  
  int count = 0;
  if(m>=2){
    vector<vector<uint64_t>> vec(m+1, vector<uint64_t>(m+1, 0));
    comb(vec);
    count += vec[m][2];
  }
  if(n>=2){
    vector<vector<uint64_t>> vec(n+1, vector<uint64_t>(n+1, 0));
    comb(vec);
    count += vec[n][2];
  }
  
  cout << count << endl;
 
  return 0;
}




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

#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()

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

    for(int i=1; i<=9; i++){
        if(1<=n/i && n/i<=9 && n%i==0){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" << endl;


}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

const int mod = 1'000'000'007;
vector<int> h;

struct dp_t {
  long long alternating;
  long long other;
};

long long power(long long n, long long k, long long m) {
  if (m < 0) m = -m;
  n %= m;
  long long ret = 1;
  while (k) {
    if (k & 1) ret = (ret * n % m);
    n = (n * n % m);
    k >>= 1;
  }
  return ret;
}


dp_t solve(int L, int R, int base) {
  dp_t res = { 0, 0 };
  if (L == R) {
    int count = h[L] - base;
    res.alternating = power(2, count - 1, mod);
    return res;
  }
  int splitbase = *min_element(h.begin() + L, h.begin() + R + 1);
  int last = L;
  long long alternate = 1;
  long long all = 1;
  for (int i = L; i <= R; i++) {
    if (h[i] == splitbase) {
      last = i + 1;
      all *= 2;
      all %= mod;
    }
    else if (i + 1 > R || h[i + 1] == splitbase) {
      if (last == i) {
        all *= power(2, h[i] - splitbase, mod);
        all *= 2;
        all %= mod;
        alternate *= power(2, h[i] - splitbase, mod);
        alternate %= mod;
      }
      else {
        dp_t sub = solve(last, i, splitbase);
        alternate *= sub.alternating * 2;
        alternate %= mod;
        all *= (sub.alternating * 4 + sub.other) % mod;
        all %= mod;
      }
    }
  }

  res.other = (all - alternate * 2) % mod;
  alternate *= power(2, splitbase - base - 1, mod);
  alternate %= mod;
  res.alternating = alternate;
  return res;
}

int main() {
  int n;
  scanf("%d", &n);
  h.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  dp_t ans = solve(0, n-1, 0);
  long long val = (ans.alternating * 2 + ans.other) % mod;
  val += mod;
  val %= mod;
  printf("%lld\n", val);
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = []
for i in range(h):
	a.append(list(input()))


temp1 = []
temp2 = []
for i in range(len(a)):
	ff = 0
	for j in range(len(a[i])):
		if a[i][j] == '.':
			continue
		ff = 1
	if ff == 0:
		temp1.append(i)
temp1.sort(reverse=True)
for i in range(len(a[0])):
	ff = 0
	for j in range(len(a)):
		if a[j][i] == '.':
			continue
		ff = 1
	if ff == 0:
		temp2.append(i)
temp2.sort(reverse=True)
for i in range(len(temp1)):
	a.pop(temp1[i])
for i in range(len(temp2)):
	for k in range(len(a)):
		a[k].pop(temp2[i])

for i in range(len(a)):
	s = ''
	for j in range(len(a[i])):
		s += a[i][j]
	print(s)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, q;
  cin >> n >> q;
  
  vector<vector<int>> v(2 * n, vector<int>(3));
  // v[i][0], v[i][1], v[i][2]: 出発時刻, 工事の始まりか終わりか, 座標
  for (int i = 0; i < n; i++) {
    int s, t, x;
    cin >> s >> t >> x;
    v.at(2 * i).at(0) = s - x;
    v.at(2 * i).at(1) = 1;
    v.at(2 * i).at(2) = x;
    v.at(2 * i + 1).at(0) = t - x;
    v.at(2 * i + 1).at(1) = 0;
    v.at(2 * i + 1).at(2) = x;
  }
  
  sort(v.begin(), v.end());
  
  multiset<int> s;
  vector<vector<int>> w(2 * n, vector<int>(2));
  for (int i = 0; i < v.size(); i++) {
    if (v.at(i).at(1) == 1) {
      s.insert(v.at(i).at(2));
      w.at(i).at(0) = v.at(i).at(0);
      if (!s.empty()) w.at(i).at(1) = *s.begin();
      else w.at(i).at(1) = -1;
    }
    else {
      s.erase(v.at(i).at(2));
      w.at(i).at(0) = v.at(i).at(0);
      if (!s.empty()) w.at(i).at(1) = *s.begin();
      else w.at(i).at(1) = -1;
    }
  }
  
  for (int i = 0; i < q; i++) {
    int d;
    cin >> d;
    int left = -1, right = 2 * n;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (w.at(mid).at(0) <= d) left = mid;
      else right = mid;
    }
    if (left == -1) cout << "-1\n";
    else cout << w.at(left).at(1) << '\n';
  }
}

Measured memory_bytes: 54400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
 
using namespace std;
 
typedef pair<int, int> P;
 
int main(){
    int D;
    cin >> D;
    int x, y;
    vector<P> v;
    cin >> x;
    while (x--){
        string s;
        cin >> s;
        int p;
        cin >> p;
        if (s == "D") v.push_back(make_pair(1, p));
    }
    cin >> y;
    while (y--){
        string s;
        cin >> s;
        int p;
        cin >> p;
        if (s == "DD") v.push_back(make_pair(2, p));
    }
 
    int n = v.size();
 
    int ans = 0;
    for (int i = 0; i < (1 << n); ++i){
        int cost = 0, tmp = 0;
        for (int j = 0; j < n; ++j){
            if (i&(1 << j)){
                cost += v[j].first;
                tmp += v[j].second;
            }
        }
        if (cost <= D) ans = max(ans, tmp);
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
using namespace std;
int main(void) {
  int y, m, d;
  int day;
  while(scanf("%d %d %d", &y, &m, &d) != EOF) {
    day = y * 365 + m * 30 + d;
    if(day >= 682098 && day <= 698119) {
      cout << "meiji" << ' ' << y - 1868 + 1<< ' ' << m << ' ' << d << endl;
    }
    else if(day >= 698120 && day <= 703374) {
      cout << "taisho" << ' ' << y - 1912 + 1<< ' ' << m << ' ' << d << endl;
    }
    else if(day >= 703375 && day <= 726022) {
      cout << "showa" << ' ' << y - 1926 + 1<< ' ' << m << ' ' << d << endl;
    }
    else if(day >= 726023) {
      cout << "heisei" << ' ' << y - 1989 + 1 << ' ' << m << ' ' << d << endl;
    }
    else if(day <= 682097) {
      cout << "pre-meiji" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true) cerr

template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print(const ContainerType<ValueType, Args...> &c)
{
    for (const auto &v : c)
        cout << v << ' ';
    cout << '\n';
}

void print() { cout << '\n'; }
template <typename T, typename... Args>
void print(T a, Args... args)
{
    cout << a << " ";
    print(args...);
}

lli llipower(lli x, lli y, lli p = LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}

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


int main(){
    int n;
    cin>>n;
    lli ans=1;
    lli x;
    vector<lli> a(n);
    fori(n) cin>>a[i];
    fori(n){
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    fori(n)
    {
        x=a[i];
        if(x>((lli)1e18)/ans){
            cout<<-1<<endl;
            return 0;
        }
        else ans*=x;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4060
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 0
pattern = set()
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    p = tuple(sorted((a, b, c)))
    if p in pattern:
        print(-1)
        sys.exit(0)
    pattern.add(p)
    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
    ans += 1

print(ans)


Measured memory_bytes: 61960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-12;

#define GE(n,m) (EPS > (m) - (n) )

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

Point proj(Point a1, Point a2, Point p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

VP crosspointLC(Point a1, Point a2, Point c, double r) {
  VP ps;
  Point ft = proj(a1, a2, c);
  if(!GE(r*r,norm(ft-c))) assert(false);
  Point dir = sqrt(max(r*r - norm(ft-c), 0.0)) / abs(a2-a1) * (a2-a1);
  ps.push_back(ft + dir);
  ps.push_back(ft - dir);
  return ps;
}

namespace std {
  bool operator<(const Point a, const Point b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

int main(void){
    double cx,cy,r;
    int q;
    cin>>cx>>cy>>r>>q;
    rep(i,q){
        double x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        VP ps = crosspointLC(Point(x1,y1),Point(x2,y2),Point(cx,cy),r);
        sort(all(ps));
        printf("%.9f %.9f " ,ps[0].X,ps[0].Y);
        printf("%.9f %.9f\n",ps[1].X,ps[1].Y);
    }
    return 0;
}

Measured memory_bytes: 3236
def test():
    s = input()
    n = len(s)
    for i in range(0,n,2):
        if s[i] == "L":
            print("No")
            return
    for i in range(1,n,2):
        if s[i] == "R":
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    test()


Measured memory_bytes: 2940
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = ~~arg[0].split(" ")[0];
    const M = ~~arg[0].split(" ")[1];
    const X = arg[1].split(" ").map(n=>~~n).sort((a,b)=>a-b);
    
    // ソートして、差の大きい順で分ける
    let diffs = [];
    
    for(let i in X) {
        if(X[~~i+1] - X[i]) {
            diffs.push(X[~~i+1] - X[i]);
        }
    }
    
    if(!diffs.length || N >= M) {
        console.log(0);
        return;
    }
    
    diffs.sort((a,b)=>b-a);
    let answer = diffs.reduce((m,n)=>m+n);

    for(let i=0; i<N-1; i++) {
        answer -= diffs[i];
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n_ = ri();
	int n = n_;
	if (n & 1) n++;
	std::string s;
	std::cin >> s;
	int q = s.size();
	
	int half = n / 2;
	int k3 = 1;
	for (int i = 0; i < half; i++) k3 *= 3;
	int next[k3];
	for (int i = 0; i < k3; i++) {
		int cur[half];
		int t = i;
		for (int j = 0; j < half; j++) cur[j] = t % 3, t /= 3;
		for (auto &j : cur) {
			if (j == 1) j = 2;
			else if (j == 2) j = 1;
		}
		t = 0;
		for (int j = half; j--; ) t *= 3, t += cur[j];
		next[i] = t;
	}
	
	std::vector<int> plus[k3];
	int end[k3];
	for (int i = 0; i < k3; i++) {
		int cur = i;
		for (auto j : s) {
			if (j == 'S') {
				cur = next[cur];
				if (!plus[i].size()) plus[i].push_back(0);
				else if (plus[i].back() == 0) plus[i].pop_back();
				else plus[i].push_back(0);
			} else if (cur + 1 == k3) {
				cur = 0;
				if (!plus[i].size() || !plus[i].back()) plus[i].push_back(1);
				else plus[i].back()++;
			} else cur++;
		}
		end[i] = cur;
	}
	int res[k3 * k3];
	for (int i = 0; i < k3; i++) {
		for (int j = 0; j < k3; j++) {
			int cur = i;
			for (auto k : plus[j]) {
				if (!k) cur = next[cur];
				else cur = (cur + k) % k3;
			}
			res[i * k3 + j] = cur * k3 + end[j];
		}
	}
	int all = k3 * k3;
	if (n_ != n) all /= 3;
	for (int i = 0; i < all; i++) printf("%d ", res[i] % all);
	puts("");
	return 0;
}


Measured memory_bytes: 7240
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '

int main() {
    long a,b;
    cin >> a >> b;
    double real = (double)a / b;
    real *= pow(10, 10);
    real = round(real);
    real /= pow(10, 10);
    printf("%d %d %1.9lf\n", a/b, a%b, real);

    return 0;
}


Measured memory_bytes: 3248
#include<iostream>
using namespace std;
int main(){
  int ans=0;
  char a,b,c,d,e,f;
  cin >> a >> b >> c;
  cin >> d >> e >> f;
  if(a==d){
    ans++;
  }
  if(b==e){
    ans++;
  }
  if(c==f){
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) (c).begin(),(c).end()
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { SORT(a); a.erase(unique(ALL(a)),a.end()); }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S,T> a) {
  return os << a.first << ' ' << a.second;
}
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,A,B;
int h[100010];
int w[100010];

bool check(int m) {
  REP(i,N) w[i] = h[i];
  REP(i,N) w[i] -= m*B;
  int cnt = 0;
  int D = A-B;
  REP(i,N) if (w[i] > 0) {
    cnt += (w[i]+D-1)/D;
  }
  return cnt <= m;
}

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

  cin >> N >> A >> B;
  REP(i,N) cin >> h[i];
  int ng = 0, ok = 1000000000;
  while (ok - ng > 1) {
    int m = (ng + ok) / 2;
    if (check(m)) ok = m;
    else ng = m;
  }
  cout << ok << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template<typename t1, class t2>
void input(t1 count,t2 array) {
	for(t1 i = 0;i < count;i++) {
		cin >> array[i];
	}
}

template<typename t1, class t2>
void output(t1 count,t2 array) {
	for(t1 i = 0;i < count;i++) {
		cout << array[i];
		if(i != count - 1) cout << " ";
	}
	cout << endl;
}

int main(int argc,char** argv) {
	string s;
	cin >> s;
	int a = 0;
	stack<int> w;
	stack<pair<int,int>> g;
	pair<int,int> f,h;
	for(int i = 0;i < s.size();i++) {
		switch(s[i]){
		case '/':
			if(!w.empty()) {
			a += i - w.top();

			f.first = w.top();
			f.second = i - w.top();
			while(g.size() >= 1 && g.top().first >= w.top() ) {
				h = g.top();
				g.pop();
				f.second += h.second;
			}
			g.push(f);
			w.pop();
			}
			break;
		case '\\':
			w.push(i);

			break;
		}

	}
	cout << a << endl;
	cout << g.size();
	if(!g.empty()) cout << " ";
	stack<int> gg;
	while(!g.empty()) {
		gg.push(g.top().second);
		g.pop();
	}
	while(!gg.empty()) {
		cout << gg.top();
		gg.pop();
		if(!gg.empty()) cout << " ";
	}
	cout << endl;
}



Measured memory_bytes: 3268
#include <iostream>
using namespace std;
int gcd(int a1, int b1) {
    if(a1 == 0 || b1 == 0) {
        return 0;
    }
    if(a1 >= b1) {
        if(a1 % b1 == 0) {
            return b1;
        } else {
            return gcd(b1, a1 % b1);
        }
    } else {
        if(b1 % a1 == 0) {
            return a1;
        } else {
            return gcd(a1, b1 % a1);
        }
    }
}

int main(void){
    // Here your code !
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
}

Measured memory_bytes: 3088
n = int(input())
s = (n-1)*n//2

if n%2 == 1:

    g = [[] for _ in range(n)]
    for i in range(n):
        j = i+1
        if j != n:
            k = n-j
            #print(j, k)
            for a in range(1, n+1):
                if a == j or a == k:
                    continue
                else:
                    if a > j:
                        g[i].append(a-1)
        #else:
            #for a in range(1, n):
                #g[i].append(a-1)
    #print(g)
    cnt = 0
    edge = []
    for v in range(n):
        cnt += len(g[v])
        for u in g[v]:
            edge.append((v+1, u+1))
    print(cnt)
    for v, u in edge:
        print(v, u)

else:
    g = [[] for _ in range(n)]
    for i in range(n):
        j = i+1
        if j != n:
            k = n+1-j
            #print(j, k)
            for a in range(1, n+1):
                if a == j or a == k:
                    continue
                else:
                    if a > j:
                        g[i].append(a-1)
    cnt = 0
    edge = []
    for v in range(n):
        cnt += len(g[v])
        for u in g[v]:
            edge.append((v+1, u+1))
    print(cnt)
    for v, u in edge:
        print(v, u)


Measured memory_bytes: 43504
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(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; }
using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
const ll MOD = 1e9+7; ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0}; vi d4y = {0, 1, 0, -1};
//---------------------------------------

int main(){
    ll n; cin>>n;
    ll ans=INF;
    for(ll i = 1; i<=sqrt(n); i++){
        if(n%i==0){
            ll a=i;
            ll b=n/i;
            ans=min(ans,a+b-2);
        }
    }
    cout<<ans<<endl;
}

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

inline bool isPrime(int a){
  if(a<=1)return false;
  for(int i=2;i*i<=a;i++){
    if(a%i==0)return false;
  }
  return true;
}

int main(){
  bool pt[30030] = {};
  vector<int> pl;
  for(int i=0;i<=30000;i++){
    if(isPrime(i)){
      pt[i] = 1; pl.push_back(i);
    }
  }

  int t;
  while(scanf("%d",&t),t){
    int res = 0;
    for(int i=0;i<(int)pl.size();i++){
      for(int j=i;j<(int)pl.size();j++){
	int rem = t - pl[i] - pl[j];
	if(rem < pl[j])break;
	if(pl[i]+pl[j]>rem && pt[rem])res++;
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int x[N], y[M];
    REP(i, N) {
       cin >> x[i]; 
    }
    REP(i, M) {
       cin >> y[i]; 
    }

    bool flag = false;

    for (int i = X + 1; i <= Y; i++) {
        bool flag1 = true;
        REP(j, N)
        {
            if(x[j] >= i) {
                flag1 = false;
            }
        }
        bool flag2 = true;
        REP(j, M)
        {
            if(y[j] < i) {
                flag2 = false;
            }
        }
        if(flag1 && flag2) {
            flag = true;
        }
        // cout << i << endl;
    }

    cout << (flag ? "No War" : "War") << endl;
    return 0;
}

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

int main()
{
    ll n, m;
    cin >> n >> m;
    map<ll, ll> memo = {};
    ll s, c;

    for (auto i = 0; i < m; i++)
    {
        cin >> s >> c;
        if (n != 1 && s == 1 && c == 0)
        {
            cout << -1 << endl;
            return 0;
        }

        if (memo.count(s))
        {
            if (memo[s] != c)
            {
                cout << -1 << endl;
                return 0;
            }
        }
        else
        {
            memo[s] = c;
        }
    }

    ll ans = 0;
    for (auto i = 0; i < n; i++)
    {
        ll digit = 0;
        if (memo.count(i + 1))
        {
            digit = memo[i + 1];
        }
        else
        {
            if (n == 1)
            {
                digit = 0;
            }
            else if (i == 0)
            {
                digit = 1;
            }
        }
        ans += ll(pow(10, n - i - 1)) * digit;
    }

    // 例外として1桁0のときは正解とする
    if (ans == 0 && n == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    if (ans >= ll(pow(10, n)) || ans < ll(pow(10, n - 1)))
    {
        cout << -1 << endl;
        return 0;
    }

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


Measured memory_bytes: 384
import math
l = input().split()
x1 = float(l[0])
y1 = float(l[1])
x2 = float(l[2])
y2 = float(l[3])

a = pow((x2 - x1), 2) + pow((y2 - y1), 2)
ans = math.sqrt(a)
print(ans)

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

int n, m;
vector<int> x;
vector<int> diffArray;

int minusToPuls(int a) {
  if(a < 0) return -a;
  else return a;
}

void arrayDifferenceCalc() {
  for(int i = 0; i < m-1; i++) {
    diffArray.push_back(minusToPuls(x[i] - x[i+1]));
  }
}

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

  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int a;
    cin >> a;
    x.push_back(a);
  }

  if(n >= m) {
    cout << 0 << endl;
    return 0;
  }

  sort(x.begin(), x.end());

  int moveCount = 0;
  if(n == 1) {
    cout << -x[0] + x[m-1] << endl;
  } else {
    arrayDifferenceCalc();
    sort(diffArray.begin(), diffArray.end());
    for(int i = 0; i < m-n; i++) moveCount += diffArray[i];
    cout << moveCount << endl;
  }
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B;
    cin >> A >> B;
    if ((A + B) % 2 == 0)
    {
        cout << (A + B) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    string s;
    cin>>s;
    n--;
    char last = s[s.length() - 1];
    map<string, int> mp;
    mp[s]++;
    int i = 0;
    while(n--)
    {
        i++;
        cin>>s;
        if(s[0] == last && mp.find(s) == mp.end())
        {
            mp[s]++;
            last = s[s.length() - 1];
        }
        else {
            //cout<<i<<endl;
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
using std::swap;


int main() {
	string S;
	cin >> S;
	for (int i = 0; i < 4; ++i) {
		int t = 0;
		for (int j = 0; j < 4; ++j) {
			if (S.substr(i, 1) == S.substr(j, 1))++t;
		}
		if (t != 2) {
			cout << "No" << "\n";
			return 0;
		}
	}
	cout << "Yes" << "\n";
	return 0;
}

Measured memory_bytes: 256
// atcoder/abc044/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    map<char, int> m;
    each (c, s) ++m[c];
    bool f = true;
    each (i, m) f = f && (i.second % 2 == 0);
    cout << (f ? "Yes" : "No") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
from collections import deque


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

min_dist = -1
seen = set()
q = deque()
q.append((0, 0, 0))  # (i, j, dist)
while len(q) > 0:
    i, j, dist = q.popleft()
    if i == H - 1 and j == W - 1:
        min_dist = dist
        break
    if i > 0 and S[i - 1][j] == '.' and (i - 1, j) not in seen:
        seen.add((i - 1, j))
        q.append((i - 1, j, dist + 1))
    if j > 0 and S[i][j - 1] == '.' and (i, j - 1) not in seen:
        seen.add((i, j - 1))
        q.append((i, j - 1, dist + 1))
    if i < H - 1 and S[i + 1][j] == '.' and (i + 1, j) not in seen:
        seen.add((i + 1, j))
        q.append((i + 1, j, dist + 1))
    if j < W - 1 and S[i][j + 1] == '.' and (i, j + 1) not in seen:
        seen.add((i, j + 1))
        q.append((i, j + 1, dist + 1))

if min_dist == -1:
    print(-1)
else:
    b = 0
    for r in S:
        for c in r:
            if c == '#':
                b += 1
    print(H * W - min_dist - b - 1)

Measured memory_bytes: 3700
<?php

$n = (int)trim(fgets(STDIN));
$a_list=[];
for ($i=1; $i <= $n; $i++) { 
	$a = (int)trim(fgets(STDIN));
	if (isset($a_list[$a])) {
		$a_list[$a] += 1;
	}else{
		$a_list[$a] = 1;
	}
}

$sum = 0;
foreach ($a_list as $v) {
	if ($v % 2 === 1) {
		$sum += 1;
	}
}
echo $sum;

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	if(w>=v){
		cout << "NO" << endl;
		return 0;
	}
	if(abs(v-w)*t < abs(a-b)){
		cout << "NO" << endl;
	} else{
		cout << "YES" << endl;
	}

	return 0;
}


Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,h,m;
	cin>>A>>B>>h>>m;
	cout.precision(10);
	cout<<fixed;
	double c = A;
	double b = B;
	double i = 1.0*(h+1.0*m/60)/12*360;
	double j = 1.0*m/60*360;
	double tmp = (i>j?i-j:j-i);
	double ans = sqrt(b*b+c*c-2.0*b*c*cos(tmp*M_PI/180));
	cout<<ans;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

map<llong, int> PrimeFact(llong n){
	map<llong, int> ret;
	while(n % 2 == 0){
		ret[2]++;
		n /= 2;
	}
	for(llong i = 3; i*i <= n; i += 2){
		while(n%i == 0){
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1)
	ret[n]++;

	return ret;
}

int main() {
	llong X;
	cin >> X;

	while (true) {
		auto m = PrimeFact(X);
		if (m.size() == 1 && m.begin()->second == 1) {
			cout << X << endl;
			break;
		}
		else {
			++X;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <map>

using namespace std;


const int INF = 1000000;
const int nmax = 50;
const int abmax = 10;
int dp[nmax][nmax*abmax][nmax*abmax];

int main(){

    int N , Ma , Mb;
    cin >> N >> Ma >> Mb;

    int a[50] , b[50] , c[50];
    for(int i = 0 ; i < N ; i++){
        cin >> a[i] >> b[i] >> c[i];
    }



    for(int ii = 0 ; ii < 50 ; ii ++){
        for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
            for (int bi = 0; bi < nmax*abmax ; bi++) {

                dp[ii][ai][bi] = INF;
            }
        }
    }

    dp[0][0][0] = 0;


    for(int ii = 0 ; ii < N ; ii ++){
        for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
            for (int bi = 0; bi < nmax*abmax ; bi++) {
                if(dp[ii][ai][bi] == INF) continue;
                dp[ii+1][ai][bi] = min(dp[ii][ai][bi] , dp[ii+1][ai][bi]);
                dp[ii+1][ai+a[ii]][bi+b[ii]] = min(dp[ii+1][ai+a[ii]][bi+b[ii]] , dp[ii][ai][bi]+c[ii]);
            }
        }
    }


    int res = INF;
    for(int ma = 1 ; ma <= nmax*abmax ; ma ++) {
        for (int mb = 1; mb <= nmax*abmax; mb++) {
            if(ma*Mb == Ma*mb){
                res = min(res , dp[N][ma][mb]);
            }
        }
    }

    if(res == INF) cout << -1 << endl;
    else cout << res << endl;
}




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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

const int mod = 1e9 +7;
int main()
{
	string s;
	cin >> s;
	
	int n = s.size();
	vector<int> d(n+1);
	d[0] = 0;

	int ten = 1;
	rep(i,n){
		int now = s[n-1-i] - '0';
		d[i+1] = (d[i] + now * ten) % 2019;
		ten *= 10;
		ten %= 2019;
	}

	vector<int> cnt(2019,0);
	ll ans = 0;
	rep(i,n+1){
		int now = d[i];
		ans += cnt[now];
		cnt[now]++;
	}
	cout << ans << endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    string S;
    cin >> S;
    if(S.size() == 3){
        reverse(S.begin(),S.end());
        cout << S << endl;
    } else {
        cout << S << endl;
    }
}

Measured memory_bytes: 3576
N = int(input())
p = input().split()
p = [int(num) for num in p]
q = sorted(p)
if p == q:
  print("YES")
else:
  t = 0
  for i in range(N):
    if p[i] != q[i]:
      t += 1
      #print(p[i],q[i],t)
    else:
      continue
  if t == 2:
    print("YES")
  else:
    print("NO")

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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<ll, ll> Pair;
typedef vector<Pair> VP;

#define MOD 1000000007
#define times(n) rep(_idx, n)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define in(a, l, r) (l <= a && a < r)
#define pb push_back
#define mk make_pair
#define out(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;

template<typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}


int main() {
    int N; cin >> N;
    VL d;
    d.resize(N);
    rep(i, N) {
        ll D; cin >> D;
        if(i == 0 && D != 0) { out(0); return 0; }
        d[D]++;
    }
    if(d[0] != 1) { out(0); return 0; }

    ll mod = 998244353;
    ll ans = 1;
    REP(i, 1, N) {
        times(d[i]) {
            ans *= d[i - 1];
            ans %= mod;
        }
    }
    out(ans % mod);
    return 0;
}

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

using namespace std;

ifstream fi("JJOOII.INP");
ofstream fo("JJOOII.OUT");

#define fi cin
#define fo cout

string S;
int demJ,demO,demI,res;

void xuli()
{
    int i=0;
    while (1)
    {
        while (S[i]=='J') ++i,++demJ;
        while (S[i]=='O') ++i,++demO;
        while (S[i]=='I') ++i,++demI;
        if (demJ>=demO && demI>=demO) res=max(res,demO);
        demJ=demO=demI=0;
        if (S[i]=='@') return;
    }
}

int main()
{
    fi>>S;
    S+='@';
    xuli();
    fo<<res<<'\n';
}

Measured memory_bytes: 2080
# -*- coding: utf-8 -*-
"""
Created on Sun Feb  2 17:14:11 2020

@author: masat
"""
import math

X = int(input())
i = X

if i == 2:
    pass
else:
    i_is_prime = True
    while True:
        for k in range(2, math.ceil(math.sqrt(i))+1):
            if i%k == 0:
                i_is_prime = False
                break
            else:
                pass
        if i_is_prime:
            break
        else:
            i_is_prime = True
            i += 1

print(i)



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

int main(){

    int lh,lw;cin >> lh >> lw;
    int h,w;cin >> h >> w;

    int sum = lh*lw;
    sum -= lh*w+lw*h;
    //重なり
    sum += h*w;

    cout << sum << endl;

    return 0;

}


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

int main(){
  int n, c = 0, s, k;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s >> k;
    if(s == k){
      c++;
    }
    else{
      c = 0;
    }
    if(c == 3){
      break;
    }
  }
  if(c == 3){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

LL dp[110][5][2] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    string S; cin >> S;
    int K; cin >> K;
    int len = S.length();
    dp[0][0][0] = 1;
    REP(i,len) REP(j,K+1) REP(k,2){
        int nd = S[i] - '0';
        REP(d,10){
            int ni = i+1, nj = j,nk = k;
            if(d != 0) nj++;
            if(nj > K) continue;
            if(k == 0){
                if(d > nd) continue;
                if(d < nd)  nk = 1;
            }

            dp[ni][nj][nk] += dp[i][j][k];
        }
    }

    LL ans = dp[len][K][0] + dp[len][K][1];
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <cstring>

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

const int MAX_N = 300;
const int MAX_M = 300;
int cost[MAX_N];
int value[3][MAX_N];

int cache[3][MAX_N][MAX_M + 1];

int solve(const int param, int i, int m) {
    if(i == -1) return 0;
    if(cache[param][i][m] != -1) return cache[param][i][m];
    int res = 0;
    res = max(res, solve(param, i - 1, m));
    if(m >= cost[i]) res = max(res, solve(param, i, m - cost[i]) + value[param][i]);
    return cache[param][i][m] = res;
}

int main() {
    for(int N, M; cin >> N >> M; ) {
        for(int i = 0; i < N; i++) {
            string dummy;
            cin.ignore();
            getline(cin, dummy);
            cin >> cost[i] >> value[0][i] >> value[1][i] >> value[2][i];
        }
        memset(cache, -1, sizeof(cache));
        solve(0, N - 1, M);
        solve(1, N - 1, M);
        solve(2, N - 1, M);
        int ans = 0;
        ans = max(ans, *max_element(cache[0][N - 1], cache[0][N - 1] + M + 1));
        ans = max(ans, *max_element(cache[1][N - 1], cache[1][N - 1] + M + 1));
        ans = max(ans, *max_element(cache[2][N - 1], cache[2][N - 1] + M + 1));
        cout << ans << endl;
    }
}

Measured memory_bytes: 2320