akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    if(N == 1 and M == 1):
        print(1)
    elif(N == 1):
        print(M-2)
    elif(M == 1):
        print(N-2)
    else:
        print((N-2)*(M-2))
        
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N;
	double A,B,C;
	double D[100];
	cin >> N >> A >> B >> C;
	for(int i=0;i<N;i++){
		cin >> D[i];
	}
	sort(D,D+N,greater<int>());
	double ret=C/A;
	double sum=C;
	for(int i=0;i<N;i++){
		sum+=D[i];
		ret=max(ret, sum/(A+(i+1)*B));
	}
	cout << (int)ret << endl;
}

Measured memory_bytes: 1244
#pragma warning (disable :4996)
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e7 + 10;

int n, q;
int S[20];
int flag[2020];
void Connection(int pos,int ans) {
	if (pos == n){
		flag[ans] = 1;
		return;
	}
	Connection(pos + 1, ans + S[pos]);
	Connection(pos + 1, ans);
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &S[i]);
	Connection(0, 0);
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		int x;
		scanf("%d", &x);
		if (flag[x]) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}


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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

template<class T>
void chmax(T& a,T b){
	a=max(a,b);
}

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

template<class T>
void ResetVector(vector<T>& v,int n,const T& t){
	v.clear();
	v.resize(n,t);
}

int main(){
	int n=read();
	vi like(n);
	REP(i,n)
		like[i]=read()-1;
	int ans=0;
	REP(i,n)
		if(like[like[i]]==i)
			ans++;
	cout<<ans/2<<endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

    for (long long h=1; h<=3500; h++)
    for (long long n=1; n<=3500; n++)
    {
        long long w = (long long)(1. / (4./N - 1./h - 1./n) + .5);
        if (4*h*n*w == N*n*w + N*h*w + N*h*n)
        {
            cout<<h<<" "<<n<<" "<<w<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],c[200010],sum,ss;
int main(){
	int i,j,k;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		sum^=a[i];
	}
	for(i=1;i<=n;i++){
		c[i]=sum^a[i];
		ss^=c[i];
		cout<<c[i]<<' ';
	}
	/*cout<<endl;
	for(i=1;i<=n;i++){
		k=ss^c[i];
		cout<<k<<' ';
	}*/
}

Measured memory_bytes: 5140
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	int m1,m2,d1,d2;
	cin>>m1>>d1;
	cin>>m2>>d2;
	if(m1!=m2)
	cout<<1;
	else
	cout<<0;
	return 0;
}

Measured memory_bytes: 256
a = [False]*4
b = list(input())
for i in range(len(b)):
    if b[i] == "N":
        a[0] = True
    elif b[i] == "W":
        a[1] = True
    elif b[i] == "S":
        a[2] = True
    elif b[i] == "E":
        a[3] = True
print("Yes" if a[0] == a[2] and a[1] == a[3] else "No")


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> cnts(200000, 0);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    cnts[a]++;
  }

  int ans = 0;
  for (int i = 0; i < 150000; ++i) {
    int cnt = cnts[i] + cnts[i + 1];
    if (i != 0) {
      cnt += cnts[i - 1];
    }

    ans = max(ans, cnt);
  }

  cout << ans << '\n';
  return 0;
}

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

int main() {
    int A, B, K, count = 0;
    cin >> A >> B >> K;
    while (count < K) {
        if (A % 2 != 0) A--;
        B += A / 2;
        A /= 2;
        count++;
        if (count >= K) break;
        if (B % 2 != 0) B--;
        A += B / 2;
        B /= 2;
        count++;
    }
    cout << A << ' ' << B << endl;
    return 0;
}

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

