akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(int argc, char const *argv[]) {
  int cnt = 0;
  string W, word;

  cin >> W;
  while(cin >> word){
    if(word == "END_OF_TEXT") break;
    for (int i = 0; i < word.size(); i++) {
      word[i] = tolower(word[i]);
    }
    if(word == W) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3216
#include <algorithm>
#include <iostream>
#include <vector>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

//マクロ定義
#define ALL(v) (v).begin(),(v).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define SORT(x) sort(begin(x),end(x))
#define SELECT_SORT(x, n) sort(begin(x),begin(x)+n)
#define SWAP(type, a, b) do {type tmp = a; a = b; b = tmp;} while (0)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))

//定数
#define INF 2000000000000
#define MAX 10

//DEBUG用
#define BAR() cout << "----------------------------" << endl;
#define DUMP(v) (cerr << #v << ": " << v << endl)
#define PRINT(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

int check(int h, int m){
	int time = h*100 + m;
	if(time >= 1100 && time <= 1459){
		return 0;
	}
	else if(time >= 1800 && time <= 2059){
		return 1;
	}
	else if(time >= 2100 || time <= 159){
		return 2;
	}
	else{
		return -1;
	}
}

bool ok(int m, int m2){
	if(m2 >= m){
		return (m2-m) <= 8;
	}
	else{
		return (60-m)+m2 <= 8;
	}
}

int main()
{
	int h, m, m2, n;
	
	while(cin >> n && n){
		double accept[3]={0};
		double total[3]={0};
		rep(i, n){
			scanf("%d%*c%d%d", &h,&m,&m2);
			if(check(h, m) != -1){
				total[check(h,m)]++;
				if(ok(m,m2)){accept[check(h,m)]++;}
			};
		}
		string ans[3];
		rep(i,3)
		{
			if(total[i] == 0){
				ans[i] = "no guest";
			}else{
				ans[i] = to_string((int)((accept[i]/total[i]) * 100));
			}
		}
		cout << "lunch" << " " << ans[0] << endl;
		cout << "dinner" << " " << ans[1] << endl;
		cout << "midnight" << " " << ans[2] << endl;
	}
}

Measured memory_bytes: 1268
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n,k;cin>>n>>k;
  vll c(n+1);
  rep(i,0,n){
    ll a;cin>>a;
    c[a]++;
  }
  ll ans=0;
  sort(c.begin(),c.end());
  rep(i,0,n-k+1){
    ans+=c[i];
  }
  cout<<ans<<endl;
}







Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int n,a,b;

int main(){
	cin >> n >> a >> b;
	
	if(b<a) swap(a,b);
	
	cout << (b-(a+n)<0?0:b-(a+n)) << endl;
	return 0;
}


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

// #define multitest 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

void solve()
{
	int a;
	cin >> a;
	cout << 3 * a * a;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef TIME
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
set<string> a;
int main(){
	int n;
	cin>>n;
	string s[n];
	r(i,n)cin>>s[i];
	r(i,6)r(j,n)r(k,s[j].size())
		if(k+i<=s[j].size())a.insert(s[j].substr(k,i));
	r(i,27)r(j,27)r(k,27)r(l,26){
		string t;
		if(i)t+='a'-1+i;
		if(j)t+='a'-1+j;
		if(k)t+='a'-1+k;
		t+='a'+l;
		if(!a.count(t))
		cout<<t<<endl,exit(0);
	}
}

Measured memory_bytes: 80192
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;

struct Node{
    int key, pri;
    Node *left, *right;
    Node(const int& k, const int& p): key(k), pri(p), left(NULL), right(NULL) {}
};

Node* rightRotate(Node* n){
    Node* t = n->left;
    n->left = t->right;
    t->right = n;
    return t;
}

Node* leftRotate(Node* n){
    Node* t = n->right;
    n->right = t->left;
    t->left = n;
    return t;
}

Node* insert(Node* n, const int& k, const int& p){
    if(!n)
        return new Node(k, p);
    if(k == n->key) return n;
    if(k < n->key){
        n->left = insert(n->left, k, p);
        if(n->left->pri > n->pri)
            n = rightRotate(n);
    }
    if(k > n->key){
        n->right = insert(n->right, k, p);
        if(n->right->pri > n->pri)
            n = leftRotate(n);
    }
    return n;
}

Node* _del(Node* n, const int& k);

Node* del(Node* n, const int& k){
    if(!n) return NULL;
    if(k < n->key)
        n->left = del(n->left, k);
    else if(k > n->key)
        n->right = del(n->right, k);
    else{
        return _del(n, k); 
    }
    return n;
}

Node* _del(Node* n, const int& k){
    if(!(n->left) && !(n->right))
        return NULL;
    else if(!(n->left))
        n = leftRotate(n);
    else if(!(n->right))
        n = rightRotate(n);
    else if(n->left->pri > n->right->pri)
        n = rightRotate(n);
    else n = leftRotate(n);
    return del(n, k);
}

bool find(Node *n, const int& k){
    if(!n) return false;
    if(k == n->key) return true;
    if(k < n->key) return find(n->left, k);
    else return find(n->right, k);
}

void inOrder(Node* n){
    if(!n) return;
    inOrder(n->left);
    printf(" %d", n->key);
    inOrder(n->right);
}

void preOrder(Node* n){
    if(!n) return;
    printf(" %d", n->key);
    preOrder(n->left);
    preOrder(n->right);
}

void print(Node* n){
    inOrder(n);
    printf("\n");
    preOrder(n);
    printf("\n");
}

int main(){
    int n, x, y;
    char cmd[10];
    Node* root = NULL;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%9s", cmd);
        if(strcmp(cmd, "insert") == 0){
            scanf("%d %d", &x, &y);
            root = insert(root, x, y);
        }
        else if(strcmp(cmd, "delete") == 0){
            scanf("%d", &x);
            root = del(root, x);
        }
        else if(strcmp(cmd, "print") == 0){
            print(root);            
        }
        else if(strcmp(cmd, "find") == 0){
            scanf("%d", &x);
            printf(find(root, x)? "yes\n" : "no\n");
        }
        else{
            printf("Invalid cmd\n");
        }
    }
}



Measured memory_bytes: 8948
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
	string S;
	cin >> S;
	int n = S.size();
	bool f[4];
	f[0] = false;
	f[1] = false;
	f[2] = false;
	f[3] = false;
	for (int i = 0; i < n; i++) {
		if (S[i] == 'S') {
			f[0] = true;
		}
		if (S[i] == 'N') {
			f[1] = true;
		}
		if (S[i] == 'W') {
			f[2] = true;
		}
		if (S[i] == 'E') {
			f[3] = true;
		}
	}
	if ((f[0] ^ f[1])||(f[2]^f[3])) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
using namespace std;
const int INF = 2000000005;
int main() {
	string s;
	cin >> s;
	bool chk[26] = { false };
	for (int i = 0; i < s.length(); i++) {
		int a = (int)(s[i]) - 97;
		chk[a]=true;
	}
	if (s.length() < 26) {
		for (int i = 0; i < 26; i++) {
			if (!chk[i]) {
				s += (char)(i + 97);
				break;
			}
		}
		cout << s << endl;
		return 0;
	}
	else {
		for (int i = 25; i >= 0; i--) {
			char min = (char)(123);
			for (int j = i + 1; j < 26; j++) {
				if (s[i] < s[j] && s[j] < min) min = s[j];
			}
			if (min < '{') {
				s[i] = min;
				cout << s.substr(0, i+1)<<endl;
				return 0;
			}
		}
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(void){
	int S, h, m, s;
	
	std::cin >> S;
	h = S / 3600;
	S %= 3600;
	m = S / 60;
	S %= 60;
	s = S;
	std::cout << h << ":" << m << ":" << s <<  std::endl;
	
	return 0;
}

Measured memory_bytes: 1168
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    S=map(int,list(input()))
    c=[0,0]
    for s in S:
        c[s]+=1
    print(min(c)*2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 49392
import java.io.IOException;
import java.util.Scanner;


public class Main {

	static int inputA,inputB;
	
	public static void main(String args[]) throws NumberFormatException, IOException{
		Scanner in = new Scanner(System.in);
		int inputA=in.nextInt();
		int inputB=in.nextInt();
		
		System.out.println(inputA*inputB+" "+(inputA+inputB)*2);
		
		
	}
	
}

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

int main() {
  
  int n;
  int64_t x;
  vector <bool> a(std::pow(10,9)-1);
  cin >> n;
  
  for(int i = 0;i<n;i++){
    cin >> x;
    if(a.at(x-1)==false){
    	a.at(x-1) = true;
      if(i==n-1){
        cout << "YES" << endl;
      }
    }else{
      cout << "NO" << endl;
      break;
    }
  }
    
}


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

int a, b;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> a >> b;
	if ((a <= 0 && 0 <= b) || a == 0 || b == 0)
		cout << "Zero\n";
	else if (a > 0 || (b - a) & 1)
		cout << "Positive";
	else
		cout << "Negative";
}


Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
plc = 0
ctemp = float(10**5)
for i in range(n):
  htemp = abs(t-h[i]*0.006-a)
  if htemp<ctemp:
    plc = i+1
    ctemp = htemp
print(plc)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

int main(void)
{
  int i,j,n,m;
  char s[110][11],t[110][11];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%s",s[i]);
 
  scanf("%d",&m);
  for(i=0;i<m;i++)
    scanf("%s",t[i]);

  int max=0,cnt;
  for(i=0;i<n;i++){
    cnt = 0;
    for(j=i;j<n;j++)
      if(strcmp(s[i],s[j])==0)
        cnt++;
    for(j=0;j<m;j++)
      if(strcmp(s[i],t[j])==0)
        cnt--;
    if(max<cnt)
      max = cnt;
  }
    
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1704
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
map<string,int> mp;
int main()
{	
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		if(mp[s]==0){
			ans++;
		}
		mp[s]=1;
	}
	printf("%d",ans);
}


Measured memory_bytes: 19388
N, M = list(map(int, input().split()))
h = list(map(int, input().split()))
ma = [0] * N

for i in range(M):
    a, b = list(map(int, input().split()))
    ma[a-1] = max(ma[a-1], h[b-1])
    ma[b-1] = max(ma[b-1], h[a-1])

ans = 0
for i in range(N):
    if ma[i] < h[i]:
        ans += 1

print(ans)

Measured memory_bytes: 20112
#include<iostream>
using namespace std;
int main(){
  char str[4];
  cin>>str;
  int a=0,b=0,c=0;
  for(int i=0;i<3;i++){
    if(str[i]=='a'){
      a++;
    }
    if(str[i]=='b'){
      b++;
    }
    if(str[i]=='c'){
      c++;
    }
  }
  if(a*b*c!=1){
    cout<<"No";
  }else cout<<"Yes";
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100
#define W 0
#define G 1
#define B 2

int INFTY = 1<<21;
int n,A[MAX][MAX];

int prim(){
  int i,v,u,min;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=W;
  }

  d[0]=0;
  while(1){
    min = INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(min>d[i]&&color[i]!=B){
	u=i;
	min= d[i];
      }
}
    if(u==-1) break;
    color[u]=B;
    for(v=0;v<n;v++){
      if(color[v]!=B&&A[u][v]!=INFTY){
	if(d[v]>A[u][v]){
	  d[v]=A[u][v];
	  p[v]=u;
	  color[v]=G;
	}
}
    }
  }
  int sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1) sum+=A[i][p[i]];
  }
  return sum;
}
int main(){
  int i,j,e;  
scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e==-1){
A[i][j]=INFTY;
      }else{
	A[i][j]=e;
      }
    }
  }
  printf("%d\n",prim());


  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<ll> a;
    rep(i, n){ ll tmp; cin >> tmp; a.push_back(tmp);}

    bool up = true;
    bool down = true;
    int base = a[0];
    int ans = 1;
    rep1(i, n-1){
        if (a[i] > base) down = false;
        if (a[i] < base) up = false;
        base = a[i];
        if (!down&&!up){
            ans++;
            down=true;up=true;
        }
    }

    cout << ans << endl;


}



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

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define fastIO ios_base::sync_with_stdio(false); cin.tie(false);
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; vector<long long>vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

