akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int maxN = 100 * 100 + 9;
const double EPS = 1e-9;

int n;
int a[maxN];

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

void solv(){
  int ans = 0;
  for(int i = 0; i < n; i++){
    int x = a[i], cnt = 0;
    while(x % 2 == 0){
      cnt++;
      x /= 2;
    }
    //cerr << cnt << ' ';
    ans += cnt;
  }

  cout << ans << '\n';
}

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

  #ifdef DEBUG
    freopen("in.txt", "r", stdin);
  #endif

  read();
  solv();

  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		if i%3 == 0 {
			fmt.Printf(" %d", i)
			continue
		}
		for j := i; j > 0; j = j / 10 {
			if j%10 == 3 {
				fmt.Printf(" %d", i)
				break
			}
		}
	}
	fmt.Println("")
	return
}



Measured memory_bytes: 1160
K = int(input())
S = input()
X = len(S)
mod = 10**9+7

temp = pow(26,K,mod)
ans = pow(26,K,mod)

Y = 25*pow(26, mod-2, mod)

for i in range(X+1,K+X+1):
   
    temp *= Y
    temp %= mod
    
    temp *= i-1
    temp %= mod
    
    temp *= pow(i-X, mod-2, mod)
    temp %= mod    

    ans += temp
    ans %= mod

print(ans)

Measured memory_bytes: 75452
w, h, x, y = gets.strip.split(" ").map(&:to_i)

half = h / 2.0
f =
  if y >= half
    (w / 2.0) * h
  else
    (h / 2.0) * w
  end

s = 
  if x == (w / 2.0) && y == (h / 2.0)
    1
  else
    0
  end

puts "#{f} #{s}"


Measured memory_bytes: 1788
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=1004535809;
const long long LMOD=154590409516822759;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Beg begin
int main()
{
	ll n;
	cin>>n;
	if(n%2!=0)
	{
		puts("0");
		return 0;
	}
	ll g1=0;
	for(ll t=10;t<=n;t*=5)
	{
		g1+=n/t;
	}
	ll g2=0;
	for(ll t=2;t<=n;t*=2)
	{
		g2+=n/t;
	}
	cout<<min(g1,g2);
	return 0;
}

Measured memory_bytes: 256
# N回の取得
N = int(input())
# 数列に変換
num = list(map(int, str(N)))
# 計算処理
if num[0] >= num[1] and num[0] >= num[2]:
    print(num[0] * 111)
else:
    print((num[0] + 1) * 111)


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

