akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int grey = 0;
	int cha = 0;
	int green = 0;
	int mizu = 0;
	int blue = 0;
	int ki = 0;
	int dai = 0;
	int red = 0;
	int any = 0;
	rep(i,n){
		if(a[i] < 400) grey = 1;
		else if(a[i] < 800) cha = 1;
		else if(a[i] < 1200) green = 1;
		else if(a[i] < 1600) mizu = 1;
		else if(a[i] < 2000) blue = 1;
		else if(a[i] < 2400) ki = 1;
		else if(a[i] < 2800) dai = 1;
		else if(a[i] < 3200) red = 1;
		else any++;
	}
	int type = grey + cha + green + mizu + blue + ki + dai + red;
	if(type == 0){
	cout << 1 << " " << type + any << endl;
	return 0;
	}
	cout << type << " " << type + any << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3608
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let r: usize = it.next().unwrap().parse().unwrap();
    let g: usize = it.next().unwrap().parse().unwrap();
    let b: usize = it.next().unwrap().parse().unwrap();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut ans = 0;
    for i in 0..(n / r + 1){
        let n = n - i * r;
        for j in 0..(n / g + 1) {
            let k = n - j * g;
            if k % b == 0 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
N = int(input())
point = dict()
for _ in range(N):
  s = str(input())
  if s in point.keys():
    point[s] += 1
  else:
    point[s] = 1

M = int(input())
for _ in range(M):
  t = str(input())
  if t in point.keys():
    point[t] -= 1

ans = max(max(point.values()), 0)
print(ans)

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

vector<int> A;
int n, m, q;
vector<tuple<int, int, int, int>> Q;
LL res = -1;

LL calc_val() {
  LL val = 0;
  for (auto &t : Q) {
    int a, b, c, d;
    tie(a, b, c, d) = t;
    if (b < sz(A) && A[b] - A[a] == c) {
      val += d;
    }
  }
  return val;
}

void solve(int len, int last) {
  if (len == n) {
    LL cur_val = calc_val();
    res = max(res, cur_val);
    return;
  }
  for (int i = last; i <= m; i++) {
    A.push_back(i);
    solve(len + 1, i);
    A.pop_back();
  }
}

int main() {
  _upgrade;
  cin >> n >> m >> q;
  Q.resize(q);
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    Q[i] = {a, b, c, d};
  }
  solve(0, 1);
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
int main()
{
	float a,b;
	float x,y;
	int c,d;
	scanf("%f%f",&a,&b);
	x = (a + b)/2;
	c = (a + b)/2;
	y = x - c;
	d = c + 1;
	if(y != 0)printf("%d",d);
	else
	printf("%d",x);
	return 0;
	}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.nextLine();
		int count = 0;
		for(String target : n.split("")) {
			if(target.equals("o")) {
				count++;
			}
		}

		int sum = (15 - n.length()) + count;
		if(sum >= 8) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}

Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
int a[maxn];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i){
        scanf("%d", &a[i]);
        a[i] -= i;
    }
    sort(a+1, a+1+n);
    ll sum = 0;
    for(int i = 1; i <= n; ++i){
        sum += abs(a[i] - a[(n+1)/2]);
    }
    printf("%lld\n", sum);
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
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(){
    ll n,m;cin >> n >>m;
    vl cnt(n,1);
    vl r(n,0);
    r[0]=1;
    rep(i,m){
        ll a,b;cin >>a >>b;a--;b--;
        if(cnt[a]==1&&r[a]==1){
            r[a]=0;r[b]=1;
        }
        if(cnt[a]>1&&r[a]==1){
            r[b]=1;
        }
        cnt[a]--;cnt[b]++;
    }
    ll ans=0;
    rep(i,n)if(r[i])ans++;
    cout <<ans <<endl;
}


