akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    ll N, M; scanf("%lld%lld", &N, &M);
    ll L = 1;

    int even = 0, odd = 0;
    vector<ll> A(N);
    for(int i=0; i<N; i++) {
        scanf("%lld", &A[i]), A[i] /= 2;
        L = lcm(L, A[i]);
        (A[i] % 2 ? odd : even)++;
        if(L > M or (odd > 0 and even > 0)) {
            puts("0");
            return 0;
        }
    }

    for(int i=0; i<N; i++) {
        if((L / A[i]) % 2 == 0) {
            puts("0");
            return 0;
        }
    }

    ll D = M / L;
    cout << (D + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 4076
data = input()

st1 = int(data[0]) * 10 + int(data[1])
st2  = int(data[2]) * 10 + int(data[3])

if (st1<= 12 and st1>=1) and (st2>= 1 and st2 <= 12):
  print("AMBIGUOUS")
elif (st1 >= 13 or st1 == 0) and (st2 != 0 and st2 <= 12):
  print("YYMM")
elif (st2 >= 13 or st2 == 0) and (st1 != 0 and st1 <= 12):
  print("MMYY")
else:
  print("NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD = 1000000007;

ll prod(ll b, ll e)
{
	ll ans = 1;
	while (e)
	{
		if (e & 1)
			ans *= b;
		ans %= MOD;
		e >>= 1;
		b *= b;
		b %= MOD;
	}
	return ans;
}

vector<ll> fact(2010), factinv(2010);

ll comb(int n, int k)
{
	ll ans = fact[n];
	ans = ans * factinv[n - k] % MOD;
	ans = ans * factinv[k] % MOD;
	return ans;
}

void pp()
{
	fact[0] = 1;
	for (int i = 1; i <= 2000; i++)
		fact[i] = fact[i - 1] * i % MOD;
	factinv[0] = 1;
	factinv[1] = 1;
	for (int i = 2; i <= 2000; i++)
		factinv[i] = prod(fact[i], MOD - 2);
}
int main(){
	int k, n;
	cin >> n >> k;
	pp();
	//赤玉に青の仕切りを入れる。
	//青ボールのグループ分割方法 i個のグループ
	for (int i = 1; i <= k;++i){
		if(i>n-k+1){
			cout << 0 << endl;
		}
		else
		{
			cout << comb(n - k + 1, i) * comb(k - 1, i - 1) % MOD << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
typedef long long ll;
const int MAXN = 1e5 + 10;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e10 ;
map<int,int> mp ;
int main(){
    int N ;
    cin >>N ;
    string s ;
    cin >>s ;
    int f1[26] ;
    // int N = (int)s.length() ;
    for(int i=0;i<26;i++)
        f1[i]=0 ;
    
    int cnt=0 ;
    for(int i=0;i<N-1;i++)
    {
        f1[s[i]-97]=1 ;
        int f2[26] ;
        for(int j=0;j<26;j++)
            f2[j]=0 ;
        for(int j=i+1;j<N;j++)
            f2[s[j]-97]=1;
        int ans=0;
        for(int j=0;j<26;j++)
            if(f2[j] && f1[j]) ans++;
        cnt=max(cnt,ans) ;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
    //    static String INPUT = "5\n3 2 2 4 1\n1 2 2 2 1";
    static String INPUT = "";

    public static void main(String[] args) {
        InputStream is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());

        Scanner scanner = new Scanner(is);

        final int n = scanner.nextInt();
        int[][] matrix = new int[2][];
        for (int i = 0; i < 2; i++) {
            matrix[i] = new int[n];
            for (int j = 0; j < n; j++) {
                matrix[i][j] = scanner.nextInt();
            }
        }

        System.out.println(solve(matrix));
    }

    static int solve(int[][] matrix) {
        return dfs(matrix, 0, 0, 0);
    }

    static int dfs(int[][] matrix, int x, int y, int acc) {
        if (y >= matrix.length || x >= matrix[0].length) {
            return acc;
        }
        if (y == matrix.length - 1 && x == matrix[0].length - 1) {
            return acc + matrix[y][x];
        }
        int max = -1;
        int accPlusCurrent = acc + matrix[y][x];
        max = Math.max(max, dfs(matrix, x, y + 1, accPlusCurrent));
        max = Math.max(max, dfs(matrix, x + 1, y, accPlusCurrent));
        return max;
    }

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int,int>>;
using vpsi = vector<pair<string,int>>;
using vpis = vector<pair<int,string>>;

int main(){
    int n,Y; cin>>n>>Y;
    int x = -1;
    int y = -1;
    int z = -1;
    for(int i = 0; i<=n; i++){
        if(i*10000>Y) continue;
        for(int j=0; j<=n-i; j++){
            int money = 10000*i + 5000*j + (n-i-j)*1000;
            if(money==Y){
                x = i;
                y = j;
                z = n-i-j;
            }
        }
    }

    cout << x << " " << y << " "  << z << endl;
}

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

int main() {
	long long n;
	cin>>n;
	long long arr[100005];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
	long long s[n+1];
	for(int i=1;i<=n;i++)s[i]=0;
	s[n-1]=abs(arr[n]-arr[n-1]);
	for(int i=n-2;i>=1;i--)
	{   int y1=abs(arr[i]-arr[i+1])+s[i+1];
	    int y2=abs(arr[i]-arr[i+2])+s[i+2];
		s[i]=min(y1,y2);
	}
	
	cout<<s[1]<<endl;
}


Measured memory_bytes: 5136
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using namespace std;
using ll = long long;

ll lcm( ll x, ll y ){
	return x/__gcd(x, y)*y;
}

int main(){
	int n; cin >> n;
	vector<ll> t(n);
	for( auto &k : t ) cin >> k;
	for( int i = 1; i < n; ++i ){
		t[i] = lcm( t[i-1], t[i] );
	}
	cout << t[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N;
    io.read(N);
    vector<string> W(N);
    for(int i = 0; i < N; i++){
        io.read(W[i]);
    }
    set<string> st;
    st.insert(W[0]);
    string ans = "Yes";
    for(int i = 1; i < N; i++){
        if(W[i - 1].back() != W[i].front() || st.find(W[i]) != st.end()){
            ans = "No";
            break;
        }
        st.insert(W[i]);
    }
    cout << ans;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    ll ans = 0;
    rep(i,n) ans+= a[i] - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE LambdaCase #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8

import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve [x,y] = or $ zipWith (\k1 k2 -> (k1*2)+(k2*4)==y) [0..x] (reverse [0..x])

output :: _ -> IO ()
output = \case
  True  -> putStrLn "Yes"
  False -> putStrLn "No"

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

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

int main() {
    int r;
    cin >> r;

    if (r < 1200) {
        cout << "ABC" << endl;
    }
    else if (r < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
ll mod = LLONG_MAX;
ll power(ll a, ll b)
{
	if(b == 0) return 1;
	ll ans = power(a, b/2);
	ans = (ans*ans)%mod;
	if(b%2) ans*=a;
	return ans%mod;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	string s;
	cin >> s;
	int mod = 2019;
	ll ans = 0;
	vector<vi > dp(3, vi(2020, 0));
	int toggle = 1;
	for(int i = 1; i <= s.size(); i++)
	{
		int curr = s[i - 1] - '0';
		for(int j = 0; j < 2019; j++) dp[toggle][j] = 0;
		dp[toggle][curr] = 1;
		for(int j = 0; j < 2019; j++)
		{
			dp[toggle][(j*10 + curr)%mod] += dp[1 - toggle][j];
		}
		ans += dp[toggle][0];
		toggle = 1 - toggle;
	}
	cout << ans;
}

Measured memory_bytes: 3744
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("YES")  # type: str


def no():
    print("NO")  # type: str


def solve(r: int, g: int, b: int):
    if int(str(r)+str(g)+str(b)) % 4 == 0:
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    g = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(r, g, b)


if __name__ == '__main__':
    main()


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

#define INF 1234567890
#define ll long long

int N, K;
vector<int> U[200201], D[200201], L[200201], R[200201];
vector<int> UDD[400401], DDD[400401], UDU[400401], DDU[400401];
// U,D는 x좌표, L,R은 y좌표
// UD*는 x-y가 일정, DD*는 x+y가 일정.

int main()
{
	scanf("%d", &N);
	for(int i=0; i<N; i++)
	{
		int x, y; char d;
		scanf("%d %d %c", &x, &y, &d);
		if (d == 'U') U[x].push_back(y), UDU[x-y+200000].push_back(x), DDU[x+y].push_back(x);
		else if (d == 'D') D[x].push_back(y), UDD[x-y+200000].push_back(x), DDD[x+y].push_back(x);
		else if (d == 'L') L[y].push_back(x);
		else if (d == 'R') R[y].push_back(x);
	}
	for(int i=0; i<=200000; i++)
	{
		sort(U[i].begin(), U[i].end());
		sort(D[i].begin(), D[i].end());
		sort(L[i].begin(), L[i].end());
		sort(R[i].begin(), R[i].end());
	}
	//
	for(int i=0; i<=400000; i++)
	{
		sort(UDD[i].begin(), UDD[i].end());
		sort(DDD[i].begin(), DDD[i].end());
		sort(UDU[i].begin(), UDU[i].end());
		sort(DDU[i].begin(), DDU[i].end());
	}

	int res = INF;
	for(int i=0; i<=200000; i++)
	{
		for(int y : U[i])
		{
			auto it = upper_bound(D[i].begin(), D[i].end(), y);
			if (it != D[i].end()) res = min(res, abs(y-*it));
		}
		for(int x : R[i])
		{
			auto it = upper_bound(L[i].begin(), L[i].end(), x);
			if (it != L[i].end()) res = min(res, abs(x-*it));
		}
	}
	// U와 R이 충돌할 수도 있다. 대각처리
	for(int y=0; y<=200000; y++)
	{
		for(int x : R[y])
		{
			auto it = upper_bound(UDD[x-y+200000].begin(), UDD[x-y+200000].end(), x);
			if (it != UDD[x-y+200000].end()) res = min(res, abs(x-*it)*2);

			it = upper_bound(DDU[x+y].begin(), DDU[x+y].end(), x);
			if (it != DDU[x+y].end()) res = min(res, abs(x-*it)*2);
		}

		for(int x : L[y])
		{
			auto it = lower_bound(DDD[x+y].begin(), DDD[x+y].end(), x);
			if (it != DDD[x+y].begin())
			{
				it--;
				res = min(res, abs(x-*it)*2);
			}

			it = lower_bound(UDU[x-y+200000].begin(), UDU[x-y+200000].end(), x);
			if (it != UDU[x-y+200000].begin())
			{
				it--;
				res = min(res, abs(x-*it)*2);
			}
		}
	}


	if (res == INF) printf("SAFE");
	else printf("%d", res*10/2);
	return 0;
}

Measured memory_bytes: 78464
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll x = 60*h1 + m1;
    ll y = 60*h2 + m2;
    out(max(0LL, y - x - k));
    re0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  llc(n);
  vector<string> s(n);
  vector<ll> a(n);
  r1(i, n) cin >> s.at(i);
  sort(s.begin(), s.end());
  ll b=0;
  /*
  r1(i,n) {
    cout<<a[i]<<' ';
  }cout<<endl;
  */
  if (n==1) cout << s.at(0) << endl;
  else {
    r2(i, n) if(s.at(i)==s.at(i-1)) {
      a.at(i)=a.at(i-1)+1;
      b=max(a.at(i),b);
    }
    /*
   r1(i,n) {
    cout<<a[i]<<' ';
  }cout<<endl;
    r1(i,n) {
      cout<<s[i]<<' ';
    }cout<<endl;
    */
    r1(i,n) {
        if(a.at(i)==b) cout << s.at(i) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 16128
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left

A,B=map(int, input().split())
S=input()
res = S.split('-')
if len(res) != 2:
    print('No')
else:
    if len(res[0]) == A and len(res[1]) == B:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3060
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(){
	int a[26] = {};
	string s;cin>>s;
	REP(i,s.size()) a[s[i]-'a']++;

	REP(i,26){
		if(a[i]==0){
			char c=('a'+i);
			cout << c << endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}


Measured memory_bytes: 512
MOD = 10**9+7

def inv_mod(n,mod):
    inv_mod = [0]*(n+1)
    inv_mod[1] = 1
    for i in range(2,n+1):
        inv_mod[i] = mod - inv_mod[mod%i] * (mod//i ) % mod
    
    return inv_mod

n = int(input())
x = list(map(int,input().split()))

x_dif = [x2-x1 for x1,x2 in zip(x,x[1:])]

fac = 1
for i in range(1,n):
    fac *= i
    fac %= MOD

inv = inv_mod(n,MOD) 
    
ans = 0
count = 0
for i,dist in enumerate(x_dif,1):
    count += (fac * inv[i]) %MOD
    count %= MOD
    
    ans += (dist * count)%MOD
    ans %= MOD

print(ans)

Measured memory_bytes: 15296
n, w = map(int, input().split())
listV, listW = [], []
for i in range(n):
    vi, wi = map(int, input().split())
    listV.append(vi)
    listW.append(wi)

dp =[[-1] * (w+1) for _ in range(n+1)]
for i in range(w+1):
    dp[0][i] = 0

for i in range(n):
    for j in range(w+1):
        if j >= listW[i]:
            dp[i+1][j] = max(dp[i][j-listW[i]] + listV[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[n][w])



Measured memory_bytes: 41888
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
int32_t main()
{ 
  IOS


  int n;
  cin >> n;
  int a[n], sum = 0, ans = 0;
  for(int i = 0;i<n;i++){
    cin >> a[i];
    ans += (sum*a[i])%mod;
    ans%=mod;
    sum += a[i];
    sum%=mod;
  }
  cout << ans << endl;

  










  
    
} 



Measured memory_bytes: 5172
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>
//#include <chrono> //正確な時間計測のため
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
#define MOD 998244353
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 

//階乗
ll Kaijou(ll a) {
if (a < 2) return 1;
return a * Kaijou(a - 1)%MOD;
}

//逆元の計算用(pは素数のときb=p-2で逆元)
ll calc(ll a, ll b, ll p) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll d = calc(a, b / 2, p);
		return (d*d) % p;
	}
	else {
		return (a*calc(a, b - 1, p)) % p;
	}
}


//ユークリッドの互除法
ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x%y);
}

ll CCC(ll all,ll a,ll b,ll c){
  all=Kaijou(all)%MOD;
  a=Kaijou(a);
  b=Kaijou(b);
  c=Kaijou(c);
  ll sita=((a*b)%MOD*c)%MOD;
  return all*calc(sita,MOD-2,MOD)%MOD;
}

 ll ans=INF;

 ll cc[501][501];
 ll D[31][31];
 
 ll pdmin[3];

//再帰なし累乗
ll iPOW(ll x, ll p){
  ll result;
	for(result=1;p!=0;p>>=1)
	{
    if(p&1) result*=x;
	  x*=x;
  }
  return result;
}


int main(){  
 int n;
 cin>>n;
 int a[10000]={0};
 int ans=0;
 rep(i,n) {
   cin>>a[i];
   while(a[i]%2==0){
     ans++;
     a[i]/=2;
   }
 }
 cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
long long ans,n,w,k,a[200010];
int main()
{
	scanf("%lld%lld%lld",&n,&w,&k);
	for(int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	for(int i=2;i<=n;i++)
	{
		int x=a[i]-a[i-1];
		ans+=min(k,x*w);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
	int a, sum, i, n, max;
	scanf("%d",&n);
	max=0;
	sum=0;
	for(i=0;i<n;i++){
		scanf("%d",&a);
			sum+=a;
		if(a>max){
			max=a;
		}
	}
	sum -= max / 2;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx - sx, y = ty - sy;
    //1回目
    rep(i, x) cout << 'R';
    rep(i, y) cout << 'U';
    rep(i, x) cout << 'L';
    rep(i, y) cout << 'D';

    //2回目
    cout << 'D';
    rep(i, x + 1) cout << 'R';
    rep(i, y + 1) cout << 'U';
    cout << 'L';
    cout << 'U';
    rep(i, x + 1) cout << 'L';
    rep(i, y + 1) cout << 'D';
    cout << 'R';

    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n; cin >> n;
    int building1[3][10] = {0};
    int building2[3][10] = {0};
    int building3[3][10] = {0};
    int building4[3][10] = {0};
    int b, f, r, v;

    for (int i = 0; i < n; i++) {
        cin >> b;
        cin >> f;
        cin >> r;
        cin >> v;
        if (b == 1) {
            building1[f-1][r-1] += v;
        }
        else if (b == 2) {
            building2[f-1][r-1] += v;
        }
        else if (b == 3) {
            building3[f-1][r-1] += v;
        }
        else if (b == 4) {
            building4[f-1][r-1] += v;
        }
    }

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 10; j++) {
            cout << ' ' << building1[i][j];
        }
        cout << '\n';
    }

    cout << "####################" << '\n';

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 10; j++) {
            cout << ' ' << building2[i][j];
        }
        cout << '\n';
    }
    cout << "####################" << '\n';

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 10; j++) {
            cout << ' ' << building3[i][j];
        }
        cout << '\n';
    }
    cout << "####################" << '\n';

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 10; j++) {
            cout << ' ' << building4[i][j];
        }
        cout << '\n';
    }

    return 0;
}



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

// shift-only.cpp
// author: Seong Yong-ju ( @sei40kr )
// Copyright (c) 2017 Seong Yong-ju

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

  int n;
  cin >> n;

  int ans = INT_MAX;
  REP(i, n) {
    int x;
    cin >> x;

    int cnt = 0;

    while (x % 2 == 0) {
      x /= 2;
      ++cnt;
    }

    ans = min(ans, cnt);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('');
   let len = xs.length;
   let ans = '';
   for(let i=0; i<len; i++){
     if(xs[i]=='7'){
       ans='Yes';
       break;
     }else{
       ans='No';
     }
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 29632
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    int N, M;

    cin >> N >> M;

    int safeStep = 0;
    int A;
    int stepSum = 0;
    int stepSets[M + 1];
    int maxStepSets = 0;
    ll patterns[100000];
    ll ans = 1;

    for(int i = 0; i < M; i++){
        cin >> A;
        stepSets[i] = A - safeStep - 1;
        if(stepSets[i] < 0){
            cout << 0 << endl;
            return 0;
        }
        if(maxStepSets < stepSets[i]){
            maxStepSets = stepSets[i];
        }
        safeStep = A + 1;
    }
    stepSets[M] = N - safeStep;
    if(stepSets[M] < 0){
        cout << 0 << endl;
        return 0;
    }
    if(maxStepSets < stepSets[M]){
        maxStepSets = stepSets[M];
    }
    
    patterns[0] = 1;
    patterns[1] = 1;
    for(int i = 2; i < maxStepSets + 1; i++){
        patterns[i] = patterns[i - 2] + patterns[i - 1];
        if(patterns[i] > 1000000007){
            patterns[i] = patterns[i] % 1000000007;
        }
    }

    for(int i = 0; i < M + 1; i++){
        ans *= patterns[stepSets[i]];
        if(ans > 1000000007){
            ans = ans % 1000000007;
        }
    }
    ans = ans % 1000000007;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            double T = (double)input[0];
            double X = (double)input[1];

            Console.WriteLine(T / X);
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
bool cmp(const int &x,const int &y)
{
	return x>y;
}
int cnt[26];
char s[11];
int main()
{
	int n,k,ans=0;
	scanf("%d%d",&n,&k);
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s);
		cnt[s[0]-'A']++;
	}
	while(true)
	{
		sort(cnt,cnt+26,cmp);
		if(cnt[k-1]==0)
			break;
		for(int i=0;i<k;i++)
			cnt[i]--;
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0]*(10**6+1)
    for a in A:
        B[a] += 1

    for a in set(A):
        v = 2*a
        while v <= 10**6:
            B[v] += 1
            v += a

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

    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = 0;
	for (int i = 0; i < (int) s.size(); ++i) {
		n += s[i] - '0';
	}
	if (n % 9 == 0)
		puts("Yes");
	else
		puts("No");

	return 0;
}



Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define debug(var) std::cout << #var << ": " << var << "\n"
using ll = long long;
using ull = unsigned long long;
ull mod = 1e9 + 7;
using namespace std;

int main(){

  int r; cin >> r;
  cout << r * r << endl;

}

Measured memory_bytes: 256
from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

mod = 10 ** 9 + 7
g = defaultdict(int)

for i in range(N):
    tmp = 1
    a = A[i]
    g_tmp = defaultdict(int)
    while tmp <= A[i] ** 0.5:
        cnt = 0
        while tmp > 1 and a % tmp == 0:
            a //= tmp
            if tmp not in g_tmp:
                g_tmp[tmp] = 1
            else:
                g_tmp[tmp] += 1
        tmp += 1
    for j in g_tmp:
        g[j] = max(g[j], g_tmp[j])
    if a > 1:
        if a not in g:
            g[a] = 1

l = 1
ans = 0
for i in g:
    l *= pow(i, g[i], mod)
    l %= mod
for a in A:
    ans += l * pow(a, mod - 2, mod)
    ans %= mod

print(ans)

Measured memory_bytes: 50796
N=int(input())
a=[int(s) for s in input().split(" ") ]

a.sort()
Alice=0
Bob=0
while len(a)>=1:
    Alice+=a[-1]
    a.pop(-1)
    if len(a)>=1:
        Bob+=a[-1]
        a.pop(-1)

print(Alice-Bob)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[] arr = new int[N];
        int total = 0;
        for (int i=0; i < N; i++) {
            arr[i] = scanner.nextInt();
            total += arr[i];
        }

        double line = (double)total / (double)(M * 4);

        int count = 0;
        for (int i=0; i< N; i++) {
            if (arr[i] >= line) {
                count++;
            }
        }

        if (count >= M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23892
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	 long long int x,a[210000]={0},n,temp,q,b,c,i;
long long int sum=0;
	scanf("%lld",&n);
	for(i=0;i<n;i++){
scanf("%lld",&temp);
a[temp]+=1;
}
  //printf("%lld\n",sum);
  for(i=0;i<=100000;i++){
  sum+=i*a[i];
  }
scanf("%d",&q);
for(i=0;i<q;i++){
scanf("%lld%lld",&b,&c);
  sum=sum+c*a[b]-b*a[b];
a[c]=a[c]+a[b];
a[b]=0;

printf("%lld\n",sum);
}

return 0;
}

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

int main(){
  int n;
  cin>>n;
  int num[4][3][10]={};
  
  for(int i=0;i<n;i++){
    int b,f,r,v;
    cin>>b>>f>>r>>v;
    num[b-1][f-1][r-1]+=v;
} 
  
  for(int i=0;i<4;i++){
    if(i) cout<<"####################"<<endl;

    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
        cout<<" "<<num[i][j][k];
      }
    cout<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2984
/**
 *    author:  tourist
 *    created: 04.05.2019 15:47:55       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 188;

int dpr[N][N][N];
int dpd[N][N][N];
int new_dpr[N][N][N];
int new_dpd[N][N][N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) {
    cin >> grid[i];
  }
  vector<vector<int>> pref(h + 1, vector<int>(w + 1, 0));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      pref[i + 1][j + 1] = pref[i + 1][j] + pref[i][j + 1] - pref[i][j] + (int) (grid[i][j] == '.');
    }
  }
  auto GetSum = [&](int i1, int j1, int i2, int j2) {
    return pref[i2 + 1][j2 + 1] - pref[i2 + 1][j1] - pref[i1][j2 + 1] + pref[i1][j1];
  };
  auto IsMono = [&](int i1, int j1, int i2, int j2) {
    int sum = GetSum(i1, j1, i2, j2);
    int area = (i2 - i1 + 1) * (j2 - j1 + 1);
    return (sum == 0 || sum == area);
  };
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int i1 = i; i1 < h; i1++) {
        int low = j - 1, high = w - 1;
        while (low < high) {
          int mid = (low + high + 1) >> 1;
          if (IsMono(i, j, i1, mid)) {
            low = mid;
          } else {
            high = mid - 1;
          }
        }
        dpr[i][j][i1] = low;
      }
      for (int j1 = j; j1 < w; j1++) {
        int low = i - 1, high = h - 1;
        while (low < high) {
          int mid = (low + high + 1) >> 1;
          if (IsMono(i, j, mid, j1)) {
            low = mid;
          } else {
            high = mid - 1;
          }
        }
        dpd[i][j][j1] = low;
      }
    }
  }
  for (int it = 0; ; it++) {
    if (dpr[0][0][h - 1] == w - 1) {
      cout << it << '\n';
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        for (int i1 = i; i1 < h; i1++) {
          int j1 = dpr[i][j][i1];
          if (j1 < w - 1) {
            j1 = dpr[i][j1 + 1][i1];
          }
          new_dpr[i][j][i1] = j1;
        }
        for (int j1 = j; j1 < w; j1++) {
          int i1 = dpd[i][j][j1];
          if (i1 < h - 1) {
            i1 = dpd[i1 + 1][j][j1];
          }
          new_dpd[i][j][j1] = i1;
        }
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        for (int i1 = i; i1 < h; i1++) {
          int j1 = new_dpr[i][j][i1];
          while (j1 < w - 1 && new_dpd[i][j][j1 + 1] >= i1) {
            ++j1;
          }
          dpr[i][j][i1] = j1;
        }
        for (int j1 = j; j1 < w; j1++) {
          int i1 = new_dpd[i][j][j1];
          while (i1 < h - 1 && new_dpr[i][j][i1 + 1] >= j1) {
            ++i1;
          }
          dpd[i][j][j1] = i1;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 103808
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        double ans = 0;
        for(int i = 0; i < n; i++){
            double c = sc.nextDouble();
            String s = sc.next();
            if(s.equals("BTC")){
                ans += c*380000;
            }else{
                ans += c;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#include <algorithm>
using namespace std;
int main()
{
	int N;
	cin>>N;
	string s;
	cin>>s;
	int R[s.length()],W[s.length()],a,b,c,d=s.length()+1;
	if(s.at(0)=='W')
	{
		W[0]=1;
		R[0]=0;
	}
	else
	{
		W[0]=0;
		R[0]=1;
	}
	int i;
	for(i=1;i<s.length();i++)
	{
		if(s.at(i)=='W')
		{
			W[i]=W[i-1]+1;
			R[i]=R[i-1];
		}
		else
		{
			W[i]=W[i-1];
			R[i]=R[i-1]+1;
		}
	}
	a=s.length()-W[s.length()-1];
	b=s.length()-R[s.length()-1];
	d=min(a,d);
	d=min(b,d);
	for(i=0;i<s.length();i++)
	{
		a=R[i];
		b=W[N-1]-W[i];
		if(a+b==N)
		d=0;
	}
	// cout<<d<<"\n";
	for(i=1;i<s.length()-1;i++)
	{
		a=W[i];
		b=R[s.length()-1]-R[i];
		c=a+b;
		// a=W[i];
		// b=
		// cout<<a<<" "<<b<<" jai\n";
		// cout<<c<<" "<<i<<"\n";
		c=c-min(W[i],R[s.length()-1]-R[i]);
		// cout<<c<<" check\n";
		if(c>0)
		d=min(c,d);
	}
	cout<<d;
	return 0;
}


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

int main(void)
{
    while (1)
    {
        int a, b;
        string op;
        cin >> a >> op >> b;
        int r;
        if (op == "+")
        {
            r = a + b;
        }
        else if (op == "-")
        {
            r = a - b;
        }
        else if (op == "*")
        {
            r = a * b;
        }
        else if (op == "/")
        {
            r = a / b;
        }
        else if (op == "?")
        {
            break;
        }
        cout << r << endl;
    }
    return 0;
}

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll a[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen(".INP", "r")){
                freopen(".INP", "r", stdin);
                freopen(".OUT", "w", stdout);
        }
        ll k, n;
        cin >> k >> n;
        for (int i = 1; i <= n; i++) cin >> a[i];
        a[0] = a[n] - k;
        ll ans = k;
        for (int i = 1; i <= n; i++){
                ans = min(ans, k - (a[i] - a[i - 1]));
        }
        cout << ans;
}


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

using namespace std;

vector<pair<int, int>> graph[21];

int main()
{
	int L;
	cin >> L;
	int l = 0;
	for(; (1 << l) <= L; l++);
	l--;
	int N = l + 1;
	for(int i = 1; i < N; i++)
	{
		graph[i].push_back({i + 1, 0});
		graph[i].push_back({i + 1, (1 << (i - 1))});
	}	
	L -= (1 << l);
	int sum = (1 << l);
	while(L > 0)
	{
		l = 0;
		for(; (1 << l) <= L; l++);
		l--;
		graph[l + 1].push_back({N, sum});
		sum += (1 << l);
		L -= (1 << l);
	}
	int e = 0;
	for(int i = 1; i <= N; i++)
	{
		e += graph[i].size();
	}	
	cout << N << " " << e << endl;
	for(int i = 1; i <= N; i++)
	{
		for(auto &edge : graph[i])
		{
			cout << i << " " << edge.first << " " << edge.second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  ll ans = 0;
  rep(i, n){
    int m = 0;
    if(i != 0) m = a.at(i-1);
    // cerr << a.at(i) << " " << ans << " " << m << endl;
    ans += (a.at(i)+m)/2;
    if(m == 0) a.at(i) %= 2;
    else if(a.at(i) != 0)a.at(i) = 1 - (a.at(i)%2);
    else a.at(i) = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3792
my @NM = split(' ', <STDIN>);
my ($N, $M) = @NM;
my @X = split(' ', <STDIN>);

if ($N < $M) {
	@X = sort { $a <=> $b } @X;
	my @d;
	for my $i (1..$#X) {
		push(@d, abs($X[$i] - $X[$i - 1]));
	}
	@d = sort { $a <=> $b } @d;
	@d = splice(@d, 0, $M - $N);

	my $sum = 0;
	for my $d (@d) {
		$sum += $d;
	}
	print $sum;
} else {
	print '0';
}


Measured memory_bytes: 19260
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
mo=10**9+7
imp='IMPOSSIBLE'

a,b=MI()
print(max(a+b,a-b,a*b))

Measured memory_bytes: 38512
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    r,g,b = map(int,input().split())
    num = r * 100 + g * 10 + b
    if num % 4 == 0:
        print("YES")
    else:
        print("NO")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38636
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1000000000000000000;
typedef pair<int, int> P;
vector<long long> A, B;
int main(){
	int n,i,j;
	string s,t;
	cin >> n;
	cout << 0 << endl;
	cin >> s;
	if (s == "Vacant")return 0;
	t = s;
	j = (n - 1) / 2;
	i = (n - 1) / 2;
	while (true) {
		cout << i << flush<<endl;
		cin >> s;
		if (s == "Vacant")break;
		if (j == 1) {
			cout << i + 1 << flush << endl;
			cin >> s;
			break;
		}
		if (s == t) {
			if (j % 2 == 1) {
				j = (j - 1) / 2;
				i = i - 1 - j;
			}
			else if (j % 2 == 0) {
				j = j / 2;
				i += j;
			}
		}
		if(s!=t){
			if (j % 2 == 0) {
				j = j / 2;
				i = i - j;
			}
			else if (j % 2 == 1) {
				j = 1+(j - 1) / 2;
				i = i-1+j;
			}
		}
	}
	return 0;
}

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

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        
        vector<vector<int> > h(n, vector<int>(n));
        vector<vector<int> > ht = h;
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                cin >> h[i][j];
                ht[j][i] = h[i][j];
            }
        }
        vector<vector<int> > c(n, vector<int>(n, 0));
        for(int i=0; i<n; i++){
            int minval = *min_element(h[i].begin(), h[i].end());
            int maxval = *max_element(ht[i].begin(), ht[i].end());
            for(int j=0; j<n; j++){
                if(h[i][j] == minval) c[i][j]++;
                if(ht[i][j] == maxval) c[j][i]++;
            }
        }

        int ans = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(c[i][j] == 2) ans = h[i][j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

#define INF 1e9
#define MOD 1000000007;//1e9+7

void solve() {
    int N;
    cin >> N;
    map<string, int>mp;
    rep(i, N) {
        string S;
        cin >> S;
        mp[S]++;
    }
    int m= 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)m = max(m, itr->second);
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        if (itr->second == m)cout << itr->first << endl;
    }
}

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

Measured memory_bytes: 25216
// Single_Source_Shortest_Path_I.c

#include <stdio.h>

#define MAX 100000000
#define N 100

void DFS(int, int);

int n, size[N], m[N][N], count[N][N], d[N];

int main() {

	int i, j, u;

	scanf("%d", &n);

	for(i = 0; i < n; i++) {
		
		scanf("%d", &u);
		scanf("%d", &size[u]);

		for(j = 0; j < size[u]; j++) {

			scanf("%d", &m[u][j]);
			scanf("%d", &count[u][j]);

		}

	}

	for(i = 0; i < n; i++) {
		d[i] = MAX;
	}

	DFS(0, 0);

	for(i = 0; i < n; i++) {
		printf("%d %d\n", i, d[i]);
	}

	return 0;
}


void DFS(int p, int q) {

	int i;

	d[p] = q;

	for(i = 0; i < size[p]; i++) {
		if(d[m[p][i]] > q + count[p][i]) {
			DFS(m[p][i], q + count[p][i]);
		}
	}

}

Measured memory_bytes: 676
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inS = Console.ReadLine().Split(' ');
            int P = int.Parse(inS[0]);
            int Q = int.Parse(inS[1]);
            int R = int.Parse(inS[2]);

            int ans = Math.Min(P + Q, P + R);
            ans = Math.Min(ans, Q + R);

            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;
using ll=long long;
const int N = 2048; 
ll dp[N][N];
void solve() {
    int n; cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        a[i] = {x,i};
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        int x,k;
        tie(x,k) = a[i];
        for (int j = 0; j <= i; j++) {
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + x*1ll* abs(k - j));
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + x*1ll* abs(k - (n - (i-j) - 1)));
        }
    }
    ll res = *max_element(dp[n], dp[n]+n+1);
    cout << res;
}

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


Measured memory_bytes: 24336
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,p[200005];
  int maxa[200005]={};
  int cnt=1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  maxa[0]=p[0];
  for(int i=1;i<n;i++){
    maxa[i]=min(p[i-1],maxa[i-1]);
  }
  for(int i=1;i<n;i++){
    if(p[i]<maxa[i]){
      cnt++;
    }
  }
  cout<<cnt<<"\n";
  return 0;
}


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

typedef long long ll;

// map<ll, ll> target, mm, mm2;

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

  ll n;
  cin >> n;

  multiset<ll, greater<ll>> v;

  for (ll i = 0; i < (1 << n); i++) {
    ll t;
    cin >> t;
    v.insert(t);
  }

  vector<ll> c;

  c.push_back(*(v.begin()));
  v.erase(v.begin());

  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < (1 << i); j++) {
      auto it = v.upper_bound(c[j]);
      if (it != v.end()) {
        // printf("%d.%d %d %d\n", i, j, c[j], *it);
        c.push_back(*it);
        v.erase(it);
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 14708
#D
n,k=map(int, input().split())
r,s,p=map(int, input().split())
t=str(input()) ###相手
te=[]
score=0
for i in range(n):
  if i>=k and t[i]==t[i-k] and t[i]!=te[i-k]:###k回前に相手が同じ手を出して自分が勝っていたとき
    te.append(t[i]) ###あいこ
  else: #ほかは勝てる
    if t[i]=='r':
      score+=p
      te.append('p')
    elif t[i]=='s':
      score+=r
      te.append('r')
    elif t[i]=='p':
      score+=s
      te.append('s')
print(score)#print(i,score,t,te)

Measured memory_bytes: 4212
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {
	int x;
	int sum = 0;
	rep(i, 0, 5) {
		cin >> x;
		sum += max(40, x);
	}
	cout << sum/5 << endl;
	return 0;
}

Measured memory_bytes: 3084
n=gets.to_i
all=[]
n.times.each do
    v=gets.split.map(&:to_i)
    all<<v

end
all=all.sort_by{|_,v|v}
count=0
for i in 0..all.length-1
    count+=all[i][0]
    if count<=all[i][1]
        next
    else
        puts "No"
        exit

    end
end
puts "Yes"

Measured memory_bytes: 34208