int main()
{
    string str;
    cin>>str;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s.compare("print")==0){
            int a,b;
            cin>>a>>b;
            for(int j=a;j<=b;j++)
               cout<<str[j];
            //cout<<str.substr(a,b);
            cout<<"\n";
            
        }
        else if(s.compare("reverse")==0){
            int a,b;
            cin>>a>>b;
            while(a<b){
                swap(str[a],str[b]);
                a++;
                b--;
            }
            
        }
         else if(s.compare("replace")==0){
            int a,b;
            string p;
            cin>>a>>b>>p;
            for(int j=0;j<b-a+1;j++){
                str[a+j]=p[j];
            }
        }
    }
}



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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N; cin >> N;
	int res = 0;
	forn(i,1,N+1){
		int x; cin >> x;
		if(i&1 && x&1)res++;
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3608
n,m = map(int,input().strip().split())
ls = list(map(int,input().strip().split()))
mini = sum(ls)/(4*m)
i = 0
while i<n and m>0:
    if ls[i]>=mini:
        m -= 1
    i += 1
if m<=0:
    print("Yes")
else:
    print("No")


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)

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

    int n, m, d; cin >> n >> m >> d;
    vector<string> field(n);
    rep(i, n) cin >> field[i];

    int ans = 0;
    rep(i, n) rep(j, m) {
        if(field[i][j] == '#') continue;
        if(i+d-1 < n) {
            bool f = true;
            rep(k, d) f &= field[i+k][j] == '.';
            if(f) ans++;
        }
        if(j+d-1 < m) {
            bool f = true;
            rep(k, d) f &= field[i][j+k] == '.';
            if(f) ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= s * t)
    yn;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  for(int i = 0; i < n; i++){
    cin >> x[i];
  }
  int mini = 1001001001;
  for(int i = 0; i < n - k + 1; i++){
    if(x[i] < 0 && x[i + k - 1] < 0){
      mini = min(mini, -x[i]);
    }else if(x[i] < 0 && x[i + k - 1] >= 0){
      mini = min({mini, -x[i] * 2 + x[i + k - 1], x[i + k - 1] * 2 - x[i]});
    }else{
      mini = min(mini, x[i + k - 1]);
    }
  }
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <utility>

using namespace std;

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define dump(x) cerr << #x << "=" << x << endl

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<bool> bv;

int main(void) {

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int sum_1 = a*x+b*y;
    int sum_2 = a*max(x-y, 0)+c*2*y;
    int sum_3 = b*max(y-x, 0)+c*2*x;

    cout << min(min(sum_1, sum_2), sum_3) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <stack>
#include <map>
#include <set>
#if __cplusplus > 199711L
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//	tree<key, mapped = null_type, cmp = less<key>, rb_tree_tag, tree_order_statistics_node_update> name;
//	order_of_key
//	find_by_order
#endif

using namespace std;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fs first
#define sc second
#define abs(a) ((a) < 0 ? -(a) : (a))
#define sqr(a) ((a) * (a))

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

inline pair<pair<bool, bool>, pair<string, bool> > useinout();

void initialization() {
#ifdef SOL
	if (useinout().fs.fs)
		freopen("input.txt", "r", stdin);
	if (useinout().fs.sc)
		freopen("output.txt", "w", stdout);
#else
	srand(time(0));
	const string file = useinout().sc.fs;
	if (!file.empty()) {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
	if(useinout().sc.sc) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
}

int solve();

void finish(int exitval) {
	fflush(stdout);
#ifdef SOL
	fprintf(stderr, "\nexit value: %d\ntime: %.3lf ms\n", exitval, 1000. * clock() / CLOCKS_PER_SEC);
#endif
}

int main() {
	initialization();
	int exitval = solve();
	finish(exitval);
	return (0);
}

const double eps = 1e-9;
const int mod = (int) 1e+9 + 7;
const double pi = acos(-1.);
const int maxn = 100100;

int a[maxn], b[maxn];

int solve() {

	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
	}
	a[0] = a[n + 1] = b[0] = b[n + 1] = 0;
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i] > a[i - 1] || b[i] > b[i + 1]) {
			ans = ans * 1ll * 1;
			if (a[i] > a[i - 1]) {
				ans = ans * 1ll * (b[i] >= a[i]);
			}
			if (b[i] > b[i + 1]) {
				ans = ans * 1ll * (a[i] >= b[i]);
			}
		} else {
			ans = ans * 1ll * min(a[i], b[i]) % mod;
		}
	}

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

	return (0);
}

inline pair<pair<bool, bool>, pair<string, bool> > useinout() {
	return (mp(mp(0, 0), mp("", 0)));
}

// by Andrey Kim


Measured memory_bytes: 1152
function Main(input) {
  var inputs = input.split(" ");
  var k = Number(inputs[0]);
  var s = Number(inputs[1]);
  var cnt = 0;

  for (var x = 0; x <= k; x++)
    for (var y = 0; y <= k; y++) if (s - (x + y) >= 0 && s - (x + y) <= k) cnt++;
  console.log(cnt)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 20936
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

#define rep(i,n) for(int i=0; i<int(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

vector<int>bus;
set<P>s;

int main() {
	int N, M; 

	cin >> N;
	for (int i = 0; i < N; i++) {
	  int h,m;
	  cin >> h >> m;
	  bus.push_back(h*60 + m);
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		 int h,m;
		 cin >> h >> m;
		 bus.push_back(h*60 + m);
	}
	sort(bus.begin(),bus.end());

	for(int i=0; i<bus.size(); i++){
	  int m = bus[i] % 60;
	  int h = (bus[i] - m)/60;
	  s.insert(make_pair(h,m));
	}

	set<P>::iterator it; 
	int i=0;
	for(it=s.begin(); it != s.end(); it++,i++){
	    printf("%d:%02d",it->first,it->second);
	    if(i != s.size()-1)cout << " ";
	 }
	cout << endl;
	return 0;
}

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

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; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main(){
    int K;
    cin>>K;
    rep(i,K) cout<<"ACL";
    cout<<endl;
}

Measured memory_bytes: 3632
xyabc = list(map(int,input().rsplit()))
p = list(map(int,input().rsplit()))
q = list(map(int,input().rsplit()))
r = list(map(int,input().rsplit()))
x = xyabc[0]
y = xyabc[1]
p.sort(reverse=True)
q.sort(reverse=True)

z =p[:x]+q[:y]
z = z + r
z.sort(reverse=True)
print(sum(z[:x+y]))


Measured memory_bytes: 23216
#include <iostream>
#define long long
using namespace std;
#define ll long long
ll dp[100001];

int main () {
  for (ll i = 0; i <= 100000; i++) dp[i] = -1;
  ll n, k;
  cin >> n >> k;
  ll a[n];
  for (ll i = 0; i < n; i++) cin >> a[i];
  for (ll i = 1; i <= 100000; i++) {
    // iの状態である.
    for (ll j = 0; j < n; j++) {
      ll now = i - a[j];
      if (now >= 0) {
        if (dp[now] == -1) {
          dp[i] = 1;
          break;
        }
      }
    }
  }
  if (dp[k] == 1) {
    cout << "First" << endl;
  }
  else {
    cout << "Second" << endl;
  }
}

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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}


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

    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.length();
    if(n <= k) {
        cout << s;
    } else {
        while((int) s.length() > k) s.pop_back();
        s += "...";
        cout << s;
    }
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 3652
use std::io;