int main() {
	string s;
	std::cin >> s;
	bool finds = s.find('S')!=s.npos;
	bool findn = s.find('N')!=s.npos;
	bool finde = s.find('E')!=s.npos;
	bool findw = s.find('W')!=s.npos;
	
	if (!(finds^findn) && !(finde^findw))puts("Yes");
	else { puts("No"); }
	
	
}


Measured memory_bytes: 256
// 
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif

    int a, b;
    cin>>a>>b;

    int max=0;

    if(a>b){
    	max=a;
    	a--;
    }
    else{
    	max=b;
    	b--;
    }

    if(a>b){
    	max=max+a;
    }
    else{
    	max=max+b;
    }
    cout<<max<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 1000000007

long fac(int n){
	long ret = 1;
	for(int i = 1; i <= n; i++){
		ret *= i;
		ret %= MAX;
	}
	return ret;
}

int main(void){
	int n, m;
	long ans;
	scanf("%d%d", &n, &m);
	if(n - m > 1 || n - m < -1){
		ans = 0;
	}else{
		ans = 1;
		ans *= fac(n);
		ans %= MAX;
		ans *= fac(m);
		ans %= MAX;
		if(n == m){
			ans *= 2;
			ans %= MAX;
		}
	}
	printf("%ld\n", ans);
}

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

