akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll dx[8]={0,1,0,-1,1,1,-1,-1};
ll dy[8]={1,0,-1,0,1,-1,1,-1};
vll dp(100010);
ll rec(ll i,vvll &t){
  if(dp[i]!=-1) return dp[i];
  ll res=0;
  for(auto nv:t[i]){
    chmax(res,rec(nv,t)+1);
  }
  return dp[i]=res;
}
int main(){
  ll n,m;
  cin>>n>>m;
  vvll t(n,vll(0));
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    t[a].pb(b);
  }
  rep(i,n) dp[i]=-1;
  ll ans=0;
  rep(i,n){
    chmax(ans,rec(i,t));
  }
  COUT(ans);
}


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

const int INF = 1<<30;

// 本当に最悪な場合 2.8e8
// ちゃんとした高速化の方法がありそうだけどわからない

int main(){
    int n, k;
    while(cin >> n >> k, n+k){
        vector<int> v[n];
        vector<vector<int>> dist(n, vector<int>(n, 0));

        int a, b, c, d;
        for(int i = 0; i < k; i++){
            cin >> a >> b >> c; b--, c--;
            if(a == 0){
                vector<int> dp(n, INF);
                dp[b] = 0;
                priority_queue<pair<int,int>> pq;
                pq.push({-0, b});
                while(!pq.empty()){
                    auto p = pq.top();  pq.pop();
                    int cost = -p.first, pos = p.second;
                    if(dp[pos] != cost)  continue;
                    if(pos == c)    break;
                    for(int next : v[pos]){
                        int ncost = cost + dist[pos][next];
                        if(dp[next] > ncost){
                            dp[next] = ncost;
                            pq.push({-ncost, next});
                        }
                    }
                }
                cout << (dp[c] == INF ? -1 : dp[c]) << endl;
            }else{
                cin >> d;
                if(dist[b][c] == 0){
                    dist[b][c] = dist[c][b] = d;
                    v[b].push_back(c);
                    v[c].push_back(b);
                }else if(dist[b][c] > d){
                    dist[b][c] = dist[c][b] = d;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3120
import sys
from collections import namedtuple

# 完答 + 最大1種類の問題が半端に解けている状態のとき最適
# 1. 完投する問題を全探索する 2^10
# 2. 残りの問題から配点が一番高い問題を目標に達するまで解く
# 3. 1,2の中で最も回答問題数が少ないケースが答え

Problem = namedtuple('Problem', 'score number bonus')                      

D, G = map(int, input().split())

problems = []

for i in range(D):
  p, c = map(int, input().split())
  problems.append(
    Problem(
      score = (i + 1) * 100,
      number = p,
      bonus = c
    )
  )

min_num_solved = sys.maxsize
  
for m in range(1 << D):
  score = 0
  num_solved = 0
  partial = None  # 部分的に解く問題
  
  for i, p in enumerate(problems):
    if 1 << i & m:
      # 完答
      score += p.score * p.number + p.bonus
      num_solved += p.number
    else:
      partial = p

  # 中途半端に解かなくてもいいのなら次へ
  if score >= G:
    min_num_solved = min(min_num_solved, num_solved)
    continue
    
  if partial is None:
    raise Exception('全問題完答したのに目標に届かない')
         
  # 中途半端に解く
  extra_num_solved = 0
    
  while extra_num_solved <= partial.number:
    if score >= G:
      min_num_solved = min(
        min_num_solved,
        num_solved + extra_num_solved
      )
      break
    score += partial.score
    extra_num_solved += 1 
          
print(min_num_solved)

Measured memory_bytes: 3444
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
// #include <fstream>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define SIZE(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define LB(c,x) lower_bound(ALL(c),x)
#define UB(c,x) upper_bound(ALL(c),x)
#define COUNT(c,x) (int)(UB(c,x)-LB(c,x))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

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

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


signed main()
{
  // string filename; cin >> filename;
  // ifstream in(filename);
  // cin.rdbuf(in.rdbuf());

  int N; cin >> N;
  vector<int> A(N);
  rep(i, 0, N) {
    cin >> A[i];
  }

  SORT(A);
  vector<int> p;
  p.push_back(0);
  p.push_back(0);
  rep(i, 0, SIZE(A)-1) {
    if (A[i] == A[i+1]) {
      p.push_back(A[i]);
      i++;
    }
  }

  cout << p[SIZE(p)-2] * p[SIZE(p)-1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<u64>();
    let (n, m) = (v[0], v[1]);
    let ans = (m * 1900 + (n - m) * 100) * 2u64.pow(m as u32);
    println!("{}", ans);
}

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()
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a) for(int i=0;i<a;i++)
int ans;	int n,m;
int icedate[100][100];
int mapdate[100][100];//shokika!
int search(int x,int y,int poyo){
	if(icedate[x][y]!=0 and mapdate[x][y]==0){
	mapdate[x][y]++;
	if(ans<poyo){ans=poyo;}
	if(x+1<m){poyo++;search(x+1,y,poyo);poyo--;}
	if(x-1>=0){poyo++;search(x-1,y,poyo);poyo--;}
	if(y+1<n){poyo++;search(x,y+1,poyo);poyo--;}
	if(y-1>=0){poyo++;search(x,y-1,poyo);poyo--;}
	mapdate[x][y]--;
	}
}


int main(){
while(1){
ans=0;
	cin>>n>>m;
if(n==0 and m==0){break;}
FOR(i,100){FOR(j,100){icedate[i][j]=0;mapdate[i][j]=0;}}
	FOR(i,m){
		FOR(j,n){
			cin>>icedate[i][j];
		}
	}
	FOR(i,m){
		FOR(j,n){
			search(i,j,1);
		}
	}
	cout<<ans<<endl;
	}
}

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

#define FOR(i,a,b) for(int i = (a); i< (b); i++)
#define REP(i,n) FOR(i,0,n)
#define endl '\n'
#define ll long long

using namespace std;

ll sol = 0;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll s,c;
    cin>>s>>c;
    sol = min(s,c/2);
    s-=sol;
    c-=2*sol;
    if(s>0){
        cout<<sol;
    }
    else{
        sol+=c/4;
        cout<<sol;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << x << endl;
typedef long long ll;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    ll x; //
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};
int main()
{
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1 >> S2;

    mint ans;
    bool pre_is_tate = (S1[0] == S2[0]);
    if (pre_is_tate)
    {
        ans = 3;
    }
    else
    {
        ans = 6;
    }

    rep(i, N - 1)
    {
        bool is_tate = (S1[i + 1] == S2[i + 1]);
        if (i == 0 && S1[0] == S1[1])
            continue;
        if (!is_tate)
            i++;
        if (is_tate && pre_is_tate)
            ans *= 2;
        else if (!is_tate && pre_is_tate)
            ans *= 2;
        else if (is_tate && !pre_is_tate)
            ans *= 1;
        else if (!is_tate && !pre_is_tate)
            ans *= 3;
        pre_is_tate = is_tate;
    }

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

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
using namespace std;

int main() {
  string s;
  cin >> s;
  const auto size = s.size();
  vector<int> changed = {0, 0};
  REP(i, size)
  (s[i] != (i % 2 == 0 ? '0' : '1') ? changed[0] : changed[1])++;

  cout << min(changed[0], changed[1]) << endl;
  return 0;
}


Measured memory_bytes: 3784
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    M=I()
    print(24-M+24)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>    //to use max or min function for 3 or more numbers
using namespace std;

int main(){
    int v1, v2, v3, v4, v5, d;
    //cout << "Enter 5 numbers and distance" << endl;
    cin >> v1 >> v2 >> v3 >> v4 >> v5 >> d;

    if (max({v1, v2, v3, v4, v5}) > 123 || min({v1, v2, v3, v4, v5}) < 0){
        //cout << "The numbers entered are out of range." << endl;
        exit(0);
    }
    if (!(v1 < v2 && v2 < v3 && v3 < v4 && v4 < v5)){
        //cout << "Enter 5 numbers in ascending order." << endl;
        exit(0);
    }

    if (max({v2 - v1, v3 - v2, v4 - v3, v5 - v4, v3 - v1, v4 - v1, v5 - v1, v4 - v2, v5 - v2, v5 - v3}) > d){
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int d, g; cin>>d>>g;
    vector<int> p(d), c(d);
    for(int i=0; i<d; i++) cin>>p[i]>>c[i];

    int ans = inf;
    for(int bit=0; bit<(1<<d); bit++){
        int score = 0;
        int cnt = 0;
        for(int i=0; i<d; i++){
            if(bit & (1 << i)){
                score += 100 * (i + 1) * p[i] + c[i];
                cnt += p[i];
            }
        }

        if(score < g){
            for(int i=d-1; i>=0; i--){
                if(!(bit & (1 << i))){
                    for(int j=1; j<=p[i]; j++){
                        score += 100 * (i + 1);
                        cnt++;
                        if(g <= score) break;
                    }
                    break;
                }
            }
        }

        if(g <= score) chmin(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long a,b,c;
	cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << 0 << endl;
	else
		cout << min(min(a*b,a*c),b*c) << endl;
	return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
int N;
vi x;
vi y;
vector<char> d;
double cal(double t){
    double xmin=1e12;
    double xmax=-1e12;
    double ymax=-1e12;
    double ymin=1e12;
    for(int i=0;i<N;i++){
        double cx=x[i];
        double cy=y[i];
        if(d[i]=='L'){
            cx=cx-t;
        }else if(d[i]=='R'){
            cx=cx+t;
        }else if(d[i]=='U'){
            cy=cy+t;
        }else{
            cy=cy-t;
        }
        xmin=min(xmin,cx);
        xmax=max(xmax,cx);
        ymin=min(ymin,cy);
        ymax=max(ymax,cy);
    }
    double ans=(xmax-xmin)*(ymax-ymin);
    return ans;
}


double binary_search(double st,double ed){
    for(int i=1;i<500;i++){
        double mid1=(2*st+ed)/3;
        double mid2=(st+2*ed)/3;
        if(cal(mid1)<cal(mid2)){
            ed=mid2;
        }else{
            st=mid1;
        }
    }
    return cal(st);
}




void solve(){
    cin>>N;
    x.resize(N);
    y.resize(N);
    d.resize(N);
    F0R(i,N){
        cin>>x[i]>>y[i]>>d[i];
    }
    double ans= binary_search(0,2e8);
    cout.precision(15);
    cout<<ans<<endl;



}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 1152
x,y = map(int,input().split())

def calc(x):
    if x == 2:
        return  -1
    elif  x == 4 or x == 6 or x == 9 or x == 11:
        return  -2
    else:
        return  -3

if calc(x)==calc(y):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  vi a(n),b(n);
  REP(i,n) cin>>a[i];

  sort(a.begin(), a.end());
  ll s=a[0];
  ll flag=0;
  REP(i,n-1){
    if (s==a[i+1])flag=1;
    s=a[i+1];
  }

  if (flag==1){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
#define ALL(o) (o).begin(), (o).end()
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}
template <typename T> ll argmax(const T &xs) {return distance(xs.begin(), max_element(xs.begin(), xs.end()));}
template <typename T> ll argmin(const T &xs) {return distance(xs.begin(), min_element(xs.begin(), xs.end()));}
ll nextLL(){ll x; scanf("%lld", &x); return x;}
int nextInt(){int x; scanf("%d", &x); return x;}
string nextString(){string s; cin >> s; return s;}


ll extgcd(ll a, ll b, ll &x, ll &y) {
    /* g を返す時点で ax + by == g となる */
    ll g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll remainder(ll x, ll y) {assert(y > 0); ll r = x % y; if (r < 0) r += y; return r;}
ll quotient(ll x, ll y) {assert(y > 0); return (x - remainder(x, y)) / y;}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}






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


    return 0;
}




Measured memory_bytes: 3628
while(1):
    a = input()
    if(a == '.'):
        break
    b = input()
    n = len(a)
    m = len(b)
    l = 0
    flag = 0
    idx_dif = 0
    error_cou = 0

    while(1):
        if(flag == 0):
            for i in range(l,n):
                if(a[i] == '\"'):
                    if(i+idx_dif < m and a[l:i+1] == b[l+idx_dif:i+idx_dif+1]):
                        l = i+1
                        flag = 1
                    else:
                        flag = 2
                    break

                elif(i == n-1):
                    if(a[l:i] != b[l+idx_dif:m-1]):
                        flag = 2
                    else:
                        l = n-1

        elif(flag == 1):
            for i in range(l,n):
                if(a[i] == '\"'):
                    for j in range(l+idx_dif,m):
                        if(b[j] == '\"'):
                            if(a[l:i+1] != b[l+idx_dif:j+1]):
                                error_cou += 1
                            idx_dif = j-i
                            l = i+1
                            flag = 0
                            break
                        if(j == m-1):
                            flag = 2
                            break
                if(flag != 1):
                    break

        if(flag == 2 or l >= n-1 or l+idx_dif >= m-1):
            break

    if(error_cou >= 2 or flag == 2):
        print("DIFFERENT")
    elif(error_cou == 1):
        print("CLOSE")
    elif(error_cou == 0):
        print("IDENTICAL")


Measured memory_bytes: 5584
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APC001A solver = new APC001A();
        solver.solve(1, in, out);
        out.close();
    }

    static class APC001A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long ca = a * b + a;

            long ans = ca % b == 0 ? -1 : ca;
            out.println(ans);
        }

    }
}



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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, n;
  cin >> a >> b >> n;
  int x = min(b - 1, n);
  cout << floor(a * x / b) - a * floor(x / b) << '\n';
}


Measured memory_bytes: 3776
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
    # ノードxのrootノードを見つける
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
    # 木の併合、入力は併合したい各ノード⇒(a,b)
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
    # ノードxが属する木のサイズを返す
        return -self.parents[self.find(x)]

    def same(self, x, y):
    # 入力ノード(x,y)が同じグループに属するかを返す
        return self.find(x) == self.find(y)

    def members(self, x):
    #ノードxが属するメンバーをリスト形式で返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
    #親全てをリスト形式で返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
    #グループ数の合計を返す
        return len(self.roots())

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n,m=map(int,input().split())
u=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    u.unite(a,b)
ans=u.roots()
print(len(ans)-1)


Measured memory_bytes: 12776
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >>N;
	string s;
	cin >>s;

	int Red=0, Blue=0;

	for(int i=0; i<N;i++){
		if (s.at(i)=='R'){
			Red ++;
			continue; 
		}

		else if (s.at(i)=='B'){
			Blue ++;
		}
	}

	if (Red > Blue){
		cout <<"Yes" <<endl;
	}
	else {
		cout <<"No"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        /*
        Set NG dattaka...
        TreeSet <Integer> s = new TreeSet<Integer>();
        s.add(a);
        s.add(b);
        s.add(c);

        StringBuilder ret = new StringBuilder();
        for (Iterator<Integer> iterator = s.iterator(); iterator.hasNext();) {
        	ret.append(" ");
			ret.append(iterator.next());
		}
		*/
        int[] tmp = new int[3];
        tmp[0] = a;
        tmp[1] = b;
        tmp[2] = c;
        Arrays.sort(tmp);

        StringBuilder ret = new StringBuilder();
        for (int i : tmp) {
        	ret.append(" ");
			ret.append(i);
		}
        System.out.println(ret.delete(0, 1).toString());
    }
}

Measured memory_bytes: 17304
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int N;
		int M;
		int temp;
		int sum = 0;
		int P;
		ArrayList<Integer> A = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		int i;
		for (i = 0; i < N; i++) {
			temp = sc.nextInt();
			A.add(temp);
			sum += temp;
		}
		Collections.sort(A, Collections.reverseOrder());
		P = A.get(M - 1);
		if ((double) sum / 4 / M > P) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		sc.close();
	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,left,right;
    while(cin>>a>>b>>c){
        if(c-a-b<0){
            cout<<"No"<<endl;
            continue;
        }
        left=4*a*b;
        right=c*c+a*a+b*b-1LL*2*a*c-1LL*2*b*c+1LL*2*a*b;
        if(left<right) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	ll cnt = 0;
	FOR(i,0,n) {
		ll a; cin >> a;
		cnt += a % 2;
	}
	cout << (cnt % 2 ? "NO" : "YES") << endl;

}



Measured memory_bytes: 256
def func(n):
    count = 1
    while(n!=4):
        if n%2==0:
            n = n // 2
        else:
            n = 3*n + 1
        count += 1
    return count + 3


s = int(input())
if s==1:
    print(4)
elif s==2:
    print(4)
else:
    print(func(s))

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

int main()
{
	long long n, k;
	scanf("%lld%lld", &n, &k);
	if (n >= k)
	{
		n %= k;
	}
	printf("%lld\n", std::min(n, k - n));
	return 0;
}


Measured memory_bytes: 128
from itertools import accumulate
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))

P = list(accumulate([(i+1)/2 for i in p]))
P = [0] + P
ans = max([P[i+k]-P[i] for i in range(n-k+1)])
print(ans)

Measured memory_bytes: 25152
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: [usize; n + 1],
        b: [usize; n],
    };
    let mut a : Vec<usize> = a;
    let mut b : Vec<usize> = b;

    let mut sum = 0;
    for i in 0..n {
        for k in 0..2 {
            let mi = std::cmp::min(a[i + k], b[i]);
            sum += mi;
            a[i + k] -= mi;
            b[i] -= mi;
        }
    }

    println!("{}", sum);
}

