akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



const int M_N=200000;

struct BIT{
    //1-indexed
    LL bit[M_N+1],n;
    //iまでの総和を返す
    LL sum(int i){
        LL s=0;
        while(i>0){
            s=(s + bit[i])%mod;
            i=i&(i-1);
        }
        return s;
    }
    //iにx加算する
    void add(int i,LL x){
        x %= mod;
        while(i<=n){
            bit[i]=(bit[i] + x)%mod;
            i+=i&-i;
        }
    }

};

int main(){
    int n;
    LL A,B;
    cin >> n >> A >> B;
    vector<LL> s(n+1,-LINF);
    for (int i = 0; i < n; i++) {
        cin >> s[i+1];
    }
    BIT bit[2];
    bit[0].n = bit[1].n = n + 1;
    bit[0].add(1,1);
    bit[1].add(1,1);
    int la = 1, lb = 1;
    for (int i = 1; i < n; i++) {
        auto x = upper_bound(ALL(s),s[i+1] - A) - s.begin();
        bit[0].add(i + 1,bit[1].sum(min(i,(int)x)));
        auto y = upper_bound(ALL(s),s[i+1] - B) - s.begin();
        bit[1].add(i + 1,bit[0].sum(min(i,(int)y)));
        if(s[i+1] < s[i] + A){
            for (int j = la; j <= i; j++) {
                bit[0].add(j,mod-bit[0].sum(j)%mod);
            }
            la = i + 1;
        }
        if(s[i+1] < s[i] + B){
            for (int j = lb; j <= i; j++) {
                bit[1].add(j,mod-bit[1].sum(j)%mod);
            }
            lb = i + 1;
        }
    }
    cout << (bit[0].sum(n + 1) + bit[1].sum(n + 1))%mod << endl;
    return 0;
}


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

int main(){
    int h,n;
    scanf("%d",&h);
    scanf("%d",&n);
    int a[n];
    for(int i = 0;i < n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    while(n--)
        h-=a[n];
    printf("%s",h<=0?"Yes":"No");
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

long int power(long int x, long int n, long int M);

int main(void){
  long int m, n, ans;

  scanf("%ld%ld", &m, &n);
  ans = power(m, n, 1000000007);
  printf("%ld\n", ans);
  return 0;
}

long int power(long int x, long int n, long int M){
  long int tmp;

  if(n == 0){
    return 1;
  }
  tmp = power(x*x%M, n/2, M);
  if(n % 2 == 1){
    tmp = tmp * x % M;
  }
  return tmp;
}

Measured memory_bytes: 596
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: i32,
        k: i32,
        h: [i32; n]
    }
    let mut ans = 0;
    for i in h.iter() {
        if k <= *i {
            ans += 1;
        }
    }

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


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

namespace DontbeLate
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(double.Parse).ToList();
            var D = input[0];
            var T = input[1];
            var S = input[2];

            if(Math.Ceiling(D / S) <= T)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 28264
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int n = sc.nextInt();
                int x = sc.nextInt();
                if(n == 0 && x == 0){
                    break;
                }

                int answer = 0;

                for(int i=1; i<=n; i++){
                    for(int j=i+1; j<=n; j++){
                        for(int k = j+1; k <= n; k++){
                            if(i + j + k == x){
                                answer++;
                            }
                        }
                    }
                }
                System.out.println(answer);
            }
        }
    }
}


Measured memory_bytes: 26652
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

vector<double> widths(const vector<int>& xs, int n, int *x, int *y) {
    vector<double> r;
    rep(i, xs.size()) {
        double miny = 1e100, maxy = -1e100;
        rep(j, n) {
            const int k = (j+1)%n;
            if(x[j]==xs[i]) {
                miny = min(miny, (double)y[j]);
                maxy = max(maxy, (double)y[j]);
            }
            else if(min(x[j], x[k])<=xs[i] && xs[i]<=max(x[j], x[k])) {
                const double dx = x[k]-x[j], dy = y[k]-y[j];
                const double cy = y[j]+dy/dx*(xs[i]-x[j]);
                miny = min(miny, cy);
                maxy = max(maxy, cy);
            }
        }
        r.push_back(maxy-miny);
    }
    return r;
}

