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

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100000;

bool tag[MAXN + 5]; pii p[2*MAXN + 5]; int N;
int main() {
	ll SA = 0, SB = 0; scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		int A, B; scanf("%d%d", &A, &B);
		SA += A, SB += B;
		p[2*i-1] = make_pair(A, i);
		p[2*i] = make_pair(B, i);
	}
	sort(p + 1, p + 2*N + 1);
	
	ll ans = 0; bool flag = false;
	for(int i=1;i<=N;i++) {
		if( tag[p[i].second] ) flag = true;
		else tag[p[i].second] = true;
		ans += p[i].first;
	}
	if( !flag ) {
		if( p[N].second == p[N + 1].second )
			ans = min(ans - p[N - 1].first + p[N + 1].first, ans - p[N].first + p[N + 2].first);
		else ans = ans - p[N].first + p[N + 1].first;
	}
	
	printf("%lld\n", min(ans, min(SA, SB)));
}

Measured memory_bytes: 2048
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <cmath>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//バブルソートs

int bubbleSort(vector<int> &A, int n)
{
  int cnt = 0;
  bool flag = true;
  while(flag)
  {
    flag = false;
    for(int j = n-1; j >= 1; --j)
    {
      if(A[j] < A[j-1])
      {
        swap(A[j],A[j-1]);
        flag = true;
        ++cnt;
      }
    }
  }
  return cnt;
}

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i = 0; i < n; ++i)
    {
      cin >> a.at(i);
    }

    int res = bubbleSort(a, n);

    for(int i = 0; i < n; ++i)
    {
      cout << a.at(i);
      if(i != n-1)
      {
        cout << " ";
      }
    }
    cout << endl;

    cout << res << endl;
    return 0;    
}



Measured memory_bytes: 3120
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        
        // int k = 50;
        // while (k-- > 0){
        // Random random = new Random();
        // n = random.nextInt(500000);
        // System.out.println(n);
        
        List<Long> list = divisorList(n);
        list.sort(Comparator.reverseOrder());
        
        long ans = 0;
        for (int i = 0; i < list.size()/2; i++) {
            int j = list.size()-1 - i;
            if (list.get(i)-1 == list.get(j)) break;
            ans += list.get(i) - 1;
            // System.out.println(list.get(i)-1);
        }
        // System.out.println(list.size());
        // System.out.println(ans);
        // for (int i = 0; i < list.size(); i++) {
        //     System.out.println(list.get(i));
        // }
        // 21170-1
        // 10585-2
        // 4234-5
        // 2117-10
        // 730-29
        // 365-58
        // 290-73
        // 146-145
        
        // long ansb = 0;
        // for (long i = 1; i <= 500000; i++) {
        //     if (n / i == n % i) {
        //         ansb += i;
        //         System.out.println(i);
        //     }
        // }
        System.out.println(ans);
        
        // if (ans != ansb) {
        //     System.out.println(n + " " + ans + " " + ansb);
        // }
        // }
    }
    
    public static List<Long> divisorList(long n) {
        List<Long> res = new ArrayList<Long>();
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                res.add(i);
                
                long j = n / i;
                if (j != i) {
                    res.add(j);
                }
            }
        }
        res.sort(Comparator.naturalOrder());
        
        return res;
    }
}


Measured memory_bytes: 36700
# coding: utf-8
# Here your code !
 
def func():
    data=[]
    while(True):
        try:
            [height,width] = [ int(item) for item in input().rstrip().split(" ") ]
        except:
            return inputError()
         
        if( (height > 0) and (width > 0) ):
            data.append([height,width])
        elif( (height == 0) and (width == 0) ):
            break
        else:
            return inputError()
    
    result=""
    for item in data:
        [height,width]=item
        for i in range(height):
            if( (i==0) or (i==height-1) ):
                result+="#"*width+"\n"
            elif(width<3):
                result+="#"*width+"\n"
            else:
                result+="#"+"."*(width-2)+"#\n"
        result+="\n"
    
    print(result[:-1])
        
def inputError():
    print("input Error")
    return -1
 
