akhauriyash/Code-Regression huggingface dataset:
h,w=map(int,input().split())
G=[input() for _ in range(h)]

from collections import deque
move=[(0,1),(0,-1),(1,0),(-1,0)]

que=deque([])

for i in range(h):
    for j in range(w):
        if G[i][j]=='#':
            que.append((i,j,0))

c=0
visit=[[0]*w for _ in range(h)]
while len(que)>0:
    ni,nj,c=que.popleft()
    for di,dj in move:
        mi,mj=ni+di,nj+dj
        if 0<=mi<h and 0<=mj<w and G[mi][mj]=='.' and visit[mi][mj]==0:
            visit[mi][mj]=1
            que.append((mi,mj,c+1))
print(c)


Measured memory_bytes: 135900
#include <stdio.h>

long min(long a,long b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  long N,M;
  scanf("%ld%ld",&N,&M);

  long ans = 0;
  long mini = min(N,M/2);
  ans += mini;
  N -= mini; M -= mini*2;
  ans += M/4;

  printf("%ld\n",ans);
  return 0;
}

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

int main() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll min_move = min({a,b,c,d,e});
  cout << (n + min_move - 1) / min_move + 4 << endl;
  return 0;
}

Measured memory_bytes: 3180
M = 998_244_353
n, k = gets.chomp.split(' ').map(&:to_i)
lr = k.times.map { gets.chomp.split(' ').map(&:to_i) }.sort_by

dp = (0..n).map { 0 }
dp[1] = 1

(2..n).each do |i|
  temp = lr.map { |l, r| dp[[0, i - l].max] - dp[[0, i - r - 1].max] }.sum
  dp[i] = (dp[i - 1] + temp) % M
end

puts (dp[n] - dp[n - 1]) % M


Measured memory_bytes: 16512
#include "bits/stdc++.h"
using namespace std;

int main()
{
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    int A = fabs(x - a);
    int B = fabs(x - b);
    if(A < B)
    cout << "A";
    else
    cout << "B";
    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        if (x >= 30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}


Measured memory_bytes: 35612
import java.io.*;
import java.util.*;

public class Main{
    PrintWriter out = new PrintWriter(System.out);
    ArrayList<Integer>[] graph;
    int[] prev;
    ArrayList<Integer> cycleList;
    static public void main(String[] args) throws Exception{
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ")
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        graph = new ArrayList[n+1];
        for(int i=0;i<=n;i++) graph[i] = new ArrayList<>();
        prev = new int[n+1];
        for(int i=0;i<m;i++){
            int a = sc.nextInt(), b = sc.nextInt();
            graph[a].add(b);
        }
        int start = 0;
        for(int i=1;i<=n;i++){
            dfs(i,i,new boolean[n+1], new ArrayList<>());
            if(cycleList!=null&&cycleList.size()>2) break;
        }
        if(cycleList==null||cycleList.size()<=2) start = -1;
        else{
            start = cycleList.get(0);
            int len = cycleList.size();
            for(int i=0;i<len;i++){
                prev[cycleList.get(i)] = cycleList.get((i-1+len)%len);
            }
        }
        if(start<=0) return -1;
        //Then start != -1, we found a loop
        int newStart = 0;
        while((newStart=GetNewStart(start,n))!=start){
            start = newStart;
        }
        Set<Integer> ans = getLoopNode(start);
        out.println(ans.size());
        for(int w:ans) out.println(w);
        out.flush();
        System.exit(0);
        return -1;
    }
    int GetNewStart(int start, int n){
        Set<Integer> cycle = getLoopNode(start);
        for(int from:cycle){
            for(int to:graph[from]){
                if(!cycle.contains(to)) continue; // dont care
                if(prev[to]!=from){
                    // we found a "shorter" loop
                    prev[to]=from;
                    if(to==start) return from;
                    else return to;
                }
            }
        }
        return start;
    }
    Set<Integer> getLoopNode(int start){
        Set<Integer> ans = new HashSet<>(100);
        int cur = prev[start];
        ans.add(start);
        while(cur!=start){
            ans.add(cur);
            cur = prev[cur];
        }
        return ans;
    }
    void dfs(int cur, int start, boolean[] visit, ArrayList<Integer> list){
        if(cycleList!=null&&cycleList.size()>2) return;
        if(cur==start&&list.size()>2){
            cycleList = new ArrayList<>(list);
            return;
        }
        if(visit[cur]) return;
        visit[cur] = true;
        list.add(cur);
        for(int to:graph[cur]){
            dfs(to,start,visit,list);
        }
        list.remove(list.size()-1);
    }
}



Measured memory_bytes: 30052
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 24, 2019
 * 
 */

#include <bits/stdc++.h>

//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 
    int n;
    cin>>n;

    bint sum =0;
    bint diff =INT_MAX;
    bint dsum=0;
    vl v(n);

    for(int i=0; i<n; ++i){
        cin>>v[i];
        sum+=v[i];
    }
    
    for(int i=0; i<n; ++i){
        sum-=v[i];
        dsum+=v[i];

        diff = min(diff , abs(sum-dsum));
    }
    cout<<diff<<endl;




    return ;
}