fn main() {
    let _n = read_one::<usize>();
    let mut s = read_one::<String>()
        .chars().collect::<Vec<char>>();
    s.dedup();
    println!("{:?}", s.len());
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
import math
a, b, h, m = map(int, input().split())

h_arg = (h/12)*360 + (m/60)*30
m_arg = (m/60)*360

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(h_arg-m_arg)))
print(ans)



Measured memory_bytes: 9380
#include <cstdio>
#include <algorithm>
using namespace std;
int id[1001];
int p[1001], q[1001], r[1001], kcal[1001];

int main() {
    int n, P, Q, R, C, sum;
    for (; ; ) {
        scanf("%d", &n);
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            scanf("%d %d %d %d", &id[i], &p[i], &q[i], &r[i]);
            kcal[i] = p[i]*4+q[i]*9+r[i]*4;
        }
        scanf("%d %d %d %d", &P, &Q, &R, &C);
        sum = 0;
        for (int i = 0; i < n; i++) {
            if (p[i] <= P && q[i] <= Q && r[i] <= R && kcal[i] <= C) { printf("%d\n", id[i]); sum++; }
        }
        if (!sum) printf("NA\n");
    }

    return 0;
}



Measured memory_bytes: 2728
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let abt: Vec<f64> = read_vec();

  println!("{}", ((abt[2] + 0.5) / abt[0]).floor() * abt[1]);
}


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