Measured memory_bytes: 10232
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
#define G(A,B) G[A][B]
#define Fp(A,B,C,D) for(A=B;A<=C;A+=D)
#define Fm(A,B,C,D) for(A=B;A>=C;A-=D)
#define Clear(A) memset(A,0,sizeof(A))
using namespace std;
const LL Max=1e5+5;
const LL Mod=1e9+7;
const LL Inf=1e18;
LL N,Cnt=0,G[Max];
LL Ans,Tmp=Inf;
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
int main(){
	LL I,J,K;
	N=Read();
	Fp(I,1,N,1){
		G[I]=Read();
	}sort(G+1,G+1+N);
	Fp(I,1,N-1,1){
		if(Tmp>=abs((G[N]>>1)-G[I])){
			Ans=G[I];
			Tmp=abs((G[N]>>1)-G[I]);
		}
	}cout<<G[N]<<" "<<Ans;
	return 0;
}

Measured memory_bytes: 1024
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;


signed main() {
int N,ans=0;
cin >> N;
vector<char> S(N);
REP(i,N){
    cin >> S[i];
}
vector<char> tmp(3);
int point;
for(int i=0;i<1000;i++){
    point=0;
if(i<10){
    tmp[0]='0';
    tmp[1]='0';
    tmp[2]='0'+i;
}
if(10<=i&&i<100){
    tmp[0]='0';
    tmp[1]='0'+(i-i%10)/10;
    tmp[2]='0'+i%10;
}
if(100<=i){
    tmp[0]='0'+(i-i%100)/100;
    tmp[1]='0'+((i-i%10)/10)%10;
    tmp[2]='0'+i%10;
}
for(int j=0;j<N;j++){
    if(S[j]==tmp[point]){
        point++;
    }
    if(point==3){
        ans+=1;
        break;
    }
}
}
answer(ans);
return 0;
}

