akhauriyash/Code-Regression huggingface dataset:
#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;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); 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 n, m;
vector<vector<int>> rows;
void create_row(vector<int> row){
    if(row.size() == n){
        rows.push_back(row);
        return;
    }
    rept(i, row.back(), m+1){
        row.push_back(i);
        create_row(row);
        row.pop_back();
    }
}

int main() { 
    int q; cin >> n >> m >> q;
    vector<int> A(q), B(q), C(q), D(q);
    rep(i, q) {cin >> A[i] >> B[i] >> C[i] >> D[i]; A[i]--, B[i]--;}

    vector<int> v; v.push_back(1);
    create_row(v);

    int res = -INF;
    for(vector<int> row: rows){
        int sum = 0;
        rep(i, q){
            if(row[B[i]] - row[A[i]] == C[i]) sum += D[i];
        }
        chmax(res, sum);
    }
    cout << res << ln;
}

Measured memory_bytes: 6708
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll dp[55][2];
ll s[55];
ll n,p;
int main()
{
    dp[0][0]=1;
    cin>>n>>p;
    for(ll i=1;i<=n;i++) 
        cin>>s[i];
    for(ll i=1;i<=n;i++)
    {
    	dp[i][0]=dp[i-1][0];
		dp[i][1]=dp[i-1][1];
		if(s[i]%2==0)
		{
    		dp[i][0]+=dp[i-1][0];
			dp[i][1]+=dp[i-1][1];	
    	}
        else
        {
    		dp[i][0]+=dp[i-1][1];
			dp[i][1]+=dp[i-1][0];
    	}
    }
    cout<<dp[n][p]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;
ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}


int main()
{
 ll n;
 cin>>n;
 vector<double> x(n),y(n);
 rep(i,n){
    cin>>x[i]>>y[i];
 }
 vector<int>t(n);
 rep(i,n){
     t[i]=i;
 }

 long double sum=0;
 ll k=0;
 do{
     k++;
     rep(i,n-1){
        sum+=sqrt(pow((x[t[i]]-x[t[i+1]]),2)+pow((y[t[i]]-y[t[i+1]]),2)); 
     }

 }while(next_permutation(t.begin(), t.end()));
 cout << fixed << setprecision(10) << sum/k<<endl;
}



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

using namespace std;

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

int n;
int start;

bool input(){
  cin>>start>>n;
  if(n==0)return false;
  return true;
}

int getnum(string str){
  int sc = 1;
  int ret = 0;
  rep(i,str.size()){
    ret += (str[i]-'0')*sc;
    sc*=10;
  }
  return ret;
}
pair<int,int> getnx(int num){
  string str;
  while(num!=0){
    str.push_back('0'+num%10);
    num/=10;
  }

  while(str.size()<n)str.push_back('0');

  sort(str.begin(),str.end());
  //cout<<str<<"|";
  int maxi = getnum(str);
  reverse(str.begin(),str.end());
  //cout<<str<<endl;
  int mini = getnum(str);
  return pair<int,int>(maxi,mini);
}
const int M = 1000000;
int memo[M];
void solve(){
  rep(i,M)memo[i]=-1;
  int count = 0;
  int num = start;
  while(1){
    if(memo[num]!=-1){
      printf("%d %d %d\n",memo[num],  num, count-memo[num]);
      break;
    }
    memo[num]=count;
    pair<int,int> nx = getnx(num);
    //printf("num   %d %d %d\n",num,nx.first, nx.second);
    num = nx.first-nx.second;
    count++;
  }
}

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

Measured memory_bytes: 5124
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll  k,x;  cin>>k>>x  ;
  
  if(500*k>=x)
  cout<<  "Yes" <<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

const int IN = 100000000;