double calc(double x, double y, double z1, double z2) {
    if(z1<z2) return x*y/2*z1 + x*y/2*(z2-z1)/3;
    else return x*y/2*z2 + y*(z1-z2)*x/3;
}

int m, mx[200], my[200], n, nx[200], nz[200];

int main() {
    for(;;) {
        scanf("%d%d", &m, &n);
        if(m==0 && n==0) return 0;
        rep(i, m) scanf("%d%d", mx+i, my+i);
        rep(i, n) scanf("%d%d", nx+i, nz+i);

        vector<int> xs;
        rep(i, m) xs.push_back(mx[i]);
        rep(i, n) xs.push_back(nx[i]);
        sort(xs.begin(), xs.end());
        xs.erase(unique(xs.begin(), xs.end()), xs.end());
        vector<double> yw(widths(xs, m, mx, my));
        vector<double> zw(widths(xs, n, nx, nz));

        double ans = 0;
        rep(i, xs.size()-1) {
            const double x = xs[i+1]-xs[i];
            const double y1 = yw[i], y2 = yw[i+1];
            const double z1 = zw[i], z2 = zw[i+1];
            if(y1<0 || y2<0 || z1<0 || z2<0) continue;
            ans += (z1+z2)*x/2 * min(y1, y2);
            if(y1>y2) ans += calc(x, y1-y2, z1, z2);
            else ans += calc(x, y2-y1, z2, z1);
        }
        printf("%.12f\n", ans);
    }
}

Measured memory_bytes: 0
from collections import deque

N, L = map(int, input().split())
*list, = map(int, input().split())

ans = []

que = deque()
for i, num in enumerate(list):
    while que and num <= que[-1][1]:
        que.pop()
    que.append((i, num))

    ans.append(que[0][1])

    if que and que[0][0] <= i+1-L:
        que.popleft()

print(*ans[L-1:])



Measured memory_bytes: 126652
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

int main() {
    int n, l;
    string s[101];
    cin>>n>>l;
    REP(i, 0, n) cin>>s[i];

    sort(s, s+n);
    REP(i, 0, n){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

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

char f[60][60];
int c[60][60];
int h,w;
int dy[4]={1,0,-1,0},dx[4]={0,1,0,-1};

bool contain(int y,int x){
    return (0<=y && y<h && 0<=x && x<w);
}
void dfs(int y,int x,int cost){
    if(!contain(y,x) || f[y][x]=='#')return ;
    if(c[y][x]>cost){
        c[y][x]=cost;
        for(int i=0;i<4;i++){
            dfs(y+dy[i],x+dx[i],cost+1);
        }
    }
}

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

    cin>>h>>w;
    int ans=h*w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>f[i][j];
            if(f[i][j]=='#')ans--;
            c[i][j]=INF;
        }
    }
    dfs(0,0,0);
    ans-=c[h-1][w-1]+1;
    if(c[h-1][w-1]==INF)ans=-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string S;
	cin>>S;
	int hi=0;
	int z=S.size();
	for(int i=0;i<z;i+=2)
	{
		if(S.substr(i,2)=="hi")
		hi++;
	}	
	if(hi*2==z)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s1[105],s2[105];
