akhauriyash/Code-Regression huggingface dataset:
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    string s;
    cin>>s;
    int qq,x=0;
    cin>>qq;
    deque <char> q;
    for(char ch:s)
    q.push_back(ch);
    while(qq--)
    {
        int typ;
        cin>>typ;
        if(typ==1)
        x++;
        else
        {
            int t2;
            char c;
            cin>>t2>>c;
            t2=2-t2;
            if(x%2==t2)
            q.push_back(c);
            else
            q.push_front(c);
        }
    }
    if(x%2)
    {
        while(!q.empty())
        {
            cout<<q.back();
            q.pop_back();
        }
    }
    else
    {
        while(!q.empty())
        {
            cout<<q.front();
            q.pop_front();
        }
    }
}


Measured memory_bytes: 3976
import sys

inf = 1<<30

def solve():
    while 1:
        n, m, a = map(int, sys.stdin.readline().split())

        if n == m == a == 0:
            return

        amida = [tuple(map(int, sys.stdin.readline().split())) for i in range(m)]
        amida.sort()

        while amida:
            h, p, q = amida.pop()

            if p == a:
                a = q
            elif q == a:
                a = p

        print(a)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 7852
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
const int biggg = 2000000000;
const long long bigggest = 1000000000000000000LL;
const double eps = .0000000001;

vector<long long> pos;
vector<long long> neg;
long long n, k;
long long func(long long goal, vector<long long>& vec){
    // for each
    long long sum = 0;
    int r = vec.size()-1;
    for (int i=0; i<vec.size(); i++){
        while (r > i && vec[i]*vec[r] >= goal) r--;
        sum += max(0, r-i);
    }
    return sum;
}
long long func2(long long goal){
    long long sum = 0;
    int r = 0;
    for (int i=pos.size()-1; i>=0; i--){
        while (r <neg.size() && neg[r]*pos[i] >= goal) r++;
        sum += neg.size()-r;
    }
    return sum;
}

int main ()
{
  prep();
  
  cin >> n >> k;
  long long arr[n];
  for (int i=0; i<n; i++){
      cin >> arr[i];
      if (arr[i] >= 0) pos.push_back(arr[i]);
      else neg.push_back(arr[i]);
  }
  sort(pos.begin(), pos.end());
  sort(neg.rbegin(), neg.rend());
  long long l = -bigggest-1, r = bigggest+1, lastgood = -1;
  while (l<=r){
    long long mid = (l+r)/2;
    // how many are over mid, if it's less than k, is good
    long long sum = func(mid, pos)+func(mid, neg)+func2(mid);
    //cout << mid << " " << sum << endl;
    if (sum >= k) r = mid-1;
    else{
        l = mid+1;
        lastgood = mid;
    }
  }
  cout << lastgood;
  return 0;
}

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

	int i,j,H,W;

	for(;;){

		scanf("%d%d",&H,&W);

		if(H==0,W==0)break;

		for(j=0;j<H;j++){
			for(i=0;i<W;i++){

				if(i==0||j==0||j==(H-1)||i==(W-1))printf("#");

				else printf(".");

			}

			printf("\n");

		}

		printf("\n");

	}

	return 0;

}

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

