akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100 + 2)

int n;
int a[MAX_N];
int dp[100002][2];

bool is_win(int k, int player){
  bool result = false;

  if(dp[k][player] != 0){
    return dp[k][player] == 1;
  }

  for (int i = 0; i < n; i++){
    if (k >= a[i]){
      result |= !is_win(k - a[i], 1 - player);
    }
  }

  dp[k][player] = result ? 1 : -1;

  return result;
}

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

  cout << (is_win(k, 0) ? "First" : "Second") << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[205],b[205];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    memset(b,0,sizeof(b));
    for(int i=0;i<n;i++){
        for(int j=0;;j++){
            if(a[i]%2==0){
                b[i]++;
                a[i]=a[i]/2;
            }
            else if(a[i]%2==1){
                break;
            }
        }
    }
    sort(b,b+n);
    cout <<b[0];
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a, xy = [], []
for _ in range(n):
    a_t = int(input())
    xy_t = [list(map(int, input().split())) for _ in range(a_t)]
    a.append(a_t)
    xy.append(xy_t)

ans = 0
for i in range(2**n):
    flag = True
    for j in range(n):
        if (i >> j) & 1:
            for k in xy[j]:
                if (i >> (k[0]-1)) & 1 != k[1]:
                    flag = False
                    break
    if flag:
        ans = max(ans, bin(i).count('1'))
print(ans)