Measured memory_bytes: 3648
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scanInt()
	}

	L, R := make([]int, N), make([]int, N)
	L[0], R[N-1] = A[0], A[N-1]
	for i := 1; i < N; i++ {
		L[i] = gcd(L[i-1], A[i])
		R[N-1-i] = gcd(R[N-i], A[N-1-i])
	}

	ans := intMax(L[N-2], R[1])
	for i := 1; i < N-1; i++ {
		ans = intMax(ans, gcd(L[i-1], R[i+1]))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4736
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   String n=kbd.next();
   if(n.equals("AAA")||n.equals("BBB"))
   {
     System.out.println("No");
   }else{
     System.out.println("Yes");
   }

}
}


Measured memory_bytes: 22740
N, M = map(int, input().split())
a = [0]*N
b = [0]*N
c = [0]*M
d = [0]*M
for i in range(N):
    a[i], b[i] = map(int, input().split())
for j in range(M):
    c[j], d[j] = map(int, input().split())
for i in range(N):
    minnum = float('inf')
    for j in range(M):
        if minnum > abs(a[i]-c[j]) + abs(b[i]-d[j]):
            minnum = abs(a[i]-c[j]) + abs(b[i]-d[j])
            ans = j+1
    print(ans)

Measured memory_bytes: 39536
#include <iostream>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