ans = 1
exist = True

while True:
  if int(ans*0.08)==a and int(ans*0.1)==b:
    break
  elif int(ans*0.08)>a or int(ans*0.1)>b:
    exist = False
    break
  
  ans += 1
  
print(ans if exist else -1)

Measured memory_bytes: 3060
#include <iostream>

int main() {
    int K;
    std::cin >> K;
    int odd{0}, even{0};
    
    for (int i=1; i<=K; ++i) {
        if (i % 2 == 0)
            even++;
        else
            odd++;
    }
    std::cout << (odd * even) << std::endl;
}

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

#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi 3.14159265359
#define fo(i, n) for(int i = 0; i < n; ++i)
#define ro(i, n) for(int i = n - 1; i >= 0; --i)
#define fill(x, y) memset(x, y, sizeof(x))


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef double D;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

int k;
const int maxk = (int) 1e5;
int a[maxk];

bool check1 (ll n) {
    fo(i, k) {
        n -= (n % a[i]);
    }
    re n >= 2;
}

bool check2 (ll n) {
    fo(i, k) {
        n -= (n % a[i]);
    }
    re n <= 2;
}

int main() {
    scanf("%d", &k);
    fo(i, k) scanf("%d", a + i);
    ll l = 0, r = (ll) 1e18;
    ll ans1 = r;
    while (l <= r) {
        ll c = (l + r) >> 1;
        if (check1(c)) {
            ans1 = c;
            r = c - 1;
        } else {
            l = c + 1;
        }
    }
    ll ans2 = 0;
    l = 0, r = (ll) 1e18;
    while (l <= r) {
        ll c = (l + r) >> 1;
        if (check2(c)) {
            ans2 = c;
            l = c + 1;
        } else {
            r = c - 1;
        }
    }
    if (ans2 < ans1) cout << -1 << endl;
    else cout << ans1 << ' ' << ans2 << endl;
    re 0;
}


Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
const ll inf = 1000000007;
int main() {
  ll n,m; cin >>n>>m;
  vector<ll> x(m);
  vector<ll> y(m);
  vector<ll> have(n);
  rep(i,m) cin >>x[i]>>y[i];
  map<ll,ll> mp;
  rep(i,n)mp[i]=1;
  have[0]=1;
  rep(i,m){
    if(mp[x[i]-1]==1){
      if(have[x[i]-1]==1){
        have[x[i]-1]=0;
        have[y[i]-1]=1;
      }
    }else if(mp[x[i]-1]>1){
      if(have[x[i]-1]==1){
        have[y[i]-1]=1;
      }
    }
      mp[x[i]-1]--;
      mp[y[i]-1]++;
  }
  ll ans=0;
  rep(i,n)if(have[i]==1)ans++;
  cout <<ans<<endl;
}