int main() {
  int64_t X;
  cin >> X;
  int64_t money = 100;
  double ye = 1.01;
  int ans = 0;
  while(true) {
    ans++;
    money *= ye;
    if(money >= X) {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << "{" << p.first << "," << p.second << "}";
  return out;
}

static const int M = 1046597;
static const int L = 12;
char T[M][L];
char com[6], word[L];
int getChar(char ch) {
  if (ch == 'A') {
    return 1;
  } else if (ch == 'C') {
    return 2;
  } else if (ch == 'G') {
    return 3;
  } else {
    return 4;
  }
}

ll getKey(char str[]) {
  ll key = 0, i = 0, p = 1;
  for (i = 0; i < (ll) strlen(str); ++i) {
    key += p * getChar(str[i]);
    key *= 5; //左シフト(5進数)
  }
  return key;
}

int h1(int key) {
  return key % M;
}

//mとh2は互いに素に
int h2(int key) {
  //素数Mより小さい数はみなMと互いに素
  //h2の周期はM未満であればなんでも可
  //1を加えるのはkey%(M-1) == 0のときにずれなくなるため
  //この関数は1 ~ M-1の間の値をとる
  return 1 + (key % (M - 1));
}

int insert(char str[]) {
  ll key, i, h;
  key = getKey(str);
  for (i = 0;; ++i) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(T[h], str) == 0) {
      return 1; //すでに格納済
    } else if (strlen(T[h]) == 0) {
      strcpy(T[h], str);
      return 0;
    }
  }
  return 0;
}

bool find(char str[]) {
  ll key, i, h;
  key = getKey(str);
  for (i = 0;; ++i) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(T[h], str) == 0) {
      return true;
    } else if (strlen(T[h]) == 0) {
      return false;
    }
  }
  return false;
}