const int INF = 1e9;
int H, W, c_i, c_j, d_i, d_j, cost[1010][1010];
string S[1010];

int main() {

	cin >> H >> W >> c_i >> c_j >> d_i >> d_j;
    for (int i = 0; i < H; ++i){
        cin >> S[i];
    }

    for (int i = 0; i < H; ++i){
        for (int j = 0; j < W; ++j){
            cost[i][j] = INF;
        }
    }

    deque<pair<int, int>> q;
    cost[c_i-1][c_j-1] = 0;
    q.push_front(make_pair(c_i-1, c_j-1));

    while(!q.empty()){
        auto p = q.front();
        q.pop_front();
        int i = p.first;
        int j = p.second;
        
        if (i >= 1 && S[i-1][j] == '.' && cost[i-1][j] > cost[i][j]) {
            cost[i-1][j] = cost[i][j];
            q.push_front(make_pair(i-1, j));
        }
        if (i <= H-2 && S[i+1][j] == '.' && cost[i+1][j] > cost[i][j]){
            cost[i+1][j] = cost[i][j];
            q.push_front(make_pair(i+1, j));
        }
        if (j >= 1 && S[i][j-1] == '.' && cost[i][j-1] > cost[i][j]) {
            cost[i][j-1] = cost[i][j];
            q.push_front(make_pair(i, j-1));
        }
        if (j <= W-2 && S[i][j+1] == '.' && cost[i][j+1] > cost[i][j]){
            cost[i][j+1] = cost[i][j];
            q.push_front(make_pair(i, j+1));
        }

        for (int k = max(0, i-2); k <= min(i+2, H-1); ++k){
            for (int l = max(0, j-2); l <= min(j+2, W-1); ++l){
                if (S[k][l] == '.' && cost[k][l] > cost[i][j]+1){
                    cost[k][l] = cost[i][j]+1;
                    q.push_back(make_pair(k, l));
                }
            }   
        }
    }
    if (cost[d_i-1][d_j-1] == INF){
        cout << -1 << endl;
    } else {
        cout << cost[d_i-1][d_j-1] << endl;
    }
	return 0;
}