int main(){
  int N,M;
  cin >>N>>M;
  int ans =0;
  int miss =0;
  bool s[N+1];
  rep(i,N+1)s[i]=false;
  vector<int>missmemo(N+1);
  rep(i,M){
    int monndaibanngou;
    cin >>monndaibanngou;
    string kekka;
    cin >>kekka;
    if(kekka == "AC"){
      if(!s[monndaibanngou])ans++;s[monndaibanngou]=true;
    }
    if(kekka == "WA"){
      if(!s[monndaibanngou])missmemo.at(monndaibanngou)++;
    }
  }
  rep(i,N+1)if(s[i])miss+= missmemo.at(i);
  cout<<ans<<" "<<miss<<endl;
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<climits>
#include<cassert>
#include<cstring>
#include<sstream>
#include<bitset>
#include<deque>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
#include<set>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

#define MAX 210
#define MINI 0
#define MAXI 1
long long dp[MAX][MAX][2];

int getPos(string &text,int p) {
  int cnt = 0;
  rep(i,(int)text.size()) {
    if( isdigit(text[i]) ) {
      if( cnt == p ) return i;
      ++cnt;
    }
  }
  assert(false);
}

void fix(string &text,string &L,string &R) {
  string tmp = text;
  rep(i,(int)text.size()) {
    if( text[i] == '(' || text[i] == ')' ) {
      text[i] = ' ';
    }
  }
  {
    stringstream ss;
    ss << text;
    string new_text = "";
    while( ss >> text ) new_text += text;
    text = new_text;
  }
  L = R = string((int)text.size(),'o');
  for(int i=0;i<(int)text.size();i+=2) {
    assert( isdigit(text[i]) );
    int p = getPos(tmp,i/2);
    if( p - 1 >= 0 && tmp[p-1] == '(' ) L[i] = 'x';
    if( p + 1 < (int)tmp.size() && tmp[p+1] == ')' ) R[i] = 'x';
  }
}

void compute(string text) {
  string L,R;
  fix(text,L,R);
  /*
  cout << "new text = " << text << endl;
  cout << "L        = " << L << endl;
  cout << "R        = " << R << endl;
  */
  rep(i,MAX) rep(j,MAX) dp[i][j][MINI] = INT_MAX;
  rep(i,MAX) rep(j,MAX) dp[i][j][MAXI] = -INT_MAX;
  rep(i,(int)text.size()) if( isdigit(text[i]) ) {
    dp[i][i][MINI] = dp[i][i][MAXI] = text[i] - '0';
  }
  int n = ((int)text.size()+1) / 2;
  REP(i,2,n+1) {
    for(int j=0;j<(int)text.size();j+=2) {
      int k = j + ( i -1 ) * 2;
      if( k >= (int)text.size() ) break;
      if( L[k] == 'x' || R[j] == 'x' ) continue;
      for(int l=j+1;l<(int)k;l+=2) {
	if( text[l] == '+' ) {
	  if( dp[j][l-1][MINI] != INT_MAX && dp[l+1][k][MINI] != INT_MAX ) {
	    dp[j][k][MINI] = min(dp[j][k][MINI],
				 dp[j][l-1][MINI]+dp[l+1][k][MINI]);
	  }
	  if( dp[j][l-1][MAXI] != -INT_MAX && dp[l+1][k][MAXI] != -INT_MAX ) {
	    dp[j][k][MAXI] = max(dp[j][k][MAXI],
				 dp[j][l-1][MAXI]+dp[l+1][k][MAXI]);
	  }
	} else {
	  if( dp[j][l-1][MINI] != INT_MAX && dp[l+1][k][MAXI] != -INT_MAX ) {
	    dp[j][k][MINI] = min(dp[j][k][MINI],
				 dp[j][l-1][MINI]-dp[l+1][k][MAXI]);
	  }
	  if( dp[j][l-1][MAXI] != -INT_MAX && dp[l+1][k][MINI] != INT_MAX ) {
	    dp[j][k][MAXI] = max(dp[j][k][MAXI],
				 dp[j][l-1][MAXI]-dp[l+1][k][MINI]);
	  }
	}
      }
    }
  }
  cout << dp[0][(int)text.size()-1][MAXI] << endl;
}

int main() {
  string text;
  cin >> text;
  compute(text);
  return 0;
}

Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int64_t f(int64_t x){
  if(x<=0){return 0;}
  else if(x%4==0){return x;}
  else if(x%4==1){return 1;}
  else if(x%4==2){return 1^x;}
  else if(x%4==3){return 0;}
}

int main() {
  int64_t A,B;
  cin>>A>>B;
  int64_t a=f(B)^f(A-1);
  cout<<a<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  c = vi(26);
  s = vvi(D, vi(26));
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void output() {
  for (int i = 0; i < D; i++) {
    cout << ans[i] + 1 << endl;
  }
}

int simulate(vi a, int day) {
  int sum = 0;
  vi last(26, 0);
  for (int i = 0; i <= day; i++) {
    sum += s[i][a[i]];
    last[a[i]] = i + 1;
    for (int j = 0; j < 26; j++) {
      sum -= c[j] * (i - last[j] + 1);
    }
  }
  return sum;
  // return max((int)1e6 + sum, 0);
}

int simulate(vi a) { return simulate(a, D - 1); }

void solve() {
  int best = simulate(ans);

  //
  {
    vi a = ans;
    for (int i = 0; i < D; i++) {
      int bst = -INF, idx = 0;
      for (int j = 0; j < 26; j++) {
        a[i] = j;
        int x = simulate(a, i);
        if (x > bst) {
          bst = x;
          idx = j;
        }
      }
      a[i] = idx;
    }
    if (best < simulate(a)) ans = a, best = simulate(ans);
  }

  //
  srand((unsigned)time(NULL));
  int loop = 1000;
  while (loop--) {
    vi a = ans;
    int change = D / 2;
    while (change--) {
      int idx = rand() % (D - 1);
      int tmp = a[idx + 1];
      a[idx + 1] = a[idx];
      a[idx] = tmp;
    }

    int x = simulate(a);
    if (x > best) {
      best = x;
      ans = a;
    }
  }
}

int main() {
  input();
  ans = vi(D, 0);
  solve();
  output();
}


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

from collections import Counter
counter = Counter(A)

from collections import defaultdict
res_dic = defaultdict(int)

base = 0
for key,n in counter.items():
  res_dic[key] = (n * (n - 1) // 2, (n - 1) * (n - 2) // 2)
  base += n * (n - 1) // 2
  
for i in range(N):
  ans = base - res_dic[A[i]][0] + res_dic[A[i]][1]
  print(ans)


Measured memory_bytes: 40588
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    LL d, t, s;
    cin >> d >> t >> s;
    LL val = d / s;
    if (val < t) {
        cout << "Yes" << endl;
    } else if (val == t) {
        if (d % s == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	while(1){
		int n,q;
		cin >> n >> q;
		if(n == 0 && q == 0) break;
		string en[10000];
		int es[10000],ee[10000];
		for(int i = 0;i < n;i++){
			string ten;
			int eb,wy;
			cin >> ten >> eb >> wy;
			en[i] = ten;
			es[i] = wy - eb + 1;
			ee[i] = wy;
		}
		for(int i = 0;i < q;i++){
			int qer;
			cin >> qer;
			
			string nengo;
			int year = 0;
			bool flag = false;
			
			for(int j = 0;j < n;j++){
				if(es[j] <= qer && qer <= ee[j]){
					nengo = en[j];
					year = qer - es[j] + 1;
					flag = true;
				}
			}
			
			if(flag){
				cout << nengo << " " << year << endl;
			}else{
				cout << "Unknown" << endl;
			}
		}
	
	}
	return 0;
}


Measured memory_bytes: 3172
#include <iostream> 
using namespace std;
int main() {
  int n,k,sum=0; cin >> n >> k;
  int arr[n];
  for (int i=0; i<n; i++) cin >> arr[i];
  sort(arr,arr+n);
  for (int i=0; i<k; i++) sum += arr[i];
  cout << sum << endl;
}

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

using namespace std;
int n;
int x;
int acmax;
int a;
int b;
int c;

int main()
{
    int counter = 0;
    cin >> n;
    vector <int> l(n, 3000);
    for(int i=0; i<n; i++)
    {
        cin >> l.at(i);
    }
    sort(l.begin(),l.end());
    for (int i=0; i<n-2; i++){
        a = l.at(i);
        acmax = a + l.at(n-1);
        for (int j=i+1; j<n-1; j++)
        {
            b = l.at(j);
            if (acmax < b || acmax == b)
                break;
            for (int k=j+1; k<n; k++)
            {
                c = l.at(k);
                x = a + b;
                if(x < c || x == c)
                    break;
                counter++;
            }
        }
    }
    cout << counter << endl;

}

Measured memory_bytes: 256
using System;

namespace Atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            int mokuhyou = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            bool check = false;

            for (int i = A; i <= B; i++)
            {
                if(i % mokuhyou == 0)
                {
                    check = true;
                }
            }

            if(check)
            {
                Console.WriteLine("OK");
            } else
            {
                Console.WriteLine("NG");
            }

        }
    }
}

Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, x, t;
	cin >> n >> x >> t;
	cout << (n / x + (n % x != 0)) * t << endl;
	return 0;
}