int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#ifdef MY_LOCAL_PROJECT
    freopen("bin","r",stdin);
    freopen("bout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 256
N, M, K = map(int,input().split())

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 #出力の制限
MAX_N = 10**6 # N >= n
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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

k = cmb(M * N - 2,K - 2,mod)



def calc(p, q, d):
    return d * (p - d) * (q ** 2)

ans = 0

for i in range(N):
    ans += calc(N, M, i)
for i in range(M):
    ans += calc(M, N, i)

ans %= mod

ans *= k

ans %= mod

print(ans)

Measured memory_bytes: 123800
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

template<typename T>

bool prime_num(T x){
    if(x == 1) return false;
    for(T i=2; i<=T(sqrt(x)); i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    int Q;
    cin >> Q;
    int r[Q], l[Q];
    int max_r = 0;

    for(int i=0; i<Q; i++){
        cin >> l[i] >> r[i];
        max_r = max(max_r, r[i]);
    }
    int cnt[max_r + 2]; 
    cnt[1] = 0;

    for(int i=3; i<max_r + 2; i+=2){
        cnt[i] = cnt[i-2];
        if(prime_num(i) && prime_num((i+1)/2)) cnt[i]++;
    }   
    
    for(int i=0; i<Q; i++){
        if(l[i] == 1){
            cout << cnt[r[i]] << endl;
        }
        else{
            cout << cnt[r[i]] - cnt[l[i] - 2] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
int n;
string s;
cin>>n>>s;
for(int i=0; i<s.size(); i++){
s[i]+=n;
if(s[i]>('A'+25))
s[i]-=26;
}
cout<<s<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

deque<int> d;

int n;
vector<int> a;

int main(void) {

    cin >> n;

    bool flip = false;
    for (int i = 0; i < n; ++i) {
        int aa;
        cin >> aa;

        if (flip) {
            d.push_front(aa);
        }
        else {
            d.push_back(aa);
        }

        flip = !flip;
    }

    for (int i = 0; i < n; ++i) {
        int ii = n % 2 == 1 ? n - 1 - i : i;
        cout << d[ii];
        if (i != n - 1) cout << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2944
n, k = [int(c) for c in input().split()]
h = [int(input()) for _ in range(n)]

h.sort()

min_d = 1000000000
for i in range(n-k+1):
    d = h[i+k-1] - h[i]
    if d < min_d:
        min_d = d

print(min_d)

Measured memory_bytes: 7436
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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 int INF=1e18;
const int MOD=1e9+7;

int mul(int x,int y){
    x=x*y%MOD;
    return x;
}

signed main(){
    string l;cin>>l;
    int dp[SZ(l)+1][2];
    REP(i,SZ(l)+2)REP(j,2)dp[i][j]=0;
    dp[0][0]=1;
    REP(i,SZ(l)){
        int d=l[i]-'0';
        if(d==0){
            dp[i+1][1]=mul(dp[i][1],3);
            dp[i+1][0]=dp[i][0];
        }
        else{
            dp[i+1][1]=(mul(dp[i][1],3)+dp[i][0])%MOD;
            dp[i+1][0]=mul(dp[i][0],2);
        }
    }
    cout<<(dp[SZ(l)][0]+dp[SZ(l)][1])%MOD<<endl;
}

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

int extend_gcd(int a,int b,int &x,int &y){
	if(b==0){
		x = 1;y = 0;
		return 0;
	}
	else{
		int r = extend_gcd(b,a%b,y,x);
		y -= x*(a/b);
		return r;
	}
}

int CRT(int a[],int m[]){
    int M = 1;
	for(int i=0;i<3;i++){
		M*=m[i];
	}
	int ret = 0;
	for(int i=0;i<3;i++){
		int x,y;
		int tm = M/m[i];
		extend_gcd(tm,m[i],x,y);
		ret = (ret+tm*x*a[i])%M;
	}
	return (ret+M)%M;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //没有重复元素的子序列
    int n;
    cin>>n;
    int ans=n;
    for(int i=0;i<=n;i++)
    {
        int cost=0;
        int t=i;
        while(t>0)cost+=t%6,t/=6;
        t=n-i;
        while(t>0)cost+=t%9,t/=9;
        ans=min(ans,cost);
    }
    cout<<ans<<endl;
  return 0;
}


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

#define MAX 31
int W;
int H;
char c;

char room[MAX][MAX];

int main(){
    cin>>W>>H>>c;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            room[i][j]='.';
            if(i==H/2&&j==W/2){
                room[i][j]=c;
                continue;
            }
            if(i==0||i==H-1){
                if(j==0||j==W-1){
                    room[i][j]='+';
                    continue;
                }
            }
            if(i==0||i==H-1){
                room[i][j]='-';
                continue;
            }
            if(j==0||j==W-1){
                room[i][j]='|';
                continue;
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            putchar(room[i][j]);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

/* MAXが入力される値より大きくなっていることを確認する */
const int MAX = 510000;
const int MOD = 998244353;

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

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

ll COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 3連続以上が抜けてた
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    COMinit();

    ll ans = 0;
    ll total = m;
    for (int i = k; i < n - 1; i++)
    {
        total = (total * (m - 1)) % MOD;
    }
    for (int i = k; i >= 0; i--)
    {
        ans += total * COM(n - 1, i);
        ans %= MOD;
        total = (total * (m - 1)) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15572
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

//#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);


    int k, s;
    cin >> k >> s;

    int ans = 0;
    REP(x, k + 1) {
        REP(y, k + 1) {
            if (x + y + k >= s && x + y <= s) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int n;
    scanf("%d", &n);
    int k;
    scanf("%d", &k);
    int cnt = 0;
    for (int i=0; i<n; i++) {
        int h;
        scanf("%d", &h);
        if (h>=k) cnt++;
    }
    printf("%d\n", cnt);
}

Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let (a, b, _c, k): (isize, isize, isize, usize) = parse_line().unwrap();

    if (a - b).abs() > 10_isize.pow(18) {
        println!("Unfair");
    }
    if k % 2 == 0 {
        println!("{}", a - b);
    } else {
        println!("{}", -(a - b));
    }
}


Measured memory_bytes: 2148
#include <cstdio>
#include <unordered_map>
#define S 1500
using namespace std;
int W[S]={0};
int H[S]={0};

int main(){
    int N,M,h,w,i,j,k,l,c;
    while(1){
        scanf("%d %d",&N,&M);
        if(!N && !M){break;}
        unordered_map<int,int> ww,hh;
        for(i=0;i<S;i++){
            W[i]=0;H[i]=0;
        }
        for(i=0;i<N;i++){
            scanf("%d",&h);
            if(!i){H[i]=h;}
            else{H[i]=H[i-1]+h;}
        }
        for(i=0;i<M;i++){
            scanf("%d",&w);
            if(!i){W[i]=w;}
            else{W[i]=W[i-1]+w;}
        }
        c=0;
        for(i=0;i<M;i++){
            for(j=0;j<=i;j++){
                if(i!=j){
                    auto itr = ww.find(W[i]-W[j]);
                    if(itr!=ww.end()){
                        ww[W[i]-W[j]]++;
                    }
                    else{
                        ww[W[i]-W[j]]=1;
                    }
                }
                else{
                    auto itr = ww.find(W[i]);
                    if(itr!=ww.end()){
                        ww[W[i]]++;
                    }
                    else{
                        ww[W[i]]=1;
                    }
                }
            }
        }

        for(k=0;k<N;k++){
            for(l=0;l<=k;l++){
                if(k!=l){
                    auto itr = hh.find(H[k]-H[l]);
                    if(itr!=hh.end()){
                        hh[H[k]-H[l]]++;
                    }
                    else{
                        hh[H[k]-H[l]]=1;
                    }
                }
                else{
                    auto itr = hh.find(H[k]);
                    if(itr!=hh.end()){
                        hh[H[k]]++;
                    }
                    else{
                        hh[H[k]]=1;
                    }
                }
            }
        }
        for(auto itr=ww.begin();itr!=ww.end();itr++){
            auto r = hh.find(itr->first);
            if(r!=hh.end()){
                c+=(itr->second*r->second);
            }
        }
        printf("%d\n",c);
    }
    return 0;
}
         



Measured memory_bytes: 29428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<ll>> ab(n, vector<ll>(2));
  rep(i, n) cin >> ab[i][0] >> ab[i][1];
  sort(ab.begin(), ab.end());
  ll ans = 0;
  rep(i, n) {
    if (m > ab[i][1]) {
      ans += ab[i][0] * ab[i][1];
      m -= ab[i][1];
    }
    else {
      ans += ab[i][0] * m;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
vector<int> a;
vector<bool> isok;
int mod = 1000000007;
int main(void){
    int n,m;
    cin >> n >> m;
    a.resize(m);
    isok.assign(n+1,true);
    for(int i = 0;i < m;i++){
        cin >> a[i];
        isok[a[i]] = false;
    }
    
    vector<int> dp(100010);
    dp[0] = 1;
    if(isok[1]) dp[1] = 1;
    
    for(int i = 2;i <= n;i++){
        if(isok[i-2]){
            dp[i] += dp[i-2];
            dp[i] %= mod;
        }
        if(isok[i-1]){
            dp[i] += dp[i-1];
            dp[i] %= mod;
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    long long N,A,B;cin >> N >> A >> B;
    if(A > B || N == 1 && A != B){
        cout << 0 << endl;
        return 0;
    }
    long long maxi = A+B*(N-1);
    long long mini = B+A*(N-1);
    cout << maxi - mini + 1 << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n, h, w; cin >> n >> h >> w;
  cout << (n-h+1) * (n-w+1) << endl;

  return 0;
}

Measured memory_bytes: 256
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, A, B, C, D = gets_i_list
S = gets.chomp

if C < D
  a_line = S.slice(A - 1, C - A + 1)
  b_line = S.slice(B - 1, D - B + 1)
  if b_line.include?("##")
    puts "No"
    exit
  elsif a_line.include?("##")
    puts "No"
    exit
  else
    puts "Yes"
  end
else
  ob_line = S.slice(B - 2, D - B + 3)
  a_line  = S.slice(A - 1, C - A + 1)
  b_line  = S.slice(B - 1, D - B + 1)
  if !ob_line.include?("...")
    puts "No"
    exit
  elsif a_line.include?("##")
    puts "No"
    exit
  elsif b_line.include?("##")
    puts "No"
    exit
  else
    puts "Yes"
  end
end


Measured memory_bytes: 4604
module UIntegerSort
  implicit none
 
  private
 
  public QuickSortInteger
 
contains
    
  !!
  ! ピボット値の取得
  !
  subroutine GetPivotIntegerValue(array, n, a, b, pivot_value)
    integer, intent(inout) :: array(:), pivot_value
    integer, intent(in) :: n, a, b
 
    pivot_value = array((a + b) / 2)
  end subroutine
 
  !!
  ! ピボット値に従って値を分離
  !
  subroutine GetPartitionInteger(array, n, a, b, pivot)
    integer, intent(inout) :: array(:)
    integer, intent(in)  :: n, a, b
    integer, intent(out) :: pivot
 
    integer :: buffer, pivot_value
    integer :: l, r
 
    if (a == b) then
      pivot = 0
      return
    end if
 
    call GetPivotIntegerValue(array, n, a, b, pivot_value)
 
    l = a
    r = b
 
    do while(.true.)
      do while(array(l) < pivot_value)
        if (l >= b) exit
        l = l + 1
      end do
 
      do while(pivot_value < array(r))
        if (r <= a) exit
        r = r - 1
      end do
 
      if(r <= l) exit
 
      buffer   = array(l)
      array(l) = array(r)
      array(r) = buffer
 
      l = l + 1
      r = r - 1
    end do
 
    pivot = r
  end subroutine
 
  !!
  ! 配列の一部分をソートする。
  !
  recursive subroutine QuickSortIntegerSubarray(array, n, a, b)
    integer, intent(inout) :: array(:)
    integer, intent(in)    :: n, a, b
 
    integer :: pivot
 
    call GetPartitionInteger(array, n, a, b, pivot)
    if (pivot /= 0) then
      call QuickSortIntegerSubarray(array, n, a, pivot)
      call QuickSortIntegerSubarray(array, n, pivot + 1, b)
    end if
  end subroutine
 
  !!
  ! 配列全体をソートする
  !
  subroutine QuickSortInteger(array, n)
    integer :: array(:)
    integer :: n
 
    call QuickSortIntegerSubarray(array, n, 1, n)
  end subroutine
 
end module
 
program TestIntegerSort
  use UIntegerSort
 
  implicit none
  integer,allocatable::a(:)
  integer :: N,i
  read*,N
  allocate(a(N))
  read(*,*)(a(i),i=1,N)
  call QuickSortInteger(a, N)
    print *, a(N/2+1)-a(N/2)
end program

Measured memory_bytes: 1152
#include<cstdio>
#include<algorithm>
#define maxn 100005
#define N 200
using namespace std;
int n,h,indeg[N*2+5],outdeg[N*2+5];
bool vis[N*2+5];
struct node { int v; node *nxt; } edge[maxn],*head[N*2+5],*ncnt;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt,indeg[v]++,outdeg[u]++;
}
void dfs(int u)
{
	vis[u]=true;
	for(node *p=head[u];p;p=p->nxt)
		if(!vis[p->v]) dfs(p->v);
}
int main()
{
	scanf("%d%d",&n,&h);
	ncnt=&edge[0];
	for(int i=1;i<=n;i++) 
	{
		int a,b,c,d,l,r;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		//printf(" * %d %d %d %d\n",a,b,c,d);
		l=c?(-c):a,r=d?d:(-b);
		//printf(" - %d %d\n",l,r);
		addedge(l+N,r+N);
	}
	for(int i=0;i<N;i++)
		if(indeg[i]<outdeg[i]) { printf("NO\n"); return 0; }
	for(int i=N+1;i<=N*2;i++)
		if(indeg[i]>outdeg[i]) { printf("NO\n"); return 0; }
	for(int i=0;i<=N*2;i++)
		if(outdeg[i]>indeg[i]&&!vis[i]) dfs(i);
	for(int i=0;i<=N*2;i++)
		if((indeg[i]||outdeg[i])&&!vis[i]) { printf("NO\n"); return 0; }
	printf("YES\n");
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> l(n); REP(i, n) cin >> l[i];
  sort(ALL(l));
  int ans = 0;
  REP(i, n) FOR(j, i + 1, n) FOR(k, j + 1, n) {
    ans += l[i] != l[j] && l[j] != l[k] && l[k] != l[i] && l[i] + l[j] > l[k];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;
int main()
{
	int i,k=0;
	char a[1000],b[1000];
	scanf("%s",&a);
	int n=strlen(a);
	for(i=0;i<n;i++)
	{
		if(a[i]=='0') b[k++]='0';
		else if(a[i]=='1') b[k++]='1';
		else if(a[i]=='B') 
		{
			if(k==0) continue;
			else k--;
		}
	}
	for(i=0;i<k;i++) printf("%c",b[i]);
	printf("\n");
}

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

main(){
  int m;
  while(cin >> m){
    for(int k=0;k<m;k++){
      int funds, period, n, ans=-1;
      cin >> funds >> period >> n;
      for(int i=0;i<n;i++){
	bool interest;
	double rate;
	int charge, tmp;
	cin >> tmp >> rate >> charge;
	if(tmp==1) interest=true;
	else interest=false;
	tmp=funds;
	
	if(interest){
	  for(int j=0;j<period;j++){
	    tmp+=(int)((double)tmp*rate)-charge;
	  }
	}
	else{
	  int sum=0;
	  for(int j=0;j<period;j++){
	    sum+=(int)((double)tmp*rate);
	    tmp-=charge;
	  }
	  tmp+=sum;
	}
	
	ans=max(ans, tmp);
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import Data.Maybe
import Data.List

main = putStrLn . show . solve =<< parse

solve :: (Int, [Int]) -> Int
solve (n, ds) = fromJust $ find (canPay ds) [n..]

canPay :: [Int] -> Int -> Bool
canPay ds n = all (flip notElem ds) (nums n)

nums :: Int -> [Int]
nums n
    | n < 10 = [n]
    | otherwise = q : nums p where
          (p, q) = divMod n 10

parse :: IO (Int, [Int])
parse = do
    [n, k] <- readInts
    ds <- readInts
    return (n, ds)

readInts :: IO [Int]
readInts = map read . words <$> getLine


Measured memory_bytes: 1020
unittest
{
	assert( [ "100", "1" ].solve == 19 );
	assert( [ "25", "2" ].solve == 14 );
	assert( [ "314159", "2" ].solve == 937 );
	assert( [ "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", "3" ].solve == 117879300 );
	
	assert( [ "99", "3" ].solve == 0 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.map!( ( a ) => ( a - '0' ).to!( long ) ).array;
	input.popFront;
	auto k = input.front.to!( long );
	
	// dp[ i桁目 ][ i桁目までのゼロ以外の個数 ][ n未満フラグ ] = パターン数
	auto dp = new long[][][]( n.length, 1 + k + 1, 2 );
	dp[ 0 ][ 0 ][ 1 ] = 1;
	dp[ 0 ][ 1 ][ 0 ] = 1;
	dp[ 0 ][ 1 ][ 1 ] = n[ 0 ] - 1;
	foreach( i, d; n[ 1 .. $ ] )
	{
		foreach( j; 0L .. k + 1 )
		{
			// 同値⇒同値
			auto jj = j + ( 0 < d );
			dp[ i + 1 ][ jj ][ 0 ] += dp[ i ][ j ][ 0 ];
			
			// 同値⇒未満
			if( 0 < d )
			{
				dp[ i + 1 ][ j     ][ 1 ] += dp[ i ][ j ][ 0 ];					// 0
				dp[ i + 1 ][ j + 1 ][ 1 ] += dp[ i ][ j ][ 0 ] * ( d - 1 );		// [1,d)
			}
			
			// 未満⇒未満
			dp[ i + 1 ][ j     ][ 1 ] += dp[ i ][ j ][ 1 ];			// 0
			dp[ i + 1 ][ j + 1 ][ 1 ] += dp[ i ][ j ][ 1 ] * 9;		// [1,10)
		}
	}
	return dp[ $ - 1 ][ k ].sum;
}


Measured memory_bytes: 2744
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    string s = in<string>();
    vector<char> ans;
    REP(i, s.size()){
        if(s[i] == '0') ans.push_back('0');
        else if(s[i] == '1') ans.push_back('1');
        else if(s[i] == 'B' and ans.size() != 0) ans.pop_back();
    }
    REP(i, ans.size()) cout << ans[i];
    cout << endl;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    string s;
    cin >> s;
    bool ans=true;
    if(s.size()%2!=0){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0;i<s.size()-1;i=i+2){
        if(s[i]!='h'||s[i+1]!='i'){
            ans=false;
        }
    }

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if ((a <= c && b >= c) || (a >= c && b <= c)) {
			System.out.printf("Yes");
		} else {
			System.out.printf("No");
		}
	}
}


Measured memory_bytes: 22224
N = int(input())
a = list(map(int,input().split()))
a.sort()
p = 1
q = 0
r = 0
ans = 1
for i in range(N-1):
    if a[i+1] == a[i]+1:
        r = q
        q = p
        p = 1
    elif a[i+1] == a[i]:
        p += 1
    elif a[i+1] == a[i] + 2:
        r = p
        q = 0
        p = 1
    elif a[i+1] != a[i]:
        r = 0
        q = 0
        p = 1
    if p+q+r > ans:
        ans = p+q+r
print(ans)

Measured memory_bytes: 14008
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int[][] happiness = new int[n][3];

        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < 3; ++j) {
                happiness[i][j] = scan.nextInt();
            }
        }

        int[][] dp = new int[n][3];
        dp[0] = happiness[0];

        for (int i = 1; i < n; ++i) {
            dp[i][0] = happiness[i][0] + Math.max(dp[i - 1][1], dp[i - 1][2]);
            dp[i][1] = happiness[i][1] + Math.max(dp[i - 1][0], dp[i - 1][2]);
            dp[i][2] = happiness[i][2] + Math.max(dp[i - 1][0], dp[i - 1][1]);
        }

        System.out.println(Math.max(dp[n - 1][0], Math.max(dp[n - 1][1], dp[n - 1][2])));
    }
}


Measured memory_bytes: 98000
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int x, a, b;
  cin >> x >> a >> b;
  if (a - b >= 0) {
    cout << "delicious" << endl;
  } else if (b - a <= x) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.algorithm, std.array;

void main(){
    while(true){
        auto line = readln();
        if(line == null){
            break;
        }
        auto strs = line.split();
		if(strs.length < 8){
			break;
		}
		auto input = strs.map!(to!real)();
        auto p1 = input[0] + input[1] * 1.0i, p2 = input[2] + input[3] * 1.0i, p3 = input[4] + input[5] * 1.0i, p = input[6] + input[7] * 1.0i;
        if((dot(p1, p2, p) && dot(p2, p3, p) && dot(p3, p1, p)) || (!dot(p1, p2, p) && !dot(p2, p3, p) && !dot(p3, p1, p))){
            writeln("YES");
        }else{
            writeln("NO");
        }
    } 
}

bool dot(creal base, creal src, creal target){
    real a = (src - base).re, b = (src - base).im, c = (target - base).re, d = (target - base).im;
    return a * d - b * c > 0;
}

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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  int ans =0;
 
  if(A>=K){
    ans= K;
  }
  else if(  A + B >= K){
    ans= A;
  }
  else if(A+B+C >= K){
    ans = A - (K-A-B);
  }
  cout << ans << endl;
  
}



Measured memory_bytes: 3600
n, k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]

index = 0
for i in range(n):
    if a[i] == 1:
        index = i
        break

count_1 = index
count_2 = n - index -1

r = count_1 % (k-1)
if r == 0:
    q_1 = count_1 // (k-1)
else:
    q_1 = count_1 // (k-1) + 1

if r == 0:
    count_3 = count_2
else:
    count_3 = count_2 - ((k-1) - r)

if count_3 < 0:
    q_2 = 0
elif count_3 % (k-1) == 0:
    q_2 = count_3 // (k-1)
else:
    q_2 =  count_3 // (k-1) +1

ans = q_1 + q_2

print(int(ans))


Measured memory_bytes: 13880
#include <stdio.h>

void swap(int *a, int *b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(void)
{
    int x, y;

    scanf("%d %d", &x, &y);
    while((x != 0) || (y != 0)) {
        if (x > y) {
            swap(&x, &y);
        }
        printf("%d %d\n", x, y);
        scanf("%d %d", &x, &y);
    }
}


Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>


int main()
{
	long long n;

	std::cin >> n;

	std::string s, t;

	std::cin >> s >> t;

	std::vector<long long > v(n + 1, 1), v2(n + 1, 1);

	if (s[0] == t[0]) {
		v[0] = 3;
		v2[0] = 1;
	} else {
		v[0] = 3;
		v2[0] = 2;
	}

	for (size_t i = 0; i < n - 1; i++) {
		if (s[i] == t[i]) { // 縦
			if (s[i + 1] == t[i + 1]) {
				v[i + 1] = 2;
				v2[i + 1] = 1;
			} else {
				v[i + 1] = 2;
				v2[i + 1] = 1;
			}
		} else {
			if (s[i + 2] == t[i + 2]) {
				v[i + 2] = 1;
				v2[i + 2] = 1;
			} else {
				v[i + 2] = 3;
				v2[i + 2] = 1;
			}
			i++;
		}
	}

	long long ans = 1;
	for (size_t i = 0; i < v.size(); i++) {
		ans = (ans * v[i]) % 1000000007;
		ans = (ans * v2[i]) % 1000000007;
	}

	//for (size_t i = 0; i < n; i++) {
	//	std::cout << v[i];
	//}
	//std::cout << std::endl;
	//for (size_t i = 0; i < n; i++) {
	//	std::cout << v2[i];
	//}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************

set<ll> calc(ll N){
    set<ll> ret;
    for(ll i = 1; i * i <= N; i++){
        if (N % i == 0){
            ret.insert(i);
            ret.insert(N / i);
        }
    }

    return ret;
}


int main(){

    ll N;
    cin >> N;

    auto vec1 = calc(N);
    const auto& vec2 = calc(N - 1);

    ll cnt = vec2.size() - 1;
    vec1.erase(1);
    for(auto& x: vec1){
        ll NN = N;
        while(NN % x == 0) NN /= x;

        if((NN - 1) % x == 0) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

bool f1(ll mid, ll ab) {
    return mid * (mid - 1) < ab;
}

bool f2(ll mid, ll ab) {
    return mid * mid < ab;
}

int main() {
    cin >> Q;

    vector<ll> ans;
    for (int i = 0; i < Q; i++) {
        ll a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        ll tmp = 0;
        ll ok = a + 1, ng = b;
        while (abs(ok - ng) > 1) {
            ll mid = ng + (ok - ng) / 2;
            if (f1(mid, a * b)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        if (f1(ok, a * b)) chmax(tmp, min(b - a, (ok - a - 1) * 2 + 1));
        // cout << a << " " << b << " " << ok << " " << tmp << endl;
        ok = a, ng = b;
        while (abs(ok - ng) > 1) {
            ll mid = ng + (ok - ng) / 2;
            if (f2(mid, a * b)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        if (f2(ok, a * b)) chmax(tmp, min(b - a, (ok - a) * 2));
        // cout << a << " " << b << " " << ok << " " << tmp << endl;
        ans.push_back(tmp + (a - 1) * 2);
    }

    for (auto i : ans) {
        cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	max := a

	if max < b {
		max = b
	}
	if max < c {
		max = c
	}

	ans := a + b + c - max

	fmt.Println(ans)
}


Measured memory_bytes: 512
#!/usr/bin/python
# -*- coding: utf-8 -*-

def sort(lst):
  for i in range(len(lst)):
    m = i
    for j in range(i+1,len(lst)):
      if lst[j] > lst[m]:
        m = j
    # swapping 
    tmp = lst[i]
    lst[i] = lst[m]
    lst[m] = tmp
  return lst

lst=[] # initialize
for i in range(10):
  lst.append(int(input()))
lst = sort(lst)
print("%d\n%d\n%d"%(lst[0],lst[1],lst[2]))

Measured memory_bytes: 4236
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
vector<int> init() {
    queue<int> q;
    vector<int> res;
    q.push(3);
    q.push(5);
    q.push(7);
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        res.push_back(cur);

        if (cur<100000000) {
            q.push(cur*10 + 3);
            q.push(cur*10 + 5);
            q.push(cur*10 + 7);
        }
    }
    return res;
}
bool check(int x) {
    int v3=0, v5=0, v7=0;
    while (x) {
        if (x%10 == 3) v3 = 1;
        if (x%10 == 5) v5 = 1;
        if (x%10 == 7) v7 = 1;
        x /= 10;
    }
    return v3 && v5 && v7;
}
int main()
{
    int n, ans;
    vector<int> nums = init();

    while (~scanf("%d", &n)) {
        ans = 0;
        for (int i: nums) if (i<=n && check(i)) ans++;
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
static const int N =100;
void Trace(int A[], int n){
        int i;
        for ( i = 1; i <= n; i++ ) {
                if ( i > 1 ) printf(" ");
                printf("%d", A[i]);
        }
        printf("\n");
}

void Isort(int A[],int n){
        int i,j,v;
        for(i=1; i<=n; i++) {
                v=A[i];
                j=i-1;
                while(j>0 && A[j]>v) {
                        A[j+1]=A[j];
                        j--;
                }
                A[j+1]=v;
                Trace(A,n);
        }

}
int main(){
        int n,i,j;
        int A[N+1];
        scanf("%d",&n);
        for (i=1; i<=n; i++) {
                scanf("%d",&A[i]);
        }
        Isort(A,n);
        return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;cin >> s;
    //aの回数保存　ABCのCをAに置き換え
    lint ans = 0, acount = ((s[0] == 'A')&&(s[1]!='C')) + (s[1] == 'A');
    FOR(i,2,SZ(s)){
        if(s[i-2]=='A'&&s[i-1]=='B'&&s[i]=='C'){
            ans += acount;
            s[i] = 'A';
            continue;
        }

        if (s[i] == 'A')
        {
            if(s[i-1]=='B'){
                acount = 1;
            }else{
                acount++;
            }
        }
        if(s[i]=='B'){
            if(s[i-1]!='A'){
                acount = 0;
            }
        }
        if(s[i]=='C')
            acount = 0;
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 640
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def cnt_div_2(x):
    cnt = 0
    while x > 0:
        if x % 2 == 0:
            x //= 2
            cnt += 1
        else:
            break
    return cnt

def main():
    N, M = map(int, input().split())
    A = list(set(map(int, input().split())))
    cnt_2 = cnt_div_2(A[0])
    for a in A:
        if cnt_div_2(a) != cnt_2:
            print(0)
            exit()


    common = lcm_list(A)
    max_A = max(A)
    cnt = M // common
    if ((2 * cnt + 1) * common) // 2 <= M:
        print(cnt + 1)
    else:
        print(cnt)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 89580
/*
Author:loceaner
*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int A = 1e5 + 11;
const int B = 1e6 + 11;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  for ( ; !isdigit(c); c = getchar()) if (c == '-') f = -1;
  for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  return x * f;
}

int main() {
  int n = read();
  if (n >= 30) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 3632