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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

ll f(ll x) {
	ll res = 1;
	ll cnt = 0;
	while (x != 1) {
		x /= 2;
		cnt++;
		res += pow(2, cnt);
	}
	//cout << cnt << endl;
	return res;
}

int main() {
	ll h;
	cin >> h;
	cout << f(h) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int k ;cin>>k;
    int ans=-1;
    vector<Int> a(k+1,0);
    a[0]=0;
    for(int i=0 ;i<k; i++){
        a[i+1]=(10*a[i]+7)%k;
        if(a[i+1]<0) a[i+1]+=k;
        if(a[i+1]==0) {ans=i+1;
        break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
	string x;
	
	while(cin >> x) {
		cout << x[0];
		int count = x.length();
		cout << count-2;
		cout << x[count-1];
		cout << endl;
	}
	
	
	return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = (a<b?a:b); }
template <typename T> T &chmax(T &a, const T &b) { return a = (a>b?a:b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

signed main(void)
{
  string s;
  cin >> s;

  if(s.size() == 1) {
    cout << s << endl;
    return 0;
  }

  int ret = 0;
  REP(i, s.size()) ret += s[i]-'0';
  if(s[0] == '0') chmax(ret, (ll)(s.size()-1)*9);
  else chmax(ret, s[0]-'0'-1 + (ll)(s.size()-1)*9);
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner
import scala.math._
object Main extends App {
  val sc = new Scanner(System.in)
  val n, k = sc.nextInt
  val Ln2 = log(2)
  println(((1 to n).map {i =>
    val coins = ceil(log(k.toDouble / i) / Ln2).toInt
    if (coins > 0) 1 / pow(2, coins) else 1
  }).sum / n)
}

Measured memory_bytes: 38856
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n),b(n);
	cin>>a>>b;
	ll ans=0;
	rep(i,n){
		ans+=max(a[i]-b[i],0);
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

void pri(vector<string> a) {
  rep(i, a.size()) {
    cout << a[i] << endl;
  }
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> b(h);
  rep(i, h) cin >> b[i];

  vector<bool> okx(110,false);
  vector<bool> oky(110,false);

  rep(i, h) {
    rep(j, w) {
      if(b[i][j] == '#') {
        okx[i] = true;
        oky[j] = true;
      }
    }
  }

  rep(i, h) {
    if(okx[i]) {
      rep(j, w) {
        if(oky[j]) {
          cout << b[i][j] << flush;
        }
      }
      cout << endl;
    }
  } 
  return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int N,M,K;
    cin>>N>>M>>K;

    for(int i=0;i<=N;i++){
        for(int j=0;j<=M;j++){
            int n=M*i;
            int m=N*j;
            int l=n+m-i*j*2;
            if(l==K){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


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

int main(void){
    cout<<fixed<<setprecision(12);
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    cout<<sqrt(pow(x2-x1,2)+pow(y2-y1,2))<<endl;
}



Measured memory_bytes: 3288
#include<iostream>
using namespace std;
int main(){
    int n,i,p=0;
    string s;
    cin>>n;
    cin>>s;
    int prev=s[0];
    int c=1;
    for(i=1;i<n;i++){
        if(s[i]==prev) ;
        else{
            c+=1;
            prev=s[i];
            
        }
    }
    cout<<c<<endl;    
    
    
  return 0;
	}
    

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        //freopen ("in1.txt", "r", stdin);
        //freopen ("ans1.txt", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    vector<int>a(n);
    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++){
        if (a[i] * 4 * m >= sum){
            cnt++;
        }
    }
    if (cnt >= m){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include  <iostream>
#include   <cstring>
#include    <cstdio>
#include    <vector>
#include    <bitset>
#include    <string>
#include    <cctype>
#include     <cmath>
#include     <deque>
#include     <stack>
#include     <queue>
#include       <map>
#include       <set>
#include       <ctime>
using namespace std;
#define scd(a) scanf("%d", &a)
#define scdd(a,b) scanf("%d%d", &a, &b)
#define scddd(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define X first
#define Y second
#define lowbit(x) ((x) & (-x))
#define IOS ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5 + 10, INF = 0x3f3f3f3f;
const ll mod =  998244353, LINF = 0x3f3f3f3f3f3f3f3f;;
const double eps = 1e-10, Pi = 2*acos(0);
int n, m;
int dp[110][110];
int deal(int x, int y){
    if(dp[x][y] != -1) return dp[x][y];
    for(int i = 1; 2*i <= x; i++) {
        if(!deal(x - 2*i, y + i)) return dp[x][y] = 1;
    }

    for(int i = 1; 2*i <= y; i++){
        if(!deal(x + i, y - 2*i)) return dp[x][y] = 1;
    }

    return dp[x][y] = 0;
}
void init(){
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
                int cur = deal(i, j);
            if(!cur) printf("%d %d %d\n", cur, i, j);
        }
    }
}
void solve(){
    ll x, y;
    scanf("%lld%lld", &x, &y);
    if(abs(x - y) <= 1) printf("Brown\n");
    else printf("Alice\n");
}
int main()
{
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("in.txt", "w", stdout);
    #endif
    int ce, c = 1, flag = 1;
//    IOS;
//    cin.tie(0);
//    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
<?php
list($a,$b)=explode(" ",trim(fgets(STDIN)));
echo lcm($a,$b);

function gcd($a,$b){
	return ($a%$b)? gcd($b,$a%$b):$b;
}
function lcm($a,$b){
	return (int)$a/gcd($a,$b)*$b;
}

Measured memory_bytes: 4728
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, x, A[50176];
int main() {
	// step #1. read input
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N;
	int H = (N >> 1);
	for (int i = 0; i < H; ++i) {
		cin >> A[i];
	}
	if (N % 2 == 1) {
		cin >> x;
	}
	for (int i = H - 1; i >= 0; --i) {
		cin >> x;
		A[i] += x;
	}
	// step #2. calculate the answer
	long long ans = 0;
	for (int i = 1; i < N; ++i) {
		long long sum = 0;
		int pos = i;
		while (pos < H) {
			sum += A[pos];
			ans = max(ans, sum);
			pos += i;
		}
		if ((N - 1) % i != 0) {
			pos = (N - 1) - pos;
			while (pos >= i) {
				sum += A[pos];
				ans = max(ans, sum);
				pos -= i;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3852
N=int(input())
list=[]
for i in range(N):
  a,b=map(int,input().split())
  list.append((b,a))
list.sort()
acc=0
for i in range(N):
  acc+=list[i][1]
  if acc>list[i][0]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 35236
N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  if i + 1 == len(list):
    break
  if add: l = l + 1 
  if l - 1 > list[i + 1] and l < list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)

Measured memory_bytes: 14252
n = int(input())
lst = list(map(int, input().split()))
nlst = []
num = 0
cnt = 0
for i in range(n-1):
  if lst[i]>=lst[i+1]:
    num += 1
  else:
    nlst.append(num)
    num = 0
nlst.append(num)
print(max(nlst))

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
    int first = n / 100;
    int second = n % 100;
    // cout << first << ' ' << second << endl;
    if (first == 0) first = 13;
    if (second == 0) second = 13;
   
    if (first > 12 && second > 12) {
    	cout << "NA" << endl;
    } else if (first < 13 && second < 13) {
    	cout << "AMBIGUOUS" << endl;
    } else if (first < 13) {
    	cout << "MMYY" << endl;
    } else {
    	cout << "YYMM" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>

using namespace std;
const int mod = 1e9+7;
int a[100010];
int main()
{
    int n;
    while(~scanf("%d", &n))
    {
        long long ans = 1;
        memset(a, 0, sizeof(a));
        for(int j = 2; j <= n; j++)
        {
            int k = j;
            for(int i = 2; i < 100000 && k != 1; i++)
            {
                while(k%i == 0)
                {
                    a[i]++;
                    k /= i;
                }
            }
        }
        for(int i = 2;i < 100000;i++)
            if(a[i]) ans = (ans*(a[i] + 1))%mod;
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 640
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
A = LI()

for i in range(N):
    if A[i] == 0:
        print(0)
        exit()

s = 1
for i in range(N):
    s *= A[i]
    if s > 10**18:
        print('-1')
        exit()

print(s)

Measured memory_bytes: 84064
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<29)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    int t, ans = 0;
    cin >> t;
    ans += 1000 * (t / 500);
    t -= 500 * (t / 500);
    ans += 5 * (t / 5);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
<?php

function dfs($first, $last) {
    if (count($last) === 0) {
        return [$first];
    }

    $res = [];
    foreach ($last as $key => $val) {
        $next_f = $first;
        $next_l = $last;

        $next_f[] = $val;
        array_splice($next_l, $key, 1);
        $res = array_merge($res, dfs($next_f, $next_l));
    }

    return $res;
}
function next_permutation($start, $end) {
    return dfs([], range($start, $end));
}

fscanf(STDIN, "%d", $n);
$x_arr = [];
$y_arr = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d %d", $x, $y);
    $x_arr[] = $x;
    $y_arr[] = $y;
}

// 経路
$routes = next_permutation(1, $n);
$sum = 0;
foreach ($routes as $route) {
    for ($i = 0; $i < $n - 1; ++$i) {
        $sum += sqrt(
            pow($x_arr[$route[$i] - 1] - $x_arr[$route[$i + 1] - 1], 2)
            + pow($y_arr[$route[$i] - 1] - $y_arr[$route[$i + 1] - 1], 2)
        );
    }
}


$tmp = 1;
for ($i = 1; $i <= $n; ++$i) {
    $tmp *= $i;
}

echo $sum / $tmp;


Measured memory_bytes: 23544
use std::io::{self, BufRead};

fn main() {
    let si = io::stdin();
    let triplets = si.lock().lines().skip(1).map(|l| {
        let l = l.unwrap();
        let mut ns = l.split_whitespace().map(|s| s.parse::<u32>().unwrap());
        (ns.next().unwrap(), ns.next().unwrap(), ns.next().unwrap())
    });
    let (mut t, mut x, mut y) = (0, 0, 0);
    for (ti, xi, yi) in triplets {
        let d = sub_abs(xi, x) + sub_abs(yi, y);
        let dt = ti - t;
        if dt < d || (dt - d) % 2 == 1 {
            println!("No");
            return;
        }
        t = ti;
        x = xi;
        y = yi;
    }
    println!("Yes");
}

fn sub_abs(a: u32, b: u32) -> u32 {
    if a > b {
        a - b
    } else {
        b - a
    }
}

Measured memory_bytes: 4352
def runrun(K,S):
    if K <= len(S):
        S.sort()
        ##print(S)
        print(S[K-1])
        return 
    else:
        for i in range(len(S)):
            tmp = S[i]%10
            if tmp == 9:
                S.append(S[i]*10+8)
                S.append(S[i]*10+9)
            elif tmp == 0:
                S.append(S[i]*10+1)
                S.append(S[i]*10)
            else:
                S.append(S[i]*10+tmp-1)
                S.append(S[i]*10+tmp)
                S.append(S[i]*10+tmp+1)
        S = list(set(S))
        runrun(K,S)

if __name__ == "__main__":
    K = int(input())
    S = []
    for i in range(1,10):
        S.append(i)
    runrun(K,S)

Measured memory_bytes: 31588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
#define PI 3.1415926535

int main()
{
    int n,m,arr[100000],sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++ )
    {
        cin>>arr[i];
        sum+=arr[i];
    }

    if(n>=sum)
        cout<<n-sum;
    else
        cout<<"-1";

}


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

int main()
{
  int y, m, d;
  char c;

  cin >> y >> c >> m >> c >> d;

  bool heisei = true;

  if(y > 2019) heisei = false;
  if(y == 2019 && m > 4) heisei = false;

  if(heisei) cout << "Heisei" << endl;
  else cout << "TBD" << endl;

  return 0;

}


Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    K = int(input())

    l = []
    for i in range(1, 1000):
        l.append(i)
    for k in range(1, 13):
        n0 = 10 ** k
        for i in range(100, 1000):
            l.append(i * n0 + n0 - 1)

    r = []
    for n in l:
        sn = 0
        d = n
        while 0 < d:
            d, m = int(d / 10), d % 10
            sn += m
        r.append(n / sn)

    min_r = r[-1]
    for i in range(len(r) - 2, -1, -1):
        if min_r < r[i]:
            r.pop(i)
            l.pop(i)
        else:
            min_r = r[i]

    for i in range(K):
        print(l[i])


if __name__ == '__main__':
    main()



Measured memory_bytes: 3828
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define ed end
#define bg begin
#define fr first
#define sc second
#define il inline
#define LL long long
#define pb push_back
#define mk make_pair
#define to(k) E[k].to
#define val(k) E[k].val
#define next(k) E[k].next
#define pint pair<int, int>

#define MAXN 400010
#define MAXS 1200100
#define Inf 998244353

using namespace std ;
struct Edge{
	int to, next, val ;
}E[MAXN << 1] ; int head[MAXN], cnt, sz[MAXS] ; 
int N, vals[MAXN], dp[MAXN], ctn[MAXN], now_st, ans ; 

void add(int u, int v, int w){
	E[++ cnt].to = v, E[cnt].val = w,
	E[cnt].next = head[u], head[u] = cnt ;
	E[++ cnt].to = u, E[cnt].val = w,
	E[cnt].next = head[v], head[v] = cnt ;
}
int do_do(int stt){
	if (!stt) return 0 ;
	if (dp[stt] != -1) return dp[stt] ;
	int ret = Inf ;
	for (int i = 1 ; i <= 15 ; ++ i){
		if (!(stt >> i & 1)) continue ;
		for (int j = 1 ; j <= 15 ; ++ j){
			if (i == j || !(stt >> j & 1)) continue ;
			int now_st = stt ^ (1 << i) ^ (1 << j) ;
			int q = i ^ j ; now_st ^= (1 << q) ; 
			if (sz[now_st] < sz[stt]) ret = min(ret, do_do(now_st) + 1 + (~now_st >> (q) & 1)) ; 
		}
	}
	return dp[stt] = ret ; 
}
int main(){
	cin >> N ; 
	int u, v, w, i ; 
	memset(dp, -1, sizeof(dp)) ;
	for (i = 1 ; i < N ; ++ i) 
		scanf("%d%d%d", &u, &v, &w), 
		add(u + 1, v + 1, w), vals[u + 1] ^= w, vals[v + 1] ^= w ;  
	for (i = 1 ; i <= N ; ++ i) if (vals[i]) ctn[vals[i]] ++ ; 
	for (i = 0 ; i <= 15 ; ++ i) ans += ctn[i] / 2, now_st |= (ctn[i] & 1) << i ;
	for (i = 1 ; i < MAXS ; ++ i) sz[i] = sz[i - (i & -i)] + 1 ; 
	ans += do_do(now_st) ; cout << ans << endl ; return 0 ; 
}

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

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

  vector<bool> used(1000009, false);
  int m;
  for (m = 1; m < 1000009; ++m) {
    if (used[s] == true) break;
    used[s] = true;
    if (s % 2 == 0) s /= 2;
    else s = 3 * s + 1;
  }
  cout << m << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int n, m; cin >> n >> m;
    char c[n][m];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++) cin >> c[i][j];
    }
    int cnt = 0;
    for (int j = 0; j < m; j++)
    {
        int cur = 0;
        for (int i = 0; i < n; i++) if (c[i][j] == '.' || c[i][j] == '-') cur++;
        if (cur == n)
        {
            for (int i = 0; i < n; i++) c[i][j] = '-';
        }
    }
    for (int i = 0; i < n; i++)
    {
        int cur = 0;
        for (int j = 0; j < m; j++) if (c[i][j] == '.' || c[i][j] == '-') cur++;
        if (cur == m)
        {
            for (int j = 0; j < m; j++) c[i][j] = '-';
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++) if (c[i][j] != '-') cout << c[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
N=int(input())
a=[]
for i in range(N):
  a.append(input())
b={}
for j in range(len(a)):
  if a[j] in b:
    b[a[j]]+=1
  else:
    b[a[j]]=1
max_b=max(b.values())
c=[]
for k,l in b.items():
  if l==max_b:
    c.append(k)
c.sort()
for m in c:
  print(m)

Measured memory_bytes: 35216
n=int(input());l=[0,1];a=0;b=c=1;p=998244353
for i in range(2,n):l+=[l[p%i]*(p-p//i)%p]
for i in range(n,n//2,-1):a+=b*c;b+=b%p;c=c*i*l[n+1-i]%p
print((pow(3,n,p)-2*a)%p)

Measured memory_bytes: 220836
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];
char field[200][200];

int main(){
  while(1){
    cin >> n >> m >> l;
    if(n == 0 && n == m && m == l)break;
    rep(i,0,n)cin >> d[i];
    m--;l--;
    int gap = 0;
    int ans = 0;
    lep(i,m,l){
      if(d[i] - d[i+1] >= gap){
        gap = d[i] - d[i+1];
        ans = i + 1;
      }
    }
    print(ans);
  }
  return 0;
}


Measured memory_bytes: 3008
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= MOD;
	}
	return ret;
}

#pragma endregion 



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

	int n;
	cin >> n;
	vvi a(2, vi(n));
	f(i, 0, 2) {
		f(j, 0, n) {
			cin >> a[i][j];
		}
	}
	vi sum1(n), sum2(n);
	sum1[0] = a[0][0];
	sum2[n - 1] = a[1][n - 1];
	f(i, 1, n) {
		sum1[i] = sum1[i - 1] + a[0][i];
		sum2[n - 1 - i] = sum2[n - i] + a[1][n - 1 - i];
	}
	int ans = 0;
	f(i, 0, n) {
		ans = max(ans, sum1[i] + sum2[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String S = in.next();
		String T = in.next();
		boolean onazi = true;
		boolean komozi = true;
		boolean mozisu = false;
    	boolean tuika = false;
    	
    	//条件
		for(int i=0; i<S.length(); i++){
			char a = S.charAt(i);
            char b = T.charAt(i);
            if(!(a == b)){
            	onazi = false;
            }
		}
    	for(int i=0; i<S.length(); i++){
            char x = S.charAt(i);
    		if(x >= 'A' && x <= 'Z') {
    			komozi = false;
    		}
    	}
    	for(int i=0; i<T.length(); i++){
			char x = T.charAt(i);
			if(x >= 'A' && x <= 'Z') {
    			komozi = false;
    		}
    	}
        if(1<=S.length() && S.length()<=10){
          mozisu = true;
        }
        if(T.length() == (S.length()+1)){
        	tuika = true;
        }
        
        //判定
        if(onazi && komozi && mozisu && tuika){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int k,i,cnt=0;
    char s[200005],t[200005];
    
    cin >> s;
    cin >> t;
    
    k = strlen(s);
    
    for(int i=0;i<k;i++)
    {
        if(s[i]!=t[i])
        cnt++;
    }
    
    cout << cnt;
}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int SZ = 1 << 18;

template<class T>
struct segtree {
	vector<T> dat;

	const T inf = numeric_limits<T>::max();

	void init() {
		dat.resize(SZ * 2);
		rep(i, SZ * 2) dat[i] = inf;
	}

	void update(int pos, T x) {
		pos += SZ - 1;
		dat[pos] = x;

		while (pos > 0) {
			pos = (pos - 1) / 2;
			dat[pos] = min(dat[pos * 2 + 1], dat[pos * 2 + 2]);
		}
	}

	T get(int a, int b, int k = 0, int l = 0, int r = SZ) {
		if (b <= l || r <= a) return inf;
		if (a <= l && r <= b) return dat[k];
		return min(get(a, b, k * 2 + 1, l, (l + r) / 2), get(a, b, k * 2 + 2, (l + r) / 2, r));
	}
};

segtree<ll> segp, segn;

const ll INF = TEN(18);

int main() {
	int N, Q, A, B;
	cin >> N >> Q >> A >> B;
	--A; --B;

	V<int> x(Q+1);
	rep(i, Q) {
		cin >> x[i+1];
		--x[i+1];
	}
	x[0] = A;

	segp.init(); segn.init();
	segp.update(B, B);
	segn.update(B, -B);

	ll off = 0;

	rep(i, Q) {
		int p = x[i], q = x[i+1];
		ll d = abs(p - q);
		ll mn = INF;
		{
			ll l = segn.get(0, q+1);
			if (l != segn.inf) {
				l = l + q - d;
			}
			chmin(mn, l);
		}
		{
			ll r = segp.get(q, N);
			if (r != segp.inf) {
				r = r - q - d;
			}
			chmin(mn, r);
		}

		segp.update(p, mn + p);
		segn.update(p, mn - p);

		off += d;
	}

	ll ans = INF;
	rep(i, N) {
		{
			ll x = segp.get(i, i + 1);
			if (x != segp.inf) {
				chmin(ans, x - i + off);
			}
		}
		{
			ll x = segn.get(i, i + 1);
			if (x != segn.inf) {
				chmin(ans, x + i + off);
			}
		}		
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	string k = "No";
	if((a == b && a != c) ||
	   (a == c && a != b) ||
	   (c == b && a != c) )
	{
		k = "Yes";
	}
	cout << k <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
  string S;
  cin>>S;
  int a=S.size();
  if(S[a-1]=='s'){
      cout<<S<<"es"<<endl;
  }
  else{
      cout<<S<<"s"<<endl;
  }
}


Measured memory_bytes: 3624
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

int32_t main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int dp[n + 1] = {0};
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    for (int i = 3; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 5164
#[allow(unused_macros)]
macro_rules! debug {
  ($($e:expr), *) => {println!(concat!($(stringify!($e), " = {:?}\n"), *), $($e), *)}
}

fn main() {
  let (n,a,b) = get::tuple3::<usize,usize,usize>();
  let ts = get::vals::<usize>(n);

  let ans = ts.iter().filter(|&&t|t<a||t>=b).count();
  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}


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

int main() {
  int A,B,C,D,Left,Right;
  cin >> A >> B >> C >> D;
  Left = A+B;
  Right = C+D;
  if(Left>Right){
    cout << "Left" << endl;
  }
  if(Left<Right){
    cout << "Right" << endl;
  }
  if(Left==Right){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]

def judge(k):
    cnt = 0
    for h in H:
        cnt += -(-(max(h-k*B,0))//(A-B))
    if cnt <= k:
        return True
    return False

def biserch(ok,ng,judge):
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        if judge(mid):
            ok = mid
        else:
            ng = mid
    return ok

ans = biserch(max(H),-1,judge)
print(ans)

Measured memory_bytes: 7076
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

type limit struct {
	A int
	B int
}

type sortB []limit

func (a sortB) Len() int           { return len(a) }
func (a sortB) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a sortB) Less(i, j int) bool { return a[i].B < a[j].B }

func main() {
	N := nextInt()
	ABn := []limit{}
	for i := 0; i < N; i++ {
		ABn = append(ABn, limit{nextInt(), nextInt()})
	}
	sort.Sort(sortB(ABn))
	ans := "Yes"
	sumA := 0
	for i := 0; i < N; i++ {
		sumA += ABn[i].A
		if ABn[i].B < sumA {
			ans = "No"
			break
		}
	}
	fmt.Println(ans)
}

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

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


Measured memory_bytes: 14848
#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def solve(A: int, P: int):
    ans = 3*A+P
    ans //= 2

    print(ans)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(A, P)



if __name__ == "__main__":
    main()


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define sz(a) a.size()
#define pii pair<ll,ll> 
#define nl "\n"
#define ff first
#define ss second
#define c(n) ll n; cin>>n;
#define ca(n) ll a[n]; rep(n) cin>>a[i];
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(a) a.begin(),a.end()
#define sort_stl(a) sort(a.begin(),a.end())
#define srt(a) sort(a,a+n)
#define fl(a,x) memset(a,x,sizeof(a))

typedef vector<ll> vll ;

int main(){
    
    fast;
    string s; cin>>s;
    for(ll i=0;i<sz(s)/2;++i) {
        if(s[i]!=s[sz(s)-1-i]) {
            cout <<"No"; return 0;
        }
    }
    string sb = s.substr(0,(sz(s)-1)/2);
    // cout << sb <<nl;
    for(ll i=0; i<sz(sb)/2;++i) {
        if(sb[i]!=sb[sz(sb)-1-i]) {
            cout <<"No"; return 0;
        }
    }
  //cout << sb << nl;
    sb = s.substr((sz(s)+3)/2-1,(sz(s)-1)/2);
    // cout << sb;
    for(ll i=0; i<sz(sb)/2;++i) {
        if(sb[i]!=sb[sz(sb)-1-i]) {
            cout <<"No"; return 0;
        }
    }
  //cout <<sb<<nl;
    cout <<"Yes";
	return 0;
}


Measured memory_bytes: 256
def nextPrime(x):

    for i in range(x, x*2):
        a = 0
        for w in range(2, i+1):
            if i%w ==0:
                break
            else:
                a = w
        if i == a + 1:
            return i if x != 2 else 2

def main():
    x = int(input())
    print(nextPrime(x))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
#include"bits/stdc++.h"

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
int INF=100000001;


int main(){
    int i,n;
    //入力
    cin>>n;
    //処理
    long sum=0;
    for(i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    //出力
    cout<<sum<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
  	Scanner s = new Scanner(System.in);
    int x = s.nextInt();
    s.close();
    
    int i = 1, j = 9;
    while (i <= j) {
      int p = i * j;
      if (p == x) {
        System.out.print("Yes");
      	return;
      }
      if (p < x) {
      	i++;
      } else {
      	j--;
      }
    }
    System.out.print("No");
    return;
  }
}

Measured memory_bytes: 21844
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
int x=0,y=0,z=0,w=0,n=0,d=0;
while(std::cin >> d){
  for(int i=1;i*d<=600-d;i++){
    y+=(i*d)*(i*d)*d;
  }
  std::cout << y<< '\n';
  y=0;
}
}



Measured memory_bytes: 3008
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n;
string s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    cin >> s;
    int res = 0;
    FOR(i,0,n-1) {
        if (i + 2 >= n) break;
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') res++;
    }
    cout << res;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

ll num[100];

ll luca_number(int n)
{
    if (num[n] != 0)
    {
        return num[n];
    }

    if (n == 0)
    {
        return num[n] = 2LL;
    }
    else if (n == 1)
    {
        return num[n] = 1LL;
    }
    return num[n] = luca_number(n - 1) + luca_number(n - 2);
}

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

    cout << luca_number(n) << endl;
    return 0;
}


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

int main(){
 int n;
  ll count=0;
  cin >> n;
  vector<int> v(n,0);
  r(i,n)cin >> v.at(i);
  r(i,n){
    if(i==v.at(v.at(i)-1)-1)count++;
  }
  cout << count / 2 << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    ok = [1] * N
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1

        if H[A] <= H[B]:
            ok[A] = 0
        if H[B] <= H[A]:
            ok[B] = 0

    print(sum(ok))

def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 20896
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define REP(n) for(int i = 0; i < n; i++)
#define all(p) p.begin(), p.end()
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
template<class X=int>inline X min(X a,X b,X c){return min(min(a,b),c);}
template<class X=int>inline X min(X a,X b,X c,X d){return min(min(a,b,c),d);}
template<class X=int> inline X max(X a,X b,X c){return max(max(a,b),c);}
template<class X=int> inline X max(X a,X b,X c,X d){return max(max(a,b,c),d);}
template<class X=int> inline X mid(X s,X e){return (s+(e-s)/2);}
template<class X=int> inline X len(X s,X e){return (e-s+1);}
const int MOD = 1e9 + 7;
const int INF = 987654321;
const bool TESTCASES = 0;
const bool CODEJAM = 0;

void solve()
{
	int L, R, d;
	cin >> L >> R >> d;
	int r = R/d;
	int l = (L - 1)/d;
	cout << r - l << "\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int T = 1;
	if(TESTCASES) cin >> T;
	for(int t = 1; t <= T; t++)
	{
		if(CODEJAM) cout << "Case #" << t << ": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

const long long MOD = 1e9 + 7;

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

	long long N, K;
	cin >> N >> K;

	long long result = 0;
	for (long long i = K; i <= N + 1; i++)
	{
		long long left = i * (i - 1) / 2;
		long long right = N * (N + 1) / 2 - (N - i) * (N - i + 1) / 2;
		long long count = right - left + 1;
		result = (result + count) % MOD;
	}

	cout << result % MOD;

	return 0;
}


Measured memory_bytes: 3652