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

int main() {
  string S;
  cin >> S;
  string ans = "AC";
  if (S.at(0) != 'A') ans = "WA";
  if (S.at(1) < 'a' || S.at(1) > 'z') ans = "WA";
  if (ans == "AC") {
    int N, ex;
    N = S.size();
    ex = 0;
    for (int i = 2; i < N - 1; i++) {
      if ((S.at(i) < 'a' || S.at(i) > 'z') && S.at(i) != 'C') {
        ans = "WA";
        break;
      }
      else if (S.at(i) == 'C' && ex == 0) ex = 1;
      else if (S.at(i) == 'C' && ex == 1) {
        ans = "WA";
        break;
      }
    }
    if (S.at(N - 1) < 'a' || S.at(N - 1) > 'z') ans = "WA";
    if (ex == 0) ans = "WA";
  }
  cout << ans << endl;
}


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

int main(void){
        string s, t;
        cin >> s >> t;
        sort(s.begin(), s.end());
        sort(t.begin(), t.end());
        if (s < t) {
                cout << "Yes" << endl;
                return 0;
        }
        string tr = "";
        for (int i = t.size()-1; i >=0; i--) {
                tr += t[i];
        }
        if (s < tr) {
                cout << "Yes" << endl;
        }
        else cout << "No" << endl;

        return 0;
}

Measured memory_bytes: 3600
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 A[] = new int[N];
		int num = 0;
		int max = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			max = Math.max(max, A[i]);
			if(i == 0) {
				num = A[0];
			} else {
				num = gcd(num, A[i]);
			}
		}
		
		if(K % num == 0 && K <= max) {
			System.out.println("POSSIBLE");
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}

	static int gcd (int a, int b) {
		return b > 0 ? gcd(b, a % b) : a;
	}
}


Measured memory_bytes: 49856
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a>=90)
	{
		cout<<"Yes"<<endl;
	}
	else if(a==19||a==29||a==39||a==49||a==59||a==69||a==79||a==89)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,id;