func()

Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
  int a, b;
  cin >> a >> b;
  if(a & 1 && b & 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll x2 = 0;
  rep(i,n) {
    if (i%2) x2 -= a[i];
    else x2 += a[i];
  }
  vector<int> ans(n);
  ans[0] = x2/2;
  rep(i,n-1) {
    ans[i+1] = a[i]-ans[i];
  }
  rep(i,n) ans[i] *= 2;
  rep(i,n) printf("%d%c", ans[i], i==n-1?'\n':' ');
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  ll k;
  cin>>k;
  vector<ll> vec;
  vec.push_back(1);
  for(int i=1;i<k;i++){
    ll j=0;
    for(;j<vec.size();j++){
      if(vec[j]==9) continue;
      if(j<vec.size()-1&&vec[j+1]-vec[j]>-1) break;
      if(j==vec.size()-1&&vec[j]<9) break;
    }
    if(j==vec.size()){
      vec.push_back(1);
      for(int k=0;k<j;k++) vec[k]=0;
    }
    else{
      vec[j]++;
      for(int k=j-1;k>=0;k--) vec[k]=max((ll)0,vec[k+1]-1);
    }
  }
  for(int i=vec.size()-1;i>=0;i--) cout<<vec[i];
  cout<<endl;
}


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

import sys

def solve(pair):
    frm, to = pair[0], pair[1]
    ans = filter(is_uruu, range(frm, to + 1))
    if not ans:
        return "NA\n"
    else:
        return "\n".join(map(str, ans)) + "\n"
    
def is_uruu(n):
    return (n % 400 == 0) or ((not n % 100 == 0) and (n % 4 == 0))

if __name__ == "__main__":
    lst = []
    while True:
        line = sys.stdin.readline()
        frm, to = tuple(map(int, line.strip().split(" ")))
        if frm == 0 and to == 0:
            break
        lst.append((frm, to))
    print "\n".join(map(solve, lst)),

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

typedef pair<int, int> pi;

int N;
vector<pi> P;
vector<bool> B;

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

	cin >> N;
	P.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> P[i].first;
		P[i].second = i;
	}

	sort(P.begin(), P.end());
	int id_med = (N + 1) / 2 - 1;
	int med_l = P[id_med].first;
	int med_r = P[id_med + 1].first;
	B.resize(N, false);
	for (int i = 0; i <= id_med; ++i)
		B[P[i].second] = true;

	for (int i = 0; i < N; ++i) {
		int ans = B[i] ? med_r : med_l;
		cout << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 3840
def main():
    INF = float("inf")

    N, M, *ABC = map(int, open(0).read().split())

    D = [0] + [INF] * (N - 1)
    E = tuple((a - 1, b - 1, -c) for a, b, c in zip(*[iter(ABC)] * 3))

    for a, b, c in E:
        D[b] = min(D[b], D[a] + c)

    ans = D[-1]

    for a, b, c in E:
        D[b] = min(D[b], D[a] + c)

    print("inf" if ans != D[-1] else -ans)

main()


Measured memory_bytes: 3572
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        s: usize
    }
    let mut ans = vec![s; n];
    if s == 1000000000 {
        for i in k..n {
            ans[i] = 1;
        }
    } else {
        for i in k..n {
            ans[i] = s + 1;
        }
    }
    for i in 0..n - 1 {
        print!("{} ", ans[i]);
    }
    println!("{}", ans[n - 1]);
}


