akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
#define all(x) (x).begin(), (x).end()


int main() {
	ifstream fin("Text.txt");
	int i, j, q;
	DT a,b,c,d,n,m,k,t,ans=1,ans2=1,mod=1000000007;
	string st;
	cin >> n >> m;
	//scanf("%I64d", &n);
	//scanf("%d%d", &n,&m);
	if (n - m == 0) {
		forn(i, n) {
			ans *= (i + 1);
			ans %= mod;
		}
		forn(i, n) {
			ans *= (i + 1);
			ans %= mod;
		}
		ans *= 2;
		ans %= mod;
	}
	else if (abs(n - m) == 1) {
		forn(i, n) {
			ans *= (i + 1);
			ans %= mod;
		}
		forn(i, m) {
			ans *= (i + 1);
			ans %= mod;
		}
	}else {
		ans = 0;
	}

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
    int n;

    cin >> n;
    
    cout << n * (n + 1) / 2 << endl;
}

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

int main(){
  int a,b;
    cin >> a >> b;
  while(a - 500 >= 0){
    a -= 500;
  }
  if(a <= b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// aribon2-6-1_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    REP(i, N) cin >> A[i];

    if (*max_element(ALL(A)) < K) {
        print("IMPOSSIBLE");
        return 0;
    }

    int d = A[0];
    REPN(i, 1, N){
        d = gcd(A[i], d);
    }

    if (K % d == 0){
        print("POSSIBLE");
    }else {
        print("IMPOSSIBLE");
    }

    return 0;
}


Measured memory_bytes: 640
// abc095_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,x,m;
  cin>>n>>x;
  int m_min=1000;
  rep(i, n) {
    cin>>m;
    x-=m;
    m_min=min(m,m_min);
  }
  cout<<n+x/m_min<<endl;

  return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int m1,m2,d1,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(d2-d1==1)cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    readline = sys.stdin.buffer.readline

    from collections import deque

    h, w = map(int, readline().split())
    s = [readline().rstrip().decode('utf-8') for _ in range(h)]

    l = []
    for i in range(h):
        for j in range(w):
            if s[i][j] == '.':
                l.append((i, j))
    dire = ((0, 1), (0, -1), (1, 0), (-1, 0))
    q = deque()
    ans = 0
    for hh, ww in l:
        q.appendleft((hh, ww, 0))
        c = [[0]*w for _ in range(h)]
        while q:
            ha, wa, ca = q.pop()
            if c[ha][wa] == 0:
                c[ha][wa] = 1
                ans = max(ans, ca)
                for dh, dw in dire:
                    hdh, wdw = ha+dh, wa+dw
                    if 0 <= hdh < h and 0 <= wdw < w:
                        if s[hdh][wdw] == '.' and c[hdh][wdw] == 0:
                            q.appendleft((hdh, wdw, ca+1))
    print(ans)

main()

Measured memory_bytes: 9408
#include <iostream>

using namespace std;

int main()
{
    int n = 100001;
    bool prime[n];
    int c[n+1];

    for (int i = 2; i < n; i++) {
        prime[i] = true;
    }

    for (int i = 2; i < n; i++) {
        if (prime[i] == false) continue;
        for (int j = i + 1; j < n; j++) {
            if (j % i == 0) {
                prime[j] = false;
            }
        }
    }

    for (int i = 3; i < n; i += 2) {
        if (prime[i] && prime[(i+1)/2]) {
            c[i]++;
        }
    }
    for (int i = 3; i < n; i++) {
        c[i] += c[i-1];
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%d\n", c[r] - c[l-1]);
    }

    return 0;
}

Measured memory_bytes: 1152
n=int(input())
v_list=list(map(int,input().split()))
c_list=list(map(int,input().split()))
get=0
for i in range(n):
    if v_list[i]-c_list[i]>0:
        get=get+v_list[i]-c_list[i]
print(get)

    
        


Measured memory_bytes: 38384
#include <iostream>
#include <stdbool.h>
#define N 8
#define NOT_FREE 1
#define FREE -1

using namespace std;

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
bool cb[N][N];

void initialize(){
    for(int i = 0; i < N; i++){
        row[i] = FREE;
        col[i] = FREE;
        for(int j = 0; j < N; j++) cb[i][j] = false;
    }
    for(int i = 0; i < 2*N-1; i++){
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard(){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(cb[i][j]){
                if(row[i] != j) return;
            }
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(row[i] == j) cout << 'Q';
            else cout << '.';
        }
        cout << endl;
    }
}

void putQueen(int i){
    if(i == N){
        printBoard();
        return;
    }

    for(int j = 0; j < N; j++){
        if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;
        row[i] = j;
        col[j] = NOT_FREE;
        dpos[i+j] = NOT_FREE;
        dneg[i-j+N-1] = NOT_FREE;
        putQueen(i+1);
        row[i] = FREE;
        col[j] = FREE;
        dpos[i+j] = FREE;
        dneg[i-j+N-1] = FREE;
    }
}

int main(){
    int k, r, c;
    initialize();
    cin >> k;
    for(int i = 0; i < k; i++){
        cin >> r >> c;
        cb[r][c] = true;
    }
    putQueen(0);
    return 0;
}


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

#define FILE
#define fr first
#define se second

using namespace std;

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

int k;
int n;
int res;
int a[N];
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> k >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
    }
    res = k - a[n] + a[1];
    for(int i = 2; i <= n; i ++){
        res = max(res, a[i] - a[i - 1]);
    }
    cout << k - res << "\n";
}