int main(){
    int n;
    scanf("%d",&n);
    int ans=n*2;
    scanf("%s%s",s1,s2);
    for(int i=0;i<n;i++){
        int tmp=i;
        int flag=1;
        for(int j=0;j<n-i;j++){
            //printf("%d,%d,",i+j,j);
            if(s1[i+j]!=s2[j]){
                flag=0;
            }
        }
        if(flag){
            ans=n+i;
            break;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = n/(a + b) * a;
    n %= (a + b);
    ans += min(n,a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) cout << 'x';
  cout << endl;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e6) + 17;

int n;
int a[MAXN];

bool read() {
    if (!(cin >> n))
        return false;
    
    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    int sum = accumulate(a, a + n, 0);
    int kek = INF;

    forn (i, n)
        kek = min(kek, abs(sum - n * a[i]));

    int ans = -1;

    forn (i, n)
        if (abs(sum - n * a[i]) == kek && ans == -1)
            ans = i;

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 256
N=int(input())
S=input()
a=[0]
for i in range(N):
    a.append(a[-1])
    if S[i]=='W':
        a[-1]+=1

ans=N
for i in range(N):
    ans=min(ans,a[i]+N-(i+1)-(a[N]-a[i+1]))
print(ans)


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

#define pb push_back
#define mk make_pair
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(S) (S).begin(), (S).end()
#define debug(a) cerr << #a << " = " << a << endl;
#define debug2(a,b) cerr << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugM(M, l, c ) rep( i, 0, l ){ rep( j, 0, c ){ cerr << M[i][j] << " "; } cerr << endl; }
#define debugP(p) cerr << #p << " = " << p.x << " --- " << #p << " = " << p.y << endl;
#define MOD 1000000007
#define MAX 3005

using namespace std;

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

const int INF = 0x3f3f3f3f;

int n;
double v[MAX];
double pd[MAX][MAX];

double solve(int i, int q) {
    if(i == n && n/2 < q) return 1.0;
    if(q+(n-i+1) < n/2) return 0;
    if(i == n) return 0;

    double ans = pd[i][q];
    if(ans > -1) return ans;

    ans = 0;

    ans += solve(i+1, q+1) * (v[i]); //ok
    ans += solve(i+1, q) * (1 - v[i]); //!ok
       
    return ans;
}

double solveIterativo() {
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n/2; j++)
            pd[i][j] = 1.0;          

    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= n/2; j++) {
            pd[i][j] = pd[i-1][j] * v[i];
            if(j)
                pd[i][j] += pd[i-1][j-1] * (1 - v[i]);
        }
    }

    return pd[n][n/2];
}

int main(void) {
	scanf("%i", &n);

    for(int i = 1; i <= n; i++)
        scanf("%lf", &v[i]);

    printf("%.10lf\n", solveIterativo());
	return 0;
}


Measured memory_bytes: 69760
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

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

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];
bool flag[2][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll d, t, s;
	cin >> d >> t >> s;
	if (t * s >= d) {
		puts("Yes");
	}
	else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 3636
import math
n = int(input())
ar = list(map(int,input().split()))
ar.sort()
ar.reverse()
ans = []
i=0
while True:
    if len(ar)-1 <= i or len(ans) >=2:
        break
    if ar[i] == ar[i+1]:
        ans.append(ar[i])
        i+=1
    i+=1
if(len(ans)<2):
    print(0)
else:
    print(ans[0]*ans[1])

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int MOD = 1e9+7;

signed main(){

  int n,w,k; cin >> n >> w >> k;

  int dp[200][10];
  fill(dp[0],dp[0]+200,0);
  dp[0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < (1 << w-1); j++){
      int t = j;
      bool f = 0;
      while(t > 0){
        if(t%4 == 3) f = 1;
        t >>= 1;
      }
      if(f) continue;

      int perm[w];
      for(int k = 0; k < w; k++) perm[k] = k;
      for(int k = 0; k < w-1; k++){
        if(j >> k & 1) swap(perm[k],perm[k+1]);
      }
      for(int k = 0; k < w; k++){
        (dp[i+1][perm[k]] += dp[i][k]) %= MOD;
      }
    }
  }
  cout << dp[n][k-1] << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

def solve():
    N, M = map(int, input().split())

    ncnt = [0]*N

    for i in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a-1, b-1

        ncnt[a] ^= 1
        ncnt[b] ^= 1

    print('NO' if any(ni for ni in ncnt) else 'YES')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3828
def inputs():
    s = input()
    li = s.split(" ")
    return(int(li[0]), int(li[1]))

def lenProg(X, Y):
    count = 0
    if(X <= Y):
        count += 1

    multiX = X * 2
    while(multiX <= Y):
        count += 1
        multiX *= 2

    return(count)

def main():
    X, Y = inputs()
    count = lenProg(X, Y)
    print(count)

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


Measured memory_bytes: 3064
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) { 
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
const int MOD = 1e9 + 7, INF = 1e9 + 5;
inline ll powmod(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)res=res*a%MOD;return res;}
inline ll power(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a)if(b&1)res=res*a;return res;}