int a[333333],b[333333];
void DFS(int i,bool f)
{
	//for(int j=1;j<=i;++j)printf("[%d-%d] ",i,a[i]);puts("");
	if(i<=n)
	{
		if(f)
		{
			a[i]=b[i];
			DFS(i+1,f);
			for(int j=b[i]-1;j;--j)
			{
				a[i]=j;
				DFS(i+1,0);
			}
		}
		else
		{
			for(int j=m;j;--j)
			{
				a[i]=j;
				DFS(i+1,0);
			}
		}
	}
	a[i]=0;
//	for(int j=1;j<i;++j)printf("%d ",a[j]);puts("");
	--id;
	if(!id)
	{
		for(int j=1;j<i;++j)printf("%d ",a[j]);
		exit(0);
	}
}
int main()
{
	scanf("%d%d",&m,&n);
	if(m&1)
	{
		int t=m+1>>1;
		for(int i=1;i<=n;++i)
			b[i]=t;
		id=n/2+1;
		DFS(1,1);
	}
	else
	{
		printf("%d ",m+1>>1);
		for(int i=2;i<=n;++i)
			printf("%d ",m);
	}
	return 0;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;
const ll INFLL = 1e18l+5;

int main(){
    int n,W;
    cin>>n>>W;
    vector<ll> dp(100001,INFLL); //dp[i] min weight at value = i
    dp[0]=0;
    for(int i=0; i<n; i++){
        int w,v;
        cin>>w>>v;

        for(int va=100001-v; va>=0; --va){
            dp[va+v]=min(dp[va+v],dp[va]+w);
        }
    }

    int ans=0;
    for(int i=0; i<100001; ++i){
        if(dp[i]<=W) ans=max(ans,i);
    }

    cout<<ans;
    
}

Measured memory_bytes: 4028
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=200111;
int h,w,n,sx,sy;
char s[maxn],t[maxn];

bool check(int len,int pos,char L,char R)
{
	int lv=0,rv=len+1;
	for(int i=n;i>=1;i--)
	{
		if(t[i]==L)rv=min(rv+1,len+1);
		if(t[i]==R)lv=max(lv-1,0);
		
		if(s[i]==L)lv++;
		if(s[i]==R)rv--;
		if(lv>=rv-1)return true;
	}
	return pos<=lv||pos>=rv;
}

int main()
{
	get3(h,w,n);get2(sx,sy);
	scanf("%s%s",s+1,t+1);
	
	if(check(h,sx,'U','D')||check(w,sy,'L','R'))puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!

n,m = [int(i) for i in input().split()]

ll=1
rr=n
for _ in range(m):
    l,r = [int(i) for i in input().split()]
    if ll < l:
        ll=l
    if rr > r:
        rr=r
    


print(max(0,rr-ll+1))

Measured memory_bytes: 3188
#include<stdio.h>


int main()
{
   char S[200] ;
   int a=0,i,j,k ;


   scanf("%s",S) ;
  for(j=0 ; S[j]!='\0' ; j++)
   {
       a=a+1 ;
   }




for(i=1 ; i<=a ; i++)
{
    printf("x") ;
}


   return 0 ;

}



Measured memory_bytes: 128
#include <cstdio>

int as[100];

bool lose[100005];

int main(){
  int N,K;
  scanf("%d %d",&N,&K);
  for(int i=0;i<N;i++){
    scanf("%d",&as[i]);
  }
  for(int i=0;i<=K;i++){
    lose[i]=true;
    for(int j=0;j<N;j++){
      if(i>=as[j]&&lose[i-as[j]]){
	lose[i]=false;
      }
    }
  }
  if(lose[K]){
    printf("Second\n");
  }else{
    printf("First\n");
  }
  return 0;
}


Measured memory_bytes: 256
import math
import bisect
n = int(input())
saidai = math.ceil(n**0.5)

ruisekiwa = [1]
for i in range(2,100):
    ruisekiwa.append(ruisekiwa[-1]+i)

#%%
so_factors = [0 for _ in range(saidai)]

for i in range(2,saidai+1):
    while n%i == 0:
        so_factors[i]+=1
        n = n//i

if n != 1:
    count = 1
else:
    count =0
    
for i in range(len(so_factors)):
    if so_factors[i] > 0:
        count+=bisect.bisect_right(ruisekiwa, so_factors[i])

print(count)

Measured memory_bytes: 140968
import java.util.*;

public class Main {
    static int[] list=new int[1000000];
    
    static void start(){
        for(int i=2;i<1000;i++){
            if(list[i]==-1)continue;
            for(int j=2;i*j<1000000;j++){
                list[i*j]=-1;
            }
        }
    }
    
    static int fun(int n){
        int c=0;
        for(int i=n;i>=2;i-=1){
            if (list[i]==0){c+=1;continue;}
            if(list[i]>0){c+=list[i];break;}
        }
        list[n]=c;return c;
    }
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        start();
        while(sc.hasNext()){System.out.println(fun(sc.nextInt()));}
    
    }   
}


Measured memory_bytes: 30084
#include <iostream>

#define MAX 1000000000000000000LL

using namespace std;

int main(int argc, char* argv[]) {
  long long N;

  cin >> N;

  long long a[N];
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }

  for (int i = 0; i < N; ++i) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  long long ret = a[0];
  for (int i = 1; i < N; ++i) {
    if ((((long double)MAX) / ret) <= a[i] && ret * a[i] != MAX) {
      cout << -1 << endl;
      return 0;
    }
    ret *= a[i];
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
#define IL inline
#define _ 600005
#define ll long long
using namespace std ;

IL ll gi(){
    ll data = 0 , m = 1; char ch = 0;
    while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
    if(ch == '-'){m = 0 ; ch = getchar() ; }
    while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
    return (m) ? data : -data ; 
}

ll n,K,tot ;
vector<ll> vec[_] ; 

int main() {
	n = gi() ; 
	ll l = 0 , r = n , ret = 0 ; 
	while(l <= r) {
		ll mid = (l + r) >> 1 ; 
		if(1ll * mid * (mid + 1) <= 2 * n) ret = mid , l = mid + 1 ; 
		else r = mid - 1 ;  
	}
	if(1ll * ret * (ret + 1) != 2 * n) {return puts("No") ,0 ; }
	puts("Yes") ; 
	K = ret ; 
	tot = 0 ; 
	++ K ; 
	for(int i = 1; i < K; i ++) 
	    for(int j = i + 1; j <= K; j ++) {
	    	++ tot ; 
	    	vec[i].push_back(tot) ; 
	    	vec[j].push_back(tot) ; 	
		}
	cout << K << endl ;
	for(int i = 1; i <= K; i ++) {
		cout << vec[i].size() << " " ; 
		for(int j = 0 , l = vec[i].size(); j < l; j ++) cout << vec[i][j] << " " ; 
		cout << endl ; 
    }
    return 0 ; 
}

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

using namespace std;
vector<int> L;

int main(){
	int N, X;
	cin >> N >> X;
	L.resize(N);
	for(int i=0; i<N; i++){
		cin >> L[i];
	}
	
	int b=1, D=0;
	bool excess = false;
	for(int i=0; i<N; i++){
		D += L[i];
		b++;
		if(D > X){
			b--;
			break;
		}
	}
	
	cout << b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	ll ans = 0;
	for(ll x=1;x<=n;x++){
		ll m = n/x;
		ans += x*m*(m+1)/2;
	}
	cout<<ans<<endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, R;
    cin >> N >> R;
    int innerRating = 100 * (10 - N);
    int displayRating;
    if (N >= 10) {
        displayRating = R;
    } else {
        displayRating = R + innerRating;
    }
    cout << displayRating << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n, m) for(int i = n; i >= m; i--)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main(){

  string s,t;
  cin >> s >>t;

  string ss=s+s;

  int slen=s.length();

  int sslen=ss.length();

  int dp[sslen][26]={};

  rep(j,sslen){
    char c=ss[j];
    int cnum=c-'a';
    repr(k,j-1,0){
      if(dp[k][cnum]!=0) break;
      dp[k][cnum]=j-k;
    }
  }

  int tlen=t.length();

  ll ans=0;

  int now=slen-1;

  rep(i,tlen){
    char c=t[i];
    int cnum=c-'a';
    if(dp[now][cnum]==0){
      std::cout << -1 << '\n';
      return 0;
    }
    ans+=dp[now][cnum];
    now+=dp[now][cnum];
    if(now>=slen) now-=slen;
  }

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


Measured memory_bytes: 21120
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

string s1, s2, s3;
void input() { cin >> s1 >> s2 >> s3; }
void solve() {
  cout << char(s1[0] + 'A' - 'a');
  cout << char(s2[0] + 'A' - 'a');
  cout << char(s3[0] + 'A' - 'a');
  cout << endl;
  ;

  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main() {
	int n,sum=0;
	cin >> n;
	vector<int> l(2*n);
	for (int i = 0; i < 2*n; i++)
		cin >> l.at(i);

	sort(l.begin(), l.end());
	for (int i = 0; i < n; i++)
		sum += l.at(i * 2);
	cout << sum << endl;
}

Measured memory_bytes: 256
import collections
import sys
n=int(input())
if n<=2:
  print(0)
  sys.exit()
s=input()
S=list(s)
t=collections.Counter(S)
R=t['R']
G=t['G']
B=t['B']
num=R*G*B
cnt=0
for i in range(1,(n//2)+1):
  for j in range(n):
    if j+(2*i)>n-1:
      continue
    if s[j]=='R':
      if s[j+i]=='G':
        if s[j+(2*i)]=='B':
          cnt+=1
      if s[j+i]=='B':
        if s[j+(2*i)]=='G':
          cnt+=1
    if s[j]=='G':
      if s[j+i]=='R':
        if s[j+(2*i)]=='B':
          cnt+=1
      if s[j+i]=='B':
        if s[j+(2*i)]=='R':
          cnt+=1
    if s[j]=='B':
      if s[j+i]=='G':
        if s[j+(2*i)]=='R':
          cnt+=1
      if s[j+i]=='R':
        if s[j+(2*i)]=='G':
          cnt+=1
print(num-cnt)


Measured memory_bytes: 69340
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pob pop_back
#define mod 1000000007
#define sr(a) sort(a.begin(),a.end())
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  ll dp[n];
  dp[0]=0;
  dp[1]=abs(a[0]-a[1]);
  for(int i=2;i<n;i++)
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
   cout<<dp[n-1]<<endl;
return 0;
}


Measured memory_bytes: 1408
// This is my template for fast solving
 
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <memory>
#include <initializer_list>
#include <iomanip>
#include <stack>
#include <bitset>
#include <cstdio>
// #include <complex>
// #include <random>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;

// const ll INF = 1e18;
// const ld INF = 1e20;
const ll MOD = 998244353;
// const ld EPS = 1e-10;
// const ld PI = acos(-1);

template<typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
    os << p.first << " " << p.second;
    return os;
}

template<typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >>  p.second;
    return is;
}
 
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& x : v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

template<typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
    bool first = true;
    for (auto x : s) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, const map<T1, T2>& m) {
    bool first = true;
    for (auto x : m) {
        if (!first) {
            os << "\n";
        }
        first = false;
        os << x;
    }
    return os;
}

void solve() {
    ll x;
    cin >> x;
    ll ans = 1000 * (x / 500);
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans << "\n";
}
 
int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    // int t; // CodeJam style
    // cin >> t;
    // for (int i = 1; i <= t; ++i) {
    //     cout << "Case #" << i << ": ";
    //     solve();
    // }
 
    // int q;
    // cin >> q;
    // while (q--) {
    //     solve();
    // }

    solve();
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)

int main() {
  int n;
  cin>>n;
  nvec(int,d,n);
  sort(all(d));
  cout<<d[n/2]-d[n/2-1];
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    ll a;
    string b;
    cin >> a >> b;
    ll ans;

    ll B = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');

    cout << (a * B / 100) << endl;

    // ans = ll(ll(a / 100) * 100 * b) + ll((a % 100) * b);
    // cout << ll(a * b) << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main() {
    string str;
    cin >> str;
    while(1){
        str.erase(str.end()-2, str.end());
        if(str.substr(0, str.length()/2) == str.substr(str.length()/2, str.back())){
            cout << str.length() << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> G[1005];
int main()
{
    scanf("%d",&n);
    int k = 1;
    while((k*(k-1)/2) < n) k++;
    if(k*(k-1)/2 != n){puts("No");return 0;}
    puts("Yes");cout<<k<<endl;
    int cnt = 0;
    for(int i = 1;i <= k;i++){
        for(int j = i + 1;j <= k;j++) {G[i].push_back(++cnt);G[j].push_back(cnt);}
    }
    for(int i = 1;i <= k;i++){
        printf("%d ",G[i].size());
        for(int j = 0;j < G[i].size();j++) printf("%d ",G[i][j]);
        printf("\n");
    }
    return 0;
}


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

int main(){
  int sum=0;
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    int l,r;
    cin>>l>>r;
    sum+=r+1-l;
  } 
  cout<<sum<<endl;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; ++i) { cin >> v[i]; }

	double sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += (1.0 / v[i]);
	}
	double ans = 1.0 / sum;

	cout.precision(15);
	cout << fixed << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;
    
    vector<int> h;

    rep(i,n){
        int tmp;
        cin >> tmp;

        h.pback(tmp);
    }

    vector<int> c;

    c.pback(0);
    c.pback(abs(h[1] - h[0]));

    for(int i = 2; i < n; i++){
        int cost = min(c[i - 1] + abs(h[i] - h[i - 1]),c[i - 2] + abs(h[i] - h[i - 2]));
        c.pback(cost);
    }

    cout << c[c.size() - 1] << endl;

    return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
 size_t strlen(const char *s);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=100010;
const int P=1000000007;
int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;//a-b昇順
}
//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ
//	cout<<(n-2)*180<<endl;
//	string s="hoge";
//	cout<<ans<<endl;
//	int  n  ,a  ,b  ,c  ,d  ,e  ,f  ;
//	cin  >>n  >>a  >>b  >>c  >>d  >>e  >>f  ;

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	len = strlen(s);
文字列長さ*/


/*
	string s;
	s.size()
*/


/*ソート
	qsort(b, 10, sizeof(int), compare_int);
*/


/*
	char s[N];
	strlen(s)
/*
	if(  <  )puts("Yes");
	else puts("No");
*/
/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/

int main(){
	int n,ans;
	cin>>n;
	ans=-1;
	if(n==1||n==2||n==3||n==4||n==5||n==6||n==7||n==8||n==9||n==10||n==12||n==14||n==15||n==16||n==18||n==20||n==21||n==24||n==25||n==27||n==28||n==30||n==32||n==35||n==36||n==40||n==42||n==45||n==48||n==49||n==54||n==56||n==63||n==64||n==72||n==81){
		puts("Yes");}
	else puts("No");

}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a>b)
	{
		printf("a > b\n");
	}else if(a<b)
	{
		printf("a < b\n");
	}else
	{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2128
N = int(input())

dic = {}

for i in range(N):
	s = input()
	s = ''.join(sorted(s))
	if s in dic:
		dic[s] += int((-1+(1+8*(dic[s]))**0.5)/2)+1
	else:
		dic[s] = 0
print(sum(dic.values()))


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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = 1.01e9;



int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int a, b, c;
    while (cin >> a >> b >> c) {
        int mx = min(c, a + b + 1);
        cout << mx + b << endl;
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 256
import sys
from functools import lru_cache

sys.setrecursionlimit(1000000)


@lru_cache(maxsize=None)
def dfs(v):
    lv = links[v]
    return max(map(dfs, lv)) + 1 if lv else 0


n, m = map(int, input().split())
sss = set(range(n))
links = [set() for _ in range(n)]
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    sss.discard(y)
    links[x].add(y)

print(max(map(dfs, sss)))


Measured memory_bytes: 344536
#
import sys
import math
import numpy as np
import itertools

# いくつか入力
n,k = (int(i) for i in input().split())  
# 空白区切りの数列をリストに代入
p = [int(i) for i in input().split()] 

q = [0]*(n-k+1)

for i in range(k):
    q[0] += p[i]

for i in range(k,n):
    q[i-k+1] = q[i-k]+p[i]-p[i-k]
maxsum=0
for i in range(n-k+1):
    maxsum=max(maxsum,q[i])

print((maxsum+k)/2)


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m; cin>>n>>m;
  vll x(n), y(m);
  rep(i,n) cin>>x[i];
  rep(i,m) cin>>y[i];
  
  vll a(n-1), b(m-1);
  rep(i,n-1) a[i]=x[i+1]-x[i];
  rep(i,m-1) b[i]=y[i+1]-y[i];
  
  n--,m--;
  ll sumx=0;
  rep(i,n){
    sumx+=a[i]*(i+1)%MOD*(n-i)%MOD;
    sumx%=MOD;
  }
  
  ll sumy=0;
  rep(i,m){
    sumy+=b[i]*(i+1)%MOD*(m-i)%MOD;
    sumy%=MOD;
  }
  ll ans=sumx*sumy%MOD;
  cout<<ans<<endl;
 }

Measured memory_bytes: 3456
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

int pos;
ll N, Q, L, A[100005], t[100005], sum[100005];

int binser(int lo, int hi, ll val){
    while(lo < hi){
        int mid = (lo+hi)/2;
        if(A[mid] >= val){
            hi = mid;
        }
        else{
            lo = mid+1;
        }
    }
    return lo;
}

int main(){

    ios :: sync_with_stdio(false);
    cin >> N >> Q;
    A[L++] = N;

    FOR(q,Q){
        ll x;
        cin >> x;
        while(L>0 && A[L-1] >= x) L--;
        A[L++] = x;
    }

    t[L-1] = 1;
    FORD(i,L-1,0){
        ll k;
        for(k=A[i]; k>A[0]; k%=A[pos]){
            pos = binser(0, i+1, k)-1;
            t[pos] += t[i] * (k/A[pos]);
        }
        sum[k] += t[i];
    }

    FORD(i,N-1,1) sum[i] += sum[i+1];
    FOR(i,N) cout << sum[i] << endl;

    return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>

int main(){
	int n, a, b, t, ans=0;
	int i, j, k, l, p, q, far=0, sta[20]={0}, now=0, tail=0, count;
	int lis[20][23];//0-19隣接リスト,20隣接する島への時間の合計,21隣接する島の数,22島1からの時間
	scanf("%d", &n);
	while(n>0)
	{
		for(p=0;p<20;p++)
		{
			for(q=0;q<23;q++)
			{
				lis[p][q]=0;
			}
		}
		for(i=0;i<n-1;i++)
		{
			scanf("%d %d %d", &a, &b, &t);
			lis[a-1][b-1]=t;
			lis[a-1][20]+=t;
			lis[a-1][21]++;
			lis[b-1][a-1]=t;
			lis[b-1][20]+=t;
			lis[b-1][21]++;
		}
		for(j=0;j<n;j++)
		{
			if(lis[j][21]>=2 || j==0) ans+=lis[j][20];
			else if(lis[j][21]==1) ans-=lis[j][20];
		}
		while(now>=0)
		{
			count=0;
			for(k=0;k<n;k++)
			{
				if(lis[sta[now]][k]>0 && lis[k][21]>=2 && lis[k][22]==0 && k>0)
				{
					lis[k][22] = lis[sta[now]][k] + lis[sta[now]][22];
					sta[tail+1] = k;
					tail++;
					count++;
				}
			}
			if(count==0) tail--;
			now=tail;
		}
		for(l=0;l<n;l++)
		{
			if(lis[l][22]>far)far=lis[l][22];
		}
		ans -= far;
		printf("%d\n", ans);
		
		
		scanf("%d", &n);
		far=0;
		now=0;
		tail=0;
		ans=0;
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{
    //ABC141 A

    int N,M;
    cin>>N>>M;

    std::priority_queue<int> que;

    int x;
    for(int i = 0; i < N; i++)
    {
        cin>>x;
        que.push(x);
    }

    

    for (int i = 0; i < M; i++)
    {
    x = que.top();
    que.pop();
    x = x/2;
    que.push(x);
    }
       long long sum = 0;
    for (int i = 0; i < N; i++)
    {
       sum += que.top();
       que.pop();
    }
    

    cout<<sum;

    return 0;
}


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

int main()
{
    int n;
    std::cin>>n;
    std::vector<int> a(n);
    for(int i=0;i<n;i++)std::cin>>a[i];

    int cnt = 0;
    for(int i=0;i<n;i++){
        while(a[i] % 2 == 0){
            a[i] /= 2;
            cnt++;
        }
    }
    std::cout<<cnt<<std::endl;
}

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

int main() {
	char s[4];
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		cin >> s[i];
		if (s[i] == '+')ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int r = sc.NextInt();
        Console.WriteLine(r * r);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

using namespace std;

int num[100005];
int dp[100005];


int main() {
    int n;

    cin >> n;

    for(int i=0; i<n; i++){
        int x;
        scanf("%d",&x);
        num[i] = x;
    }

    dp[1] = INT_MAX;


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

    dp[n-1] = min(dp[n-1],dp[n-2] + abs(num[n-2]-num[n-1]));


    /*for(int i=0; i<n; i++){
        cout << dp[i] << " ";
    }*/

    cout << dp[n-1];

    return 0;
}

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

using namespace std;

typedef pair<int, int> P;

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

int mp[102][102];
int w, h;

void bfs_fill()
{
	queue<P>  que;
	que.push(make_pair(1, 0)); // (y, x)

	mp[1][0] = -1;

	while (que.size()) {
		P p = que.front(); que.pop();
		for (int i = 0; i < 6; ++i) {
			int ny = p.first + dy[i], nx = p.second + dx[p.first % 2][i];
			if (0 <= ny && ny <= h + 1 && 0 <= nx && nx <= w + 1 && mp[ny][nx] == 0) {
				que.push(make_pair(ny, nx));
				mp[ny][nx] = -1;
			}
		}
	}
}

int main()
{
	cin >> w >> h;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> mp[i][j];
		}
	}

	bfs_fill();

	int cnt = 0;

	for (int y = 0; y <= h+1; ++y) {
		for (int x = 0; x <= w+1; ++x) {
			if (mp[y][x] != -1) continue;
			for (int i = 0; i < 6; ++i) {
				int ny = y + dy[i], nx = x + dx[y % 2][i];
				if (1 <= ny && ny <= h && 1 <= nx && nx <= w && mp[ny][nx] == 1) cnt++;
			}
		}
	}

	printf("%d\n", cnt);
}

Measured memory_bytes: 1240
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

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

    vector<int> t(n, 0);

    int a, b;
    REP(i, m){
        cin >> a >> b;
        ++t[a - 1];
        ++t[b - 1];
    }

    REP(i, n) cout << t[i] << endl;
    return 0;
}


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

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;

/////////////

int main(){
    int ni, ai, bi;
    mint n,a,b;
    cin >> ni >> ai >> bi;
    n = (mint)ni; a = (mint)ai; b = (mint)bi;
    
    mint comb[bi+1];
    comb[0] = 1;
    rep2(i,1,bi+1){
        comb[i] = comb[i-1] * (n-(mint)i+1) / (mint)i;
    }

    // mint pow2 = 1;
    // rep(_, ni){
    //     pow2 *= 2;
    // }

    mint pow2 = modpow((mint)2, (ll)ni);

    cout << (pow2 - comb[ai] - comb[bi] - 1) << endl;

    return 0;
}

Measured memory_bytes: 1792
//Reference: youtube解説
#include<iostream>
using namespace std;
#include<string.h>
#include<array>
typedef long long ll;

int main(){
  string S;
  //S = "??????????????????????????"
  cin >> S;
  //13で割ったあまりがkのパターン数
  array<ll, 13 > dp={0};
  dp[0]=1;
 
  ll mul = 1;
  ll mod = 1e9+7;
  
  for(ll i=S.length()-1; i>=0; i--){
    array<ll, 13 > nextDP={0};//次の状態
    //for(int i=0; i<13; i++) cout << nextDP[i]<<endl;
   
    char c=S[i];
    if(c == '?'){
      for(ll k=0; k<10; k++){
	for(ll j=0; j<13; j++){
	  nextDP[(k*mul+j)%13] += dp[j];
	  nextDP[(k*mul+j)%13] %= mod;
	}
      }
    }else{
      ll k= (ll)(S[i]-'0');
     
      for(ll j=0; j<13; j++){
	nextDP[(k*mul+j)%13] += dp[j];
	nextDP[(k*mul+j)%13] %= mod;
      }
       
      //cout<<dp[5] <<endl;
    }
    mul *=10;
    mul %= 13;
    dp = nextDP;
  }
  cout << dp[5] <<endl;
  
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
vector<ll> pref;
ll sum(int l, int r) {
	if (l > r) {
		return 0;
	}
	return pref[r + 1] - pref[l]; 
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	ll m;
	cin >> n >> m;
	vector<int> a(n);
	pref.resize(n + 1);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	
	for (int i = 0; i < n; ++i) {
		pref[i + 1] = pref[i] + a[i];
	}
	int l = 0, r = 2 *  a[n - 1];
	ll answer = 0;
	ll min_plus = 0;
	//~ debug(a);
	while (l <= r) {
		int mid = l + (r - l) / 2;
		//~ debug(mid);
		int p = 0;
		ll cnt = 0;
		for (int i = n - 1; i >= 0; --i) {
			while (p < n && a[p] + a[i] < mid) {
				++p;
			}
			cnt += n - p;
		}
		if (cnt >= m) {
			l = mid + 1;
			min_plus = mid;
		} else {
			r = mid - 1;
		}
	} 
	//~ debug(min_plus);
	int p = 0;
	++min_plus;
	for (int i = n - 1; i >= 0; --i) {
		//~ debug(m);
		while (p < n && a[p] + a[i] < min_plus) {
			++p;
		}
		//~ debug(p, i);
		int cnt = n - p;
		if (m >= cnt) {
			answer += 1ll * cnt * a[i] + sum(p, n - 1); 
			m -= cnt;
		} else {
			assert(false);
		}
	}
		//~ debug(answer);
	--min_plus;
	answer += m * min_plus;
	cout << answer << '\n';
	return 0;
}


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

using namespace std;

constexpr int N = 3e5 + 10;
constexpr int MOD = 998244353;

long long n, A, B, K, fact[N], ans;

long long mypow (long long a, long long b) {
    return b ? (mypow (a * a % MOD, b >> 1) * (b & 1 ? a : 1)) % MOD : 1;
}

long long ch (long long a, long long b) {
    if (b > a)
        return 0;
    return (fact[a] * mypow (fact[b] * fact[a - b] % MOD, MOD - 2)) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> A >> B >> K;
    fact[0] = 1;
    for (int i = 1; i < N; i++)
        fact[i] = (fact[i - 1] * i) % MOD;
    for (int i = 0; i <= n && i * A <= K; i++) {
        // i ta A biad
        long long remain = K - i * A;
        if (remain % B)
            continue;
        int z = remain / B;
        ans += ch (n, i) * ch (n, z) % MOD;
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2560
n, x = map(int, input().split())

list = [x]
a = 1

for X in range(n - 1):
  list.append(x + a)
  list.insert(0, (x - a))
  a += 1
str_list = str(list)
strip_list = str_list.strip("[]")
l = strip_list.replace(",", "")
print(l)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 400010;
int n;
int out[N];
int main() {
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int a;
        cin >> a;
        out[a]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << out[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 4364
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b){printf("%d",c);}
  if(a==c){printf("%d",b);}
  if(b==c){printf("%d",a);}
return 0;
}

Measured memory_bytes: 128
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.regex.Pattern;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            String pile = null;
            long lineNum = 0;
            long resultShowLine = 0;
            
            // ??????????????????
            Pattern p = Pattern.compile("^[0-9]*$");
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                // ???????????¶.
                if ("-".equals(inputStr)) {
                    // do nothing.
                    break;
                }
                
                // ??±??°?????????????????????.
                if (p.matcher(inputStr).find()) {
                    if (lineNumReader.getLineNumber() == lineNum + 1) {
                        // ?????£??????????????°???????????????????????¨?????????????????°????¨????.
                        resultShowLine = resultShowLine
                                + Integer.parseInt(inputStr) + 2;
                        continue;
                    } else {
                        // ?????£?????????????????????
                        int h = Integer.parseInt(inputStr);
                        pile = shuffle(pile, h);
                    }
                } else {
                    pile = inputStr;
                    lineNum = lineNumReader.getLineNumber();
                }
                
                if (lineNumReader.getLineNumber() == resultShowLine) {
                    // ??¢???????????????
                    System.out.println(pile);
                }
            }
            
            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
    
    public static String shuffle(String original, int h) {
        StringBuilder shuffledStr = new StringBuilder(original);
        String temp = shuffledStr.substring(0, h);
        shuffledStr.delete(0, h);
        shuffledStr.append(temp);
        return shuffledStr.toString();
        
    }
}

Measured memory_bytes: 24312
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)
thr = sum(A) / (4*M)
ans = 0
for i in A:
    if i >= thr:
        ans+=1
    else:
        break
if ans >= M:
    print('Yes')
else:
    print('No')

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

	int n;
  scn(n);
  int a[n+1] , b[n];
  for(int i=0; i<=n; i++) scn(a[i]);
	for(int i=0; i<n; i++) scn(b[i]);  
  lli ans = 0;
  
  for(int i=0; i<n; i++){
    
    int take = min(a[i],b[i]);
    
    ans += take;
    b[i] -= take;
   
    take = min(a[i+1],b[i]);
    
    ans += take;
    a[i+1] -= take;
  }
  
  cout<<ans;
  


    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF = 1e9L + 7;

int main() {
    int n,k;
    cin>>n>>k;
    int dp[k+1]={0};
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=1;i<=k;i++){
        for(auto a:x){
            if(i>=a && !dp[i-a]){
                dp[i]=1;
            }
        }
    }
    if(dp[k])
        cout<<"First";
    else cout<<"Second";
    return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

int main() {

	//1 から　9
	//100 kara 999
	//10000 kara 99999
	//1000000 karahanai

	long N; cin >> N;
    long res = 0;
    for(int i = 1; i <= N; i++){
        if (1 <= i && i <= 9) res++;
        if (100 <= i && i <= 999) res++;
        if (10000 <= i && i <= 99999) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256