Measured memory_bytes: 5372
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    std::string s;
    std::cin >> s;
    bool flag = false;
    int q;
    std::cin >> q;
    std::string pre, af;
    while(q--) {
        int t;
        std::cin >> t;
        if(t == 1) {
            flag = !flag;
        } else {
            int f;
            std::string c;
            std::cin >> f >> c;
            if(!flag) {
                if(f == 1) {
                    pre += c;
                } else {
                    af += c;
                }
            } else {
                if(f == 2) {
                    pre += c;
                } else {
                    af += c;
                }
            }
        }
    }
    if(flag) {
        std::reverse(s.begin(), s.end());
        std::reverse(af.begin(), af.end());
        std::cout << af << s << pre << std::endl;
    } else {
        std::reverse(pre.begin(), pre.end());
        std::cout << pre << s << af << std::endl;
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

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

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

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> p(M);
	vector<string> s(M);
	for (int i = 0; i < M; ++i) {
		cin >> p[i] >> s[i];
	}

	vector<bool> ac(N + 1, false);
	vector<int> wa(N + 1, 0);
	for (int i = 0; i < M; ++i) {
		if (ac[p[i]]) { continue; }
		
		if (s[i] == "AC") {
			ac[p[i]] = true;
		} else {
			++wa[p[i]];
		}
	}

	int AC = 0, WA = 0;
	for (int i = 1; i <= N; ++i) {
		if (!ac[i]) { continue; }
		++AC;
		WA += wa[i];
	}
	cout << AC << " " << WA << endl;

	return 0;
}


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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    if (N % 2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }

    vector<char> temp(N / 2);
    vector<char> remain(N / 2);
    int i, j;
    for (i = 0, j = 0; i < N / 2; i++, j++)
    {
        temp.at(j) = S.at(i);
    }
    for (j = 0; i < N; i++, j++)
    {
        remain.at(j) = S.at(i);
    }

    if (temp == remain)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    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 m=0;
    int f=0;
    int r=0;
    for(int i=0;i<50;i++){
      m=sc.nextInt();
      f=sc.nextInt();
      r=sc.nextInt();
      char grade;
      if(m==-1 && f==-1 && r==-1) break;
      else if(m==-1 || f==-1 || m+f<30) grade='F';
      else if(m+f<50 && r<50) grade='D';
      else if(m+f<65) grade='C';
      else if(m+f<80) grade='B';
      else grade='A';
      System.out.println(grade);
    }
  }
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    int maxh = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
        maxh = max(maxh, h[i]);
    }
    for (int i = 0; i < 101; i++)
    {
        for (int j = 0; j < 101; j++)
        {
            for (int H = maxh; H < maxh + 201; H++)
            {
                bool ans = true;
                for (int k = 0; k < n; k++)
                {
                    if (h[k] != max(H - abs(i - x[k]) - abs(j - y[k]), 0))
                    {
                        ans = false;
                    }
                }
                if (!ans)
                    continue;
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int W;
  cin >> W;
  long long int A[W], INF = 100000000000LL;
  for(int i = 0; i < W; ++i)
    cin >> A[i];
  
  vector<int> E;
  for(int i = 0; i < W; ++i){
    if(!A[i]) E.push_back(i);
  }

  int N = (int)E.size();
  long long int s, t;
  vector<long long int> ans(W,0LL);
  for(int i = 1; i < N; ++i){
    s = E[i-1], t = INF;
    for(int j = E[i-1]+1; j < E[i]; ++j){
      if(A[j] < 0){
	if(-A[j]-s+(long long int)j < t){
	  t = -A[j];
	  s = j;
	}
      }else{
	ans[j] = max(ans[j],min(A[j],t-j+s));
      }
    }
  }

  for(int i = N-2; i >= 0; --i){
    s = E[i+1], t = INF;
    for(int j = E[i+1]-1; j > E[i]; --j){
      if(A[j] < 0){
	if(-A[j]+s-j < t){
	  t = -A[j];
	  s = j;
	}
      }else{
	ans[j] = max(ans[j],min(A[j],t+j-s));
      }
    }
  }
  if(N){
    s = E[N-1]+1;
    t = INF;
    for(int i = E[N-1]+1; i < W; ++i){
      if(A[i] < 0){
	if(-A[i]-s+i < t){
	  //cout << s << " " << t << endl;
	  t = -A[i];
	  s = i;
	}
      }else{
	ans[i] = max(ans[i],min(A[i],t-i+s));
      }
    }
    s = E[0]-1;
    t = INF;
    for(int i = E[0]-1; i >= 0; --i){
      if(A[i] < 0){
	if(-A[i]+s-i < t){
	  //cout << s << " " << t << endl;
	  t = -A[i];
	  s = i;
	}
      }else{
	ans[i] = max(ans[i],min(A[i],t+i-s));
      }
    }
  }
  long long int sum = 0LL; 

  for(int i = 0; i < W; ++i){
    sum += (long long int)ans[i];
    //cout << ans[i] << " ";
  }
  //cout << endl;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4900
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        v_s: [String; n],
    }
    let v_s: Vec<String> = v_s;

    let mut hs: HashMap<String, usize> = HashMap::new();

    for s in v_s {
        let e = hs.entry(s).or_insert(0);
        *e += 1;
    }

    for &s in ["AC", "WA", "TLE", "RE"].into_iter() {
        let v = hs.get(s).unwrap_or(&0);
        println!("{} x {}", s, v)
    }



}


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

int main() {
  int n, a;
  cin >> n;
  vector<int> vec(n);
  
  for (int i = 0; i < n; i++) {
    cin >> a;
    a--;
    vec.at(i) = a;
  }
  int now = 0, c = 0;
  while (1) {
    if (now == 1) break;
    if(c >= n) {
      c = -1;
      break;
    }
    c++;
    now = vec[now];
  }
  cout << c << endl;
}


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

int x[50005];
int cur[50005];
int len;
int n, k;
bool can(int mid){
	if(mid == len) return 1;
	memset(cur, 0, sizeof(cur));
	cur[0] = 1;
	for(int i = 0; i < len; i ++){
		if(i == mid) continue;
		for(int s = k; s >= 0 ; s --){
			if(!cur[s]) continue;
			if(s + x[i] <= k) cur[s + x[i]] = 1;
		}
	}
	for(int s = k - x[mid]; s < k; s ++) if(cur[s]) return 1;
	return 0;
}

int main(){
	len = -1;
	cin >> n >> k;
	for(int i = 0; i < n; i ++) cin >> x[i];
	sort(x, x + n);
	for(int i = 0; i < n; i ++){
		if(x[i] >= k){
			len = i;
			break;
		}
	}
	if(len == -1) len = n;
	if(len == 0){
		cout << 0 << '\n';
		return 0;
	}
	int st = 0, en = len, mid;
	while(st < en){
		mid = (st + en) / 2;
		if(can(mid)) en = mid;
		else st = mid + 1;
	}
	cout << en << '\n';
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
	scanf("%d%d",&n,&k);
	int z=n*(n-1)/2-k;
	if(z<n-1){
		puts("-1");
		return 0;
	}
	printf("%d\n",z);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			if(!z)return 0;
			printf("%d %d\n",i,j);
			z--; 
		}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> dp(N + 1);
    dp[0] = 1000;
    // dp[i]:=i日目に得られる最大の利益
    for(int i = 0; i < N; i++) {
        dp[i + 1] = dp[i];
        for(int j = 0; j < i; j++) {
            ll num = dp[j] / A[j];
            ll tmp = dp[j] % A[j] + A[i] * num;
            dp[i + 1] = max(dp[i + 1], tmp);
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n;
map<string,int> m;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=0;i<n;i++){
        string s;
        cin>>s;
        m[s]++;
    }
    int maxi=0;
    for (auto i:m){
        maxi=max(maxi,i.second);
    }
    for (auto i:m){
        if (i.second==maxi){
            cout<<i.first<<'\n';
        }
    }
}

Measured memory_bytes: 23808
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define vint vector<int>


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i,n) cin >> a[i];
	
	int mx=0;
	REP(i,n){
		mx = max(mx,a[i]);
	}
	int digit = 32;
	
	vint sum(digit,0);
	REP(i,n){
		REP(j,digit){
			if(a[i] & (1<<j)) sum[j]++;
		}
	}
	
	vector<int> ans(n,0);
	REP(i,n){
		REP(j,digit){
			if(sum[j]%2==0){
				if(a[i] & (1<<j)){
					ans[i] |= (1<<j);
				}
			}else{
				if(!(a[i] & (1<<j))){
					ans[i] |= (1<<j);
				}
			}
		}
	}
	
	REP(i,n) cout << ans[i] << " ";
	cout << endl;
 	
	
	return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <map>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