Measured memory_bytes: 9484
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

const int N = 2e5+25;
int sz[N], pa[N];

int fnd(int x) {return (x == pa[x] ? pa[x] : pa[x] = fnd(pa[x]));}
void uni(int a, int b) {
	if((a = fnd(a)) == (b = fnd(b)))
		return;
	if(sz[a] > sz[b])
		swap(a, b);
	sz[b] += sz[a], pa[a] = b;
}

signed main() {
	EmiliaMyWife

	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		pa[i] = i, sz[i]++;
	vector<vector<int>> edge;
	for(int i = 0, a, b; i < m; i++) {
		cin >> a >> b;
		uni(a, b);
	}
	cout << *max_element(sz, sz + N) << '\n';

	return 0;
}


Measured memory_bytes: 5204
n,k=map(int,input().split())
v=list(map(int,input().split()))
ans=0
for a in range(min(k,n)+1):
  for b in range(min(k,n)-a+1):
    t=v[:a]
    t+=v[n-b:]
    t.sort()
    for i in range(k-(a+b)):
      if len(t) and t[0]<0:
        t.pop(0)
    ans=max(ans,sum(t))
print(ans)


Measured memory_bytes: 3064
//بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ
//لا إله إلا الله محمد رسول الله

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define ll long long
#define pb push_back
#define fr first
#define sc second
#define in freopen("input.txt", "r" , stdin)
#define out freopen("snakes.out", "w", stdout)
using namespace std;

