akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second

using namespace std;

typedef long long LL;
typedef double db;
typedef unsigned int ui;
typedef pair<int,int> pir;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

ui seed;
ui rd(){seed^=seed<<13;seed^=seed>>17;seed^=seed<<5;return seed;}

const int N = 2e+5+5;

int n;
struct node{
	ui val;
	int l,r,key,tot;
	int v[2];
}tree[N];
int fa[N];
int p[N],q[N];
bool bz[N];

int getrt(int x){for(;fa[x];x=fa[x]);return x;}

void update(int x){
	if(tree[tree[x].l].tot&1){
		tree[x].v[0]=min(tree[tree[x].l].v[0],tree[tree[x].r].v[0]);
		tree[x].v[1]=min(tree[tree[x].l].v[1],tree[tree[x].r].v[1]);
	}
	else{
		tree[x].v[0]=min(tree[tree[x].l].v[0],tree[tree[x].r].v[1]);
		tree[x].v[1]=min(tree[tree[x].l].v[1],tree[tree[x].r].v[0]);
	}
	tree[x].v[(tree[tree[x].l].tot+1)&1]=min(tree[x].v[(tree[tree[x].l].tot+1)&1],tree[x].key);
	tree[x].tot=tree[tree[x].l].tot+tree[tree[x].r].tot+1;
}

int merge(int x,int y){
	fa[x]=fa[y]=0;
	if (!x||!y)return x^y;
	if (tree[x].val<tree[y].val){
		y=merge(tree[x].r,y);
		fa[y]=x,tree[x].r=y;
		update(x);
		return x;
	}
	x=merge(x,tree[y].l);
	fa[x]=y,tree[y].l=x;
	update(y);
	return y;
}

int findth(int x,int y){
	if (x==y)return tree[tree[x].l].tot+1;
	if (y<x)return findth(tree[x].l,y);
	return tree[tree[x].l].tot+1+findth(tree[x].r,y);
}

pir split(int x,int k){
	fa[x]=0;
	if (!k)return make_pair(0,x);
	if (k>=tree[x].tot)return make_pair(x,0);
	if (k<=tree[tree[x].l].tot){
		pir u=split(tree[x].l,k);
		tree[x].l=u.se;
		if (u.se)fa[u.se]=x;
		update(x);
		return make_pair(u.fi,x);
	}
	pir u=split(tree[x].r,k-tree[tree[x].l].tot-1);
	tree[x].r=u.fi;
	if (u.fi)fa[u.fi]=x;
	update(x);
	return make_pair(x,u.se);
}

set<int>s;

void del(int x){
	int rt=getrt(x);
	s.erase(tree[rt].v[1]);
	int k=findth(rt,x);
	pir u=split(rt,k);
	if (u.se)s.insert(tree[u.se].v[1]);
	u=split(u.fi,k-1);
	if (u.fi)s.insert(tree[u.fi].v[1]);
}

int main(){
	n=get();
	seed=16792369;
	fo(i,1,n){p[i]=get();q[p[i]]=i;}
	int rt=0;
	tree[0].v[0]=tree[0].v[1]=1E+9;
	fo(i,1,n){
		tree[i].val=rd();
		tree[i].key=tree[i].v[1]=p[i];
		tree[i].v[0]=1e+9;
		tree[i].tot=1;
		rt=merge(rt,i);
	}
	s.clear();
	s.insert(tree[rt].v[1]);
	fo(i,1,n/2){
		int x=*s.begin(),y;
		int rt=getrt(q[x]);
		pir u=split(rt,findth(rt,q[x]));
		if (tree[u.se].tot&1){
			y=tree[u.se].v[1];
			merge(u.fi,u.se);
			if (q[x]<q[y])printf("%d %d ",x,y);
			else printf("%d %d ",y,x);
			del(q[x]),del(q[y]);
			bz[y]=1;
		}
		else merge(u.fi,u.se);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	string res[100000];
	map<string,int> rmap;
	cin>>n;
	rmap["AC"]=0;
	rmap["WA"]=0;
	rmap["TLE"]=0;
	rmap["RE"]=0;
	for(int i=0; i<n; i++) {
		cin>>res[i];
		rmap[res[i]]++;
	}

	cout<<"AC"<<" x "<<rmap["AC"]<<endl;
	cout<<"WA"<<" x "<<rmap["WA"]<<endl;
	cout<<"TLE"<<" x "<<rmap["TLE"]<<endl;
	cout<<"RE"<<" x "<<rmap["RE"]<<endl;
	
	return 0;
}

Measured memory_bytes: 6760
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    ll x;
    cin >> x;
    
    ll A = -1000;
    ll B = -1000;
    int found = 0;
    
    for(ll a = -1000; a <= 1000; a++){
        if (found) break;
        for(ll b = -1000; b <= 1000; b++){
            if (found) break;
            if ((ll)pow(a,5)-(ll)pow(b,5) == x){
                if(found == 0){
                    A = a; B = b;
                    found = 1;
                }
            }
        }
    }
    cout << A << " " << B;
}





