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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

void hawawa()
{
  llong a, b, c;
  cin >> a >> b >> c;
  cout << min({(a % 2) * b * c, (b % 2) * a * c, (c % 2) * b * a}) << "\n";
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = pi*r*r;
        double length = 2*pi*r;
        System.out.printf("%f %f",area,length);
    }
}


Measured memory_bytes: 28156
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int H,W; cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; i++){ cin >> S[i];}
  
  int dx[] = { 1,0,-1,0};
  int dy[] = {0, 1, 0, -1};
  
  bool flag = true;
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
       flag = false;
      if(S[i][j] == '.'){ continue;}
      else{
        for(int k = 0; k < 4; k++){
          if( 0 <= i + dx[k] && i + dx[k] < H && 0 <= j + dy[k] && j + dy[k] < W && S[i + dx[k]][ j + dy[k]] == '#'){
            flag = true;}}
            if(!flag){ cout << "No" << endl; return 0;}
      
      }}}
  
  cout << "Yes" << endl; 
  return 0;}
        

Measured memory_bytes: 256
import math


def C(n,r):
    fact = math.factorial
    return fact(n) // fact(r) // fact(n-r)

def main():
    N, A, B = tuple(map(int, input().split(' ')))
    v = list(map(int, input().split(' ')))

    v.sort(reverse=True)

    print(sum(v[:A])/A)

    a, b = v.count(v[A-1]), v[:A].count(v[A-1])

    if v[0] == v[A-1]:
        print(sum([C(a, r) for r in range(A, min(B, a)+1)]))
    else:
        print(C(a, b))



if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

const int MAX_V = 100010;

vector<int> G[MAX_V];
int V;
int color[MAX_V];
int WB[3];
// 頂点を1と-1で塗っていく
bool dfs(int v, int c) {
    color[v] = c;
    WB[c+1]++;

    for (int i = 0; i < G[v].size(); i++) {
        // 隣接している頂点が同じ色ならfalse
        if (color[G[v][i]] == c) return false;
        // 隣接している頂点がまだ塗られていないなら-cで塗る
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }

    // すべての頂点を塗れたらtrue
    return true;

}

 

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M;
    cin >> V >> M;
    rep(i, M) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    if (dfs(0, 1)) cout << (ll)WB[0]*WB[2] - M << endl;
    else cout << (ll)V*(V-1)/2 - M << endl;

    return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		sc.close();

		if (a >= c || b >= c) {
			System.out.println("No");
		} else {
			long val1 = 4 * a * b;
			long val2 = c - a - b;
			val2 *= val2;
			if (val1 < val2) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
  double n;
  cin >> n;
  double x[int(n)], y[int(n)], a[int(n)];
  for (int i = 0; i < n; i++)
    cin >> x[i];
  for (int i = 0; i < n; i++)
  {
    cin >> y[i];
    a[i] = abs(x[i] - y[i]);
  }

  double p1 = 0;
  double p2 = 0;
  double p3 = 0;
  double p4 = 0;
  for (int i = 0; i < n; i++)
  {
    p1 += a[i];
    p2 += a[i] * a[i];
    p3 += a[i] * a[i] * a[i];
    if (p4 < a[i])
      p4 = a[i];
  }
  p2 = sqrt(p2);
  p3 = pow(p3, 1.0 / 3.0);

  cout << fixed << setprecision(10) << p1 << endl;
  cout << p2 << endl;
  cout << p3 << endl;
  cout << p4 << endl;
}

Measured memory_bytes: 3464
def partition(a, p, r):
    x = int(a[r].split()[1])
    i = p-1
    for j in range(p, r):
        if int(a[j].split()[1]) <= x:
          i = i+1
          a[i], a[j] = a[j], a[i]
    a[i+1], a[r] = a[r], a[i+1]
    return i+1

def quick_sort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quick_sort(a, p, q - 1)
        quick_sort(a, q + 1, r)

n = int(input())
cards = [input() for i in range(n)]
stable = sorted(cards, key=lambda x: int(x.split()[1]))
quick_sort(cards, 0, n - 1)

print("Stable" if stable == cards else "Not stable")

for card in cards:
    print(card)