Measured memory_bytes: 3580
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, X, Y;
    cin >> N >> X >> Y;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    if(N==1){
        // とるしかない
        p(abs(A[0]-Y));
        return 0;
    }


    ll candidate0 = abs(A[N-1] - Y);
    ll candidate1 = abs(A[N-2] - A[N-1]);

    p(max(candidate0, candidate1));
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val p = (0 until n).map {
        sc.next().toLong()
    }

    abc154d(n, k, p)
}

fun abc154d(n: Int, k: Int, p: List<Long>) {
    val list = DoubleArray(n + 1) { 0.0 }
    for (i in 0 until n) {
        val pi = p.get(i)
        list[i + 1] = list[i] + (sum(pi) / pi)
    }

    var ans = 0.0
    for (i in 0..n - k) {
        val temp = list[i + k] - list[i]
        if (temp > ans) ans = temp
    }

    println(ans)
}

private fun sum(pi: Long): Double {
    var sum = 0.0
    for (i in 1..pi) {
        sum += i
    }
    return sum
}

Measured memory_bytes: 57664
n, m = map(int, raw_input().split())
g = [[] for i in xrange(m)]
for i in xrange(n):
    ipt = map(int, raw_input().split())
    k = ipt[0]
    for e in ipt[1:]:
        g[e-1].append(i)