int arr[300000];
int maxlen[300000];
const int N = 300000;  // limit for array size
int t[4 * N + 1];

void buildTree(int* tree, int index, int s, int e)
{
	//base case
	if (s > e)
		return;
	//reached leaf node
	if (s == e)
	{
		tree[index] = 0;
		return;
	}
	//now build the segment tree in bottom up manner
	int m = (s + e) / 2;
	buildTree(tree, 2 * index, s, m);
	buildTree(tree, 2 * index + 1, m + 1, e);
	tree[index] = max(tree[2 * index], tree[2 * index + 1]);
	return;
}

//function to query the segment tree for RMQ
int query(int* tree, int index, int s, int e, int qs, int qe)
{
	//base case: if query range is outside the node range
	if (qs > e || s > qe)
		return INT_MIN;
	//complete overlap
	if (s >= qs && e <= qe)
		return tree[index];
	//now partial overlap case is executed
	int m = (s + e) / 2;
	int left_ans = query(tree, 2 * index, s, m, qs, qe);
	int right_ans = query(tree, 2 * index + 1, m + 1, e, qs, qe);
	return max(left_ans, right_ans);
}

//function to update a value at position to "pos"
void updateNode(int* tree, int index, int s, int e, int pos, int val)
{
	if (pos<s || pos>e)
		return;
	if (s == e)
	{
		tree[index] = val;
		return;
	}
	int m = (s + e) / 2;
	updateNode(tree, 2 * index, s, m, pos, val);
	updateNode(tree, 2 * index + 1, m + 1, e, pos, val);
	tree[index] = max(tree[2 * index], tree[2 * index + 1]);
	return;
}

