akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

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

    int pt = 0, px = 0, py = 0;
    int t, x, y;
    REP(i, N) {
        std::cin >> t >> x >> y;
        int dt = t - pt;
        int mandis = std::abs(x - px) + std::abs(y - py);

        if(dt < mandis) {
            std::cout << "No" << std::endl;
            return 0;
        } else if(dt == mandis) {
            continue;
        } else if( (dt-mandis) % 2 != 0){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}

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


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    red = [[a[i], b[i], False] for i in range(N)]
    blue = [[c[i], d[i], False] for i in range(N)]

    red.sort(key=lambda x: x[0], reverse=True)
    blue.sort(key=lambda x: x[0])

    # print(red)
    # print(blue)
    ans = 0

    for b in blue:
        cand = [i for i, r in enumerate(red) if r[0] < b[0] and r[1] < b[1]]
        # fix
        if len(cand) > 0:
            ans += 1
            i = max(cand, key=lambda i: red[i][1])
            red.pop(i)
    print(ans)

    # flag = True
    # while flag:
    #     flag = False
    #     for i in range(N):
    #         if red[i][2] == True:
    #             continue
    #         cand = []
    #         counter = 0
    #         for j in range(N):
    #             if blue[j][2] == True:
    #                 continue
    #             if red[i][0] < blue[j][0] and red[i][1] < blue[j][1]:
    #                 counter += 1
    #                 cand.append(j)
    #         if counter == 1:
    #             red[i][2] = True
    #             blue[cand[0]][2] = True
    #             flag = True
    #             ans += 1
    #             print("pair ", red[cand[0]], blue[cand[0]])
    # print(ans)
    # for i in range(N):
    #     if red[i][2]:
    #         plt.scatter(red[i][0], red[i][1], color="red", marker="o")
    #     else:
    #         plt.scatter(red[i][0], red[i][1], color="orange", marker="o")
    # for i in range(N):
    #     if blue[i][2]:
    #         plt.scatter(blue[i][0], blue[i][1], color="blue", marker="o")
    #     else:
    #         plt.scatter(blue[i][0], blue[i][1], color="navy", marker="o")
    # plt.show()
    # return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [int()] * (N)  # type: "List[int]"
    d = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, a, b, c, d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

struct WeightedUnionFind {
    vector<int> d;
    vector<int> diff_weight;
    WeightedUnionFind(int n=0) : d(n, -1), diff_weight(n, 0) {}

    int find(int x) {
        if (d[x] < 0) return x;
        int root = find(d[x]);
        diff_weight[x] += diff_weight[d[x]];
        return d[x] = root;
    }
    
    int weight(int x) {
        find(x);
        return diff_weight[x];
    }

    int diff(int x, int y) { return diff_weight[y] - diff_weight[x];}

    // weight(y) - weight(x) = w
    bool unite(int x, int y, int w) {
        w += weight(x);
        w -= weight(y);
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) {
            swap(x, y);
            w = -w;
        }
        d[x] += d[y];
        d[y] = x;
        diff_weight[y] = w;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    WeightedUnionFind wuf(n);
    rep(i, m) {
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        if (wuf.same(l, r)) {
            if (wuf.diff(l, r) != d) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            wuf.unite(l, r, d);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1024
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

l,r,d = MAP()

if(l%d==0):

    print(r//d-l//d+1)
else:
    print(r // d - l // d)

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




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int r, g, b, n, ans = 0;
    cin >> r >> g >> b >> n;
    for(int i = 0; i * r <= n; i++){
        for(int j = 0; i * r + j * g <= n; j++){
            int k = n - (i * r + j * g);
            if(k % b == 0){
                ans += 1;
            }
        }
    }
    cout << ans;
}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int k;
set<long long> res;
int lunlun(long long x){
    int good = 1;
    int last = -1;
    while(x > 0){
        if(last != -1){
            good &= (abs((x % 10) - last) <= 1);
        }
        last = (x % 10);
        x /= 10;
    }
    return good;
}
void rec(long long x){
    if(x > 3234566668){
        return;
    }
    if(res.find(x) != res.end()){
        return;
    }
    res.insert(x);
    for(int i = -1; i <= 1; i ++){
        if((x % 10) + i >= 0 && ((x % 10) + i) <= 9){
            rec(x * 10 + (x % 10) + i);
        }
    }
}
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> k;
    for(int i = 1; i <= 9; i ++){
        rec((long long)i);
    }
    assert(k <= (int)res.size());
    while(-- k > 0){
        res.erase(res.begin());
    }
    cout << *res.begin() << "\n";
}


Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int a,p;
    cin >> a >> p;
    cout << ((a*3)+p)/2 << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  int K;
  cin >> s >> K;
  int sz = s.size();
  map<string, int> mp;
  vector<string> v;
  for (int i = 0; i < sz; i++) {
    for (int j = 1; i + j <= sz && j <= K; j++) {
      string t = s.substr(i, j);
      if (mp[t]) continue;
      mp[t]++;
      v.emplace_back(t);
    }
  }
  sort(v.begin(), v.end());
  cout << v[K - 1] << endl;

  return 0;
}

Measured memory_bytes: 2048
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let mut v: Vec<i32> = read_vec();
    v.sort();
    println!("{} {} {}", v[0], v[1], v[2]);
}


Measured memory_bytes: 5028
#include <fstream>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <cassert>
#include <deque>
#include <set>
#include <map>
#include <vector>

using namespace std;

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

string a[8];

//#define LOCAL_DEBUG
int main() {
#ifdef LOCAL_DEBUG
	freopen("input.txt","r", stdin);
#endif
	int H, W;
	cin >> H >> W;

	int scnt = 0;
	for (int i = 0; i < H; i++) {
		cin >> a[i];
		for (int j = 0; j < W; j++)
			if (a[i][j] == '#') scnt++;
	}

	int x, y;
	x = y = 0;

	int cnt = 1;
	while (true) {
		if (x == W - 1 && y == H - 1) {
			if (scnt == cnt)
				cout << "Possible" << endl;
			else
				cout << "Impossible" << endl;
			break;
		}
		if (x + 1 < W && a[y][x  + 1] == '#') {
			x++;
			cnt++;
			continue;
		}
		if (y + 1 < H && a[y + 1][x] == '#') {
			y++;
			cnt++;
			continue;
		}
		cout << "Impossible" << endl;
		break;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
  int a, b, c, x;
  int count = 0;

  std::cin >> a >> b >> c;
  x = a;
  if(a > b) return 0;
  if(!(1 <= a && a <= 10000)) return 0;
  if(!(1 <= b && b <= 10000)) return 0;
  if(!(1 <= c && c <= 10000)) return 0;

   while(x <= b) {
       if((c % x) == 0) count++;
       x++;
   }

    std::cout << count << std::endl;

    return 0;
   
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 A, B, C, K;
  cin >> A >> B >> C >> K;
  i64 cnt = 0;
  while(A >= B) {
    cnt++;
    B *= 2;
  }
  while(B >= C) {
    cnt++;
    C *= 2;
  }
  if(cnt <= K) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

// バケット法を用いる
signed main() {
  string s; cin >> s;
  int backet[26] = {0};

  bool ans = true;
  for(int i = 0; i < s.size(); i++) {
    backet[s.at(i) - 'a']++;
    if(backet[s.at(i) - 'a'] >= 2) {
      ans = false;
      break;
    }
  }
  cout << (ans ? "yes" : "no") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8101145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n,x; cin>>n>>x;
    long long a[n]; rep(i,n) cin>>a[i];
    sort(a,a+n);
    int cnt=0;
    rep(i,n){
        x-=a[i];
        if(x>=0) cnt++;
    }
    if(x>0) cnt--;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <assert.h>
#include <string>
#include <set>
#include <map>
using namespace std;
#define LL long long

int n,p;

int main(){

	cin >> n >> p;
	p += n * 3;
	printf("%d\n",p/2);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[100];
int main(){
	scanf("%s",str);
	int cnt=0;
	for(int i=0;str[i];i++){
		if(str[i]=='A'&&cnt%2==0)cnt++;
		if(str[i]=='Z'&&cnt%2)cnt++;
	}
	cnt-=cnt%2;
	if(cnt==0)printf("-1\n");
	else{
		for(int i=0;i<cnt/2;i++)printf("AZ");
		printf("\n");
	}
}

Measured memory_bytes: 952
using System;
using System.Linq;

namespace abc110_b
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
			Console.WriteLine(Math.Max(x[2], a.Max()) < Math.Min(x[3], b.Min()) ? "No War" : "War");
		}
	}
}


Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
#define N 100000
#include<algorithm>
using namespace std;

int T[N+1];
int BinarySearch(int k, int n){
	int mid,left = 0, right = n;
	while(left < right){
		mid = (left + right)/2;
		if(T[mid] == k)	return 1;
		else if(T[mid] < k)	left =  mid + 1;
		else if(T[mid] > k)	right = mid;
	}
	return 0;
}
int main(){
	int n,q,t,sum = 0;
	cin>>n;
	for(int i = 0; i < n; i++){
		scanf("%d",&T[i]);
	}
	sort(T, T+n);
	cin>>q;
	for(int i = 0; i < q; i++){
		scanf("%d",&t);if(BinarySearch(t, n))	sum++;
	}
	cout<<sum<<endl;
	return 0;
}


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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  
  for (int i = a; i < b + 1; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      break;
    }
    else if (i == b) {
      cout << "NG" << endl;
    }
  }
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#define MOD 1000000007
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    string s;
    
    cin >> n >> s >> k;
    
    for(int i=0;i < n;i++){
        if(s[i]!=s[k-1]) s[i]='*';
    }
    
    cout << s << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

ll calc(vl a){
	// puta(a);
	ll ret=0;
	ll n=a.size();
	ll cnt=0;
	rep(i,n){
		if(a[i]==-1){
			ret+=i-cnt;
			cnt++;
		}
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; string ss;
	cin>>ss;
	string s = regex_replace(ss, regex("BC"), "a");
	// puta(s);
	n=s.size();
	vl a(0);
	ll ans=0;
	rep(i,n){
		if(s[i]=='A')a.push_back(1);
		else if(s[i]=='a'){
			a.push_back(-1);
		}else{
			ans+=calc(a);
			a=vl(0);
		}
	}
	if(a.size()!=0)ans+=calc(a);
	puta(ans);
	return 0;
}

Measured memory_bytes: 3848
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRng10s solver = new BRng10s();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRng10s {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            for (int i = 0; i < t; i++) {
                long a = in.nextLong();
                long b = in.nextLong();
                long c = in.nextLong();
                long d = in.nextLong();

                if (a < b || b > d) {
                    out.println("No");
                    continue;
                }

                if (c >= b) {
                    out.println("Yes");
                    continue;
                }

                long gcdBD = Euclid.gcd(b, d);
                long sub = a - ((a - b) / gcdBD + 1) * gcdBD;

                out.println(c < sub && sub < b ? "No" : "Yes");
            }
        }

    }

    static class Euclid {
        public static long gcd(long a, long b) {
            return a == 0 ? b : gcd(b % a, a);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>

using namespace std;
const int MAX = 1000000;
const int MIN = -1000000;

int main() {
    int n, a, mn = MAX, mx = MIN;
    long long s = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        mn = min(mn, a);
        mx = max(mx, a);
        s += a;
    }
    cout << mn << ' ' << mx << ' ' << s << endl;
    return 0;
}



Measured memory_bytes: 3116
#include<stdio.h>

int N[101];
int main() {
	int n,temp;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d",&temp); N[temp]++; }
	temp = 0;
	for (int i = 1; i<=100; ++i) {
		if (N[i])++temp;
	}
	printf("%d", temp);
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

//最小公倍数
int lcm(int number1,int number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main(){

string S;
cin >> S;

int f = stoi(S.substr(0,2));
int a = stoi(S.substr(2,2));

bool YYMM = false;
bool MMYY = false;

if(a > 0 && a <= 12) YYMM = true;
if(f > 0 && f <= 12) MMYY = true;

if(YYMM & MMYY) print("AMBIGUOUS");
else if(YYMM) print("YYMM");
else if(MMYY) print("MMYY");
else print("NA");

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi frist
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=200005;
int a[N],c[N],n,K;

int main(){
	read(n),read(K);
	rep(i,1,n){
		read(a[i]);
	}
	rep(k,1,K){
		memset(c,0,sizeof c);
		rep(i,1,n){
			int l=max(1,i-a[i]);
			int r=min(n,i+a[i]);
			c[l]++,c[r+1]--;
		}
		int flag=0;
		rep(i,1,n){
			c[i]+=c[i-1];
			a[i]=c[i];
			if(a[i]<n){
				flag=1;
			}
		}
		if(!flag){
			break;
		}
	}
	rep(i,1,n){
		printf("%d%c",a[i]," \n"[i==n]);
	}
	return 0;
}

Measured memory_bytes: 5316
#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;
/* ---------------------------------------------------------------------------------------------------- */



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

  int A,B;
  cin >> A >> B;
  if (A+B >= 10) {
    cout << "error" << endl;
  } else {
    cout << A+B << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll N = 1e6 + 10;
const ll mod = 1e9 + 7;

int mi_p[N];

ll binpow(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

ll inv(ll x) {
	return binpow(x, mod - 2);
}

void init() {
	for (int i = 2; i < N; i++) {
		if (mi_p[i]) continue;
		for (int j = i; j < N; j += i)
			mi_p[j] = i;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	init();
	int n; cin >> n;
	int a[n] = {};
	map<int, int> tot;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		int x = a[i];
		while (x != 1) {
			int p = mi_p[x];
			int cnt = 0;
			while (x % p == 0) x /= p, ++cnt;
			tot[p] = max(tot[p], cnt);
		}
	}
	ll L = 1;
	for (auto pr : tot) {
		L = L * binpow(pr.first, pr.second) % mod;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += L * inv(a[i]) % mod, ans %= mod;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 8016
#include <bits/stdc++.h>
#define maxn 200009
using namespace std;
bool vis[maxn];
vector<int>G[maxn];
int n,m;
void dfs(int u){
    vis[u]=1;
    for(auto v:G[u]){
        if(vis[v])
            continue;
        dfs(v);
    }
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        for(int j=1;j<=x;j++){
            int y;
            cin>>y;
            G[i].push_back(n+y);
            G[n+y].push_back(i);
        }
    }
    dfs(1);
    bool ok=1;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            ok=0;
            break;
        }
    }
    if(ok)
        printf("YES\n");
    else
        printf("NO\n");
    //system("pause");
    return 0;
}

Measured memory_bytes: 8704
import java.io.*;
import java.util.StringTokenizer;
 
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
 
    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int i = in.nextInt();
            int o = in.nextInt();
            int t = in.nextInt();
            int j = in.nextInt();
            int l = in.nextInt();
            int s = in.nextInt();
            int z = in.nextInt();
            long res = o;
            int modCnt = i%2 + j%2 + l%2;
            if (modCnt > 1 && i > 0 && j > 0 && l > 0) {
                i--; j--; l--; res+=3;
            }
            res += (i / 2) * 2;res += (j / 2) * 2;res += (l / 2) * 2;
            out.println(res);
 
        }
    }
 
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
    }
}

Measured memory_bytes: 8532
#include<iostream>
#include<string>

using namespace std;

const long long MOD=1000000007;

string s;
long long n,dp[2][110][10010]={0};

signed main(){
    cin>>s>>n;
    dp[0][0][0]=0;
    dp[1][0][0]=1;
    for(int i=0;i<s.length();++i){
        for(int j=0;j<n;++j){
            for(int k=0;k<=9;++k){
                (dp[0][(j+k)%n][i+1]+=dp[0][j][i])%=MOD;
            }
            for(int k=0;k<s[i]-'0';++k){
                (dp[0][(j+k)%n][i+1]+=dp[1][j][i])%=MOD;
            }
            (dp[1][(j+s[i]-'0')%n][i+1]+=dp[1][j][i])%=MOD;
        }
    }

    cout<<(dp[0][0][s.length()]-1+dp[1][0][s.length()]+MOD)%MOD<<endl;

    return 0;
}

Measured memory_bytes: 16640
n=int(input())
m=0
a=0
r=0
c=0
h=0
for i in range(n):
    s=input()
    if s[0]=="M":
        m+=1
    elif s[0]=="A":
        a+=1
    elif s[0]=="R":
        r+=1
    elif s[0]=="C":
        c+=1
    elif s[0]=="H":
        h+=1
ans=(m*a*r)+(m*a*c)+(m*a*h)+(m*r*c)+(m*r*h)+(m*c*h)+(a*r*c)+(a*r*h)+(a*c*h)+(r*c*h)
print(ans)


Measured memory_bytes: 9092
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int sum[2010][2010];
int dots[2010][2010];
int query(int x1, int y1, int x2, int y2) {
    if (x1 > x2 || y1 > y2) return 0;
    return sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1];
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    rep(i, N) {
        int x, y; cin >> x >> y;
        char c; cin >> c;
        if(c == 'W') x += K;
        x %= K * 2;
        y %= K * 2;
        dots[x + 1][y + 1]++;
    }
    rep(i, K * 2 + 3) {
        rep(j, K * 2 + 3) {
            sum[i + 1][j + 1] = dots[i + 1][j + 1] + sum[i][j + 1] + sum[i + 1][j] - sum[i][j];
        }
    }
    // rep(i, K * 2 + 3) {
    //     rep(j, K * 2 + 3) {
    //         cout << sum[i][j];
    //     }
    //     cout << endl;
    // }
    int ans = 0;
    REP(i, 1, K) {
        REP(j, 1, K) {
            int tmp[5] = {};
            tmp[0] = query(1, 1, i - 1, j - 1);
            tmp[1] = query(i, j, K + i - 1, K + j - 1);
            tmp[2] = query(K + i, K + j, K * 2, K * 2);
            tmp[3] = query(K + i, 1, K * 2, j - 1);
            tmp[4] = query(1, K + j, i - 1, K * 2);
            int S = 0;
            rep(k, 5) {
                S += tmp[k];
                //cout << tmp[k] << " ";
            }
            //cout << endl;
            
            ans = max(ans, S);
            ans = max(ans, N - S);
        }
    }
    cout << ans << endl;

    return 0;
}

// xxxooo
// xxxooo
// xxxooo
// oooxxx
// oooxxx
// oooxxx


// oxxxoo
// oxxxoo (K * 2, K * 2) - (K + 1, K + 1)
// xoooxx (K * 2, j) - (K + 1, 0)
// xoooxx (i, K * 2) - (i, K + j)
// xoooxx (4, 4) - (0, 0)
// oxxxoo (1, 1)


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int count(vector<int> V) {
    int s = V.size();
    int m = -1;
    rep(i, s) {
        chmax(m, V[i]);
        V[i]++;
    }
    if(m < s) return 0;
    rep(i, s) {
        if(V[i] == m + 1) {
            V[i] -= (s + 1);
            break;
        }
    }
    return count(V) + 1;
}
signed main() {
    int K;
    cin >> K;
    vector<int> Ans(50);
    int m = K % 50;
    rep(i, m) Ans[i] = 50;
    for(int i = 49; 49 - i < (50 - m); i--) Ans[i] = 49 - i;
    rep(i, 50) Ans[i] += (K / 50);
    cout << 50 << endl;
    for(auto x : Ans) cout << x << ' ';
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c;
  cin>>a>>b>>c;
  if((c-a-b)>0)
  {
     long long p=(c-a-b)*(c-a-b);
      if(4*a*b<p)
              cout<<"Yes"<<endl;
      else
              cout<<"No"<<endl;
  }
  else
          cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<p> array;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        array.push_back(p(a, b));
    }
    sort(array.begin(), array.end());
    ll ans = 0, sum = 0;
    while(sum < k){
        sum += array[ans].second;
        ans++;
    }
    cout << array[ans - 1].first << endl;
}


Measured memory_bytes: 4316
n,m = map(int,input().split())
cnt = [0]*n
for _ in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    cnt[a]+=1
    cnt[b]+=1
for i in range(n):
    if cnt[i]&1:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 9600
//A.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  long long N, M;
  cin >> N >> M;
  long long Ans;
  if(N!=1&&M!=1){
    Ans = (N-2)*(M-2);
  }else if(N==1&&M!=1){
    Ans = M - 2;
  }else if(N!=1&&M==1){
    Ans = N - 2;
  }else{
    Ans = 1;
  }

  printf("%lld\n",Ans);
  return 0;
}


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