Measured memory_bytes: 8832
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll n, m;
  cin >> n >> m;

  map<ll, ll> mp;
  map<ll, ll> mpn;
  ll ac = 0;
  ll pn = 0;
  rep(i, m) {
    ll idx;
    string str;
    cin >> idx >> str;
    if(str == "AC" && mp[idx] != 1) {
      mp[idx] = 1;
      ac++;
    } else if(str == "WA" && mp[idx] != 1){
      mpn[idx]++;
    }
  }

  rep(i, n){
    if (mp[i+1] == 1) pn += mpn[i+1];
  }

  cout << ac << " " << pn << endl;

  return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x,ll y,ll m) {
    ll res = 1; 
    x = x % m;                
    if (x == 0)
        return 0; 
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int f=1;
    while(a>0&&c>0) {
        if(f==1) {
            c-=b;
            f=0;
        }
        else {
            a-=d;
            f=1;
        }
    }
    if(a<=0) {
        cout<<"No";
    }
    else {
        cout<<"Yes";
    }
    
}

int main()
{
    fastio;
    int t=1;
    //cin >> t;
    while (t-- > 0)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
#define Imax 1e9+5
#define LLmax 1e18
#define Imin -1e9-5
#define LLmin -1e18
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector <string> v;
bool sortByFirst(const pair<int,int>&a,const pair<int,int>&b){
    return a.first>b.first;
}
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    double a,b;
    while(cin>>a>>b){
        a>b?cout<<"GREATER"<<endl:cout<<(a<b?"LESS":"EQUAL")<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
//#define double long double

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
    
    long double l;
    cin>>l;

    long double x = l/3;
    x=x*x*x;

    cout<<fixed<<setprecision(30)<<x<<endl  ; 
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;

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

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

	int n;
	cin >> n;
	vi a(n);
	rep(i, n - 1) {
		int t;
		cin >> t;
		a[t - 1]++;
	}

	for (auto &p : a)cout << p << "\n";

	return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    intl max = 1;
    for(intl i = 2; i <= n; i++){
        for(intl j = 2; pow(i,j) <= n; j++){
            max = max(max,pow(i,j));
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
h = map(int, raw_input().split())
INF = 2 ** 32
dp = [INF for i in xrange(n)]
dp[0] = 0
for i in xrange(n):
    if i - 1 >= 0:
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i])
    if i - 2 >= 0:
        dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i])