Measured memory_bytes: 17276
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, t;
    cin >> n >> t;
    long long a[n], s = t;
    for (long long i = 0; i < n; i++) cin >> a[i];
    if (n > 1)
        for (long long i = 1; i < n; i++) s += min(a[i] - a[i - 1], t);
    cout << s;
}

Measured memory_bytes: 5172
import itertools
a, b = map(int, input().split())

def hoge(x: int):
    ans = []
    t = 1
    while x >= t:
        temp = t * (x//(t * 2)) + max(x%(t * 2) - (t - 1), 0)
        ans.append(temp)
        t *= 2
    return ans
ans=0
t=1
for i, j in itertools.zip_longest(hoge(b) , hoge(a-1), fillvalue = 0):
    if (i - j) % 2 == 1:
        ans += t
    t *= 2
print(ans)



Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

    vi a(n);
    rep(i, n) {
        if(s[i] == 'R') a[i] = 0;
        if(s[i] == 'G') a[i] = 1;
        if(s[i] == 'B') a[i] = 2;
    }
    vi cnt(3);
    rep(i, n) cnt[a[i]]++;
    //rep(i, 3) cout << cnt[i] << " " << endl;
    ll ans = 1;
    rep(i, 3) ans *= cnt[i];
    rep(j, n)rep(i, j) {
        int k = j + (j - i);
        if(k < n) {
            if(a[i] == a[j]) continue;
            if(a[i] == a[k]) continue;
            if(a[j] == a[k]) continue;
            ans--;
        }
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
  char seq_word[11];
  char eot[] = {"END_OF_TEXT"};
  char input_sen[1000];
  int counter_i = 0;
  int counter_j = 0;

  scanf("%s", seq_word);

  for( ; ; )
    {
      scanf("%s", input_sen);
      if(strcmp(input_sen, eot) == 0)
	break;

      for(counter_i = 0 ; input_sen[counter_i] != '\0' ; counter_i++)
	input_sen[counter_i] = tolower(input_sen[counter_i]);

      if(strcmp(input_sen, seq_word) == 0)
	counter_j++;
    }
  printf("%d\n", counter_j);
}



Measured memory_bytes: 2072
n = int(input())
can_make = [False for i in range(101)]
four = [4*i for i in range(26)]
seven = [7*i for i in range(15)]

for f in four:
    for s in seven:
        if f+s <= 100:
            can_make[f+s]=True

if can_make[n]:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
char s[4], date[8][4]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
scanf("%s",s);
for(int i=0;i<7;i++){
    if(date[i][0] == s[0] && date[i][1] ==s[1]){
printf("%d\n", 7-i);
    }
}
 return 0;
}

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
// Verify : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1102
#include <iostream>
#include <cctype>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;

char e[1000];

typedef long long ll;
typedef complex<ll> C;

inline bool valid(C x){
    ll t = max(abs(x.real()),abs(x.imag()));
    return t <= 10000;
}

class OverFlow {};

C expr(char* &p);
C term(char* &p);
C fact(char* &p);
C num(char* &p);

inline bool ispm(char c){
    return c=='+' || c=='-';
}
inline bool ispd(char c){
    return c=='*' || c=='/';
}

C num(char* &p){
    C res = 0;
    if(isdigit(*p) || *p == 'i'){
        ;
    }else{
        throw "num begin";
    }
    if(isdigit(*p)){
        while (isdigit(*p)){
            res*=10;
            res+=*p-'0';
            if(!valid(res)) throw OverFlow();
            p++;
        }
    }else{
        res = C(0,1);
        p++;
    }

    if(*p=='\0' || *p==')' || ispm(*p) || ispd(*p)){
        ;
    }else{
        throw "num end";
    }

    if(!valid(res)) throw OverFlow();
    return res;
}

C fact(char* & p){
    C res = 0;
    if(*p=='(' || isdigit(*p) || *p == 'i'){
        ;
    }else{
        throw "fact begin";
    }

    if(*p=='('){
        p++;
        res += expr(p);
        p++;
    }else if(isdigit(*p) || *p == 'i'){
        res += num(p);
    }
    if(*p=='\0' || *p==')' || ispm(*p) || ispd(*p)){
        ;
    }else{
        cout << p-e << endl;
        throw "fact end";
    }

    if(!valid(res)) throw OverFlow();
    return res;
}