ll n, W;
ll w[100005], v[100005];
ll dp[105][100005];
int main(){
    //in;
    //out;
    ios_base::sync_with_stdio(false);
    cin >> n >> W;
    ll sum = 0, inf = 1e18;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = inf;
        }
    }


    for(int i = 1; i <= n; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = dp[i-1][j];
            if (j >v[i]) dp[i][j] = min (dp[i][j], dp[i-1][j - v[i]] + w[i]);
            if (j == v[i]) dp[i][j] = min (dp[i][j], w[i]);
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (ll j = 0; j <= 100000; j++) {
            if (dp[i][j] > 0 and dp[i][j] <= W) {
                ans = max (ans, j);
            }
        }
    }

    cout << ans;

}




Measured memory_bytes: 80128
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int       lint;
typedef vector<int>         vi;
typedef vector<lint>        vl;
typedef pair<int, int>      pii;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
 
#define pb(n)           push_back(n)
#define ALL(n)          (n.begin(), n.end())
#define SORT(n)         (n.begin(), n.end(), greater<lint>())       
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define M               10000000
#define MOD             10000007
#define INF             10000000000000000
#define REP(i,a,b)      for(int i = int(a); i <= int(b); i++)
#define REPL(i,a,b)     for(lint i = lint(a); i <= lint(b); i++)
#define fastIO()        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    deque<char>dq;
    string s;
    cin>>s;

    REP(i, 0, s.size() - 1){
        if(s[i] == '1' || s[i] == '0') dq.push_back(s[i]);
        else if(!dq.empty()) dq.pop_back();
    }
    for(auto i : dq) cout<<i;
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
dp=[100000]*(100000+1)
dp[0]=0
dp[1:5]=range(1,6)
k9=0
k6=0
for n in range(6,N+1):
  while n//(9**k9)>=9:
    k9+=1
  while n//(6**k6)>=6:
    k6+=1
  dp[n]=min(dp[n],dp[n-6**k6]+1,dp[n-9**k9]+1,dp[n-1]+1)
