akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#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 llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    int N,M,a,b;
    cin >> N >> M;
    bool ship_from_one_to[N+2];
    bool ship_to_N_from[N+2];
    rep(i,N+2){
        ship_from_one_to[i] = false;
        ship_to_N_from[i] = false;
    }
    rep(i,M){
        cin >> a >> b;
        if (a==1) ship_from_one_to[b]=true;
        if (b==N) ship_to_N_from[a]=true;
    }
    for(int i=2;i<N;i++){
        if (ship_from_one_to[i] && ship_to_N_from[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 640
n, q = map(int, input().split())
s = input()
ac = [0]*n

for i in range(1, n):
    if s[i]=="C" and s[i-1]=="A":
        ac[i]=1
    else:
        ac[i]=0

cnt = [0]*n
for i in range(1, n):
    cnt[i] += cnt[i-1] + ac[i]
for i in range(q):
    l, r = map(int, input().split())
    print(cnt[r-1]-cnt[l-1])


Measured memory_bytes: 8436
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  REP(i, N){
    cin >> C[i];
    REP(j, M){
      cin >> A[i][j];
    }
  }

  int ans = INF;
  REP(bit, (1<<N)){
    int ret = 0;
    vector<int> rikai(M, 0);
    REP(i, N){
      if((bit >> i)&1){
        ret += C[i];
        REP(j, M){
          rikai[j] += A[i][j];
        }
      }
    }

    REP(i, M){
      if(rikai[i] < X) break;
      if(i == M-1){
        chmin(ans, ret);
      }
    }
  }

  if(ans == INF) ans = -1;
  cout << ans << "\n";

  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] % 2 == 0)
        {
            a[i] /= 2;
            cnt++;
        }
    }
    if (cnt == n)
    {
        ans = 1;
    }
    while (cnt == n)
    {
        cnt = 0;
        ans++;
        for (int i = 0; i < n; i++)
        {
            a[i] /= 2;
            if (a[i] % 2 == 0)
            {
                cnt++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n,d,ans=0;
  cin >> n >> d;

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

  for(int i = 0; i < n; i++){
    for(int k = i+1; k < n; k++){
      double sum = 0;
      for(int j = 0; j < d; j++){
        sum += (tmp[i][j] - tmp[k][j]) * (tmp[i][j] - tmp[k][j]);
      }
      double sq = sqrt(sum);
      if(fmod(sq, 1) == 0) ans++;
    }
  }
  cout << ans<< endl;
}


Measured memory_bytes: 256
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;


my @a;
while (<>) {
    chomp;
    push @a, $_;
}
my @S = split "", shift @a;

my $ans = 10000000;
my $hoge;
for my $i (0 .. ($#S - 2)) {
    my $num = $S[$i] * 100 + $S[$i+1] * 10 + $S[$i+2];
    my $diff = abs($num - 753);
    if ($diff < $ans) {
        $hoge = $num;
        $ans = $diff;
    }
}

#for my $i (0 .. ($#S - 3)) {
#    my $num = $S[$i] * 1000 + $S[$i+1] * 100 + $S[$i+2] + $S[$i+3];
#    my $diff = abs($num - 753);
#    if ($diff < $ans) {
#        $hoge = $num;
#        $ans = $diff;
#    }
#}
say $ans;


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


int main() {
    ll n, a[MAX_N];
    bool f = false;
    cin >> n;
    REP(i,n)cin >> a[i];
    REP(i,n){
        f |= a[i]%2==1;
    }
    cout << (f?"first":"second") << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int n;
  cin>>n;
  int l[15];
  int sum=0;
  for(int i=0;i<n;i++)
  {
  cin>>l[i];
    sum+=l[i];
  }
  sort(l,l+n);
  reverse(l,l+n);
  cout<<(l[0]<sum-l[0] ? "Yes" :"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    ll ans=0;
    string s;
    cin>>s;
   rep(i,s.size()-1){
       if(s.at(i+1)==s.at(i)){
           ans++;
           if(s.at(i+1)=='0')s.at(i+1)='1';
           else s.at(i+1)='0';
       }
   }
   cout<<ans<<endl;
}
   



Measured memory_bytes: 512
#include <stdio.h>
int main()
{
    int a, s, m, h, S;
    scanf("%d", &S);
    h = S / 3600;
    a = S % 3600;
    m = a / 60;
    s = a % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}
    

Measured memory_bytes: 2756
const N=parse(Int,readline())
const P=map(x->parse(Int,x),split(readline()))
const A=zeros(Int,N)
const B=zeros(Int,N)
const Ta=zeros(Int,17,N)
function init()
	B[1]=1
	for i=1:N
		A[P[i]]=i
		if i>1
			B[i]=B[i>>1]+1
		end
		Ta[1,i]=P[i]
	end
	for k=2:17
		L=1<<(k-2)
		for i=1:N-L+1
			Ta[k,i]=Ta[k-1,i]
			if i+L+L<=N+1&&Ta[k,i]<Ta[k-1,i+L]
				Ta[k,i]=Ta[k-1,i+L]
			end
		end
	end
end
function query(L,R)
	b=B[R-L]
	X=max(Ta[b,L],Ta[b,R-(1<<(b-1))])
	X
end
init()
function main()
	ans=0
	for i=N-1:-1:1
		id=A[i]
		L1L=0
		L1R=id
		if id==1||query(1,id)<i
			L1R=0
		end
		while L1R-L1L>1
			L1M=div(L1R+L1L,2)
			if query(L1M,id)>i
				L1L=L1M
			else
				L1R=L1M
			end
		end
		L1=id-L1L
		L2L=0
		L2R=L1L
		while L2R-L2L>1
			L2M=div(L2R+L2L,2)
			if query(L2M,L1L)>i
				L2L=L2M
			else
				L2R=L2M
			end
		end
		L2=L1L-L2L
		R1L=id+1
		R1R=N+1
		if query(id,N+1)==i
			R1L=N+1
		end
		while R1R-R1L>1
			R1M=div(R1R+R1L,2)
			if query(id,R1M)>i
				R1R=R1M
			else
				R1L=R1M
			end
		end
		R1=R1L-id
		R2L=R1L+1
		R2R=N+1
		if R1R>N||query(R1R,N+1)<i
			R2L=N+1
		end
		while R2R-R2L>1
			R2M=div(R2R+R2L,2)
			if query(R1R,R2M)>i
				R2R=R2M
			else
				R2L=R2M
			end
		end
		R2=R2L-R1L
		ans+=i*(L1*R2+R1*L2)
	end
	println(ans)
end
main()

Measured memory_bytes: 166312
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        string s,t;
        cin>>s>>t;
        int ans=0;
        rep(i,0,3)
        if(s[i]==t[i]) ans++;
        cout<<ans;
    }   
}     

Measured memory_bytes: 256
def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

a, b, c = mi()

p = min(b, c)
ans = 2 * p
b -= p
c -= p
if c:
    ans += min(a, c)
    if c > a:
        ans += 1
if b:
    ans += b
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef pair<string, int> psi;
typedef vector<pair<psi, int> > vsi;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n; cin >> n;
  vsi res;
  rep(i,n) {
    string s;
    int p;
    cin >> s >> p;
    res.pb(mp(mp(s,-p), i+1));
  }
  sort(all(res));
  rep(i,n) {
    cout << res[i].ss << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
lis = list(map(int,input().split()))
co = 0
cou = 0
a = math.floor(sum(lis)/n)
b = math.ceil(sum(lis)/n)
for i in range(n):
  co += (abs(a-lis[i])) ** 2
  cou += (abs(b-lis[i])) ** 2
print(min(co,cou))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		for (int i = 111; i < 1000; i += 111) {
			if (N <= i) {
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;
vector<pair<P,int> > xv;
vector<pair<P,int> > yv;

int u[1000000]; 


int find(int x){
  if(x==u[x]){
    return x;
  }

  return u[x]=find(u[x]);
}

bool same(int x,int y){
  return find(x)==find(y);
}


void uni(int x,int y){
  int xr = find(x);
  int yr = find(y);
  if(xr!=yr) u[yr] = xr;
}

int main(){
  cin>>n;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    xv.push_back(make_pair(P(x,y),i));
    yv.push_back(make_pair(P(y,x),i));
  }

  rep(i,n){
    u[i]=i;
  }

  sort(xv.begin(),xv.end());
  sort(yv.begin(),yv.end());
  vector<pair<int,P> > v;

  rep(i,n){
    if(i!=0){
      v.push_back(make_pair(xv[i].first.first-xv[i-1].first.first,
        P(xv[i].second,xv[i-1].second)));
      v.push_back(make_pair(yv[i].first.first-yv[i-1].first.first,
        P(yv[i].second,yv[i-1].second)));
    }
  }
  sort(v.begin(),v.end());
  ll ans = 0;
  int c=0,i=0;

  while(c!=n-1){
    pair<int,P> p = v[i];
    int xr = p.second.first;
    int yr = p.second.second;

    if(!same(xr,yr)){
      uni(xr,yr);
      ans += p.first;
      c++;
    }
    i++;
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 7724
def main():
    import sys
    input = sys.stdin.readline
    
    N,M = map(int, input().split())
    X = list(map(int, input().split()))
    X = sorted(X)
    X = X[::-1]
    Y = []
    for i in range(M-1):
        Y.append(X[i]-X[i+1])
    Y = sorted(Y)
    Y = Y[::-1]
    
    Ans = X[0] - X[-1]
    for i in range(min(N-1,M-1)):
        Ans -= Y[i]
    print(Ans)
    
    
    
main()

Measured memory_bytes: 58848
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
use std::cmp::*;
// use std::num;
fn main() {
    input! {N:usize, A:[u64;N]}
    let mut sum = 0u64;
    for i in 2..N {
        sum ^= A[i];
    }
    //println!("{}", sum);
    // 残りの個数のXOR合計はsum。
    //    let mut ans = 0u64;
    //  let mut i = 0;
    let mut a0 = A[0];
    let mut a1 = A[1];
    let ans = sub(A[0], A[1], sum);
    if ans < A[0] {
        println!("{}", ans);
    } else {
        println!("{}", -1);
    }
}
fn sub(a: u64, b: u64, c: u64) -> u64 {
    if (a & 1) ^ (b & 1) != c & 1 {
        return std::u64::MAX;
    }
    if c == 0 {
        if a < b {
            return std::u64::MAX;
        } else {
            return (a - b) / 2;
        }
    }
    // case 0
    let mut x = sub(a / 2, b / 2, c / 2);
    // case 1
    let mut y = if a > 0 {
        sub((a - 1) / 2, (b + 1) / 2, c / 2)
    } else {
        std::u64::MAX
    };
    //println!("{},{},{},{},{}", a, b, c, x, y);
    if x < std::u64::MAX {
        x = x * 2;
    }
    if y < std::u64::MAX {
        y = y * 2 + 1;
    }
    return min(x, y);
}


Measured memory_bytes: 2176
#include <iostream>
#include <string> // 文字列を使う
using namespace std;

int main(void){
  string s;
  while(true) {
      cin >> s;
      if (s == "0") {
          break;
      }
      int d = 0;
      for(int i = 0; i < s.size(); i++) {
            // TODO: n 文字コード を数値に変換する
          int n = s[i] - '0';
          //cout << "'" << s[i] << "'" << n << endl;
          d += n;
      }
      cout << d << endl;
  }
}


Measured memory_bytes: 3232
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)

int main(){
  int h,w;
  string s;
  cin >> h >> w;
  REP(i,h){
    cin >> s;
    cout << s << endl << s << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d) out("Yes");
    else if(abs(a-b<=d&&abs(b-c)<=d)) out("Yes");
    else out("No");
    
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = 100 + (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

int count(int n){
	int nnd = to_string(n).size();
	int res = 0;
	
	
	for(int nd = 1, low = 1, high = 10; nd <= nnd; nd++, low *= 10, high *= 10){
		if(nnd == nd) high = n + 1;
		
		int fizz = 0, buzz = 0, fizzbuzz = 0, other = 0;
		
		fizz = (high - 1)/3 - (low - 1)/3;
		buzz = (high - 1)/5 - (low - 1)/5;
		fizzbuzz = (high - 1)/15 - (low - 1)/15;
		other = high - low - fizz - buzz + fizzbuzz;
		
		res += (fizz + buzz) * 4 + other * nd;
	}
	
	return res;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	int s;
	string ans;
	
	cin>>s;
	
	string test;
	
	
	int low = 1, high = INF, med;
	
	while(low + 1 < high){
		med = (low + high)>>1;
		
		if(count(med) < s) {
			low = med;
		} else {
			high = med;
		}
	}
	
	for(int i = low; i < low + 100; i++){
		
		if(i % 3 == 0) ans += "Fizz";
		if(i %  5 == 0) ans += "Buzz";
		if(i % 3 && i % 5) ans += to_string(i);
	}
	
	
	int b =  s - count(low-1) - 1;
	
	for(int i = b; i < b + 20; i++){
		cout<<ans[i];
	}
	
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 3300
import math
while True:
    n = int(input())
    if n == 0:
        exit()
    s = list(map(int, input().split()))
    ave = float(sum(s) / n)
    r = 0
    for j in range(n):
        r += float(pow(s[j] - ave, 2))
    print(math.sqrt(r / n))



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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (writeln!(out,$($format)*).unwrap());
    }
    macro_rules! put {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
    }
    let mut m = 0;
    for s in 2.. {
        let e = s*(s-1);
        if e == 2*n {
            m = s;
            break;
        } else if e > 2*n {
            break;
        }
    }
    if m == 0 {
        return puts!("{}", "No");
    }

    puts!("{}", "Yes");
    puts!("{}", m);

    let mut ans = vec![vec![0;m-1]; m];
    let mut cur = 0;
    for i in 0..m-1 {
        for j in 0..m-1-i {
            cur += 1;
            ans[i][j+i] = cur;
            ans[j+1+i][i] = cur;
        }
    }
    debug!(ans);
    for a in ans {
        put!("{} ", a.len());
        for v in a {
            put!("{} ", v);
        }
        puts!("");
    }
}


Measured memory_bytes: 5500
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long v = sc.nextLong();
    long b = sc.nextLong();
    long w = sc.nextLong();
    long t = sc.nextLong();
    if ((v - w) * t >= Math.abs(a - b)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 35728
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <string>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const ll inf = 1e14;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  int n = a.size();
  VL lft(n, inf), rgt(n, inf);
  REP(i, 0, n) {
    ll r = i, l = (n - i) % n;
    REP(j, 0, n) {
      if (b[(i + j) % n] == '1') {
        lft[j] = min(lft[j], l);
        rgt[j] = min(rgt[j], r);
      }
    }
  }
  ll mi = inf;
  // <==---0=====>
  REP(stop, -n + 1, n) {
    vector<PL> pool;
    REP(i, 0, n) {
      if (b[(i + stop + n) % n] != a[i]) {
        pool.push_back(PL(lft[i], rgt[i]));
      }
    }
    sort(pool.begin(), pool.end());
    int m = pool.size();
    VL rma(m + 1, 0);
    for (int i = m - 1; i >= 0; --i) {
      rma[i] = max(rma[i + 1], pool[i].second);
    }
    REP(l, max(0, -stop), n) {
      int idx = upper_bound(pool.begin(), pool.end(), PL(l, inf + 1))
        - pool.begin();
      ll rmax = rma[idx];
      rmax = max(rmax, (ll)stop);
      mi = min(mi, 2 * (l + rmax) - abs(stop) + m);
    }
  }
  cout << (mi >= inf ? -1 : mi) << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;
#define REP(i,n) for (int i = 0; i < n; ++i)

const int MAX = 110;
int N;
int H[MAX];

int main() {
    cin >> N;
    REP (i, N) cin >> H[i];
    int count = 0;
    int start = 0;
    while (start < N) {
        int j = start;
        if (H[j] == 0) {
            start++;
            continue;
        }
        while (j < N) {
            if (H[j] == 0)
                break;
            H[j]--;
            j++;
        }
        count++;
    }
    cout << count << endl;
}

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

int main(){
    ll A,B; cin >> A >> B;
    if(A<B) swap(A,B);
    ll kake=A*B;
    ll ama=A%B;
    
    while(1){
        if(ama==0) break;
        else{
            A=B;
            B=ama;
            ama=A%B;
        }
    }
    cout << kake/B;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s,answer="";
    cin >> s;
    REP(i,s.length()){
        if(i%2==0)answer+=s[i];
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 512
from collections import deque
n = int(input())
dlist = deque()
for i in range(n):
    code = input().split()
    if code[0] == "insert":
        dlist.insert(0,code[1])
    if code[0] == "delete":
        try:
            dlist.remove(code[1])
        except:
            continue
    if code[0] == "deleteFirst":
        dlist.popleft()
    if code[0] == "deleteLast":
        dlist.pop()
print(*dlist,sep=" ")

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

int main(){
	int a,b,k;
	cin>>a>>b>>k;
	if(b-a+1<k*2){
		for(int i=a;i<=b;i++){
			cout<<i<<endl;
		}
		return 0;
	}
	for(int i=0;i<k;i++){
		cout<<a++<<endl;
	}b-=k;
	for(int i=0;i<k;i++){
		cout<<++b<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}

int main()
{
  int x;
  cin >> x;
  while (true) {
    if(is_prime(x)) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
    
    
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int n, m;
vector<vector<int>> g;
vector<bool> vis;
void dfs(int u) {
    if (vis[u]) return;
    vis[u] = true;
    for (int v : g[u]) {
        dfs(v);
    }
}

int main() {
    cin >> n >> m;
    g.resize(n + 1);
    for (int i = 0; i < m; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    vis.resize(n + 1);
    int ans = 0;
    for (int u = 1; u <= n; ++u) {
        if (!vis[u]) {
            ++ans;
            dfs(u);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#include <iostream>
// #include <unordered_map>
#define vi vector <ull>
#define ii pair<ull,ull>
#define vii vector<ii>

#define seti set<ull>
#define mii map<ull,ull>
#define um unordered_map
#define ull long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 100100
#define _ << " " <<

using namespace std;





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


	ull dp[n];
	for(int i = 0; i < n; i++){
		dp[i] = 1e10;
	}

	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j <= min(i+2, n-1); j++){
			dp[j] = min(dp[j], dp[i] + abs(a[i]-a[j])); 
		}
	}

	cout << dp[n-1];

	
}


int main(){
	// freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ull q;
	// cin >> q;
	q = 1;
	for(ull i = 0; i < q; i++){
		// cout << "Case #" << i+1 << ":" << endl;

		solve();
		// cout << endl;
	}

	

	return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef vector<int> vi;
typedef vector<long long int> vl;
#define pb push_back
#define mp make_pair

ll dpx[3001][3001];
ll dpy[3001][3001];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	
	int n;
	cin >> n;

	vi a(n+1, 0);
	for(int i=0;i<n;i++) cin >> a[i];

	
	for(int j = 0;j<n;j++){
		dpx[j][j] = a[j];
		dpy[j][j] = -a[j];
		for(int i=j-1;i>=0;i--){
			dpx[i][j] = max(a[i]+dpy[i+1][j], dpy[i][j-1]+a[j]);
			dpy[i][j] = min(dpx[i+1][j]-a[i], dpx[i][j-1]-a[j]);
		}
	}
	
	cout << dpx[0][n-1] << endl;
	return 0;
}



Measured memory_bytes: 139776
#include <stdio.h>
#define MOD 1000000007
int main()
{   int n;
    scanf("%d",&n);
    int cnt[1001]={0};
    for(int i=n;i>0;i--){
        int cpy=i;
        for(int j=2;j<=i;j++){
            while(cpy%j==0&&cpy>0){
                cpy/=j;
                cnt[j]++;
                }
            }
            if(cpy>1){
                cnt[cpy]++;
                printf("cnt%dincre\n",cpy);
        }
    }
    /*for(int i=2;i<=n;i++){
        printf("cnt[%d]=%d\n",i,cnt[i]);
    }*/
    long long ans=1;
    for(int i=2;i<=n;i++){
        ans*=(cnt[i]+1);
        ans%=MOD;
        }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
xy = [list(map(int,input().split())) for _ in range(m)]

cnt = [1] * n
r = [1] + [0] * (n-1)
for x, y in xy:
    cnt[x-1] -= 1
    cnt[y-1] += 1
       
    if r[x-1] == 1:
        r[y-1] = 1
        
    if cnt[x-1] == 0:
        r[x-1] = 0
    
print(sum(r))


Measured memory_bytes: 62680
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

int mod = 1e9 + 7;

int power(int x, int y)
{
	int res = 1;
	while(y) {
		if(y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}

int ncr(int n,int r)
{
	int res = 1;
	if(r > n - r)
		r = n - r; 

	for(int i = 0; i < r; i++)
	{
		res = res * (n-i) % mod;
	    res = res * power(i + 1, mod - 2) % mod;
	}
	return res;
} 

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
    	int n, a, b;
    	cin >> n >> a >> b;

    	int ans = ( power(2, n) - 1 - ncr(n, a) - ncr(n, b) + 10 * mod ) % mod;
    	cout << ans << '\n';
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j,c,d=0;
  scanf("%d",&n);
  for(i=1;i<=n;i+=2){
    c=0;
    for(j=1;j<=n;j++){
      if(i%j==0)c++;
    }
    if(c==8)d++;
  }
  printf("%d\n",d);
  return 0;
}


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

int main()
{
	int a,b;
	cin >> a >> b;
	if (a == b) cout << "Draw" << endl;
	else if (a == 1) cout << "Alice" << endl;
	else if (b == 1) cout << "Bob" << endl;
	else if (a > b) cout << "Alice" << endl;
	else cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

struct Edge {
    ll to;     // 辺の行き先
    ll weight; // 辺の重み
    Edge(ll t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge> >;

ll dp[MAX][20];
// dp[i][j] は　集合iは通過済み、現在j にいる状態から後どれくらいで一周できるか
ll d[20][20];

int main() {
    // 頂点数と辺数
    ll N, M; cin >> N >> M;

    rep(i,20) rep(j,20) d[i][j] = INF;
    rep(i,M) { ll a,b,c; cin >> a >> b >> c; d[a][b] = c; }


    rep(i,MAX) rep(j,20) dp[i][j] = INF;
    dp[(1 << N) - 1][0] = 0;
    // 全て通過済みで0にいる、完了状態
    for(ll S = (1 << N) - 2; S >= 0; S--){
      // たくさんの点を通っている時から逆算する
      rep(v,N){
        // vからの最短経路を逆算する
        rep(u,N){
          if(!(S >> u & 1)){
            // v から　uにいく時　もしかしたら最善 ?
            dp[S][v] = min(dp[S][v] , dp[S | 1 << u][u] + d[v][u]);
          }
        }
      }
    }
    /*
    rep(i,1 << N){
      rep(j,N){
        cout << i << " " << j << " " << dp[i][j] << endl;
      }
    }
    */
    if(dp[0][0] == INF) cout << -1 << endl;
    else cout << dp[0][0] << endl;

}



Measured memory_bytes: 82788
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define mkp make_pair
#define pb push_back
#define endl '\n'
#define mod 1000000007
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
lld power(lld b, lld e)
{
    if(e==0)
        return 1;
    if(e%2==1)
        return b*power(b*b,(e-1)/2);
    else
        return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else
		return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n<0) 
		n*=-1;
	if(n==0)
		return 1;

    return floor(log10(n) + 1);
}

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

void swagWaalaFunction()
{
	string s;
	cin>>s;

	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes";
	else
		cout<<"No";
	return;
}

int main()
{
    SPEEDUP;
 	lld t=1;
 	//cin>>t;

 	while(t--)
 		swagWaalaFunction();

 	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    vector<pair<string,int> >v;
    map<int,int>mp;
    for(int i=1;i<=n;i++)
    {
        string str;
        cin>>str;
        int k;
        cin>>k;
        mp[k]=i;
        v.push_back(make_pair(str,k));
    }

    for(int i=0;i<v.size();i++)
    {
        for(int j=i+1;j<v.size();j++)
        {
            if(v[i].first>v[j].first)
            {
                swap(v[i].first,v[j].first);
                swap(v[i].second,v[j].second);
            }
            else if(v[i].first==v[j].first&&v[i].second<v[j].second)
            {
                 swap(v[i].first,v[j].first);
                swap(v[i].second,v[j].second);
            }
        }
    }
    for(int i=0;i<v.size();i++)
    {
        //cout<<v[i].first<<endl;
        cout<<mp[v[i].second]<<endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int func(int n){
    while(n>9){
        n /=10;
    }
    return n;
}

int main(){
    int n; cin >> n;
    int cnt[10][10];
    rep(i, 10)rep(j,10) cnt[i][j] = 0;

    for(int i=1; i<=n; i++){
        int f = func(i), e = i%10;
        cnt[f][e]++;
    }
    ll res= 0;
    for(int i=1; i<=n; i++){
        int f = func(i), e = i%10;
        res += cnt[e][f];
    }
    cout << res << ln;
}



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

int main(){
    string N;
    cin>>N;
    
    int sum=0;
    for(const char &n:N){
        sum+=n-'0';
    }
    cout<<(sum%3==0?"Yes":"No")<<endl;
}


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

using namespace std;
typedef long long ll;
const ll p = 1e9 + 7;
const int N = 1e6 + 10;
ll dp[N];
ll sum_dp;

ll add(ll a, ll b) {
    a += b;
    if (a >= p)
        a -= p;
    return a;
}

ll sub(ll a, ll b) {
    a -= b;
    if (a < 0)
        a += p;
    return a;
}

ll mul(ll a, ll b) {
    return (a * b) % p;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    dp[0] = n;
    dp[1] = mul(n, n);
    sum_dp = add(dp[0], dp[1]);
    for (int i = 2; i < n; i++) {
        dp[i] = mul(n - 1, n - 1);
        dp[i] = add(dp[i], sum_dp);
        dp[i] = sub(dp[i], dp[i - 2]);
        dp[i] = add(dp[i], n - i + 1);
        sum_dp = add(sum_dp, dp[i]);
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	string x;
	cin >> x;
	ll N = x.size();
	ll sum[N+5];
	sum[0] = 0;
	for(int i=1;i<=N;i++){
		sum[i] = i + sum[i-1];
	}
	ll ans = sum[N-1] + 1;
	ll cnt[27];
	memset(cnt,0,sizeof cnt);
	for(int i=0;i<x.size();i++){
		int a = (x[i] - 'a');
		cnt[a]++;
	}
	for(int i=0;i<26;i++){
		int gg = max(cnt[i]-1,(ll)0);
		ans = ans - sum[gg];
	}
	cout << ans << "\n";
}



Measured memory_bytes: 2180
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var b = readLine()!!.split(" ").map(Integer::parseInt)

    val ans = mutableListOf<Int>()

    for (i in n - 1 downTo 0) {
        var v = -1
        for (j in 0..i) {
            if (b[j] == j + 1) {
                v = if (v > j + 1) v else j + 1
            }
        }
        if (v == -1) {
            println(-1)
            return
        }
        ans.add(v)
        b = b.filterIndexed { index, value ->
            index != v - 1
        }
    }

    println(ans.reversed().joinToString(separator = "\n"))
}



Measured memory_bytes: 37824
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int N_MAX = 10;
typedef pair<int,int> P;
int main()
{
  int n;
  cin >> n;
  int s=0;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l[i];
    s+=l[i];
  }
  int m=*max_element(l.begin(),l.end());
  if(m*2>=s)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
 
 
def input():
    return sys.stdin.readline().strip()
 
 
sys.setrecursionlimit(20000000)
 
 
def main():
    N, W = map(int, input().split())
    B = [list(map(int, input().split())) for _ in range(N)]
    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i in range(N):
        w = B[i][0]
        v = B[i][1]
        for j in range(W + 1):
            if j >= w:
                dp[i + 1][j] = max(dp[i][j - w] + v, dp[i][j])
            else:
                dp[i + 1][j] = dp[i][j]
    print(dp[-1][-1])
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 118128
using System;

namespace D___Dice_in_Line
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var k = int.Parse (input[1]);
            input = Console.ReadLine ().Split (' ');
            var p = new double[n];
            for (var i = 0; i < n; i++)
            {
                p[i] = int.Parse (input[i]);
            }
            var s = new double[n];
            var a = 0.0;
            for (var i = 0; i < n; i++)
            {
                a += (1 + p[i]) / 2;
                s[i] = a;
            }
            var max = s[k - 1];
            for (var i = 0; i + k < n; i++)
            {
                max = Math.Max (max, s[i + k] - s[i]);
            }
            Console.WriteLine (max);
        }
    }
}

Measured memory_bytes: 31708
def reconstruction(l, r)
  if l >= r
    return
  end
  c = $preorders.shift
  m = $inorders.index(c)

  reconstruction(l, m)
  reconstruction(m + 1, r)

  $postorders << c
end

n = gets.to_i
$preorders = gets.split.map(&:to_i)
$inorders = gets.split.map(&:to_i)
$postorders = []

reconstruction(0, n)

puts $postorders.join(" ")


Measured memory_bytes: 6860
#include<stdio.h>
int main()
{
    int a,b;
    while(scanf("%d",&a)!=EOF)
    {
        scanf("%d",&b);
        int r;
        r=b;
        while(a%b)
        {
            r=a%b;
            a=b;
            b=r;
        }
        printf("%d\n",r);
    }
}



Measured memory_bytes: 2076
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,ma,mi;
    cin >> a >> b >> c;
    ma=mi=a;
	if(b>ma)
        ma=b;
    if(c>ma)
        ma=c;
    if(b<mi)
        mi=b;
    if(c<mi)
        mi=c;
    cout << ma*10+(a+b+c-ma-mi)+mi << endl;
	return 0;
}


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

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

// https://www.wolframalpha.com/input/?i=Sum%5Bk%2F16*+(15%2F16)%5E(k-1)+,+%7Bk,+1,+inf%7D%5D
// https://www.wolframalpha.com/input/?i=Sum%5Bk%2Ft*+((t-1)%2Ft)%5E(k-1)+,+%7Bk,+1,+inf%7D%5D
signed main() {
    ll N,M;
    cin>>N>>M;
    cout<<(1900*M + 100*(N-M))*pow(2,M)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
 
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
 
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
 
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
 
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
 


int a[4];


int main(){
  int N;
  cin >> N;
  vector<P> p(N);
  rep(i,N) {
    int a,b;
    cin >> a >> b;
    p[i] = (make_pair(b,a));
  }
  bool f = true;
  sort(p.begin(),p.end());
  int now=0;
  rep(i,N){
    now += p[i].second;
    if(now>p[i].first) f = false;
  }
  cans(f);
}



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

n, m, x = MAP()
arr = [LIST() for _ in range(n)]
c = [arr[i][0] for i in range(n)]
a = [arr[i][1:] for i in range(n)]

ans = inf
for i in range(2 ** n):
    tmp = [0 for _ in range(m)]
    cst = 0
    for j in range(n):
        if i - (i >> (j + 1)) * (2 ** (j + 1)) >= 2 ** j:
            for k in range(m):
                tmp[k] += a[j][k]
            cst += c[j]
    flag = True
    for j in range(m):
        if tmp[j] < x:
            flag = False
    if flag:
        ans = min(ans, cst)
if ans == inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 70284
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			TreeMap<Integer,Integer> S = new TreeMap<>();
			int c = 0;
			int q = sc.nextInt();
			for(int i = 0; i < q; i++) {
				int cmd = sc.nextInt();
				Integer x = sc.nextInt();
				if(cmd == 0) {
					Integer n = S.getOrDefault(x, 0);
					S.put(x, n+1);
					System.out.println(++c);
				}
				else if(cmd == 1){
					Integer n = S.getOrDefault(x, 0);
					System.out.println(n);
				}
				else if(cmd == 2) {
					Integer n = S.getOrDefault(x, 0);
					S.remove(x);
					c-=n;
				}
				else /* cmd == 3 */{
					int r = sc.nextInt();
					S.subMap(x,true, r, true).forEach((k,v)->{
						for(int j = 0; j <v; j++) System.out.println(k);
					});
				}
			}
		}
	}
}



Measured memory_bytes: 163936
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[101][100001];
ll getTheMaximum(ll N,ll W,ll a[][2]){
    //base case
    if(N==0 && W>=a[N][0]){
        return dp[N][W]=a[N][1];
    }else if(N==0 && W<a[N][0]){
        return dp[N][W]=0;
    }

    if(dp[N][W]!=0){
        return dp[N][W];
    }
        
    dp[N][W]=0;
    if(W<a[N][0]){
        dp[N][W]=getTheMaximum(N-1,W,a);
    }
    else{
        dp[N][W]=max(getTheMaximum(N-1,W,a),a[N][1]+getTheMaximum(N-1,W-a[N][0],a));
    }
    return dp[N][W];
}
int main() {
	// your code goes here
	ll n,W;
	cin>>n>>W;
	memset(dp,0,sizeof(dp));
	ll a[n][2];
	for(ll i=0;i<n;i++)
	    cin>>a[i][0]>>a[i][1];
	cout<<getTheMaximum(n-1,W,a);
	return 0;
}


Measured memory_bytes: 79104