int main() {
	int result = 0;
	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	int s = 0, e = 300000;
	buildTree(t, 1, 0, 300000);

	for (int i = 0; i < n; i++)
	{
		int a = arr[i];

		// a가 마지막
		// - activelast 에서 제일 긴거 탐색, 뒤에 이어 붙인다?
		/*for (int j = 0; j < i; j++)
		{
			if (abs(arr[j] - arr[i]) <= k)
			{
				maxlen[i] = max(maxlen[i], maxlen[j] + 1);
			}
		}
		
		// a가 처음임
		maxlen[i] = max(maxlen[i], 1);
		result  = max(result, maxlen[i]);*/

		int maxim = max(query(t, 1, s, e, a-k, a+k), 0);
		updateNode(t, 1, s, e, a, maxim + 1);

		maxlen[i] = maxim + 1;
		result = max(result, maxlen[i]);
	}

	//debug
	/*for (int i = 0; i < n; i++)
	{
		cout << maxlen[i] << ' ';
	}
	cout << endl;*/

	cout << result << endl;
}

Measured memory_bytes: 10016
#include <iostream>
#include <string.h> 
using namespace std;

int main()
{
    int num,h,i;
	string str,end="-";
	string left;
	string right;
	
	while(1)
	{
		cin>>str;
		if(str==end)break;
		cin>>num;
		for(i=0;i<num;i++){
			cin>>h;
			left = str.substr(0, h);
			right = str.substr(h);
			str = right + left;
			
		}
		cout<<str<<endl;
	}
    return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A & 1 || B & 1 || C & 1) {
		cout << 0 << endl;
		return 0;
	}
	if (A == B && B == C && A == C) {
		cout << -1 << endl;
		return 0;
	}
	int cnt = 0;
	int a = A, b = B, c = C;
	while (1) {
		if (a & 1 || b & 1 || c & 1) {
			cout << cnt << endl;
			return 0;
		}
		int na = b / 2 + c / 2;
		int nb = a / 2 + c / 2;
		int nc = a / 2 + b / 2;
		a = na, b = nb, c = nc;
		cnt++;
	}
}

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

#define int long long


using namespace std;








signed main(){
    int N;
    cin >> N;
    int A[N];
    int mx = 0, mx2 = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] > mx){
            mx2 = mx;
            mx = A[i];
        }else if(A[i]==mx){
            mx2 = A[i]; 
        }else if(A[i] > mx2){
            mx2 = A[i];
        }
    }

    for(int i=0;i<N;i++){
        if(A[i] == mx){
            cout << mx2 << endl;
        }else{
            cout << mx << endl;
        }
    }
}

Measured memory_bytes: 3200
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, W = ni()
    val (w, v) = na2(N)
    val V = v.max * N
    val INF = 1e9.toInt + 10
    val dp = Array.fill[Long](2, V + 1)(INF)
    dp(0)(0) = 0
    REP(N) { i =>
      import java.util
      val x = i % 2
      util.Arrays.fill(dp(x^1), INF)
      REP(V + 1) { j =>
        dp(x^1)(j) = min(dp(x^1)(j), dp(x)(j))
        if (j + v(i) <= V) dp(x^1)(j + v(i)) = min(dp(x^1)(j + v(i)), dp(x)(j) + w(i))
      }
    }
    val ans = dp(N % 2).zipWithIndex.filter(_._1 <= W).map(_._2).max
    out.println(ans)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 38944
