akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
    int n, flag=1;
    cin >> n;

    int h[n], i, tmp=0;
    for(i=0; i<n; i++) {
        cin >> h[i];
        if(tmp>h[i]) {
            flag = 0;
        }
        tmp = h[i];
    }

    if(flag) {
        cout << "Yes" << endl;
        return 0;
    }

    tmp = h[0]-1;
    for(i=1; i<n; i++) {
        if(h[i]-tmp>=1) {
            tmp = h[i]-1;
        } else if(h[i]-tmp==0) {
            tmp = h[i];
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
    
}

Measured memory_bytes: 640
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
mod = 10**9+7
x,y = map(int,input().split())
if (x+y) % 3 != 0:
    res = 0
else:
    m = (2 * x - y) // 3
    n = (2 * y - x) // 3
    if m < 0 or n < 0:
        res = 0
    else:
        total = n+m
        k = n
        fac,ifac = make_tables(mod, total)
        res = cmb(total, k, mod, fac, ifac)
print(res)



Measured memory_bytes: 82464
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
int main(){
  long long A;
  long long B;
  long long C;
  rd(A);
  rd(B);
  rd(C);
  wt_L(B +min_L(A+B+1, C));
  wt_L('\n');
  return 0;
}
// cLay varsion 20190925-1

// --- original code ---
// {
//   ll A, B, C;
//   rd(A,B,C);
//   wt(B + min(A+B+1, C));
// }


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

int main() {

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

    for(int i = m/n; i>=0; --i){
        if(m%i == 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, K;

int main() {
    cin >> N >> K;
    vector<Pll> A(N);
    ll t, d;
    REP(i, N) {
        cin >> t >> d;
        A[i] = make_pair(t, d);
    }
    sort(ALL(A), [](const auto& lh, const auto& rh) {
        return lh.second > rh.second;
    });
    set<ll> T;
    priority_queue<ll, vector<ll>, greater<ll>> Q;
    ll score = 0;
    REP(i, K) {
        score += A[i].second;
        if(T.find(A[i].first)!=T.end()) {
            Q.push(A[i].second);
        }
        T.insert(A[i].first);
    }
    ll ans = score + SQ(T.size());
    FOR(i, K, N-1) {
        if(T.find(A[i].first)==T.end() && Q.size() > 0) {
            score -= Q.top();
            score += A[i].second;
            T.insert(A[i].first);
            ans = max(ans, ll(score + SQ(T.size())));
            Q.pop();
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5116
#include<stdio.h>

main(){
	int time, s, m, h;
	
	scanf("%d",&time);
	
	s=time%60;
	time/=60;
	
	m=time%60;
	
	h=time/60;
	
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

using namespace std;

int main(int argc, char const* argv[])
{
	string name;
	int a,b;

	for( int i = 0;i < 9;i++ ){
		cin >> name >> a >> b;
		cout << name << " " << a + b << " " << a * 200 + b * 300 << endl;
	}
	return 0;
}

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

public class Main
{
	static boolean Valid(String S)
	{
		for (char C : S.toCharArray())
		{
			if (C != 'A' && C != 'C' && C != 'T' && C != 'G') return false;
		}
		return true;
	}
	
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		String S = BR.readLine();
		int Best = 0;
		for (int i = 0; i < S.length(); i++)
		{
			String substr = S.substring(i);
			for (int j = 1; j <= substr.length(); j++)
			{
				String result = substr.substring(0, j);
				//System.out.println(result);
				if (Valid(result)) Best = Math.max(Best, result.length());
			}
		}
		System.out.println(Best);
	}
}


Measured memory_bytes: 32632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = Character.getNumericValue(s.charAt(0));
		int b = Character.getNumericValue(s.charAt(1));
		int c = Character.getNumericValue(s.charAt(2));
		int d = Character.getNumericValue(s.charAt(3));

		if (a + b + c + d == 7) {
			System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
		} else if (a - b + c + d == 7) {
			System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
		} else if (a + b - c + d == 7) {
			System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
		} else if (a + b + c - d == 7) {
			System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
		} else if (a - b - c + d == 7) {
			System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
		} else if (a + b - c - d == 7) {
			System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
		} else if (a - b + c - d == 7) {
			System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
		} else if (a - b - c - d == 7) {
			System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
		}

		sc.close();

	}

}

Measured memory_bytes: 39488
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
 
#define INF 1e12+7
#define ARRAY_MAX 2010
 
int main(){
 
    int n,left = 0,right = 0,pair_count = 0;
    string s;
    cin >> n >> s;
 
    REP(i,s.length()){
        if(s[i] == '('){
            left++;
        }else{
            right++;
        }
    }
 
    
    int left_tmp = 0;
    for(int i = 0;i < s.length();){
    
        if(s[i] == ')'){
            /*今見ている文字が)の場合はインクリメント*/
            i++;
        }else{
            /*(が出てきたとき*/
            while(s[i] == '(' && i < s.length()){
                /*(連続する個数を調べる*/
                i++;
                left_tmp++;
            }
            /*ここで、left_tmp個の連続する(の個数が求まる*/
            /*ループを抜けたので)が出てきたか文字の終わりに達したかのいずれかになっている*/
            if(i != s.length()){
                /*文字の終端でなかった場合、)が出てきたことになるので'('の個数分')'があればペアとみなす*/
                /*途中で')'の個数のほうが大きくなった場合はペアとしてカウントせず)が終わるまで進める*/
                while(s[i] == ')' && i < s.length() && left_tmp > 0){
                    i++;
                    left_tmp--;
                    pair_count++;
                }
                /*この時点で文字の終端に達したか再び'('が出てきたかのいずれかになる*/
                if(i == s.length()){
                    i = s.length()+10;
                    /*操作の終了*/
                }
            }else{
                i = s.length()+10;
                /*操作を終了*/
            }
        }
    }
 
    left -= pair_count;
    right -= pair_count;/*()ができている個数だけ減らす*/
    
    string ans;
    REP(i,right){
        ans.push_back('(');
    }
    ans += s;
    REP(i,left){
        ans.push_back(')');
    }
 
    //cout << left << " " << right << endl;
    cout << ans << endl;
    
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n,n)
	{
		int a[n];
		for (int i = 0; i < n; ++i) cin>>a[i];
		sort(a,a+n);
		int ans=10000000;
		for (int i = 1; i < n; ++i) ans=min(ans,a[i]-a[i-1]);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3164
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let mut abc = io.readn::<i64>(3);
    abc.sort();
    io.writeln(if abc[0] + abc[1] == abc[2] {
        "Yes"
    } else {
        "No"
    });
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<int>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };

int main()
{
	int k;
	cin >> k;
	vector<ll> a;
	for(int i = 1; i <= 9; i++)
	{
		a.push_back(i);
	}
	while (1)
	{
		if (k < a.size())
		{
			cout << a[k - 1] << endl;
			return 0;
		}
		k -= a.size();
		vector<ll> old;
		swap(old, a);
		for (ll x : old)
		{
			for (int i = -1; i <= 1; i++)
			{
				ll d = x % 10 + i;
				if (d < 0 || d> 9) {
					continue;
				}
				ll nx = x * 10 + d;
				a.push_back(nx);
			}
		}
	}
	return 0;
}

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

int main() {
  
  int a=0, b=0, c=0;
  cin >> a >> b >> c;
  
  if(a==b && a==c) {
    
    cout << "1" << endl;
    
  } else if(a!=b && a!=c && b!=c) {
    
    cout << "3" << endl;
    
  } else {
    
    cout << "2" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;
string A[MAX];
struct Matrix
{
	LL T[2][2];
	Matrix()
	{
		FOR(i, 0, 2) FOR(j, 0, 2) T[i][j] = 0;
	}

	void one()
	{
		T[0][0] = T[1][1] = 1;
	}

	void operator *=(Matrix a)
	{
		LL R[2][2] = {0};
		FOR(i, 0, 2)
		{
			FOR(j, 0, 2)
			{
				FOR(k, 0, 2)
				{
					R[i][j] = (R[i][j] + T[i][k] * a.T[k][j]) % MOD;
				}
			}
		}

		FOR(i, 0, 2)
		{
			FOR(j, 0, 2) T[i][j] = R[i][j];
		}
	}

	void print()
	{
		FOR(i, 0, 2)
		{
			FOR(j, 0, 2) cout << T[i][j] << " ";
			cout << endl;
		}
	}
};

void bp(Matrix& A, LL k)
{
	Matrix R;
	R.one();

	while (k)
	{
		if (k & 1)
		{
			R *= A;
		}

		k >>= 1;
		A *= A;
	}

	FOR(i, 0, 2)
	{
		FOR(j, 0, 2) A.T[i][j] = R.T[i][j];
	}
}
int main(){
    ios::sync_with_stdio();
    cin.tie(0);
    int n,m;
    LL k;
    cin>>n>>m>>k;
    FOR(i,0,n)
        cin>>A[i];
    LL cnt=0;
    bool ver=false;
    bool hor=false;
    FOR(i, 0, n)
	{
		if (A[i][0] == A[i][m - 1] && A[i][0] == '#') hor = true;
	}

	FOR(j, 0, m)
	{
		if (A[0][j] == A[n - 1][j] && A[0][j] == '#') ver = true;
	}
	FOR(i, 0, n)
	{
		FOR(j, 0, m) cnt += A[i][j] == '#';
	}

	if (ver && hor)
	{
		cout << 1 << endl;
		return 0;
	}

	if (!ver && !hor)
	{
		Matrix res;
		res.T[0][0] = cnt;
		bp(res, k - 1);
		cout << res.T[0][0] << endl;
		return 0;
	}
	LL w,b;
	w=b=0;
	if (hor)
	{
		FOR(i,0,n)
		{
			FOR(j, 1, m)
			{
				if (A[i][j] == A[i][j - 1] && A[i][j] == '#') w++;
			}

			if (A[i][0] == A[i][m - 1] && A[i][0] == '#') b++;
		}
	}
	else
	{
		FOR(j, 0, m)
		{
			FOR(i, 1, n)
			{
				if (A[i - 1][j] == A[i][j] && A[i][j] == '#') w++;
			}

			if (A[0][j] == A[n - 1][j] && A[0][j] == '#') b++;
		}
	}

	Matrix res;
	res.T[0][0] = b;
	res.T[0][1] = w;
	res.T[1][0] = 0;
	res.T[1][1] = cnt;
	bp(res, k - 1);
	w=res.T[0][1];
	b=res.T[1][1];
	cout<<(b-w+MOD)%MOD<<endl;
    return 0;
}



Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        boolean[][] cards = new boolean[4][13];
        for(int i=0; i<4; i++){
            for(int j=0; j<13; j++){
                cards[i][j] = true;
            }
        }

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for(int i=0; i<n; i++){
            String c = sc.next();
            int a = sc.nextInt();
            switch(c){
                case "S":
                    cards[0][a-1] = false;
                    break;
                case "H":
                    cards[1][a-1] = false;
                    break;
                case "C":
                    cards[2][a-1] = false;
                    break;
                case "D":
                    cards[3][a-1] = false;
                    break;    
            }
        }

        for(int i=0; i<4; i++){
            for(int j=0; j<13; j++){
                if(cards[i][j]){
                    switch(i){
                        case 0:
                            System.out.print("S ");
                            break;
                        case 1:
                            System.out.print("H ");
                            break;
                        case 2:
                            System.out.print("C ");
                            break;
                        case 3:
                            System.out.print("D ");
                            break;
                    }
                    System.out.println(j+1);  
                }
            }
        }

    }
}


Measured memory_bytes: 26392
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] str = br.readLine().split(" ");
        int[] a = new int[5];
        for(int i=0; i<5; i++){
            a[i] = Integer.parseInt(str[i]);
        }
        if( (a[4] <= a[2]) && (a[2] <= (a[0] - a[4])) ){
            if( (a[4] <= a[3]) && (a[3] <= (a[1] - a[4])) ){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24352
using System;

namespace AC3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);
            int D = (B + C) - A;
            if (D > 0) {
            Console.WriteLine(D); }
            else { Console.Write(0);
            }
        }
    }
}

Measured memory_bytes: 11092
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;



int main() {
	ll n, a=0, b=0;
	ll m=0, w;
	bool ans = true;
	vector<pair<ll, ll>> work;
	cin >> n;
	rep(i, n) {
		cin >> a >> b;
		work.push_back(make_pair(b, a));
	}
	sort(all(work));
	for (auto s : work) {
		m += s.second;
		if (m > s.first) {
			ans = false;
			break;
		}
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 5872
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    map <string,int> cnt;
    int n,ans=0; cin>>n; 
    while (n--){
        string s; cin>>s;
        sort(s.begin(),s.end());
        cnt[s]++;
    }
    for (auto &it: cnt) ans += ((it.ss)*(it.ss-1))/2; 
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 11196
import Data.List

toInt :: String -> Int
toInt = read :: String -> Int

main = do
  n <- toInt <$> getLine
  v <- map toInt . words <$> getLine
  c <- map toInt . words <$> getLine
  print . sum . filter (> 0) . map (\(x, y) -> x-y) $ zip v c


Measured memory_bytes: 4040
s = input()
n = len(s)
sf = s[0:(n-1)//2]
sl = s[(n+1)//2:]
for i in range(n//2):
    if s[i] != s[-i-1]:
        print('No')
        exit()
n2 = len(sf)
for i in range(n2//2):
    if sf[i] != sf[-i-1] or sl[i] != sl[-i-1]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))

# 何種類減らす必要がある？
remain = len(set(A))-K
#print(remain)

c = Counter(A)
c = c.most_common()[::-1]
#print(c)

count = 0
s = c[0:remain]
#print(s)
for _, num in s:
    count += num

print(count)


Measured memory_bytes: 48608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{


    fast();
      

    ll n,k;
    cin>>n>>k;
    vec q(n);
    f(i,0,n)
    {
      cin>>q[i];
    }
    ll array[n]={0};
    f(i,0,n)
    {
      f(j,i+1,n)
      {
        if(q[i]>q[j])
        {
          array[i]++;
        }
      }
    }
    ll array1[n]={0};
    f(i,0,n)
    {
      f(j,0,n)
      {
        if(i!=j&&q[i]>q[j])
        {
          array1[i]++;
        }
      }
    }
    

    // f(i,0,n)
    // {
    //   cout<<array[i]<<edl;
    // }
    ll s=0;
    f(i,0,n)
    {
      s=(s%MOD+array[i]%MOD*k%MOD)%MOD;
      s%=MOD;
      
      s=(s%MOD+(((k*(k-1))/2)%MOD*array1[i])%MOD)%MOD;
      


    }
    cout<<(s)%MOD<<edl;
  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}


Measured memory_bytes: 256
D[100][100],F[100],I=1<<29,N,M,L,K,A,H,i,j,k;
W(){for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];}
main(l){for(;scanf("%d%d%d%d%d%d",&N,&M,&L,&K,&A,&H),N;){
	for(memset(D,i=0,sizeof(D));i<N;i++)for(j=i+1;j<N;j++)D[i][j]=D[j][i]=I;
	for(memset(F,i=0,sizeof(F));i<L;i++)scanf("%d",&j),F[j]=1;
	F[A]=F[H]=1;
	for(i=0;i<K;i++)scanf("%d%d%d",&j,&k,&l),D[j][k]=D[k][j]=l;
	W();
	for(i=0;i<N;i++)for(j=0;j<N;j++)if(!F[i]||!F[j]||D[i][j]>M)D[i][j]=I;
	W();
	l=D[A][H];
	printf(l==I?"Help!\n":"%d\n",2*l-(l<M?l:M));
}exit(0);}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n,m,u,v;
vector<int> ga[100100];
int deg[100100];
int dp[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>u>>v;
		ga[u].push_back(v);
		deg[v]++;
	}
	stack<int> s;
	for(int i=1;i<=n;i++){
		if(deg[i]==0){
			s.push(i);
		} 
	}
	while(s.size()){
		int x=s.top();
		s.pop();
		for(int i=0;i<ga[x].size();i++){
			int y=ga[x][i];
			deg[y]--;
			dp[y]=max(dp[y],dp[x]+1);
			if(deg[y]==0){
				s.push(y);
			}
		} 
	}
	cout<<*max_element(dp+1,dp+n+1);
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int main(){
  bool flag;
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(1){
    C -= B;
    if(C <= 0){
      flag = true;
      break;
    }
    A -= D;
    if(A <= 0){
      flag = false;
      break;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

const int maxn = 5100;
int n, m;
int a[maxn][maxn], b[maxn][maxn];
int main() {
	n = ri(), m = ri();
	for (int i = 1; i <= n; i++) {
		string s;
		cin >> s;
		for (int j = 1; j <= m; j++) {
			if (s[j - 1] == '#') {
				a[i][j] = b[i][j] = 1;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		a[i][1] = 1; b[i][m] = 1;
	}
	for (int i = 1; i <= n; i++) {
		if (i & 1 == 1) {
			for (int j = 2; j < m; j++) {
				a[i][j] = 1;
			}
		}
		else {
			for (int j = 2; j < m; j++) {
				b[i][j] = 1;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i][j] == 0) cout << '.';
			else cout << '#';
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (b[i][j] == 0) cout << '.';
			else cout << '#';
		}
		cout << endl;
	}
}


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

int main(){
    int r,c,b;
    int a=0;
    cin>>r>>c;
    
    int x[r+1][c+1];
    int y[r+1];
    int z[c+1];
    
    for (int i=1;i<=r;i++){
        y[i]=0;
    }
    for (int i=1;i<=c;i++){
        z[i]=0;
    }
    for (int i=1;i<=r;i++){
        for (int j=1;j<=c;j++){
            cin>>b;
            x[i][j]=b;
            a += x[i][j];
        }
    }
    for (int i=1;i<=r;i++){
        for (int j=1;j<=c;j++){
            y[i] += x[i][j];
        }
    }
    for (int i=1;i<=c;i++){
        for (int j=1;j<=r;j++){
            z[i] += x[j][i];   
        }
    }
    for (int i=1;i<=r;i++){
        for (int j=1;j<=c;j++){
            cout << x[i][j]<<" ";
        }cout<<y[i]<<endl;
    }
    
    for (int i=1;i<=c;i++){
        cout<<z[i]<<" ";
    }
    cout<<a<<endl;
    return 0;
}


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

int main(){
  int P,Q,R;
  cin >> P >> Q >> R;
  
  cout << min({P+Q, P+R, Q+R}) <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int N, X;
	int L[110];

	cin >> N >> X;

	int ans = 1;
	int now = 0;
	for (int i = 1; i <= N; i++) {
		cin >> L[i];
		now += L[i];
		if (now <= X)ans++;
	}
	cout << ans;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> L(N);
  REP(i, N)
  cin >> L[i];
  int mx = 0;
  int sum = 0;
  REP(i, N)
  {
    if (mx < L[i])
      mx = L[i];
    sum += L[i];
  }
  if (mx < sum - mx)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main()
{
int n , m ;
cin >> n >> m ;
int ans = 0 ;
for (int i =1 ; i < n ; i++)
    ans+=i;
for(int i = 1 ; i < m ; i++)
    ans+=i;
cout << ans ;


}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,d,r;
	double f;
	scanf("%d%d",&a,&b);
	d=a/b;
	r=a%b;
	f=1.0*a/b;
	printf("%d %d %.5f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
import math

N, K = [int(s) for s in input().split(" ")]
p = 0
for n in range(1, N+1):
    if n >= K:
        p += 1/N
    else:
        p += 1/N * (0.5 ** (math.ceil(math.log2(K/n))))
print(p)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////

ll tn ; 
void solve()
{
 int n ; cin>>n; 
 int a = n%10; 
 int b = (n/10)%10; 
 int c = n/100; 
 if(a==7||b==7||c==7)
 cout<<"Yes"<<endl; 
 else
 cout<<"No"<<endl; 
}
int main()
{ ios; 

ll t ;t = 1; 
  for(tn = 1; tn<=t; tn++)
	solve(); 
	return 0 ; 
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define inf 2000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif
			ll n;
			cin>>n;
			if(n>=30)
			{
				cout<<"Yes"<<endl;

			}
			else
			{
				cout<<"No"<<endl;
			}
			
		
			return 0;
		 }	




Measured memory_bytes: 3644
#include <iostream>
using namespace std;
long long mod = 1e9+7,fact[200000],inv[200000],result[200000],cd,a[200000];
long long bigmod(long long base , long long hat)
{
		if (hat == 0) return 1;
		long long k = bigmod(base , hat / 2);
		if (hat % 2 == 0) return k * k % mod;
		return k * k % mod * base % mod;
}
long long C(long long k , long long n)
{
		if (k > n) return 0;
		return fact[n] * inv[n-k] % mod * inv[k] % mod;
}
void prepare()
{
		for (long long i = 0 ; i <= 100000 ; i++)
		{
				if (i == 0) fact[i] = 1;
				else        fact[i] = fact[i-1] * i % mod;
				inv[i]  = bigmod(fact[i] , mod - 2);
		}
}
void dp()
{
		for (long long i = 1 ; i <= 100000 ; i++)
		{
				result[i] = (result[i-1] + fact[i-1] + result[i-1] * (i-1)) % mod;
				//if (i <=4) cout <<"result["<<i<<"] : "<<result[i]<<endl;
		}
}
long long get()
{
		long long kq = 0;
		for (long long i = 1 ; i <= cd ; i++)
		{
			//	kq += C(i , cd) * result[i] % mod * (result[cd-i+1] - fact[cd-i+1] + mod) % mod * a[i] % mod;
				kq += C(i , cd) * result[i] % mod * a[i] % mod * fact[cd-i] % mod;
				kq += C(cd - i + 1 , cd) * (-fact[cd-i+1] + mod + result[cd - i + 1]) % mod * a[i] % mod * fact[cd - (cd - i + 1)] % mod;
				kq %= mod;
			//	cout <<"kq : "<<kq<<endl;
		}
		return kq;
}
int main()
{
		prepare();
		cin >> cd;
		for (int i = 1 ; i <= cd ; i++)
		{
				cin >> a[i];
		}
		dp();
		cout <<get();
}

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

def counter(num):
    cnt = 0
    while True:
        if num % 2 == 0:
            num = int(num/2)
            cnt += 1
        else:
            break

    return cnt



N = int(input())

max_cnt = 0
max_num = num = N
for num in range(N,0,-1):
    cnt = counter(num)
    if cnt > max_cnt:
        max_cnt = cnt
        max_num = num   

print(max_num)

Measured memory_bytes: 8996
#include<stdio.h>
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        int a=N/100;
        int b=N%10;
        int c=(N%100)/10;
        if((a==7)||(b==7)||(c==7))
        printf("Yes\n");
        else
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1568
# 点更新，区間クエリ
class SegTree:
    # n : 元の配列の長さ
    # init_list: 元の配列
    # segfunc : 載せる関数（演算）
    # ide_ele : segfuncの単位元
        
    def __init__(self, n, init_list ,segfunc, ide_ele):
        #　num : 2**num >= n となる最小の整数 （葉の数）
        # seg : segtreeのリスト
        self.num = 2**((n-1).bit_length())
        self.seg = [ide_ele]*(2*self.num)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        # 葉の要素をセット
        for i in range(n):
            self.seg[i+self.num-1] = init_list[i]        
        # segtreeの構築
        for i in range(self.num-2, -1, -1):
            self.seg[i] = segfunc(self.seg[2*i+1],self.seg[2*i+2])
        
        #memo: 要素iの子ノードは要素2*i+1, 2*i+2
        #    : 要素iの親ノードは要素(i-1)//2
        
    # 要素の更新 (init_list[k]=x)
    def update(self,k,x):
        k += self.num-1 #葉のノードのインデックス
        self.seg[k] = x
        #末端から頂点まで更新
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[2*k+1], self.seg[2*k+2])
     
    # 区間クエリ （区間[l,r)に対する演算結果）
    def query(self, l,r):
        if r<=l:
            return self.ide_ele
        
        l += self.num-1 #葉のノードのインデックス
        r += self.num-2 #半開区間から閉区間へ
        ret = self.ide_ele
        
        while r-l>1:
            if l&1 == 0:
                ret = self.segfunc(ret,self.seg[l])
            
            if r&1 == 1:
                ret = self.segfunc(ret,self.seg[r])
                r -= 1
            # 親ノードへ遷移
            l = l//2
            r = (r-1)//2
        if r==l:
            ret = self.segfunc(ret, self.seg[r])
        else:
            ret = self.segfunc(ret, self.seg[l])
            ret = self.segfunc(ret, self.seg[r])
        
        return ret
            
def segfunc(x,y):
    return max(x,y)

N = int(input())
S = list(input())
Q = int(input())

alphalist = [[0]*N for _ in range(26)]
atmp = ord('a')
for i,s in enumerate(S):
    alphalist[ord(s)-atmp][i] = 1

seglist = [None]*26
for i in range(26):
    seglist[i] = SegTree(N,alphalist[i],segfunc,0)

ans = []
for i in range(Q):
    t,l,r = map(str,input().split())
    if t=='1':
        i = int(l)-1
        c = r
        
        org_idx = ord(S[i])-atmp
        seglist[org_idx].update(i,0)
        S[i] = c
        upt_idx = ord(c) - atmp
        seglist[upt_idx].update(i,1)
                
        
    else:
        l,r = int(l)-1,int(r)
        cnt = 0
        for i in range(26):
            cnt += seglist[i].query(l,r)
        ans.append(cnt)

for a in ans:
    print(a)











Measured memory_bytes: 410448
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {

	int N;
	cin >> N;

	vector<string> S(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> S[i];
	}

	set<string> X;
	for (int i = 0; i < N; ++i)
	{
		X.insert(S[i]);
	}

	cout << X.size() << endl;

	return 0;
}

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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

string L;
int main(){
  MOD = 1000000007;
  cin >> L;
  ll len=L.size();
  ll foo = 1;
  ll bar = 0;
  for (ll i=0;i<len;i++){
    ll temp1,temp2;
    if (L[i]=='1'){
      temp1=mod(foo*2);
      temp2=mod(foo+bar*3);
      foo = temp1;
      bar = temp2;
    }else if (L[i]=='0'){
      temp1=mod(foo*1);
      temp2=mod(bar*3);
      foo = temp1;
      bar = temp2;
    }
  }
  cout << mod(foo+bar) << endl;
}


Measured memory_bytes: 1144
A=[x for x in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
N=int(input())
S=input()
s=[x for x in S]
ans=""
for i in range(len(S)):
  if A.index(S[i])+N<=25:
    ans+=A[A.index(S[i])+N]
  else:
    ans+=A[A.index(S[i])+N-26]
print(ans)


Measured memory_bytes: 3060
from itertools import combinations

n, D = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(n)]
cnt = 0


for a, b in combinations(ls, 2):
    l = 0
    for d in range(D):
        l += (a[d]-b[d])**2
    if l ** 0.5 == int(l ** 0.5):
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  vector<int> aivector(n);
  priority_queue<int> aiqueue;
  for(int &c : aivector) {
    cin >> c;
    aiqueue.push(c);
  }
  for(int i = 0; i < n; i++) {
    if(aivector.at(i) == aiqueue.top()) {
      int save = aiqueue.top();
      aiqueue.pop();
      cout << aiqueue.top() << endl;
      aiqueue.push(save);
    }
    else {
      cout << aiqueue.top() << endl;
    }
  }
}

Measured memory_bytes: 5080
cnt = 0
n, d = [int(x) for x in input().rstrip().split(" ")]
d2 = d**2
for i in range(n):
  x, y = [int(_) for _ in input().rstrip().split(" ")]
  if x**2 + y**2 <= d2:
    cnt += 1
print(cnt)

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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()


const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

class RangeMinorMaxorSumQuery // 0-index
{
    int const intmax = 2147483647;
    int const intmin = 0;
    vector<int> sgt;
    int n;
    int k;

public:
    RangeMinorMaxorSumQuery(int n1, int f = -1)
    {
        if (f == -1)
            f = intmax;
        else if (f == 0)
            f = intmin;
        int na = 1;
        int ka = 0;
        while (na < n1)
        {
            na *= 2;
            ka++;
        }
        for (int i = 0; i < 2 * na; i++)
            sgt.push_back(f);
        n = na;
        k = ka;
    }

    void update_sum(int i, int x)
    {
        i += n;
        sgt[i] = x;
        while (i > 1)
        {
            i /= 2;
            sgt[i] = sgt[2 * i] + sgt[2 * i + 1];
        }
    }

    int getsum(int a, int b, int k = 1, int l = 0, int r = -1) //閉区間 l <= x < r とする
    {
        if (r == -1)
            r = n;
        if (r <= a || b <= l)
            return intmin;
        if (a == l && b == r)
            return sgt[k];
        else
            return getsum(a, min(b, (l + r) / 2), 2 * k, l, (l + r) / 2) + getsum(max(a, (l + r) / 2), b, 2 * k + 1, (l + r) / 2, r);
    }
    void printsegtree()
    {
        for (int i = 0; i < 2 * n; i++)
        {
            cout << sgt[i] << " ";
        }
        cout << endl;
    }
};

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, q, sl, k, a, b, c, ans;
    char d;
    string s;

    cin >> n >> s >> q;
    sl = s.size();
    vector<RangeMinorMaxorSumQuery> words(26, RangeMinorMaxorSumQuery(sl, 0));

    rep(i, sl)
    {
        k = s[i] - 'a';
        words[k].update_sum(i, 1);
    }
    rep(i, q)
    {
        cin >> a;
        if (a == 2)
        {
            ans = 0;
            cin >> b >> c;
            rep(k, 26)
            {
                if(words[k].getsum(b - 1, c)) ans++;
            }
            cout << ans << rt;
            
        }
        else
        {
            cin >> b >> d;
            words[s[b - 1] - 'a'].update_sum(b - 1, 0);
            s[b - 1] = d;
            words[s[b - 1] - 'a'].update_sum(b - 1, 1);
        }
    }
    // rep(i, 26)
    // {
    //     words[i].printsegtree();
    // }

    return 0;
}


Measured memory_bytes: 111732
from sys import stdin,stdout
one,zero,neg1,k=list(map(int,stdin.readline().split()))
o1=o0=o3=0
o1=min(k,one)
left=k-o1
o2=min(zero,left)
left-=o2
o3=max(0,min(left,neg1))
print(o1-o3)

Measured memory_bytes: 9120
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
 
ll choose2(ll n){
    return n*(n-1)/2;
}
 
int main() {
    vector<int> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    cout<<a[2] * 10 + a[1] + a[0]<<endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  sort(all(x));

  ll ans = INF;
  REP(i, 1, 101) {
    ll tmp = 0;
    rep(j, n) tmp += (i - x[j]) * (i - x[j]);
    ans = min(ans, tmp);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int chair_length, interval, width, count = 0;
  scanf("%d %d %d", &chair_length, &width, &interval);
  chair_length -= interval;
  while(1) {
    if(chair_length < width + interval) {
      printf("%d\n", count);
      break;
    } else {
      chair_length -= (width + interval);
      count++;
    }
  }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 10 22:30:07 2019

@author: Yamazaki Kenichi
"""
import heapq
#import random
#X,Y,Z,K = 1000,1000,1000,3000
#A = random.sample(range(10**9),1000)
#B = random.sample(range(10**9),1000)
#C = random.sample(range(10**9),1000)

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
Q = []
T = [[-1 for i in range(X)] for i in range(Y)]
T[0][0] = 0
heapq.heappush(Q,[-(A[0]+B[0]+C[0]),0,0,0])
for i in range(K-1):
    k = heapq.heappop(Q)
    s1,s2,s3 = k[1],k[2],k[3]
    if s1 + 1 != X and T[s1+1][s2] < s3:
        heapq.heappush(Q,[-(A[s1+1]+B[s2]+C[s3]),s1+1,s2,s3])
        T[s1+1][s2] += 1
    if s2 + 1 != Y and T[s1][s2+1] < s3:
        heapq.heappush(Q,[-(A[s1]+B[s2+1]+C[s3]),s1,s2+1,s3])
        T[s1][s2+1] += 1
    if s3 + 1 != Z and T[s1][s2] < s3 + 1:
        heapq.heappush(Q,[-(A[s1]+B[s2]+C[s3+1]),s1,s2,s3+1])
        T[s1][s2] += 1
    print(-k[0])
k = heapq.heappop(Q)
print(-k[0])


Measured memory_bytes: 12784
#include <bits/stdc++.h>
using namespace std; void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); solve(); }
template <typename Type> void print_collection(Type coll) { cout << "{ "; for (auto e : coll) cout << e << ' '; cout << "}\n"; }
void solve() {
    string s;
    cin >> s;
    int min_repaints = s.size() + 1;
    for (char c : {'0', '1'}) {
        int repaints = 0;
        for (auto sc : s) {
            if (c != sc) ++repaints;
            c = c == '0' ? '1' : '0';
        }
        min_repaints = min(min_repaints, repaints);
    }
    cout << min_repaints << '\n';
}


Measured memory_bytes: 512