Measured memory_bytes: 1792
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        ArrayList<String> w_list = new ArrayList<String>();
        
        for(String c : sc.next().split("")){
            w_list.add(c);
        }
        
        Collections.sort(w_list);
        
        Map<String, Integer> ans = new HashMap<String, Integer>();
        for(int i=0; i<w_list.size(); i++){
            if(ans.get(w_list.get(i)) == null){
                ans.put(w_list.get(i), 1);
            }else{
                ans.put(w_list.get(i), ans.get(w_list.get(i)) + 1);
            }
        }
        
        for(int i=0; i<w_list.size(); i++){
            if(ans.get(w_list.get(i)) % 2 != 0){
                System.out.println("No");
                return;
            }
        }
        
        System.out.println("Yes");
    }
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int a[3];
int main()
{
	cin>>a[0]>>a[1]>>a[2];
	if(a[0]+a[1]+a[2]>=22)
	{
		cout<<"bust";
	}
	else
	{
		cout<<"win";
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] arrayp = new int[100000];
		String[] arrays = new String[100000];
		int[] arrayA = new int[100000];
		int[] arrayW = new int[100000];
		for(int i=0;i<m;i++) {
			arrayp[i] = sc.nextInt();
			arrays[i] = sc.next();
		}
		for(int i=0;i<m;i++) {
			if(arrays[i].equals("AC")){
				arrayA[arrayp[i]]=1;
			}else if(arrayA[arrayp[i]]!=1){
				arrayW[arrayp[i]]+=1;
			}
		}
		long counta=0,countw=0;

		for(int i=0;i<100000;i++) {
			if(arrayA[i]==1) {
				counta+=1;
				if(arrayW[i]>0) {
					countw+=arrayW[i];
				}
			}
		}
		System.out.println(counta+" "+countw);

	}
}




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