Measured memory_bytes: 1024
/*  Author : Alpha_The_Coder
    Created on 29/08/2020      */
#include <bits/stdc++.h>
using namespace std;
#define iamalpha ios_base::sync_with_stdio(false);cin.tie(NULL);
#define loop(a,n) for(int i=a;i<n;i++)
#define nloop(a,n) for(int j=a;j<n;j++)
#define lli long long int
void solve();
int main()
{
    iamalpha;
    int t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
}
void solve()
{

    string s,subs;
    cin>>s>>subs;
    int length=subs.size();
    int n=s.size();

            int cnt=0;
            int ans=0;
            // Sliding algorithm

           for(int i=0;i<=n-length;i++)
           {
               cnt=0;
               int current=i;
               for(int j=0;j<length;j++,current++)
               {
                   if(subs[j]==s[current])
                    cnt++;
               }
               ans=max(cnt,ans);
           }
           cout<<length-ans;

}
// Solely contributed by Subhojeet Sahoo aka Alpha


Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

uint64_t mygcd(uint64_t lhs, uint64_t rhs) {
  if (lhs % rhs == 0) {
    return rhs;
  } else {
    return mygcd(rhs, lhs % rhs);
  }
}

int main() {
  uint64_t A, B, C, D;
  cin >> A >> B >> C >> D;
  uint64_t E = C / mygcd(C, D) * D;
  uint64_t ansC = B / C - (A - 1) / C;
  uint64_t ansD = B / D - (A - 1) / D;
  uint64_t ansE = B / E - (A - 1) / E;
  cout << (B - A + 1 - ansC - ansD + ansE) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int A, B, K;
    cin >> A >> B >> K;
    int ans;
    int count = 0;
    for(int i=min(A, B); i>0; i--){
        if(A%i==0 && B%i==0){
            count++;
            //cout << i << endl;
        }
        if(count == K){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;

		try {
			while ((line = br.readLine()) != null) {
				line = line.trim();
				int num = Integer.parseInt(line);
				if (num < 0 || num > 50)
					System.exit(-1);

				int count = 0;
				if (num / 4.0 <= 9.0) {
					for (int a = 0; a < 10; a++) {
						for (int b = 0; b < 10; b++) {
							for (int c = 0; c < 10; c++) {
								for (int d = 0; d < 10; d++) {
									if(a + b + c + d == num) count++;
								}
							}
						}
					}
				}
				System.out.println(count);
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	static int factorial(int n) {
		if (n == 1)
			return 1;
		else {
			return n * factorial(n - 1);
		}
	}
}

Measured memory_bytes: 18856
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#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 RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;
 
ll inv[MAX_N], fac[MAX_N];
 
template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }
 
typedef pair<int, pair<int, int>> edge;
 
class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};
 
 
 
class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};
 
 
 
//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}
 
ll UnionFind::size(int x) {
	return -par[find(x)];
}
 
void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);
 	if (x == y) return;
	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}
 
bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}
 
 
 
//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}
 
void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}
 
 
 