const int MAXN = 2e5 + 10;

int a[MAXN];

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = k; i < n; i++){
		if(a[i] > a[i-k])
			cout << "Yes\n";
		else
			cout << "No\n";
	}
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);

            ll a,b;
            cin>>a>>b;
            if(2*b>=a)
            {
                cout<<"0";

            }
            else
            {
                cout<<a-2*b;
            }
            
        
        return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans;
int main()
{
    int a,b,c,n;cin>>a>>b>>c>>n;
    
    for (int i=0;i<=a;i++){
     for (int j=0;j<=b;j++){
      if ((n-i*500-j*100<=c*50)&&(n-i*500-j*100>=0)){
          ans+=1;
      }}}
    cout<<ans<<endl;
    return 0;
}

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

def main():
    def lcm(x, y):
        return x * y // gcd(x, y)

    n = int(input())
    a = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    x = reduce(lcm, a)
    print(sum(x // i for i in a) % mod)

if __name__ == '__main__':
    main()

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

int main()
{
	int N;
	string chipher;

	while(cin >> N)
	{
		if (N == 0) { break; }
		vector<int> keys(N);

		for(int i = 0; i < N; i++) {
			cin >> keys[i];
		}
		cin >> chipher;
		
		for(int i = 0; i < chipher.size(); i++)
		{
			char ans;
			int ii = i % keys.size();
			int diff_i;
			bool upper = true;
			if ('a' <= chipher[i] && chipher[i] <= 'z')
			{
				diff_i = chipher[i] - 'a';
				upper = false;
			}
			else if ('A' <= chipher[i] && chipher[i] <= 'Z')
			{
				diff_i = chipher[i] - 'A';
				upper = true;
			}
			int left_diff_i = diff_i - keys[ii];
			//cout << left_diff_i << " ";
			
			//int left_diff_i = diff_i - keys[ii];
			while(left_diff_i < 0) {
				left_diff_i = 26 + left_diff_i;
				upper = !upper;
			}

			if (upper) {
				cout << (char)('A'+left_diff_i);
			}
			else {
				cout << (char)('a'+left_diff_i);
			}

		}
		cout << endl;
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1204
#include<stdio.h>
int main(void)
{
  int a,x=0,i;
  for (i=0;i<4;i++)
    {
     scanf("%d",&a);
     x=x+a;
    }
  a=x/60;
  i=x%60;
  printf("%d\n%d\n",a,i);
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>

#define N_MAX 100000
#define W_MAX 10000

typedef long long ll;

int ws[N_MAX];
int n;
int k;

bool check(const ll P) {
	ll sum = 0;
	int count = 0;
	for (int i = 0; i < n; ++i) {
		sum += ws[i];
		while (sum > P) {
			sum = ws[i];
			++count;
			if (count == k) {
				return false;
			}
		}
	}
	return true;
}

ll solve() {
	ll begin = 0;
	ll end = N_MAX * W_MAX;

	while (begin < end) {
		ll mid = (begin + end) / 2;
		if (check(mid)) {
			end = mid;
		} else {
			begin = mid + 1;
		}
	}
	return begin;
}

int main() {
	std::cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		std::cin >> ws[i];
	}
	std::cout << solve() << std::endl;

	return 0;
}

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

int main()
{
    string s, t;
    int a, b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(u == s){
        cout << a - 1 << " " << b << endl;
    }else{
        cout << a << " " << b - 1 << endl;
    }
    return 0;

}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    int x, y;
    cin >> x >> y;
    rep(i,x+1){
        int j = x - i;
        if(2*i + 4*j == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200020
int a[1024][1024];
int b[1023][1023];


int main() {
	int n, m;
	int nn, mm;
	a[0][0] = 0;
	int x = 1;
	f(ii, 10) {
		f(i, x) {
			f(j, x) {
				a[x + i][j] = a[i][j];
				a[i][x + j] = a[i][j];
				a[x + i][x + j] = 1 - a[i][j];
			}
		}
					x = x * 2;
	}
	f(i, 1023) {
		f(j, 1023) {
			b[i][j] = (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]) % 2;
		}
	}
	scanf("%d %d", &nn, &mm);
	n = 1;
	m = 1;
	f(i, nn)n = n * 2;
	f(i, mm)m = m * 2;
	n--;
	m--;
	f(i, n) {
		f(j, m) {
			printf("%d", b[i][j]);
		}
		printf("\n");
	}


	return 0;
}

Measured memory_bytes: 9344
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int A;
    int cost1 = 0, cost2 = 0;
    for (int i = 0; i < M; i++) {
        cin >> A;
        if (A < X) {
            cost1 += 1;
        } else {
            cost2 += 1;
        }
    }
    cout << min(cost1, cost2) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = tuple(map(int, input().split()))
x = [[] for _ in range(N + 1)]
for i, a in enumerate(A):
    x[a].append(i)

maxcount = 0
todo = [(1, i) for i in x[1]]
while todo:
    a, i = todo.pop()
    maxcount = max(maxcount, a)
    if a == N:
        continue
    na = a + 1
    for ni in x[na]:
        if ni < i:
            continue
        todo.append((na, ni))
if maxcount > 0:
    print(N - maxcount)
else:
    print(-1)

Measured memory_bytes: 47064
#include<iostream>
using namespace std;
int main()
{
    int l,r,k;
    cin>>l>>r>>k;
    int s=0;
    for(int i=l;i<=r;i++)
    {
        if(i%k==0)
        s++;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define For(i, a, b) for (int i = a; i < b; ++i)
#define Out(i, a, b) for (int i = a - 1; i >= b; --i)
#define pb push_back
#define point pair <int, int>
#define x first
#define y second
#define free free228
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

const string FILENAME = "input";
typedef long long base;
const int MAXN = 2e5 + 1;

int n;
int f[MAXN];
vector <int> edge[MAXN];

int func(int i = 1, int p = -1) {
	int res = 0;
	for (int j : edge[i]) {
		if (p == j) continue;
		res ^= func(j, i) + 1;
	}
	return res;
}

int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(false);
    //read(FILENAME);
    cin >> n;
	for (int i = 2; i <= n; ++i) {
		int a, b;
		cin >> a >> b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	if (func() == 0) {
		cout << "Bob" << endl;
	} else {
		cout << "Alice" << endl;
	}
}

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

using namespace std;

int a[100];

int main() {
    int n, ans = 1e9, i, j;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = -100; i <= 100; i++) {
        int sum = 0;
        
        for (j = 0; j < n; j++) sum += (i - a[j]) * (i - a[j]);
        
        ans = min(ans, sum);
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int h,w;
  cin >> h >> w;
  int ch,cw,dh,dw;
  cin >> ch >> cw >> dh >> dw;
  vector<vector<char>> maze(h+2,vector<char>(w+2,'#'));
  rep1(i,h) rep1(j,w) cin >> maze[i][j];
  int INF = 1001001001;
  vector<vector<bool>> seen(h+2,vector<bool>(w+2,0));
  vector<vector<int>> warp(h+2,vector<int>(w+2,INF));
  deque<pair<int,int>> q;
  q.push_front({ch,cw});
  warp[ch][cw] = 0;
  while(!q.empty()){
    int a = q.front().first;
    int b = q.front().second;
    q.pop_front();
    if(seen[a][b]) continue;
    seen[a][b] = 1;
    for (int i=-2;i<=2;i++){
      for (int j=-2;j<=2;j++){
        int nA = a+i;
        int nB = b+j;
        if(nA<0 || h<nA) continue;
        if(nB<0 || w<nB) continue;
        if(seen[nA][nB]) continue;
        if(maze[nA][nB]=='#') continue;
        bool sub1 = i==-1 && j==0;
        bool sub2 = i==1 && j==0;
        bool sub3 = i==0 && j==-1;
        bool sub4 = i==0 && j==1;
        bool sub = sub1 || sub2 || sub3 || sub4;
        warp[nA][nB] = min(warp[nA][nB],warp[a][b]+!sub);
        pair<int,int> nextQ = {nA,nB};
        if(sub) q.push_front(nextQ);
        else q.push_back(nextQ);
      }
    }
  }
  if(warp[dh][dw]==INF) cout << -1 << endl;
  else cout << warp[dh][dw] << endl;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e7+5;

int main()
{
	int n,W;
	cin>>n>>W;ll wi,vi;
	ll dp[W+10];
	memset(dp, 0, sizeof dp);
	for(int i=0;i<n;i++)
	{
		cin>>wi>>vi;
		for(int x=W;x>=wi;x--)
		{
			dp[x]=max(dp[x-wi]+vi, dp[x]);
		}
	}
	ll a=-1;
	for(int i=0;i<=W;i++)a=max(a,dp[i]);
	cout<<a;
	
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;


int main(){
  ll N;
cin>>N;
double ans=1;
if(N%2==0){
  cout<<ans/2<<endl;
  return 0;
}
if(N==1){
  cout<<1<<endl;
  return 0;
}

cout<<double((N/2)+1)/N<<endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x));
#define SORT(x) sort(ALL(x));
#define SUM(x) accumulate(ALL(A), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef vector<char> VC;
typedef vector<VC> VVC;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll n,m;
	ll result=0;
	cin>>n>>m;
	result=(n-1)*(m-1);
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for _ in range(3)]
s1=sum(c[0])
s2=sum(c[1])
s3=sum(c[2])
s4=c[0][0]+c[1][0]+c[2][0]
s5=c[0][1]+c[1][1]+c[2][1]
s6=c[0][2]+c[1][2]+c[2][2]
for x in [s2-s1, s3-s1, s5-s4, s6-s4]:
    if abs(x)%3 != 0:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
 
using namespace std;
 
int main()
{   
    int h,k;
    cin >> h >> k;
    int a[h];
    long long sum=0;
  	
    for(int i=0;i<h;i++)
        cin >> a[i];
    
    sort(a,a+h);
    for(int i=0;i<h-k;i++)
        sum+=a[i];
    cout << sum;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#define rop(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

ll gcd(ll c, ll d)
{
    return d ? gcd(d, c%d) : c;
}

ll lcm(ll c, ll d)
{
    return c/gcd(c,d)*d;
}

ll f(ll n,ll c,ll d)
{
    ll as = n;
    as -= n / c;
    as -= n / d;
    as += n / lcm(c, d);
    return as;
}

int main()
{
    ll a, b, c, d;
    ll ans;
    cin >> a >> b >> c >> d;

    ans = f(b,c,d) - f(a-1,c,d);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc092_a.cpp
 * time   : Thu Apr 30 18:15:53 2020
 * quest  : A - Traveling Budget
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << "\n";
  return 0;
}

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

int main()
{
    char a, b, c;
    int cnt = 0;
    cin >> a >> b >> c;
        if (a == '1') {
            cnt++;
        }
        if (b == '1') {
            cnt++;
        }
        if (c == '1') {
            cnt++;
        }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

ans = 0
lim = max(A)+1
ok = [True]*lim
checked = [False]*lim

for a in sorted(A):
    if (not checked[a]) and ok[a]:
        checked[a] = True
        for j in range(a*2, lim, a):
            ok[j] = False

cnt = Counter(A)
for a in A:
    if cnt[a] == 1 and ok[a]:
        ans += 1
print(ans)


Measured memory_bytes: 135356
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    int n;
    cin >> n;
    vector<P> p;


    rep(i, n){
        ll x, l;
        cin >> x >> l;
        p.emplace_back(x + l, x - l);
    }
    sort(ALL(p));

    ll now = p[0].first;
    ll res = 1;
    REP(i, 1, n - 1){
        if(p[i].second < now)continue;
        now = p[i].first;
        res++;
    }
    cout << res;
}

Measured memory_bytes: 2420
def main():
    n, m = map(int, input().split())
    if n%2:
        for i in range(1, m+1):
            print(i, n-i+1)
    else:
        for i in range(1, m+1):
            if n-2*i+1 > n//2:
                print(i, n-i+1)
            else:
                print(i, n-i)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69636
using System;

namespace A_Tenki
{
    class Program
    {
        static void Main(string[] args)
        {
            string num1 = Console.ReadLine();
            char[] s = new char[3];
            
            for(int i=0; i < 3; i++)
            {
                s[i] = num1[i];
            }

            string num2 = Console.ReadLine();
            char[] t = new char[3];

            for (int i = 0; i < 3; i++)
            {
                t[i] = num2[i];
            }

            int counter = 0;


            for(int i=0; i<3; i++)
            {
                if (num1[i] == num2[i])
                {
                    counter = counter + 1;
                }
            }

            Console.WriteLine(counter);

        }
    }
}


Measured memory_bytes: 13140
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [k, x] <- getIntList
  putStrLn $ ["No", "Yes"] !! (k * 500 `div` x)

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int X;cin >> X;
  int N = X/100;
  if(5*N>=X%100) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


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

int main(){
	int a[3][3];
	for( int i = 0; i < 3; i++){
		for( int j = 0; j < 3; j++ ){
			cin >> a[i][j];
		}
	}
	bool bl = false;
	for( int i = 0; i < 3; i++){
		for( int j = 1; j < 3; j++ ){
			int check = a[0][i]-a[0][j];
			for( int k = 1; k < 3; k++ ){
				if( a[k][i]-a[k][j] != check ){
					bl = true;
					break;
				}
			}
			if( bl ) break;
		}
		if( bl ) break;
	}

	if( !bl ){
		for( int i = 0; i < 3; i++){
			for( int j = 1; j < 3; j++ ){
				int check = a[i][0]-a[j][0];
				for( int k = 1; k < 3; k++ ){
					if( a[i][k]-a[j][k] != check ){
						bl = true;
						break;
					}
				}
				if( bl ) break;
			}
			if( bl ) break;
		}
	}

	if( bl ) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	s, t := ScanWord(), ScanWord()
	a, b := ScanInt64(), ScanInt64()
	u := ScanWord()

	if u == s {
		P((a - 1), b)
	} else if u == t {
		P(a, (b - 1))
	}
	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int64) []int64 {
	length := int(n)
	arr := make([]int64, n)
	for i := 0; i < length; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func Mx(args ...int64) int64 {
	maxVal := MN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Mn(args ...int64) int64 {
	minVal := MX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}


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

class Main {
	static int inf = Integer.MAX_VALUE/2;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N+2];
		Arrays.fill(h, inf);
		for(int i=0; i < N; i++) h[i] = sc.nextInt();
		int[] dp = new int[N+2];
		Arrays.fill(dp, inf);
		dp[0] = 0;
		for(int i = 0; i < N; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(h[i] - h[i+1]));
			dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(h[i] - h[i+2]));
		}
		System.out.println(dp[N-1]);
				/*
		 * N

		 */
	}
}


Measured memory_bytes: 54740
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,sum,m,x;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	while(m--)cin>>x,sum+=x;
	if(sum>=n)cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

int main(){

  int a[4], i, m=0;

  for ( i=0; i<5; i++){
    cin >> a[i];
    if (a[i]<40){
      a[i]=40;
	}
    m+=a[i];
  }

  cout << m/5 << endl;

  return 0;

}

Measured memory_bytes: 3092
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def prime_factorization(n):
    res = []
    for i in range(2, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1:
        res.append([n, 1])
    return res


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    prime = [0] * max(A)
    for a in A:
        primes = prime_factorization(a)
        for num, ex in primes:
            prime[num - 1] = max(prime[num - 1], ex)

    L = 1
    for i in range(len(prime)):
        if prime[i] == 0:
            continue
        L *= pow(i + 1, prime[i])

    res = 0
    for a in A:
        res += L * pow(a, mod - 2, mod)
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 18224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iterator>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i, a, cont, next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i, a, b, step) repfn(i, a, i < b, i + step)
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int digits(int x)
{
  if (x < 10)
    return 1;
  else
    return 1 + digits(x / 10);
}

int main(int argc, char **argv)
{
  int a, b;
  while (cin >> a >> b) {
    cout << digits(a+b) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
a=list(map(int,input()))
n=len(a)
for i in range(1<<n-1):
  tmp=a[0]
  string=str(a[0])
  # print(bin(i))
  for j in range(1,n):
    if (i>>j-1)&1==0:
      tmp-=a[j]
      string+="-"
      string+=str(a[j])
    else:
      tmp+=a[j]
      string+="+"
      string+=str(a[j])
    # print("",tmp)
  if tmp==7:
    print(string+"=7")
    exit()

Measured memory_bytes: 3064
import copy

n = int(input())

dotsa = []
for _ in range(n):
    y,x = map(int,input().split(" "))
    dotsa.append([y,x])

pattern = []
pattern.append(dotsa)


for y in range(8):
    nextpattern = []
    #print("#######")
    #print(pattern)
    for pat in pattern:
        #print(";;;;;;;;;;;;;;;;;;;;;")
        #print(pat)
        flag = False
        for dot in pat:
            if dot[0] == y:
                flag = True
                break

        if flag:
            nextpattern = pattern
            continue

        ifFound = False
        for x in range(8):
            ank = len(pat)
            flag2 = True
            for i in range(ank):
                if abs(pat[i][0]-y) == abs(pat[i][1]-x) or pat[i][1] == x:
                    flag2 = False
                    break
            if flag2:
                #print("appended")
                #print(y)
                #print(x)
                tmp = copy.deepcopy(pat)
                tmp.append([y,x])
                nextpattern.append(tmp)
        #print("x loop end")
    pattern = nextpattern

ans = pattern[0]
board = [["."]*8 for i in range(8)]
#print(ans)
for ele in ans:
    board[ele[0]][ele[1]] = "Q"
for row in board:
    print(''.join(map(str,row)))



Measured memory_bytes: 6348
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var N, M int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &M)

	mp := make(map[int]int)
	for i := 0; i < N; i++ {
		var K int
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &K)

		for j := 0; j < K; j++ {
			var n int
			scanner.Scan()
			fmt.Sscanf(scanner.Text(), "%d", &n)
			mp[n]++
		}
	}
	ans := 0
	for _, cnt := range mp {
		if cnt == N {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC130 C - Rectangle Cutting
// 2020.06.19

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double W, H, x, y; cin >> W >> H >> x >> y;
  double ans = W*H/2;
  bool flag;
  if(x*2 == W && y*2 == H){
    flag = true;
  }else{
    flag = false;
  }
  cout << fixed << setprecision(10) << ans << " ";
  cout << flag << endl;
}

Measured memory_bytes: 3780