akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll A,B,V,W,T;
    cin >> A >> V >> B >> W >> T;
    if (W>=V) {
        cout << "NO\n";
        return 0;
    }
    if ((V-W)*T >= abs(A-B)) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

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

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

    bool flg = true;
    while(true){
        c -= b;
        if (c <= 0) {
            break;
        }

        a -= d;
        if (a <= 0) {
            flg = false;
            break;
        }
    }

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

Measured memory_bytes: 3632
#include <stdio.h>

int main(){
	long W,H,x,y;
    int sp;
    double dim;
    scanf("%ld %ld %ld %ld",&W,&H,&x,&y);
    dim = (double)W*H/2;
    if(W==2*x && H==2*y){ 
    	sp=1;
    }else{
    	sp=0;
    }
    printf("%lf %d",dim,sp);
	return 0;
}

Measured memory_bytes: 128
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
seen = set()
W = s()
seen.add(W)
prev_c = W[-1]
for i in range(N-1):
    W = s()
    if W in seen or W[0] != prev_c:
        print('No')
        import sys
        sys.exit()
    seen.add(W)
    prev_c = W[-1]
print('Yes')


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

	string S, T;
	cin >> S >> T;


	rep(i, N) {
		cout << S[i] << T[i];
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/	
int m, n;
vector<vector<ld>> rate;
ld dp[17][(1 << 16) + 1];

ld solve(int room, int rest)
{
	if (room == n) return 1.0;
	if (rest == (1 << m) - 1) return 0;
	if (dp[room][rest] >= 0) return dp[room][rest];
	ld res = 0;
	REP(i, m)
	{
		if ((rest >> i) & 1) continue;
		ld exp = 1.0; ld tres = 0;
		FOR(j, room, n)
		{
			ld win = rate[i][j];
			tres += exp * (1.0 - win) * solve(j, rest | (1 << i));
			exp *= win;
		}
		tres += exp;
		chmax(res, tres);
	}
	return dp[room][rest] = res;
}

int main()
{
	cin.sync_with_stdio(false);
	REP(i, 17)REP(j, (1 << 16)+1) dp[i][j] = -1;
	cin >> m >> n;
	rate.resize(m, vector<ld>(n));
	REP(i, m)REP(j, n) cin >> rate[i][j];
	cout << D10 << solve(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 12012
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int n;
vector<string>in;
int a;
int f(int b){
	char c=in[a][b];
	a++;b++;
	int sum=0;
	if(c=='*')sum=1;
	while(1){
		int t=0;
		if(isdigit(in[a][b])){
			t=in[a][b]-'0';
		}else{
			t=f(b);
			a--;
		}
		if(c=='*')sum*=t;
		else sum+=t;
		a++;
		if(a==n)break;
		if(in[a].size()<=b)break;
	}
	return sum;
}
int main(){
	while(cin>>n,n){
		in=vector<string>(n);
		rep(i,n)cin>>in[i];
		if(n==1){
			cout<<in[0]<<endl;
		}else{
			a=0;
			cout<<f(0)<<endl;
		}
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int INF = 1e9;
const int MOD = 1e9+7;
const int N = 1e5+7;

int a[101],b[101];
int a_sum[101],b_sum[101];
int b_max;

int main(){

  int n; cin >> n;
  REP(i,n){
    cin >> a[i];
    if(i) a_sum[i] = a_sum[i-1] + a[i];
    else a_sum[i] = a[i];
  }
  REP(i,n){
    cin >> b[i];
    b_max += b[i];
    if(i) b_sum[i] = b_sum[i-1] + b[i];
    else b_sum[i] = b[i];
  }

  int ans = 0;
  REP(i,n){
    ans = max(ans,a_sum[i] + (b_max-b_sum[i-1]));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep( i, begin, end ) for( int i = begin; i < end; i++ )
using namespace std;
 
bool scores( string input ) {
    int length = input.size();
    bool left = true, right = true;
    input += '!';
    rep( i, 0, length) {
        if( input[ i ] == input[ i + 1 ] )
            return false;
        if( input[ i ] == 'L' && i % 2 == 1 )
            left = false; 
        if( input[ i ] == 'R' && i % 2 == 0 )
            left = false;
        if( input[ i ] == 'L' && i % 2 == 0 )
            right = false; 
        if( input[ i ] == 'R' && i % 2 == 1 )
            right = false; 
    }
 
    return ( left | right );
}
 
int main() {
    int n;
    string input;
    cin >> n;
    rep( i, 0, n) {
        cin >> input;
        cout << ( scores( input ) ? "Yes":"No") << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3268
import Data.List
import Data.Tuple

main = do
  (n:m:_) <- getLine >>= return . map read . words :: IO [Int]
  paths <- getContents >>= return . (\x -> x ++ (map swap x)) . map ((\(a:b:_) -> (a,b)) . map read . words) . lines :: IO [(Int, Int)]

  print $ length $ filter id $ map (solve paths) (map (1:) $ permutations [2..n])

  where
    solve paths stroke = solve' stroke paths
    solve' (_:[]) _ = True
    solve' (a:b:rest) paths = if elem (a,b) paths then solve' (b:rest) paths else False


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i;
    string a,b;
    getline(cin,a);
    b=a;
    reverse(a.begin(),a.end());
    for(i=0;i<a.size();++i)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    string p;
    int ans=100000;
    for(int i=0; i<=s.size()-t.size(); i++){
        string str;
        int cnt=0;
        str=s.substr(i,t.size());
        for(int i=0; i<str.size(); i++){
            if(str.at(i)!=t.at(i)) cnt++;
        }
     
        ans=min(cnt,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
def solve():
    d = 0
    c = 0
    for i in range(D):
        d += p[i][0]
    dp = [[0]*(d+1) for i in range(D)]
    for i in range(D):
        for j in range(p[i][0]+1):
            if i == 0:
                if j == p[i][0]:
                    dp[i][j] += p[i][1]
                dp[i][j] += 100*j
            else:
                for k in range(c+1):
                    if j == p[i][0]:
                        dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1)+p[i][1])
                    else:
                        dp[i][k+j]=max(dp[i][k+j],dp[i-1][k]+100*j*(i+1))
        c += p[i][0]
    for i in range(d+1):
        if dp[D-1][i]>=G:
            print(i)
            break    
    
if __name__=="__main__":
    D,G = list(map(int, input().split()))
    p = [list(map(int, input().split())) for _ in range(D)]
    solve()


Measured memory_bytes: 9228
arg = list(map(int, input().split())) # 1行, 配列
N = arg[0]
K = arg[1]
S = list(map(int, input().split())) # 1行, 配列

DP = [float('inf')] * N
DP[0] = 0
for i in range(1, N):
  if i == 1:
    DP[i] = abs(S[i] - S[i-1])
    continue
  for j in range(K+1):
    if i - j < 0:
      continue
    DP[i] = min(DP[i] , DP[i-j] + abs(S[i] - S[i-j]))

print(DP[-1])

Measured memory_bytes: 55776
sx, sy, tx, ty = map(int, input().split())

dx = "R" * (tx - sx)
dy = "U" * (ty - sy)
ans = dx + dy

dx = "L" * (tx - sx)
dy = "D" * (ty - sy)
ans = ans + dx + dy

dx = "R" * (tx - sx + 1)
dy = "U" * (ty - sy + 1)
ans = ans + "D" + dx + dy + "L"

dx = "L" * (tx - sx + 1)
dy = "D" * (ty - sy + 1)
ans = ans + "U" + dx + dy + "R"

print(ans)

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

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  rep(i, n) cout << s[i] << t[i];
  cout << endl;
  return 0;
}

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

int main()
{
    int n,k,i;
    cin >> n >> k;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    int ans = 1;
    n -= k; --k;
    if(n % k == 0){
        ans += n/k;
    }else{
        ans += n/k+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<int> cnt(50, 0);

  for (int i = 0; i < n; i++) {
    for (int d = 0; d < 50; d++) {
      if (a[i] & (1LL << d)) {
        cnt[d]++;
      }
    }
  }

  vector<vector<ll>> dp(51, vector<ll>(2, -1));
  dp[50][0] = 0;
  for (int d = 49; d >= 0; d--) {
    ll c0 = (1LL << d) * cnt[d];
    ll c1 = (1LL << d) * (n - cnt[d]);
    if (dp[d + 1][1] != -1) {
      dp[d][1] = max(dp[d][1], dp[d + 1][1] + max(c1, c0)); 
    }
    if (k & (1LL << d)) {
      dp[d][1] = max(dp[d][1], dp[d + 1][0] + c0);
      dp[d][0] = max(dp[d][0], dp[d + 1][0] + c1);
    } else {
      dp[d][0] = max(dp[d][0], dp[d + 1][0] + c0);
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
  return 0; 
} 

Measured memory_bytes: 1024
n = int(input())
a = []
b = []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

tot = 0
for i in range(n)[::-1]:
    a[i] += tot
    # print(i, a[i])
    if a[i] != 0:
        if a[i] % b[i] == 0:
            continue
        else:
            tot += b[i]*(a[i]//b[i] + 1) - a[i]
    else:
        tot += a[i]
    # print(tot)
print(tot)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+1;
int n,k;
int a[N];
int dp[N];
int solve(int i){
    if(i==1)return 0;
    if(dp[i]+1){
        return dp[i];
    }
    int path,mn=123456789101;
    for(int u=1;u<=k;u++){
        if(i-u<1)continue;
        path=solve(i-u)+abs(a[i]-a[i-u]);
        mn=min(mn,path);
    }
    return dp[i]=mn;
}
main()
{
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }memset(dp,-1,sizeof(dp));
    cout<<solve(n);
}


Measured memory_bytes: 15104
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int X; cin >> X;
    cout << (X >= 30 ? "Yes" : "No") << ln;
}


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

// グローバル変数
ll k, n;
vector<ll> a;
//vector<int> c;

// 関数プロトタイプ
void input();
void solve();

int main(void)
{
    input();
    solve();  
}

// 標準入力
void input() {
    cin >> k >> n;
    a.resize(n);
    for (int i = 0; i < n;i++) {
        cin >> a[i];
    }
}

void solve() {
    vector<ll> dist(n);
    dist[0] = a[0] + k - a[n - 1];
    for (int i = 0; i < n-1;i++) {
        dist[i + 1] = a[i + 1] - a[i];
    }
    sort(dist.begin(), dist.end(), greater<ll>());
    cout << k - dist[0] << endl;
}

Measured memory_bytes: 3456
N=int(input())
syougen=[]
for i in range(N):
  A=int(input())
  X=[list(map(int,input().split())) for i in range(A)]
  syougen.append(X)

def chk(l,X):
  for x,y in l:
    if X[x-1]!=str(y):
      return True
    else:
      continue
  return False

ans=0
for i in range(2**N):
  flg=True
  X=format(i,'b').zfill(N)
  for j,x in enumerate(X):
    if x=='0':
      continue
    elif chk(syougen[j],X):
      flg=False
      break
  if flg:
    _ans=sum(list(map(int,''.join(X))))
    if _ans>ans:
      ans=_ans
  
print(ans)

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

const int MOD = 1e9 + 7;

main() {
  int N; cin >> N;
  ll ans = 1;
  for (int i = 1; i <= N; i++) {
    ans = (ans * i) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    ll N;
    cin >> N;
    set<ll> s;
    ll C;
    rep(i,N){
        cin >> C;
        if (s.find(C) == s.end()){
            s.insert(C);
        } else {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;    
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int ans;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    rep(i, 0, s.size()) {
        if (s[i] == '1') ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    map<char, int> cm;
    string ans;
    
    rep(i, n) {
        string s;
        cin >> s;
        map<char, int> tmp;
        
        if (i == 0) {
            rep(ii, s.length()) {
                cm[s[ii]]++;
            }
        }
        else {
            rep(ii, s.length()) {
                tmp[s[ii]]++;
            }
            
            for (auto u : cm) {
                cm[u.first] = min(u.second, tmp[u.first]);
            }
        }
    }
    
    for (auto u : cm) {
        rep(i, u.second) {
            ans += u.first;
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

#define INF 1e10
const int MOD = 1e9+7;

ll dp[1111][1111];
string s[1111];

int main(){
	int h, w;
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		cin >> s[i];
	}
	dp[0][0]=1;
	for(int i = 1; i < w; i++){
		if(s[0][i]=='.')dp[0][i]+=dp[0][i-1];
		else dp[0][i]=0;
	}
	for(int i = 1; i < h; i++){
		if(s[i][0]=='.')dp[i][0]+=dp[i-1][0];
		else dp[i][0]=0;
	}
	for(int i = 1; i < h; i++){
		for(int j = 1; j < w; j++){
			if(s[i][j]=='.')dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
			else dp[i][j]=0;
		}
	}
	cout<<dp[h-1][w-1];
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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;}

void solve(){
    ll n,m;cin>>n>>m;
    vec a(n);rep(i,n)cin>>a[i];
    sort(all(a));

    ll h=INF;
    ll l=0;
    while(h-l>1){
        ll mid=h+l>>1;
        ll cnt=0;
        rep(i,n){
            ll idx=lower_bound(all(a),mid-a[i])-a.begin();
            cnt+=n-idx;        
        }
        if(cnt<m)h=mid;
        else l=mid;
    }

    vec s(n+1);rep(i,n)s[i+1]=s[i]+a[i];
    ll ans=0;
    ll cnt=0;
    rep(i,n){
        ll idx=lower_bound(all(a),l-a[i])-a.begin();
        ans+=s[n]-s[idx]+a[i]*(n-idx);
        cnt+=n-idx;
    }
    cout<<ans-l*(cnt-m)<<endl;
}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll num(ll n, ll c, ll d){
    ll n_c = n/c;
    ll n_d = n/d;
    ll minseki = c / __gcd(c, d) * d;
    return n - n/c - n/d + n/minseki;
}

signed main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = 0;
    ll div_c = 0, div_d = 0, div_all = 0;
    ll minseki = c / __gcd(c, d) * d;
    
    
    ans = num(b, c, d) - num(a-1, c, d);
   
    cout << ans << endl;

}

Measured memory_bytes: 3628
import itertools
import copy
n = int(input())
ps = list(map(int, input().split()))

c = list(itertools.combinations(range(n), 2))

ps_sort = sorted(ps)
if ps == ps_sort:
  print('YES')
  exit()
else:
  for i in range(len(c)):
    nps  = copy.copy(ps)
    nps[c[i][0]], nps[c[i][1]] = nps[c[i][1]], nps[c[i][0]]
    if nps == ps_sort:
      print('YES')
      exit()
  else:
    print('NO')
  
                                                
  

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

using namespace std;

int main()
{
    int a, b;
    int points = 0;
    cin >> a >> b;

    if(a >= b){
        points += a;
        a--;
    }else{
        points += b;
        b--;
    }
    if (a >= b)
    {
        points += a;
        a--;
    }
    else
    {
        points += b;
        b--;
    }
    cout << points << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <iterator>

int main()
{
    std::list<int> L = {};
    int q, query, x;
    int d = 0;
    std::list<int>::iterator pos;
    pos = L.end();

    std::cin >> q;

    for (int i = 0; i < q; ++i)
    {
        std::cin >> query;
        switch (query)
        {
        case 0:
            std::cin >> x;
            pos = L.insert(pos, x);
            break;
        case 1:
            std::cin >> d;
            pos = std::next(pos, d);
            break;
        case 2:
            pos = L.erase(pos);
            break;
        }
    }
    int size = L.size();
    for (std::list<int>::iterator it = L.begin(); it != L.end(); it++)
    {
        std::cout << *it << std::endl;
    }
}



Measured memory_bytes: 18564
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define rep(i,a,b,c)            for(int i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(int i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define vpii                    vector<pair<int,int>>
#define si                      set<int>
#define usi                     unordered_set<int>
#define vi                      vector<int>
#define vld                     vector<ld>
#define vvi                     vector<vector<int>>
#define vvld                    vector<vector<ld>>
#define pii                     pair<int,int>
#define vvpii                   vector<vector<pair<int,int>>>
#define pqi                     priority_queue<int>
#define mii                     map<int,int>
#define mic                     map<int,char>
#define um                      unordered_map
#define umii                    um<int,int>
#define umic                    um<int,char>
#define umci                    um<char,int>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    int Testcases;cin>>Testcases;while(Testcases--)
#define input(a,n)              for(int i=0;i<n;++i) cin>>a[i];
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
	inp_out();
	int n,k;
	cin>>n>>k;
	si st;
	for(int i=1;i<=n;++i)
		st.insert(i);
	for(int i=0;i<k;++i)
	{
		int d,x;
		cin>>d;
		for(int j=0;j<d;++j)
		{
			cin>>x;
			st.erase(x);
		}
	}
	cout<<st.size();
	return 0;
}

Measured memory_bytes: 3620
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    s = input()
    ans = 0
    for i1 in range(10):
        for i2 in range(10):
            for i3 in range(10):
                ii1 = s.find(str(i1))
                if ii1 == -1:
                    continue
                ii2 = s[ii1+1::].find(str(i2))
                if ii2 == -1:
                    continue
                ii3 = s[ii1+1+ii2+1::].find(str(i3))
                if not ii3 == -1:
                    ans += 1
    print(ans)


    return

if __name__ == '__main__':
    main()


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;
VL a, idx;

int main() {
    cin >> N;
    idx.resize(N + 1);
    FOR(i, 1, N + 1) idx[IN()] = i;
    ll ans = 0;
    set<ll> used = {0, N + 1};
    FOR(i, 1, N + 1) {
        ll l, r;
        auto itr = used.upper_bound(idx[i]);
        r = *itr;
        l = *(--itr);
        ans += i * (idx[i] - l) * (r - idx[i]);
        used.insert(idx[i]);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 105
#define ll long long
#define db double
#define dbg1(x) cout<<#x<<"="<<x<<" "
#define dbg2(x) cout<<#x<<"="<<x<<"\n"
int n,mark[N],ecnt,last[N],ans,used[N],match[N];
struct point{int x,y;}A[N],B[N];
struct road{int to,nex;}e[N*N];
void adde(int u,int v) {e[++ecnt]=(road){v,last[u]},last[u]=ecnt;}
bool dfs(int x)
{
	for(int k=last[x];k;k=e[k].nex)
		if(!used[e[k].to])
		{
			used[e[k].to]=1;
			if(!match[e[k].to]||dfs(match[e[k].to])) return match[e[k].to]=x,1;
		}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&A[i].x,&A[i].y);
	for(int i=1;i<=n;i++) scanf("%d%d",&B[i].x,&B[i].y);
//	sort(A+1,A+1+n),sort(B+1,B+1+n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(A[i].x<B[j].x&&A[i].y<B[j].y) adde(i,j);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++) used[j]=0;
		if(dfs(i)) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(void){
	int n;

	cin >> n;

	int a, num2 = 0, num4 = 0;
	for (int i = 0; i < n; i++){
		cin >> a;

		if (a % 4 == 0)
			num4++;
		else if (a % 2 == 0)
			num2++;
	}


	if (num2 > 0)
		if (2*num4 + num2 < n)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	else
		if (2*num4 + 1 < n)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;		
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
  	cin>>N;
  	bool flag = false;
  	for(int i=0;i<N;i++){
      string x;
      cin>>x;
      if(x=="Y")flag=true;
    }
  	cout<<(flag?"Four":"Three")<<endl;
}

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

class Dice {
public:
  int face[6];
  Dice() {
    face[0] = 1;
    face[1] = 5;
    face[2] = 4;
    face[3] = 6;
    face[4] = 2;
    face[5] = 3;
  }

  /*
    ツサツイツコツδ債づーツ転ツつェツつキツ。
    dir : ツ嘉アツ転ツつキツづゥツ陛サツ古シ
          1 -> xツ陛サツ古シ
          2 -> yツ陛サツ古シ
          ツ閉可づ個青板づ可つキツづゥツつアツづづ逆ツ古シツつォツづ可づ按づゥ
  */
  void roll(int dir) {
    int tmp;
    bool reverse;
    if(dir < 0) {
      dir *= -1;
      reverse = true;
    } else {
      reverse = false;
    }
    tmp = face[0];
    switch(dir) {
    case 1:
      if(reverse) {
	face[0] = face[1];
	face[1] = face[3];
	face[3] = face[4];
	face[4] = tmp;
      } else {
	face[0] = face[4];
	face[4] = face[3];
	face[3] = face[1];
	face[1] = tmp;
      }
      break;
    case 2:
      if(reverse) {
	face[0] = face[2];
	face[2] = face[3];
	face[3] = face[5];
	face[5] = tmp;
      } else {
	face[0] = face[5];
	face[5] = face[3];
	face[3] = face[2];
	face[2] = tmp;
      }
      break;
    }
  }
};

int main() {
  while(1) {
    int n;
    string str;
    Dice dice;

    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; i++) {
      cin >> str;
      if(str == "north") {
	dice.roll(-1);
      } else if(str == "east") {
	dice.roll(2);
      } else if(str == "south") {
	dice.roll(1);
      } else if(str == "west") {
	dice.roll(-2);
      }
    }

    cout << dice.face[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import numpy as np
n,m,c = map(int,input().split())
B = np.array(list(map(int,input().split())))
A = []
for _ in range(n):
    A.append(list(map(int,input().split())))

             
a = np.array(A)
ans = 0
for i in range(n):
    k = c + sum(B *a[i])
    if k >0:
        ans+= 1
print(ans) 

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

int main(){
	while(1){
		int h,w;
		cin >> h >> w;
		if (h == 0 and w == 0)break;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(i % 2 == 0 and j % 2 == 0)cout << "#";
				if(i % 2 == 1 and j % 2 == 0)cout << ".";
				if(i % 2 == 0 and j % 2 == 1)cout << ".";
				if(i % 2 == 1 and j % 2 == 1)cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>

int main(){
  int n,m,sum=0,key,T[100005];
  int i,j,f;
  int left,right,mid;

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

  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d",&key);

    //BinarySearch                                                                                                                                          
    left = 0;
    right = n;
    f = 0;
    while(left<right){
      mid = (left + right)/2;
      if(T[mid]==key){
        f = 1;
        break;
      }
      if(T[mid]<key){
        left = mid+1;
      }else if(T[mid]>key){
        right = mid;
      }
    }
    if(f)sum++;
  }

  printf("%d\n",sum);

  return 0;
}

Measured memory_bytes: 988
#include <iostream>
#include <vector> 
#include <algorithm>
// #include <bits/stdc++.h>
using namespace std;

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

    vector<int> vec(N);

    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int flag = 1;
    int count = 0;

    while(flag) {

        flag = 0;
        for (int j = N - 1; j > 0; j--) {
            if(vec.at(j) < vec.at(j - 1)) {
                int temp = vec.at(j);
                vec.at(j) = vec.at(j - 1);
                vec.at(j - 1) = temp;

                flag = 1;

                count ++;
            }
        }
    }

    for (int k = 0; k < N; k++) {
        if(k == N - 1) {
            cout << vec.at(k);
        } else {
            cout << vec.at(k) << " ";
        }
    }

    cout << endl;

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3096
def cooking_takoyaki(target_num, cook_per, need_time):
    div, mod =divmod(target_num, cook_per)
    if mod == 0:
        return div * need_time
    return div * need_time + need_time

if __name__=='__main__':
    a, b, c = map(int, input().split())
    print(cooking_takoyaki(a, b, c))

Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<58;
const double eps = 1e-13;

int d[100009];
int cameout[100009];
int cc[100009];
vector<int> sq;

int main(){
	DRIII(n,m,q);//number of arrays,length
	REP(i,q){
		RI(d[i]);d[i]--;
	}
	MS1(cameout);
	int ci=0;
	for(int i=q-1;i>=0;i--){
		if(cameout[d[i]]!=-1)continue;
		cameout[d[i]]=ci++;
		sq.PB(d[i]);
	}
	int minleft=100009;
	REP(i,m){
		if(cameout[i]==-1)minleft=min(minleft,i);
	}
	for(int i=ci-1;i>=0;i--){
		if(sq[i]<minleft){
			cameout[sq[i]]=-1;
			ci--;
			minleft=sq[i];
		}
		else break;
	}
	for(int i=q-1;i>=0;i--){
		if(cameout[d[i]]==-1)continue;
		int ci=cameout[d[i]];
		cc[ci]++;
		if(ci!=0){
			cc[ci]=min(cc[ci],cc[ci-1]);
		}
	}
	//printf("%d",ci);
	REP(i,ci){
		if(cc[i]<n){
			printf("No");return 0;
		}
	}printf("Yes");
}


Measured memory_bytes: 1912
#include <stdio.h>
#include <stdlib.h>
int num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
int main(void){
    int n, x;
    int m[100000];
    int i, dif=0, ans=0, min=0;
    
    n = num();
    x = num();
    for(i=0; i<n; i++){
        m[i] = num();
    }
    dif = x;
    for(i=0; i<n; i++){
        dif = dif-m[i];
        ans++;
    }
    min = m[0];
    for(i=0; i<n; i++){
        if(min > m[i]){
            min = m[i];
        }
    }
    while(dif >= min){
        dif = dif-min;
        ans++;
    }
    printf("%d", ans);
    //printf("%d,%d,%d\n", dif, ans, min);
    
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int n;
	long long int b[110],ans = 0;
	cin >> n;
	for (int i = 0; i < n - 1; i++) { cin >> b[i]; }
	ans += b[0];
	for (int i = 0; i < n - 2; i++)
	{
		ans += min(b[i], b[i + 1]);
	}
	ans += b[n - 2];
	cout << ans << endl;
	return 0;
}

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

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

ll W, H;
ll cnt;

void dfs(vector<string> &A, ll x, ll y){
    cnt++;
    A[y][x]='#';

    FOR(i, 0, 4){
        ll tx = x + dx[i];
        ll ty = y + dy[i];

        if(0<=tx && tx<W && 0<=ty && ty<H && A[ty][tx]=='.'){
            dfs(A, tx, ty);
        }
    }
}

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

    for(;;){
        cin >> W >> H;

        if(W==0 && H==0){
            return 0;
        }

        vector<string> A(H);
        FOR(i, 0, H){
            cin >> A[i];
        }

        ll start_x, start_y;
        FOR(y, 0, H){
            FOR(x, 0, W){
                if(A[y][x]=='@'){
                    start_x = x;
                    start_y = y;
                }
            }
        }

        cnt = 0;
        dfs(A, start_x, start_y);
        p(cnt);
    }
    
    return 0;
}


Measured memory_bytes: 3044
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        char[][] s = new char[n][];
        int[][] count = new int[n][4];
        int sum = 0;
        int sum2 = 0;
        for(int i=0;i<n;i++){
            s[i] = sc.next().toCharArray();
            count[i][2] = i;
            for(int j=0;j<s[i].length;j++){
                if(s[i][j]=='('){
                    count[i][0]++;
                    sum++;
                }else{
                    if(count[i][0] > 0){
                        count[i][0]--;
                    }else{
                        count[i][1]++;
                    }
                    sum2++;
                }
            }
            if(count[i][0] > 0 && count[i][1] > 0){
                count[i][3] = 2;
            }else if(count[i][0] > 0){
                count[i][3] = 1;
            }else if(count[i][1] > 0){
                count[i][3] = 3;
            }else{
                count[i][3] = 4;
            }

        }
        sc.close();
        if(sum!=sum2){
            System.out.println("No");
            return;
        }
        final int a = sum;
        Arrays.sort(count,new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
                if(o1[3] == o2[3] && o1[3] == 2){
                    int a1 = o1[1]-a;
                    int a2 = o2[1]-a;
                    if(a1<=0 && a2<=0 || a1>=0 && a2>=0){
                        return (o2[0]-o2[1])-(o1[0]-o1[1]);
                    }else{
                        return o1[1]-o2[1];
                    }
                }else{
                    return o1[3] - o2[3];
                }
				
			}
        });
        sum = 0;
        for(int i=0;i<n;i++){
            if(count[i][3]==2){
                sum-=count[i][1];
                if(sum < 0){
                    System.out.println("No");
                    return;
                }
                sum+=count[i][0];
            }else{
                sum+=count[i][0];
                sum-=count[i][1];
                if(sum<0){
                    System.out.println("No");
                    return;
                }
            }
        }

        System.out.println("Yes");


    }
    
}

Measured memory_bytes: 133744
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;
int main()
{
    int n,i,j,k;k=0;
    int a[100005],b[100005],c[100005];
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {scanf("%d",&a[i]);
    b[a[i]]+=1;
    }
    for(i=1;i<=100005;i++)
        c[i]=b[i-1]+b[i]+b[i+1];
    for(i=1;i<=100005;i++)
    {
       if(k<c[i])
            k=c[i];
    }
    printf("%d",k);
    return 0;
}

Measured memory_bytes: 1408
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

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

mod = 10**9+7
n = int(input())
a = list(map(int,input().split()))
L = a[0]
for i in a:
    L = lcm(L,i)
    
ans = 0
for i in a:
    ans += (L // i )
print(ans % mod)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,kt;
int main()
{
    kt = 0;
    cin >> n;
    for(int i = 1;i <= n;i ++)
    {
        ll x;
        cin >> x;
        if(x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) kt = 1;
    }
    kt == 1 ? cout << "DENIED" : cout << "APPROVED";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ac,wa,tle,re;string s;
int main(){
	cin>>n;
	while(n--){
		cin>>s;
		if(s=="AC")ac++;
		if(s=="WA")wa++;
		if(s=="TLE")tle++;
		if(s=="RE") re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(){
    int m, f, r;
    while(1){
        scanf("%d %d %d ", &m, &f, &r);
        if(m==-1&&f==-1&&r==-1)break;
        if(m==-1||f==-1){
            printf("F\n");
        }else if(m+f>=80){
            printf("A\n");
        }else if(m+f>=65){
            printf("B\n");
        }else if(m+f>=50){
            printf("C\n");
        }else if(m+f>=30){
            if(r>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else{
            printf("F\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll T;
    cin >> T;
    int N;
    cin >> N;
    vector<pair<ll, ll>> A(N);
    vector<ll> B(N + 1, 0);
    rep(i, N){
        cin >> A[i].first >> A[i].second;
        if(A[i].second - A[i].first > T) B[i + 1] = T;
        else B[i + 1] = A[i].second - A[i].first;
    }
    
    ll ret = 0;
    
    int cur = 0;
    ll sum = 0;
    ll tmp = 0;
    rep(i, N){
        sum -= B[i];
        sum -= tmp;
        while(A[cur].second <= A[i].first + T && cur < N){
            sum += A[cur].second - A[cur].first;
            cur++;
        }
        if(cur < N){
            if(A[cur].first <= A[i].first + T){
                sum += A[i].first + T - A[cur].first;
                tmp = A[i].first + T - A[cur].first;
            }
        }
        ret = max(ret, sum);
//        cout << i << ":" << ret <<  endl;
    }

    output(ret, 0);
    
    return 0;
}

Measured memory_bytes: 5208
x1, x2, x3, x4, x5= map(int, input().split())
if x1==0:
    print("1")
elif x2 == 0:
    print("2")
elif x3 == 0:
    print("3")
elif x4 ==0:
    print("4")
elif x5 == 0:
    print("5")

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ff first
#define ss second
#define ii pair<int,int>
#define lp(x,y) for(ll i=x;i<y;i++)
#define pb push_back
const int N = 200 * 1000 + 11;
 
 
int main() 
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}

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


signed main() {

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    #endif

    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for( int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    int s = 0;
    for( int i = 0; i < k; i++) {
        s += v[i];
    }

    cout << s << '\n';

}

Measured memory_bytes: 3576
a,v = gets.strip.split.map(&:to_i)
b,w = gets.strip.split.map(&:to_i)
t = gets.strip.to_i
vw = v - w
if vw > 0 && ( (a - b).abs + vw - 1) / vw <= t
    puts "YES"
else
    puts "NO"
end

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

int n;
map<string, int> m;

int main() {
    cin >> n;
    string s;
    cin >> s;
    m[s]++;
    long long ans = 1;
    for (int i=1; i<n; i++) {
        cin >> s;
        if (m[s] == 0) {
            m[s]++;
            ans++;
        }
        else continue;
    }
    cout << ans;
}

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

int main(void)
{
	long long a, b;
	long long x;
	cin >> a >> b;
	cin >> x;


	if (a % x == 0) {
		cout << b / x - a / x  + 1 << endl;

	}
	else {
		cout << b / x - a / x << endl;
	}




	
	return (0);
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,ans=0;
    cin>>n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin>>p[i];
    }
    int mi=n+1;
    for (int i = 0; i < n; i++)
    {
        if(p[i]<mi) ans++;
        mi=min(mi,p[i]);
    }
    cout<<ans<<endl;
    
    return 0;
}

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

int main(){
	int m, n;
	int A[100][100], b[100], c[100];
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	for(int i = 0; i < n; i++){
		c[i] = 0;
		for(int j = 0; j < m; j++){
			c[i] += A[i][j] * b[j];
		}
	}
	for(int i = 0; i < n; i++){
		cout << c[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
split _ [] = []
split n x = (take n x):(split n $ drop n x)

ans ([n,m]:as) =
  let g = lcm n m
      s = split m $ concat $ take (g`div`n) $ cycle as
      r = sum $ map (\x -> (maximum x) - (minimum x)) s
  in
    r

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c
      o = ans i
  print o



Measured memory_bytes: 49916