parent = range(n)
def root(x):
    if x == parent[x]:
        return x
    parent[x] = root(parent[x])
    return parent[x]
def unite(x, y):
    px = root(x)
    py = root(y)
    if px < py:
        parent[py] = px
    elif px > py:
        parent[px] = py
    return min(px, py)
for e in g:
    for i in xrange(len(e)-1):
        unite(e[i], e[i+1])
for i in xrange(n):
    root(i)
print "YES"*(sum(parent) == 0) or "NO"


Measured memory_bytes: 16872
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 10;
vector<int> E[2][maxn]; 
int col[2][maxn];
int cnt[4];
int n, m, d1, d2;
bool in(int x, int y) { return 0 <= x && x < (n << 1) && 0 <= y && y < (n << 1);}
int idx(int x, int y) { return x * (n << 1) + y;}
void connect(int x, int y, int k)
{
	for(int i = 0; i < (n << 1); ++i)
		for(int j = 0; j < (n << 1); ++j)
			if(in(i + x, j + y))
			{
				int u = idx(i, j), v = idx(i + x, j + y);
				E[k][u].push_back(v);
				E[k][v].push_back(u);
			}
}
void dfs(int x, int k, int c)
{
	col[k][x] = c;
	for(auto v : E[k][x])
		if(col[k][v] == -1)
			dfs(v, k, c ^ 1);
}
void solve(int d, int k)
{
	int a = sqrt(d) + 0.5;
	for(int i = -a; i <= a; ++i)
	{
		if(i * i > d) continue;
		int j = sqrt(d - i * i) + 0.5;
		if(i * i + j * j == d)
			connect(i, j, k);
	}
	memset(col[k], -1, sizeof col[k]);
	for(int i = 0; i < m; ++i)
		if(col[k][i] == -1)
			dfs(i, k, 0);
}
int main()
{
	scanf("%d%d%d", &n, &d1, &d2);
	m = 4 * n * n;
	solve(d1, 0);
	solve(d2, 1);
	for(int i = 0; i < m; ++i)
		++cnt[col[0][i] * 2 + col[1][i]];
	int val = max_element(cnt, cnt + 4) - cnt;
	for(int i = 0, tot = n * n; tot; ++i)
		if(col[0][i] * 2 + col[1][i] == val)
		{
			--tot;
			printf("%d %d\n", i / (n << 1), i % (n << 1));
		}
	return 0;
}

Measured memory_bytes: 123428
import java.util.*;
import java.io.*;
import java.math.BigInteger;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for(int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }
        long[] skip = new long[N];
        for(int i = 0; i < N; i++) {
            if(i != 0 && skip[i - 1] != 0) {
                skip[i] = skip[i - 1] - 1;
            }else if(A[i] == 0) {
                int cou = 0;
                for(int j = i; j < N; j++) {
                    if(A[j] == 0) cou++;
                    else break;
                }
                skip[i] = cou;
            }
        }
        long count = 0;
        for(int i = 0; i < N; i++) {
            long xor = 0L;
            long add = 0L;
            for(int j = 0; ; j++) {
                int id = i + j;
                if(id >= N) break;
                if(skip[id] > 0) {
                    j += skip[id]-1;
                    count += skip[id];
                    continue;
                }
                add += A[id];
                xor ^= A[id];

                if(add == xor) count++;
                if(xor < add) break;
            }
        }
        System.out.println(count);





    }
}