C term(char* & p){
    C res;
    if(*p=='(' || isdigit(*p) || *p == 'i'){
        res = fact(p);
    }else{
        throw "term begin";
    }
    while(1){
        if(*p=='*'){
            p++;
            res *= fact(p);
        }else if(*p=='/'){
            p++;
            res /= fact(p);
        }else if(*p=='\0' || *p==')' || *p=='+' || *p=='-'){
            break;
        }else{
            throw "term end";
        }
        if(!valid(res)) throw OverFlow();
    }

    if(!valid(res)) throw OverFlow();
    return res;
}

C expr(char* & p){
    C res;
    if(*p=='(' || isdigit(*p) || *p == 'i'){
        res=term(p);
    }else{
        throw "exp begin";
    }

    while(1){
        if(*p=='+'){
            p++;
            res += term(p);
        }else if(*p=='-'){
            p++;
            res -= term(p);
        }else if(*p=='\0' || *p==')'){
            break;
        }else{
            throw "exp end";
        }
        if(!valid(res)) throw OverFlow();
    }

    return res;
}

void print(C c){
    int a=c.real(), b=c.imag();
    if(a==0 && b==0) cout << 0 << endl;
    else if(a==0) cout << b << "i" << endl;
    else if(b==0) cout << a <<endl;
    else if(b>0) cout << a << "+" << b << "i" << endl;
    else cout << a << b << "i" << endl;
}

int main(){
    while(cin>>e){
        try {
            char* p = e;
            print(expr(p));
        } catch(const OverFlow e){
            cout << "overflow" << endl;
        }
    }
}

Measured memory_bytes: 1252
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

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

	int A[H + 1][W + 1];
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			scanf("%d", &A[i][j]);
		}
	}

	int V[H + 1][W + 1];
	for (int i = 0; i <= H; ++i) {
		V[i][0] = 0;
	}
	for (int i = 0; i <= W; ++i) {
		V[0][i] = 0;
	}

	int maxWidth = 0;
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (A[i][j] == 0) {
				V[i][j] = min(V[i][j - 1], min(V[i - 1][j - 1], V[i - 1][j])) + 1;
				maxWidth = max(maxWidth, V[i][j]);
			} else {
				V[i][j] = 0;
			}
		}
	}
	cout << maxWidth * maxWidth << endl;

	return 0;
}

Measured memory_bytes: 18464
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
    int r, a, b;
    cin >> r;
    
    if(r == 1) {
        cout << "Hello World" << endl;
        return 0;
    }
    else{
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output


int main() {

	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	ll l;
	cin>>l;

	double s = double(l);
	cout<<setprecision(10)<<(s/3)*(s/3)*(s/3);

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int seen[200010];

int main(){
  ll n,k; cin >> n >> k;
  rep(i,n) seen[i]=-1;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  int b=0;
  int cycle=0;
  int x=0;
  rep(i,n){
    if(i==k){
      cout << b+1 << endl;
      return 0;
    }
    if(seen[b]!=-1){
      x=seen[b];
      cycle=i-seen[b];
      break;
    }
    seen[b]=i;
    b=a[b];
  }
  k=(k-x)%cycle+x;
  b=0;
  rep(i,k){
    b=a[b];
  }
  cout << b+1 << endl;
}

Measured memory_bytes: 4844
//
// Created by sark2 on 19-10-2019.
//

#include "bits/stdc++.h"

#define pb push_back
using namespace std;
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cases int t;cin>>t;while(t--)
typedef long double ld;
typedef long long ll;
ll mod = 1e9 + 7;
int n;

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

int mul(int a, int b)  {
    return (ll) a*b % mod;
}



struct M{
    vector<vector<int>>t;
    M(){
        t.resize(n,vector<int>(n));
    }
    M operator*(const M& b)const{
        M c = M();
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                for(int k = 0; k < n; k++){
                    add_self(c.t[i][k], mul(t[i][j], b.t[j][k]));
                }
            }
        }
        return c;
    }
};