Measured memory_bytes: 9256
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  if(s.size()==a+b+1){
    rep(i,s.size()){
      if(i==a){
        if(s[i]=='-'){
          //pass
        }else{
          cout<<"No"<<endl;
          return 0;
        }
      }else{
        if(s[i]>='0'&&s[i]<='9'){
          //pass
        }else{
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }else{
    cout<<"No"<<endl;
    return 0;
  }

  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	constexpr int max_card = 300000;
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int n, q; std::cin >> n >> q;
	std::vector<int> max_cards(max_card + 1, 0);
	{
		int c;
		for (auto i = 0; i < n; ++i) {
			std::cin >> c;
			max_cards[c] = c;
		}
	}
	for (auto i = 1; i < max_cards.size(); ++i) {
		max_cards[i] = std::max(max_cards[i], max_cards[i - 1]);
	}
	for (auto _i = 0; _i < q; ++_i) {
		int mod; std::cin >> mod;
		int max_rest = max_cards.back() % mod;
		for (auto i = mod - 1; i < max_cards.size(); i += mod) {
			max_rest = std::max(max_rest, max_cards[i] % mod);
		}
		std::cout << max_rest << '\n';
	}
}


Measured memory_bytes: 4144
#include<iostream>
using namespace std;
int main(){
	for(;;){
		int a,b;string op;
		cin>>a>>op>>b;
		if(op=="?")break;
		else if(op=="+"){cout<<a+b<<endl;}
		else if(op=="-"){cout<<a-b<<endl;}
		else if(op=="*"){cout<<a*b<<endl;}
		else {cout<<a/b<<endl;}
		
	}
	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

bool check(ll x, ll y, ll z) {
    return (x < y + z && y < x + z && z < x + y);
}
void solve() {
    int n;
    cin >> n;
    vecll a(n);
    for(auto &it : a) cin >> it;
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            for(int k = j + 1; k < n; ++k) {
                if(a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) continue;
                if(check(a[i], a[j], a[k])) ans++;
            }
        }
    }
    cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e3 + 5;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
ll fastpow(ll b, ll e) {
    if (!e)
        return 1;
    ll ret = fastpow(b, e / 2);
    ret = (ret * ret) % mod;
    if (e % 2)
        ret = (ret * b) % mod;
    return ret;
}
ll modinv(ll x) {
    return fastpow(x, mod - 2);
}
double torad(double ang) {
    return ang * pi / 180.0;
}

ll dp[N][N];
string mat[N];
int main()
{
    ///smallest/largest case
    ///initialize
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        cin >> mat[i];
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (mat[i][j] == '#')
                continue;
            if (i > 0)
                dp[i][j] = (dp[i - 1][j] + dp[i][j]) % mod;
            if (j > 0)
                dp[i][j] = (dp[i][j - 1] + dp[i][j]) % mod;
        }
    }
    printf("%lld", dp[n - 1][m - 1]);
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  map<char, int> b;
  int m = 0;
  for (int i = 1; i < n - 1; i++) {
    string sl = s.substr(0, i);
    string sr = s.substr(i);
    b.clear();
    for (int i = 0; i < sl.size(); i++) {
      char c = sl[i];
      if (sr.find(c) != string::npos) {
        if (b.find(c) == b.end()) {
          b[c] = 0;
        } else {
          b[c]++;
        }
      }
    }
    m = max(m, (int)b.size());
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 3240
n = int(input())
A = list(map(int,input().split()))
d = {}
for a in A:
    d.setdefault(a,0)#setdefault(key,value):辞書の既存のkeyについては変更せず
    d[a] += 1       #新規のkeyにのみ新たなvalueで要素を追加できる   
#今は({A1:1,A2:1,...An:1}となっている)
A = sorted(set(A))#重複要素なくしてかつ昇順にする
t = [True] * (10 ** 6 + 1)#Aiの制約範囲最大までのTrueのリストを作る

for a in A:
    if d[a] > 1:
        t[a] = False
    for i in range(a+a, 10 ** 6 + 1, a):#自分自身を含めないためのa+a
        t[i] = False
print(sum(1 for a in A if t[a]==True))

Measured memory_bytes: 44216
N = int(input())
F = [[int(i) for i in input().split()] for _ in range(N)]
P = [[int(i) for i in input().split()] for _ in range(N)]

ans = -float('inf')

for i in range(1, 1024):
    B = bin(i)[2:][::-1]
    count = [0]*N
    s = 0
    for i, b in enumerate(B):
        if b == '1':
            for j, f in enumerate(F):
                if f[i] == 1:
                    count[j] += 1
    for p, c in zip(P, count):
        s += p[c]
    ans = max(ans, s)
print(ans)


Measured memory_bytes: 42352
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

const ll MOD = 1e9+7;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    ll N,K,cnt=0,n;
    cin >>N>>K;
    
    FOR(b,K+1,N){
        n=N/b;
        cnt+=(b-K)*n;
        if(N-(b*n)>=K) cnt+=(N-(b*n)-K+1);
        if(K==0) cnt--;
    }
    cout <<cnt<<endl;
    
    return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ


#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PARENT(i) ((i)/2)

//priorityに対してプライオリティキューを構築
typedef struct{
    double priority;
    double value;
}heapdata; //heapの構造体の中の要素を定義

//ヒープ二分木のポインタをheap型と定義
typedef struct{
    int max_size; //ヒープ二分木(配列A)の中に格納できる最大要素数
    int heap_size; //ヒープ二分木(配列A)の中に現在入っている要素の数
    heapdata* A; //要素を格納するための配列(ポインタ)
}* heap;

//ヒープH内の配列のA[i]とA[j]の値を入れ替える関数
void heap_swap(heap H,int i,int j){
    heapdata tmp;
    
    tmp=H->A[i];
    H->A[i]=H->A[j];
    H->A[j]=tmp;
    
    return;
}

//ヒープの削除
void free_heap(heap H){
    free(H);
    return;
}

//HEAPIFY O(nlogn)

//A[i]を根とする部分木がヒープになるように整序する関数
void heapify(heap H, int i){
    int l,r,largest,size;
    heapdata* A;
    
    l=LEFT(i); //iの左の子の添字
    r=RIGHT(i); //iの右の子の添字
    size=H->heap_size; //今のヒープHのサイズ
    A=H->A; //ヒープ二分木に格納されている要素の配列
    
    //以下largestを決めるコード
    if(l>size&&r>size){
        largest=i;
    }
    else if(l<=size&&r>size){
        if(A[l].priority>A[i].priority){
            largest=l;
        }
        else{
            largest=i;
        }
    }
    else{
        if(A[r].priority>A[l].priority){
            largest=r;
        }
        else{
            largest=l;
        }
        if(A[i].priority>A[largest].priority){
            largest=i;
        }
    }
    
    if(largest!=i){
        heap_swap(H,i,largest);
        heapify(H,largest);
    }
    
    return;
}

//BUILD_HEAP O(n)

//要素n個の配列A、max_sizeをもつヒープ木Hのメモリを確保し出力する関数
heap heap_build(int n, heapdata* A, int max_size){
    int i;
    heap H;
    NEW(H,1);
    
    H->max_size=max_size;
    H->heap_size=n;
    H->A=A;
    
    for(i=n/2;i>=1;i--){
        heapify(H,i);
    }
    
    return H;
}

//EXTRACT_MAX O(logn)

//ヒープ木の中の最大要素を削除し、その最大要素を除いたヒープ木を再構成する関数
heapdata extract_max(heap H){
    int n=H->heap_size;
    
    heap_swap(H,1,n);
    H->heap_size=n-1;
    heapify(H,1);
    
    return H->A[n];
}

//data xをヒープHに挿入する関数
void heap_insert(heap H,heapdata x){
    int n=H->heap_size;
    
    if(n==H->max_size){
        printf("ERROR　cannot insert anymore\n");
        return;
    }
    else{
        H->A[n+1]=x;
        H->heap_size=n+1;
        
        int i=n+1;
        while(PARENT(i)>=1&&H->A[i].priority>H->A[PARENT(i)].priority){
            heap_swap(H,i,PARENT(i));
            i=PARENT(i);
        }
        return;
    }
}


int main(void){
    int N, M;
    scanf("%d %d",&N, &M);

    heapdata* A;
    NEW(A,N+1); //A[1]~A[N]と思われ
    for(int i=1;i<=N;i++){
        scanf("%lf",&A[i].priority);
    }

    heap H = heap_build(N,A,N);
    while(M!=0){
        heapdata h = extract_max(H);
        h.priority=(h.priority)/2;
        heap_insert(H,h);
        M--;
    }

    long ans=0;
    for(int i=1;i<=N;i++){
        int tmp=A[i].priority;
        ans+=tmp;
    }
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int remove_bit(int x, int j) {
  int low = x & ((1 << j) - 1);
  return ((x >> (j + 1)) << j) + low;
}
int insert_bit(int x, int j, int v) {
  int low = x & ((1 << j) - 1);
  return ((x >> j) << (j + 1)) + (v << j) + low;
}
vector<int> solve (int n, int a, int b) {
  if (n == 1) {
    return {a, b};
  }
  for (int j = 0; j < n; j++) {
    if ((a ^ b) & (1 << j)) {
      int aa = remove_bit(a, j);
      int bb = remove_bit(b, j);
      for (int u = 0; u < (1 << n); u++) {
        int uu = remove_bit(u, j);
        if (uu != aa && uu != bb) {
          if (__builtin_popcount(aa ^ uu) % 2 == 0) {
            continue;
          }
          if (__builtin_popcount(bb ^ uu) % 2 == 0) {
            continue;
          }
          vector<int> p1 = solve(n - 1, aa, uu);
          vector<int> p2 = solve(n - 1, uu, bb);
          for (int& x : p1) {
            x = insert_bit(x, j, (a >> j) & 1);
          }
          for (int& x : p2) {
            x = insert_bit(x, j, (b >> j) & 1);
          }
          p1.insert(p1.end(), p2.begin(), p2.end());
          return p1;
        }
      }
    }
  }
  assert(false);
  return {};
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  if (__builtin_popcount(a ^ b) % 2 == 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  vector<int> p = solve(n, a, b);
  set<int> val(p.begin(), p.end());
  for (int i = 0; i < (1 << n); i++) {
    assert(0 <= p[i] && p[i] < (1 << n));
  }
  for (int i = 0; i < (1 << n) - 1; i++) {
    assert(__builtin_popcount(p[i] ^ p[i + 1]) == 1);
  }
  for (int i = 0; i < (1 << n); i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << p[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 7664
#include<stdio.h>

int main(void)

{
	int a, b, c, d, e, f;

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


	if ((-d <= b - a && b - a <= d) && (-d <= c - b && c - b <= d))
		printf("Yes");
	else if (-d <= a - c && a - c <= d)
		printf("Yes");
  else
		printf("No");

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n,a,b;
	cin>>n>>a>>b;
	if(a>b)
		swap(a,b);
	ll x=abs(a-b);
	if(x%2==0)
	{
		cout<<x/2<<endl;
		return;
	}
	ll y=min(a-1,n-b);
	ll ans=((x+1)/2);
	//cout<<"ans:"<<ans<<endl;
	ans+=y;
	cout<<ans<<endl;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 2000000;


int main() {
    int N;
    cin>>N;
    string S,T;
    cin>>S>>T;
    string ans="";
    for(int i=0;i<N;i++){
        ans+=S[i];
        ans+=T[i];
    }
    cout<<ans<<endl;







}


Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []
for i in range(M):
    a,b = map(int,input().split())
    P.append(a)
    X.append(b)
for i in range(M):
    S = 0
    for j in range(N):
        if j==P[i]-1:
            S+=X[i]
        else:
            S+=T[j]
    print(S)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;


ll dp[101][101][303];
ll w[100100];
ll v[100100];
ll w1;
int n;
ll f(int i,int j,int s){
    if(i == n){
        if(j*w[0]+s <= w1)
            return 0;
        return -1e15;
    }
    if(dp[i][j][s] != -1)
        return dp[i][j][s];
    ll r1 = f(i+1,j,s);
    ll r2 = f(i+1,j+1,s+w[i]-w[0])+v[i];
    return dp[i][j][s] = max(r1,r2);
}

int main(){
    cin>>n>>w1;
    for(int i= 0 ;i <n ;i ++){
        scanf("%I64d%I64d",&w[i],&v[i]);
    }
    memset(dp,-1,sizeof dp);
    cout<<f(0,0,0)<<endl;
    return 0;
}


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

l = a[:]
while len(l) > 1:
    midx = l.index(min(l))
    r = []
    for i in range(len(l)):
        if i != midx:
            l[i] = l[i] % l[midx]
        if l[i] != 0:
            r.append(l[i])
    l = r[:]
print(l[0])

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    cout << (ll)pow(2, m) * (1900 * m + 100 * (n-m)) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
 
template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}
 
const int MN = 3030;
int n;
V<ll> a;
ll dp[MN][MN];
bool vis[MN][MN];
ll solve(int l, int r) {
    if (r + 1 == l) return 0;
    if (vis[l][r]) return dp[l][r];
    vis[l][r] = true;
    ll ans = max(a[l] - solve(l + 1, r), a[r] - solve(l, r - 1));
    return dp[l][r] = ans;
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    cin >> n;
    a = V<ll>(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    cout << solve(0, n-1) << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    map<P,int> mp;
    rep(i,n-1){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
        mp[P(a,b)] = c;
        mp[P(b,a)] = c;
    }
    int q, k;
    cin >> q >> k;
    k--;

    queue<int> que;
    vector<ll> dist(n, -1);

    dist[k] = 0;
    que.push(k);
    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int nv : g[v]){
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v] + mp[P(v,nv)];
            que.push(nv);
        }
    }

    rep(i,q){
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << dist[x] + dist[y] << endl;
    }
}

Measured memory_bytes: 22732
R, C, K = map(int, input().split())

Items = [[0] * (C + 1) for _ in range(R + 1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    Items[r][c] = v


DP = [[0] * 4 for _ in range(R + 1)]

for x in range(1, C+1):
    for y in range(1, R+1):
        v = Items[y][x]
        if v:
            DP[y][3] = max(DP[y][3], DP[y][2] + v)
            DP[y][2] = max(DP[y][2], DP[y][1] + v)
            DP[y][1] = max(max(DP[y][1], DP[y][0] + v), max(DP[y-1]) + v)
            DP[y][0] = max(DP[y][0], max(DP[y-1]))
        else:
            DP[y][0] = max(DP[y][0], max(DP[y-1]))

print(max(DP[R]))

Measured memory_bytes: 147296
s = input()
n = len(s) + 1
dp = [0] * n
for i, c in enumerate(s):
  if c == '<':
    dp[i+1] = dp[i] + 1

for i, c in enumerate(reversed(s)):
  if c == '>':
    dp[-i-2] = max(dp[-i-2], dp[-i-1] + 1)

print(sum(dp))
  

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

ans = 0
for i in range(N):
    if A[i] < B[i]:
        ans += A[i]
        ans += min(A[i+1],B[i]-A[i])
        A[i+1] = max(0,A[i+1] - (B[i]-A[i]))
        A[i] = 0
    else:
        ans += B[i]
        A[i] = A[i]-B[i]

print(ans)

Measured memory_bytes: 18624
unittest
{
	assert( [ "3", "1 2 1" ].parse.expand.solve == "1\n1\n2" );
	assert( [ "2", "2 2" ].parse.expand.solve == "-1" );
	assert( [ "9", "1 1 1 2 2 1 2 3 2" ].parse.expand.solve == "1\n2\n2\n3\n1\n2\n2\n1\n1" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	return tuple( bs );
}

auto solve( long[] bs )
{
	// 操作を逆順にして、全部揃っている状態から削除する場合を考える
	auto anss = new long[]( bs.length );
	LOOP: foreach_reverse( ref ans; anss )
	{
		foreach_reverse( j; 0 .. bs.length )
		{
			if( bs[ j ] != j + 1 ) continue;
			ans = bs[ j ];
			bs = bs[ 0 .. j ] ~ bs[ j + 1 .. $ ];
			continue LOOP;
		}
		return "-1";
	}
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;



int main()
{
    string s;
    cin >> s;
 
 
    REP(i,s.size()){
        cout << "x";
    }
 
    
    

  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    String S = scanner.next();
    for (int i = 0; i < S.length(); i++) {
      for (int j = i; j <= S.length(); j++) {
        String T = S.substring(0, i) + S.substring(j);
        if (T.equals("keyence")) {
          System.out.println("YES");
          return;
        }
      }
    }
    System.out.println("NO");
  }
}


Measured memory_bytes: 25812
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);

	int a,b;
	cin >> a >> b;

	if ((1<=a)&&(a<=9)&&(1<=b)&&(b<=9))
	{
		cout << a*b << endl;
	}
	else
	{
		cout << "-1" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a); i >= (b); --i)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;
const ll MOD =  1e9+7;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(v) (cout<<#v<<" = "<<v<<endl)
#define endln (cout<<endl)
template <class T> inline void dbv(T a) {  for(auto x : a){ cout<<x<<", " ;} cout<<endl;}
vector<vector<pair<ll,ll> > >g;
map<pair<vector<char>,vector<char> >,ll> counts(vector<char> s)
{
    ll n = s.size();
    map<pair<vector<char>,vector<char> >,ll> mpx;
    FOR(i,0,(1<<n))
    {
        vector<char> p1;
        vector<char> p2;
        FOR(j,0,n)
        {
            if(((1<<j)&i)>0)
            {
                p1.pb(s[j]);
            }
            else
            {
                p2.pb(s[j]);
            }
        }
        pair<vector<char>,vector<char> > p = mp(p1,p2);
        mpx[p]++;
    }
    return mpx;
} 
void output(ll tx)
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<char> sf;
    FOR(i,n,2*n)
    {
        sf.pb(s[i]);
    }
    ll cnt = 0;
    map<pair<vector<char>,vector<char> >,ll> mpx = counts(sf);
    FOR(i,0,(1<<n))
    {
        ll p1 = 0;
        ll p2 = n-1;
        vector<char> t1;
        vector<char> t2;
        FOR(j,0,n)
        {
            if(((1<<j)&i)>0)
            {
                t1.pb(s[j]);
                p1++;
            }
            else
            {
                t2.pb(s[j]) ;
                p2--;
            }
        }
        reverse(t2.begin(),t2.end());
        reverse(t1.begin(),t1.end());
        cnt += mpx[mp(t1,t2)];
    }
    cout<<cnt<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t =1;
    // cin>>t;
    FOR(i,0,t)
    {
        output(i+1) ;
    }
    return 0 ;
}

Measured memory_bytes: 82176
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb push_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;

using namespace std;

const int N = 5e5 + 10, mod = 1e9 + 7, inf = 1e18 + 7, logn = 23;
const double pi = acos(-1);

int dp[N], t[4 * N];

int get(int v, int tl, int tr, int l, int r) {
	if(l > tr || tl > r) return 0;
	if(tl == l && tr == r) {
		return t[v];
	}

	int tm = (tl + tr) / 2;
	int gol = get(v + v, tl, tm, l, min(r, tm)),
		gor = get(v + v + 1, tm + 1, tr, max(l, tm + 1), r);

	return max(gol, gor);
}

void update(int v, int tl, int tr, int pos, int val) {
	if(tl == tr) {
		t[v] = val;
	} else {
		int tm = (tl + tr) / 2;
		if(pos <= tm) {
			update(v + v, tl, tm, pos, val);
		} else {
			update(v + v + 1, tm + 1, tr, pos, val);
		}
		t[v] = max(t[v + v], t[v + v + 1]);
	}
}

void solve() {
	//soln
	int n;
	cin >> n;
	vector<int> h(n), a(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		dp[h[i]] = a[i];
	}

	int ans = 0;
	for(int i = 0; i < n; i++) {
		int mx = get(1, 1, n, 1, h[i] - 1);
		dp[h[i]] = max(dp[h[i]], mx + a[i]);
		update(1, 1, n, h[i], dp[h[i]]);
		ans = max(ans, dp[h[i]]);
	}

	cout << ans << endl;
}
main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}
		

Measured memory_bytes: 12084
#include <stdio.h>
#include <string.h>
#define LEN 100005

// 構造体
// 名前と残りの時間を持つ
typedef struct {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b; }


int main() {
    int elaps = 0, c;
    int i, q;
    P u;
    
    scanf("%d %d", &n, &q);
    for (i=1; i<=n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;
    
    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) enqueue(u);
        else {
            printf("%s %d\n", u.name, elaps);
        }
    }
    
    return 0;
}


Measured memory_bytes: 12844
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    ll n,ans=0;
    string s;
    vector<ll> sr,sg,sb;
    map<ll,char> m;
    cin>>n>>s;
    rep(i,n)
    {
        if(s[i]=='R') sr.pb(i);
        if(s[i]=='G') sg.pb(i);
        if(s[i]=='B') sb.pb(i);
        m[i]=s[i];
    }
    rep(i,sr.size())
    {
        ll a=sr[i];
        rep(j,sg.size())
        {
            ll b=sg[j];
            ans+=sb.size();
            if(m[2*b-a]=='B') ans--;
            if((a+b)%2==0&&m[(a+b)/2]=='B') ans--;
            if(m[2*a-b]=='B') ans--;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 4352
#include <stdio.h>
double map[7][2]={{35.5,71.0},{37.5,77.0},{40.0,83.0},{43.0,89.0},{50.0,105.0},{55.0,116.0},{70.0,148.0}};
char map1[7][4]={"AAA","AA","A","B","C","D","E"};
int main(void){
    int i;
    double t1,t2;
    for(;~scanf("%lf %lf",&t1,&t2);){
        for(i=0;i<7;i++)
            if(map[i][0] > t1 && map[i][1] > t2)
                break;
        printf("%s\n",i==7?"NA":map1[i]);
    }
    return 0;
}

Measured memory_bytes: 608
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    # 1-indexに
    a = [0] + list(map(int, input().split()))
    c = [0 for _ in range(n + 1)]

    # See
    # https://www.youtube.com/watch?v=-o4r74eJzV4
    # 全体の計算量は，O(N^2)のようにみえて，O(NlogN)
    # 箱iの番号が大きいものから見る
    for i in range(n, 0, -1):
        # ボールの個数の和を0で初期化
        ball_count = 0

        # iの倍数の箱を順番に見る
        # ループの範囲を[2 * i, n]として，i個飛ばしで
        for j in range(2 * i, n + 1, i):
            # mod2は，xor（排他的論理和）を使うと言い換えるとスマートに記述できる．
            # ただし，演算の順序に注意が必要
            ball_count ^= c[j]

        # i個ずつみた後の合計(mod2)とa[i]を比べる
        c[i] = a[i] ^ ball_count

    # 出力
    # ボールが入っている箱の個数とその番号
    ans = [index for index, ci in enumerate(c) if ci == 1]
    print(len(ans))
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 19892
#include <stdio.h>

int ARR_ADJ[101][101];
void refleshARR(int c,int d,int n);

int main(){
	
	int n,k;
	int dflg;
	int a,b;
	int c,d,e;

	int i,j;
	int cost;

	while(1){
		scanf("%d%d\n",&n,&k);
		if(n==0 && k==0)break;
		
		for(i=0;i<=n;i++)for(j=0;j<=n;j++) ARR_ADJ[i][j]=-1;
		for(i=0;i<=n;i++)ARR_ADJ[i][i]=0;
		
		for(i=0;i<k;i++){
			scanf("%d",&dflg);
			if(dflg==1){
				scanf("%d%d%d",&c,&d,&e);
				if(ARR_ADJ[c][d]==-1 || ARR_ADJ[c][d]>e )ARR_ADJ[c][d]=ARR_ADJ[d][c]=e;

				refleshARR(c,d,n);
			}
			if(dflg==0){
//dbg1(n);
				scanf("%d%d",&a,&b);
				cost=ARR_ADJ[a][b];	
				printf("%d\n",cost);
			}
		}
	}

	return 0;
}


void refleshARR(int c,int d,int n){
	int i,j;
	int cost0;

	for(i=0;i<=n;i++){
		for(j=i+1;j<=n;j++){
			if(ARR_ADJ[i][c]!=-1&&ARR_ADJ[d][j]!=-1){
				cost0=ARR_ADJ[i][c]+ARR_ADJ[c][d]+ARR_ADJ[d][j];
				if(ARR_ADJ[i][j]==-1||ARR_ADJ[i][j]>cost0)ARR_ADJ[i][j]=ARR_ADJ[j][i]=cost0;
			}
			if(ARR_ADJ[i][d]!=-1&&ARR_ADJ[c][j]!=-1){
				cost0=ARR_ADJ[i][d]+ARR_ADJ[d][c]+ARR_ADJ[c][j];
				if(ARR_ADJ[i][j]==-1||ARR_ADJ[i][j]>cost0)ARR_ADJ[i][j]=ARR_ADJ[j][i]=cost0;
			}
		}
	}
	return;

}

Measured memory_bytes: 644
using System;

namespace abc097b
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            int stop = (int)Math.Sqrt(x) + 1;
            int ans = 1;
            for (int i=2; i<stop; i++)
            {
                for (int j=2; j<11; j++)
                {
                    int p = (int)Math.Pow(i, j);
                    if (p > x) break;
                    ans = Math.Max(ans, p);
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
bool check(string str){
    int p=str.find('+');
    int e=str.find('=');
    stringstream ss;
    string s[3];
    s[0]=str.substr(0,p);
    s[1]=str.substr(p+1,e-p-1);
    s[2]=str.substr(e+1,str.length()-e-1);
    if((s[0][0]=='0'&&s[0].length()!=1)||(s[1][0]=='0'&&s[1].length()!=1)
       ||(s[2][0]=='0'&&s[2].length()!=1))return false;
    int ma=max(s[0].length(),max(s[1].length(),s[2].length()));
    for(int i=0;i<3;i++)reverse(s[i].begin(),s[i].end());
    for(int i=0;i<3;i++){
        for(int j=s[i].length();j<=ma;j++)s[i]+='0';
    }
    int up=0;
    for(int i=0;i<=ma;i++){
        int v1=s[0][i]-'0',v2=s[1][i]-'0',v3=s[2][i]-'0';
        int val=v1+v2+up;
        if(val%10!=v3)return false;
        if(val>9)up=1;
        else up=0;
    }
    return true;
}
int main(){
    string str;
    while(cin>>str){
        int ans=-1;
        for(int i=0;i<=9;i++){
            string s=str;
            while(true){
                if(s.find('X')==string::npos)break;
                s[s.find('X')]=i+'0';
            }
            if(check(s)){
                ans=i;
                break;
            }
        }
        if(ans==-1)cout<<"NA"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
int D[10];

int main(){
  int N,K,i,h,flag,temp;
  scanf("%d %d",&N,&K);
  for(i=0;i<K;i++){
    scanf("%d",&h);
    D[h]=1;
  }
  
  do{
    flag=0;
    temp=N;
    while(temp!=0){
      if(D[temp%10]==1){
          flag=1;
          break;
      }else{
          temp=temp/10;
      }
    }
    if(flag==1)
      N++;
  }while(flag!=0);
  
  
  printf("%d\n",N);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

typedef long long ll;

int n, k;
int w[100001];

bool check(int p){
  ll sum=0;
  int idx = 0;

  rep(i, k){
    sum = 0;
    while(w[idx] + sum <= p){
      sum+=w[idx];
      idx++;
      if(idx == n) return true;
    }
  }
  return false;
}

signed main(){
  cin >> n >> k;

  rep(i, n) cin >> w[i];

  // binary search
  ll left = 0, right = 100000 * 10000;
  while(right - left > 1){
    ll mid = (left + right) / 2;
    if(check(mid)) right = mid;
    else left = mid;
  }

  cout << right << endl;
}


Measured memory_bytes: 3476
#include<iostream>
using namespace std;
int main()
{
	int k,n;
	cin>>k>>n;
	int ans=INT_MAX;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
    int arr[2*n];
    for(int i=0;i<n;i++)
    {
    arr[i]=a[i];
    arr[i+n]=k+a[i];	
    }
    for(int i=0;i<=n;i++)
    {
    ans=min(ans,arr[i+n-1]-arr[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 5524
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++)
        {if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}
    return C[n][k];
 }

ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
// code now
   
    string s;
    cin>>s;
    fori(s.size()){cout<<"x";}
    
//code ends
    return 0;
}


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

using namespace std;

int main()
{
	string a,b;
	cin>>a>>b;
	a=a+a;
	int res=a.find(b),l=b.size();
	for(int i=res;i<res+l;i++){
		if(a[i]!=b[i-res]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 500000
#define S_IN 1000000000
int L[N],R[N];
int count=0;
void merge(int A[],int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i,j;
  for(int i=0;i<n1;i++)L[i] = A[left + i];
  for(int i=0;i<n2;i++)R[i] = A[mid + i];
  L[n1] = 2*S_IN;
  R[n2] = 2*S_IN;
  i = 0;
  j = 0;
  for (int k = left;k<right;k++){
    count++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  if (left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(){
  int A[N],n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",count);

  return 0;
}



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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

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

  int p = n/2, g = n-p;

  int ans = 0;
  rep(i, g) if(s[i] == 'p') --ans;
  rep(i, p) if(s[i+g] == 'g') ++ans;

  cout << ans << endl;
}


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

char s[51][51];

bool ispair(int i, int j) {
  if (i-1 >= 0 && s[i-1][j] == '#') return true;
  if (i+1 <= 51 && s[i+1][j] == '#') return true;
  if (j-1 >= 0 && s[i][j-1] == '#') return true;
  if (j+1 <= 51 && s[i][j+1] == '#') return true;
  return false;
}

int main() {
  int H, W;
  cin>>H>>W;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++) cin>>s[i][j];
 
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      if (s[i][j] == '#')
        if (!ispair(i,j)) {
          cout<<"No"<<endl;
          exit(0);
        }

  cout<<"Yes"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const long long mod = 1e9 + 7;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n,k;
    cin >> n >> k;
//    if(k >= n)
//        cout << 1 << endl;
//    else
//    {
        ll sum = 0,Min = 0,Max = 0,num1 = k,num2 = n-k,ans = 0;
//        for(int j = 0,a = k;a > 0;a--,j++)
//            Min += j;
//        for(int j = n,a = k;a > 0;a--,j--)
//            Max += j;
        for(int i = k;i <= n+1;i++)
            ans=(ans+(ll)i*(2*n-i+1)/2-(ll)i*(i-1)/2+1)%mod;
        cout << ans << endl;
//    }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define M 998244353
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	cin>>t;
  	int a=0,b=0,c=0,d=0;
	for(int i0=0;i0<t;i0++)
	{
		string s;
      	cin>>s;
      	if(s.size()==3)
        {
          c++;
        }
      	else
        {
          if(s[0]=='A')
          {
            a++;
          }
          else if(s[0]=='W')
          {
            b++;
          }
          else if(s[0]=='R')
          {
            d++;
          }
        }
	}
    cout<<"AC x "<<a<<endl;
      cout<<"WA x "<<b<<endl;
      cout<<"TLE x "<<c<<endl;
      cout<<"RE x "<<d<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
vector<vector<ll>> graph;
vector<ll> as;
map<P, ll> number;
ll rmemo[101][300001];
ll memo[101][300001];
int main() {
    ll n;
    cin >> n;
    map<ll, ll> cnt;
    rep(i, 1, 105) {
        rep(j, 1, 105) {
            rep(k, 1, 105) { cnt[((i + j) * (i + j) + (i + k) * (i + k) + (k + j) * (k + j)) / 2]++; }
        }
    }
    rep(i, 1, n + 1) { cout << cnt[i] << endl; }
}

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

void solve1()
{
    int A, B, C;
    cin >> A >> B >> C;
    if(A + B+C >= 22) {
        cout<<"bust"<<endl;
    } else {
        cout << "win" <<endl;
    }

}

int main()
{
    solve1();
    return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, m = LI()
X = LI()

X.sort()
# print(X)
C = []
for i in range(m - 1):
    C.append(abs(X[i + 1] - X[i]))

# print(C)
C.sort()
C.reverse()
ans = 0
for i in range(n - 1, m):
    if i >= m - 1:
        break
    ans += C[i]
    # print(ans)

print(ans)


Measured memory_bytes: 13684