void solve() {
  rep(i,0,M)
  {
    T[i][0] = '\0'; //すべて空文字列で初期化
  }
  int n;
  scanf("%d", &n);
  rep(i,0,n)
  {
    scanf("%s %s", com, word);
    if (com[0] == 'i') {
      insert(word);
    } else {
      if (find(word)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
}
int main() {
  solve();
  return 0;
}



Measured memory_bytes: 15420
#include<iostream>

using namespace std;
  
int main(){
  int N, K;
  char S[100];
  int i;
  cin >> N >> K;
  for (i = 0; i < N; i++){
  	cin >> S[i];
  }
  S[i] = '\0';
  
  for (int i = 0; i < N; i++){
    if (i == K-1){
      S[i] = S[i] + 'a' - 'A'; 
    }
  }

  cout << S << endl;
  
  return 0;
}

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



int m=1e9+7;



void add_self(long long &a, long long b){
    a=a+b;
    if(a>m) a = a-m;
}


int main() {

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

int a[n];
for(int i=0;i<n;i++)    cin>>a[i];
    
int b[n];
    for(int i=0;i<n;i++){
        int count =0;
        for(int j=i+1;j<n;j++){
        if(a[j]<a[i]) count++;
        }
        b[i]=count;
    }
    int sum=0;
    for(int i=0;i<n;i++) sum+=b[i];
        
    int t=0,pp=0;
    sort(a,a+n);
    for(int i=1;i<n;i++){
      if(a[i]!=a[i-1]) pp=i;
      t+=pp;
    }
    
    //cout<<t<<" "<<k<<" "<<sum<<endl;
    long long ans=0;
    
    for(int i=0;i<sum;i++){
        add_self(ans,k);
    }
    
    long long temp = (long long)(k*(long long)(k-1)/2)%m;
    for(int i=0;i<t;i++){
        add_self(ans, temp);
    }
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
    	Scanner s = new Scanner(System.in);
    	long a = s.nextLong(), b = s.nextLong(), c = s.nextLong();
    	long z = c - a - b;
    	long y = 4 * a * b;
    	if (z > 0 && z * z > y) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
    	}
    }


Measured memory_bytes: 23764
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    
     ll t; t = 1;
     while(t--){
     	string s; cin >> s;
     	if(s[1] == 'B')
     		s[1] = 'R';
     	else s[1] = 'B';
     	cout << s;
     }
    	return 0;
}

Measured memory_bytes: 3596
n,Y = map(int,input().split())
for x in range(n + 1):
    for y in range(n - x + 1):
        z = n - x - y
        if 0 <= z <= 2000 and 10000*x + 5000*y + 1000*z == Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
N,X,Y = map(int,input().split())
X,Y = X-1,Y-1
for k in range(1,N):
    res = 0
    for n in range(N):
        r = k-abs(Y-n)-1
        for x in {n-k, X-r, X+r}:
            if 0 <= x < n and min(n-x, abs(Y-n)+1+abs(X-x)) == k:
                res += 1
    print(res)


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

int main(){
	bool cards[4][14];
	int n, rank, z;
	char suit;

	for(int s=0; s<4; s++)
		for (int r=1; r<=13; r++)
			cards[s][r] = 0;

	cin >> n;
	for(int i=0; i<n; i++){
		cin >> suit >> rank;
		if(suit == 'S') cards[0][rank] = 1;
		if(suit == 'H') cards[1][rank] = 1;
		if(suit == 'C') cards[2][rank] = 1;
		if(suit == 'D') cards[3][rank] = 1;
	}

	for(int s=0; s<4; s++){
		for(int r=1; r<=13; r++){
			if(cards[s][r]) continue;
			if(s==0) suit = 'S';
			if(s==1) suit = 'H';
			if(s==2) suit = 'C';
			if(s==3) suit = 'D';
			cout << suit << " " << r << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#define llong long long

int main() {
  llong a,b;
  while(scanf("%lld %lld", &a, &b) != EOF) {
    llong lcm = a*b;
    while(a != 0 && b != 0) {
      if(a >= b) a = a%b;
      else b = b%a;
    }
    llong gcd = a+b;
    lcm /= gcd;
    printf("%lld %lld\n", gcd, lcm);
  }
  return 0;
}

Measured memory_bytes: 2696
# -*- coding: utf-8 -*-
import sys
import math
import collections
#sys.setrecursionlimit(100000)

n=int(input())

if(n%2==1):
	print(0)
else:
	ans=0
	tmp=n//2
	while tmp>=5:
		ans+=tmp//5
		tmp=tmp//5
	print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define ll long long
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 5;
ll ans[maxn];

ll qpow(ll a, ll b){
    ll res = 1;
    while(b ){
        if(b & 1) res = (res% MOD * a % MOD) %MOD;
        a = (a % MOD * a % MOD)%MOD;
        b >>= 1;
    }
    return res;
}

int main()
{
    long long  n,k;
    scanf("%lld%lld",&n,&k);
    for(long long  i = k; i >=1; i--){
        ans[i] = qpow(k/i,n);
        for(long long j = 2 *i; j <= k; j = j + i){
            ans[i] = (ans[i] - ans[j] + MOD)%MOD;
        }

    }
    ll res = 0;
    for(long long  i = 1; i <= k; i++){
            res = (res + i *ans[i])%MOD;
    }
    printf("%lld",res);
    return 0;




    return 0;
}


Measured memory_bytes: 2500
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false); cin.tie(0);
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const int nmax = 5010;
int main() {
    IO;
    
    int k;
    string s;
    cin >> s;
    cin >> k;
    int n = s.length();
    set <string> sub;
    for (int i = 0; i < n; i++) 
    for (int len = 1; len <= k; len++) 
    if (i + len - 1 < n) {
        string tmp = s.substr(i, len);
        sub.insert(tmp);
    }
    int cnt = 0;
    set <string> :: iterator it;
    for (it = sub.begin(); it != sub.end(); it++) {
        cnt++;
        if (cnt == k) {
            cout << *it;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
//==========================================
// ABC138b
//
// 2019/08/18
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<double> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  double ans=0;
  double sum=0;

  for(int i=0;i<n;i++)
  {
    sum += 1 / a[i];
  }
  ans = 1/ sum;
  cout << ans <<endl;


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e3+17;

int main(int argc ,char const *argv[])
{
   	 #ifdef GoodbyeMonkeyKing
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif	
    LL x,y;
    cin>>x>>y;
    int ans = 0;
    while(x<=y)
    {
    	ans++;
    	x*=2;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include<chrono>
 
using namespace std;
//using namespace std::chrono;
 
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vl int64_t

int main()
{
     int a,b;
     cin>>a>>b;
     cout<<6-a-b;
     return 0;
}

Measured memory_bytes: 256
N=int(input())
B= [int(s) for s in input().split()]

#print(N,B)

A=[0]*N

#print(A[0])
A[0]=B[0]
A[N-1]=B[N-2]

for i in range(1,N-1):
  if B[i]<B[i-1]:
    A[i]=B[i]
  else:
    A[i]=B[i-1]

#print(A)
print(sum(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  ll sum = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a==0 || i==n-1) {
      sum += a;
      ans += sum/2;
      sum = 0;
    } else {
      sum += a;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;

signed main(){
    int n;
    cin >> n;
    cout << n/500*1000+(n-(n/500)*500)/5*5 << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
lis = list(map(int,input().split()))
li = list(map(int,input().split()))
l = list(map(int,input().split()))
ans = sum(li)
for i in range(n-1):
    if lis[i] +1 == lis[i+1]:
        ans += l[lis[i]-1]
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
typedef long long ll;
int main(){
	ll S;
	int y3;
	scanf("%lld",&S);
	y3=(S+999999999)/1000000000;
	printf("0 0 1000000000 1 %d %d\n",y3*1000000000ll-S,y3);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,m;
	cin>>h>>m;
	ll ch[30000];
	ll a[1010];
	ll b[1010];
	for(ll i=0;i<m;i++){
		cin>>a[i]>>b[i];
	}
	for(ll i=0;i<30000;i++){
		ch[i]=inf;
	}
	ch[0]=0;
	ll ans=inf;
	for(ll i=0;i<20000;i++){
		for(ll j=0;j<m;j++){
			ch[i+a[j]]=min(ch[i+a[j]],ch[i]+b[j]);
			if(i+a[j]>=h){
			ans=min(ans,ch[i+a[j]]);
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3876
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
int n,k,t;
int main(){
	//freopen("xxx.in","r",stdin);
	splay(n),splay(k);
	int g;
	for(int i=1;i<=n;i++){
		int x;splay(x);
		if(i==1)g=x;
		else g=__gcd(g,x);
		t=max(t,x);
	}
	if(t<k)puts("IMPOSSIBLE");
	else puts(k%g?"IMPOSSIBLE":"POSSIBLE");
}

Measured memory_bytes: 256
from collections import deque
# import math


def bfs(maze, mazeColor, h, w, sy, sx, gy, gx):
    for y in range(h):
        for x in range(w):
            maze[y][x] = float("inf")

    if mazeColor[sy][sx] == '.':
        maze[sy][sx] = 0
    else:
        maze[sy][sx] = 1
    que = deque([[sy, sx]])
    while que:
        y, x = que.popleft()
        for i, j in [(1, 0), (0, 1)]:
            nexty, nextx = y + i, x + j
            distColor = mazeColor[nexty][nextx]
            beforeColor = mazeColor[y][x]
            dist = maze[nexty][nextx]
            if distColor != '#':
                if dist > maze[y][x]:
                    maze[nexty][nextx] = maze[y][x] + 0
                    que.append([nexty, nextx])
            else:
                if dist > maze[y][x]:
                    if beforeColor == '.':
                        maze[nexty][nextx] = maze[y][x] + 1
                    else:
                        maze[nexty][nextx] = maze[y][x] + 0
                    que.append([nexty, nextx])

    # for i in range(len(maze[0])):
    #    print(maze[i])
    print(maze[gy][gx])


h, w = map(int, input().split())
mazeColor = ['#'+'#'*w+'#']
for i in range(h):
    mazeColor.append('#'+input()+'#')
mazeColor.append('#'+'#'*w+'#')

maze = [[0 for j in range(w+2)] for i in range(h+2)]

bfs(maze, mazeColor, h+1, w+1, 1, 1, h, w)


Measured memory_bytes: 42588
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(long long i=0;i<n;i++)
#define FROM(a,i,n) for(long long i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
/*Main function*/
int main()
{
    long long a,b,x;
    cin>>a>>b>>x;
    long long n=min(b-1,x);
    cout<<((a*n)/b)-a*(n/b);
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const double inf = 1e12;

const long double eps = 1e-8;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 n;
    cin >> n;

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

    i64 m = a[0];
    i64 R = 0;
    for (i64 i = 1; i < n; i++) {
        R += max(0ll, m - a[i]);
        m = max(m, a[i]);
    }

    cout << R << endl;


    return 0;
}

Measured memory_bytes: 4748
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <random>
using namespace std;

#define rep(i, N) for (int i=0; i<N; ++i)
#define irep(i, N) for (int i=N-1; i>=0; --i)
#define llong long long

template <typename T, int size0>
void fill(T (&a)[size0], T value)
{
	fill_n(a, size0, value);
}
template <typename T, int size0, int size1>
void fill(T (&a)[size0][size1], T value)
{
	fill_n(a[0], size0 * size1, value);
}
template <typename T, int size0, int size1, int size2>
void fill(T (&a)[size0][size1][size2], T value)
{
	fill_n(a[0][0], size0 * size1 * size2, value);
}

const int MAX_S = 3000;
const int MAX_T = 3000;
string s;
string t;

int dp[MAX_S][MAX_T];
int di[MAX_S][MAX_T];
int dj[MAX_S][MAX_T];
 
int solve(int i, int j)
{
	if (i == s.size() || j == t.size()) return 0;
	if (dp[i][j] != -1) return dp[i][j];

	int a = solve(i+1, j);
	dp[i][j] = a;
	di[i][j] = 1;
	dj[i][j] = 0;

	int b = solve(i, j+1);
	if (dp[i][j] < b)
	{
		dp[i][j] = b;
		di[i][j] = 0;
		dj[i][j] = 1;
	}
	if (s[i] == t[j])
	{
		int c = 1 + solve(i+1, j+1);
		if (dp[i][j] < c)
		{
			dp[i][j] = c;
			di[i][j] = 1;
			dj[i][j] = 1;
		}
	}
 
	return dp[i][j];
}

int main ()
{
	cin >> s;
	cin >> t;
	fill(dp, -1);

	solve(0, 0);

	int i = 0, j = 0;
	while (i < s.size() && j < t.size())
	{
		if (di[i][j] == dj[i][j])
		{
			cout << s[i];
		}
		int d_i = di[i][j];
		int d_j = dj[i][j];
		i += d_i;
		j += d_j;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 106112
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N;
  cin>>N;
  int ans = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin>>a[i];
  }
  for (int i = 1; i < N-1; i++) {
    if (a[i-1] < a[i] && a[i] < a[i+1]) {
      ans++;
    } else if (a[i+1] < a[i] && a[i] < a[i-1]) {
      ans++;
    }
  }
  cout << ans << endl;
}



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

using namespace std;

class DSU {
private:
  std::vector<int> rank, p, size;
public:
  DSU(int n): rank(n, 0), p(n), size(n, 1) {
    std::iota(p.begin(), p.end(), 0);
  }

  int findRep(int x) {
    if (p[x] != x) {
      p[x] = findRep(p[x]);
    }
    return p[x];
  }

  void unite(int x, int y) {
    int p1 = findRep(x), p2 = findRep(y);
    if (p1 == p2) return;
    if (rank[p1] < rank[p2]) std::swap(p1, p2);
    
    if (rank[p1] == rank[p2]) rank[p1]++;
    p[p2] = p1;
    size[p1] += size[p2];
  }

  int getSize(int x) {
    int xRep = findRep(x);
    return size[xRep];
  }

  bool isSame(int x, int y) {
    return findRep(x) == findRep(y);
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  
  DSU fri = DSU(n);

  vector< vector<int> > G1(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    fri.unite(a, b);
    G1[a].push_back(b);
    G1[b].push_back(a);
  }
  vector<int> cnts(n, 0);
  for (int i = 0; i < k; ++i) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    if (fri.isSame(c, d)) {
      cnts[c]++;
      cnts[d]++;
    }
  }



  for (int i = 0; i < n; ++i) {
    int base = fri.getSize(i);
    int sub = G1[i].size() + 1;
    base -= sub;
    base -= cnts[i];
    cout << base;
    if (i == n - 1) puts("");
    else cout << " ";
  }
  return 0;
}



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

int n,m,x,y,dp[5][10010],cnt[200],h;
string a;

int main()
{
	int i;
	for(i=1;i<=3;i++)
	{
		cin>>x;
		cnt[x]++;
		if(cnt[x]==1) h++;
	}
	cout<<h;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

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

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    vector<int> a(n);
    REP(i,n)cin>>a[i];
    int s = accumulate(a.begin(),a.end(),0)- *min_element(a.begin(),a.end())
      - *max_element(a.begin(),a.end());
    cout<<s/(n-2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define pb push_back
#define INF INT_MAX
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);

int main () {
       int a,b;
       cin>>a>>b;
       double ar[a];
       double total=0;
       f(i,0,a)cin>>ar[i],total+=ar[i];
       double x=total/(4*b);
       int y=0;
       f(i,0,a){
         if(ar[i]>=x)y++;
       }
       if(y>=b)cout<<"Yes";
       else cout<<"No";
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int n;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		if ((n - i) % 4 == 0 && i % 7 == 0) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
		
	return 0;
}

Measured memory_bytes: 256
as=Array.new(3){Array.new}
as[0]=gets.chomp.codepoints.map{|e|e-"a".ord}
as[1]=gets.chomp.codepoints.map{|e|e-"a".ord}
as[2]=gets.chomp.codepoints.map{|e|e-"a".ord}
turn=0
while true
  num=as[turn].shift
  turn=num
  break if as[turn].empty?
end
puts (turn+"a".ord).chr.upcase
  

Measured memory_bytes: 1788
a,b=map(int, input().split())

c = b + a - 1
d = b - a + 1

n_list = []

if c == d:
    print(c)
elif c != d:
    max_n = max(c,d)
    min_n = min(c,d)
    for i in range(min_n, max_n+1):
        n_list.append(i)
    
# for i in n_list:
#     print(i, end ="")
print( " ".join( repr(e) for e in n_list ) )

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
  ll n,k,s;
  cin>>n>>k>>s;
  for(int i=1;i<=k;i++)
  {
    cout<<s<<" ";
  } 
  n-=k;
  if(s!=1)
  {
  for(int i=1;i<=n;i++)
  {
    cout<<s-1<<" ";
  } 
}
else
{
  for(int i=1;i<=n;i++)
  {
    cout<<2<<" ";
  } 
}
  cout<<endl;

}
return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
//75 divide

int sizeP;

int dfs(vector<int> &lis, vector<int> &x)
{
    if (x.size() == 0)
        return 1;
    else
    {
        int ans = 0;
        int last = x.back();
        x.pop_back();
        REP(i, sizeP)
        {
            if (lis[i] >= last - 1)
            {
                vector<int> newlis(lis);
                vector<int> newx(x);
                newlis[i] = 0;
                ans += dfs(newlis, newx);
            }
        }
        return ans;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;

    vector<bool> isPrime(101, false);
    vector<int> PrimeList;
    isPrime[2] = true;
    PrimeList.push_back(2);
    FORS(i, 3, N)
    {
        bool flg = true;
        REP(j, (int)PrimeList.size())
        {
            if (i % PrimeList[j] == 0)
            {
                flg = false;
                break;
            }
        }
        if (flg)
        {
            isPrime[i] = true;
            PrimeList.push_back(i);
        }
    }
    REP(i, sizeP)
    {
        //   cout << PrimeList[i] << "\n";
    }
    sizeP = (int)PrimeList.size();
    vector<int> amountList(sizeP, 0);
    // cout << "\n";
    REP(i, sizeP)
    {
        int tmpN = N;
        while (tmpN > 0)
        {
            tmpN /= PrimeList[i];
            amountList[i] += tmpN;
        }
    }
    // 75 1,75,
    REP(i, sizeP)
    {
        //cout << amountList[i] << "\n";
    }
    //    cout << "\n";
    int ans = 0;
    vector<vector<int>> p = {{75}, {3, 25}, {5, 15}, {3, 5, 5}};

    REP(i, (int)p.size())
    {
        ans += (i == 3) ? dfs(amountList, p[i]) / 2 : dfs(amountList, p[i]);
        //cout << ans << "\n";
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll K;
ll ans=0;
//ユークリッドの互除法, 再帰
ll gcd(ll p,ll r){
    ll tmp;
    if(p<r){tmp=p;p=r;r=tmp;}
    if(p%r==0){
        return r;
    }
    return gcd(r,p%r);
}

int main(){
    cin>>K;
    rep(i,1,K+1){
        rep(j,1,K+1){
            rep(k,1,K+1){
                ans+=gcd(gcd(i,j),k);    
            }
        }
    }
    cout<<ans;
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; cin >> n;
	set<int> s;
	rep(i, 0, n) {
		int t; cin >> t;
		auto it = s.find(t);
		if (it == s.end())
			s.insert(t);
		else
			s.erase(it);
	}
	cout << s.size() << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	ll N, W;
	cin >> N >> W;
	ll w[N], v[N];
	rep(i, 0, N) cin >> w[i] >> v[i];

	int f1 = w[0];
	int f2 = -1, f3 = -1, f4 = -1;
	vector<pair<ll, ll> > w1, w2, w3, w4;
	w1.push_back(make_pair(v[0], w[0]));

	rep(i, 1, N) {
		if(f1 == w[i]) {
			w1.push_back(make_pair(v[i], w[i]));
			continue;
		}
		if(f2 == -1) f2 = w[i];
		if(f2 == w[i]) {
			f2 = w[i];
			w2.push_back(make_pair(v[i], w[i]));
			continue;
		}
		if(f3 == -1) f3 = w[i];
		if(f3 == w[i]) {
			f3 = w[i];
			w3.push_back(make_pair(v[i], w[i]));
			continue;
		}
		if(f4 == -1) f4 = w[i];
		if(f4 == w[i]) {
			f4 = w[i];
			w4.push_back(make_pair(v[i], w[i]));
			continue;
		}
	}
	vsort(w1);
	reverse(w1.begin(), w1.end());
	vsort(w2);
	reverse(w2.begin(), w2.end());
	vsort(w3);
	reverse(w3.begin(), w3.end());
	vsort(w4);
	reverse(w4.begin(), w4.end());

	ll res = 0;
	rep(i, 0, w1.size() + 1) {
		rep(j, 0, w2.size() + 1) {
			rep(k, 0, w3.size() + 1) {
				rep(l, 0, w4.size() + 1) {
					ll tmp_w = 0;
					if(w1.size() != 0) tmp_w += i * w1[0].second;
					if(w2.size() != 0) tmp_w += j * w2[0].second;
					if(w3.size() != 0) tmp_w += k * w3[0].second;
					if(w4.size() != 0) tmp_w += l * w4[0].second;
					if(tmp_w > W) continue;
					ll tmp_v = 0;
					if(w1.size() != 0) rep(a, 0, i) tmp_v += w1[a].first;
					if(w2.size() != 0) rep(a, 0, j) tmp_v += w2[a].first;
					if(w3.size() != 0) rep(a, 0, k) tmp_v += w3[a].first;
					if(w4.size() != 0) rep(a, 0, l) tmp_v += w4[a].first;
					res = max(res, tmp_v);
				}
			}
		}
	}

	cout << res << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int dp[50];

int fib(int n) {
  if( n == 0 || n == 1 ) return dp[n] = 1;
  if( dp[n] != -1 ) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main() {
  int n, i;
  for(i = 0; i < 50; i++ ) dp[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fib(n));

  return 0;
}

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

typedef long long ll;
typedef pair<int,int> pri;
const int INF = 1e9 + 7;
const ll LINF = 1LL<<61;

int n,k;
vector<int> h;
long long ans;

int main(){
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(),h.end());
  if( k >= n){
    ans = 0;
  }else{
    for(int i = 0; i < n-k; i++){
      ans += h[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 2; i++) {
		for (int j = i + 1; j < 3; j++) {
			if ((a[i] + a[j]) == a[3 - i - j]) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    ll N;
    cin >> N;
    if  (N % 2 == 0) {
        cout << N << endl;
    } else {
        cout << N*2 << endl;
    }  
    return 0;
}

Measured memory_bytes: 256
cooktimes = [int(input()) for i in range(5)]
intervals = [0 if x % 10 == 0 else 10 - (x % 10) for x in cooktimes]
alist = []
for i in range(5):
    alist.append(tuple([cooktimes[i], intervals[i]]))
alist.sort(key=lambda x: x[1])
ans = 0
for i in range(4):
    ans += alist[i][0] + alist[i][1]
ans += alist[4][0]
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a;
  while(cin>>n>>m>>a,n){
    int d[1001][101]={};
    for(int i=0;i<m;++i){
      int h,p,q; cin>>h>>p>>q;
      d[h][p]=q,d[h][q]=p;
    }
    int x=a;
    for(int i=1000;i>=0;--i)
      if(d[i][x]) x=d[i][x];
    cout<<x<<endl;
  }
  return 0;
}

Measured memory_bytes: 3360
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  ll x;
  cin>>x;
  ll tmp1,tmp2;
  ll ans1,ans2;

  rep(i,-200,200)
  rep(j,-200,200){
    tmp1=i,tmp2=j;
    ll tmp=pow(tmp1,5)-pow(tmp2,5);
    if(tmp==x){
      ans1=tmp1,ans2=tmp2;
    }
  }

  cout<<ans1<<' '<<ans2<<endl;
}

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

#define fi first
#define se second

const int N = 300300;
const int MAGIC = 1000;
const long long mod = 998244353;

using namespace std;

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        string s;
        cin >> s;
        long long res = 0, f = 0;
        for(int i = 0; i < s.size(); i++){
                if(s[i] == 'A'){
                        f += 1;
                } else{
                        if(i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C'){
                                res += f;
                                i += 1;
                        } else{
                                f = 0;
                        }
                }
        }
        cout << res << "\n";
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, a, b;
	cin >> x >> a >> b;
	int c = b - a;
	if (c <= 0)cout << "delicious" << endl;
	else if (c <= x)cout << "safe" << endl;
	else cout << "dangerous" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ');
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

int main () {
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  cout << (s < t ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
 
using namespace std;
 
#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define mp make_pair
#define pb push_back
 
/////////////////////////
 
int const N = 5e5 + 41;
int const K = 27;
int const M = 20; 

int n, m, dp[N][K], ans[N], par[N];
string s;
vector<pair<int, int> > q[N];

int len[N], spt[N][M];

void buildSpt(){

	fi(0, N) fj(0, M) spt[i][j] = n;

	fi(0, n){
		spt[i][0] = dp[i][26];
	}
	for(int i=1;i<M;++i){
		for(int j=0;j<n;++j){
			int nxt = spt[j][i-1] + 1;
			spt[j][i] = spt[nxt][i-1];
		}
	}
}

void solve(){
	cin >> s;
	n = sz(s);
	fi(0, n) s[i] -= ('a');
	cin >> m;
	fi(0, m){
		int l, r;
		cin >> l >> r;
		--l;--r;
		q[l].pb(mp(r, i));
	}
 
	for(int i=n-1;i>=0;--i){
		fj(0, K) dp[i][j] = n;
 
		dp[i][s[i]] = i;
		fj(s[i]+1, K){
			int nxt = dp[i][j-1] + 1;
			if(nxt == n || dp[nxt][j-1] == n) break;
			dp[i][j] = dp[nxt][j-1];
		}
 
		int nxt = dp[i][26] + 1;
		if(nxt < n){
			fj(0, s[i]){
				dp[i][j] = dp[nxt][j];
			}
		}
	}

	buildSpt();
	fi(0, n){
		fj(0, sz(q[i])){
			int r = q[i][j].first;
			int id = q[i][j].second;
			int p = i;
			for(int k=M-1;k>=0;--k){
				if(spt[p][k] <= r) p = spt[p][k] + 1;
			}
			if(p == r + 1) ans[id] = 1;
		}
	}
 
	fi(0, m) if(ans[i]) cout << "Yes" << endl; else cout << "No" << endl;
}
 
int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
 
	solve();
 
 
 
	return 0;
}

Measured memory_bytes: 113284
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	int f = 2, s = 1;
	REP(i, 3) {
		int a;
		CIN(a);
		if(a == 5) --f;
		else if(a == 7) --s;
	}
	if(!f && !s) COUT("YES");
	else COUT("NO");
}


Measured memory_bytes: 256
import sys
from functools import reduce
from math import gcd

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def eratosthenes(n):
    prime = [2]
    if n == 2:
        return prime
    limit = int(n ** 0.5)
    data = [i + 1 for i in range(2, n, 2)]
    res = [0] * (n + 1)
    res[1] = 1
    for i in range(2, n + 1, 2):
        res[i] = 2
    while True:
        p = data[0]
        if limit <= p:
            for e in data:
                res[e] = e
            return res
        prime.append(p)
        res[p] = p
        for e in data:
            if e % p == 0:
                res[e] = p
        data = [e for e in data if e % p != 0]


def solve():
    _ = int(rl())
    A = list(map(int, rl().split()))
    
    prime_fact = eratosthenes(10 ** 6)
    p_flg = True
    prime_fact_set = set()
    for ai in A:
        num = ai
        prime_fact_ai = set()
        while num != 1:
            prime_fact_ai.add(prime_fact[num])
            num //= prime_fact[num]
        for p in prime_fact_ai:
            if p in prime_fact_set:
                p_flg = False
                break
            prime_fact_set.add(p)
        if not p_flg:
            break
    
    if p_flg:
        print('pairwise coprime')
        return
    
    gcd_a = reduce(gcd, A)
    if gcd_a == 1:
        print('setwise coprime')
        return
    
    print('not coprime')


if __name__ == '__main__':
    solve()


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

int main()
{
  int a, b, c, ans;
  cin >> a >> b >> c;
  if(a == b && b == c && c == a)
  {
    ans = 1;
  }
  else if(a != b && b != c && c != a)
  {
    ans = 3;
  }
  else
  {
    ans = 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256