int main() {
    IOS

    cin>>n;
    ll k; cin>>k;

    vector<vector<int>>mat(n, vector<int>(n,0));

    for(auto &row : mat){
        for(auto& e : row){
            cin>>e;
        }
    }

    M ans = M();
    for(int i = 0; i < n; i++)
        ans.t[i][i]  = 1;

    M m = M();
    m.t = mat;

    while(k){
        if(k % 2 ){
            ans = ans*m;
        }
        m = m*m;
        k /= 2;
    }

    int total = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            add_self(total, ans.t[i][j]);
        }
    }

    cout<<total<<"\n";

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int m=sc.nextInt();
        int mina=Integer.MAX_VALUE;
        int minb=Integer.MAX_VALUE;
        int[] as=new int[a];
        int[] bs=new int[b];
        for(int i=0;i<a;i++){
            as[i]=sc.nextInt();
            mina=Math.min(mina, as[i]);
        }
        for(int i=0;i<b;i++){
            bs[i]=sc.nextInt();
            minb=Math.min(minb, bs[i]);
        }
        int ans=mina+minb;
        for(int i=0;i<m;i++){
            ans=Math.min(ans, as[sc.nextInt()-1]+bs[sc.nextInt()-1]-sc.nextInt());
        }
        System.out.println(ans);
        
        
 
    }



}


Measured memory_bytes: 132360
A,B,N = map(int, input().split())

import math

i = B-1
#print(i, math.floor(a*i/b), a*math.floor(i/b), math.floor(a*i/b)-a*math.floor(i/b))

if B-1 <= N:
    i = B-1
else:
    i = N
print(math.floor(A*i/B)-A*math.floor(i/B))

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  int ans = 1;
  rep (i, N) { ans = min(ans + K, ans * 2); }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import string
def main():
    def f(n):
        if n == -1:return
        a, b = divmod(n, 26)
        ans.append(string.ascii_lowercase[b])
        f(a-1)

    N = int(input())
    ans = []
    f(N-1)
    print("".join(ans[::-1]))
if __name__ == "__main__":
    main()

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

int main() {
  int n; cin >> n;
  if (n%2 == 0) cout << n/2 << endl;
  else cout << n/2+1 << endl;
  
  return 0;
}

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

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

long calc(int[] a) {
    long ans = 0;
    int hi = 0;
    int sum = a[0]; // lo=0 の分
    for (int lo = 0; lo < a.length; lo++) {
        // hi を伸ばせるところまで伸ばす
        while (hi + 1 < a.length && sum + a[hi + 1] == (sum ^ a[hi + 1])) {
            sum += a[hi + 1];
            hi++;
        }

        ans += hi - lo + 1;
        // lo を右にずらすのでその分だけ引く
        sum -= a[lo];
        // hi = max(hi, lo);
    }
    return ans;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}


Measured memory_bytes: 11432
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i<n; i++)
#define ll long long
#define MOD 1000000007
using namespace std;;
 
int main() {
  int N,ans =1; scanf("%d",&N); 
  while(ans<=N) {
    ans *=2;
  } 
  printf("%d\n",ans/2);
  
}

Measured memory_bytes: 3776
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int a, b;
	int ans = 1;
	cin >> a >> b;
	REP(i, a) {
		ans = min(2 * ans, ans + b);
	}
	cout << ans << endl;
}



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

int main()
{
    string s, t;

    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    bool is_t_big;
    bool is_compare = false;

    int len_s = s.size();
    int len_t = t.size();
    int min_len = len_s > len_t ? len_t : len_s;
    
    
    for ( int i = 0; i < min_len; i++ ) 
    {
        if ( t[i] > s[i] )
        {
            is_t_big = true;
            is_compare = true;
            break;
        }
        
        if ( t[i] < s[i] )
        {
            is_t_big = false;
            is_compare = true;
            break;
        }
    }

    if ( !is_compare ) 
    {
        if ( len_s >= len_t )
        {
            is_t_big = false;
        } 
        else
        {
            is_t_big = true;
        }
    }

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


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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

using namespace std;

template <class T> int find_index(T x, const std::vector<T> &v) {
    auto it = std::find(v.begin(), v.end(), x);
    if (it != v.end()) { return (int)std::distance(v.begin(), it); }
    return -1;
}
template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }

template <class T> void print(T x) {
    std::cout << x << std::endl;
}

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

    vector<vector<pair<int, int>>> graph(N);
    FOR(i, 0, M) {
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        graph[l].emplace_back(make_pair(r, d));
        graph[r].emplace_back(make_pair(l, -d));
    }

    vector<bool> used_node(N, false);
    vector<int> dist(N);

    FOR(i, 0, N) {
        if (used_node[i]) { continue; }

        dist[i] = 0;
        used_node[i] = true;

        queue<int> que;
        que.push(i);
        while (not que.empty()) {
            auto node1 = que.front(); que.pop();


            FOE(node, graph[node1]) {
                int node2 = node.first;
                int d = node.second;

                if (used_node[node2]) {
                    if (dist[node2] != dist[node1] + d) {
                        print(No);
                        return 0;
                    }
                }
                else {
                    used_node[node2] = true;
                    dist[node2] = dist[node1] + d;
                    que.push(node2);
                }
            }
        }
    }

    print(Yes);

}


Measured memory_bytes: 9344
//    _____ _     _                _           _     _ _     _     
//    \_   \ |_  (_)___  __      _| |__   __ _| |_  (_) |_  (_)___ 
//     / /\/ __| | / __| \ \ /\ / / '_ \ / _` | __| | | __| | / __|
//  /\/ /_ | |_  | \__ \  \ V  V /| | | | (_| | |_  | | |_  | \__ \
//  \____/  \__| |_|___/   \_/\_/ |_| |_|\__,_|\__| |_|\__| |_|___/
//                                                                 
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=2e5+9;
int n;
ll a[sz];
ll k;