#include <cstdio>
using namespace std;
int n;
double memo[305][305][305];
int f1,f2,f3;
double dp(int i,int j,int k){
    if (!(i|j|k)) return 0;
    else if (memo[i][j][k]!=0) return memo[i][j][k];
    int num=i+j+k;
    double ans=0;
    if (i) ans+=(dp(i-1,j,k))*i/num;
    if (j) ans+=(dp(i+1,j-1,k))*j/num;
    if (k) ans+=(dp(i,j+1,k-1))*k/num;
    return memo[i][j][k]=ans+ (double)n/(num);
}
int main(){
    scanf("%d",&n);
    int t;
    for (int x=0;x<n;x++){
        scanf("%d",&t);
        if (t==1) f1++;
        else if (t==2) f2++;
        else f3++;
    }
    printf("%.8f\n",dp(f1,f2,f3));
}


Measured memory_bytes: 219264
S = input()
Q = int(input())

jun = True
head = ""

for _ in range(Q):
    T = input().split()
    if T[0] == "1":
        jun = not jun
    
    else:

        if (T[1] == "1" and jun) or (T[1] == "2" and not jun):
            head += T[2]
            continue

        else:
            S += T[2]

if jun:
    print(head[::-1] + S)
else:
    print(S[::-1] + head)

Measured memory_bytes: 4468
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))
 
#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("WA.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
using namespace std;
const LL inf = 1e9;

const LL lim = 1010;
LL dp[lim][lim];
LL c[lim], t[lim];
LL N,T;

LL F( LL pos, LL rem ){
    if(rem<0) return inf;
    if(pos == 0){
        if( rem == T ) return inf;
        else return 0;
    }
    LL &ret = dp[pos][rem];
    if(ret!=-1) return ret;
    ret = min( F(pos-1, rem) , c[pos] + F(pos-1,rem-t[pos]) );
    return ret;
}


int main(){
    SET(dp);
    
    SL(N); SL(T);
    FOR(i,1,N) SL(c[i]), SL(t[i]);
    LL ans = F(N,T);
    if(ans>=inf) cout<<"TLE"<<endl;
    else cout<<ans<<endl; 
return 0;}

Measured memory_bytes: 8192
target=int(input())

if target<13:
    print(target)
    exit()

cnt=9

result={}
for i in range(10):
    result[i]=[[i],[],[],[],[],[],[],[],[],[],[],[],[],[]]

for j in range(20):
    temp=[]
    for i in [1,2,3,4,5,6,7,8,9]:
        for k in result[i-1][j]:
            result[i][j+1].append(str(i)+str(k))
            cnt+=1
            if cnt==target:
                print(str(i)+str(k))
                exit()
        for k in result[i][j]:
            result[i][j+1].append(str(i)+str(k))
            cnt+=1
            if cnt==target:
                print(int(str(i)+str(k)))
                exit()
        if i!=9:                
            for k in result[i+1][j]:
                result[i][j+1].append((str(i)+str(k)))
                cnt+=1
                if cnt==target:
                    print(int(str(i)+str(k)))
                    exit()
    for item in result[0][j]:
        result[0][j+1].append(str(0)+str(item))
        #print(str(0)+str(k))
    for item in result[1][j]:
        result[0][j+1].append(str(0)+str(item))

print(result[0])

        









Measured memory_bytes: 46428
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
sys.setrecursionlimit(200000)
class uf:
    def __init__(self,n):
        self.n=n
        self.l=[-1]*n
    def ro(self,n):         #root
        if self.l[n]<0:
            return n
        r=self.ro(self.l[n])
        self.l[n]=r
        return r
    def me(self,a,b):       #merge
        ra=self.ro(a)
        rb=self.ro(b)
        if self.l[ra]>self.l[rb]:
            ra,rb=rb,ra
        if ra!=rb:
            self.l[ra]+=self.l[rb]
            self.l[rb]=ra
    def size(self,n):
        return -self.l[self.ro(n)]
    def sa(self,a,b):       #same
        return self.ro(a)==self.ro(b)
    def rl(self):           #roots list
        return [i for i,v in enumerate(self.l) if v<0]
    
    def len(self):          #len(roots)
        return len(self.rl())
    def ul(self):
        d={n:i for i,n in enumerate(self.rl())}
        m=[[]for i in range(self.len())]
        for i in range(self.n):
            m[d[self.ro(i)]].append(i)
        return m
    def __str__(self):
        return f"{self.ul()}"
    def __setitem__(self,i,v):
        self.l[i]=v
u=uf(N)
for i in range(M):
    u.me(*map(lambda x: int(x)-1,input().split()))
print(u.len()-1)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int yukichi = 1e4;
const int inazo = 5 * 1e3;
const int natsume = 1e3;

