akhauriyash/Code-Regression huggingface dataset:
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#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__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int x;cin>>x;
    int ans = 1;
    rep(b, 2, x+1){
        int v = b*b;
        while(v<=x){
            chmax(ans, v);
            v *= b;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,m,l = input().split()

n = int(n)
m = int(m)
l = int(l)

matrix_A = [[0]*m for i in range(n)]
matrix_B = [[0]*l for j in range(m)]
matrix_C = [[0]*l for k in range(n)]
box_a = []
box_b = []
box_c = 0

for a in range(n):
    
    box_a = input().split()
    
    for b in range(m):
        
        matrix_A[a][b] = int(box_a[b])
        
    
for c in range(m):
    
    box_b = input().split()
    
    for d in range(l):
        
        matrix_B[c][d] = int(box_b[d])
        
            
for e in range(n):
    
    for f in range(l):
        
        for g in range(m):
            box_c += matrix_A[e][g] * matrix_B[g][f]
        
        
        matrix_C[e][f] = box_c
        box_c = 0
    
    print(" ".join(map(str,matrix_C[e])))


Measured memory_bytes: 6896
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        p: [(i64, i64, i64, i64); n],
    }
    let mut x = Vec::with_capacity(2 * n);
    let mut y = Vec::with_capacity(2 * n);
    for p in p.iter() {
        x.push(p.0);
        x.push(p.2);
        y.push(p.1);
        y.push(p.3);
    }
    x.sort();
    x.dedup();
    y.sort();
    y.dedup();
    let mut add = vec![vec![]; x.len()];
    let mut sub = vec![vec![]; x.len()];
    for (a, b, c, d) in p {
        let a = x.binary_search(&a).unwrap();
        let b = y.binary_search(&b).unwrap();
        let c = x.binary_search(&c).unwrap();
        let d = y.binary_search(&d).unwrap();
        add[a].push((b, d));
        sub[c].push((b, d));
    }
    let mut ans = 0;
    let mut dp = vec![0; y.len()];
    for i in 0..(x.len() - 1) {
        let mut imos = vec![0; y.len()];
        for p in add[i].iter() {
            imos[p.0] += 1;
            imos[p.1] -= 1;
        }
        for p in sub[i].iter() {
            imos[p.0] -= 1;
            imos[p.1] += 1;
        }
        for j in 1..y.len() {
            imos[j] += imos[j - 1];
        }
        for (dp, imos) in dp.iter_mut().zip(imos.iter()) {
            *dp += *imos;
        }
        let h = x[i + 1] - x[i];
        for j in 0..(y.len() - 1) {
            if dp[j] > 0 {
                ans += h * (y[j + 1] - y[j]);
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 5060
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int n, head[N], tot, siz[N], dis[N];
struct data{int d, id;}d[N];
struct node{int to, nex;}a[N << 1];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
bool cmp(const data & a, const data & b) {return a.d > b.d;}
void add(int x, int y) {a[++ tot].to = y; a[tot].nex = head[x]; head[x] = tot;}
void dfs(int x, int fa)
{
	for(int i = head[x]; i; i = a[i].nex)
	{
		int y = a[i].to; if(y == fa) continue;
		dis[y] = dis[x] + 1; dfs(y, x);
	}
}
signed main()
{
	n = read();
	for(int i = 1; i <= n; i ++) {d[i] = data{read(), i}; siz[i] = 1;}
	sort(d + 1, d + n + 1, cmp);
	for(int i = 1; i < n; i ++)//<n
	{
		int val = d[i].d - n + 2 * siz[i];
		int l = 1, r = n + 1, pos;//n + 1
		while(l <= r)
		{
			int mid = (l + r) >> 1;
			if(d[mid].d <= val) pos = mid, r = mid - 1;
			else l = mid + 1;
		}
		if(d[pos].d != val) {puts("-1"); return 0;}
		add(d[i].id, d[pos].id); add(d[pos].id, d[i].id); siz[pos] += siz[i];
	}
	dfs(d[n].id, 0); int sum = 0;
	for(int i = 1; i <= n; i ++) sum += dis[i];
	if(sum != d[n].d) puts("-1");
	else {for(int i = 1; i <= tot; i += 2) printf("%lld %lld\n", a[i].to, a[i + 1].to);}
	return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <string>

using namespace std;

int main () {
  double D, T, S;
  cin >> D >> T >> S;

  double reach_time = D/S;
  string ans;
  if(reach_time <= T) {
    ans = "Yes";
  } else {
    ans = "No";
  }

  cout << ans << endl;
}

Measured memory_bytes: 3752
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
A_sorted = sorted(A)


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(2 * N + 1)  # N+1番目が真ん中
target = (N * (N+1) // 2 + 1) // 2

# にぶたん
l, r = -1, 10**9+1

while r - l > 1:
    X = (r + l) // 2
    Binary = [(1 if a > X else -1) for a in A]
    Binary = list(accumulate(Binary))

    BIT.reset()

    inversion = 0

    for j in range(N):
        inversion += BIT.sum(Binary[j] + N + 1) + (Binary[j] >= 0)
        BIT.add(Binary[j] + N + 1, 1)

    if inversion >= target:
        l = X
    else:
        r = X

print(r)


Measured memory_bytes: 121964
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int main() {
	vector<int>v(10);
	iota(v.begin(),v.end(),1);

	vector<vector<int>>anss;
	do {
		vector<vector<int>>field(3,vector<int>(3));
		const int mod=v[9];
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				field[i][j]=v[i*3+j];
			}
		}
		bool ok=true;
		int need=field[0][0]+field[1][1]+field[2][2];
		need%=mod;
		for (int y = 0; y < 3; ++y) {
			int asum=0;
			for (int x = 0; x < 3; ++x) {
				asum+=field[y][x];
			}
			if(asum%mod!=need)ok=false;
		}
		for (int x = 0; x < 3; ++x) {
			int asum=0;
			for (int y = 0; y < 3; ++y) {
				asum+=field[y][x];
			}
			if(asum%mod != need)ok=false;
		}
		for (int i = 0; i < 2; ++i) {
			int asum=0;
			for (int j = 0; j < 3; ++j) {
				asum+=field[j][i?j:2-j];
			}
			if(asum%mod != need)ok=false;
		}
		if (ok) {
			anss.emplace_back(v);
		}
	}while(next_permutation(v.begin(),v.end()));

	while (true){
		vector<int>v(10);
		for(int i=0;i<10;++i)cin>>v[i];
		if(v[0]==-1)break;
		int sum=0;
		for (auto && ans : anss) {
			bool ok=true;
			for (int i = 0; i < 10; ++i) {
				if(v[i]&&v[i]!=ans[i])ok=false;
			}
			if(ok)sum++;
		}
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 28260
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>

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

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

    int ans = 0;
    rep(i, 1, n)
    {
        bool x[300] = {}, y[300] = {};
        rep(j, 0, n)
        {
            if (j < i)
                x[s[j]] = true;
            else
                y[s[j]] = true;
        }
        int cnt = 0;
        for (char c = 'a'; c <= 'z'; c++)
        {
            if (x[c] && y[c])
                cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n=0;
	int m=0;
	int a[60];
	int b[60];
	int c[100000];
	int i=0;
	int ii=0;
	int z=0;
	
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a[i];
		cin>>b[i];
	}
	z=1;
	for(i=0;i<m;i++){
		z=1;
		for(ii=1;ii<n+1;ii++){
			if(a[i]==z){
				c[z]=c[z]+1;
			}
			if(b[i]==z){
				c[z]=c[z]+1;
			}
			z=z+1;
		}
	
	}
	for(z=1;z<n+1;z++){
		cout<<c[z]<<endl;
	}
	
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l;
		double a,b,c,d;
		l=sc.nextInt();
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		d=sc.nextInt();
		if(Math.ceil(a/c)<Math.ceil(b/d)){
			System.out.println((int)(l-Math.ceil(b/d)));
		}else{
			System.out.println((int)(l-Math.ceil(a/c)));
		}
	}
}

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

using namespace std;

int main(){
    int n, t, a, k = 0; cin>>n>>t>>a;
    double m = 1e9;
    for (int i=1; i<=n; ++i){
        double h; cin>>h;
        if ((double)abs(a-(t-h*0.006)) < m){
            m = (double)abs(a-(t-h*0.006));
            k = i;
        }
    }
    cout<<k;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int number = Integer.parseInt(sc.next());
        ArrayList<Integer> arrayList = new ArrayList<>();
        for (int i = 0; i < number; i++) {
            arrayList.add(Integer.parseInt(sc.next()));
        }
        arrayList.sort(Collections.reverseOrder());
        int sum = 0;
        for (int i = 0; i < number; i++) {
            int max = arrayList.remove(0);
            if (i % 2 == 0) {
                sum += max;
            } else {
                sum -= max;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 22100
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

#include <iostream>

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

	if (A >= 13) { cout << B << endl; }
	else if (A >= 6 && A <= 12) { cout << B / 2 << endl; }
	else { cout << 0 << endl; }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);

  string str; 
  cin >> str;
  int size = str.size();

  int first_A;
  for(int i = 0; i < size; i++) {
    if( str[i] ==  'A' ) {
      first_A = i;
      break;
    }
  }

  int last_Z;
  for(int i = size-1; 0 <= i; i--) {
    if( str[i] ==  'Z' ) {
      last_Z = i;
      break;
    }
  }

  cout << last_Z - first_A + 1 << "\n";


  return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n;
    cin>>n;
    map<ll,ll>mp;
    ll a[n];
    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll ans = 0; 
    for(auto it:mp){
        ans += ((it.second)*(it.second-1))/2;
    }
    ll e,p;
    for(int i = 0 ; i < n ; i++){
        e = ans;
        e -= (mp[a[i]]*(mp[a[i]]-1))/2;
        p = mp[a[i]]-1;        
        e += (p*(p-1))/2;
        cout<<e<<endl;
    }
}

Measured memory_bytes: 11008
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;


public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int a = scanner.nextInt();
    final int b = scanner.nextInt();

    if (a > b) {
      for (int i = 0; i < a ;i++) {
        System.out.print(b);
      }
    } else {
      for (int i = 0; i < b; i++) {
        System.out.print(a);
      }
    }
  }
}


Measured memory_bytes: 21844
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    indic = dict()

    for i in range(n):
        a = inlis[i]
        if a in indic:
            indic[a] += 1
        else:
            indic[a] = 1
    indic2 = sorted(indic.items(), key = lambda x:x[0], reverse=True)
    ans1 = 0

    for j in range(n):
        kazu = indic2[j][1]
        nagasa = indic2[j][0]
        if kazu >= 4 and ans1 == 0:
            print(nagasa ** 2)
            exit()
        elif kazu >= 2 and ans1 == 0:
            ans1 = nagasa
        elif kazu >= 2 and ans1 > 0:
            print(ans1 * nagasa)
            exit()
    print(0)
        



if __name__ == "__main__":
    main()

Measured memory_bytes: 101960
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

vec dot(0), ans(10, 0);
map<ll, int> checked;
bool in_grid(ll h, ll w){
    return h >= 3 && h < H - 3 && w >= 3 && w < W - 3;
}
void dfs(ll id){
    ll h = id/W, w = id%W;
    if(!in_grid(h, w) || checked[id] == 1) return;
    checked[id] = 1;
    ll temp = 0, left = id - W - 1;
    rep(i,3){
        temp += lower_bound(ALL(dot), left + 3) - lower_bound(ALL(dot), left);
        left += W;
    }
    ++ans[temp];
    return;
}

int main() {
    cin>>H>>W>>N;
    ll zero = (H - 2) * (W - 2);
    H += 4, W += 4;
    rep(i,N){
        cin>>A>>B;
        A += 1, B += 1;
        dot.push_back(W * A + B);
    }
    sort(ALL(dot));
    rep(i,N){
        rep(j, 3){
            rep(k, 3){
                dfs(dot[i] + W * (j - 1) + (k - 1));
            }
        }
    }
    reps(i,1,10) zero -= ans[i];
    ans[0] = zero;
    rep(i,10) cout<<ans[i]<<endl;
}

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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

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

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define inf ((1LL << 62) - 1 + (1LL << 62))

// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    lint K, N;
    cin >> K >> N;
    vli pos(N);
    rep(i, N) cin >> pos[i];
    pos.push_back(pos[0] + K);
    lint max_dist = 0;
    rep(i, N) chmax(max_dist, pos[i + 1] - pos[i]);
    cou(K - max_dist);

}

Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))

a.sort()
maxa = a.pop(-1)

import bisect
if maxa % 2 == 0:
    i = bisect.bisect_right(a,maxa//2)
    if a[i-1] == maxa//2:
        print(maxa, maxa//2)
    else:
        if i == 0:
            print(maxa, a[0])
        elif i == len(a):
            print(maxa, a[-1])
        else:
            if abs(a[i-1] - maxa//2) < abs(a[i] - maxa//2):
                print(maxa,a[i-1])
            else:
                print(maxa,a[i])
else:
    i = bisect.bisect_right(a,maxa//2)
    if a[i] == maxa//2 + 1:
        print(maxa, a[i])
    elif a[i-1] == maxa//2:
        print(maxa, a[i-1])
    else:
        if i == 0:
            print(maxa,a[0])
        elif i == len(a):
            print(maxa,a[-1])
        else:
            if abs(a[i-1] - maxa//2) < abs(a[i] - maxa//2 + 1):
                print(maxa, a[i-1])
            else:
                print(maxa, a[i])


Measured memory_bytes: 62704
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n;
map<int,int> b;
int ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		b[x]++;
	}
	for(map<int,int>::iterator it=b.begin();it!=b.end();it++)
		ans+=it->second%2;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4992
N, Q = map(int, input().split())
str = input()
length = [list(map(int, input().split())) for _ in range(Q)]

ans = [0 for _ in range(N+1)]
for i in range(1, N):
    if (str[i-1] == "A"):
        if (str[i] == "C"):
            ans[i] = ans[i-1] + 1
        else:
            ans[i] = ans[i-1]
    else:
        ans[i] = ans[i-1]
        ans[i+1] = ans[i-1]
        i += 1

for l1, l2 in length:
    # print(ans)
    print(ans[l2-1] - ans[l1-1])


Measured memory_bytes: 30636
#include <bits/stdc++.h>
using namespace std;
#define MAX_P 200010
typedef long long ll;
const int mod = 1000000007;
ll fact[MAX_P];

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    ll d = a;
    if (b != 0)
    {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d;
}
ll mod_inverse(ll a, ll m)
{
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}
void make_fact()
{
    fact[1] = 1;
    for (ll i = 2; i < MAX_P; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    return;
}
ll mod_fact(ll n, ll p, ll &e)
{
    e = 0;
    if (n == 0)
        return 1;
    ll res = mod_fact(n / p, p, e);
    e += n / p;
    if (n / p % 2 != 0)
        return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}
int mod_comb(int n, int k, int p)
{
    if (n < 0 || k < 0 || n < k)
        return 0;
    ll e1, e2, e3;
    ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
    if (e1 > e2 + e3)
        return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

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

    int n, m;
    cin >> n >> m;
    vector<int> v;
    for (int i = 2; m != 1; i++)
    {
        int cnt = 0;
        while (m % i == 0)
        {
            cnt++;
            m /= i;
        }
        if (cnt != 0)
            v.push_back(cnt);
    }
    make_fact();
    ll ans = 1;
    for (int i = 0; i < v.size(); i++)
    {
        (ans *= mod_comb(v[i] + n - 1, n - 1, mod)) %= mod;
    }
    cout << ans << endl;
}

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

#ifdef _DEBUG
#define debug
#else
#define debug 1 ? 0 : 
#endif

int is_lower(char ascii);
int coprime_alpha(int alpha);
char affine_func(char ascii, int alpha, int beta);
void affine_dec(char *enc_string, char *dec_string, int alpha, int beta);

int main(void)
{
	char enc_input[512];
	char dec_output[512];
	int n, i;
	int a, b;

	scanf("%d", &n);
	scanf("%*c");
	for (i = 0; i < n; i++){
		fgets(enc_input, 512, stdin);
		for (a = 3; a <= 52; a++){
			if (coprime_alpha(a) == 1){
				for (b = 0; b <= 26; b++){
					affine_dec(enc_input, dec_output, a, b);
					if (strstr(dec_output, "this") != NULL || strstr(dec_output, "that") != NULL){
						goto end;
					}
					debug printf(dec_output);
				}
			}
		}
		end:;
		printf("%s", dec_output);
	}

	return (0);
}

int is_lower(char ascii)
{
	if (ascii >= 'a' && ascii <= 'z'){
		return (1);
	}
	else {
		return (0);
	}
}

int coprime_alpha(int alpha)
{
	if (alpha % 2 != 0 && alpha % 13 != 0){
		return (1);
	}
	else {
		return (0);
	}

}

char affine_func(char ascii, int alpha, int beta)
{
	int ret;

	ret = alpha * (ascii - 'a') + beta;
	ret %= 26;

	return ((char)(ret + 'a'));
}

void affine_dec(char *enc_string, char *dec_string, int alpha, int beta)
{
	int i;

	for (i = 0; enc_string[i] != '\0'; i++){
		if (is_lower(enc_string[i]) == 1){
			dec_string[i] = affine_func(enc_string[i], alpha, beta);
		}
		else {
			dec_string[i] = enc_string[i];
		}
	}
	dec_string[i] = '\0';
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

int main() {
        string s;cin>>s;
        vector<pair<ll,char>>v;ll c=1,cc=0;
        for(ll i=1;i<s.size();i++){
            if(s[i]==s[i-1])c++;
            else{
                v.pb({c,s[i-1]});
                c=1;
            }
        }
        v.pb({c,s[s.size()-1]});
        ll ans=0;
        for(ll i=0;i<v.size();i++){
            if(v[i].S=='<' && v[i+1].S=='>'){
                ll mx=max(v[i+1].F,v[i].F);
                ll mn=min(v[i+1].F,v[i].F);
                mn--;
                ans+=((mx*(mx+1))/2);
                ans+=((mn*(mn+1))/2);
                i++;
            }
            else{
                ans+=(v[i].F*(v[i].F+1))/2;
            }
        }
        cout<<ans;
}

Measured memory_bytes: 7032
import sys
from bisect import bisect_right
from collections import defaultdict

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


def solve():
    _ = int(rl())
    A = list(map(int, rl().split()))
    
    pow_of_2 = [1]
    while pow_of_2[-1] < 2 * 10 ** 9:
        pow_of_2.append(pow_of_2[-1] * 2)
    
    A.sort(reverse=True)
    counter = defaultdict(int)
    for ai in A:
        counter[ai] += 1
    
    ans = 0
    for ai in A:
        if counter[ai] == 0:
            continue
        idx = bisect_right(pow_of_2, 2 * ai) - 1
        t = pow_of_2[idx]
        aj = t - ai
        if 1 < counter[aj] or 0 < counter[aj] and ai != aj:
            ans += 1
            counter[ai] -= 1
            counter[aj] -= 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 118860
#include<iostream>
#include<string>
#include<stdio.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>

using namespace std;

int main(){
    int a,b;cin >> a >> b;
    if(a < b)cout << 0 << endl;
    else cout << 10 << endl;
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int n, m; cin >> n >> m;
	cout << (n-1)*(m-1) << endl;


	return 0;

}


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

int main(){
    string s;
    cin>>s;
    int slen=s.length();
    int cnt=0;
    for(int i=0;i<slen;i++)
        if(s[i]=='1')
            cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
int main(){
  using namespace std;
  int a,b,c;
  cin >> a >> b >> c;
  int d = a - b;
  if(d > c){
    cout << 0 << endl;
  }else if(d > 0){
    cout << c - d << endl;
  }else{
    cout << c << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    unsigned long long int a,b,n;
    scanf("%llu %llu %llu",&a, &b,&n);
    unsigned long long int max=0;
    unsigned long long int ans=0;
    if(b<=n)
    {
    ans=((b-1)*a)/b;
    if(ans>max){
    max=ans;
    }
    }
    else{
    ans=((n*a)/b)-a*(n/b);
    if(ans>max){
        max=ans;
                }
        }
        
     printf("%llu",max);
    return 0;
}

Measured memory_bytes: 1732
n, m = map(int, input().split())
h = list(map(int, input().split()))
tree = [1 for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] < h[b]:
        tree[a] = 0
    elif h[b] < h[a]:
        tree[b] = 0
    else:
        tree[a] = 0
        tree[b] = 0
print(sum(tree))

Measured memory_bytes: 19996
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N;
    string S;

    cin >> N;
    cin >> S;

    bool left = false;
    bool right = false;
    int count = 0;
    int max = 0;
    for(int i = 0; i < N ; i++) {
        count = 0;
        for(int alp = 'a'; alp <= 'z'; alp++) {
            left = false;
            right = false;
            for(int j = 0; j < i; j++) {
                if(S[j] == alp) left = true;
            }
            for(int j = i ; j < N; j++) {
                if(S[j] == alp) right = true;
            }
            if(left && right) count += 1;
        }
        if(max <= count) max = count;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>

using namespace std;

int main() {
  long long n, k;
  cin >> n >> k;

  if(!(n % k)){
    cout << 0 << endl;
  }
  else if(n < k){
    if(n > k - n){
      cout << k - n << endl;
    }
    else{
      cout << n << endl;
    }
  }
  else{
    long long s = n / k;

    long long mn = min((n - k*s), (k*(s+1) - n));

    cout << mn << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N, K, T, L;
double U, V;
bool A[105000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K >> T >> U >> V >> L;
    for(int i = 0; i < N; i++) {
        int d;
        cin >> d;
        A[d] = true;
    }
    double ans = 0;
    int Last = -1e9;
    int num = 0;
    for(int i = 0; i < L; i++) {
        if(A[i]) {
            if(num < K) {
                num++;
            } else {
                Last = i;
            }
        }
        if(Last + V * T <= i and num) {
            num--;
            Last = i;
        }
        if(Last + V * T <= i) ans += 1 / U;
        else {
            ans += 1 / V;
        }
    }
    cout << fixed << setprecision(30) << ans << endl;
    return 0;
}


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

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

	vector<int> arr(5);
	for(int i=0; i<5; ++i){
		cin>>arr[i];
	}
	for(int i=0; i<5; ++i){
		if( arr[i] == 0 ){
			cout<<i+1<<'\n';
		}
	}

	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(Math.abs(x - a) < Math.abs(x - b)) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;

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

    scanf("%d",&n);
    while(n--)
    {
        int aim;
        scanf("%d",&aim);
        for(int i=0; i<9; i++)
        {
            if(a[i]==aim)
            {
                a[i]=0;
                break;
            }
        }

    }
    int flag=0;
    for(int i=0; i<3; i++)
    {
        int sum=0;
        sum=a[i]+a[i+3]+a[i+6];
        if(sum==0)
        {
            flag=1;
        }
    }
    for(int i=0; i<7; i+=3)
    {
        int sum=0;
        sum=a[i]+a[i+1]+a[i+2];
        if(sum==0)
        {
            flag=1;
        }
    }
    if(a[0]==0&&a[4]==0&&a[8]==0)
    {
        flag=1;
    }
    if(a[2]==0&&a[4]==0&&a[6]==0)
    {
        flag=1;
    }
    if(flag==0)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <numeric>
#include <cmath>

using namespace std;
using sl = signed long;
using sll = signed long long;
using ll = long long;

// For debug
template <class T> void print_vecotor(vector<T> v){
	for(auto itr=v.begin();itr<v.end();itr++){
		cout << *itr << " ";
	}
}

int main(int argc, char *argv[])
{
	int N;
	int ans = 1;
	string S;
	cin >> N >>S;
	
	for(int i = 1; i<N ; i++){
		if(S[i]!=S[i-1]) ans++;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 512
/*
	设 sum[n][0/1] 表示子树某种颜色权值和 (可以交换)
	sum[u] 肯定有一个是 val[u]
	所以只要让另一个最小就行了
*/
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#define N 1005
#define MAX 5005

using namespace std;

int n;
int deg[N], fa[N];
int val[N], sum[N][2];

bool f[N][2][MAX], beZero[N];

inline void read(int &x) {
	x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}

inline void trans(bool a[2][MAX], int o, int u) {
	int c = sum[u][0];
	for(int i = 5000; i >= c; --i)
		a[1][i] |= a[0][i - c];
	c = sum[u][1];
	if(c <= 5000) {
		for(int i = 5000; i >= c; --i)
			a[1][i] |= a[0][i - c];
	}
	memcpy(a[0], a[1], sizeof a[0]), memset(a[1], 0, sizeof a[1]);
	return;
}
void topo() {
	queue<int> que;
	for(int i = 1; i <= n; ++i)
		if(!deg[i]) {
			que.push(i);
		}
	while(!que.empty()) {
		int u = que.front(); que.pop();
		bool flag = false;
		sum[u][0] = val[u];
		for(int i = val[u]; ~i; --i) {
			if(f[u][0][i]) {
				if(i == 0 && !beZero[u]) break;
				flag = true, sum[u][1] -= i;
				break;
			}
		}
		if(!flag) puts("IMPOSSIBLE"), exit(0);
//		printf("%d : %d %d\n", u, sum[u][0], sum[u][1]);
		int v = fa[u];
		if(sum[u][0] && sum[u][1]) beZero[v] = false;
		sum[v][1] += sum[u][0] + sum[u][1];
		trans(f[v], v, u);
		if(!--deg[v]) que.push(v);
	}
	return;
}

int main() {
	read(n);
	for(int i = 2; i <= n; ++i)
		read(fa[i]), ++deg[fa[i]];
	for(int i = 1; i <= n; ++i) {
		read(val[i]);
		f[i][0][0] = true;
	}
	
	memset(beZero, true, sizeof beZero);
	topo();
	
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 9600
{-# LANGUAGE RecursiveDo        #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE NumericUnderscores #-}

import qualified Data.ByteString.Char8 as C8
import Data.List
import Data.Char

solve :: Int -> Int -> [Int] -> Int
solve _  d2 [_, _   ] = d2
solve d1 d2 [x, y, z] = dn
  where a  = d1 + abs (z - x)
        b  = d2 + abs (z - y)
        dn = min a b
solve d1 d2 (x:y:z:h) = solve d2 dn (y:z:h)
  where a  = d1 + abs (z - x)
        b  = d2 + abs (z - y)
        dn = min a b

main :: IO ()
main = do
  _ <- C8.getLine
  h @ (h0:h1:_) <- unfoldr (C8.readInt . C8.dropWhile isSpace) <$> C8.getLine
  print $ solve 0 (abs (h0 - h1)) h


Measured memory_bytes: 5964
N,K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 1000000007

dp = [[0] * (K+10) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(K,-1,-1):
        dp[i+1][j] += dp[i][j]
        dp[i+1][j] %= MOD
        if j + A[i] + 1 <= K+1:
            dp[i+1][j+A[i]+1] = (dp[i+1][j+A[i]+1] - dp[i][j] + MOD) % MOD
    
    for j in range(K+1):
        dp[i+1][j+1] += dp[i+1][j]
        dp[i+1][j+1] %= MOD

print(dp[N][K])


Measured memory_bytes: 118768
n=int(input())#357の木を作る
a=[]
ans=0

def search(count):
    global ans
    #print(count)
    if int(count)>n:#超えたら終わり
        return 
    #print(set(sorted(list(count))))
    if set(sorted(list(count))) =={"0","3","5","7"}:#lsitにかえてそれをsortしてset型に変える
        ans+=1

    for i in "357":
        search(count+i)


search("0")
print(ans)

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

constexpr auto MAXN = 2000+550;

int num[MAXN]; bool vis[MAXN];
std::vector<int> link[MAXN],G[MAXN];
int inc[MAXN];

void Dfs(const int& nowAt){
	vis[nowAt] = true;
	for(const auto &it : link[nowAt])
		if(!vis[it]){
			G[nowAt].push_back(it);
			inc[it]++;
			Dfs(it);
		}
}

signed main(void)
{
	int totNums;

	scanf("%d", &totNums);
	for(int i=0;i<totNums;i++) scanf("%d", num+i);
	std::sort(num,num+totNums);

	for(int i=0;i<totNums;i++)
		for(int j=i+1;j<totNums;j++)
			if(std::__gcd(num[i],num[j]) > 1){
				link[i].push_back(j); link[j].push_back(i);
			}

	memset(vis,false,sizeof(vis));
	for(int i=0;i<totNums;i++)
		if(!vis[i]) Dfs(i);

	std::priority_queue<int,std::vector<int>,std::less<int>> que;
	for(int i=0;i<totNums;i++)
		if(inc[i] == 0) que.push(i);

	int nowAt;
	while(!que.empty()){
		nowAt = que.top(); que.pop();
		printf("%d ", num[nowAt]);
		for(const auto &it : G[nowAt])
			if(--inc[it] == 0) que.push(it);
	}
	putchar('\n');

	return 0;
}


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

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

    return 0;
}


Measured memory_bytes: 1024
def solve():
  INF = 100000
  while True:
    n = int(input())
    if not n: break
    lst = [int(input()) for _ in range(n)]
  
    def check(x):
      c1 = c2 = lst[x]
      l = r = x
      b = 0
      for i in range(r, n):
        if lst[i] != c2:
          r = i - 1
          break
      else:
        r = n - 1
  
      for i in range(l, -1, -1):
        if lst[i] != c1:
          l = i + 1
          break
      else:
        l = 0
  
      if r - l - b < 3:
        return n
      else:
        b = r - l
  
      while l > 0 and r < n - 1:
        c1 = lst[l - 1]
        c2 = lst[r + 1]
        if c1 != c2:
          break
        else:
          for i in range(r + 1,n):
            if lst[i] != c2:
              r = i - 1
              break
          else:
            r = n - 1
             
          for i in range(l - 1, -1, -1):
            if lst[i] != c1:
              l = i + 1
              break
          else:
            l = 0
  
          if r - l - b < 4:
            break
          else:
            b = r - l
      return n - (b + 1)
  
    ans = INF
    for i in range(n):
      lst[i] = (lst[i] + 1) % 3 + 1
      ans = min(ans, check(i))
      lst[i] = (lst[i] + 1) % 3 + 1
      ans = min(ans, check(i))
      lst[i] = (lst[i] + 1) % 3 + 1
    print(ans)
solve()


Measured memory_bytes: 5736
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int H, W, K; cin >> H >> W >> K;
  vector<string> C(H);
  for (int i = 0; i < H; ++i) cin >> C[i];

  int total = 0;
  for (int h = 0; h < (1 << H); ++h) {
    for (int w = 0; w < (1 << W); ++w) {
      bitset<6> bh(h), bw(w);
      int cnt = 0;
      for (int r = 0; r < H; ++r) {
        for (int c = 0; c < W; ++c) {
          if (!bh.test(r) && !bw.test(c) && C[r][c] == '#') ++cnt;
        }
      }
      if (cnt == K) total++;
    }
  }
  cout << total << endl;
}


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

int32_t main(){
        SKILLER;
  
        cin >> n;
        int amt = 1000, stock = 0;
        int maxt = 1000;
        for(int i = 0; i < n; i++){
            int x; cin >> x;
            v.pb(x);
        }
        int flag = 0;
        for(int i = 0; i < n - 1; i++){
           if(!flag){
                if(v[i] >= v[i + 1])
                    continue;
                else{
                    stock = amt/v[i];
                    amt = amt%v[i];
                    flag = 1;
                }
           }
           else{
                if(v[i] <= v[i + 1])
                    continue;
                else{
                    amt = amt + stock * v[i];
                    stock = 0;
                    flag = 0;
                   // cout << amt <<" ";
                    maxt = max(maxt, amt);
                }
           }
           
        }
        amt += stock * v[n - 1];
           maxt = max(maxt, amt);
           cout << maxt;
        return 0;
}

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

/*
x問で解いたときの最大値をもとめていき、Gと比べる
問題数は最大で100*10問なのでいける
*/

int main() {
    int D, G;
    cin >> D >> G;
    vector<int> P(D), C(D);
    for (int i = 0; i < D; i++)
    {
        cin >> P[i];
        cin >> C[i];
    }

    // int ans = 1e9;
    int res = 1e9;
    for (int tmp = 0; tmp < (1 << D); tmp++)
    {
        int score = 0, num = 0;

        bitset<10> s(tmp);

        // 小さい桁から見ていって、一番点数が大きく、解ききってない問題のidxをrest_maxへ格納
        for (int i = 0; i < D; i++)
        {
            if (s.test(i))
            {
                score += 100 * (i + 1) * P[i] + C[i];
                num += P[i];
            }
        }

        if ( score >= G ) {
            res = min(res, num);
        }
        else {
            for (int i = D-1; i >= 0; i--)
            {
                if (s.test(i))
                    continue;
                
                for (int j = 0; j < P[i]; j++)
                {
                    if (score >= G) break;
                    score += 100 * (i + 1);
                    num++;
                }
            }
            res = min(res, num);
        }
    }
    cout << res << endl;
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

ll p2(ll x) {
    if (x == 1)return 0;
    ll ret = 1LL;
    ll cnt = 0;
    while (ret < x) {
        ret *= 2LL;
        cnt++;
    }
    if (ret == x)return cnt;
    else return cnt - 1;
}

int main() {
    ll a, b, pa, pb;
    cin >> a >> b;
    a--;
    pa = p2(a);
    pb = p2(b);

    map<ll, ll> mp, mp2;
    if(a>=0) {
        for (ll i = pa; i >= 0; i--) {
            ll t = (1LL << (i + 1));
            mp[i] = ((a + 1) / t) * (t / 2) + max(0LL, ((a + 1) % t) - (t / 2));
        }
    }

    for (ll i = pb; i >= 0; i--) {
        ll t = (1LL << (i + 1));
        mp2[i] = ((b+1) / t) * (t / 2) + max(0LL, ((b+1) % t) - (t / 2));
    }

    ll ans = 0LL;
    for (int i = pb; i >= 0; i--) {
        if ((mp2[i] - ((a<0)?0 : mp[i])) % 2 == 1)ans += (1LL << i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin >>a>>b>>c>>d>>e>>k;
  if (e-a>k){
    cout << ":(";
  }
  else{
    cout <<"Yay!";
  }
}

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

string sa,sb,sc;

int main(){
    cin >> sa >> sb >> sc;
    queue<char> qa,qb,qc;
    for(int i=0;i<sa.size();i++)qa.push(sa[i]);
    for(int i=0;i<sb.size();i++)qb.push(sb[i]);
    for(int i=0;i<sc.size();i++)qc.push(sc[i]);

    char tar = qa.front();
    qa.pop();
    while(1){
        if(tar == 'a'){
            if(qa.empty())break;
            tar = qa.front();
            qa.pop();
        }else if(tar == 'b'){
            if(qb.empty())break;
            tar = qb.front();
            qb.pop();
        }else{
            if(qc.empty())break;
            tar = qc.front();
            qc.pop();
        }
    }

    if(tar == 'a')cout << "A" << endl;
    else if(tar == 'b')cout << "B" << endl;
    else cout << "C" << endl;
}

Measured memory_bytes: 256
n = int(input())

tn = n
t = []
for i in range(2, int(n ** 0.5) + 1):
    while n % i == 0:
        n //= i
        t.append(i)

if n != 1:
    t.append(n)

print("{}: {}".format(tn, " ".join(map(str, t))))



Measured memory_bytes: 5640
#include<stdio.h>

int main (void)

{
	char str[20];
	char sstr[20];
	int i;
	int n = 0;
	int j;
	
	printf("");
	scanf("%s", str);
	
	for(i = 0;str[i] != '\0';i++){
		sstr[i] = str[i];
		n++;
	}
	for(j = n -1;j != -1;j--){
		printf("%c", sstr[j]);
	}
	
	printf("\n");
	
	return(0);
}

Measured memory_bytes: 520
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

typedef struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
}Node;

Node *T;

void insert(int);
void print(Node *);
void inorder(Node *);
void preorder(Node *);

int main()
{
  int n,i,k,j;
  char command[10];
  Node *z;

  //T->l=NIL;
  //T->r=NIL;
  
  scanf("%d",&n);
  if(n>500000) exit(1);
  for(i=0;i<n;i++){
      scanf("%s",command);
    if(command[0] == 'i'){
      scanf("%d",&k);
      insert(k);
    }
    else
      print(T);
  }
  return 0;
}

void insert(int k)
{
  Node *x,*y,*z;

  y = NIL; //xの親
  x = T;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l=NIL;
  z->r=NIL;
  
  while(x != NIL){
    y = x; //親を設定
    if(z->key < x->key) x = x->l; //左の子に移動
    else x = x->r; //右の子に移動
  }
  z->p = y;
  
  if(y==NIL) //Tが空の場合
    T = z;
  else if(z->key < y->key)
    y->l = z; //zをyの左の子にする
  else
    y->r = z; //zをyの右の子にする
  //printf(" %d",x->p);
}

void print(Node *root)
{
  if(root==NIL) return;
  
  inorder(root); //左→上→右
  printf("\n");
  preorder(root); //左→右→上
  printf("\n");
}

void inorder(Node *root)
{
  if(root==NIL) return;
  inorder(root->l);
  printf(" %d",root->key);
  inorder(root->r);
}

void preorder(Node *root)
{
  if(root==NIL) return;
  printf(" %d",root->key);
  preorder(root->l);
  preorder(root->r);
}



Measured memory_bytes: 25140
import math
a, b, x = map(int, input().split())

if x == a**2*b:
    print(0)
elif 2*x <= (a**2)*b:
    print(math.degrees(math.atan((b**2)*a/(2*x))))
else :
    print(90-math.degrees(math.atan((a**3)/(2*((a**2)*b-x)))))

Measured memory_bytes: 9332
x=input()
a=x[:2]
b=x[2:]
ans_lst=[]
for y in [a,b]:
	if "00"<y<"13":
		ans_lst.append(True)
	else:ans_lst.append(False)
if all(ans_lst):
    print("AMBIGUOUS")
elif not any(ans_lst):
    print("NA")
elif ans_lst[0] and ans_lst[1]==False:
	print("MMYY")
elif ans_lst[0]==False and ans_lst[1]:
	print("YYMM")


Measured memory_bytes: 3060
def readInt():
    return list(map(int,input().split()))
    
x,y = readInt()
crain = (4*x-y)/2
turtle = (y-2*x)/2
if crain.is_integer() and turtle.is_integer and crain >= 0 and turtle >= 0:
    print('Yes')
else:
    print('No')

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

int main() {
	int n,W;
	cin>>n>>W;
	vector<int> w(n), v(n);
	vector<vector<long long int>> dp(n+1, vector<long long int> (W+1, 0));
	for(int i=0;i<n;i++) {
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=W;j++) {
			if(w[i-1]<=j) {
				dp[i][j] = max(v[i-1] + dp[i-1][j-w[i-1]], dp[i-1][j]);
			} else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout<<dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  } else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256