ll div_floor(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll div_ceil(ll a, ll b) {
	return a / b + (((a ^ b) >= 0) and a % b);
}


bool ok(ll x){
	ll ret=0;
	for(int i=0;i<n;i++){
		int pos;
		if(!a[i]) ret+=(x>=0?n-1:0);
		else if(a[i]>0){
			// y*a[i]<=x
			// y<=x/a[i];
			ll y=div_floor(x,a[i]);
			pos=upper_bound(a,a+n,y)-a;
			if(pos<=n-1) ret+=pos-(pos-1>=i);
			else ret+=n-1;
		}else{
			// y*a[i]<=x
			// y>=x/a[i]
			ll y=div_ceil(x,a[i]);
			pos=lower_bound(a,a+n,y)-a;
			if(pos<=n-1) ret+=n-pos-(pos<=i);
		}
	}
	ret>>=1;
	return ret>=k;
}


int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll st=-1e18,en=1e18;
	while(st<en){
		ll mid=(st+en)>>1;
		if(ok(mid)) en=mid;
		else st=mid+1;
	}
	cout<<st;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N ,M, K;
    cin >> N >> M >> K;
    bool ok = false;
    rep(n, N+1)rep(m ,M+1)ok |= (K == (N-n)*m + (M-m)*n);
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;

int main() {
	int p, q, r;
	cin >> p >> q >> r;
	int res = min(p+q,q+r);
	res = min(res, r + p);
	pv(res)

	return(0);
}

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

typedef pair<int,int> pii;

int n, m;

int main() {
	while(cin >> n >> m, n || m) {
		vector<vector<int> > pic, sce;
		for(int i = 0; i < n; i++) {
			vector<int> v;
			for(int j = 0; j < n; j++) {
				int tmp;
				cin >> tmp;
				v.push_back(tmp);
			}
			pic.push_back(v);
		}
		for(int i = 0; i < m; i++) {
			vector<int> v;
			for(int j = 0; j < m; j++) {
				int tmp;
				cin >> tmp;
				v.push_back(tmp);
			}
			sce.push_back(v);
		}

		vector<pii> ans;
		for(int d = 0; d < 4; d++) {
			for(int i = 0; i < n - m + 1; i++) {
				for(int j = 0; j < n - m + 1; j++) {
					pii p;
					for(int k = 0; k < m; k++) {
						for(int l = 0; l < m; l++) {
							if(pic[i+k][j+l] != sce[k][l] && sce[k][l] != -1)
								goto LABEL;
						}
					}

					for(int k = 0; k < m; k++) {
						for(int l = 0; l < m; l++) {
							if(sce[k][l] != -1) {
								p.first = k + i;
								p.second = l + j;
								k = l = m;
							}
						}
					}
					ans.push_back(p);
					/*
					for(int i = 0; i < n; i++) {
						for(int j = 0; j < n; j++)
							cout << pic[i][j] << " ";
						cout << endl;
					}
					for(int i = 0; i < m; i++) {
						for(int j = 0; j < m; j++)
							cout << sce[i][j] << " ";
						cout << endl;
					}
					*/
LABEL:;
				}
			}

			vector<vector<int> > nex;
			for(int i = 0; i < m; i++) {
				nex.push_back(vector<int>());
				for(int j = 0; j < m; j++) {
					nex[i].push_back(sce[m-1-j][i]);
				}
			}
			sce = nex;
		}
		sort(ans.begin(), ans.end());

		if(ans.size()) {
			cout << ans[0].second + 1 << " " << ans[0].first + 1 << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    bool n,w,s,e;
    n=w=s=e=0;
    string X;
    cin>>X;
    rep(i,X.size()){
        if(X[i]=='N')n=1;
        if(X[i]=='W')w=1;
        if(X[i]=='S')s=1;
        if(X[i]=='E')e=1;
    }
    if((n&w&s&e)||(n&(!w)&s&(!e))||((!n)&w&(!s)&e))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using P = pair<int, int>;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<int> A(N);
    for (int& x : A) cin >> x;
    vector<int> id(N);
    iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(), [&](int a, int b) {
      if (A[a] != A[b]) return A[a] > A[b];
      return a < b;
    });
    for (int i = 0; i < N; i++) {
      int k = -1;
      for (int j = 0; j < 2; j++) {
        if (id[j] != i) {
          k = id[j];
          break;
        }
      }
      cout << A[k] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	int N; cin >> N;
	ll cnt = 0;
	vector<ll> h(N); 
	rep(i, N) {
		cin >> h[i];
		if (h[i] == 0) cnt++;
	}

	ll ans = 0;
	while (1) {
		if (cnt == N) {
			cout << ans << endl;
			return 0;
		}
		ll l = -1, r = -1;
		rep (i, N) {
			if (l == -1 && h[i] != 0) l = i;
			if (l != -1 && h[i] == 0) {
				r = i - 1;
				break;
			}
			if (l != -1&& i == N - 1 && r == -1) r = N - 1;
		}

		for (int i = l; i <= r; i++) {
			h[i]--;
			if (h[i] == 0)cnt++;
		}
		ans++;
	}
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

const string HIDDEN = "";

int query_count = 0;

string query(const string& q) {
  query_count++;
  if (query_count > 64) {
    cerr << "Too many queries!" << endl;
    exit(1);
  }

  cout << "? " << q << endl;
  if (HIDDEN.empty()) {
    string response;
    cin >> response;
    return response;
  } else {
    int64 qi = stoll(q);
    int64 hi = stoll(HIDDEN);
    if ((qi <= hi && q <= HIDDEN) || (qi > hi && q > HIDDEN)) {
      return "Y";
    } else {
      return "N";
    }
  }
}

void output(const string& q) {
  cout << "! " << q << endl;
}

int main() {
  string r1 = query("1000000000000");
  if (r1 == "Y") {
    // The answer is 10^k
    string q = "9";
    while (true) {
      if (query(q) == "Y") {
        string ans = "1";
        while (ans.size() < q.size()) ans += "0";
        output(ans);
        return 0;
      } else {
        q += "9";
      }
    }
  }

  int size = -1;
  for (int d = 9; d >= 1; d--) {
    string q = "1";
    while (q.size() < d) q += "0";
    if (query(q) == "Y") {
      size = d;
      break;
    }
  }

  if (size < 0) {
    cerr << "Unexpected!" << endl;
    exit(1);
  }

  if (DEBUG) {
    cout << "size: " << size << endl;
  }

  string ans = "";
  for (int d = 0; d < size; d++) {
    int l = 0;
    int r = 9;
    if (d == 0) {
      l = 1;
    }

    while (l < r) {
      if (d < size - 1) {
        int m = (l + r + 1) / 2;
        string q = ans + to_string(m);
        string response = query(q);
        if (response == "Y") {
          l = m;
        } else {
          r = m - 1;
        }
      } else {
        int m = (l + r) / 2;
        string q = ans + to_string(m) + "0";
        string response = query(q);
        if (response == "Y") {
          r = m;
        } else {
          l = m + 1;
        }
      }
    }
    ans += to_string(l);
  }

  output(ans);
}

Measured memory_bytes: 596
N, M = map(int, input().split())
ans = -float('inf')
for i in range(1, int(M ** .5 ) + 1):
    if M % i == 0:
        if N <= i:
            ans = max(ans, M // i)
        if N <= M // i:
            ans = max(ans, i)
print(ans)

Measured memory_bytes: 38640
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}


vector<long> dp(1000000, -1);
long n;
long k;



//dp[i]にその位置までの最小コストを保存
long search(vector<long>&h, long pos) {
  long mincost = LINF;

  cerr << pos <<endl;


  for(int i=1;i<=k;i++){
    if (!(pos + i < n))continue;

    if (dp[pos + i] < 0) {
      mincost = min(search(h,pos + i) + abs(h[pos] - h[pos+i]),mincost); //再帰呼び出し
    }else{
      mincost = min(dp[pos + i] + abs(h[pos] - h[pos+i]),mincost); //DP利用
    }
  }

  if (pos == n-1)mincost = 0;
  dp[pos] = mincost;



  return mincost;
}



int main() {


  cin >> n >> k;

  vector<long> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  long ans = 0;


  ans = search(h, 0);

  cerr <<endl;
  for(int i=0;i<n;i++){
    cerr <<dp[i] <<endl;
  }


  cout << ans;


}























Measured memory_bytes: 15104
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
s = input()
t = input()

ans = 10**10

for i in range(n - 1, -1, -1):
    if s[i:] == t[:n-i]:
        if len(s) + len(t[n-i:]) >= n:
            ans = min(ans, len(s) + len(t[n-i:]))
if len(s) + len(t) >= n:
    ans = min(ans, len(s) + len(t))

if ans == 10**10:
    print(n)
else:
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;

  int max=A+B;
  if (max < A - B) max = A - B;
  if (max < A*B) max = A * B;

  cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n!=0){
    int i;
    double s[1000]={},sum=0,a=0;
    for(i=0;i<n;i++){
      cin >> s[i];
      sum+=s[i];
    }
    for(i=0;i<n;i++){
      a+=((sum/n)-s[i])*((sum/n)-s[i])/n;
    }
    printf("%.5f\n",sqrt(a));
    cin >> n;
  }
  
  return 0;
}



Measured memory_bytes: 3212
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
  ios;
  int n;
  cin>>n;
  double a[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];

  }
  sort(a,a+n);
  for(int i=0;i<n;i++)
  {
      a[i+1]=(a[i]+a[i+1])/2.0;
  }
  cout<<a[n-1]<<endl;





}
//Alhamdulillah












