akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string l = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
int mod = a.length();

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

    map<char, int> m;
    map<int,char> f;
    for (char c : a) {
        m[c] = m.size();
        f[m[c]] = c;
    }

    //for (auto s : f) cout << s.first << " : " << s.second << endl;
    string ans;
    for (char ch : S) {
        int p = (m[ch] + n)-1;
        ans += l[p];
    }
    cout << ans << endl;
    return 0;
}


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


template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

map<ll, bool> mp;

int main() {
    ll s;
    cin >> s;
    mp[s] = true;
    int i=1;
    while (true) {
        if (s%2) s = 3*s+1;
        else s /= 2;
        ++i;
        if (mp.count(s)>0) {
            cout << i << endl;
            return 0;
        }
        mp[s]=true;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

double calc(vector<double> v){
   double mean = 0.0;
   double sum  = 0.0;
   for(auto it : v) sum += it;
   mean = sum / (int)v.size(); 
   double ret = 0.0;
   for(auto it : v) ret += (it - mean) * (it - mean);	
   ret /= ((int)v.size());
   ret = sqrt(ret);
   return ret;
}

void solve(){
	cout << fixed;
	cout << setprecision(10);
	int n;
	while(cin >> n && n > 0){
	  vector<double> v;
	  for(int i = 0; i < n; i++){
		  double x;
		  cin >> x;
		  v.push_back(x);  
		}
	 double val = calc(v);
	 cout << val << endl;		
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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

int main() {
  string o, e, ans;
  cin >> o >> e;
  for (int i=0; i<e.size(); i++) ans = ans + o.at(i) + e.at(i);
  if (o.size() - e.size() == 1) ans = ans + o.at(o.size() - 1);
  cout << ans << endl;
}

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

int A[20+1];
int n;

bool solve(int i, int m)
{
    // solve(i, m) 用第i个元素后面的元素可以得出m时返回true
    if (m == 0)
        return true;
    if (i >= n)
        return false;
    return solve(i+1, m) || solve(i+1, m -A[i]);
}
int main()
{
    int i, q, k;
    bool res;
    //ifstream cin("in.txt");
    // ofstream cout("out.txt");

    cin >> n;
    for (i = 0; i < n; i++)
        cin >> A[i];
    cin >> q;
    for (i = 0; i < q; i++)
    {
        cin >> k;
        res = solve(0, k);
        if (res)
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class FModularness {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int k, q; cin >> k >> q;
      vector<int> d(k);
      rep(i, k) {
        cin >> d[i];
      }
      while(q--) {
        int n, x, m;
        cin >> n >> x >> m;
        n--;
        x %= m;

        ll sum = 0;
        ll zeros = 0;
        rep(i, k) {
          sum += (d[i]%m);
          if (d[i]%m == 0) zeros++;
        }
        int lo = n / k;
        sum *= lo;
        sum += x;
        zeros *= lo;

        ll ans = (n/k*k) - zeros - (sum/m);
        x = sum%m;

        int before = x;
        int s = n%k;
        for (int i = 0; i < s; i++) {
          int after = (before + d[i]) % m;
          if (before < after) ans++;
          before = after;
        }

        cout << ans << endl;
      }


    }
};

signed main() {
  FModularness solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 384
n, k, q = map(int, input().split())
users = {i + 1: 0 for i in range(n)}
for i in range(q):
    a = int(input())
    users[a] += 1

output = []
for user in users.values():
    if k - q + user > 0: output.append("Yes")
    else: output.append("No")
print(*output, sep="\n")



Measured memory_bytes: 19540
#include <iostream>
#include<algorithm>

#define MOD 1000000007

using namespace std;

int a[100010];

int main()
{
	int n, b, flag = 0;
	long long res=1;
	int i,j=0;
	cin >> n;
	
	for (i = 0; i < n; i++)cin >> a[i];
	
	sort(a,a+n);

	if (n % 2 != 0 && a[0] == 0) {
		b = 0;
		for (i = 0; i < n; i++) {
			if (a[i] != b) { flag = 1; break; }
			if (i % 2 == 0 && i != n - 1) {
				b += 2;
				res *= 2;
				res %= MOD;

			}
		}
	}else{
		b = 1;
		for (i = 0; i < n; i++) {
			if (a[i] != b) { flag = 1; break; }
			if (i % 2 != 0) {
				b += 2;
				res *= 2;
				res %= MOD;
			}
		}
	 }
	if (flag)cout << 0 << endl;
	else cout << res << endl;
	return 0;
}

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

int main(){
  int N,sum=0;
  cin >> N;
  vector<int> A(N+2,0);
  for(int i=1;i<=N;i++){
    cin >> A[i];
  }
  for(int i=0;i<=N;i++){
    sum += abs(A[i]-A[i+1]);
  }
  for(int i=1;i<=N;i++){
    int b = abs(A[i-1]-A[i])+abs(A[i]-A[i+1])-abs(A[i-1]-A[i+1]);
    cout << sum - b << endl;
  }
}

Measured memory_bytes: 1664
#include <cstdio>
#include <algorithm>
using namespace std;

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 * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

const int N = 1e5 + 10;
int a[N];

int main() {
	int n = read();
	for (int i = 0; i < n; i++) a[i] = read();
	sort(a, a + n);
	printf("%d\n", a[n / 2] - a[n / 2 - 1]);
	return 0;
}

Measured memory_bytes: 512
MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '500
  0 933 743 262 529 700 508 752 256 256 119 711 351 843 705 108 393 330 366 169 932 917 847 972 868 980 223 549 592 164 169 551 427 190 624 635 920 944 310 862 484 363 301 710 236 876 431 929 397 675 491 190 344 134 425 629 30 727 126 743 334 104 760 749 620 256 932 572 613 490 509 119 405 695 49 327 719 497 824 596 649 356 184 93 245 7 306 509 754 352 665 783 738 801 690 330 337 195 656 963 11 427 42 106 968 212 1 510 480 658 571 331 814 847 564 197 625 438 931 18 487 151 187 913 179 995 750 750 913 562 134 273 547 521 830 140 557 678 726 503 597 408 893 988 238 85 93 188 720 211 746 387 710 209 887 668 103 473 900 674 105 183 952 370 787 302 410 905 110 400 996 142 585 860 47 924 731 158 386 219 400 415 55 682 874 61 6 602 268 365 470 518 723 89 106 319 130 655 732 993 974 595 810 673 55 730 95 245 705 694 948 873 353 474 760 741 756 644 143 640 737 679 135 149 529 210 607 417 255 787 373 626 445 112 172 595 153 53 183 717 655 17 176 77 776 399 654 728 2 161 455 870 316 694 381 930 480 604 386 359 207 954 79 702 365 453 732 836 432 563 17 107 583 910 467 116 546 719 528 71 107 256 520 353 528 154 430 477 48 520 204 414 810 719 925 298 131 701 709 751 22 817 652 924 695 471 153 625 978 616 142 597 88 732 917 404 743 395 749 407 936 302 767 45 563 340 398 896 51 807 767 997 978 650 809 330 360 716 161 293 209 753 98 130 634 543 889 88 31 692 401 674 294 693 165 949 765 737 458 841 48 943 229 215 389 209 388 754 243 501 271 516 564 277 912 5 611 212 782 92 123 201 324 4 437 602 804 363 391 273 575 906 759 626 896 859 763 358 577 484 747 156 948 605 454 194 359 430 323 883 24 447 202 847 876 49 792 588 304 133 558 842 414 567 728 506 391 0 992 118 398 718 868 975 579 119 363 596 379 916 466 840 232 430 414 155 571 311 179 796 300 216 903 993 55 728 481 905 29 37 897 286 657 377 682 554 506 757 529 580 641 866 852 933 660 490 616 732 606 114 185 647 227 435 58 183 110 742 374 604 671 872 605 480 671 979 717 481 680 791
  30
  0 9 18 30 31 42 48 49 59 74 85 115 121 153 165 168 181 195 205 207 220 228 248 252 255 270 274 289 291 300
  '.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

n = line[0].to_i
arr1 = line[1].split.map(&:to_i)
m = line[2].to_i
arr2 = line[3].split.map(&:to_i)

cnt=0
(0...m).each do |i|
  (0...n).each do |k|

    if arr2[i]==arr1[k]
      cnt += 1
      break
    end
  end
end
puts cnt

Measured memory_bytes: 9008
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	if b-a == c-b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int r, D, i;
    long long x;
    
    scanf("%d %d %lld", &r, &D, &x);
    
    for(i = 1; i <= 10; i++){
        x = r * x - D;
        printf("%lld\n", x);
    }
    
}


Measured memory_bytes: 1708
n, m = map(int, input().split())
f = [i for i in range(n + 1)]
def getF(u):
    i = u
    while f[i] != i:
        i = f[i]
    j = u
    while f[j] != j:
        oj = j
        j = f[j]
        f[oj] = i
    return i
def uniF(u, v):
    u = getF(u)
    v = getF(v)
    if u != v:
        f[u] = v
for i in range(m):
    u, v = map(int, input().split())
    uniF(u, v)
c = [0] * (n + 1)
for i in range(1, n + 1):
    c[getF(i)] += 1
print(max(c))

Measured memory_bytes: 86988
use std::io::Read;
use std::collections::HashMap;

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

    let answer = solve(&buf);

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

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

    let s = iterator.next().unwrap();

    if s == "zyxwvutsrqponmlkjihgfedcba" {
        return "-1".to_string();
    }

    let alphabets: Vec<char> = "abcdefghijklmnopqrstuvwxyz".chars().collect();

    let mut counts: HashMap<char, usize> = HashMap::new();
    for c in s.chars() {
        *counts.entry(c).or_insert(0) += 1;
    }

    if s.len() < 26 {
        let mut next_c = ' ';
        for alphabet in alphabets {
            if !counts.contains_key(&alphabet) {
                next_c = alphabet;
                break;
            }
        }
        return format!("{}{}", s, next_c);
    }

    let s_chars: Vec<char> = s.chars().collect();
    let mut position = 0;
    for i in (1..26).rev() {
        let ca = s_chars[i - 1];
        let cb = s_chars[i];
        let ca_idx = alphabets.iter().position(|it| *it == ca).unwrap();
        let cb_idx = alphabets.iter().position(|it| *it == cb).unwrap();
        if ca_idx > cb_idx {
            continue;
        } else {
            position = i;
            break;
        }
    }

    let part1 = &s[..(position - 1)];

    let q = *&s[..(position)].chars().last().unwrap();

    let mut others: Vec<char> = (&s[position..]).chars().collect();
    others.sort();

    let mut next_c = ' ';
    for c in others {
        let q_idx = alphabets.iter().position(|it| *it == q).unwrap();
        let c_idx = alphabets.iter().position(|it| *it == c).unwrap();
        if q_idx < c_idx {
            next_c = c;
            break;
        }
    }

    return format!("{}{}", part1, next_c);
}


Measured memory_bytes: 4352
h,w = map(int,input().split())
ls = []
side = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
for i in range(h):
  ls.append(list(input()))
for i in range(h):
  ans2 = ""
  for j in range(w):
    ans = 0
    if ls[i][j] == "#":
      ans2 += "#"
    else:
      for k in range(8):
        if i+side[k][0] < 0 or j+side[k][1] < 0 or h <=i+side[k][0] or w <= j+side[k][1]:
          continue
        else:
          ans += (1 if ls[i+side[k][0]][j+side[k][1]] == "#" else 0)
      ans2 += str(ans)
  print(ans2)


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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int a;
    int y, z;
    y = 0; z = 0;
    for (int i = 0; i < m; i++) {
        cin >> a;
        if (a < x) y++;
        else z++;
    }
    cout << min(y, z) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int N,A;
    cin>>N>>A;
    cout<<N*N-A<<endl;

    return 0;
}


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

int main()
{

    int n,l,i,j;
    scanf("%d %d",&n,&l);
        char str1[n][l+1];
    for(i=0;i<n;i++)
    {
        scanf("%s",&str1[i]);

    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(strcmp (str1[i],str1[j])>0)
            {
                char str2[l+1];
                strcpy(str2,str1[i]);
                strcpy(str1[i],str1[j]);
                strcpy(str1[j],str2);

            }
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%s",str1[i]);
    }

    return 0;
}



Measured memory_bytes: 1724
#include <iostream>
using namespace std;

int main(){
    int N, Q;
    string S;
    cin >> N >> Q;
    cin >> S;
    int l_list[100010] = {0};
    int r_list[100010] = {0};
    for(int i=0; i<Q; i++){
        cin >> l_list[i];
        cin >> r_list[i];
    }
    long long dp[100010] = {0};
    for(int i=1; i<N; i++){
        dp[i] = dp[i-1];
        if(S.substr(i-1, 2) == "AC"){
            dp[i] += 1;
        }
    }
    int l, r;

    for(int i=0; i<Q; i++){
        l = l_list[i]-1;
        r = r_list[i]-1;
        if(l < 0){
            cout << dp[r] << '\n';
        }else{
            cout << dp[r] - dp[l] << '\n';
        }
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 105;
int a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

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

    vector<int> ans;

    while (n > 0) {
        int x = -1;
        for (int i = n; i > 0; i--) {
            if (a[i] == i) {
                x = i;
                break;
            }
        }
        if (x == -1) {
            cout << -1;
            return 0;
        }
        for (int i = x; i < n; i++) {
            swap(a[i], a[i + 1]);
        }
        n--;
        ans.push_back(x);
    }

    reverse(all(ans));
    
    for (int x : ans)
        cout << x << "\n";



 
    return 0;
}

Measured memory_bytes: 256
use proconio::*;

const MAX: usize = 1 << 18;

struct Solver {
    item: Vec<(u32, usize)>,
    query: Vec<Vec<(usize, usize)>>,
    ans: Vec<u32>,
}

impl Solver {
    fn dfs1(&mut self, v: usize, mut dp: Vec<u32>) {
        let (a, b) = self.item[v];
        for i in (b..dp.len()).rev() {
            dp[i] = std::cmp::max(dp[i], dp[i - b] + a)
        }
        for &(w, k) in self.query[v].iter() {
            self.ans[k] = dp[w];
        }
        if 2 * v >= (1 << 9) {
            self.dfs2(2 * v, &dp, vec![(0, 0)]);
            self.dfs2(2 * v + 1, &dp, vec![(0, 0)]);
        } else {
            self.dfs1(2 * v, dp.clone());
            self.dfs1(2 * v + 1, dp);
        }
    }
    fn dfs2(&mut self, v: usize, dp: &[u32], mut p: Vec<(u32, usize)>) {
        let (a, b) = self.item[v];
        for i in 0..p.len() {
            let (x, y) = p[i];
            p.push((x + a, y + b));
        }
        for &(w, k) in self.query[v].iter() {
            let mut ans = 0;
            for &(a, b) in p.iter().filter(|p| p.1 <= w) {
                ans = std::cmp::max(ans, a + dp[w - b]);
            }
            self.ans[k] = ans;
        }
        if v >= MAX / 2 {
            return;
        } else {
            self.dfs2(2 * v, dp, p.clone());
            self.dfs2(2 * v + 1, dp, p);
        }
    }
}

#[fastout]
fn run() {
    input! {
        n: usize,
        mut item: [(u32, usize); n],
        q: usize,
        ask: [(usize, usize); q],
    }
    while item.len() < MAX {
        item.push((0, 0));
    }
    item.insert(0, (0, 0));
    let mut query = vec![vec![]; MAX + 1];
    for (i, &(v, w)) in ask.iter().enumerate() {
        query[v].push((w, i));
    }
    let mut solver = Solver {
        item: item,
        query: query,
        ans: vec![0; q],
    };
    solver.dfs1(1, vec![0; 100000 + 1]);
    for a in solver.ans {
        println!("{}", a);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 24836
#include <stdio.h>
int main()
{

    int d, t, s;
    scanf("%d %d %d", &d, &t, &s);
    double min = (double)d / s;
    if (min <= t)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    vector<int> a(3);
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
ll c,d,e,f,p,t,x,y,ans=0;


string s;

void input(void){
    cin>>s;
}

ll solve(void){
    rep(i,s.length()){
      if((i%2==0&&s[i]=='L')||(i%2==1&&s[i]=='R')){
        cout<<"No"<<endl;
        return 0;
         }
         }
         cout<<"Yes"<<endl;
    return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  long INF = Long.MAX_VALUE;
  long[][] dp;

  public static void main(String[] args) {
    new Main().solve();
  }

  void solve() {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    System.out.println(N*A < B ? N*A: B);
  }
}


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

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

  // ここにプログラムを追記
  string a;
  
  for(int i=0;i<N;i++){
    string op;
    cin>>op;
    
    if(op=="Y"){
      a="Four";
      break;
    }
    
    else{
      a="Three";
    }
    
  }
  
  cout << a <<endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    T = readline().decode('utf-8').strip()
    ans = T.replace('?','D')
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9316
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	

	multiset<long long,greater<long long>> L;
	multiset<long long> R;
	long long l=0,r=0;
	long long mid=0;
	long long ans=0;
	long long Q;
	cin>>Q;
	Q--;
	long long c;;
	cin>>c;
	cin>>mid>>ans;	
	while(Q--)
	{
		
		cin>>c;
		if(c==1)
		{
			long long a,b;
			cin>>a>>b;
			ans=ans+b;
			if(a>mid)
			{
				R.insert(a);
				r=r+a;
				if(L.size()+1!=R.size() && L.size()!=R.size())
				{
					auto it=R.begin();
					r=r-(*it);
					L.insert(mid);
					l=l+mid;
					mid=(*it);
					R.erase(it);
				}
			}
			else
			{
				L.insert(a);
				l=l+a;
				if(L.size()+1!=R.size() && L.size()!=R.size())
				{
					auto it=L.begin();
					l=l-(*it);
					R.insert(mid);
					r=r+mid;
					mid=(*it);
					L.erase(it);
				}
			}
		}
		else
		{
			long long a1=r-(R.size())*mid+(L.size())*mid-l+ans;
			cout<<mid<<" "<<a1<<endl;
		}
	}
	

	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(void) {
  int N, B[3];
  cin >> N >> B[0] >> B[1] >> B[2];
  vector <int>l(N);
  for  (int i = 0; i < N; i++) cin >> l[i];

  unsigned int total_cost = 3000; //temp max
  for (unsigned int i = 0; i < pow(4, N);  i++) {
    vector <unsigned int> usage(N); // 0:not use, 1:for A, 2: for B, 3: for C
    unsigned int wk = i;
    unsigned int not_bamboo_check = 0x0;
    for (int j = 0; j < N; j++) {
      usage[j] = wk & 0x3;
      wk >>= 2;
      not_bamboo_check |= (1 << usage[j]);
    }
    // A, B, Cそれぞれについて。最低1つは竹材が欲しい
    if ((not_bamboo_check&0xE) != 0x0E) continue;

    unsigned int cost = 0;
    for (int k = 0; k < 3; k++) { // for A, B, C
      int bamboo_len = 0;
      for (int j = 0; j < N; j++) {
        if (usage[j]==(k+1)) {
          if (bamboo_len) {cost += 10;} // 2本以上結合する場合、MP10
          bamboo_len += l[j];
        }
      }
      cost += abs(bamboo_len - B[k]);
    }
    total_cost = min(total_cost, cost);
  }
  cout << total_cost << endl;
  return 0;
}


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

using ll = long long int;

int n;
string str;

map<pair<string, string>, ll> cnt;

ll ans;

int main(void){
  scanf("%d", &n);
  cin >> str;

  for (int i = 0; i < (1 << n); ++i) {
    string s1, s2;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) s1.push_back(str[j]);
      else s2.push_back(str[j]);
    }
    cnt[make_pair(s1, s2)] += 1;
  }

  reverse(str.begin(), str.end());


  for (int i = 0; i < (1 << n); ++i) {
    string s1, s2;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) s1.push_back(str[j]);
      else s2.push_back(str[j]);
    }
    ans += cnt[make_pair(s1, s2)];
  }

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 91904
#include <iostream>
using namespace std;


int main() {
  int a, b;
  int ans = 0;
  int num = 1;
  cin >> a >> b;
  if (a == b) {
    for (int i=0; i < b; i++) {
      ans += b * num;
      num *= 10;
    }
  }
  else if (a > b) {
    for (int i=0; i < a; i++) {
    ans += b * num;
    num *= 10;
    }
  }
  else {
    for (int i=0; i < b; i++) {
      ans += a * num;
      num *= 10;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace content4
{
    class Program
    {
        static void Main(string[] args)
        {
            //連立方程式を解く
            //ax + by = c
            //dx + ey = f
            while (true)
            {
                //空白で分割する
                var line_origin = Console.ReadLine();

                if (string.IsNullOrEmpty(line_origin))
                {
                    break;
                }
                var line = line_origin.Split();
                //配列の要素、すべてに処理を行う
                var num_array = Array.ConvertAll(line, len => int.Parse(len));

                double a = num_array[0];
                double b = num_array[1];
                double c = num_array[2];
                double d = num_array[3];
                double e = num_array[4];
                double f = num_array[5];

                double x = (b * f - c * e) / (b * d - a * e);
                double y = (c * d - a * f) / (b * d - a * e);

                x = Math.Round(x * 1000, MidpointRounding.AwayFromZero) / 1000;
                y = Math.Round(y * 1000, MidpointRounding.AwayFromZero) / 1000;
                Console.WriteLine("{0:0.000} {1:0.000}", x.ToString("0.000"), y.ToString("0.000"));
            }
                //            Console.ReadKey();
        }
    }
}

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

int n;
string s;

bool is_substr(string s, string t){
  if(s.size() < t.size()) return false;
  int j = 0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == t.at(j)) j++;
    if(j == t.size()) return true;
  }
  return false;
}

string fill_str(int n, char c, string s){
  string res = "";
  rep(i, n - s.size()) res.push_back(c);
  res += s;
  return res;
}

int main(){
  cin >> n >> s;
  long long res = 0;
  for(int i = 0; i < 1000; i++){
    string t = fill_str(3, '0', to_string(i));
    if(is_substr(s, t)) res++;
  }
  cout << res << endl;  
}


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

int main()
{
    char c;
    cin >> c;

    cout << (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ? "vowel" : "consonant") << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let s:Vec<usize> = (0..n).map(|_| read()).collect();
    let q:usize = read();
    let t:Vec<usize> = (0..q).map(|_| read()).collect();
    let mut ans = 0;
    for i in t {
        ans += binary_search(&s, i);
    }
    println!("{}", ans);
}

fn binary_search(a: & Vec<usize>, key:usize) -> i32 {
    let mut ng = -1;
    let mut ok = a.len() as i32;
    while (ok - ng).abs() >1 {
        let mid = (ok + ng) / 2;
        if a[mid as usize] == key {
            return 1
        }
        if is_ok(&a, mid as usize, key) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    0
}

fn is_ok(a: &Vec<usize>, index: usize, key:usize) -> bool {
    if a[index] >= key {
        true
    } else {
        false
    }
}


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

int main(){
  int n, k; cin >> n >> k;
  int A[n+10];
  vector<int> d(n+1);
  for (int i=0; i<n; i++){
    cin >> A[i];
  }
  for (int i=0; i<n; i++){
    d[A[i]]++;
  }
  int ans =0;
  sort(d.begin()+1, d.end());

  for (auto itr=d.begin()+1; itr!=d.begin()+n-k+1; itr++){
    ans += *itr;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N;
	cin >> N;
	vi A(N+1);
	vi B(N);
	for(int i=0; i<A.size(); i++){
		cin >> A[i];
	}
	for(int i=0; i<B.size(); i++){
		cin >> B[i];
	}

	ll ans=0;
	for(int i=0; i<N; i++){
		if(B[i]>A[i]){
			ans+=A[i];
			B[i]-=A[i];
			if(B[i]<=A[i+1]){
				ans+=B[i];
				A[i+1]-=B[i];
			}else{
				ans+=A[i+1];
				A[i+1]=0;
			}
		}else{
			ans+=B[i];
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

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

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

const int MOD = 1e9 + 7;

int main(){

	int n;
	cin >> n;
	string s;
	cin >> s;
	
	vector<vector<ll>> dp(n+1, vector<ll>(n));
	rep(j,n) dp[1][j] = 1;
	
	for(int i = 2; i <= n; i++){
		vector<ll> cumsum(n);
		cumsum[0] = dp[i-1][0];
		rep(j,n-1) cumsum[j+1] = ( cumsum[j] + dp[i-1][j+1] ) % MOD;
		
		for(int j = 0; j <= n-i; j++){
			if(s[i-2] == '>'){
				dp[i][j] = cumsum[ max(0,j) ];
			}
			else{
				dp[i][j] = ( cumsum[ max(j+1,n-i+1) ] - cumsum[j] + MOD ) % MOD;
			}
		}
	}
	
	cout << dp[n][0] << endl;
	
	return 0;
}

Measured memory_bytes: 70784
/* 2020/03/17 Atcoder Beginner Contest 122 B - 105 */

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

bool acgt(char a) {
    if(a=='A' || a=='C' || a=='G' || a=='T') {
        return true;
    } else {
        return false;
    }
}
int main() {
    string s;
    cin >> s;
    int ans = 0, count = 0;
    for(int i=0; i<s.length(); i++) {
        if(acgt(s.at(i))) {
            count++;
            ans = max(ans, count);
        } else {
            count=0;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  ll a[60];
  ll b[60];
  ll c[60];
  ll d[60];
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];
  rep(i,n) {
    ll way = 1e20;
    int ans = 0;
    rep(j,m) {
      ll manhattan = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (manhattan < way) {
        way = manhattan;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
}

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

const long long MOD = 1000000007;

vector<pair<ll, ll>> prime_factorize(ll N) {
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; a++) {
        if (N % a != 0) {
            continue;
        }
        ll ex = 0;

        while (N % a == 0) {
            ex++;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) {
        res.push_back({N, 1});
    }
    return res;
}
void solve(long long N) {
    if (N == 1) {
        cout << 1 << endl;
        return;
    }
    map<ll, ll> merge;
    for (ll i = 2; i <= N; i++) {
        vector<pair<ll, ll>> res = prime_factorize(i);
        rep(j, res.size()) { merge[res[j].first] += res[j].second; }
    }
    ll ans = 1;
    for (map<ll, ll>::iterator i = merge.begin(); i != merge.end(); i++) {
        ans *= (i->second + 1);
        ans %= MOD;
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

mn = min(l)
mx = max(l)

ms = 10**9
ll = [0]*n
for j in range(mn, mx+1):
    for i in range(n):
        ll[i] = (l[i]-j)**2
        
    s = sum(ll)
    ms = min(ms, s)
    
print(ms)

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

int main() {
    long a, b;
    cin >> a >> b;

    long ans = 0;
    for (long i = 0; i < 2; i++) {
        if (a > b) {
            ans += a;
            a--;
        }
        else {
            ans += b;
            b--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		a, _ := strconv.Atoi(buf[0])
		b, _ := strconv.Atoi(buf[1])
		if a == 0 && b == 0 {
			break
		}
		if a < b {
			a, b = b, a
		}
		cnt := 0
		for b != 0 {
			a = a%b
			a, b = b, a
			cnt++
		}
		fmt.Println(a, cnt)
	}
}


Measured memory_bytes: 1160
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/
Solved on 2019/2/
@author: shinjisu
"""


# ARC 062 C AtCoDeer and Rock-Paper
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def probC():
    S = input()
    dmp(S)
    GU = 'g'
    PA = 'p'
    guCount = 0
    paCount = 0
    point = 0
    allTe = ''
    for i in range(len(S)):
        if S[i] == GU:
            if paCount < guCount:
                te = PA
                paCount += 1
            else:
                te = GU
                guCount += 1
        else:
            if paCount < guCount:
                te = PA
                paCount += 1
            else:
                te = GU
                guCount += 1
        if te == GU and S[i]== PA:
            point -= 1
        elif te == PA and S[i]== GU:
            point += 1
        allTe += te
    dmp(allTe,'allTe')
    dmp(point)
    return point


debug = False  # True False
ans = probC()
print(ans)
#for row in ans:
#    print(row)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define M 10
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
const double EPS = 1e-8;

double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;   // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(cross(b,c) < -EPS) return -1; // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

vector<P> convex_cut(vector<P> G, L l){
  vector<P> ans;
  for(int i=0;i<G.size();i++){
    P A = G[i];
    P B = G[(i+1)%G.size()];
    if(ccw(l.first, l.second, A) != -1) ans.push_back(A);
    if(ccw(l.first, l.second, A) * ccw(l.first, l.second, B) < 0)
      ans.push_back(crossPoint(L(A,B), l));
  }
  return ans;
}

double area(vector<P> v){
  double sum = 0.0;
  int n = v.size();
  for(int i=0;i<n;i++) sum += (real(v[i]) - real(v[(i+1)%n])) * (imag(v[i]) + imag(v[(i+1)%n]));
  return fabs(sum) / 2;
};

int n,m,x,y,cx,cy;
vector<P> vi;
P c[M];

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      vi.push_back(P(x,y));
    }
    for(int i=0;i<m;i++){
      cin>>cx>>cy;
      c[i]=P(cx,cy);
    }
    for(int i=0;i<m;i++){
      vector<P> cp=vi;
      for(int j=0;j<m;j++){
	if(i==j)continue;
	double X=(c[j].real()-c[i].real())/2.0;
	double Y=(c[j].imag()-c[i].imag())/2.0;
	P A=P(c[i].real()+c[j].imag()-c[i].imag()+X,
	      c[i].imag()-(c[j].real()-c[i].real())+Y);
	P B=P(c[i].real()+X,c[i].imag()+Y);
	cp=convex_cut(cp,L(A,B));
      }
      printf("%.20f\n",area(cp));
    }
    vi.clear();;
  }
  return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <functional>
#include <map>
#include <cmath>
using namespace std;

int H, a[3][100000], dp[3][100000];

int main() {
	cin >> H;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < H; j++) cin >> a[i][j];
	}
	dp[0][0] = a[0][0];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < H; j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + a[i][j + 1]);
		}
	}
	cout << dp[1][H - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int map[101][101];
int d[101];
int queue[101];
int n;

int main(){
    int i, j;
    int u, o, a;
    scanf("%d", &n);
    for( i = 1; i <= n; i++ ){
        d[i] = -1;
        for( j = 1; j <= n; j++ ){
            map[i][j] = 0;
        }
    }
    for( i = 1; i <= n; i++ ){
        scanf("%d", &u);
        scanf("%d", &o);
        for( j = 0; j < o; j++ ){
            scanf("%d", &a);
            map[i][a] = 1;
        }
    }

    int ppp=0, xxx=0;
    queue[xxx++] = 1;
    d[1] = 0;
    while( ppp < xxx ){
        i = queue[ppp++];
        for( j = 1; j < n+1; j++ ){
            if( map[i][j] == 1 && d[j] == -1 ){
                queue[xxx++] = j;
                d[j] = d[i]+1;
            }
        }
    }

    for( i = 1; i <= n; i++ ){
        printf("%d %d\n", i, d[i]);
    }
}



Measured memory_bytes: 2096
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (n, x) = {
        let v: Vec<i64> = read_vec();
        (v[0], v[1])
    };

    let mut a = vec![1];
    let mut p = vec![1];

    for i in 0..n as usize {
        let t = a[i];
        let s = p[i];
        a.push(t * 2 + 3);
        p.push(s * 2 + 1);
    }

    let ans = f(&a, &p, n as usize, x);
    println!("{}", ans);
}

fn f(a: &Vec<i64>, p: &Vec<i64>, n: usize, x: i64) -> i64 {
   if n == 0 {
      return if x <= 0 { 0 } else { 1 };
   } else if x <= 1 + a[n-1] {
      return f(&a, &p, n-1, x-1);
   } else {
       return p[n-1] + 1 + f(&a, &p, n-1, x - 2 - a[n-1]);
   }
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

struct Cube
{
	int f[6];
	Cube(){}

	void roll(int i,int j,int k,int l)
	{
		int t = f[i];
		f[i] = f[j];
		f[j] = f[k];
		f[k] = f[l];
		f[l] = t;
	}

	void roll_z() { roll(1,2,4,3); }
	void roll_y() { roll(0,2,5,3); }
	void roll_x() { roll(0,1,5,4); }

	void move(char c)
	{
		if(c == 'E') rep(i,3) roll_y();
		else if(c == 'W') roll_y();
		else if(c == 'N') roll_x();
		else if(c == 'S') rep(i,3) roll_x();
	}
};

int main()
{
	Cube c;
	string s;
	rep(i,6) cin >> c.f[i];
	cin >> s;

	rep(i,s.size()) c.move(s[i]);

	cout << c.f[0] << endl;
	return 0;
}

Measured memory_bytes: 1204
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll N;
ll A[100001];
ll b[100001];
bool ok[40];

ll va(ll x){
  ll cnt = 0;
  while(x > 1){
    x>>=1;
    cnt++;
  }
  return cnt;
}

int main()
{
  cin>>N;
  ll ans = 0;
  rep(i,N){
    cin>>A[i];
    ans^=A[i];
    ll cnt = 0;
    while(A[i]%2 == 0){
      A[i]>>=1;
      cnt++;
    }
    ok[cnt]=1;
  }
  ll a = 0;
  while(ans>0){
    a++;
    ll m = va(ans);
    if(!ok[m]){
      puts("-1");
      return 0;
    }
    ans ^= ((1<<(m+1))-1);
  }
  cout<<a<<endl;
}


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


using namespace std;

#define endl '\n'
#define PB push_back
#define MP make_pair
#define LL long long
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

typedef long long ll;

bool file=0,rt=1;
clock_t tStart ;
void FAST_IO();
////////////////////////

int main() {

    //FAST_IO();
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout << setprecision(5);
    cout << fixed;

    int a, b;

    cin >> a >> b;

    int ans1 = a + b;

    int c = max(a, b);

    int ans2 = c + c-1;

    cout << max(ans1 , ans2) << endl;





    return 0;
}

void FAST_IO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);
    if(rt && file){ tStart = clock(); }
    if(file){
    #ifndef _offline
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    }
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M;
    cin>>N>>M;
    vector<int64_t> H(N);
    rep(n,0,N) cin>>H.at(n);

    bitset<100000> B(0);
    B.flip();

    rep(m,0,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        if(H.at(a)>H.at(b)){
            //B.set(a);
            B.reset(b);
        }
        else if(H.at(a)<H.at(b)){
            //B.set(b);
            B.reset(a);
        }else{
            B.reset(a);
            B.reset(b);
        }
    }

    cout<<B.count()-100000+N<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int k;

bool is_ok(ll mid){
  int n[61], st=70;
  ll tmp=mid;
  FORR(i, 0, 61){
    n[i]=tmp%10;
    tmp/=10;
    if(n[i]>0){
      st=i;
    }
  }
  ll dp[62][2][2][10];
  REP(i, 62){
    REP(j, 2){
      REP(k, 2){
        REP(l, 10){
          dp[i][j][k][l]=0;
        }
      }
    }
  }
  dp[st][0][0][0]=1;
  FOR(i, st, 61){
    REP(j, 2){
      for(int x=0; x<=(j ? 9 : n[i]); ++x){
        dp[i+1][j || x<n[i]][x!=0][x]+=dp[i][j][0][0];
        dp[i+1][j || x<n[i]][1][x]+=dp[i][j][1][x];
        if(x>0){
          dp[i+1][j || x<n[i]][1][x]+=dp[i][j][1][x-1];
        }
        if(x+1<=9){
          dp[i+1][j || x<n[i]][1][x]+=dp[i][j][1][x+1];
        }
      }
    }
  }
  ll res=0;
  REP(i, 10){
    res+=dp[61][0][1][i]+dp[61][1][1][i];
    // if(mid==34){
    //   DEBUG(dp[61][0][i]);
    //   DEBUG(dp[61][1][i]);
    // }
  }
  // DEBUG(mid);
  // DEBUG(res);
  return res>=k;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  cin>>k;
  ll lb=0, ub=1e18;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(is_ok(mid)){
      ub=mid;
    }
    else{
      lb=mid;
    }
  }
  cout<<ub<<'\n';
  return 0;
}


Measured memory_bytes: 384
def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    a_max = max(a)
    ind_M = a.index(a_max)
    tmpl = a
    tmpl.pop(ind_M)
    for i in range(n):
        if i != ind_M:
            print(a_max)
        else:
            print(max(tmpl))


if __name__ == "__main__":
    main()


Measured memory_bytes: 68568
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(int i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	vector<string> a;
	a.pb("Sunny");
	a.pb("Cloudy");
	a.pb("Rainy");
	string x;
	cin>>x;
	forin(i,0,2)
	{
		if(x==a[i])
		{
			cout<<a[(i+1)%3]<<endl;
			break;
		}
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int ans = 0;
  int t_cnt = 0;
  for(int i=S.size()-1; i>=0; i--){
    if(S.at(i) == 'S' && t_cnt > 0){
      ans++;
      t_cnt--;
    }
    else if(S.at(i) == 'T'){
      t_cnt++;
    }
  }
  cout << S.size() - ans*2 << endl;
}

Measured memory_bytes: 640