akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define mp make_pair
#define _1 first
#define _2 second

ll C(ll n, ll k) {
    if (k > n) return 0;
    ll ret = 1;
    ROF(i, n, n - k + 1) ret *= i;
    FOR(i, 1, k) ret /= i;
    return ret;
}

int main() {
    ll n, k;
    scanf("%lld%lld", &n, &k);
    ll upp = n / k;
    ll ans = 6 * C(upp, 3) + C(upp, 2) * 6 + C(upp, 1);
    if (k % 2 == 0) {
        upp = (n + k / 2) / k;
        ans += C(upp, 3) * 6 + C(upp, 2) * 6 + C(upp, 1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
#define read(n) scanf("%d",&n)
#define f(i,a,b) for(int i=a;i<=b;++i)
int main()
{
	int num[1005];
	int n,ans=0,k;
	read(n);read(k);
	f(i,1,n) read(num[i]);
	sort(num+1,num+1+n);
	f(i,1,k) ans+=num[i];
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3768
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        x: usize,
        y: usize,
        z: usize
    }

    println!("{} {} {}", z, x, y);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

int main(void){
    int a, b;
    char s[15];
    int i;
    int flag = 0;
    scanf("%d %d", &a, &b);
    scanf(" %s", s);
    if (s[a] == '-'){
        flag = 1;
    }
    if (strlen(s) != a+b+1){
        flag = 0;
    }
    for (i = 0; i < a; i++){
        if (s[i] < '0' || s[i] > '9'){
            flag = 0;
        }
    }

    for (i = a+1; i < strlen(s); i++){
        if (s[i] < '0' || s[i] > '9'){
            flag = 0;
        }
    }

    if (flag == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;


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

ll A,B,N;
cin >> A >> B >> N;

ll x;
if(N < B) x = N;
else x = B-1;

ll ans = (ll)floor((double)(A*x) / (double)(B));
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3700
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){

int N;
while(1){
	cin>>N;if(N==0)break;
	int i,I=0;
	double w,h;
	double min=0;

	cin>>i>>h>>w;
	h=h/100;
	if(w/h/h<=22)min=22-w/h/h;
	else min=w/h/h-22;
	I=i;
	for(int ii=1;ii<N;ii++)
	{
		cin>>i>>h>>w;
		h=h/100;
		if(min>22-w/h/h&&w/h/h<=22){min=22-w/h/h;I=i;}
		else if(min>w/h/h-22&&w/h/h>22){min=w/h/h-22;I=i;}
	
	}
	cout<<I<<endl;
}
return 0;
}

Measured memory_bytes: 1228
import numpy as np

H, W = map(int,input().split())

board = []
arr = np.empty((0,W),str)

for i in range(H):
  string = list(str(input()))
  board.append(string)
  arr = np.append(arr, np.array([string]), axis=0)

delete_h = []
delete_w = []
for i in range(H):
  cc = 0
  for j in range(W):
    if board[i][j] == "#":
      cc += 1
  if cc == 0:
    delete_w.append(i)

for i in range(W):
  cc = 0
  for j in range(H):
    if board[j][i] == "#":
      cc += 1
  if cc == 0:
    delete_h.append(i)
    
delete_w.reverse()
delete_h.reverse()

for i in delete_h:
  arr = np.delete(arr, i, 1)

for i in delete_w:
  arr = np.delete(arr, i, 0)

for i in range(H-len(delete_w)):
  print("".join(arr[i]))





Measured memory_bytes: 12628
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int N;
	long long a1[100000];
	long long a2[100000];
	long long a3[100000];

	scanf("%d", &N);
	for(int i=0;i<N;i++) scanf("%lld", &a1[i]);
	for(int i=0;i<N;i++) scanf("%lld", &a2[i]);
	for(int i=0;i<N;i++) scanf("%lld", &a3[i]);

	priority_queue<long long> PQ, PQ2;

	long long plus[100001];
	long long minus[100001];
	memset(plus,0,sizeof(plus));
	memset(minus,0,sizeof(minus));

	for(int i=0;i<N;i++) PQ.push(-a1[i]);
	for(int i=0;i<N;i++) PQ2.push(a3[i]);

	for(int i=0;i<N;i++) plus[0] += a1[i];
	for(int i=0;i<N;i++) minus[N] += -a3[i];

	for(int i=0;i<N;i++){
		PQ.push(-a2[i]);
		plus[i+1] = plus[i] + a2[i] + PQ.top();
		PQ.pop();
	}

	for(int i=0;i<N;i++){
		PQ2.push(a2[N-1-i]);
		minus[N-1-i] = minus[N-i] - a2[N-1-i] + PQ2.top();
		PQ2.pop();
	}
	/*
	for(int i=0;i<=N;i++) printf("%lld ", plus[i]);
	printf("\n");
	for(int i=0;i<=N;i++) printf("%lld ", minus[i]);
	printf("\n");
	*/

	long long ans = plus[0] + minus[0];
	for(int i=0;i<=N;i++){
		ans = max(ans, plus[i] + minus[i]);
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 6516
N = int(input())
A = list(map(int,input().split()))

flg = 1
for a in A:
    if a%2 == 0:
        if not (a%3 == 0 or a%5 == 0):
            flg = 0

if flg:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int dp[n];
	dp[n-1]=0;
	dp[n-2]=abs(a[n-1]-a[n-2]);
	for(int i=n-3;i>=0;i--){
		dp[i]=min(abs(a[i]-a[i+1])+dp[i+1],abs(a[i]-a[i+2])+dp[i+2]);
	}	
	cout<<dp[0];
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		final int t = sc.nextInt();
		
		for(int tt = 0; tt < t; tt++){
			final int n = sc.nextInt();
			final int k = sc.nextInt();
			
			int[] len = new int[n];
			for(int i = 0; i < n; i++){
				len[i] = sc.nextInt();
			}
			Integer[] dist = new Integer[n-1];
			for(int i = 0; i < n - 1; i++){
				dist[i] = len[i + 1] - len[i];
			}
			
			Arrays.sort(dist, Collections.reverseOrder());
			
			int sum = 0;
			for(int i = k - 1; i < n - 1; i++){
				sum += dist[i];
			}
			
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 108364
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
countlist = []
tmp = 0
for i in range(0, N):
	if tmp != A[i]:
		countlist.append([A[i], 0])
		tmp = A[i]
	countlist[-1][1] += 1
countlist.sort(key = lambda v: v[1])
sum = 0
for i in range(0, len(countlist)-K):
	sum += countlist[i][1]
print(sum)

Measured memory_bytes: 100560
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-19 20:12:22
---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{

	int s;
	cin >> s;
	int flag = 0;
	int a, b;
	a = s/100; b = s%100;
	// cout << a << ' ' << b << endl;
	if(1 <= b && b <= 12)	flag += 1;	//yymm
	if(1 <= a && a <= 12)	flag += 2;	//mmyy
	if(flag == 0)	cout << "NA" << endl;
	if(flag == 1)	cout << "YYMM" << endl;
	if(flag == 2)	cout << "MMYY" << endl;
	if(flag == 3)	cout << "AMBIGUOUS" << endl;

	return 0;
}

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

int n,k;
ll a[200005];

int main(void){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<n-k;i++){
		if(a[i]<a[i+k]){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}


Measured memory_bytes: 5316
#include <stdio.h>

int ST(int hi[],int n,int key);
int main()
{
  int i,n,q,key,count=0;
  int hi[10001];

  scanf ("%d",&n);
  for (i=0;i<n;i++)
    scanf("%d",&hi[i]);
  scanf ("%d",&q);
  for (i=0;i<q;i++){
    scanf ("%d",&key);
    if ( ST(hi,n,key) )
      count++;
  }
  printf ("%d\n",count);
  return 0;
}
  

int ST (int hi[],int n,int key){
  int i=0;
  hi[n]=key;
  while(hi[i]!=key)
    i++;
  return i!=n;
}
  



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

template <typename T>
T gcd(T a, T b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}

template <typename T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

int main(void) {
  lint a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
  return 0;
}

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

int main(){
    set<int > s;
    int x;
    for(int i=1;i<=3;i++){
        cin>>x;
        s.insert(x);
    }
    if(s.size()==2)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int x[5], i;
  for(i = 1; i <= 5; i++) scanf("%d", &x[i]);
  for(i = 1; i <= 5; i++){
    if(x[i] == 0){
      printf("%d\n", i);
    }
  }
  return 0;
}


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

main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE    
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout); 
    #endif

    int n;cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i+2<n;i++){
        int pass=1;
        for(int j=i;j<=i+2;j++){
            if(a[j][0]!=a[j][1])    pass=0;
        }
        if(pass){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int n,sum=0,a,b,x,c;
int main(){
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		x=i;c=0;
		while(x!=0){
			c+=x%10;x/=10;
		} 
		if(c>=a and c<=b)sum+=i;		
	}
	cout<<sum<<endl; 
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll a, b;
    cin >> a >> b;
    ll h = 100, w = 100;
    cout << h << " " << w << endl;
    vector<vector<char>> c(h / 2, vector<char> (w, '.'));
    vector<vector<char>> d(h / 2, vector<char> (w, '#'));
    a--;
    b--;
    for(int i = 1; i < h / 2; i += 3) {
        for(j = 1; j < w; j += 3) {
            if(b-- > 0) c[i][j] = '#';
        }
    }
    for(int i = 1; i < h / 2; i += 3) {
        for(j = 1; j < w; j += 3) {
            if(a-- > 0) d[i][j] = '.';
        }
    }
    for(vector<char> x:c){
        for(char ch:x)cout << ch;
        cout << endl;
    }
    for(vector<char> x : d) {
        for(char ch : x)
            cout << ch;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

// n を b 進数で表したとき、何桁になるか
int calc(int n, int b) {
    if (n == 0) return 1;

    int k = 0;
    while (n > 0) {
        n /= b;
        k++;
    }
    return k;
}

void main() {
    int n, k; scan(n, k);
    writeln(calc(n, k));
}


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

const ll INF = 1ll << 60;

int main(int argc, char **argv)
{
	int n; cin >> n;
	string str; cin >> str;

	vector<ll> white_sum(n+1, 0), black_sum(n+1, 0);
	for (int i = 0; i < n; ++i)
	{
		black_sum[i+1] = black_sum[i] + (str[i] == '#' ? 1 : 0);
		white_sum[i+1] = white_sum[i] + (str[i] == '.' ? 1 : 0);
	}

	ll res{INF};
	for (int left = 0; left <= n; ++left)
	{
		ll tmp{0};
		tmp += black_sum[left];
		tmp += white_sum[n] - white_sum[left];
		res = min(res, tmp);
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 3716
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0

int prime (int n)
{
    ll i;
    while(1){
        ll p=0;
        for(i=2; i<=sqrt(n); i++){
            if(n%i==0){
                p=1;
                break;
            }
        }
        if(p==1){
            n++;
        }
        else{
            return n;
        }

    }
}

int main () {
    ll a;
    cin>>a;
    cout<<prime(a)<<endl;
    End;
}
/* pray for me
All is well
*/



Measured memory_bytes: 256
import itertools

def get_target_list(source):
    targets = []
    for size in range(1, len(source) + 1):
        for x in itertools.combinations(source, size):
            targets.append(x)
    return targets

paramN, paramM, paramX = list(map(lambda x: int(x), input().split(' ')))
targets = get_target_list([list(map(lambda x: int(x), input().split(' '))) for i in range(paramN)])

price_sum = 10000000000
for books in targets:
    ps = 0
    tmp = [0 for i in range(paramM)]
    for book in books:
        ps += book[0]
        for i1, x in enumerate(book[1:]):
            tmp[i1] += x
    if len(list(filter(lambda y: y < paramX, tmp))) == 0:
        price_sum = min(price_sum, ps)

if price_sum == 10000000000:
    print(-1)
else:
    print(price_sum)

Measured memory_bytes: 9384
#include <stdio.h>

int main(void)
{
    int a, b;

    scanf("%d %d", &a, &b);
    if (a < b)
    {
        puts("a < b");
    }
    else if (a > b)
    {
        puts("a > b");
    }
    else
    {
        puts("a == b");
    }

    return 0;
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int taro = 0, hanako = 0;
        rep(i,n){
            string a,b;
            cin >> a >> b;
            if(a > b) taro+= 3;
            else if(a < b) hanako+= 3;
            else {
                taro++; hanako++;
            }
        }
        cout << taro << ' ' << hanako << endl;
    }
}

Measured memory_bytes: 1212
if __name__=="__main__":
    N = int(input())
    same = 0
    for i in range(N):
        D1, D2 = (int(x) for x in input().split())
        if D1==D2:
            same += 1
        else:
            if same>=3:
                continue
            else:
                same = 0
    if same>=3:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	cout<<min(a*e,b+max(e-c,0)*d)<<endl;
}



Measured memory_bytes: 3172
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	Wn := make([]string, N)
	Wnsort := make([]string, N)
	for i := range Wn {
		Wn[i] = nextLine()
	}
	copy(Wnsort, Wn)

	sort.Strings(Wnsort)
	for i := 0; i < N-1; i++ {
		if Wn[i][len(Wn[i])-1] != Wn[i+1][0] || Wnsort[i+1] == Wnsort[i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

int main()
{
    ll n,output=3;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    if(!prev_permutation(a.begin(), a.end())){
        next_permutation(a.begin(), a.end());
        output--;
    };


    rep(i,output){
        rep(i,n)
            cout << (i ? " " : "") << a[i];
        cout << endl;

        if(!next_permutation(a.begin() , a.end())) break;
    };

    return 0;
}


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


void solve(long long N){
    int i=(int) log2(N);
    int ans = 1;
    for(int j=0; j< i; j++)
        ans *= 2;
    cout <<  ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main(){
  int n;
  int sura[101]={};
  int cnt=0;

  cin >> n;

  for(int i=0;i < n;i++){
    cin >> sura[i];
  }

  for(int i=0;i+1 < n;i++)
    {
      if(sura[i] == sura[i+1])
	{
	  sura[i+1] = 0;
	  i++;
	}
    }
  for(int i=0;i < n;i++)
    {
      if(sura[i] == 0)cnt++;
    }
  cout << cnt << endl;
  return 0;
}


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

vector<int> init = {0, 1, 2, 3, 4, 5, 6, 7};
vector<vector<int>> adj = {
    {1, 4},
    {0, 2, 5},
    {1, 3, 6},
    {2, 7},
    {0, 5},
    {1, 4, 6},
    {2, 5, 7},
    {3, 6}
};

map<vector<int>, int> d;

int solve(vector<int> init, vector<int> goal) {
    if (d.find(goal) != d.end()) {
        return d[goal];
    }
    d.clear();
    d[init] = 0;
    queue<vector<int>> q;
    q.push(init);
    while ( ! q.empty()) {
        vector<int> v = q.front();
        q.pop();
        int step = d[v];
        if (v == goal) return step;
        for (int i=0; i<8; ++i) {
            if (v[i] == 0) {
                for (int j=0; j<(int)adj[i].size(); ++j) {
                    swap(v[i], v[adj[i][j]]);
                    if (d.find(v) == d.end()) {
                        q.push(v);
                        d[v] = step + 1;
                    }
                    swap(v[i], v[adj[i][j]]);
                }
            }
        }
    }
    return -1;
}

int main() {
    vector<int> v(8);
    while (1) {
        for (int i=0; i<8; ++i) {
            if (cin >> v[i]) { } else { return 0; }
        }
        cout << solve(init, v) << endl;
    }
    return 0;
}

Measured memory_bytes: 3828
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        r: usize,
    }
    println!("{}", r * r * 3);
}


Measured memory_bytes: 4352
def main():
    N = int(input())
    data = []
    for i in range(1, N+1):
        tmp = []
        city, score = input().split()
        tmp.append(i)
        tmp.append(city)
        tmp.append(int(score))
        data.append(tmp)

    data.sort(key=lambda x: x[2], reverse = True)
    data.sort(key=lambda x: x[1])

    for i in range(0, N):
        print(data[i][0])


if __name__ == "__main__":
    main()


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

long long d[1000050];
int head[1000500],n,size;

struct edge
{
	int to,next;
	long long val;
}e[1000050];

void addedge(int u,int v,long long w)
{
	e[++size].to=v;
	e[size].val=w;
	e[size].next=head[u];
	head[u]=size;
}

void dfs(int u,int fa)
{
	for(int i=head[u]; i; i=e[i].next)
	{
		int to=e[i].to;
		if(to==fa)continue;
		d[to]=d[u]+e[i].val;
		dfs(to,u);
	}
}

int main()
{
	cin>>n;
	for(int i=1; i<n; i++)
	{
		long long u,v,w;
		cin>>u>>v>>w;
		addedge(u,v,w);
		addedge(v,u,w);
	}
	int q,k;
	cin>>q>>k;
	dfs(k,0);
	for(int i=1; i<=q; i++)
	{
		int x,y;
		cin>>x>>y;
		printf("%lld\n",d[x]+d[y]);
	}
	return 0;
}

Measured memory_bytes: 14720
import java.util.Scanner;
public class Main{
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
        int x=sc.nextInt();
        int y=x*x*x;
        System.out.print(y);
        System.out.println();
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

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

int main() {
    int r, d, x;
    cin >> r >> d >> x;

    for (int i = 2001; i <= 2010; ++i) {
        x = max(0, r * x - d);
        cout << x << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int getint()
{
	int x = 0;
	char c;

	do {
		c = getchar();

		if (c == ' ' || c == '\n')
			break;

		x *= 10;
		x += c - '0';
	} while (1);

	return x;
}

const int INT_DIGIT = 1000000000;

void putint(const int x)
{
	int digit = INT_DIGIT;

	while (!(x / digit))
		digit /= 10;

	while (digit) {
		putchar((x / digit % 10) + '0');
		digit /= 10;
	}
}

int main()
{
	int k = getint();

	putint((k / 2) * ((k+1) / 2));

	return 0;
}

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

bool path[51][51] = {};
int n, m, a, b;

int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        path[a][b] = path[b][a] = true;
    }

    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(!path[i][j]) continue;

            path[i][j] = path[j][i] = false;

            stack<int> s;
            s.push(a);
            bool visit[n+1];
            for(int i = 0; i < n+1; i++)    visit[i] = false;

            while(!s.empty()){
                int x = s.top(); s.pop();
                if(visit[x])    continue;

                visit[x] = true;
                for(int y = 0; y <= n; y++){
                    if(path[x][y] && !visit[y]) s.push(y);
                }
            }

            bool judge = true;
            for(int i = 1; i <= n; i++) judge &= visit[i];
            if(!judge)   cnt++;
            path[i][j] = path[j][i] = true;
        }
    }

    cout << cnt/2 << endl;

    return 0;
}

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

int main(){
  
  int n,x[100],i;

  cin >> n;
    for( i = 0 ; i < n ; i++){
      cin >> x[i];
    }

    for( i = n ; i > 0; i--){
      if(i < n)cout << " ";
      cout << x[i-1] ;
    }
  cout <<endl;

  return 0 ;

}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in);) {
			
			int i = 1;
			int x;
			
			while((x = sc.nextInt()) != 0) {
				System.out.println("Case " + i++ + ": " + x);
			}
		}
	}
}



Measured memory_bytes: 41760
import math
a,b,x=map(int,input().split())
a=float(a)
b=float(b)
x=float(x)
v=a*a*b
r=a*b*b
m=v-x
if 2*x<=v:
    print(math.degrees(math.atan(r/(2*x))))
else:
    print(math.degrees(math.atan(2*m/(a**3))))

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

int main() {
    int h, w;
    int i, j;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        for (i = 0; i < h; i++) {
            for (j = 0; j < w; j++) {
                if (i > 0 && i < h - 1 && j > 0 && j < w - 1) {
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 2992
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int ans = 0;
		String str = saori.nextHayami();


		String[] s = str.split("");
		
		for(int i = n - 1;i > 0;i--){
			if(s[i].equals(s[i-1])){
				ans++;
			}
		}
		System.out.println(n - ans);

		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 30036
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 35

struct LOC{
	LOC(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

int H,W;
char table[SIZE][SIZE];
vector<LOC> V;

int main(){

	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){

		scanf("%s",table[row]);

		for(int col = 0; col < W; col++){

			if(table[row][col] == 'B'){
				V.push_back(LOC(row,col));
			}
		}
	}

	int ans = 0;

	for(int i = 0; i < V.size()-1; i++){
		for(int k = i+1; k < V.size(); k++){

			ans = max(ans,abs(V[i].row-V[k].row)+abs(V[i].col-V[k].col));
		}
	}

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

	return 0;
}



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

using namespace std;

int main(){

  int l, r, d;
  cin>>l>>r>>d;
  
  int cnt=0;

  for(int i=l; i<=r; i++){
    if(i%d==0){
      cnt++;
    }
  }

  cout<<cnt<<endl;


}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  int K;
  string S;
  cin >> K>> S;
  if(K < S.size()){
  for(int i=0;i<K;i++){
    cout << S.at(i); 
  }
  cout << "..." << endl;
  }else{
    cout << S << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
// Never let them see you bleed...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

const int maxn = 310;

int dp[maxn][maxn], dp2[maxn][maxn], C[maxn][maxn];

int mod;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();
    
    int N, K;
    cin >> N >> K >> mod;
    for(int i = 0; i <= N; i++){
	C[i][0] = 1;
	for(int j = 1; j <= i; j++)
	    C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
    }
    for(int i = 0; i <= K; i++){
	dp[0][i] = 1;
    }
    for(int n = 1; n <= N; n++){
	for(int k = 1; k <= K; k++){
	    for(int x = 1; x <= k; x++){
		dp2[n][k] = (1ll * dp2[n][k] + 1ll * dp[n-1][x-1]) % mod;
	    }
	    for(int x = 1; x <= n; x++){
		dp[n][k] = (1ll * dp[n][k] + 1ll * dp2[x][k] * dp[n-x][k] % mod * C[n-1][x-1]) % mod;
	    }
	}
    }
    return cout << dp[N][K] << endl, 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll n;
    cin >> n;
    set<ll> a;
    rep(i, n){
        ll ai;
        cin >> ai;
        a.insert(ai);
    }
    if (a.size() == n){
        cout << "YES" << endl;
    } else{
        cout << "NO" << endl;
    }

    return 0;   
}

Measured memory_bytes: 9600
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,maxn=3e5+5;

int n,m,q,a[maxn],b[maxn],ta[maxn];

int work(int x){
	int r=inf,st=0,pos=0;
	for(int i=1;i<=n+1;i++){
		if(a[i] >= a[x]){
			if(st == 0)st = i;
		}else{
			if(st && i-st>=m){
				int bc = 0;
				for(int j=st;j<=i-1;j++){
					b[++ bc]=a[j];
				}
				sort(b+1,b+bc+1);
				for(int j=1;j+m-1<=bc;j++)
					ta[++pos]=b[j];
			}
			st = 0;
		}
	}
	if(pos < q)return inf;
	sort(ta+1,ta+pos+1);
	return ta[q]-a[x];
}

int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int ans = inf;
	for(int i=n;i>=1;i--){
		ans = min(ans,work(i));
	}
	printf("%d\n",ans);

	return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll X, T;
  cin >> T >> X;
  cout << (double)T/X;
  return 0;
}


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

int main() {
  string s;
  int q;
  cin >> s >> q;
  vector<int> t(q);
  vector<int> f(q);
  vector<char> c(q);
  for(int i = 0; i < q; i++){
    int a, b;
    cin >> a;
    t.at(i) = a;
    if(a == 2){
      cin >> b;
      f.at(i) = b;
      char k;
      cin >> k;
      c.at(i) = k;
    }
  }
  
  int k = 0;
  string fr, ba;
  for(int i = 0; i < q; i++){
    if(t.at(i) == 1) k++;
    else{
      if(f.at(i) == 1){
        if(k % 2) ba.push_back(c.at(i));
        else fr.push_back(c.at(i));
      }
      else{
        if(k % 2) fr.push_back(c.at(i));
        else ba.push_back(c.at(i));
      }
    }
  }
  
  if(k % 2){
    reverse(s.begin(), s.end());
    reverse(ba.begin(), ba.end());
    cout << ba << s << fr << endl;
  }
  else{
    reverse(fr.begin(), fr.end());
    cout << fr << s << ba << endl;
  }
}

Measured memory_bytes: 2880
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  cin>>n;
  vector<ll>v(n,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  ll f=1;
  for(ll i=0;i<n;i++){
    if(v[i]%2==0){
      if((v[i]%3!=0)&&(v[i]%5!=0))f=0;
    }
  }
  if(f)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lint, lint>
#define ld long double
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define vi vector<int>
#define sz(x) (int)x.size()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N=2e5+5, MOD=1e9+7;
const lint INF=1e18;

lint _add(lint x, lint y) {
    lint ret=x+y;
    while(ret<0LL) ret+=MOD;
    return ret;
}
lint _mult(lint x, lint y) {
    x%=MOD; y%=MOD;
    lint ret=x*y;
    ret%=MOD;
    while(ret<0LL) ret+=MOD;
    return ret;
}
inline int modpow(lint base, int exp, int modulo) {
  base %= modulo;  lint result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulo;
    base = (base * base) % modulo; exp >>= 1;
  }
  return result;
}
using namespace std;
using namespace __gnu_pbds;
template <typename T> 
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<string> v;
string s[N];
map<string, int> M;
int n;
signed main()
{
    int mx = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> s[i];
        M[s[i]]++;
        mx = max(mx, M[s[i]]);
    }
    for(auto it: M)
    {
        if(it.second == mx)
        {
            v.pb(it.first);
        }
    } 
    sort(v.begin(), v.end());
    for(auto it: v)
    {
        cout << it << endl;
    }
}

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


int main() {
  int a, b, k;
  cin >> a >> b >> k;

  int i = 1;
  int counter = 0;
  vector<int> numbers(110);
  while(i <= 110) {
    if (a % i == 0 && b % i == 0) {
      numbers.push_back(i);
    }
    i++;
  }
  sort(numbers.begin(), numbers.end(), greater<int>());

  cout << numbers[k-1] << endl;

  return 0;
}

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

string S;
cin >> S;
int ans = 0;

for (int i = 1; i < 3; i++){
    if(S.at(i) == 'R' && S.at(i - 1) == 'R'){
        ans ++;
    }
}

if(S.at(0) == 'R' || S.at(1) == 'R' || S.at(2) == 'R'){
    ans ++;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,Q,M=0;
  cin>>N;
  map<int,int> A;
  for(int i=0;i<N;i++){
    int j;
    cin>>j;
    A[j]++;
    M+=j;
  }
  cin>>Q;
  for(int i=0;i<Q;i++){
    int B,C;
    cin>>B>>C;
    M=M-A[B]*(B-C);
    A[C]+=A[B];
    A.erase(B);
    cout<<M<<endl;
  }
}

Measured memory_bytes: 7488
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
lis = [0] * (n + 1)
for i in range(m):
    l, r = nm()
    lis[l - 1] += 1
    lis[r] -= 1
for i in range(1, n + 1):
    lis[i] += lis[i - 1]
cnt = 0
for i in lis:
    if i == m:
        cnt += 1
print(cnt)

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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define Exist(a, b)     (find(All(a), (b)) != (a).end())
#define Sort(x)         sort(All(x))
#define Gsort(x)        sort(All(x), greater<typeof(*((x).begin()))>())
#define Unique(v)       Sort(v); (v).resize(unique(ALL(v)) - (v).begin())

#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(ll x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 3e5 + 5;

ll bit[N];

ll n, m, k, q;

void Solve(){
	cin >> n;
	ll res = 0;
	for(int i = 1; i <= n; i++){
        ll x;
        cin >> x;
        for(int i = 1; i <= 64; i++){
            bit[i] += Get_bit(x, i);
        }
	}
	for(ll i = 1; i <= 64; i++){
        res = (res + bit[i] * (((n - bit[i]) * Pow(2, i - 1)) % MOD)) % MOD;
	}
	cout << res;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
}


Measured memory_bytes: 256
from collections import deque


def main():
    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    base = ["#" *(w+4)]
    base.append("#" * (w+4))
    for n in range(h):
        base.append("##" + input() + "##")
    base.append("#" * (w+4))
    base.append("#" * (w+4))
    ans = [[-1] * (w+4) for _ in range(h+4)]
    for j in range(w+4):
        for i in range(h+4):
            if base[i][j] == "#":
                ans[i][j] = -2
    ch+=1; cw+=1
    dh+=1; dw+=1
    ans[ch][cw] = 0
    move = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    move2 = [
        [-2, -2], [-2, -1], [-2, 0], [-2, 1], [-2, 2], \
        [-1, -2], [-1, -1], [-1, 0], [-1, 1], [-1, 2], \
        [0, -2], [0, -1], [0, 0], [0, 1], [0, 2], \
        [1, -2], [1, -1], [1, 0], [1, 1], [1, 2], \
        [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]
        ]
    q = deque([[ch, cw]])
    one_time = deque([])
    while len(q) > 0:
        x, y = q.popleft()
        one_time.append([x, y])
        for i, j in move:
            v1, v2 = x+i, y+j
            if ans[v1][v2] == -1:
                ans[v1][v2] = ans[x][y]
                q.append([v1, v2])
        if len(q) == 0:
            while len(one_time) > 0:
                x2, y2 = one_time.popleft()
                for i, j in move2:
                    v1, v2 = x2+i, y2+j
                    if ans[v1][v2] == -1:
                        ans[v1][v2] = ans[x2][y2] + 1
                        q.append([v1, v2])
    print(ans[dh][dw])

if __name__ == "__main__":
    main()

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

namespace ITP1_9_D
{
    public static class StringExtensions
    {
        public static void Print(this string s, int n, int m)
        {
            int len = m - n + 1;
            Console.WriteLine(new string(s.Skip(n).Take(len).ToArray()));
        }

        public static string Replace(this string s, int n, int m, string t)
        {
            char[] ch = s.ToCharArray();
            for (int i = n, j = 0; i <= m; i++, j++)
            {
                ch[i] = t[j];
            }
            return new string(ch);
        }

        public static string Reverse(this string s, int n, int m)
        {
            int len = m - n + 1;
            var rev = s.Skip(n).Take(len).Reverse();
            return s.Replace(n, m, new string(rev.ToArray()));
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string txt = Console.ReadLine();
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                string order = input[0];
                int from = int.Parse(input[1]);
                int to = int.Parse(input[2]);
                switch (order)
                {
                    case "print":
                        txt.Print(from, to);
                        break;
                    case "reverse":
                        txt = txt.Reverse(from, to);
                        break;
                    case "replace":
                        txt = txt.Replace(from, to, input[3]);
                        break;
                }
            }
        }
    }
}

Measured memory_bytes: 9528