using namespace std;

#define mx 1000006
bitset<mx>mark;
vector<int> primes;

void sieve() {
    mark [0] = mark[1] = 1;
    primes.push_back(2);
    int lim = sqrt(mx * 1.0) + 2;
    for (int i = 4; i < mx; i = i + 2) {
        mark[i] = 1;
    }
    for (int i = 3;  i < mx; i = i + 2) {
        if(!mark[i]) {
            primes.push_back(i);
            if(i <= lim) {
                for(int j = i * i; j < mx; j = j + i) {
                    mark[j] = 1;
                }
            }
        }
    }

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

    for (int i = n; i < mx; i++) {
        if(!mark[i]) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1148
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<string> S(N);
    for (auto& s : S) {
        cin >> s;
    }
    vector<P> pos, neg;
    for (auto& s : S) {
        string now;
        for (auto& c : s) {
            if (now.empty()) {
                now += c;
            } else {
                if (now.back() == '(' && c == ')') {
                    now.pop_back();
                } else {
                    now += c;
                }
            }
        }
        int A = 0, B = 0;
        for (auto& c : now) {
            if (c == ')') {
                ++A;
            } else {
                ++B;
            }
        }
        if (B - A >= 0) {
            pos.emplace_back(A, B);
        } else {
            neg.emplace_back(A, B);
        }
    }
    sort(all(pos), [](P a, P b) {
        return a.first < b.first;
    });
    int cumsum = 0;
    for (auto& p : pos) {
        cumsum -= p.first;
        if (cumsum < 0) {
            cout << "No" << endl;
            return 0;
        }
        cumsum += p.second;
    }
    sort(all(neg), [](P a, P b) {
        return a.second > b.second;
    });
    for (auto& p : neg) {
        cumsum -= p.first;
        if (cumsum < 0) {
            cout << "No" << endl;
            return 0;
        }
        cumsum += p.second;
    }
    if (cumsum) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 42480
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    string s;
    cin>>s;
    set<char> st;
    rep(i,3) st.insert(s[i]);
    if(st.size()==3) cout<<"Yes";
    else cout<<"No";
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
*/

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

    ans = 0

    for a in A:
        ans += B[a-1]

    tmp = A[0]
    for i in range(1, N):
        if A[i] - tmp == 1:
            ans += C[tmp-1]
        tmp = A[i]
    print(ans)


if __name__ == '__main__':
    main()

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

int main(){
    int x ,t;
    cin >> x >> t;

    for(int i=0; i < t; i++){
        x -= 1;
    }

    if(x > 0) cout << x << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 384
N, M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]

tmp = [0]*(M+1)
for a in A:
  for aa in a[1:]:
    tmp[aa] += 1
ans = 0
for t in tmp:
  if t == N:
    ans += 1
print(ans)

Measured memory_bytes: 3064
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let (n, m) = input!(i64, i64);
    let modulo = 1000000007;

    if (n - m).abs() > 1 {
        println!("0");
        return;
    } else if (n - m).abs() == 1 {
        let n_factorial = (1..n+1).fold(1, |acc, x| (acc * x) % modulo);
        let m_factorial = (1..m+1).fold(1, |acc, x| (acc * x) % modulo);
        println!("{}", (n_factorial * m_factorial) % modulo);
    } else {
        let n_factorial = (1..n+1).fold(1, |acc, x| (acc * x) % modulo);
        let m_factorial = (1..m+1).fold(1, |acc, x| (acc * x) % modulo);
        println!("{}", 2 * ((n_factorial * m_factorial) % modulo) % modulo);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAX = 1e18;

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    if (a == 0) {
      ans = 0;
      break;
    }
    if (ans == -1) continue;
    //cout << MAX << " " << a << " " << ans << endl;
    if (MAX / a < ans) {
      ans = -1;
    } else {
      ans *= a;
    }
    if (ans > MAX) {
      ans = -1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	count := readInt()
	list := make([]int, count)

	Loop(0, count, func(i int) {
		list[i] = readInt()
	})

	sort.Ints(list)

	previous := list[0]
	Loop(1, count, func(i int) {
		if previous == list[i] {
			fmt.Println("NO")
			os.Exit(0)
		}
		previous = list[i]
	})

	fmt.Println("YES")
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func readInt() int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

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

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;

    cout << c <<" "<< a << " " << b << endl;
}

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

    solve();
    return 0;
}
 


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

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
//global-----------------------------------------------------------------------------------------------------------------------
int n, m, a, o, ans;
int dp[ 101 ][ 101 ][ 3 ][ 2 ];
//#define DEBUG
//function-------------------------------------------------------------------------------------------------------------------
int solve(int a, int b, bool d, bool c) {
	if ( a >= n || b >= m ) {
		return 0;
	}
	if ( dp[ a ][ b ][ d ][ c ] >= 0 ) {
		return dp[ a ][ b ][ d ][ c ];
	}
	int res;
	if ( a == n - 1 && b == m - 1) {
		res = 1;
	}
	else if ( a == 0 && b == 0 ) {
		res = ( solve( a + 1, b, true, true ) + solve( a, b + 1, false, true ) ) % 100000;
	}
	else if ( d ) {
		res = solve( a + 1, b, true, true ) % 100000;
		if ( c ) {
			res += solve( a, b + 1, false, !c );
			res %= 100000;
		}
	}
	else if ( !d ) {
		res = solve( a, b + 1, false, true ) % 100000;
		if ( c ) {
			res += solve( a + 1, b, true, !c );
			res %= 100000;
		}
	}
	return dp[ a ][ b ][ d ][ c ] = res;
}
int main() {
	while ( scanf( "%d %d", &n, &m ) != EOF && n && m ) {
		memset( dp, -1, sizeof( dp ) );
		ans = solve( 0, 0, 0, true ) % 100000;
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1448
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        long d = (long) 4 * a * b;
        long e = (long) (c - a - b) * (c - a - b);

        if (d < e && (long) (c - a - b) >= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 21972
from collections import Counter


def solve(n, ds):
    if n >= 24:
        return 0
    freq = Counter(ds)
    if (0 in freq) or (freq[12] >= 2) or max(freq.values()) >= 3:
        return 0
    up_low = [0, 0]
    switch = 0
    ans = 25
    for d, s in sorted(freq.items()):
        if s == 2:
            ans = min(ans, d - up_low[0], d - up_low[1])
            up_low[0] = up_low[1] = d
        else:
            ans = min(ans, d - up_low[switch])
            up_low[switch] = d
            switch ^= 1
    ans = min(ans, 24 - sum(up_low))
    return ans


print(solve(int(input()), list(map(int, input().split()))))


Measured memory_bytes: 3444