Measured memory_bytes: 3784
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18

 
using namespace std;
 
int max(int a, int b)
{
    if(a>b) return a;
    else return b;
}
 
int min(int a,int b)
{
    if(a<b) return a;
    else return b;
}
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int n,i,temp,sum=0;
    cin>>n;
    vi count(100001);
    for(i=0;i<n;i++)
    {
        cin>>temp;
        count[temp]++;
        sum+=temp;
    }
    int q;
    cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        sum=sum-count[b]*b+count[b]*c;
        count[c]+=count[b];
        count[b]=0;
        cout<<sum<<endl;
    }
}

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


int main() {
  int x,n; cin>>x>>n;
  vector<int> v(n);
  rep(i,n){cin>>v[i];}
  int m=x,ans;
  for (int i=101; i>=0; i--){
    if(count(v.begin(),v.end(),i)){continue;}
    else{
      int mm= max(x-i,i-x);
      if(mm<=m){
        m=mm;
        ans=i;
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 13 17:16:33 2016

"""

U = []
n = int(input())
for _ in range(n):
    U.append(input())

D = True
U = set(U)
    
m = int(input())
for _ in range(m):
    t = input()
    if t in U:
        print({True:"Opened by ", False:"Closed by "}[D]+t)
        D = not D
    else:
        print("Unknown " + t)

Measured memory_bytes: 7672
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    quota,half,single,double = map(int,input().split())
    want_icetea=int(input())
    cost_list = [4 * quota, 2 * half, single, double / 2]
    ans=0
    if want_icetea >= 2:
        idx1 = cost_list.index(min(cost_list))
        if idx1 == 0:
            ans = 4 * quota * want_icetea
        elif idx1 == 1:
            ans = 2 * half * want_icetea
        elif idx1 == 2:
            ans = single * want_icetea
        elif idx1 == 3:
            if want_icetea % 2 == 0:
                ans = want_icetea // 2 * double
            elif want_icetea % 2 == 1:
                ans = want_icetea // 2 * double
                idx2 = cost_list.index(min(cost_list[:3]))
                if idx2 == 0:
                    ans += 4 * quota
                elif idx2 == 1:
                    ans += 2 * half
                elif idx2 == 2:
                    ans += single
    else:
        idx2 = cost_list.index(min(cost_list[:3]))
        if idx2 == 0:
            ans = 4 * quota * want_icetea
        elif idx2 == 1:
            ans = 2 * half * want_icetea
        elif idx2 == 2:
            ans = single * want_icetea
    print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 9204
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll x;

	cin>>x;
	if(x%11==0){
		cout<<x/11*2<<endl;
	}else if(x%11<=6){
			cout<<x/11*2+1<<endl;
		}else if(x%11>6){
			cout<<x/11*2+2<<endl;
		}

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i < n; i++) cin >> v[i];

  int count = 0;
  int idx = 1;
  for(int i=0; i < n; i++) {
    if(v[i] != idx) count++;
    else {idx++;}
  }
  if(idx == 1) cout << -1 << endl;
  else cout << count << endl;
}


Measured memory_bytes: 1024
h, w = map(int, input().split())
s = [input() for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      d = set()
      if i>0:
        d.add(s[i-1][j])
      if i<h-1:
        d.add(s[i+1][j])
      if j>0:
        d.add(s[i][j-1])
      if j<w-1:
        d.add(s[i][j+1])
      if "#" not in d:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
from collections import defaultdict
import math
N, H = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

ab.sort(key=(lambda x: -x[0]))
max_a = ab[0][0]
ab.sort(key=(lambda x: -x[1]))
max_b = ab[0][1]

hp = 0
att = 0

if max_b >= H:
    print(1)
    exit()

for a,b in [(a,b) for a,b in ab if b > max_a]:
    hp += b
    att += 1
    if hp >= H:
        break

if hp < H:
    #max_aできり続ける
    att += math.ceil((H - hp)/max_a)

print(att)


Measured memory_bytes: 34732
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        double a, l, x;
        if(!(cin >> a >> l >> x))
            return 0;

        double y = sqrt((x * x + 2 * l * x) / 4.0);
        double z = sqrt(l * l - a * a / 4.0);
        double ret = l * y + a * z / 2.0;

        printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 1240
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,m=mii()

arr =[]
for i in range(n):
    a,b=mii()
    arr.append([a,b])
mat = []
for i in range(m):
    c,d=mii()
    mat.append([c,d])
ans=[]
for i,j in arr:
    num = 10**100
    c1,c2=0,0
    cnt=0
    p=0
    for c,d in mat:
        cnt+=1
        if abs(i-c)+abs(j-d) <num:
            c1,c2=c,d
            num = abs(i-c)+abs(j-d)
            p=cnt
            
    ans.append(p)

print(*ans)


Measured memory_bytes: 64364
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long cnt = 0 ;
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			for(int k=1; k<=n; k++)
			{
				cnt += __gcd(i, __gcd(j, k));
			}
		}
	}
	cout << cnt;
	return 0; 
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
vector<int> temp;
vector<vector<int>>vec;
int n;
void solve(int idx){
    if(idx >= n){
        vec.push_back(temp);
        return;
    }
    temp.push_back(idx);
    solve(idx + 1);
    temp.pop_back();
    solve(idx + 1);
}
int main(){
    Hello
    cin >> n;
    int c[n + 5], v[n + 5];
    for(int i = 0; i < n; i++)
        cin >> v[i];
    for(int i = 0; i < n; i++)
        cin >> c[i];
    solve(0);
    ll ans = 0;
    for(int i = 0; i < vec.size(); i++){
        ll x = 0, y = 0;
        for(int j = 0; j < vec[i].size(); j++){
            x += v[vec[i][j]];
            y += c[vec[i][j]];
        }
        ans = max(ans, x - y);
    }
    cout << ans;
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  if (n % 10 == 9) {
    cout<<"Yes"<<endl;
  } else if (n / 10 == 9) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256