print dp[n-1]
        


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

ll n,c[100010];
vector<vector<pair <ll,ll> >>a(100010);
void dep(ll now,ll p,ll nowco){
	if(a[now].size()==1&&a[now][0].first==p){
		return;
	}
	for(int i=0;i<a[now].size();i++){
		ll next=a[now][i].first;
		if(next==p){
			continue;
		}
		ll nextcos=nowco+a[now][i].second;
		c[next]=nextcos;
		dep(next,now,nextcos);
	}
}
int main() {
	cin>>n;
	for(int i=0;i<n-1;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		a[x].push_back(make_pair(y,z));
		a[y].push_back(make_pair(x,z));
	}
	ll q,k;
	cin>>q>>k;
	k--;
	dep(k,-1,0);
	for(int i=0;i<q;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		cout << c[x]+c[y]<<endl;
	}
	return 0;
}

Measured memory_bytes: 14336
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		int max = 0;
		int num_i = 0;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			if(max < a[i]) {
				max = a[i];
				num_i = i;
			}
		}
		
		double dist = Double.MAX_VALUE;
		int ans = 0;
		for(int i = 0; i < N; i++) {
			if(i == num_i) continue;
			if(dist > Math.abs((double)(max / 2) - (double)a[i])) {
				dist = Math.abs((double)max / 2 - (double)a[i]);
				ans = a[i];
			}
		}
		System.out.println(max + " " + ans);
	}
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);
//const int INF=(1<<29);

int main(){
  int W,H,N;
  cin >> W >> H >> N;
  vector<vector<int>> m(W, vector<int>(H,1));

  REP(i,N){
    int x, y, a;
    cin >> x >> y >> a;

    if(a==1){
      REP(j,x)REP(k,H)m[j][k]=0;
    }else if(a==2){
      FOR(j,x,W)REP(k,H)m[j][k]=0;
    }else if(a==3){
      REP(j,W)REP(k,y)m[j][k]=0;
    }else{
      REP(j,W)FOR(k,y,H)m[j][k]=0;
    }
  }

  int ans=0;
  REP(i,W)REP(j,H)ans+=m[i][j];

  cout << ans << endl;
}



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

int main(){
  vector<int> a;
  while (true) {
    int tmp;
    cin >> tmp;
    if (tmp == 0) break;
    else a.push_back(tmp);
  }

  for (int i=0; i<a.size(); i++) {
    printf("Case %d: %d\n", i+1, a[i]);
  }
  return 0;
}



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

#ifdef HELTHAZAR
#define dout if (true) cout
#else
#define dout if (false) cout
#endif

const int MAXN = 1e5 + 1;
const long long MOD = 1e9 + 7;
struct edge {
	int next;
	long long d;
};
vector<edge> edges[MAXN];
int used[MAXN];
long long dis1[MAXN], dis2[MAXN];
long long cnt1[MAXN], cnt2[MAXN];

long long summod(long long a, long long b) {
	return (a + b) % MOD;
}

long long mulmod(long long a, long long b) {
	return (a * b) % MOD;
}

long long sqr(long long x) {
	return mulmod(x, x);
}