// Binary Indexed Tree (Fenwick Tree)
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  // 0-indexed
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  // 0-indexed
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  // 半開区間
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};
int main(){
    ll N, D, A; cin >> N >> D >> A;

    vector<pair<ll,ll>> XH(N);
    rep(i,N) cin >> XH[i].first >> XH[i].second;

    sort(XH.begin(), XH.end());

    ll ans = 0;
    BIT<ll> bit(N+1);
    rep(i,N){
        ll x = XH[i].first;
        ll h = XH[i].second;
        h -= bit.sum(i);
        if (h <= 0) continue;
        ll num = (h+(A-1))/A;
        ans += num;
        ll damage = num*A;
        bit.add(i,damage);
        //ll right_end = min(x+D*2, INF);
        ll right_end = x+D*2;        
        pair<ll, ll> right = make_pair(right_end+1, -1);
        int j = lower_bound(XH.begin(), XH.end(), right) - XH.begin();
        bit.add(j, -damage);
    }

    cout << ans << endl;


}

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c;
  cin>>a>>b>>c;
  for(int i=1;i<100;i++){
    if(a*i%b==c){
     cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 256
nk=input().split()

n=int(nk[0])
k=int(nk[1])

weight=[int(input()) for i in range(n)]

def ok(m):
    load=0
    track=1
    # sum all the weight and count the track number we need
    for i in range(n):
        load+=weight[i]
        if load==m:
            load=0
            if i!=n-1:
                track+=1
        elif load>m:
            if weight[i]>m:
                return False
            else:
                load=weight[i]
                track+=1
        else:
            continue

    if track<=k:
        return True
    else:
        return False

low=0
high=sum(weight)
while low+1<high:
# low<mid<high
#not ok(l) and ok(h)
    mid=(low+high)//2
    if ok(mid):
        high=mid
    else:
        low=mid


print(high)

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

using namespace std;

vector<vector<long long int>> dp(105, vector<long long int>(100005, -1));
vector<int> weights, values;

//dp[n][w] = maximum sum of values for n items in a knapsack of max
//capacity of w
//Logic: either include the n'th item in the knapsack, or don't.
long long int solve(int n, int w)
{
    if(w < 0)
        return(-(int)(1e15));
    if(dp[n][w] != -1)
        return(dp[n][w]);
    if(n == 0)
        return(dp[n][w] = 0);
    return(dp[n][w] = max(values[n] + solve(n-1, w-weights[n]), solve(n-1, w)));
}

int main()
{
    int n, w;
    long long int ans;
    cin >> n >> w;
    weights.push_back(-1), values.push_back(-1);
    for(int i=0;i<n;i++)
    {
        int weight, value;
        cin >> weight >> value;
        weights.push_back(weight), values.push_back(value);
    }
    ans = solve(n, w);
    cout << ans << endl;
    return(0);
}

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

using namespace std;

int abs(int p){
	return ((p>=0) ? p : -1*p );
}

int main(void){
	vector<int> arr(3);
	cin >> arr[0] >> arr[1] >> arr[2];
	
	sort(arr.begin(), arr.end());
	
	int sum = 0;
	for(int i=0;i<3-1;i++){
		sum += abs(arr[i+1] - arr[i]);
	}
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int	main()
{
	int	A, B, C;
	long long	K, ans;

	scanf("%d %d %d %lld\n", &A, &B, &C, &K);
	if (K % 2) //odd
		ans = B - A;
	else //even
		ans = A - B;
	if (ans >= 100000000000000000 || ans <= -100000000000000000)
		printf("Unfair\n");
	else
		printf("%lld\n", ans);
	return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> T1 pow_(T1 a, T2 b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  vector<vector<int> > G(n);
  vector<int> ans(n);
  vector<int> lis;

  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].eb(b);
    G[b].eb(a);
  }
  lis.eb(a[0]);
  auto dfs = [&](auto &&dfs, int v, int p) -> void {
    for (int nv : G[v]) {
      if (nv == p) continue;
      int it = lb(lis, a[nv]);
      int i = -1, j = -1;
      if (it == sz(lis)) {
        lis.eb(a[nv]);
        i = sz(lis);
      } else {
        i = it;
        j = lis[it];
        lis[it] = a[nv];
      }
      // cout << v << " " << nv << "  " << lis << endl;
      dfs(dfs, nv, v);
      ans[nv] = sz(lis);
      if (i == sz(lis)) {
        lis.pop_back();
      } else {
        lis[i] = j;
      }
    }
  };
  dfs(dfs, 0, -1);
  ans[0] = 1;
  rep(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 32972
#include <iostream>
using namespace std;
#define rep(i,s,n)for(ll i=s;i<n;i++)
typedef long long  ll;

int main()
{
	ll N; cin >> N;
	char s[100];
	rep(i, 0, N) {
		cin >> s[i];
		if (s[i] == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;

	return 0;
}

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

int main(){
    int N, X; cin >> N >> X;
    int D = 0, count = 1;
    for(int i = 0; i < N; i++){
        int L; cin >> L;
        D += L;
        if(D <= X){
            count++;
        }else{
            break;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 500000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll k) {
    ll ret = 1;
    for(ll i=0;i<k;i++) ret = (ret*(n-i))%MOD;
    return (ret * finv[k])%MOD;
}
ll RepeatSquaring(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2);
        return t*t % MOD;
    }
    return (N * RepeatSquaring(N, P-1))%MOD;
}
int main(){
    COMinit();
   ll n,a,b;
   cin >> n >> a >> b;
   ll ans = RepeatSquaring(2,n)-COM(n,a)-COM(n,b)-1;
   while(ans<0) ans += MOD;
   cout << ans << endl;
}


Measured memory_bytes: 11904
A,B,K = map(int,input().split(' '))
# 与えられた整数の約数を返す
def func_divisors(x):
  divisors = []
  for i in range(1,int(x**0.5)+1):
    if x % i == 0:
      divisors.append(i)
      if i != x / i:
        divisors.append(int(x/i))
        
  divisors.sort()
  return divisors
  
A_divisors = func_divisors(A)
B_divisors = func_divisors(B)
C_divisors = sorted(list(set(A_divisors) & set(B_divisors)),reverse=True)

print(C_divisors[K-1])
  

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

int main(void){
  char s[11];
  scanf("%s",s);
  
  int len = strlen(s);
  int checkA = 0 , checkB = 0 , checkC = 0;
  
  if(s[0]=='A'){
    checkA++;
  }
  for(int i = 2;i < len-1;i ++){
    if(s[i]=='C'){
      checkB++;
    }
  }
  
  for(int i = 0;i < len;i ++){
    if(s[i]>='a'&&s[i]<='z'){
      checkC ++;
    }
  }
    if(checkA==1&&checkB==1&&checkC==len-2){
      printf("AC");
    }
    else {
      printf("WA");
    }
    
    return 0;
  }

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    string str; cin >> str;
    int len = str.size();
    cout << str[0] << len-2 << str[len-1] << endl;

    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N, D, A; cin >> N >> D >> A;
    vector< pair<ll, ll> > enemy;
    for(int i=0; i<N; i++) {
        ll X, H; cin >> X >> H;
        enemy.emplace_back(X, H);
    }
    sort(enemy.begin(), enemy.end());

    ll dec = 0, ans = 0;
    using Elem = tuple<ll, ll, ll>;
    priority_queue< Elem, vector< Elem >,
                    greater<> > que;
    for(int i=0; i<N; i++) {
        ll X, H; tie(X, H) = enemy[i];

        while(que.size() and get<0>(que.top()) <= X) {
            ll c = get<2>(que.top());
            if(get<1>(que.top()) == 1) {
                dec += A * c;
            }
            else {
                dec -= A * c;
            }
            que.pop();
        }

        ll current_dec = dec;
        ll diff = max(0LL, (H - current_dec + A - 1) / A);
        if(diff > 0) {
            ans += diff;
            que.emplace(X, 1, diff);
            que.emplace(X+2*D+1, 0, diff);
        }

        while(que.size() and get<0>(que.top()) <= X) {
            ll c = get<2>(que.top());
            if(get<1>(que.top()) == 1) {
                dec += A * c;
            }
            else {
                dec -= A * c;
            }
            que.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> m(n);
  for(int i=0;i<n;++i) cin >> m[i];
  int a=0,cnt=n;
  for(auto i:m) a+=i;
  sort(m.begin(),m.end());
  while(a<=x){
    a+=m[0];
    cnt++;
  }
  cnt--;
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
import java.math.*;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
	Scanner reader=new Scanner(System.in);
	int N= reader.nextInt();
	int K= reader.nextInt();
	int X= reader.nextInt();
	int Y= reader.nextInt();
	int SUM=0;
	for(int i=1;i<=Math.min(K,N);i++) {
		SUM=SUM+X;
	}

	for(int i=K+1;i<=N;i++) {
		SUM=SUM+Y;
	}
	System.out.print(SUM);

	}

}


Measured memory_bytes: 23252
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
int q;
LL a, b;
int main() {
	scanf("%d", &q);
	while(q--) {
		scanf("%lld%lld", &a, &b);
		LL n = a * b;
		LL temp = sqrt(n);
		LL res = temp * 2LL;
		if(temp * temp == n) {
			res -= 2LL;
		}
		else if(temp * (temp + 1LL) >= n)res--;
		if(a != b)res--;
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
d = list(map(int, input().split()))

# bucket
lst = [[] for i in range(n)]
ans = 1
sum = 1
P = 998244353
if d[0] != 0:
    print(0)
    quit()
else:
    for i in range(n):
        if d[i] == 0 and i != 0:
            print(0)
            quit()
        lst[d[i]].append(i + 1)

    tmp = len(lst[1])
    for i in range(1, n):
        if len(lst[i]) == 0:
            if sum != n:
                print(0)
                quit()
        sum += len(lst[i])
        if i == 1:
            continue
        ans = (ans * tmp ** len(lst[i])) % P
        tmp = len(lst[i])
    print(ans)


Measured memory_bytes: 21888
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();

    vector<vector<int>> is(26);
    rep(i, n) {
        is[s[i] - 'a'].push_back(i);
    } 
    rep(i, n) {
        is[s[i] - 'a'].push_back(i+n);
    }

    ll ans = 0;
    int p = 0;
    rep(i, m) {
        int c = t[i] - 'a';
        if(is[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
        if(p >= n) {
            p -= n;
            ans += n;
        }
    }
    ans += p;

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

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int a, b, c; cin >> a >> b >> c;
  if(a <= c && c <= b){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  system("pause");
}

Measured memory_bytes: 504
N,M = gets.split.map(&:to_i)
P = []
Y = []
a = []
b = []
for i in 0..M-1
    P[i],Y[i] = gets.split.map(&:to_i)
    a[i] = [P[i],Y[i],i]
end

a.sort_by!{|x| x[0]}
j = 0
b[0] = []
b[0][0] = [a[0][0],a[0][1],a[0][2]]
for i in 1..M-1

    if a[i][0] != a[i-1][0]

        b[j].sort!
        j += 1
        b[j] = []
        
        
    end

    b[j].push(a[i])

end

for i in 0..j

    b[i].sort_by!{|x| x[1]}

end

c = []
n = 0

for i in 0..j

    for k in 0..b[i].size-1

        b[i][k].push(k+1)
        c.push(b[i][k])

        

    end

    

end

c.sort_by!{|x|  x[2]}

for i in 0..M-1

    puts "#{(c[i][0] % (10**6)) / (10**5)}#{(c[i][0] % (10**5)) / (10**4)}#{(c[i][0] % (10**4)) / (10**3)}#{(c[i][0] % (10**3)) / (10**2)}#{(c[i][0] % (10**2)) / (10**1)}#{(c[i][0] % (10**1)) / (10**0)}#{(c[i][3] % (10**6)) / (10**5)}#{(c[i][3] % (10**5)) / (10**4)}#{(c[i][3] % (10**4)) / (10**3)}#{(c[i][3] % (10**3)) / (10**2)}#{(c[i][3] % (10**2)) / (10**1)}#{(c[i][3] % (10**1)) / (10**0)}"

end 




Measured memory_bytes: 40668
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

import math
a, b = MAP()
print(math.ceil((a + b) / 2.0))


Measured memory_bytes: 27112
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vll vector<ll>
#define pb push_back
#define x first
#define y second

vector<ll> w,v;
ll dp[109][100009];

ll maxi(ll n, ll W)
{
	if(n<0 || W<=0)
		return 0;		
	if(dp[n][W]!=-1)
		return dp[n][W];
	if(w[n]>W)
		dp[n][W]=maxi(n-1,W);
	else
		dp[n][W] = max(maxi(n-1,W),maxi(n-1,W-w[n])+v[n]);
	return dp[n][W];
}

int main()
{
	IOS
    ll N,W,a,b,i,j;
	cin>>N>>W;
	for(i=0;i<N;i++)
	{
		cin>>a>>b;
		w.pb(a);
		v.pb(b);
	}
	for(i=0;i<N;i++)
		for(j=0;j<=W;j++)
		{
			dp[i][j]=-1;
		}
	maxi(N-1,W);
	/*for(i=0;i<N;i++)
		for(j=0;j<=W;j++)
		{
			cout<<dp[i][j]<<' ';
		}*/
	cout<<dp[N-1][W];
}

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

int main(){
	string s;
	cin >> s;
	int k;
	cin >> k;
	REP(i,k){
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}else if(i == k - 1){
			cout << 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    s=str(input())
    ans=[]
    for i in s:
        if i =='0':
            ans.append('0')
        elif i=='1':
            ans.append('1')
        else:
            if ans:
                ans.pop(-1)

    print(''.join(ans))

resolve()

Measured memory_bytes: 3060
#include <stdio.h>
#include <memory.h>
int main(void){
	int n,m,p[100],d,v,i,sum;
	while(1){
		sum=0;
		scanf("%d %d",&n,&m);
		if(!n) break;
		memset(p,0,sizeof(p));
		for(i=0;i<n;i++){
			scanf("%d %d",&d,&v);
			if(p[d-1]<v){
				p[d-1]=v;
			}
		}
		for(i=0;i<m;i++)
			sum+=p[i];
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 600
N = int(input())
*A, = map(int, input().split())

#最大公約数
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

a = A[0]
for i in range(1,N):
  a = gcd(a, A[i])
 
print(a)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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


  cout << fixed;
  cout << setprecision(11);
  int n;
  cin >> n;
  vector<double> a(n);
  double sum = 0;
  rep(i, n) {
    cin >> a[i];
    a[i] = 1 / a[i];
    sum += a[i];
  }

  sum = 1 / sum;
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  if (n<10){
    cout <<"ABC00"<<n<<endl;
  }
  else if (n<100){
    cout <<"ABC0"<<n<<endl;
  }
  else {
    cout <<"ABC"<<n<<endl;
  }
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
    li n;
    cin >> n;
    if (n == 1) {
        puts("Hello World");
        return 0;
    }
    li a, b;
    cin >> a >> b;
    cout << a + b << endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;


#if 1
//No.1
int main()
{
	string str;
	cin >> str;

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

	return 0;
}
#endif


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def 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, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

s = STR()
i = 0
l = len(s)
debug(l)
while i < l:
    debug(i, s[i])
    if i + 4 >= l:
        print('NO')
        exit()
    if s[i] == 'd':
        if s[i:i + 5] != 'dream':
            print('NO')
            exit()
        if i + 5 >= l:
            i += 5
        elif i + 6 == l - 1 and s[i:i + 7] == 'dreamer':
            i += 7
        elif i + 6 < l and s[i:i + 7] == 'dreamer':
            if s[i + 7] == 'a':
                i += 5
            else:
                i += 7
        else:
            i += 5
    elif s[i] == 'e':
        if s[i:i + 5] != 'erase':
            print('NO')
            exit()
        if i + 5 >= l:
            i += 5
        elif i + 5 == l - 1 and s[i:i + 6] == 'eraser':
            i += 6
        elif i + 6 < l and s[i:i + 6] == 'eraser':
            if s[i + 6] == 'a':
                i += 5
            else:
                i += 6
        else:
            i += 5
    else:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 61676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n; cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int cur=0,r=0;
    ll ans=0;
    for(int l=0;l<n;l++){
        while(r<n&&(cur&a[r])==0){
            cur|=a[r++];
        }
        ans+=r-l;
        cur&=~a[l];
    }
    cout<<ans<<endl;
}


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

int main() {
 multiset<UL> S;
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  UL c; scanf("%u",&c);
  if(c==0){
   UL x; scanf("%u",&x);
   S.insert(x);
   printf("%u\n",S.size());
  }
  if(c==1){
   UL x; scanf("%u",&x);
   printf("%u\n",S.count(x));
  }
  if(c==2){
   UL x; scanf("%u",&x);
   S.erase(x);
  }
  if(c==3){
   UL L,R; scanf("%u%u",&L,&R);
   for(auto itr=S.lower_bound(L); itr!=S.end(); itr++){
    if(*itr>R) break;
    printf("%u\n",*itr);
   }
  }fflush(stdout);
 }
 return 0;
}




Measured memory_bytes: 12412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 200000
#define MOD 998244353

ll fac[MAX], finv[MAX], inv[MAX];

void myCOMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll myCOM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

ll myPOW(ll a, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

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

    myCOMinit();

    ll res = 0;
    for(ll k = 0; k <= K; k++) {
        res = ( res + ( M * myCOM(N-1,k) ) % MOD * myPOW(M-1,N-1-k) % MOD ) % MOD;
    }
    cout << res <<  endl;
    return 0;
}

Measured memory_bytes: 8276
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define ll long long
#define clr(x) memset((x),0,sizeof(x))
using namespace std;
template<class T>
inline void read(T &res){
	static char ch;T flag=1;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
}
inline int readin(){
	static char ch;int flag=1,res;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
	return res;
}
inline int readst(char *s){
	static char ch;int len=0;
	while((ch=getchar())<'a'||ch>'z');s[len++]=ch;
	while((ch=getchar())>='a'&&ch<='z')s[len++]=ch;
	return --len;
}
int n,m;
int vis[200015][2];
int main(){
	read(n);read(m);
	memset(vis,0,sizeof(vis));
	int a,b;
	for(int i=1;i<=m;i++){
		read(a),read(b);
		if(a==1){
			if(vis[b][1]){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}else{
				vis[b][0]=1;
			}
		}
		if(b==1){
			if(vis[a][1]){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}else{
				vis[a][0]=1;
			}
		}
		if(a==n){
			if(vis[b][0]){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}else{
				vis[b][1]=1;
			}
		}
		if(b==n){
			if(vis[a][0]){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}else{
				vis[a][1]=1;
			}
		}
		
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n,m,a,b,c,d,h,w,x,y;
string str;

signed main(){

  cin >> str;
  FOR(i,6){
    m+=str[i]-'0';
  }
  cout <<m fin;
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    const C = parseInt(arg[0].split(" ")[2]);
    
    const array = [A, B, C];
    const set = new Set(array);
    
    console.log(set.size === 2 ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22076
#include<bits/stdc++.h>
using namespace std;using ll = long long;int main(){ll n;cin >> n;vector<ll> a(n*3);for(ll i=0;i<3*n;++i) cin >> a.at(i);sort(a.begin(),a.end());ll ans = 0;for(ll i=3*n-2;i>=3*n-n*2;i-=2)ans += a.at(i);cout << ans << endl;return 0;}


Measured memory_bytes: 5524
/*
  AtCoder Beginner Contest 082
  B - Two Anagrams
*/

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

string s, t;

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

  sort(s.begin(), s.end());                  // 文字列sを使った最小となる文字列
  sort(t.begin(), t.end(), greater<char>()); // 文字列tを使った最大となる文字列


  if (s < t) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int a, b, c; cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] xn = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int x = xn[0];
        int n = xn[1];
        string s = Console.ReadLine();
        if (s.Trim() == "")
        {
            Console.WriteLine(x);
            return;
        }
        int[] p = s.Split(' ').Select(s => int.Parse(s)).ToArray();
        int pMin = p.Min();
        int pMax = p.Max();
        List<int> list = Enumerable.Range(pMin - 1, pMax - pMin + 3).ToList();
        foreach (int pn in p)
            list.Remove(pn);

        int res = 1000;
        int dis = 1000;
        foreach (int l in list)
        {
            int xa = Math.Abs(x - l);
            if (xa < dis)
            {
                res = l;
                dis = xa;
            }
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 28392
n, l = map(int,input().split())
apple = [l+i-1 for i in range(1,n+1)]

minn = float('INF')
savei = None
for i in range(n):
    num = abs(apple[i])
    if(minn > num):
        minn = num
        savei = i

print(sum(apple) - apple[savei])


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var list = new List<int>();
        for(var i = 1;i <= n;i++){
            if(i % 3 == 0 || IncludeThree(i)){
                list.Add(i);
            }     
        }
        
        var ans = string.Join(" ",list);
        Console.WriteLine(" " + ans);
        
        
    }
    static bool IncludeThree(int n){
        while(n > 0){
            if(n % 10 == 3){
                return true;
            }
            n /= 10;
        }
        return false;
    }
}



Measured memory_bytes: 8028
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define debug_() cerr << "AAAAA" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;
using P = pair<int, int>;

int n, a, b, c;
vector<int> l;
int ans = 1001001001;

void calc(vector<int> &vec)
{
    int tmp = 0;
    int p = 0;
    int q = 0;
    int r = 0;
    for (int i = 0; i < vec.size(); i++)
    {
        if (vec[i] == 0)
        {
            p += l[i];
        }
        else if (vec[i] == 1)
        {
            q += l[i];
        }
        else if (vec[i] == 2)
        {
            r += l[i];
        }
    }
    // cout << "------------------" << endl;
    // debug_vec(vec);
    for (int i = 0; i < 3; i++)
    {
        int x = count(vec.begin(), vec.end(), i);
        if (x == 0)
        {
            tmp = 1001001001;
        }
        else
        {
            tmp += (x - 1) * 10;
        }
    }
    // debug(tmp);
    tmp += abs(p - a) + abs(q - b) + abs(r - c);
    if (ans > tmp)
    {
        // debug_vec(vec);
        ans = min(ans, tmp);
    }
    // ans = min(ans, tmp);
}

void dfs(int depth, vector<int> &v)
{
    if (depth == n)
    {
        calc(v);
        // debug_vec(v);
        return;
    }
    for (int i = 0; i < 4; i++)
    {
        v[depth] = i;
        dfs(depth + 1, v);
    }
}

int main()
{
    cin >> n >> a >> b >> c;
    l.resize(n);

    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    // debug_();
    vector<int> vec(n);

    dfs(0, vec);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long Comb (long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);lin(K);
  vlin(h,N);
  sort(rall(h));
  
  K=min(K,N);
  
  rep(i,K){
    h[i]=0;
  }
  ll res=0;
  rep(i,N) res+=h[i];
  
  cout<<res;
}

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

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

using namespace std;
using lint=long long;

int main(){
	int n,MOD; scanf("%d%d",&n,&MOD);
	int a[100000];
	rep(i,n) scanf("%d",a+i);

	int sum=0;
	map<int,int> f;
	f[0]=1;
	lint ans=0;
	rep(i,n){
		sum=(sum+a[i])%MOD;
		ans+=f[sum]++;
	}
	cout<<ans<<endl;

	return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> x(m),diff(m-1);
  rep(i,m) cin >> x[i];
  sort(x.begin(),x.end());
  rep(i,m-1) diff[i] = x[i+1] - x[i];
  sort(diff.begin(),diff.end());
  ll ans = 0;
  rep(i,m-n) ans += diff[i];
  cout << ans << endl;
}

Measured memory_bytes: 4040
n, k = map(int, input().split())
p = list(map(int, input().split()))
temp = 0
dif = 0
if k < n:
    for i in range(n - k):
        next_dif = p[i + k] - p[i]
        dif += next_dif
        if dif > 0:
            temp = i + 1
            dif = 0
s = 0
for i in range(temp, temp + k):
    s += p[i]
a = (s + k) / 2
print(a)

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int d;
  cin >> d;
  vector<int> c(26);
  int i,j;
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(d,vector<int>(26));
  rep(i,d)rep(j,26) cin >> s[i][j]; 
  vector<int> t(d);
  rep(i,d)
  {
    int ind = -1;
    int val = -1;
    rep(j,26)
    {
      if(s[i][j] > val)
      {
        ind = j;
        val = s[i][j];
      }
    }
    t[i] = ind;
    cout << t[i]+1 << "\n";
  }
  vector<int> las(26,0);
  vector<int> rowans(26,0);
  int sums = 0;
  int kans = 0;
  rep(i,d)
  {
    las[t[i]] = i+1;
    sums += s[i][t[i]];
    kans += s[i][t[i]];
    rep(j,26)
    {
      kans -= c[j]*(i+1-las[j]);
      rowans[j] += c[j]*(i+1-las[j]);
    }
  }
  /*
  int m;
  cin >> m;
  rep(i,m)
  {
    int tod,q;
    cin >> tod >> q;
    tod--;
    q--;
    int bq = t[tod];
    sums -= s[tod][bq];
    sums += s[tod][q];
    t[tod] = q;
    rowans[q] = 0;
    rowans[bq] = 0;
    rep(j,26)
    {
      las[j] = 0;
    }
    rep(j,d)
    {
      las[t[j]] = j+1;
      rowans[bq] += c[bq]*(j+1-las[bq]);
      rowans[q] += c[q]*(j+1-las[q]);
    }
    int kans = sums;
    rep(j,26) kans -= rowans[j];
  }*/
  // kans:ans(-1)
}


Measured memory_bytes: 3712