signed main() {
	int n,m; cin >> n >> m;
	UnionFind uf(n);
	REP (i,m) {
		int x,y,z; cin >> x >> y >> z;
		x--; y--;
		uf.unite(x,y);
	}
	set<int> se;
	REP (i,n) {
		se.insert(uf.find(i));
	}
	cout << se.size() << endl;
}


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

 using namespace std;
 int main() {
   string n;
   int i;
   cin >> n;
   for (i = 0; i < 3; i++){
     if (n.at(i) == '1') n.at(i) = '9';
     else n.at(i) = '1';
   }
   cout << n << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct Combination {
    vector<ll> fac, finv, inv;
    const int mod = 1e9 + 7;
    
    Combination(int n) : fac(n + 1), finv(n + 1), inv(n + 1) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        
        for (int i = 2; i < n; 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 nCr(int n, int k) {
        if ((n < k) || (n < 0) || (k < 0)) {
            return 0;
        }
        
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Combination c(2020);
    const ll mod = 1e9 + 7;
    int n, k;
    cin >> n >> k;
    reps(i, 1, k + 1) {
        cout << (c.nCr(n - k + 1, i) * c.nCr(k - 1, i - 1)) % mod << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc112_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int m = input[1];

            int ans = 1;
            for (int i = 1; i*i <= m; i++)
            {
                if(m % i == 0){
                    int x = m / i;
                    if((long)i*n <= m) ans = Max(ans, i);
                    if((long)x*n <= m) ans = Max(ans, x);
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int A[4][4], N, b[12];

int main() {

	rep(i, 3) rep(j, 3)
		cin >> A[i][j];
	cin >> N;
	rep(i, N) cin >> b[i];

	rep(n, N)
		rep(i, 3) rep(j, 3) {
		if (A[i][j] == b[n]) A[i][j] = 0;
	}

	rep(i, 3) if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	rep(i, 3) if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) {
		cout << "Yes" << endl;
		return 0;
	}


	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

ll s[1001];

int main() {
	int a, b;
	cin >> a >> b;
	int ans = max(a - b, max(a + b, a* b));
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define aaa cout<<233<<endl;
#define endl '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
// mt19937 rnd(TM(0));
const int inf = 0x3f3f3f3f;//1061109567 > 1e9
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const double pi = 3.14159265358979;
const int maxn = 1e5 + 5;
const int maxm = 5e5 + 233;
const int mod = 1e9 + 7;

int n, a[maxn];
int main()
{
    // double pp = clock();
    // freopen("233.in", "r", stdin);
    // freopen("233.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    
    cin >> n;
    for(int i = 1; i <= 9; ++i){
        for(int j = 1; j <= 9; ++j){
            if(i * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
    // cout << endl << (clock() - pp) / CLOCKS_PER_SEC << endl;
    return 0;
}

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

	long long int n;
	long long int a[200005];
	long long f(long long b)
	{
		long long int s=0;
		for(int i=0;i<n;i++)
		{
			s+= abs(a[i]-(b+i+1));
		}
		return s;
	}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);

	cin>>n;

	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	//cout<<abs(*max_element(a,a+n)-*min_element(a,a+n))<<endl;
	long long l=-1000000000,r=1000000000,m,res,v1,v2,v3;
	while(l<=r)
	{
		m= (l+r)/2;
		v1 = f(m-1);
		v2= f(m);
		v3 = f(m+1);
		if(v2<=v1 && v2<=v3)
            {
                res = m;
                r=m-1;
            }
            if(v2<=v1 && v3<=v2)
            {
                l=m+1;
            }
            else
            if(v1<=v2 && v2<=v3)
            {
                r=m-1;
            }
	}
	/*
	for(int b=-100;b<=100;b++)
	{
		cout<<b<<" ";
		int s=0;
		for(int i=0;i<n;i++)
		{
			s+= abs(a[i]-(b+i+1));
		}
		cout<<s<<endl;
	}
	*/
	cout<<f(res)<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <set>
#include <stack>
#include <string>
using namespace std;
typedef long long ll;

void solve() {
	int N,X,T;
	cin >> N >> X >> T;
	cout << ((N%X == 0) ? (N/X)*T : (N/X+1)*T) ;
}

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

Measured memory_bytes: 3136
#include <iostream>

int main() {
int n;
std::cin >> n;
for(int i = 1; i <= n; i++) {
int x = i;
for(int j = 1; x > 0; j++) {
if(i % 3 == 0) {
std::cout << ' ' << i;
break;
}
else if(x % 10 == 3) {
std::cout << ' ' << i;
break;
}
x /= 10;
}
}
std::cout << std::endl;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int f[1000][1000], dat[1000][1000];
int x[1000001], y[1000001];
int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

int main() {
	int h, w; scanf("%d%d", &h, &w);
	rep(i, h)rep(j, w) {
		scanf("%d", &f[i][j]);
		x[f[i][j]] = i; y[f[i][j]] = j;
	}
	rep(i, h)rep(j, w) {
		bool ok = true;
		rep(k, 4) {
			int nx = i + dx[k], ny = j + dy[k];
			if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&f[nx][ny] < f[i][j])ok = false;
		}
		if (ok)dat[i][j] = f[i][j];
	}
	int ans = 0;
	for (int i = 1; i <= h*w; i++) {
		rep(j, 4) {
			int nx = x[i] + dx[j], ny = y[i] + dy[j];
			if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&f[x[i]][y[i]] > f[nx][ny]) {
				if (dat[x[i]][y[i]] == 0)dat[x[i]][y[i]] = dat[nx][ny];
				else if (dat[x[i]][y[i]] != dat[nx][ny])dat[x[i]][y[i]] = -1;
			}
		}
		if (dat[x[i]][y[i]] == -1)ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 18840
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  int n; cin >> n;
  deque<ll> dq;
  bool rev = false;
  rep(i,n){
    ll a;
    cin >> a;
    if(rev){
      dq.push_front(a);
    }else{
      dq.push_back(a);
    }
    rev = !rev;
  }
  if(rev) reverse(All(dq));
  for(int i=0;i<n;i++) cout << dq[i] << ((i==n-1)?"\n":" ");
}

Measured memory_bytes: 3840
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<numeric>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#define int long long
#define inf 8938103643641919514ll
#define oku 1000000007ll
using namespace std;
int a,b,c,d,e,f,g,n,m;
int dx[]={0,-1,0,1,0};
int i,j,k;
int p[2];
signed main(){
	cin>>n;
	for(i=0;i<n;i++){
		int u;
		cin>>u;
		p[u%2]++;
	}
	if(p[1]%2==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {

	int n,f, num=0;
	cin >> n;
	for (int i = 0; i < n; i++) {

		cin >> f;
		if ((i+1) % 2 != 0 && f % 2 != 0)
			num++;

	}
	cout << num;



}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int cnt=0;
		for(int i=0;i<S.length-1;i++){
			if(S[i]!=S[i+1]) cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 25672
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }

    aa.forEach {
        if (it % 2 == 0 && it % 3 != 0 && it % 5 != 0) {
            println("DENIED")
            return
        }
    }

    println("APPROVED")
}


Measured memory_bytes: 38000
// #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 ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  string s, t;
  cin >> s;
  for (auto &&si : s) {
    if (si != 'B') {
      t.push_back(si);
    } else if (!t.empty()) {
      t.pop_back();
    }
  }
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,b;
 vector<ll>a;
 sc(n);
 rep(i,0,5){sc(b);push(a,b);}
 sort(a);
 if(a[0]>n)ans=5;
 else ans=4+cei(n,a[0]);
 pr(ans);
  
  return 0;}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}


int main(){
	dclt(string,s);
	int ans=0;
	for(auto c:s){
	    ans+=(c=='p'?-1:1);
	}
	cout<<ans/2<<endl;
	
}


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

int main(){
 string s,p;
 cin >> s >> p;
 for(int i=0; i<s.size(); i++){
         for(int j=0; j<p.size() && s[(i+j)%s.size()] == p[j]; j++){
             if(j == p.size()-1) {
                 cout << "Yes" << endl;
                 return 0;
             }
         }
 }
cout << "No" << endl;
return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int s1[250010],s2[250010];
int main(){
    int h,w;cin>>h>>w;
    int g1=0;if(h%2&&w%2)g1=1;
    int g2=(h/2)*(w%2)+(w/2)*(h%2);
    int g4=(h/2)*(w/2);
    int c[26]={};
    for(int i=0;i<h;i++){
        char cc[110];
        cin>>cc;
        for(int j=0;j<w;j++){
            c[cc[j]-'a']++;
        }
    }
    for(int i=0;i<26;i++){
        if(g4>0){
            g4-=c[i]/4;
            c[i]%=4;
        }
        if(g2>0){
            g2-=c[i]/2;
            c[i]%=2;
        }
        if(g1>0){
            g1-=c[i];
            c[i]=0;
        }
        if(c[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;

class Program {
    static void Main (string[] args) {
        int N = int.Parse (Console.ReadLine ());
        string[] input1 = new string[N];
        for (int i = 0; i < N; i++) {
            input1[i] = Console.ReadLine ();
        }
        Hashtable hashtable = new Hashtable ();

        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (!hashtable.ContainsKey (input1[i])) {
                ans++;
                hashtable.Add (input1[i], 0);
            }
        }

        Console.WriteLine (ans);

    }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, k, a[100000];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> a[i]; }
	
	sort(a, a + n);
	
	int mi = 2e9;
	inc(i, n - k + 1) {
		setmin(mi, a[i + k - 1] - a[i]);
	}
	
	cout << mi << endl;
	
	return 0;
}


Measured memory_bytes: 640
# coding: utf-8

height, width = map(int, input().split())

for i in range(width+2):
    print("#", end='')
    
print("")

for j in range(height):
    print("#", end='')
    str = input()
    print(str, end='')
    print("#")


for l in range(width+2):
    print("#", end='')

Measured memory_bytes: 9052
# Your code here!
n=int(input())

a_list=[int(i) for i in input().split()]
count_list=[]

for i in range(n):
    num=a_list[i]
    count=0
    while True:
        if num%2==0:
            num//=2
            count+=1
        else:
            break
    count_list.append(count)

#print(count_list)   
print(min(count_list))

Measured memory_bytes: 9180
n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a-=1; b-=1
    g[a].append(b)
    g[b].append(a)

for i in range(n):
    print(len(g[i]))

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

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


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <climits>
#include <cstring>
#include <algorithm>
#define N 56
using namespace std;

int top=0,S[1000];

void push(int x)
{
    S[++top]=x;
}

int pop()
{
    top--;
    return S[top+1];
}

int main()
{
    int a,b;
    char s[100];

    while(scanf("%s",s)!=EOF)
    {
        if(s[0]=='+')
        {
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(s[0]=='-')
        {
            a=pop();
            b=pop();
            push(b-a);
        }
        else if(s[0]=='*')
        {
            a=pop();
            b=pop();
            push(a*b);
        }
        else
        {
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
}



Measured memory_bytes: 3236
import math
def is_prime(n):
    if n==2:
        return True
    if n%2==0:
        return False
    for i in range(3,int(math.sqrt(n))+1,2):
        if n%i==0:
            return False
    return True
if __name__=="__main__":
    x=input()
    x=int(x)
    res=x
    while True:
        if is_prime(res):
            print(res)
            break
        res+=1

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

int main() {
	string s;
	cin >> s;
	if (s.substr(0, 4) == "YAKI") puts ("Yes");
	else puts ("No");
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = 0
    for i in range(5):
        res = (N + A[i] - 1) // A[i] + 4
        if ans < res:
            ans = res

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
	int n,m,b,c;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
	}
	cin>>m;
	for(int i=0; i<m; i++)
	{
		cin>>b>>c;
		long long sum=0;
		for(int j=1; j<=n; j++)
		{
			if(j==b)
			sum+=c;
			else
			sum+=a[j];
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.append(X)
D = abs(X-x[0])
x.sort()


def GCD(x, y):
    a = max(x, y)
    b = min(x, y)
    r = a % b

    if r == 0:
        return b
    else:
        return GCD(b, r)

for ni in range(N):
    dif = x[ni+1] - x[ni]
    D = GCD(dif, D)

print(D)

Measured memory_bytes: 14252
import scala.io.Source
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    val lines = for{
      in <- Source.stdin.getLines.toList
    }yield in.split(" ").toList.map(_.toInt)

    if(lines.length <= 2){
      val tup = hitAndBlow(lines.head, lines.last)
      println(tup._1 + " " + tup._2)
    }
    else{
      mulHitAndBlow(lines, List()).reverse.foreach{tup => println(tup._1 + " " + tup._2)}
    }
  }

  @tailrec
  def mulHitAndBlow(list: List[List[Int]], tupList: List[(Int, Int)]): List[(Int, Int)]={
    if(list.isEmpty) tupList
    else mulHitAndBlow(list.tail.tail, hitAndBlow(list.head, list.tail.head) :: tupList)
  }

  def hitAndBlow(list1: List[Int], list2: List[Int]): (Int, Int) ={
    val hit = numOfHit(list1, list2, 0)
    (hit, numOfBlow(list1, list2, 0) - hit)
  }

  @tailrec
  def numOfHit(list1: List[Int], list2: List[Int], n: Int): Int={
    if(list1.isEmpty) n
    else if(list1.head == list2.head) numOfHit(list1.tail, list2.tail, n + 1)
    else numOfHit(list1.tail, list2.tail, n)
  }

  @tailrec
  def numOfBlow(list1: List[Int], list2: List[Int], n: Int): Int={
    if(list2.isEmpty) n
    else if(checkBlow(list1, list2.head)) numOfBlow(list1, list2.tail, n + 1)
    else numOfBlow(list1, list2.tail, n)
  }

  def checkBlow(list1: List[Int], n :Int): Boolean = list1.contains(n)
}

Measured memory_bytes: 44116
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int L = S.length();
		int Ucount = 0;
		int Ccount = 0;

		for(int i=0; i<L; i++) {
			if(Character.isUpperCase(S.charAt(i))){
				Ucount += 1;
			}
		}

		for(int j=2; j<L-1; j++) {
			if(S.charAt(j) == 'C') {
				Ccount += 1;
			}
		}

		if(Ucount == 2 && Ccount ==1) {
			if(S.charAt(0) == 'A') {
				System.out.println("AC");
			}else {
				System.out.println("WA");
			}
		}else {
			System.out.println("WA");
		}

	}

}


Measured memory_bytes: 21972
def comb(n, r, mod):
    denominator = 1
    numerator = 1
    for i in range(1, r + 1):
        denominator *= i
        denominator %= mod
    for i in range(n - r + 1, n + 1):
        numerator *= i
        numerator %= mod
    return (numerator * pow(denominator, mod - 2, mod)) % mod


def main():
    all_balls, blue_balls = map(int, input().split())
    mod = 10 ** 9 + 7
    for i in range(1, blue_balls + 1):
        print((comb(all_balls - blue_balls + 1, i, mod) * comb(blue_balls - 1, i - 1, mod)) % mod)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		double sum = 0.0;
		for(int i = 0; i < n; ++i){
			sum += 1.0 / sc.nextInt();
		}
		
		double ans = 1.0 / sum;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21204
n = int(input())
h = list(map(int, input().split()))
for i in reversed(range(n-1)):
    if h[i+1] == h[i] - 1:
        h[i] = h[i] - 1
flag = True
for i in range(n-1):
    if h[i+1] < h[i]:
        flag = False
        break
if flag == True:
    print('Yes')
else:
    print('No')

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

#define pb push_back
const int inf=0x3f3f3f3f;
const int N=10,M=1000;
int n,m,s;
char a[N+1][M+5];

int main()
{
	cin>>n>>m>>s;
	for(int i=1;i<=n;i++)
	    cin>>a[i]+1;
	int ans=inf;
	for(int i=0;i<1<<n-1;i++)
	{
		vector<int> pos;
		pos.pb(0);
		for(int j=1;j<n;j++)
		    if(i&1<<j-1)
			    pos.pb(j);
		pos.pb(n);
		int now=pos.size()-2;
		vector<int> cnt(pos.size()-1,0);
		for(int j=1;j<=m;j++)
		{
			bool ok=true; 
			vector<int> cnt0(pos.size()-1,0);
			for(int k=0;k<cnt.size();k++)
			{ 
				for(int o=pos[k]+1;o<=pos[k+1];o++)
				    cnt0[k]+=a[o][j]^48;
				if(cnt0[k]>s)
				    goto label_end;
				if(cnt[k]+cnt0[k]>s)
				    ok=false;
			}
			if(ok)for(int k=0;k<cnt.size();k++)cnt[k]+=cnt0[k];
			else now++,cnt=cnt0;
		}
		ans=min(ans,now);
	label_end:;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
def check(ymd,y,m,d):
        if ymd < 18680908:
            print "pre-meiji"
        elif ymd < 19120730:
            print "meiji",y-1867,m,d
        elif ymd < 19261225:
            print "taisho",y-1911,m,d
        elif ymd < 19890108:
            print "showa",y-1925,m,d
        else:
            print "heisei",y-1988,m,d

while True:
    try:
        y, m, d = map(int, raw_input().split())
        ymd = 10000*y + 100*m + d
        check(ymd,y,m,d)
    except:
        break

Measured memory_bytes: 4212
#include <algorithm>
#include <cstdlib>
#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long d, m;
    cin >> d >> m;
    long long diff = abs(d - m);
    if (diff >= 2) {
        cout << 0 << '\n';
    } else {
        const long long p = int(1e9) + 7;
        long long f[100000 + 1];
        f[0] = 1;
        long long bound = max(d, m);
        for (int i = 1; i <= bound; ++i) {
            f[i] = (i * f[i - 1]) % p;
        }
        if (diff == 1) {
            cout << (f[d] * f[m]) % p << '\n';
        } else {
            cout << (2 * ((f[d] * f[m]) % p)) % p << '\n';
        }
    }
    return 0;
}


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


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string str;
	cin>>str;
	if(str=="SUN")cout<<7<<endl; 
	else if(str=="SAT")cout<<1<<endl;
	else if(str=="FRI")cout<<2<<endl;
	else if(str=="THU")cout<<3<<endl;
	else if(str=="WED")cout<<4<<endl;
	else if(str=="TUE")cout<<5<<endl;
	else if(str=="MON")cout<<6<<endl;
	return 0;
}

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


		int n;
		string s;
		cin >> n >> s;
		int red = 0,white = 0;
		for(int i = 0;i < n; i++){
			red += (s[i] == 'R');
		}
		for(int i = 0; i < red; i++){
			white += (s[i] == 'W');
		}
		cout << white << "\n";


	return 0;
}


Measured memory_bytes: 3712
//#include <iostream>
//#include <bits/stdc++.h>
//#include <cmath>
//#include <cstdlib>
//#include <vector>
//using namespace std;
//int main(){
//  int t;
//  
//  scanf("%d",&t);
//  int k;
//  scanf("%d",&k);
//  int arr[t];
//  for(int i=0;i<t;i++){
//    scanf("%d",&arr[i]);
//  }
//  int dp[t];
//  for(int i=0;i<t;i++){
//  	dp[i]=10e4;
//  }
//  
//  
//  	
//}
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;
int main(){
  int t;
  int k;
  scanf("%d %d",&t,&k);
  
  int arr[t];
  for(int i=0;i<t;i++){
    scanf("%d",&arr[i]);
  }
  int dp[t];
  for(int i=0;i<t;i++){
  	dp[i]=INT_MAX;
  }
  dp[0]=0;
  for (int i=1;i<t;i++){
  	int j=1;
  	while(i-j>=0 and j<=k){
  		dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
  		j++;
	}
  }
  cout<<dp[t-1];
  	
}

Measured memory_bytes: 4528
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000000;
    public static void Main()
    {
        long[] box = SpRead(' ').Select(long.Parse).ToArray();
        long N = box[0], x = box[1];
        box = SpRead(' ').Select(long.Parse).ToArray();
        long ans = 0;
        long cost = 0;
        for (int i = 0; i < N - 1; i++)
        {
            if (box[i] + box[i + 1] > x)
            {
                cost = box[i] + box[i + 1] - x;
                ans += cost;
                if (cost > box[i + 1])
                {
                    box[i + 1] = 0;
                }
                else box[i + 1] -= cost;
            }
            //box.ToList().ForEach(v => Console.Write(v));
            //Console.WriteLine(" : " + cost);
        }
        Console.WriteLine(ans);

    }
}

public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
}


Measured memory_bytes: 31452
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
   ll n;
   cin >> n;
   ll sum[n+1],s=0,a[n];
   for(ll i=0;i<n+1;i++) sum[i]=0;
   for(ll i=0;i<n;i++) cin >>a[i];
   sum[n]=0;
   for(ll i=n-1;i>=0;i--) sum[i]+=(sum[i+1]+a[i]);
   ll ans=1e10,k;
   for(ll i=1;i<n;i++){
      k=abs(sum[0]-2*sum[i]);
      ans=min(k,ans);
   }
   cout <<ans<<endl;
}


Measured memory_bytes: 3328