Measured memory_bytes: 88384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  string s;
  vector<char> str;

  cin >> s;

  for(int i = 0;i < s.size();i++){
    if(s[i] == 'B' && !str.empty()){
      str.pop_back();
    } else if (s[i] == '0' || s[i] == '1'){
      str.push_back(s[i]);
    }
  }

  for(int i = 0;i < str.size();i++){
    cout << str[i];
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define N 100005
constexpr int inf = 1e9+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
vector<vector<int>> dist;
vector<vector<char>> maze;
int h,w;
bool check(int mid){

  return false;
}

ll serch(ll ok,ll ng) {
	while (abs(ok-ng) > 1) {
		ll mid = (ok + ng) / 2;
		if (check(mid))ok = mid;
		else ng = mid;
	}
	return ok;
}

int bfs(int x ,int y){
  rep(i,h){
    rep(j,w){
      dist[i][j]=inf;
    }
  }
  dist[x][y]=0;
  queue<P> q;
  q.push(make_pair(x,y));
  while(!q.empty()){
    P nq=q.front();q.pop();
    rep(i,4){
      int nx=nq.first+di[i];
      int ny=nq.second+dj[i];
      if(0<=nx&&nx<h&&0<=ny&&ny<w&&maze[nx][ny]!='#'&&dist[nx][ny]==inf){
        q.push(make_pair(nx,ny));
        dist[nx][ny]=dist[nq.first][nq.second]+1;
      }
    }
  }
  int m=0;
  rep(i,h){
    rep(j,w){
      if(maze[i][j]!='#'&&dist[i][j]!=inf){
        m=max(m,dist[i][j]);
      }
    }
  }
  return m;
}

int main(){
  cin>>h>>w;
  dist.resize(h);
  maze.resize(h);
  rep(i,h){
    dist[i].resize(w);
    maze[i].resize(w);
    rep(j,w){
      cin>>maze[i][j];
    }
  }
  int ans=0;
  rep(i,h){
    rep(j,w){
      if(maze[i][j]=='.'){
        ans=max(ans,bfs(i,j));
      }
    }
  }
  cout<<ans<<endl;
}



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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, 0, N) {
    cin >> L[i];
  }
  sort(All(L));
  int biggest = L[N - 1];
  int tmp = 0;
  rep(i, 0, N - 1) {
    tmp += L[i];
  }
  if (biggest < tmp) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
};


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
const int maxn=110;
int main()
{
   // set<char> se;
    set<string> see;
    int n;
    char ch[maxn];
    string s[maxn];
    int ans=0;
    cin>>n;
    cin>>s[0];
    see.insert(s[0]);
   // se.insert(s[0][0]);
    for(int i=1;i<n;i++){
    cin>>s[i];
    see.insert(s[i]);
    //se.insert(s[i][0]);
    if(s[i-1][s[i-1].size()-1] != s[i][0])ans=1;
    }
    if(see.size()<n)cout<<"No"<<endl;
    else if(ans)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <cstring>

#define nl '\n'

using namespace std;

long long h;

long long attack(long long x){
    if(x == 1){
        return 1;
    } else{
        return 2*attack(x/2)+1;
    }
}

int main(){

    cin >> h;

    cout << attack(h);




}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

Measured memory_bytes: 384
@{$_ x3}=1for A..D;for$i(1..<>-1){$x=0;for$j(glob'{A,B,C,D}'x3){$j=~/../,($$j[$i]+="$_$j"!~/ABC|A.*C.*B|CAB/*${$_.$&}[$i-1])%=$%=1e9+7for A..D;$x+=$$j[-1]}}print$x%$%

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

static int pow5(int x) {
    int xx = x * x;
    return xx * xx * x;
}
signed main() {
    int x;
    cin>>x;
    rep(a, 1000) {
        FOR(b, -500, 500) {
            if(pow5(a) - pow5(b) == x) {
                cout<<a<<' '<<b;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int q = sc.nextInt();

    Deque<Process> procs = new ArrayDeque<>();
    for (int i = 0; i < n; i++) {
      String name = sc.next();
      int time = sc.nextInt();
      procs.push(new Process(name, time));
    }

    Deque<Process> finishedProcs = new ArrayDeque<>();

    int totalQ = 0;

    while (procs.size() > 0) {
      Process p = procs.removeLast();
      int quantum = Math.min(q, p.getTime());
      totalQ += quantum;
      p = p.progress(quantum);
      if (p.finished()) {
        finishedProcs.addLast(new Process(p.getName(), totalQ));
      } else {
        procs.addFirst(p);
      }
    }

    PrintWriter pw = new PrintWriter(System.out);
    for (Process p : finishedProcs) {
      pw.println(p.getName() + " " + p.getTime());
    }

    pw.flush();
  }

  private static class Process {
    private String name;
    private int time;

    public Process(String name, int time) {
      this.name = name;
      this.time = time;
    }

    public String getName() {
      return name;
    }

    public int getTime() {
      return time;
    }

    public Process progress(int ms) {
      return new Process(name, time - ms);
    }

    public boolean finished() {
      return time <= 0;
    }
  }
}


Measured memory_bytes: 77512
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

map<char,int> mci;

bool check(int v){
  stringstream ss; ss << v;
  string s = ss.str();
  rep(i,s.size()){
    if(mci[s[i]])
      return false;
  }
  return true;
}

int main(){
  int n,k; cin >> n >> k;
  rep(i,k){
    char c; cin >> c;
    mci[c]++;
  }
  for(int i = n; n <= 10000; i++){
    if(check(i)){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	string x;
	cin>>x;
	
	for(auto it: x)
	{
		int temp=it-'A';
		temp+=n;
		temp%=26;
		
		cout<<(char)('A'+temp);
	}
					                                				
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, k = MAP()
if (n + 1) // 2 >= k:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 60268
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << ((a+b==c+d)?"Balanced":((a+b>c+d)?"Left":"Right")) << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int N;
    cin >> N;

    int ans=0;
    rep(i,0,N){
        int l,r;
        cin >> l >> r;
        ans+=r-l+1;
    }
    
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

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

    int c[50] = {};
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        c[a]++;
        c[b]++;
    }

    for (int i = 0; i < n; i++) {
        cout << c[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
import math
L = [int(input()) for _ in range(5)]
Lm = []
for i in L:
    if i%10 == 0:
        Lm.append(0)
    else:
        Lm.append(10-i%10)
print(sum([10*math.ceil(i/10) for i in L])-max(Lm))





Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2e5+100;
vector <int> g[N];
ll dis[N][2];
queue <int> q;
void bfs(ll x){
    while(q.size()){
        ll v=q.front();
        q.pop();
        for (int i=0;i<g[v].size();i++){
            ll u=g[v][i];
            if (dis[v][x]+1<dis[u][x]){
                dis[u][x]=dis[v][x]+1;
                q.push(u);
            }
        }
    }
    return ;
}
int32_t main(){
    ll n,x,y;
    cin >> n >> x >> y;
    for (int i=0;i<n-1;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    memset(dis,69,sizeof dis);
    dis[x][0]=0;
    q.push(x);
    bfs(0);
    dis[y][1]=0;
    q.push(y);
    bfs(1);
    ll ans=0;
    for (int i=1;i<=n;i++){
        if (dis[i][0]<=dis[i][1]){
            if (dis[i][0]%2==dis[i][1]%2){
                ans=max(ans,dis[i][1]-1);
            }
            else{
                ans=max(ans,dis[i][1]-1);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 11904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int r, c, sum, sumOfAll;
		int[][] sheet;
		String[] size = in.readLine().split(" ");
		r = Integer.parseInt(size[0]);
		c = Integer.parseInt(size[1]);
		sheet = new int[r][c];
		for (int i = 0; i < r; i += 1) {
			sum = 0;
			String[] array = in.readLine().split(" ");
			for (int j = 0; j < c; j += 1) {
				sheet[i][j] = Integer.parseInt(array[j]);
				sb.append(sheet[i][j]).append(" ");
				sum += sheet[i][j];
			}
			sb.append(sum + System.getProperty("line.separator"));
		}
		sumOfAll = 0;
		for (int m = 0; m < c; m += 1) {
			sum = 0;
			for (int n = 0; n < r; n += 1) {
				sum += sheet[n][m];
			}
			sumOfAll += sum;
			sb.append(sum).append(" ");
		}
		sb.append(sumOfAll);
		System.out.println(sb);
	}
}

Measured memory_bytes: 23140
#include <stdio.h>
int main(void){
    int a, i, n, min, max;
    long int s;
    
    min = 1000000; 
    max = -1000000;

    s = 0;
    
    scanf("%d", &n);
    
    0 < n <= 10000;
    
    for (i = 0; i < n; i++){
        scanf("%d", &a);
        s += a;
        
        if(a < min){
            min = a;
        }
        if(a > max){
            max = a;
        }
    }
    
    printf("%d %d %ld\n", min, max, s);

    return(0);
}
    


Measured memory_bytes: 2104