int main() {
  int A,B,C,D;

  cin >> A >> B >> C >> D;

  if(A+B > C+D ) cout << "Left" << endl;
  else if(A+B == C+D ) cout << "Balanced" << endl;
  else if(A+B < C+D ) cout << "Right" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> ab(n);
    vector<tuple<ll, ll, ll>> cd(m);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        ab[i] = {a, b};
    }
    rep(i, m) {
        ll c, d;
        cin >> c >> d;
        cd[i] = make_tuple(i, c, d);
    }
    rep(i, n) {
        ll min = 1e18;
        int tmp = 0;
        rep(j, m) {
            if (abs(ab[i].first - get<1>(cd[j])) + abs(ab[i].second - get<2>(cd[j])) < min) {
                min = abs(ab[i].first - get<1>(cd[j])) + abs(ab[i].second - get<2>(cd[j]));
                tmp = get<0>(cd[j])+1;
            }
        }
        cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
    int n, h, s = 0, x;
    cin >> h >> n;
    for (int i = 0; i < n; ++i){
        cin >> x;
        s += x;
    }
    if (s >= h)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

int main(int argc, void **argv)
{
	long long a, b, c, x;

	scanf("%lld %lld %lld", &a, &b, &c);

    if( a == b ) {
        x = c;
    } else {
        x = c - (a - b);
        if( x < 0 ) x = 0;
    }
    printf("%lld\n", x);

	return 0;
}


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;
use std::collections::HashMap;

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

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    type Graph = Vec<Vec<usize>>;
    let n: usize = read();
    let x: usize = read();
    let y: usize = read();
    let mut G: Graph = vec![Vec::new(); n];
    for i in 0..n-1 {
        G[i].push(i+1);
        G[i+1].push(i);
    }
    G[x-1].push(y-1);
    G[y-1].push(x-1);

    let mut dist:Vec<Vec<i32>> = vec![vec![-1; n];n];
    let mut queue: VecDeque<usize> = VecDeque::new();

    //各頂点からその他への頂点への最短距離をBFSで求める
    //ただし逆向きですでに求めた部分は処理しない

    for i in 0..n {
        dist[i][i] = 0;
        queue.push_back(i);

        while !queue.is_empty() {
            let v = queue.pop_front().unwrap();
            for nv in G[v].iter() {
                if dist[i][*nv] == -1 {
                    dist[i][*nv] = dist[i][v] + 1;
                    queue.push_back(*nv);
                }
            }
        }
    }

    let mut scores = HashMap::new();

    for i in 0..n {
        for j in i+1..n{
            //println!("dist{}",dist[i][j] );
            let count = scores.entry(dist[i][j]).or_insert(0);
            *count += 1;
        }
    }
    //println!("{:?}",G);
    //println!("{:?}",dist);
    for i in 1..n {
        println!("{}", scores.get(&(i as i32)).unwrap_or(&0));
    }


}


Measured memory_bytes: 20732
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = (1 << 31) - 1;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
vl A;

void input() {
	cin >> n;
}


void solve() {
	rep(i, 10) {
		rep(j, 10) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return;
			}
		}
	}

	cout << "No" << endl;

}