Measured memory_bytes: 4096
//### In The Name Of GOD ###

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const int MOD = 1000000007;
const int INF = 30 * 1000 + 20;
const int MAXN = 2600;
const int MLOG = 18;
const int NMAX = 60;

#define int ll
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define ct(x) const_cast<const int&>(x)

vector<int> primes;

bool prime(int x){
	for(int a : primes){
		if(x%a==0){
			return false;
		}
	}
	return true;
}

int32_t main(){
	primes.pb(2);
	for(int i = 3;i < MAXN;i++){
		if(prime(i)){
			primes.pb(i);
		}
	}
	int n;
	cin >> n;
	int ans = 1;
	int kk[primes.size()]={};

	for(int i = 1; i <= n ; i++){
		int a = i;
		for(int j=0;j<sz(primes);j++){
			while(a % primes[j]==0){
				a/=primes[j];
				kk[j]++;
			}
		}
	}	
	for(int i=0;i<sz(primes);i++){
//		if(kk[i] > 0)
//			cout << primes[i] << ' ' << kk[i] << endl;
		ans *= kk[i] + 1;
		ans %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int minof(int min, int x) {
  min = (min < x) ? min:x;
  return min;
}
 
int slovei(int, int);
int slovei(int a, int b) {
  int i, j, k, l, o, p, min, temp, d[4] = {};
  min = 268435456;
  for(i = 1; i*i<= a; i += 1) {
    if(a % i == 0) {
      for(k = 1; k*k <= b; k += 1) {
        if(b % k == 0) {
          j = a / i;
          d[0] = i;
          d[1] = j;
          l = b / k;
          d[2] = k;
          d[3] = l;
          for(o = 0; o < 3; o += 1) {
            for(p = 3; p >= o; p -= 1) {
              if(d[p] < d[p - 1]) {
               temp = d[p];
               d[p] = d[p - 1];
               d[p - 1] = temp;
              }; 
            }; 
          }; 
          min = minof(min, (d[1] - d[0]) * (d[1] - d[0]) + (d[2] - d[1]) * (d[2] - d[1]) + (d[3] - d[2]) * (d[3] - d[2]));
        }; 
      }; 
    }; 
  }; 
  return min;
}
 
int main() {
  int a, b;
 
  while(1) {
    scanf("%d %d", &a, &b);
    if(a == 0 && b == 0) {
      break;
    }; 
    printf("%d\n", slovei(a, b));
  };
 
  return 0;
}

Measured memory_bytes: 600
#include<stdlib.h>
#include<stdio.h>
#include<string.h>



int main(){
    int N,M;
    scanf("%d %d",&N,&M);
    int H[N];
    int A[100000]={};
    for (int i=0; i<N; i++) {
        scanf("%d",&H[i]);
    }
    int a,b;
    for (int i=0; i<M; i++) {
        scanf("%d %d",&a,&b);
        if(A[a-1]<H[b-1]){
            A[a-1]=H[b-1];
        }
        if(A[b-1]<H[a-1]){
            A[b-1]=H[a-1];
        }
    }
    int sum=0;
    for (int i=0; i<N; i++) {
        if(A[i]<H[i]){
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 2508
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n,m;
    
    cin >> n;
    
    int a[n];
    
    rep(i,0,n) cin >> a[i];
    
    cin >> m;
    int b[m];
    rep(i,0,m) cin >> b[i];
    
    
    rep(i,0,min(n,m)){
        if(a[i] > b[i]){
            cout << 0 << endl;
            return 0;
        }
        else if(a[i] < b[i]){
            cout << 1 << endl;
            return 0;
        }
    }
    
    if(n < m){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define REP(i,a,b) for(int i=a; i<b; i++)

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

const int MX=1e5+3, mod=1e9+7;

int n;
ll dp[MX][2];
vector<int> edg[MX];

void dfs(int v, int par=0){
	dp[v][0]=dp[v][1]=1;
	for(auto u:edg[v]) if(u!=par){
		dfs(u,v);
		dp[v][0]=dp[v][0] * ((dp[u][0]+dp[u][1])%mod)%mod;
		dp[v][1]=(dp[v][1]*dp[u][0])%mod;
	}
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	REP(i,1,n){
		int u, v;
		cin>>u>>v;
		edg[u].pb(v);
		edg[v].pb(u);
	}
	dfs(1);
	cout<<(dp[1][0]+dp[1][1])%mod<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    map<string, ll> X;
    REP(i,N){
        string s;
        cin >> s;
        X[s]++;
    }

    ll high = -1;
    for(auto&& p : X){
        chmax(high, p.second);
    }

    //set<string> OK;
    for(auto&& p : X){
        if(high == p.second){
            //if(OK.find(p.first) != OK.end())
            //    continue;
            cout << p.first << endl;
            //OK.insert(p.first);
        }
    }
    return 0;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll mod=1e9+7;
vector<double> v;
vector<vector<double>> dp;
double solve(int i,int x)
{
  if(x<=0)
  return 1;
  if(i==0)
  return 0;
  if(dp[i][x]!=-1)
  return dp[i][x];
  double ans=v[i-1]*solve(i-1,x-1)+(1-v[i-1])*solve(i-1,x);
  return dp[i][x]=ans;
} 
int main()
{
  int n;
  cin>>n;
  v.resize(n);
  dp.resize(n+1,vector<double>(n+1,-1));
  for(double& x: v)
  cin>>x;
  cout<<fixed<<setprecision(10)<<solve(n,n/2+1)<<endl;
  return 0;
}


Measured memory_bytes: 74084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

bool debug = 0;

ll fracmod(ll n) {
    ll ret = 1;
    for (int i = 1; i <= n; i++) {
        ret *= i;
        ret %= MOD;
    }
    return ret;
}

void solve() {
    ll n, m;
    cin >> n >> m;
    ll ans;
    ans = fracmod(n) * fracmod(m) % MOD;
    if (n == m) ans *= 2;
    if (abs(n - m) > 1) ans = 0;
    ans %= MOD;
    cout << ans << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}

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

int main(){
  vector<int> s={
    1, 1, 1, 2, 1, 2, 1, 5,
    2, 2, 1, 5, 1, 2, 1, 14,
    1, 5, 1, 5, 2, 2, 1, 15,
    2, 2, 5, 4, 1, 4, 1, 51};
  
  int k;cin >> k;
  
  cout << s[k-1] << endl;
  
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    double n, x, t;
    long int res;
    cin >> n >> x >> t;
    if(n>x){
        //cout << "ceil: " << ceil(n/x) << "\n";
        res = (int)ceil(n/x)*t;
        cout << res << "\n";
    }
    else{
        res = (int)t;
        cout << res << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int dp[30000];

int main() {
    int h, n; cin >> h >> n;
    typedef pair<int, int> P;
    vector<P> ab(n);
    rep(i,n) {
        int a, b; cin >> a >> b;
        ab[i].first = a, ab[i].second = b;
    }

    rep(i,h+1) {
        dp[i] = 1e9;
    }
    dp[0] = 0;

    rep(i,n) {
        rep(j,h) {
            chmin(dp[min(h, j+ab[i].first)], dp[j]+ab[i].second);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int direct = x*a+y*b;
		int A = 0;
		int B = 0;
		int indirect = 0;
		if(x>y) {
			A = 2*y*c+(x-y)*a;
			indirect = Math.min(A, 2*x*c);
		}else {//
			B = 2*x*c+(y-x)*b;
			indirect = Math.min(B, 2*y*c);
		}	
		System.out.println(Math.min(direct, indirect));
	}
}

Measured memory_bytes: 26956
from fractions import gcd

N=int(input())
A=list(map(int, input().split()))
B=list(reversed(A))

for i in range(1, N):
	A[i] = gcd(A[i], A[i-1])
	B[i] = gcd(B[i], B[i-1])

B=list(reversed(B))

print(max([A[N-2], B[1]] + [gcd(A[i-1], B[i+1]) for i in range(1,N-1)]))


Measured memory_bytes: 90848
H, W, N = list(map(int, input().split()))
sr, sc = list(map(int, input().split()))
S = input()
T = input()

k = sc - 1
for i in range(N):
  if S[i] == "R":
    k += 1
    if k >= W:
      print("NO")
      exit()
  if T[i] == "L":
    k = max(k - 1, 0)

k = sc - 1
for i in range(N):
  if S[i] == "L":
    k -= 1
    if k < 0:
      print("NO")
      exit()
  if T[i] == "R":
    k = min(k + 1, W - 1)

k = sr - 1
for i in range(N):
  if S[i] == "D":
    k += 1
    if k >= H:
      print("NO")
      exit()
  if T[i] == "U":
    k = max(k - 1, 0)

k = sr - 1
for i in range(N):
  if S[i] == "U":
    k -= 1
    if k < 0:
      print("NO")
      exit()
  if T[i] == "D":
    k = min(k + 1, H - 1)

print("YES")

Measured memory_bytes: 44880
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
char text[1001];
int main(){
    int i,ii,j,n,a;
    cin>>n;   
    for(i=0;i<=n;i++){
        gets(text);
		a=strlen(text);
		for(j=0;j<a-6;j++){
              if(text[j]=='H'&&text[j+1]=='o'&&text[j+2]=='s'&&text[j+3]=='h'&&text[j+4]=='i'&&text[j+5]=='n'&&text[j+6]=='o'){
                   text[j+6]='a';j+=6;
               }
            }
			if(i==0)continue;
            cout<<text<<endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#define N 100001
typedef struct {
  int x;
  char c;
  int num;
}per;
per A[N];
int Partition(per* A,int p,int r){
  per k=A[r],tmp;
  int i=p-1,j;
  for(j=p;j<r;j++){
    if(A[j].x <= k.x){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;
    return i+1;
}

void Quicksort(per* A,int p,int r){  
  int q;
if(p<r){
  q=Partition(A,p,r);
  Quicksort(A,p,q-1);
  Quicksort(A,q+1,r);
 }
}

int main(){
  int i,k,n,flag=0;
  scanf("%d",&n);
 
  for(i=0;i<n;i++){

    scanf(" %c %d",&A[i].c,&A[i].x);
    A[i].num=i;
}
  Quicksort(A,0,n-1);
  for(i=1;i<n;i++){
    if(A[i].x==A[i-1].x){
      if(A[i].num<A[i-1].num)flag=-1;
    }

  }
  if(flag==0)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].c,A[i].x);
  }
  
  
  
  return 0;
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "\t" << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl << "\t", dump_func(__VA_ARGS__);
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  string S; cin >> S;
  int ans = 0;
  int acc = 0;
  REP (i, S.size()) {
    if (S[i] == 'B') {
      acc++;
    } else {
      ans += acc;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 720
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    string s = "";
    cin >> s;
    vector<ll> ans(s.size());
    int odd = 0, even = 0;
    for (int i=0; i<s.size()-1; i++) {
        if (s.at(i) == 'L') continue;
        if (s.at(i+1) == 'L') {
            ans.at(i+1) += even;
            ans.at(i) += odd+1;
            odd = 0;
            even = 0;
        }
        else {
            odd++;
            swap(odd, even);
        }
    }
    for (int i=s.size()-1; i>0; i--) {
        if (s.at(i) == 'R') continue;
        if (s.at(i-1) == 'R') {
            ans.at(i-1) += even;
            ans.at(i) += odd+1;
            odd = 0;
            even = 0;
        }
        else {
            odd++;
            swap(odd, even);
        }
    }
    for (int i=0; i<s.size(); i++) {
        cout << ans.at(i);
        if (i == s.size()-1) cout << endl;
        else cout << " ";
    }
    return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
A,B,C=map(int,input().split())
K = int(input())
S = max(A,B,C) #入力された整数の最大のものを選ぶ
L = [A,B,C] #入力された整数のリスト化
L.remove(S)
P = sum(L , S*2**K)
print(P)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
//vector <bool> prime(boolsize,1);
//void seive()
//{
//    ll n=boolsize;
//    prime[0]=prime[1]=0;
//    for(ll i=2;i<=sqrt(boolsize);i++)
//    {
//        if(prime[i]==1)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//            {
//                prime[j]=0;
//            }
//        }
//    }
//}

/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n>>k;
    vi v(n);
    fo(i,n)
    cin>>v[i];
    sort(v.begin(),v.end(),comp<ll>);
    ll sum=0;
    fo(i,k)
    sum+=v[i];
    cout<<sum<<endl;

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

        //fun();
        vfun();
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not




Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    long long sum = 0;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
        sum += a[i];
    }
    
    sort(a.begin(),a.end());

    cout << a[0] << " " << a[n - 1] << " " << sum << endl;
  
    return 0;
}


Measured memory_bytes: 3200
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long



int N;
vector<int> L;
bool check(int a,int b, int c){
	if(c < a + b){
		return true;
	}
	else{
		return false;
	}
}
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  L.resize(N);

  REP(i,N){
  	cin >> L[i];
  }
  sort(all(L));
  int ans = 0;
  for(int a = 0; a < N; a++){
  	for(int b = a + 1; b < N; b++){
  		int ok = b;
  		int ng = N;
  		while(abs(ng - ok) > 1){
  			int c = (ok + ng) / 2;
  			if(check(L[a],L[b],L[c])){
  				ok = c;
  			}
  			else{
  				ng = c;
  			}
  		}

  		ans += ok - b;
  	}
  }
  cout << ans << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  string s;
  stack<char> a;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] != s[i + 1])
      a.push(s[i]);
  }
  cout << a.size() - 1 << endl;
  return 0;
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

m = 1000
s = 0

mx = [0] * n
for i in range(1, n):
    if a[i-1] < a[i]:
        mx[i] = 1
        mx[i-1] = 0
        
mn = [0] * n
for i in range(1, n):
    if a[i-1] >= a[i]:
        mn[i] = 1
        mn[i-1] = 0
        
if a[0] < a[1]:
    mn[0] = 1
    
mn[-1] = 0

for i in range(n):
    if mx[i] == 1:
        m += s * a[i]
        s = 0
    if mn[i] == 1:
        s += m//a[i]
        m -= m//a[i] * a[i]

print(m)

Measured memory_bytes: 62000
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
h = list(map(int, input().split()))

INF = float('inf')
dp = [INF for _ in range(n)]
dp[0] = 0

for i in range(1, n):
    l, r = max(i - k, 0), i
    dp[i] = min([pdp + abs(h[i] - ph) for pdp, ph in zip(dp[l:r], h[l:r])])

print(dp[-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a, b;
  long long c, d;
  long long cnt = 0;
  long long x;
  long long gcd;

  cin >> a >> b >> c >> d;

  cnt = b - a;
  gcd = __gcd(c, d);
  x = (c / gcd) * d;
  cnt -= (((b / c) + (b / d) - (b / x)) - ((a / c) + (a / d) - (a / x)));

  if(a % c != 0 && a % d != 0) cnt ++;
  cout << cnt << endl;
  return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 924844033 
#define N 100005
#define M 1000003
#define LOG 20
#define KOK 250
#define EPS 0.0000001
using namespace std;

int n,m;
int a[N],pind[N<<1];
ll pre[N<<1],dc[N<<1];
ll ans;

int main() {

	scanf("%d %d",&n,&m);

	for(int i=1;i<=n;i++) {

		scanf("%d",&a[i]);

		if(i-1) {

			if(a[i]<a[i-1]) a[i]+=m;

			pind[a[i-1]+1]--;
			pind[a[i]+1]++;

			pre[a[i-1]+1]+=a[i-1]+1;
			pre[a[i]+1]-=a[i-1]+1;

			ans+=a[i]-a[i-1];
			
			if(a[i]>m) a[i]-=m;

		}

	}

	ll d=0;

	for(int i=1;i<=2*m;i++) {

		pind[i]+=pind[i-1];
		pre[i]+=pre[i-1];

		int ind=i>m?i-m:i;

		dc[ind]+=(ll)pind[i]*i+pre[i];

		umin(d,dc[ind]);

	}

	printf("%lld",ans+d);

}

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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    const int dx = tx - sx, dy = ty - sy;
    string ans="";
    ans += string(dx, 'R') + string(dy, 'U');
    ans += string(dx, 'L') + string(dy, 'D');

    ans += 'D' + string(dx+1, 'R') + string(dy+1, 'U') + 'L';
    ans += 'U' + string(dx+1, 'L') + string(dy+1, 'D') + 'R';
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
#include<iostream>
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> P2;

int r,w[2],h[2],x[2],y[2];
int l[2][501][501],num,prv;
int d[2][501][501];
vector<P> v[2];
int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

void dijkstra(int k){
  v[k].clear();
  for(int i=1;i<=h[k];i++)
    for(int j=1;j<=w[k];j++)d[k][i][j] = 100000000;
  
  priority_queue<P2,vector<P2>,greater<P2> > q;
  q.push(P2(l[k][y[k]][x[k]],P(y[k],x[k])));
  num = prv = 0;
  
  while(q.size()){
    P2 p = q.top(); q.pop();
    int lv = p.first, sy = p.second.first, sx = p.second.second;

    if(d[k][sy][sx] <= lv)continue;
    d[k][sy][sx] = lv;
    if(prv != lv){
      v[k].push_back(P(num,prv));
      prv = lv;
    }
    num++;

    for(int i=0;i<4;i++){
      int tlv = lv, ty = sy+dy[i], tx = sx+dx[i];
      if(ty<1 || tx<1 || h[k]<ty || w[k]<tx)continue;
      if(tlv<l[k][ty][tx])tlv = l[k][ty][tx];
      if(tlv < d[k][ty][tx]){
	q.push(P2(tlv,P(ty,tx)));
      }
    }
  }
  v[k].push_back(P(num,prv));
}

int main(){
  while(scanf("%d",&r), r){
    for(int k=0;k<2;k++){
      scanf("%d%d%d%d",&w[k],&h[k],&x[k],&y[k]);
      for(int i=1;i<=h[k];i++)
	for(int j=1;j<=w[k];j++)scanf("%d",&l[k][i][j]);

      dijkstra(k);
      sort(v[k].begin(),v[k].end());
    }

    int ans = 200000000;
    for(int i = (int)v[0].size()-1;i>=0;i--){
      P tmp = P(r-v[0][i].first,0);
      vector<P>::iterator it = lower_bound(v[1].begin(),v[1].end(),tmp);
      if(it == v[1].end())break;
      else ans = min(ans,v[0][i].second + (*it).second);
    }
    printf("%d\n",ans);
  }
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

int  N;
pii p[55];

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

  cin >> N;
  rep(i,N) cin >> p[i].fi >> p[i].se;
  int ma = 0;
  vector<pii> ds;
  rep(i,N){
    rep(j,N){
      if (i!=j){
        ds.pb(pii(p[i].fi-p[j].fi, p[i].se-p[j].se));
      }
    }
  }
  for(const auto& d : ds) {
    int s = 0;
    for(const auto& dd : ds) {
      if (d.fi==dd.fi&&d.se==dd.se) {
        s++;
      }
    }
    ma = max(ma, s);
  }
  int ans = N - ma;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{ 
    static void Main(string[]args)
    {
        Magatro m = new Magatro();
        m.Scan();
        m.Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;
    private string[] S;
    private int Index;

    private const char Separator=' ';

    public Scanner()
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(Console.OpenStandardInput());
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[]LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }

    public bool ScanToEnd(ref string s)
    {
        if (Sr.EndOfStream)
        {
            return false;
        }
        else
        {
            s = Sr.ReadLine();
            return true;
        }
    }
}

public class Magatro
{
    private int N;
    private int[] A, B;
    public void Scan()
    {
        Scanner sc = new Scanner();
        N = sc.NextInt();
        A = new int[N];
        B = new int[N];
        for(int i = 0; i < N; i++)
        {
            A[i] = sc.NextInt();
            B[i] = sc.NextInt();
        }
    }

    public void Solve()
    {
        long ans = 0;
        for(int i = N - 1; i >= 0; i--)
        {
            long a = A[i]+ans;
            long b = B[i];
            if (a % b != 0)
            {
                ans += b - (a % b);
            }
        }
        Console.WriteLine(ans);
    }
}





Measured memory_bytes: 7512
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=1000000007;
//
int main(){
	int n=0;
	cin>>n;
	int ans[100001]={};
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			for(int k=1;k<=100;k++){
				if(i*i+j*j+k*k+i*j+j*k+k*i<=n){
					ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//vector< vector<int> > v (size1, vector<int>(size2) );

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 510000;

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

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;

    vector<pair<long long, long long> > prm;

    prm=prime_factorize(m);
    
    ll ans=1;
    for(auto e:prm){
        //cout<<e.first<<' '<<e.second<<endl;
        ans*=COM(e.second+n-1,n-1)%MOD;
        ans%=MOD;
    }
    
    cout<<ans%MOD<<endl;
    

}


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

int main()
{
	int n;
	long long total=0;
	scanf("%d", &n);
	int minnum=0x7fffffff;
	for (int i=1; i<=n; ++i)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		total+=a;
		if (a>b) minnum=min(minnum, b);
	}
	if (minnum==0x7fffffff) printf("0\n");
	else printf("%lld\n", total-minnum);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int n, a, b;
  cin >> n >> a >> b;

  cout << min(a * n, b) << endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long double ll;

ll N, K, Q;
vector<ll> A;

int main() {
    cin >>N >> K >> Q;
    A.resize(Q);
    for (int i = 0; i < Q; i++) {cin >> A[i]; A[i]--;}
    vector<ll> P(N);
    for (int i = 0; i < Q; i++) {
      P[A[i]]++;
    }
    for (int i = 0; i < N; i++){
        if(K-abs(P[i]-Q)>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    } return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++)
    {
        cin >> p.at(i);
    }

    int answer = 0;

    for(int i=0;i<n-2;i++)
    {
        vector<int> V = {p.at(i),p.at(i+1),p.at(i+2)};
        
        if(V.at(0) == *min_element(V.begin(),V.end()) && V.at(2) == *max_element(V.begin(),V.end()) ||
        V.at(2) == *min_element(V.begin(),V.end()) && V.at(0) == *max_element(V.begin(),V.end()))
        {
            answer++;
        }
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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 long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n,ans=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)cin>>a[i];
	while(1){
		for(i=0;i<n;i++){
			if(a[i]%2==0)a[i]/=2;
			else{
				cout<<ans<<endl;
				return 0;
			}
		}
		ans++;
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 200005;
const ll MOD = 1e9+7;
ll C[MAX_N],pow4[MAX_N];

void calc_pow()
{
	pow4[0] = 1;
	rep(i,MAX_N-1)
	{
		pow4[i+1] = (pow4[i] * 4) % MOD;
	}
}

int main()
{
	calc_pow();
	ll N;
	cin >> N;
	rep(i,N)
	{
		cin >> C[i];
	}
	sort(C,C+N);
	reverse(C,C+N);
	ll ans = 0;
	rep(i,N)
	{
		ans = (ans + (C[i] * pow4[N-1] % MOD) * (i+2) % MOD) % MOD;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v.at(i);
    std::sort(v.begin(), v.end(), std::greater<ll>());
    ll sum = 0;
    for(int i = k; i < n; i++) sum += v.at(i);
    cout << sum << endl;
    return 0;
}


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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

int d[334334];

int tmp[114514];

signed main() {
  int n;
  cin >> n;
  rep(i, 3 * n) {
    cin >> d[i];
  }
  int all = 0;
  priority_queue<int, vector<int>, greater<int>> pq1;
  rep(i, n) {
    all += d[i];
    pq1.push(d[i]);
  }
  trep(i, n) {
    tmp[i] = all;
    all += d[i + n];
    pq1.push(d[i + n]);
    all -= pq1.top();
    pq1.pop();
  }
  all = 0;
  priority_queue<int> pq2;
  int ans = -inf * inf;
  rep(i, n) {
    all += d[i + 2 * n];
    pq2.push(d[i + 2 * n]);
  }
  for(int i = n; i >= 0; i--) {
    ans = max(ans, tmp[i] - all);
    all += d[i - 1 + n];
    pq2.push(d[i - 1 + n]);
    all -= pq2.top();
    pq2.pop();
  }
  cout << ans << endl;
}


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

int main(){
  int a, h, w;
  cin >> h >> w;
  a = 0;
  char b[h + 2][w + 2];
  int c[h + 2][w + 2];
  for(int i = 0; i < h + 2; i++){
    b[i][0] = '#';
    b[i][w + 1] = '#';
  }
  for(int i = 0; i < w + 2; i++){
    b[0][i] = '#';
    b[h + 1][i] = '#';
  }
  for(int i = 1; i < h + 1; i++){
    for(int j = 1; j < w + 1; j++){
      cin >> b[i][j];
    }
  }
  for(int i = 1; i < h + 1; i++){
    for(int j = 1; j < w + 1; j++){
      if(b[i][j] == '.'){
        for(int k = 0; k < h + 2; k++){
          for(int l = 0; l < w + 2; l++){
            c[k][l] = 401;
          }
        }
        c[i][j] = 0;
        for(int k = 0; k < 400; k++){
          for(int l = 1; l < h + 1; l++){
            for(int m = 1; m < w + 1; m++){
              if(b[l][m] == '.'){
                if(b[l][m - 1] == '.')
                  c[l][m] = min(c[l][m], c[l][m - 1] + 1);
                if(b[l][m + 1] == '.')
                  c[l][m] = min(c[l][m], c[l][m + 1] + 1);
                if(b[l - 1][m] == '.')
                  c[l][m] = min(c[l][m], c[l - 1][m] + 1);
                if(b[l + 1][m] == '.')
                  c[l][m] = min(c[l][m], c[l + 1][m] + 1);
              }
            }
          }
        }
        for(int k = 1; k < h + 1; k++){
          for(int l = 1; l < w + 1; l++){
            if(c[k][l] < 401)
              a = max(a, c[k][l]);
          }
        }
      }
    }
  }
  cout << a << endl;
}

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

int main(void) {
    int N;cin>>N;
    string S;cin>>S;
    int i = 0;
    int result = 0;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    while (i <= N - 2) {
        if (S.size() <= 1) break;
        string tmp = S.substr(i, 2);
        if (tmp == "OX" || tmp == "XO") {
            result++;
            i += 2;
        } else {
            i++;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3332
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
 
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = s; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 

int main() {
    string s;
    cin >> s;
    vector<int> as(s.size()+1, 0);
    int p = 0;
    REP(i, s.size()) {
        if (s[i] == '<') {
            as[i] = p++;
        } else {
            as[i] = p;
            p = 0;
        }
    } 
    if (s[s.size()-1] == '<') as[s.size()] = p; 
    p = 0;
    for(int i = s.size()-1; i >= 0; --i) {
       if (s[i] == '>') {
            as[i+1] = p++;
        } else {
            as[i+1] = max(as[i+1], p);
            p = 0;
        }
    }
    if (s[0] == '>') as[0] = p; 
    ll ret = 0;
    REP(i, s.size()+1) ret +=as[i]; 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back

using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    long long n;
    char ch;
    string s;
    cin>>n;
    cout<< n + n*n + n*n*n;
	return 0;
}

Measured memory_bytes: 3648
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main() {
    ll n;
    ll a[100010];
    ll b[100010];
    std::cin >> n;
    for (int i = 0; i < n+1; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }
    ll result = 0;
    
    for (int i = n-1; i >= 0; i--) {
        result += min(a[i+1],b[i]);
        b[i] -= min(a[i+1],b[i]);
        if(b[i]>0){
            result += min(a[i],b[i]);
            a[i] -= min(a[i],b[i]);
        }
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	long long int N; scanf("%lld", &N);
	long long int ret = 10000000000000;
	for (long long int i = 1; i*i <= N; i++){
		if (0 == N%i){
			ret = min(ret, i + N / i - 2);
		}
	}

	printf("%lld", ret);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<long long> A(N, 0);
	long long accum = 0;
	long long even_accum = 0;

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

		accum += A[i];
		even_accum += ((i + 1) % 2 == 0) ? A[i] : 0;
	}

	long long X = accum - 2 * even_accum;
	cout << X << " ";

	for (int i = 1; i < N; i++)
	{
		X = 2 * A[i - 1] - X;
		cout << X << " ";
	}

	return 0;
}

Measured memory_bytes: 2176
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[(1<<16)];
ll sums[(1<<16)];

ll calculate(vector<vector<int>>& score,int mask)
{
    ll ans = 0;
    for(int i = 0; i < 17; i ++)
    {
        for(int j = i+1; j < 17; j ++)
        {
            if(((mask&(1<<i))!=0) && ((mask&(1<<j))!=0))
                ans += score[i][j];
        }
    }
    return ans;
}

void prepareSums(vector<vector<int>>& score,int n)
{
    for(int subset = 1; subset < (1<<n); subset++)
        dp[subset] = inf;
    for(int subset = 1; subset < (1<<n); subset++)
        sums[subset] = calculate(score, subset);
}

ll solve(vector<vector<int>>& score,int mask)
{
    if(mask == 0)
        return 0;
    if(dp[mask] != inf)
        return dp[mask];
    
    ll ans = 0;
    for(int submask = mask; submask != 0; submask = (submask-1)&mask)
         ans = max(ans, sums[submask] + solve(score, mask ^ submask));
    
    return dp[mask] = ans;
}

int main(){
    int n;
    cin>>n;
    vector<vector<int>> score(n, vector<int>(n));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> score[i][j];
    prepareSums(score,n);
    cout << solve(score, (1<<n) - 1);
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
 
typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/
int main()
{
  int N, A;
  cin >> N >> A;
  int m = N % 500;
  if(m <= A) cout << "Yes" << endl;
  else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256