int main() {
	ll n;
	cin >> n;
	ll ans = 0, cur = -1, prev = 1e11, r1;
	for(ll i = 0; i < n; ++i) {
		cin >> r1;
		if(r1<=prev) {
			++cur;
			if(cur > ans) {
				ans = cur;
			}
		}
		else {
			cur = 0;
		}
		prev = r1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
a = [int(i) for i in input().split()]

def solve() :
    c = Counter(a)
    if len(c.keys()) > 2 :
        return 'No'
    
    if len(c.keys()) == 2 :
        if max(c.keys()) - min(c.keys()) != 1 :
            return 'No'
            
        mk, Mk = min(c.keys()), max(c.keys())
        mv, Mv = c[mk], c[Mk]
        n = N - mv
        m = Mk - mv
        if 0 < m * 2 <= n :
            return 'Yes'
        else :
            return 'No'
    else :
        n = N
        m = list(c.keys())[0]
        if m * 2 <= n or m == n - 1 :
            return 'Yes'
        else :
            return 'No' 

print(solve())


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

const int N=5005;

int n,tot,p,m,cnt;
int fa[N*100];
char s[N],up[N*100];
map<int,int> ch[N*100];

void dfs(int k){
	int j,u;
	if (!m) return;
	for (j=0;j<26;j++)
		if (ch[k][j]){
			m--;
			if (!m){
				p=ch[k][j];
				break;
			}
			dfs(ch[k][j]);
		}
}

int main(){
	int i,j,k;
	scanf("%s",s+1); n=strlen(s+1);
	scanf("%d",&m);
	for (i=1;i<=n;i++){
		k=0;
		for (j=i;j<=n;j++){
			if (!ch[k][s[j]-'a']){
				ch[k][s[j]-'a']=++tot;
				fa[tot]=k; up[tot]=s[j];
			}
			k=ch[k][s[j]-'a'];
			if (j-i>5) break;
		}
	}
	dfs(0);
	while (p!=0){
		s[++cnt]=up[p];
		p=fa[p];
	}
	for (i=1;i<=cnt;i++) printf("%c",s[cnt-i+1]);
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int main() {
  ll n, k, m, ans = 0, idxa = -1, idxb = -1;
  cin >> n >> m >> k;
  vector<ll> a(n), b(m), sa(n + 1, 0), sb(m + 1, 0);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  // ll dp[n + 1][m + 1]={};

  rep(i, n) sa[i + 1] = sa[i] + a[i];
  rep(i, m) sb[i + 1] = sb[i] + b[i];

  rep(i, n + 1) {
    ll t = k - sa[i];
    ans = max(ans, upper_bound(sb.begin(), sb.end(), t) - sb.begin() + i - 1);
    if (t < 0) break;
    // cout << ans << endl;
  }

  // rep(i, idxa) rep(j, idxb) {
  //   if (sa[i] + sb[j] > k) break;
  //   ans = max(ans, i + j);
  // }

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


Measured memory_bytes: 9592
#![allow(dead_code, unused_variables)]
use proconio::{fastout, input};
use proconio::marker::Usize1;
use std::collections::VecDeque;
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        edges: [(Usize1, Usize1); m],
    }
    let mut graph = vec![vec![];n];
    let mut indeg = vec![0;n];
    let mut dp = vec![0;n];

    edges.into_iter().for_each(|(x,y)|{
        graph[x].push(y);
        indeg[y] += 1;
    });

    let mut q = VecDeque::new();
    for i in 0..n{
        if indeg[i] == 0{
            q.push_back(i);
        }
    }

    while !q.is_empty(){
        let v = q.pop_front().unwrap();
        for e in &graph[v]{
            let nv = *e;
            indeg[nv] -= 1;
            if indeg[nv] == 0{
                q.push_back(nv);
            }
            dp[nv] = max(dp[nv],dp[v] + 1);
        }
    }
    let ans = dp.into_iter().max().unwrap();
    println!("{}",ans);

}


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

int main() {
	int n;
	cin >> n;
	vector<int>g(9,0);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x >= 3200)x = 3200;
		g.at(x / 400)++;
	}
	int mi = 0;
	int ma = 0;
	for (int i = 0; i < 8; i++)if (g.at(i) >= 1)mi++;
	ma = mi + g.at(8);
	mi = max(mi, 1);
	cout << mi << " " << ma << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    if(n>=100 && n<=111){
        printf("%d\n",111);
    }
    else if(n<=222){
        printf("%d\n",222);
    }
    else if(n<=333){
        printf("%d\n",333);
    }
    else if(n<=444){
        printf("%d\n",444);
    }
    else if(n<=555){
        printf("%d\n",555);
    }
    else if(n<=666){
        printf("%d\n",666);
    }
    else if(n<=777){
        printf("%d\n",777);
    }
    else if(n<=888){
        printf("%d\n",888);
    }
    else if(n<=999){
        printf("%d\n",999);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    if(a <= 0&&b >= 0){
        cout << "Zero" << endl;
    }else if(a >= 0&&b >= 0){
        cout << "Positive" << endl;
    }else{
        if((abs(b-a-1))%2 != 0){
            cout << "Negative" << endl;
        }else{
            cout << "Positive" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <cassert>

using namespace std;

string str;

int P,Q,R;


int Minus(int a) {
  return 2 - a;
}

int Prod(int a, int b) {
  if (a == 0) {
    return 0;
  }
  if (b == 0) {
    return 0;
  }
  if (a == 1) {
    return 1;
  }
  if (b == 1) {
    return 1;
  }
  if (a == 2) {
    return 2;
  }
}

int Sum(int a, int b) {
  return 2 - Prod(2 - a, 2 - b);
}
/*
int Minus[] = {2, 1, 0};

int Prod[][3] = {
  {0, 0, 0},
  {0, 1, 1},
  {0, 1, 2}};

int Sum[][3] = {
  {0, 1, 2},
  {1, 1, 2},
  {2, 2, 2}};
*/
typedef pair<int, int> Res;

Res formula(int i) {
  if (str[i] == '-') {
    Res res = formula(i + 1);
    return Res(Minus(res.first), res.second);
  } else if (str[i] == '(') {
    Res lhs = formula(i + 1);
    i = lhs.second;
    if (str[i] == '+') {
      Res rhs = formula(i + 1);
      assert(str[rhs.second] == ')');
      return Res(Sum(lhs.first, rhs.first), rhs.second + 1);
    } else if (str[i] == '*') {
      Res rhs = formula(i + 1);
      assert(str[rhs.second] == ')');
      return Res(Prod(lhs.first, rhs.first), rhs.second + 1);
    }
    assert(false);
  } else if (str[i] == 'P') {
    return Res(P, i + 1);
  } else if (str[i] == 'Q') {
    return Res(Q, i + 1);
  } else if (str[i] == 'R') {
    return Res(R, i + 1);
  } else if (str[i] == '0') {
    return Res(0, i + 1);
  } else if (str[i] == '1') {
    return Res(1, i + 1);
  } else if (str[i] == '2') {
    return Res(2, i + 1);
  }
  assert(false);
}

void solve() {
  int cnt = 0;
  for (P = 0; P < 3; P++) {
    for (Q = 0; Q < 3; Q++) {
      for (R = 0; R < 3; R++) {
        Res res = formula(0);
        //        assert(res.second == str.size());
        if (res.first == 2) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

int main() {
  while (true) {
    getline(cin, str);
    if (str == ".") {
      return 0;
    }
    solve();
  }
}

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

int main(){
    int a,b,c;
    int d1,d2;
    cin >> a >> b >> c;
    d1 = b-a;
    d2 = c-b;
    if(d1 == d2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
hw=[]
for _ in range(H):
    hw.append(input())

yoko_list=[]
tate_list=[]
for i in range(H):
    for j in range(W):
        if hw[i][j]=="#":
            break
        elif j==W-1:
            yoko_list.append(i)

for i in range(W):
    for j in range(H):
        if hw[j][i]=="#":
            break
        elif j==H-1:
            tate_list.append(i)

for i in range(H):
    if not i in yoko_list:
        p=0
        for j in range(W):
            if not j in tate_list:
                p+=1
                if p==W-len(tate_list):
                    print(hw[i][j])
                else:
                    print(hw[i][j],end="")

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

int main() {

  int N,K;
  int n=1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    if(n*2>n+K){
    	n+=K;
    }else{
    	n*=2;
    }
  }
	cout << n;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, M; cin >> N >> M;
    vector<queue<ll>> vq(N);
    rep(i, N) rep(_, M){
        ll a; cin >> a; a--; vq[i].push(a);
    }
    
    ll ans = N; vb rmv(M, false); ll rcnt = 0;
    while (rcnt < M) {
        vl cnt(M, 0);
        rep(i, N){
            cnt[vq[i].front()]++;
        }
        ll mxi = -1, mx = 0;
        rep(i, M) if(chmax(mx, cnt[i])) mxi = i;
        chmin(ans, mx);
        rmv[mxi] = true;
        rep(i, N){
            while(!vq[i].empty() && rmv[vq[i].front()]) vq[i].pop();
        }
        rcnt++;
    }
    
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 1024
import queue
import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
c=[0]*N#count

to=[[] for i in range(N)]

for i in range(N-1):
    a,b =map(int,input().split())
    a-=1
    b-=1
    to[a].append(b)
    to[b].append(a)
    
    
for i in range(Q):
    p,x =map(int,input().split())
    p-=1
    c[p]+=x
    
q=queue.Queue()
q.put((0,-1))


while not q.empty():
    v,prev=q.get()
    for i in range(len(to[v])):
        v_next=to[v][i]
        if v_next!=prev:
            q.put((v_next,v))
            c[v_next]+=c[v]

        
print(' '.join(map(str, c)))

Measured memory_bytes: 128244
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>



namespace Mylib{
    using namespace std;
    

    void Division(stack<long>& s){
        long tempLong=s.top()/2;
        s.pop();
        s.push(tempLong);
        s.push(tempLong);//ふえる
    
    }
    
    long Attack(stack<long>& s,map<long,long>& m,long enemyHP,long AC){
        AC++;
        
        if(enemyHP==1||enemyHP==0){
            s.pop();
            m[0]=1;
            m[1]=1;
            return 1;
        }
        if(m[enemyHP]!=0){
            s.pop();
            return m[enemyHP];
        }
        Division(s);
        long copy=s.top();
        m[enemyHP]=Attack(s,m,copy,AC)+1;//+Attack(s,m,copy,AC);
        return m[enemyHP]*2-1;

    }
    
    
}



int main(void){
    using namespace std;
    long HP;
    cin >> HP;
    
    long attackCount=0;
    stack<long> sLong;
    sLong.push(HP);    
    map<long,long> llmap;
        attackCount+=Mylib::Attack(sLong,llmap,HP,0);
        
        

    cout << attackCount << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
#define ALL(x) x.begin(), x.end()
#define fir first
#define sec second
using namespace std;

int main()
{
    double ans = 0;
    int n;
    cin >> n;
    rep(i, n)
    {
        double t;
        string s;
        cin >> t >> s;
        if (s == "JPY")
            ans += t;
        else
            ans += 380000.0 * t;
    }
    cout << ans << endl;
    return 0;
}

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

int a[105];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", a + i);

    int sum = 0;
    for (int i = 0; i < n; ++i)
        sum += a[i];
    int ans = 1e9, t = 0;
    for (int i = 0; i < n; ++i)
        if (abs(n * a[i] - sum) < ans)
        {
            ans = abs(n * a[i] - sum);
            t = i;
        }
    printf("%d\n", t);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int now,ans=0;
    bool f;
    char a[10000];
    for(int i=0;i<10000;i++)a[i]='\0';
    while(scanf("%s",a)!=EOF){
        now=0;
        f=true;
        while(a[now]!='\0')now++;
        if(now%2==1){
            now/=2;
            for(int i=1;i<=now&&f;i++){
                if(a[i+now]!=a[now-i])f=false;
            }
            if(f)ans++;
        }
        else{
            now/=2;
            for(int i=0;i<now&&f;i++){
                if(a[now-1-i]!=a[now+i])f=false;
            }
            if(f)ans++;
        }
        for(int i=0;i<10000;i++)a[i]='\0';
    }
    printf("%d\n",ans);
}

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

cost = sorted(list(zip([[2, 5, 5, 4, 5, 6, 3, 7, 6][a-1] for a in A], A)), key=lambda x: (x[0], -x[1]))

# 同じ画数の数字を除く
tmp = len(cost)
i = 1
while i < tmp:
    if cost[i][0] == cost[i-1][0]:
        cost.pop(i)
        tmp = len(cost)
    else:
        i += 1
cost.sort(key=lambda x:-x[1])

# Dynamic Programming
dp = [0] + [-10] * (N)  # dp[n]: n本までマッチ棒を使った場合の最大桁数
for i in range(2, N+1):
    dp[i] = max([-10] + [dp[i-c]+1 for c, _ in cost if i >= c])

n = N
out = ""
i = 0
while n:
    c, a = cost[i]
    if (n >= c) and (dp[n-c] == dp[n] - 1):
        n -= c
        out += str(a)
    else:
        i += 1
print(out)

Measured memory_bytes: 3440
def find(s):
    dic={}
    for i in range(len(s)):
        if s[i] in dic:
            dic[s[i]]+=1
        else:
            dic[s[i]]=1
    if len(dic)==2:
        for x in dic:
            if dic[x]!=2:
                return False
        return True
    else:
        return False
s=input()
if find(s):
    print("Yes")
else:
    print("No")

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
//typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005, LG = 20;
int n, k, a[MX], q;
int pi[MX][LG], pd[MX][LG];
ll si[MX][LG], sd[MX][LG];
int li[MX], ld[MX];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> k;
	forn (i, n) cin >> a[i];

	for (int i = n - 1; i >= 0; i--) {
		int j = lower_bound(a, a + n, a[i] + k) - a;
		
		if (j == n) {
			pi[i][0] = -1;
			li[i] = 0;
		} else {
			pi[i][0] = j;
			li[i] = li[j] + 1;
		}

		si[i][0] = i;
	}

	for (int i = 0; i < n; i++) {
		int j = upper_bound(a, a + n, a[i] - k) - a;
		j--;

		if (j < 0) {
			pd[i][0] = -1;
			ld[i] = 0;
		} else {
			pd[i][0] = j;
			ld[i] = ld[j] + 1;
		}

		sd[i][0] = i;
	}

	for (int j = 1; j < LG; j++)
		forn (i, n) {
			if (pi[i][j - 1] != -1) {
				pi[i][j] = pi[pi[i][j - 1]][j - 1];
				si[i][j] = si[i][j - 1] + si[pi[i][j - 1]][j - 1];
			} else {
				pi[i][j] = -1;
			}

			if (pd[i][j - 1] != -1) {
				pd[i][j] = pd[pd[i][j - 1]][j - 1];
				sd[i][j] = sd[i][j - 1] + sd[pd[i][j - 1]][j - 1];
			} else {
				pd[i][j] = -1;
			}
		}

	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		l--, r--;

		ll sup = 0, to = l, cn = 1;

		for (int j = LG - 1; j >= 0; j--)
			if (pi[to][j] != -1 && pi[to][j] <= r) {
				sup += si[to][j];
				to = pi[to][j];

				cn += 1 << j;
			}

		sup += to;

		ll sdn = 0; to = r;

		for (int j = LG - 1; j >= 0; j--)
			if (pd[to][j] != -1 && pd[to][j] >= l) {
				sdn += sd[to][j];
				to = pd[to][j];
			}

		sdn += to;

		cout << sdn - sup + cn << endl;
	}

	return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> d(2*n); // 0:L, 1:R
	for (int i = 1; i <= s.size(); i++) {
		if (s[2*n-i] == 'W') {
			d[2*n-i] = (i-1)%2;
		}
		else {
			d[2*n-i] = i%2;
		}
	}
	int lc = 0;
	LL ans = 1;
	for (int i = 0; i < s.size(); i++) {
		if (d[i] == 0) {
			lc++;
		}
		else {
			ans *= lc;
			ans %= MOD;
			lc--;
		}
	}
	if (lc != 0) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		ans *= i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1428
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut f: Vec<usize> = vec![0; n + 1];
    for x in 1..=100 {
        for y in 1..=100 {
            for z in 1..=100 {
                let a = x * x + y * y + z * z + x * y + y * z + z * x;
                if a <= n {
                    f[a] += 1;
                }
            }
        }
    }

    let mut result = String::new();
    for i in 1..=n {
        result.push_str(&format!("{}\n", f[i]));
    }
    result.trim().to_string()
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i64 A, B;
    cin >> A >> B;

    i64 sub =  (A > B)? A - B : B - A;
    if (sub % 2 == 0) {
        cout << sub / 2 + min(A, B) << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


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

int main () {
    //int  T; cin >> T;
   // while (T--) {
        string s,s1,s2;
        cin>>s>>s1;
        s2=s1+s;
        cout<<s2<<endl;
    //}
    shesh;
}
/* pray for me
All is well
*/


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    
    if (a>b)
        printf("a > b\n");
    else if (a<b)
        printf("a < b\n");
    else
        printf("a == b\n");
    return 0;
    
}


Measured memory_bytes: 2040
#ifndef ___Rank_Union_Find
#define ___Rank_Union_Find

// ------ Required ------ //
#include <vector>

// ------ Class ------ //
class RankUnionFind {
private:
	int size_; std::vector<int> par, rank;
public:
	RankUnionFind() : size_(0), par(std::vector<int>()), rank(std::vector<int>()) {};
	RankUnionFind(int size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (int i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	int size() { return size_; }
	int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
	bool same(int x, int y) { return root(x) == root(y); }
	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const RankUnionFind &u) { return par == u.par; }
	bool operator!=(const RankUnionFind &u) { return par != u.par; }
};

#endif

#include <cstdio>
#pragma warning(disable : 4996)
int H, W, Q, x, y, v; char s[1007][1007];
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
int main() {
	scanf("%d%d", &W, &H);
	for (int i = 0; i < H; i++) scanf("%s", s[i]);
	RankUnionFind uf(W * H);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == 't') v = i * W + j;
			if (s[i][j] == '#') continue;
			for (int k = 0; k < 2; k++) {
				int tx = j + k, ty = i + 1 - k;
				if (0 <= tx && tx < W && 0 <= ty && ty < H && s[ty][tx] != '#') {
					uf.unite(i * W + j, ty * W + tx);
				}
			}
		}
	}
	scanf("%d", &Q);
	int ret = -1;
	if (uf.same(0, v)) ret = 0;
	else {
		for (int i = 0; i < Q; i++) {
			scanf("%d%d", &x, &y); s[y][x] = '.';
			for (int j = 0; j < 4; j++) {
				int tx = x + dx[j], ty = y + dy[j];
				if (0 <= tx && tx < W && 0 <= ty && ty < H && s[ty][tx] != '#') {
					uf.unite(y * W + x, ty * W + tx);
				}
			}
			if (uf.same(0, v)) {
				ret = i + 1; break;
			}
		}
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 11044
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
print('U' * dy + 'R' * dx + 'D' * dy + 'L' * (dx + 1)
      + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
      + 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin >> n;
    string tmp;
    set<string> s;
    for (int i=0;i<n;i++){
        cin >> tmp;
        s.insert(tmp);
    }
    // for (auto itr = s.begin(); itr != s.end(); ++itr) {
    //     cout << *itr << endl;
    // }
    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 15696
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll sum = 0;
    ll A[N];
    F0R(i, N) {
        cin >> A[i]; sum ^= A[i];
    }

    sum ^= A[0] ^ A[1];
    ll total = A[0] + A[1];

    ll dp[2]; dp[0] = -1e15; dp[1] = 0;
 //   cout << sum << nl;
    F0Rd(bit, 45) {
        if (sum & (1ll << bit)) {

            if (A[0] & (1ll << bit)) {
                dp[0] += (1ll << bit);
                ckmax(dp[0], dp[1]);
                dp[1] += (1ll << bit);
            } else {
                dp[0] += (1ll << bit);
            }
            total -= (1ll << bit);
        } else {
            if (total >= (1ll << (bit+1))) {
                if (!(A[0] & (1ll << bit))) {
                    dp[1] = -1e15;
                }
                dp[0] += (1ll << bit);
                dp[1] += (1ll << bit);
                total -= 1ll << (bit+1);
            } else {
                if (A[0] & (1ll << bit)) {
                    ckmax(dp[0], dp[1]);
                }
            }
        }
//        cout << bit << " " << dp[0] << " " << dp[1] << nl;
    }

    if (total == 0 && (dp[0] > 0 || dp[1] > 0)) {
        cout << A[0]-max(dp[0], dp[1]) << nl;
    } else {
        cout << -1 << nl;
    }


	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3652
N, = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
mxk = 29
msk = (1<<mxk) - 1
msk2 = (1<<(mxk-1))
r = 0
for i in range(mxk):
    # 下からiビット目をみる
    for j in range(N):
        Q[j] = Q[j] & msk
        P[j] = P[j] & msk
    msk >>= 1
    P.sort()
    Q.sort()
    j1 = N-1
    j2 = N-1
    b = 0
    ss = N
#    print(P, Q)
    for l in range(N):
        if P[l] & msk2:
            ss = l
            break
        k1 = msk2 - (P[l]&msk)
        k2 = k1 + msk2
        while j1 >= 0:
            if Q[j1] < k1:
                break
            j1 -= 1
        while j2 >= 0:
            if Q[j2] < k2:
                break
            j2 -= 1
        b += j2 - j1
#        print("a",j2-j1,k1,k2,j1,j2)

    j1 = N-1
    j2 = N-1
#    print(ss)
    for l in range(ss, N):
        k1 = msk2 - (P[l]&msk)
        k2 = k1 + msk2
        while j1 >= 0:
            if Q[j1] < k1:
                break
            j1 -= 1
        while j2 >= 0:
            if Q[j2] < k2:
                break
            j2 -= 1
#        print("b",j1 - j2 + N)
        b += j1 + N - j2

#    b = 0
#    for p in P:
#        if p & msk2:
#            x = g(2*msk2 - (p&msk))
#            z = g(msk2 - (p&msk))
#            b += z+N-x
#        else:
#            x = g(2*msk2 - (p&msk))
#            z = g(msk2 - (p&msk))
#            b += x-z
#    print(b, r, i)
    if b%2:
        r += 1<<(mxk-1-i)
    msk2 >>= 1
print(r)


Measured memory_bytes: 126212
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 200006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define forit(it, A) for(set<ll>::iterator it = A.begin(); it != A.end(); it++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
ld n, t, a, ans=INF, pos;
ld abss(ld y)
{
return (y) > (-y) ? y : (-y);
}
int main()
{
	cin >> n >> t >> a;
	for(ll i = 0; i < n; i++)
	{
		ld x;
		cin >> x;	
		// cout << abs(t - ((long double)x*0.006)) << "\n";
		if(abss(a - (t - ((long double)x*0.006))) < ans)pos = i, ans = abss(a - (t - ((long double)x*0.006)));
	}
	cout << pos+1 << "\n";
}


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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int n,counter=0;
    cin>>n;
    bool ok=true;
    vector<int> p(n);
    int ma1=0,ma2=0,a;
    rep(i,n) cin>>p[i];
    a=p[n-1];
    rep(i,n-1){
        if(a!=p[i]){
            ok=false;
            break;
        }
    }
    if(ok){
        rep(i,n) cout<<p[0]<<endl;
        return 0;
    }
    rep(i,n){
        ma1=max(ma1,p[i]);
    }
    rep(i,n){
        if(p[i]==ma1) counter++;
    }
    rep(i,n){
        if(p[i]==ma1) continue;
        ma2=max(ma2,p[i]);
    }
    if(counter>1){
        rep(i,n) cout<<ma1<<endl;
        return 0;
    }
    rep(i,n){
        if(p[i]==ma1) cout<<ma2<<endl;
        else cout<<ma1<<endl;
    }
    return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
 
int main(){
  int N;
  int i;
  int flag = 0;
  scanf("%d", &N);
  
  for(i = 1; i <= 9; i++){
    if(N%i == 0 && (N/i >=1 && N/i <= 9))
      flag = 1;
  }
  if(flag)
    printf("Yes\n");
  else
    printf("No\n");
}

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

int main()
{
    int32_t A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int32_t ans = INT32_MAX;
    for (int i = 0; i <= 2 * max(X, Y); i += 2)
    {
        int half = i / 2;
        int x = max(X - half, 0);
        int y = max(Y - half, 0);
        ans = min(ans, A * x + B * y + C * i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count = 0

#all(): 全ての要素がTrueならTrue
#any(): 一つでもTrueならTrue
while all(a%2==0 for a in A): 
    A = [a/2 for a in A]
    count += 1
    
print(count)

Measured memory_bytes: 3060
/*
 *
 *    I am o0o0oo00.
 *
 */
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll          long long
#define p7          1000000007
#define p9          998244353
#define pb          push_back
#define ff          first
#define ss          second
#define vll         vector<ll>
#define pll         pair<ll,ll>
#define vpll        vector<pll>
#define mll         map<ll,ll>
#define test        ll T;cin>>T;while(T--)
#define ad(a,n)     vll a;a.resize(n);for(ll i=0;i<n;i++)cin>>a[i];
#define as(a,n)     for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define all(x)      x.begin(),x.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll powm(ll x, ll y, ll m = p7) {
    x = x % m; ll res = 1; while (y)
    {if (y & 1)res = res * x; res %= m; y = y >> 1; x = x * x; x %= m;} return res;
}
ll modi(ll a, ll m = p7) {return powm(a, m - 2, m);}
void yesno(bool f) {f ? cout << "YES" << endl : cout << "NO" << endl;}


void ss99()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}


int32_t main()
{
//   ss99();
//    test
    {
        ll n, m; cin >> n >> m;
        ll dp[n][m];
        string s[n];
        for (ll i = 0; i < n; i++)
            cin >> s[i];
        dp[0][0] = 1;
        for (ll i = 0; i < n; i++)
        {
            for (ll j = 0; j < m; j++)
            {
                if (i == 0 && j == 0)
                    continue;
                if (s[i][j] == '#')
                    dp[i][j] = 0;
                else if (i == 0)
                    dp[i][j] = dp[i][j - 1];
                else if (j == 0)
                    dp[i][j] = dp[i - 1][j];
                else
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % p7;;
            }
        }
        cout << dp[n - 1][m - 1] % p7 << endl;
    }
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mo 1000000007
int h , w; int dp[1009][1009];ll ans ; 

long long int fun(int i , int j,string s[] )
{  
 if(dp[i][j]!=-1)
	return(dp[i][j]);
	
	if(i>=h||j>=w||i<0||j<0||s[i][j]=='#')
	{
		return(dp[i][j]=0); 
	}
	
	
	return(dp[i][j]= (fun(i+1,j,s)+fun(i,j+1,s))%mo);
}


int main()
{
cin>>h>>w; 
string s[h];
for(int i =0 ; i<h ; i++)
cin>>s[i];
memset(dp,-1,sizeof(dp));
ans = 0 ; 
dp[h-1][w-1]= 1; 
cout<<fun(0,0,s);

}


Measured memory_bytes: 5376
def makelst(lst, v):
    for i in range(N):
        if wv[i][0] == v:
            lst.append(wv[i][1])
    lst.sort(reverse=True)

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
v1cnt = W // wv[0][0]
v2cnt = W // (wv[0][0] + 1)
v3cnt = W // (wv[0][0] + 2)
v4cnt = W // (wv[0][0] + 3)
v1, v2, v3, v4 = [], [], [], []
makelst(v1, wv[0][0])
makelst(v2, wv[0][0] + 1)
makelst(v3, wv[0][0] + 2)
makelst(v4, wv[0][0] + 3)

[0] + v1, [0] + v2, [0] + v3, [0] + v4

ans = 0

v1cnt = min(v1cnt, len(v1))
v2cnt = min(v2cnt, len(v2))
v3cnt = min(v3cnt, len(v3))
v4cnt = min(v4cnt, len(v4))
ru1 = [0] * (v1cnt + 1)
ru2 = [0] * (v2cnt + 1)
ru3 = [0] * (v3cnt + 1)
ru4 = [0] * (v4cnt + 1)
for i in range(1, v1cnt + 1):
    ru1[i] = ru1[i - 1] + v1[i - 1]

for i in range(1, v2cnt + 1):
    ru2[i] = ru2[i - 1] + v2[i - 1]

for i in range(1, v3cnt + 1):
    ru3[i] = ru3[i - 1] + v3[i - 1]

for i in range(1, v4cnt + 1):
    ru4[i] = ru4[i - 1] + v4[i - 1]

for i in range(len(ru1)):
    for j in range(len(ru2)):
        for k in range(len(ru3)):
            for l in range(len(ru4)):
                wtmp = (i * wv[0][0]) + (j * (wv[0][0] + 1)) + (k * (wv[0][0] + 2)) + (l * (wv[0][0] + 3))
                if wtmp <= W:
                    ans = max(ans, ru1[i] + ru2[j] + ru3[k] + ru4[l])

print(ans)

Measured memory_bytes: 3316
#include <iostream>
typedef long long ll;
using namespace std;
int main(void){
   ll N, a, n, cnt;
   cnt = 0;
   char c;
   cin >> N;
   while (N--) {
       cin >> a >> c >> n;
       cnt += (c == '(' ? n:-n);
       cout << (cnt == 0 ? "Yes":"No") << endl;
   }
    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int main()
{
    char a,b;
    cin >> a >> b;
    if(a == b)cout << "H" << endl;
    else cout << "D" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	INT a, b, x;

	cin >> a >> b >> x;


	if (2 * x < a * a * b)
	{
		cout << std::setprecision(10) << atanl(a * b * b / (2 * double(x))) * 180.0 / 3.14159265 << endl;
	}
	else
	{
		long double _x = a * a * b - x;
		cout << std::setprecision(10) << atanl(2 * _x / (a * a * a)) * 180.0 / 3.14159265 << endl;
	}
	return 0;
}


Measured memory_bytes: 256