int main() {
	input();
	solve();
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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 const INF = 1001001001;


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

map<string,int> mp;
int N,M;
cin >> N;
rep(i,N) {
    string s;
    cin >> s;
    mp[s] = mp[s] + 1;
}
cin >> M;
rep(i,M) {
    string t;
    cin >> t;
    mp[t] = mp[t] - 1;
}

int ans = 0;
for(auto x : mp) {
    chmax(ans, x.second);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<memory.h>
using namespace std;
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define pf printf
#define sf scanf
#define pb push_back
#define MAX 1000005
#define FOR(i,n) for(i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define mod7 1000000007
typedef long long int ll;
typedef long double lld;
const double PI=2*acos(0.0);
int CASE=1,TEST=0;
struct vpair{
    int a;
    int b;
    vpair(int a,int b){this->a=a;this->b=b;}
};
bool cmp(vpair &a,vpair &b){
    if(a.a<b.a)return true;
    else if(a.a==b.a){
        if(a.b<b.b)return true;
        else return false;
    }else{
        return false;
    }
}
bool endsWith(const string &mainStr, const string &toMatch){
	if(mainStr.size()>=toMatch.size() && mainStr.compare(mainStr.size()-toMatch.size(),toMatch.size(),toMatch)==0)return true;
		else return false;
}
int n,m,a,b,c,ans;
ll x,y,i;
string s;

int main(void){
    cin>>x>>y;
    for( i=0;x<=y;i++){
        x=(x*2);
    }
    cout<<i<<endl;
    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    map<int, int> mp;
    REP(i, n) mp[a[i]]++;
    int ans = 0;
    for(auto x: mp) if(x.second & 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <limits>
#include <cassert>

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	double N = 0, X = 0, T = 0;		
	cin >> N >> X >> T;
	int res = ceil(N/X)*T;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)


const ll INF = 10010001010;
const int inf = 1000034000;

typedef tuple<string, int, int> TUP;

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

int main()
{
   char A;
    cin >> A;
    if(isupper(A)){
        cout << "A" << endl;
    }
    else{
        cout << "a" << endl;
    }
}


Measured memory_bytes: 3620
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int k=sc.nextInt();
  int ans=0;
  for(int i=0;i<n;i++)
  if(k<=sc.nextInt())ans++;
  System.out.println(ans);
}
}

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

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

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

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

int main()
{
    int h,w;
    cin >> h >> w;
    char f[h][w];
    rep(i,h){
        rep(j,w) cin >> f[i][j];
    }
    int dp[h][w];
    rep(i,h) rep(j,w) dp[i][j] = inf;
    if(f[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;
    rep(i,h){
        rep(j,w){
            rep(k,2){
                int ny = i + dy[k];
                int nx = j + dx[k];
                if(ny < h && nx < w){
                    int add = 0;
                    if(f[ny][nx] == '#' && f[i][j] == '.') add++;
                    dp[ny][nx] = min(dp[ny][nx],dp[i][j]+add);
                }
            }
            
        }
    }
    cout << dp[h-1][w-1];
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i64 n,m,k; cin >> n >> m >> k;
    vl a_csum(n+1), b_csum(m);
    rep1(i,n) cin >> a_csum[i];
    rep(i,m) cin >> b_csum[i];
    for(i32 i = 0; i < n; ++i) a_csum[i+1] += a_csum[i];
    for(i32 i = 1; i < m; ++i) b_csum[i] += b_csum[i-1];
//
//    rep(i,n) cout << a_csum[i] << ' '; cout << '\n';
//    rep(i,m) cout << b_csum[i] << ' '; cout << '\n';

    i32 ans = 0;
    for(i32 i = 0; i <= n; ++i) {
        i64 sum = k - a_csum[i];
        if(sum < 0) break;
        i32 idx = upper_bound(all(b_csum), sum) - b_csum.begin();
//        debug(i);
//        debug(a_csum[i]);
//        debug(sum);
//        debug(idx);
//        debug(upper_bound(all(b_csum), 310) - b_csum.begin());
        chmax(ans, i + idx);
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 6420
#include<stdio.h>
int main()
{
	int i,n;
	char a[100],b[100];
	scanf("%d",&n);
	scanf("%s%s",a,b);
	for(i=0;i<n;i++)
	{
		printf("%c",a[i]);
		printf("%c",b[i]);
	}
 } 

Measured memory_bytes: 128
import numpy as np
import sys

def split_(arr, ite):
    new = [arr[:ite[0]]]
    if len(ite)==1:
        if ite[0]==len(arr)-1:
            return new
        else:
            new.append(arr[ite[0]+1:])
            return new
    else:
        for i in range(1,len(ite)):
            new.append(arr[ite[i-1]+1:ite[i]])
        if ite[-1]==len(arr)-1:
            return new
        else:
            new.append(arr[ite[-1]+1:])
            return new

n = int(input())
h = [np.array(list(map(int, input().split())))]

ans = 0
while h:
    if len(h[0])==1:
        ans += h[0][0]
        h.pop(0)
    else:
        m = min(h[0])
        ans += m
        h[0] -= m
        filtered = list(filter(lambda x: h[0][x]==0, range(len(h[0]))))
        splited = split_(h[0], filtered)
        h.pop(0)
        for s in splited:
            if len(s)>0:
                h.append(s)
print(ans)

Measured memory_bytes: 12480
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
ll a[1009];
map<ll,ll>left3;
map<ll,ll>right3;
vector<ll>dog;
map<ll,char>change;
char str[1000009];
ll pow26(ll n)
{
  ll x=26,i,j,k,l=1;
  for(i=1;i<=n;i++)
  {
     l=l*x;	
  }
  return l;	
}
int main()
{
  ll i=1,j,k,l,p=0,q,r,s,t,u=0,v,w,x,y,z=26,xyz=-1,n,m,lef=0,rigt=0,sum=0,sum2=0,val=10000000000000009,ans=1,pos;
  
  
  char cp='a';
  while(sum<=val)
  {
      ans=ans*z;
      sum=sum+ans;
      dog.push_back(sum);
      	
  } 
  cin>>n;
  for(i=0;i<dog.size();i++)
  {
   // cout<<dog[i]<<'\n';	
     if(dog[i]<=n)
     {
        p=i+1;
        q=n-dog[i];	
     }	
  }
 // s=dof
 if(q>0)
   p++;
 //cout<<p<<'\n';  
 for(i=0;i<p;i++)
 {
   u=u+pow26(i);
//   cout<<pow26(i)<<" "<<u<<'\n';
   	
 }
// cout<<u<<'\n';
 v=n-u;
 //cout<<v<<'\n';
 for(i=0;i<p;i++)
 {
   w=v%z;
   pos=w;
   cp=char(pos+'a');
   str[i]=cp;
   v=v/z;	
 }
 for(i=p-1;i>=0;i--)
 cout<<str[i];
  
  
   
  	
  
}

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

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> p(N,0);
    rep(i,N){
        cin >> p[i];
    }
    vector<ll> memo(N-K+1,0);
    //double E=0;
    //sort(p.begin(),p.end());
    rep(i,K){
        //memo[0] += (1+p[i])/double(2.0);
        memo[0] += ll(ll(1)+p[i]);
    }

    for(int i=1; i<N-K+1;i++){
        //memo[i] = memo[i-1] - (1+p[i-1])/double(2.0) + (1+p[i+K-1])/double(2.0);
        memo[i] = memo[i-1] - ll(ll(1)+p[i-1]) + ll(ll(1)+p[i+K-1]);
    }
    sort(memo.begin(),memo.end());

    cout<< setprecision(10) << memo[N-K]/double(2.0) <<endl;
}


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

using namespace std;

typedef vector <int> vi;
typedef vector <vi> vvi;

vvi adjList;
int e, n;

int main(){
    cin >> n >> e;
    adjList.assign(n + 1, vi());

    while(e--){
        int u, v;
        cin >> u >> v;
        adjList[u].push_back(v);
    }

    int u = 1;
    for(int v : adjList[u]){
        for(int w : adjList[v]){
            if(w == n){
                cout << "POSSIBLE";
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE";
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
using namespace std; typedef long long ll;
int main() {
	int N; cin >> N;
	queue <ll>q;
	rep( i, 1, 10 )
	q.push( i );
	rep( i, 0, N - 1 ){
		ll front = q.front(); q.pop();
		int k = front % 10;
		rep( num_add, k - 1, k + 2 )
		if (num_add >= 0 && num_add < 10)
			q.push( front * 10 + num_add );
	}
	cout << q.front() << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        if(n < 10) {
            r = r + (100 * (10 - n));
            System.out.println(r);
        } else {
            System.out.println(r);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL //デバッグ出力系
#define dout(s) cout<<s<<"\n";
#define debug() if(true)
#else
#define dout(s)
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n);
typedef long long ll;
typedef unsigned long long ull;

void Main() {
	int N, K;
	cin >> N >> K;
	vec(nums, N);
	for (int i = 1; i < N+1; i++) {
		int tmp = i;
		int cnt = 0;
		while (K>tmp) {
			cnt++;
			tmp = tmp << 1;
		}
		//dout(cnt);
		nums[i-1] = cnt;
	}
	int sum=0;
	for (auto&i:nums) {
		sum += 1<<(nums[0]-i);
	}
	int a = (N*(1 << nums[0]));
	cout << ((double)sum/a);
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int N,T;
    cin >> N >> T;
    int c[N],t[N];
    for (int  i = 0;i< N;i++){
        cin >> c[i] >> t[i];
    }
    int p = 1000000000;
    bool flag = false;
    for (int i = 0;i<N;i++){
        if (t[i] <= T){ 
            p = min(p,c[i]);
            flag = true;
        }
    }
    if (flag == true){
        cout << p << endl;
    }
    else{
        cout << "TLE" << endl;
    }
}

Measured memory_bytes: 384
/*author : Yashvardhan
Sunday, June 23, 2019
12:25 PM
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
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 debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod(pow(takemod(a), mod-2,mod));}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();

	string s;
	cin>>s;
	bool possi = true;
	char prev = s[0];

	for(int i = 1; i < 4 ; i++){
		if(s[i] == prev){
			possi = false;
			break;
		}
		prev = s[i];
	}

	if(possi) cout<<"Good"<<endl;
	else cout<<"Bad"<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
int main(){int n,c,d;while(std::cin>>n){int a=0,b=0;if(!n)return 0;while (n--){std::cin>>c>>d;if(c>d)a+=c+d;if(c==d){a+=c;b+=c;}if(c<d)b+=c+d;}printf("%d %d\n",a,b);}}

Measured memory_bytes: 1136
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

template<class Str>
vector<int> mp(Str s) {
    int n = (int)s.size();
    vector<int> R(n+1); R[0] = -1;
    for (int i = 0, j = -1; i < n; i++) {
        while (j >= 0 && s[i] != s[j]) j = R[j];
        j++;
        R[i+1] = j;
    }
    return R;
}

int main() {
    string s;
    cin >> s;
    int n = (int)s.size();
    bool allsame = true;
    for (int i = 0; i < n; i++) {
        if (s[0] != s[i]) {
            allsame = false;
            break;
        }
    }
    if (allsame) {
        printf("%d\n", n);
        printf("%d\n", 1);
        return 0;
    }

    auto table = mp(s);
    int fr = n - table[n];
    if (fr == n or n % fr) {
        printf("%d\n", 1);
        printf("%d\n", 1);
        return 0;
    }
    
    bool ok[n+1];
    fill_n(ok, n+1, true);
    ok[0] = false; ok[n] = false;
    for (int i = 1; i < n; i++) {
        int f = i - table[i];
        if (!(f == i or i % f)) {
            ok[i] = false;
        }
    }
    reverse(s.begin(), s.end());
    table = mp(s);
    for (int i = 1; i < n; i++) {
        int f = i - table[i];
        if (!(f == i or i % f)) {
            ok[n-i] = false;
        }
    }

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if (ok[i]) ans++;
    }
    printf("%d\n", 2);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 5656
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n;

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	cin >> n;
	puts(n % 10 == 7 || n / 10 % 10 == 7 || n / 100 == 7 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {

        solve();
    }

    private static void solve() {

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int k = scanner.nextInt();


        int count = 0;
        int result = Math.min(a, k);
        count = Math.min(a, k);

        count += b;
        result -= Math.max(k - count, 0);

        System.out.println(result);
    }
}

Measured memory_bytes: 35740
# n 枚のカードがあり、i 枚目のカードには ai という数が書かれています。
# Alice と Bob はこれらのカードを使ってゲームを行います。
# ゲームでは 2 人が交互に 1 枚ずつカードを取っていきます。
# Alice が先にカードを取ります。
# 2 人がすべてのカードを取ったときゲームは終了し、取ったカードの数の合計がその人の得点になります。
# 2 人とも自分の得点を最大化するように最適戦略をとったとき、Alice は Bob より何点多くの得点を獲得できるかを求めてください。

# カードの枚数を取得
n = gets.chomp.to_i

# それぞれのカードの情報を取得
cards = gets.chomp.split
n.times do |i|
    cards[i] = cards[i].to_i
end

# Alice と Bob のそれぞれが取ったカードに書かれた数を足した和を格納する変数を定義
a = 0
b = 0

# ゲームの処理を記述
cards.length.times do |i|
  
  # 取られていないカードのうち、最大の数とそのカードの位置を格納する変数を定義
  max = 0
  max_index = 0
  
  # 取られていないカードのうち、最大の数とそのカードの位置を格納
  cards.each do |card|
    if card > max
      max = card
      max_index = cards.index(card)
    end
  end
  
  # ループの回数が偶数か奇数かで、Alice と Bob のどちらの順番かを判定
  if i.even?
    a += max
  else
    b += max
  end
  
  # 取ったカードを削除
  cards.delete_at(max_index)
end

# 結果を出力
puts a - b

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
struct Info{int A,B,ci;};
vector<Info> an;
int T,A,B,C,D;
string ans;
void add(int x,Info j){
	int s=x%(j.A+j.B);
	if (s==0)s=j.A+j.B;
	if (s>=1&&s<=j.A) ans+='A';else ans+='B';
}
int main(){
	cin>>T;
	for (int i=1;i<=T;i++){
		an.clear();ans="";
		cin>>A>>B>>C>>D;
		if (A>=B){
			int x=A/(B+1)+((A%(B+1))!=0);
			if (x*B>A){
				int g=(A-B),p=g/(x-1)+((g%(x-1))!=0);
				if (A<p*x||((A-(p*x))/(x+1)!=(B-p)/(x+1)))p--;
				int q=(A-(p*x))/(x+1);
				p+=q;
				an.pb((Info){x,1,p});
				an.pb((Info){A-x*p-q,B-p-x*q,1});
				an.pb((Info){1,x,q});
			}else{
				an.pb((Info){x,1,B});
				an.pb((Info){A-x*B,0,1});
			}
		}else{
			int x=B/(A+1)+((B%(A+1))!=0);
			if (x*A>B){
				int g=(B-A),q=g/(x-1)+((g%(x-1))!=0);
				if (B<q*x||((A-q)/(x+1)!=(B-q*x)/(x+1)))q--;
				int p=(A-q)/(x+1);
				q+=p;
				an.pb((Info){x,1,p});
				an.pb((Info){A-x*p-q,B-p-x*q,1});
				an.pb((Info){1,x,q});
			}else{
				an.pb((Info){0,B-x*A,1});
				an.pb((Info){1,x,A});
			}
		}
		for(auto j:an){
			if (C<=(j.A+j.B)*j.ci&&D>0){
				for (int i=max(C,1);i<=min(D,(j.A+j.B)*j.ci);i++)add(i,j);
			}
			C-=(j.A+j.B)*j.ci;D-=(j.A+j.B)*j.ci;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class AStationAndBus {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    string S;
    cin >> S;
    int A = 0, B = 0;
    rep(i, 3) {
      if (S[i] == 'A') {
        A++;
      } else {
        B++;
      }
    }
    if (A > 0 and B > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
};


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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int r; cin >> r;
    put_double(2 * r * 3.14159265);

    return 0;
}



Measured memory_bytes: 3796
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)

ret = 0
c_pointer = 0
comfort = []
tmp = A.pop()
comfort.append(tmp)

while len(A) > 0:
    tmp = A.pop()
    c_pointer += 1
    comfort.append(tmp)
    comfort.append(tmp)

print(sum(comfort[:c_pointer]))

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

int main() {
    int n, x = 0;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(char c : s) {
        if(c == 'I') {
            x++;
        }
        if(c == 'D') {
            x--;
        }
        ans = max(ans, x);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,K,s,i;
int main()
{
	scanf("%d%d%d",&n,&K,&s);
	for(i=1;i<=K;++i)
		printf("%d ",s);
	for(;i<=n;++i)
		printf("%d ",(s==1000000000?s-1:s+1));
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

vector<vector<int>> to, ot;
vector<bool> seen, rseen, ok;

void dfs(int v) {
    seen[v] = true;
    for (auto u : to[v]) {
        if (seen[u]) continue;
        dfs(u);
    }
}

void rdfs(int v) {
    rseen[v] = true;
    for (auto u : ot[v]) {
        if (rseen[u]) continue;
        rdfs(u);
    }
}

vector<tuple<int, int, long long>> es;
vector<long long> dist;

bool bellman_ford(int v, int s) {
    const long long INF = numeric_limits<long long>::max();
    dist.assign(v, INF);
    dist[s] = 0;
    for (int t = 0; t < v; ++t){
        bool update = false;
        for (size_t i = 0; i < es.size(); ++i) {
            int from, to;
            long long cost;
            tie(from, to, cost) = es[i];
            if (!ok[from] || !ok[to]) continue;
            if (dist[from] != INF && dist[to] > dist[from] + cost) {
                update = true;
                dist[to] = dist[from] + cost;
            }
        }
        if (!update) break;
        if (t == v-1) return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m, p;
    cin >> n >> m >> p;
    to.resize(n);
    ot.resize(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        to[a].pb(b);
        ot[b].pb(a);
        es.eb(a, b, -(c-p));
    }
    seen.resize(n);
    rseen.resize(n);
    ok.resize(n);
    dfs(0);
    rdfs(n-1);
    rep(i, n) ok[i] = seen[i] && rseen[i];
    if (!bellman_ford(n, 0)) {
        ll ans = -dist[n-1];
        cout << max(0LL, ans) << endl;
    } else {
        puts("-1");
    }
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

int n_;
vector<int> dat;

void init(int size){
    //initialize size=a power of 2
    n_=1;
    while(n_ < size) n_*=2;
    dat.assign(2*n_-1, 0);
}

//a_id(0-indexed) -> val
void update(int id, int val){
    //id of leaf
    id+=n_-1;
    dat[id]=val;
    while(id > 0){
        id=(id-1)/2;
        dat[id]=max(dat[2*id+1], dat[2*id+2]);
    }
}

//get Min{a_i | s <= i < t}, [s, t)
//dat[id] interval -> [l, r)
//first, query(s, t, 0, 0, n_)
int query(int s, int t, int id, int l, int r){
    if(r <= s || t <= l) return 0;

    if(s <= l && r <= t) return dat[id];
    int vl=query(s, t, 2*id+1, l, (l+r)/2);
    int vr=query(s, t, 2*id+2, (l+r)/2, r);
    return max(vl, vr);
}

int main(){
    int N, K; cin >> N >> K;
    vi A(N);
    int mx=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        chmax(mx, A[i]);
    }
    vi nA=A;
    sort(all(nA));

    init(mx+1);
    for(int i=0; i<N; i++){
        int id1=lower_bound(all(nA), A[i]-K)-nA.begin();
        int id2=upper_bound(all(nA), A[i]+K)-nA.begin();
        update(A[i], query(nA[id1], nA[id2-1]+1, 0, 0, n_)+1);
    }
    cout << query(0, n_, 0, 0, n_) << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define pai 3.1415926535


int main(void) {

	int N;
	scanf("%d", &N);
	int d[100];
	int a = 0;
	int count = 1;
	for (int i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1 - i; j++) {
			if (d[j] < d[j + 1]) {
				a = d[j];
				d[j] = d[j + 1];
				d[j + 1] = a;
			}
		}
	}
	for (int i = 0; i < N-1; i++) {
		if (d[i] > d[i + 1]) {
			count++;
		}
	}
	printf("%d", count);

	return 0;
}

Measured memory_bytes: 128
K = int(input())
k = K % 50
kk = K // 50
N = [i for i in range(50)]
for i in range(k):
    for j in range(50):
        if i == j:
            N[j] += 50
        else:
            N[j] -= 1
for i in range(50):
    N[i] += kk
print("50")
print(" ".join(map(str,N)))

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

int main(){
    int n;
    while(true){
    cin >>n;
    if(n==0){
    	break;
    }
    
    int k[n];
    for(int i=0;i<n;i++){
        cin >>k[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(k[i]==0){
            ans+=1;
        }
    }
    sort(k,k+n);
    if(k[n-1]<2){
        cout <<"NA"<<endl;
        continue;
    }else{
        cout <<n+1-ans<<endl;
    }
    
    }
	return 0;
}

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

int solve(int A,int B)
{
  int x,y;
  
  for(int i=0;i<1009;i++)
  {
    x=(int)i*0.08;
    y=(int)i*0.1;
   if((x==A)&&(y==B))
   {
     return i;
   }

  }
  
  return -1;
}

int main()
{
  int A,B,ans;
  
  cin >> A >>B;
  
  ans = solve(A,B);
  
  cout << ans;
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {
	lli A,B;
  	cin >> A >> B;
  
  	if( A >= 13 )
      COUT(B);
    else if(A >= 6)
      COUT(B / 2);
    else
      COUT(0);
      

	return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7

def main():
    n = int(input())
    c = list(map(int, input().split()))
    c.sort()
    ans = 0
    for i in range(n):
        tmp = pow(2, i, MOD)
        if i < n-1:
            tmp *= pow(2, n-i-1, MOD) + pow(2, n-i-2, MOD) * (n-i-1)
        else:
            tmp *= pow(2, n-i-1, MOD)
        tmp %= MOD
        ans += c[i] * tmp
    print(ans * pow(2, n, MOD) % MOD)

if __name__ == "__main__":
    main()

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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    ll ans = n;

    ll gap = n - k;

    ll least;

    if (gap > 0) {
        least = n - (gap / k) * k;
        amin(ans, least);
        least -= k;
    } else least = n;

    amin(ans, least);
    least = k - least;
    amin(ans, least);

    cout << ans << endl;
}


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

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

using namespace std;
typedef long long ll;
#define INF 1<<30

int main()
{
    int n; cin >> n;
    int a[n], b[n];
    for (auto& x : a) cin >> x;
    for (auto& x : b) cin >> x;

    reverse(b, b + n);
    for (int i = 1; i < n; i++) {
        a[i] += a[i - 1];
        b[i] += b[i - 1];
    }

    reverse(b, b + n);
    int ans = -1;
    for (int i = 0; i < n; i++) {
        ans = max(ans, a[i] + b[i]);
    }
    cout << ans << endl;

    return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static int N;
        static int[] zurashi;
        static string S;
        static void Main(string[] args)
        {
            var inp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            
            if(inp[0] <= inp[1]){
              Console.WriteLine("unsafe");
            }else{
              Console.WriteLine("safe");
            }
           
            
        }

        static void MakeZurashi(int i)
        {
            var len = N - i;
            zurashi = new int[len];
            var count = 0;

            for (int j = 1; j < len; j++)
            {
                zurashi[j] = count;
                if (S[count] == S[j])
                {
                    count++;
                }
                else
                {
                    count = 0;
                }
            }
        }
    }
}


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

int main(){
    int s;
    cin>>s;
    cout<<(s/100>=1 && s/100<=12?s%100>=1 && s%100<=12?"AMBIGUOUS":"MMYY":s%100>=1 && s%100<=12?"YYMM":"NA");
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<iostream>
#include<set>
#include<queue>
#include<stack>
using namespace std;
int n,p;
long long s[2000200];
long long fd[2000100];
long long sum;
long long ans;
char c[200020];
long long pow[2000200];
bool tp[200020];
int main()
{
    cin>>n>>p;
    scanf("%s",c+1);
    pow[0]=1;
    for(int i=1;i<=1000000;i++)
    {
    	pow[i]=pow[i-1]*10;
    	pow[i]%=p;
	}
	for(int i=1;i<=n;i++)
	{
		s[i]=c[i]-'0';
		if(s[i]==0)
		{
			tp[i]=true;
		}
		s[i]%=p;
		if(p==2||p==5)
		{
			continue;
		}
		s[i]*=pow[n-i];
		s[i]%=p;
	}	
	sum=0;
	fd[0]=1;
	for(int i=1;i<=n;i++)
	{
		/*if(tp[i]&&tp[i-1])
		{
			continue;
		}*/
		if(p==2||p==5)
		{
			if(s[i]==0)
			{
				ans+=i;
			}
			continue;
		}
		sum+=s[i];
		sum%=p;
		ans+=fd[sum];
		fd[sum]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14592