void dijkstra(int s, long long dis[], long long cnt[]) {
	set<pair<long long, int> > st;
	st.insert({1, s});
	used[s] = 1;
	cnt[s] = 1;
	while (!st.empty()) {
		auto v = st.begin()->second;
		st.erase(st.begin());
		for (auto e: edges[v]) {
			if (!used[e.next] || dis[e.next] > dis[v] + e.d) {
				st.erase({dis[e.next], e.next});
				used[e.next] = 1;
				dis[e.next] = dis[v] + e.d;
				cnt[e.next] = cnt[v];
				st.insert({dis[e.next], e.next});
			}
			else if (dis[e.next] == dis[v] + e.d) {
				cnt[e.next] = summod(cnt[e.next], cnt[v]);
			}
		}
	}
}

void solve() {
	int n, m;
	cin >> n >> m;
	int s, t;
	cin >> s >> t;
	for (int i = 0; i < m; i++) {
		int u, v;
		long long d;
		cin >> u >> v >> d;
		edges[u].push_back({v, d});
		edges[v].push_back({u, d});
	}

	dijkstra(s, dis1, cnt1);
	fill(used + 1, used + n + 1, 0);
	dijkstra(t, dis2, cnt2);
	long long d = dis1[t];
	long long sum = 0, sqrsum = 0;
	for (int v = 1; v <= n; v++) {
		if (dis1[v] + dis2[v] == d && dis1[v] == dis2[v]) {
			long long res = mulmod(cnt1[v], cnt2[v]);
			sum = summod(sum, res);
			sqrsum = summod(sqrsum, sqr(res));
		}
		for (auto e: edges[v])
			if (dis1[v] + e.d + dis2[e.next] == d && dis1[v] * 2 < d && dis2[e.next] * 2 < d) {
				long long res = mulmod(cnt1[v], cnt2[e.next]);
				sum = summod(sum, res);
				sqrsum = summod(sqrsum, sqr(res));
			}
	}
	cout << summod(sqr(sum), MOD - sqrsum) << endl;
}

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

	solve();
}


Measured memory_bytes: 21616
#include<bits/stdc++.h>
#define LL long long
using namespace std;
string str;
LL ans;
int len;
void dfs(LL sum,int now)
{
    if(now==len)
    {
        ans+=sum;
        return;
    }
    for(int i=now; i<len; i++)
    {
        LL tmp=0;
        for(int j=now; j<=i; j++)
            tmp=tmp*10+(str[j]-'0');
        dfs(sum+tmp,i+1);
    }
}
int main()
{
    cin>>str;

        ans=0;
        len=str.size();
        dfs(0,0);
        printf("%lld\n",ans);

}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  str s; cin >> s;
  ll ans_1 = 0, ans_2 = 0;
  REP(i,s.length()){
    if(i%2==0){
      if(s[i]=='0'){
        ans_1++;
      }else{
        ans_2++;
      }
    }else{
      if(s[i]=='0'){
        ans_2++;
      }else{
        ans_1++;
      }
    }
  }
  cout << min(ans_1,ans_2) << endl;
  return 0;
}


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