int main() {
  int n, y;
  cin >> n >> y;

  for (int i = 0; i <= n; ++i) {
    for (int j = 0; i + j <= n; ++j) {
      if (i * yukichi + j * inazo + (n - i - j) * natsume == y) {
        cout << i << " " << j << " " << n - i - j << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}


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

int n;
string s;

int main(void){
	cin >> n;
	unordered_map<string, int> mp;
	int maxv = 0;
	rep(i, n){
		cin >> s;
		maxv = max(maxv, ++mp[s]);
	}
	priority_queue<string, vector<string>, greater<string>> q;
	for(auto i : mp){
		if(i.second == maxv) q.push(i.first);
	}
	while(!q.empty()){
		cout << q.top() << endl;
		q.pop();
	}
	return 0;
}


Measured memory_bytes: 27072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

template <int mod>
struct Modular {
	int val;
	Modular(int new_val = 0) {
	    val = new_val;
	}
	Modular operator +(const Modular& ot) const {
		if (val + ot.val >= mod) return val + ot.val - mod;
		else return val + ot.val;
	}
	Modular operator -(const Modular& ot) const {
		if (val - ot.val < 0) return val - ot.val + mod;
		else return val - ot.val;
	}
	Modular operator *(const Modular& ot) const {
		return 1ll * val * ot.val % mod;
	}
	Modular& operator ++() {
        if (val + 1 == mod) return 0;
        else return val + 1;
	}
	Modular operator ++(int) {
		Modular tmp(*this);
		operator ++();
		return tmp;
	}
	void operator +=(const Modular& ot) {
		val += ot.val;
		if (val >= mod) {
			val -= mod;
		}
	}
	void operator -=(const Modular& ot) {
		val -= ot.val;
		if (val < 0) {
			val += mod;
		}
	}
	void operator *=(const Modular& ot) {
		val = 1ll * val * ot.val % mod;
	}
	bool operator ==(const Modular& ot) const {
		return val == ot.val;
	}
	bool operator !=(const Modular& ot) const {
		return val != ot.val;
	}
};

template <int mod>
ostream& operator <<(ostream& ostr, const Modular<mod>& x) {
	return ostr << x.val;
}

const int mod = 1000000007;
using Mint = Modular<mod>;

Mint binpow(Mint a, int n) {
    Mint res = 1;
    while (n) {
        if (n & 1) res *= a;
        a *= a;
        n >>= 1;
    }
    return res;
}

const int N = 400 + 10;
int lef[N], rig[N];
Mint dp[N][N];
Mint pref[N][N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, c;
    cin >> n >> c;
    for (int i = 1; i <= n; i++) {
        cin >> lef[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> rig[i];
    }
    for (int k = 0; k <= N - 1; k++) {
        for (int i = 1; i <= N - 1; i++) {
            pref[i][k] = pref[i - 1][k] + binpow(i, k);
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= c; j++) {
            for (int k = 0; k <= j; k++) {
                dp[i][j] += dp[i - 1][j - k] * (pref[rig[i]][k] - pref[lef[i] - 1][k]);
            }
        }
    }
    cout << dp[n][c] << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 10;

int N, M;
int S[MAX], C[MAX];

ll solve() {
    if (N == 1) {
        REP (ans, 10) {
            bool check = true;
            REP (i, M) if (C[i] != ans) check = false;
            if (check) return ans;
        }
        return -1;
    }
    REP (i, M) if (S[i] == 1 && C[i] == 0) return -1;
    vi num(N, -1);
    REP (i, M) {
        if (num[S[i]-1] != -1 && num[S[i]-1] != C[i]) return -1;
        num[S[i]-1] = C[i];
    }
    if (num[0] <= 0) num[0] = 1;
    ll ans = 0;
    REP (i, N) {
        if (num[i] == -1) num[i] = 0;
        ans = ans * 10 + num[i];
    }
    return ans;
}

int main() {
    cin >> N >> M;
    REP (i, M) cin >> S[i] >> C[i];
    cout << solve() << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	sum := 0.0
	for i := 0; i < n; i++ {
		x, u := nextFloat64(), next()
		if u == "BTC" {
			x *= 380000.0
		}
		sum += x
	}

	fmt.Println(sum)
}


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

using namespace std;

int n;
string s;
unordered_map<string, int> mp;
string str[4] = {"AC", "WA", "TLE", "RE"};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n + 1; ++i) 
	{
		getline(cin, s);
		mp[s] ++;
	}
	
	for (auto i : str)
	{
		cout << i << " x " << mp[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;



int main() {
	int n;
	string s;

	cin >> n >>  s;

	char prev = ' ';

	int ans = 0;

	for (char c : s) {
		if (prev == ' ') {
			prev = c;
		} else if (prev == 'O' && c == 'X') {
			prev = ' ';
			ans++;
		} else if (prev == 'X' && c == 'O') {
			prev = ' ';
			ans++; 
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
const ll MOD=1000000007;



int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ta,ao;
    ta=(c-1)/b+1;
    ao=(a-1)/d+1;
    if(ta<=ao){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
constexpr int MOD = 1e9 + 7;
//} END

//階乗計算 a^n mod
int mod_pow(int x, int n, int mod) {
  int res = 1;
  while (n > 0) {  //最下位ビットが立っている時にx^(2^i)を掛ける
    if (n & 1) res = res * x % mod;
    x = x * x % mod;  // xを順次二乗していく
    n >>= 1;          // nを1ビット右へ
  }
  return res;
}

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int m, n;
  cin >> m >> n;

  cout << mod_pow(m, n, mod1) << '\n';
  return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
using namespace std;
const int maxn = 110;
const int maxw = 100100;
ll n, w;
ll weight[maxn], value[maxn];
ll dp[maxw];

int main() {
	cin>>n>>w;
	for(int i=1;i<=n;i++) {
		cin>>weight[i]>>value[i];
		
		for(int j=w;j>=1;j--) {
			if(j - weight[i] >= 0)
				dp[j] = max(dp[j], dp[j-weight[i]] + value[i]);
		}
	}
	cout<<dp[w]<<"\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	int n,a[102],b[102],j=0;
	bool pd = true;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0) {  b[j++]=a[i]; }
	}
	for (int i = 0; i < j; i++)
	{
		if (b[i] % 3 != 0 && b[i] % 5 != 0) { cout << "DENIED" << '\n'; pd = false; break; }
	}
	if(pd) { cout << "APPROVED" << '\n'; }

}


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

int main(){
    string s = "";
    cin >> s;
    bool ans = true;
    if(s[0] != 'A'){
        ans = false;
    }
    bool found = false;
    for(int q = 2; q < s.size() - 1; q++){
        if(s[q] == 'C') found  = true;
    }
    int amount = 0;
    for(int z = 0; z < s.size(); z++){
        if(isupper(s[z])){
            amount++;
        }
    }

    if(ans && found && amount < 3){
        cout << "AC\n";
    }else{
        cout << "WA\n";
    }
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int a, b;
	cin >> a >> b;
	cout << (a * b) / __gcd(a, b) << en;


	return 0;
}



Measured memory_bytes: 3652
#include<limits.h>
#include<iostream>
#include<vector>
using namespace std;
vector<int> coin;

int get_change(int num) {
	vector<int> ret(num + 1, 0);
	vector<int> r(num + 1, 0);
	for (int i = 1; i <= num; i++) {
		int q = INT_MAX;
		for (int j = 0; j < coin.size(); j++) {
			if (i >= coin[j]) {
				if (q > 1 + r[i - coin[j]]) {
					q = q < (1 + r[i - coin[j]]) ? q : (1 + r[i - coin[j]]);
					ret[i] = j;
				}
			}
		}
		r[i] = q;
	}
	return r[num];
}

int main() {
	int num;
	int m;
	cin >> num >> m;
	for (int i = 0; i<m; i++) {
		int tmp;
		cin >> tmp;
		coin.push_back(tmp);
	}
	int ans;
	ans = get_change(num);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
int main(){
        int n,k;
        cin>>n>>k;
        vector<int> h(n),dp(n,inf);
        for(int i=0;i<n;i++)cin>>h[i];
        dp[0] = 0;
        for(int i=1;i<n;i++)
                for(int j=1;j<=k&&i-j>=0;j++){
                dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]) );
        }
        cout<< dp[n-1]<<endl;


        return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111

typedef long long ll;
typedef long double ld;

int main(){
	string str;
	cin >> str;
	if(str.find("AC") != -1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl; 
	
	return 0;
}

Measured memory_bytes: 256