print(dp[N])


Measured memory_bytes: 3828
#define DIV 1000000007
#include<bits/stdc++.h>
using namespace std;

long long mypow(long long x, long long n){
    long long ret=1,p;
    long long l=1,p2=1;
    p=x;
    while(1){
        if(n&p2) ret*=p;
        p*=p;
        p%=DIV;
        ret%=DIV;
        p2*=2;
        if(p2>n) break;
    }
    return ret;
}

long long frac(long long n){
    long long ret=1;
    for(; n>0; n--){
        ret*=n;
        ret%=DIV;
    }
    return ret;
}
int inv(int n){
    return mypow(frac(n),DIV-2)%DIV;
}

int nCk(int n, int k){
    k=min(k,n-k);
    long long ret=1;
    for(int i=n; i>n-k; i--){
        ret*=i;
        ret%=DIV;
    }
    ret *= inv(k);
    ret %= DIV;
    return ret;
}

int main(){
    int N,a,b;
    cin >> N >> a >> b;
    long long ans=mypow(2,N)-1;
    ans -= nCk(N,a) + nCk(N,b);
    ans%=DIV;
    if(ans<0) ans+=DIV;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
function main(input) {
  input=input.trim();
  const n = parseInt(input.split(" ")[0], 10);
  const a = parseInt(input.split(" ")[1], 10);
  const b = parseInt(input.split(" ")[2], 10);

if(n*a>b){
  console.log(b);
}else{
  console.log(a*n);
}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		//aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
	//		aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		printf("%d ", n);
		//aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
vector<int>a(55);
int mem[100][100][100];
LL solv(int l, int r, int k, int n) {
	if (k < 0) { return -1e9; }
	if (k == 0 or (l > r)) { return 0; }
	int &ans = mem[l][r][k];
	if (ans != -1)
		return ans;
	if (mem[l][r][k] != -1)
		return mem[l][r][k];
		int x = solv(l + 1, r, k - 1, n) + a[l];
		int y = solv(l, r - 1, k - 1, n) + a[r];
		int z = solv(l + 1, r, k - 2, n);
		int t = solv(l, r - 1, k - 2, n);
		ans=max({ans,x,y,z,t,0 });
		return ans;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n, k;
	memset(mem, -1, sizeof mem);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans= solv(0, n - 1, k, n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
n=int(input())
a=list(map(int,input().split()))
d=dict()
#コンビネーション逆元
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル


for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(n+1):
    if a[i] not in d:
        d[a[i]]=i
    else:
        idx1=d[a[i]]
        idx2=i
        break
for i in range(1,n+2):
    ans=cmb(n+1,i,mod)
    if n-idx2+idx1<i-1:
        print(ans)
    else:
        ans=(ans-cmb(n-idx2+idx1,i-1,mod)+mod)%mod
        print(ans%mod)

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

#define ipair pair<int,int>
#define rep(n) for(int i=0;i<n;i++)
#define OK1 cout << "ok1" << endl
#define OK2 cout << "ok2" << endl

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	int n, i, j;
	vi a;
	int sum;
	lli count, count2;

	cin >> n;
	a.resize(n);

	rep(n) {
		cin >> a[i];
	}

	count = 0;
	count2 = 0;
	sum = 0;
	
	if (a[0] <= 0) {
		sum = 1;
		count += abs(a[0]) + 1;
	}
	else {
		sum = a[0];
	}

	rep(n-1) {

		if (sum + a[i + 1] == 0) {
			count++;
			if (sum < 0)
				sum = 1;
			else
				sum = -1;
		}
		else if (sum < 0 && (sum + a[i + 1]) < 0) {
			j = 1 - sum;
			count += j - a[i+1];
			sum = 1;
		}
		else if (sum > 0 && (sum + a[i + 1]) > 0) {
			j = -1 - sum;
			count += abs(j - a[i + 1]);
			sum = -1;
		}
		else {
			sum += a[i + 1];
		}
	}


	if (a[0] >= 0) {
		sum = -1;
		count2 += abs(a[0]) + 1;
	}
	else {
		sum = a[0];
	}
	rep(n - 1) {

		if (sum + a[i + 1] == 0) {
			count2++;
			if (sum < 0)
				sum = 1;
			else
				sum = -1;
		}
		else if (sum < 0 && (sum + a[i + 1]) < 0) {
			j = 1 - sum;
			count2 += j - a[i + 1];
			sum = 1;
		}
		else if (sum > 0 && (sum + a[i + 1]) > 0) {
			j = -1 - sum;
			count2 += abs(j - a[i + 1]);
			sum = -1;
		}
		else {
			sum += a[i + 1];
		}
	}


	cout << min(count, count2);

	return 0;
}

Measured memory_bytes: 640