int main()
{
    string n;
    cin >> n;
    int count = 0;
    for (int i = 0; i < n.size(); i++)
    {
        count += (int)(n.at(i) - '0');
    }
    if (count % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define Divhim() cout<<">>>>>>>>>"<<endl
#define Divher() cout<<"<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!"<<endl

template<typename T> bool Getmax(T &a,T b){return (a<b)?(a=b,true):false;}
template<typename T> bool Getmin(T &a,T b){return (a>b)?(a=b,true):false;}

const int N=2e5+10;

int h,w,n,sr,sc;
char s[N],t[N];
char trans[233];

void GG()
{
	puts("NO");
	exit(0);
}

bool Work()
{
	int L=0,R=w+1;
	for(int i=n;i>=1;--i)
	{
		if(t[i]=='L')++R;
		else if(t[i]=='R')--L;
		Getmax(L,0);
		Getmin(R,w+1);
		if(s[i]=='L')++L;else if(s[i]=='R')--R;
		Getmax(L,0);
		Getmin(R,w+1);
		if(L+1>=R)return true;
	}
	return sc<=L||sc>=R;
}

int main()
{
	scanf("%d%d%d%d%d%s%s",&h,&w,&n,&sr,&sc,s+1,t+1);
	trans['L']='U';
	trans['R']='D';
	trans['U']='L';
	trans['D']='R';
	if(Work())GG();
	swap(h,w);
	swap(sr,sc);
	for(int i=1;i<=n;++i)
	{
		s[i]=trans[s[i]];
		t[i]=trans[t[i]];
	}
	if(Work())GG();
	puts("YES");
	return 0;
}

Measured memory_bytes: 640
# 同じ木に属する(==そこまでたどりつけるかどうか）の判定にunionfind
# 同じ木に属しているノードはあとで数えることができる（そうだね）
# 除外するやつが出てくる。直の友達+ブロック関係にあるやつ（と自分）
# 同じ木に属しているノードの総数 - (直の友達+ブロック関係+自分自身)が答え
from sys import setrecursionlimit
setrecursionlimit(10**8)
n, m, k = map(int, input().split())
par = [i for i in range(n)]
ans = [0 for _ in range(n)]


def root(x):
    if x == par[x]:
        return x
    y = root(par[x])
    par[x] = y
    return y


def union(x, y):
    if x > y:
        x, y = y, x
    rx, ry = root(x), root(y)
    if rx != ry:
        par[ry] = rx


friends = [[] for _ in range(n)]
blocks = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    union(a - 1, b - 1)
    friends[a - 1].append(b - 1)
    friends[b - 1].append(a - 1)
for _ in range(k):
    c, d = map(int, input().split())
    blocks[c - 1].append(d - 1)
    blocks[d - 1].append(c - 1)

# 木に属しているやつを数えるぜ
group_count = [0 for _ in range(n)]
for i in range(n):
    group_count[root(i)] += 1
# 答えを作るぜ
for i in range(n):
    # 初期化（じゃないけど）
    ans[i] += group_count[root(i)]
    # 直の友達を除く
    ans[i] -= len(friends[i])
    # ブロックしてるやつを除く
    for b in blocks[i]:
        ra, rb = root(i), root(b)
        if ra == rb:
            ans[i] -= 1
    # 自分自身を除く
    ans[i] -= 1
print(" ".join(list(map(str, ans))))


Measured memory_bytes: 63660
S=list(input())
N=len(S)
first=True
second=True

for i in range((N-1)//2):
    if S[i]!=S[N-1-i]:
        first=False
if first==True:
    for j in range(N//4+1):
        if S[j]!=S[N//2-1-j]:
            second=False
if first==True and second==True:
    print("Yes")
else:
    print("No")





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

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

  if (s == "SUN")
    cout << 7 << endl;
  if (s == "MON")
    cout << 6 << endl;
  if (s == "TUE")
    cout << 5 << endl;
  if (s == "WED")
    cout << 4 << endl;
  if (s == "THU")
    cout << 3 << endl;
  if (s == "FRI")
    cout << 2 << endl;
  if (s == "SAT")
    cout << 1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

int main(){
  startupcpp();
  int i,N;
  cin>>N;
  vector<int> a(N);
  multiset<int> se;
  rep(i,N){
    cin>>a[i];
    se.insert(a[i]);
  }
  vrsort(a);
  if(a[0]!=a[1]){
    print("Impossible");
    return 0;
  }
  vector<int> v(a[0]+1);
  rep(i,a[0]+1)v[a[0]-i]=i;
  rep(i,a[0]+1)chmax(v[i],i);
  rep(i,a[0]+1){
    if(se.count(v[i])==0){
      print("Impossible");
      return 0;
    }
    se.erase(se.find(v[i]));
  }
  if(se.size()==0||*se.lower_bound(0)>*min_element(all(v))){
    print("Possible");
  }else{
    print("Impossible");
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():

	n = int(raw_input())
	i = 1
	print(''),
	while i <= n:
		x = i
		if x % 3 == 0:
			print('%d' % i),
		else:
			while x > 0:
				if x % 10 == 3:
					print('%d' % i),
					break
				x /= 10
		i += 1

if __name__ == "__main__":

	main()


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    cout<<a.at(N-1)-a.at(0)<<endl;

}

Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split(' ').map(&:to_i)
B = gets.chomp.split(' ').map(&:to_i)

cnt, prev_cnt = 0, -1
while cnt != prev_cnt
  prev_cnt = cnt
  N.times do |i|
    adj_sum = B[(i - 1) % N] + B[(i + 1) % N]
    k = (B[i] - A[i]) / adj_sum
    if k > 0
      B[i] -= k * adj_sum
      cnt += k
    end
  end
end

# require 'pry'



if A == B
  puts cnt
else
  puts -1
end








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

int		main() {
  int x, ureshisa, tmp;
  cin >> x;
  
  ureshisa = (x / 500) * 1000;
  tmp = x % 500;
  ureshisa += (tmp / 5) * 5;
  
  cout << ureshisa << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
string s;cin>>s;
ll l=s.length();
ll count=0;
for(ll i=0;i<l;i++){
        if((i+1)%2!=0){
    if(s[i]=='R' || s[i]=='U' || s[i]=='D'){
            count++;
    }
        }
    else{
        if(s[i]=='L' || s[i]=='U' || s[i]=='D'){
            count++;
        }
    }
}
if(count==l){
    cout<<"Yes";
}else{
cout<<"No";}

}


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

string toString(int n)
{
    string str;
    stringstream ss;
    ss << n;
    ss >> str;
    return str;
}

string toNegativeBase(int n, int negBase)
{
    if (n == 0) return "0";
    string converted = "";
    while (n != 0)
    {
        int remainder = n % negBase;
        n /= negBase;
 
        if (remainder < 0)
        {
            remainder += (-negBase);
            n += 1;
        }
        converted = toString(remainder) + converted;
    }
 
    return converted;
}
long long int n;
int main()
{
	cin >> n;
    int negBase = -2;
 
    cout << toNegativeBase(n, negBase);
 
    return 0;
}

Measured memory_bytes: 256
lst = [input() for _ in range(5)]
check = float("inf")
last_num = 0

for i in lst:
    if int(i[-1]) != 0 and int(i[-1]) < check:
        check = int(i[-1])
        last_num = i
if last_num != 0:
    lst.remove(last_num)

for i in range(len(lst)):
    if int(lst[i]) % 10  != 0:
        lst[i] = (int(lst[i]) + (10 - int(lst[i]) % 10))

print(sum(list(map(int,lst))) + int(last_num))

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll sum=0;
    
    if(k>a){
        sum+=a;
        k-=a;
        if(k>0) k=k-b;
        if(k>0){
            if(k<=c) sum-=k;
        }
    }else if(k==a)
    { 
        sum+=k;  
    }else{
        sum+=k;
    }

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


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


int main() {
  int l,r,d;
  cin >> l >> r >> d;
  if(l%d==0 && r%d==0)
  cout << abs(l/d-r/d)+1 << endl;
  else
  cout << abs(l/d-r/d) << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define Start ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define fr first
#define sc second
#define PI 3.14159265
#define ullt unsigned long long int
using namespace std;
const int MOD=1e9+7;
ll mod (ll x){
	return (x%MOD+MOD)%MOD;
}
ll add(ll x,ll y){
	return mod(y)+mod(x);
}
ll mul(ll x,ll y){
	return mod(x)*mod(y);
}
void solve(){
	ll n;
	cin>>n;
	vector<ll>a(n+1);
	for(int i=0;i<n;i++)cin>>a[i];
	vector<ll>pre(n+1);
	pre[0]=a[0];
	for(int i=1;i<n;i++)pre[i]=pre[i-1]+a[i];
	ll ans=0;
	for(int i=0;i<n;i++)
		ans=add(ans,mul(a[i],pre[n-1]-pre[i]));
	cout<<ans;
	

}
int main()
{
	Start;

	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
		cout << "\n";
	}
	return 0;
} 


Measured memory_bytes: 6356
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	d = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}
	S = sys.stdin.readline()
	print(d[S[:-1]])


main()

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

int main() {
	int n, k;
	cin >> n >> k;
	
	vector<int> a(n);
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	
	vector<int> dp(n);
	int pos = a[0];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	for (int i=2; i<n; i++) {
		dp[i] = dp[i-1]+abs(a[i-1] - a[i]);
		for (int j=2; j<=min(i, k); j++) {
			dp[i] = min(dp[i], dp[i-j]+abs(a[i-j] - a[i]));
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    stack<char> q;
    int ret = 0;
    for (int i = 0; i < s.size(); i++) {
        if (!q.empty() && q.top() != s[i]) {
            ret += 2;
            q.pop();
        } else q.push(s[i]);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  reep(i,1,n){
    if((1<=i&&i<=9)||(100<=i&&i<=999)||(10000<=i&&i<=99999))
      ++sum;
  }
  ou(sum);
}

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

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

void sol( ){
  ll a, b, c, k ;
  cin >> a >> b >> c >> k ;
  ll ans = 0 ;
  if( k > 0 ){
    ans += min( a, k ) ;
    k -= min( a, k ) ;
  }
  if( k > 0 ){
    k -= min( k, b ) ;
  }
  if( k > 0 ){
    ans -= min( k, c ) ;
    k -= min( k, c ) ;
  }
  cout << ans << nl ;
}

signed main( ){
  timesaver ;
//  int t = 1 ; cin >> t ; while(t--)
  {
    sol( );
  }
}

Measured memory_bytes: 3612