akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	int cnt = 0;
	int n, k;
	cin >> n >> k;
	while(n != 0) {
		cnt++;
		n /= k;	
	}
	if(cnt == 0) ++cnt;
	cout << cnt << endl;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
main :: IO ()                                                                                                              
main = do                                                                                                                  
  n <- getLine                                                                                                             
  let sn = sum . map (read . (:[])) $ n                                                                                    
      nn = read n                                                                                                          
  putStrLn $ if nn`mod`sn==0 then "Yes" else "No"

Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;

int main(void){
	string s;
	cin >> s;
	int K;
	cin >> K;
	vector<string> sub_s;

	for(int k = 1; k < K+1; k++){
		for(int i = 0; i < s.length(); i++){
			string S = s.substr(i,k);
			sub_s.push_back(S);
		}
	}

	sort(sub_s.begin(), sub_s.end());
	sub_s.erase(std::unique(sub_s.begin(), sub_s.end()), sub_s.end());
	cout << sub_s[K-1] << endl;
	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

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

  return 0;
}

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

void bubblesort(int n, int a[]){
  int count = 0;
  for(int i = 0; i < n; i++){
    for(int j = n-1; j>i; j--){
      if(a[j] < a[j-1]){
        int tmp = a[j];
        a[j] = a[j-1];
        a[j-1] = tmp;
        count++;
      }
    }
  }
  for(int i = 0; i < n-1; i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  cout << count << endl;

  return ;
}

int main(int argc, char const *argv[]) {
  int a[101], n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  bubblesort(n, a);
  return 0;
}

Measured memory_bytes: 3044
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char

main :: IO ()
main = do
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ foldl (\acc c-> if c == 'B' then take (length acc - 1) acc else acc ++ [c]) [] s


Measured memory_bytes: 380
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include<math.h>
//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
/************************************************************************************/
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
/**************/

int main()
{
	int n;
	cin >> n;
	if (n == 7 || n == 5 || n == 3)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
const ll MOD=1e9+7;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> b(N),a;
  rep(i,N){
    cin >> b[i];
  }

  while(b.size() > 0){
    auto it=b.end()-1, mItr=b.end();
    int max = b[b.size()-1];
    int count=b.size();

    while(it-b.begin() >= 0){
      if(count == *it){
        mItr = it;
        max = *it;
        break;
      }
      count--;
      it--;
    }
    if(mItr == b.end()){
      cout << -1 << endl;
      return 0;
    }
    a.push_back(max);
    b.erase(mItr);
    if(b.size()==0) break;
  }

  rep(i,a.size()){
    cout << a[a.size()-1-i] << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s; cin >> s;
	int n = s.size() / 2;
	int ans = 0;
	for (int i = 1; i < n; i++){
		for (int j = 0; j < i; j++) {
			if (s[j] != s[i + j]) {
				goto cont;
			}
		}
		ans = max(ans, i);
	cont:;
	}
	cout << ans * 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (n == i * j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, N, A, sum=0;
  cin >> H >> N;
  for (int i=0; i<N; i++){
    cin >> A;
    sum += A;
  }
  if(sum >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 1000
#define MAX(a, b) (((a) > (b)) ? (a): (b))
int lcs(char*, char*);
int main(void)
{
  int i, n;
  char s1[N+1], s2[N+1];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%*c%s%*c%s", s1, s2);
    printf("%d\n", lcs(s1, s2));
  }
}
int lcs(char *s1, char *s2)
{
  int i, j, maxl = 0, c[N+1][N+1], m = strlen(s1), n = strlen(s2);
  for (i = 1; i <= m; i++) c[i][0] = 0;
  for (j = 1; j <= n; j++) c[0][j] = 0;
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      if (s1[i-1] == s2[j-1]) {
        c[i][j] = c[i-1][j-1] + 1;
      } else {
        c[i][j] = MAX(c[i-1][j], c[i][j-1]);
      }
      maxl = MAX(maxl, c[i][j]);
    }
  }
  return maxl;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<string> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

struct Vec {

    double x, y;

    double size() {
        return sqrt(x * x + y * y);
    }

    double inner_product(Vec v2) {
        return x * v2.x + y * v2.y;
    }

    Vec product(double rate) {
        Vec v2;
        v2.x = x * rate;
        v2.y = y * rate;
        return v2;
    }
};


struct Point {
    double x, y;

    Point plus(Vec vec) {
        Point p;
        p.x = x + vec.x;
        p.y = y + vec.y;
        return p;
    }

    friend istream &operator>>(istream &is, Point &f) {
        cin >> f.x >> f.y;
        return is;
    }

};

struct Line {
    Point start, end;

    Vec to_vec() {
        Vec vec;
        vec.x = end.x - start.x;
        vec.y = end.y - start.y;
        return vec;
    }

    friend istream &operator>>(istream &is, Line &f) {
        cin >> f.start >> f.end;
        return is;
    }

};

int main() {
    Line line;
    cin >> line;
    Vec v_l1 = line.to_vec();

    int q;
    cin >> q;
    rep(i, q) {

        Line line2;
        line2.start = line.start;
        cin >> line2.end;

        Vec v_l2 = line2.to_vec();
        double bunshi = v_l1.inner_product(v_l2);
        double bunbo = v_l1.size() * v_l1.size();
        double rate = bunshi / bunbo;
        Vec ans_vec = v_l1.product(rate);
        Point ans_p = line.start.plus(ans_vec);
        printf("%.20f %.20f\n", ans_p.x, ans_p.y);
    }

}



Measured memory_bytes: 3296
N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
c=sum(A)-N*(N+1)/2
for i in range(len(A)):
  if A[i]==c:
    se.append(i)

mod=10**9+7
 
#階乗計算
factorial=[1]
for i in range(1,N+2):
    factorial.append(factorial[i-1]*i %mod)
#逆元計算
inverse=[0]*(N+2)
inverse[N+2-1] = pow(factorial[N+2-1], mod-2,mod)
for i in range(N+2-2, -1, -1):
    inverse[i] = inverse[i+1] * (i+1) % mod
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
if N==1:
  print(N)
else:
  for i in range(1,N+1):
    print(int(nCr(N+1,i+1)-nCr(se[0]+N-se[1],i))%mod)


Measured memory_bytes: 16484
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include <functional>
#include<cmath>
using namespace std;


int main(){
	int n;
	while(cin>>n&&n){
		double now=10000,y,r,t,ans,iti=0;
		int b;
			cin>>y;
			for(int i=0;i<n;i++){
				cin>>b>>r>>t;
				now=10000;
				if(t==1){
					now=now*(1+y*(r/100));
				}
				else if(t==2){
					now=now*pow((1+r/100),y);
				}
				if(now>iti){
					iti=now;
					ans=b;
				}
				//cout<<b<<" "<<now<<endl;
			}
		cout<<ans<<endl;
	}
	
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int a,b,c,d;cin>>a>>b>>c>>d;
    int ad = a+d;
    int bc = b+c;
    int ac = a+c;
    int bd = b+d;
    int res = min(min(min(ad, bc), ac), bd);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	static long MOD = 1000000007l;
	static int MAX_DIGIT = 60;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}
		sc.close();

		long ans = 0;
		for (int d = 0; d < MAX_DIGIT; d++) {
			long n0 = 0, n1 = 0;
			for (int i = 0; i < N; i++) {
				if (((A[i] >> d) & 1) == 1) { // d桁目が1
					n1++;
				} else { // d桁目が0
					n0++;
				}
			}
			long tmp = (1l << d) % MOD; // 2^d
			long n = n0 * n1 % MOD;
			tmp = tmp * n % MOD;
			ans = (ans + tmp) % MOD;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 100144
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = min(n * a, b);

		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23252
import java.util.Scanner;

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

        while(true)
        {
            int n = sc.nextInt();
            int x = sc.nextInt();
            int sum=0;
            int count=0;

            if((n==0 && x==0) || n<3) break;

            int i,j,k;
            for(i=1;i<=n;i++)
            {
                for(j=1;j<=n;j++)
                {
                    for(k=1;k<=n;k++)
                    {
                        sum = i+j+k;
                        if(sum==x && (i<j && j<k))
                        {
                            count++;
                            //System.out.printf("%d+%d+%d=%d\n",i,j,k,sum);
                        }
                    }
                }
            }
            System.out.println(count);
        }

        sc.close();
    }
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

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

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


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

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 0) continue;

        int cnt = 0;
        for (int j = 1; j <= n; ++j) {
            if (i % j == 0) cnt++;
        }
        if (cnt == 8) ans++;
    }

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

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



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}


// https://ei1333.hateblo.jp/entry/2017/04/10/224413
struct edge { int to, cost; };

const int maxn = 100005;
vector<edge> G[maxn];
ll dist[maxn];
// i から i の (決めた頂点を根とする) 部分木内で一番遠い頂点までの距離
// 根を除く葉の dist は 0
void dfs(int v, int p) {
  for (edge& e : G[v]) {
    if (e.to == p) continue;
    dfs(e.to, v);
    // dfs から上がってきたタイミングで
    chmax(dist[v], dist[e.to] + e.cost);
  }
}

vector<int> ans(maxn);

// v を根とする答え
// Dpar : v の親方向の, v から一番遠い頂点と v の距離
void dfs2(int v, int Dpar, int p) {
  vector<pii> d_child;
  d_child.eb(0, -1); // 下で最大2つを取るが, 2つないとき用

  for (edge& e : G[v]) {
    // 親との距離と, 親方向の部分木で一番遠い頂点との距離の和
    if (e.to == p) d_child.eb(Dpar + e.cost, e.to);
    // 部分木の, ある頂点 j への距離と, j と j の部分木内での一番遠い頂点との距離の和
    else d_child.eb(e.cost + dist[e.to], e.to);
  }
  sort(d_child.rbegin(), d_child.rend());
  // sort 後, 最大 2 つ
  ans[v] = d_child[0].F ;

  // 同じ部分木内で木の直径が実現されることがある
  for (edge& e : G[v]) {
    if (e.to == p) continue;
    // v と一番遠い方向 f に行かない
    // 2 番手の方に行けば, f の距離を d_p にもつ
    dfs2(e.to, d_child[d_child[0].S == e.to].F, v);
  }
}

void solve() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--; // debuged
    G[a].eb(edge{b, 1});
    G[b].eb(edge{a, 1});
  }
  dfs(0, -1);
  dfs2(0, 0, -1);
  // 各辺 2 回通るが, 一番長いのだけ 1 回
  rep(i, n) cout << (n - 1) * 2 - ans[i] << endl;
}



Measured memory_bytes: 31336
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;

    vector<pair<ll, ll>> res;
    ll skip = n;
    if(n%2 == 1)skip--;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j)if(j > i && j != skip){
            res.push_back(make_pair(i, j));
        }
        --skip;
    }
    cout << res.size() << endl;
    rep(i, res.size())cout << res[i].first << " " << res[i].second << endl;
    
}

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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 2e9
#define int long long
#define pow poww

const int N = 3e3 + 5;
int n , sum;
int a[N];
int dp[N][N];

main()
{
    //freopen("TROCHOI.inp","r",stdin);
    //freopen("TROCHOI.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
    {
        cin >> a[i];
        sum += a[i];
    }
    FOR(i , 1 , n)
        dp[i][i] = a[i];
    FOR(i , 1 , n - 1)
        dp[i][i + 1] = max(a[i] , a[i + 1]);
    FOR(r , 1 , n)
    {
        FORD(l , r - 2 , 1)
            dp[l][r] = max(min(dp[l + 2][r] , dp[l + 1][r - 1]) + a[l] , min(dp[l + 1][r - 1] , dp[l][r - 2]) + a[r]);
    }
    cout << dp[1][n] - (sum - dp[1][n]);
}


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

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M-N)*4 % 13 for N in R10] for M in R13]
AM = 10**9+7

MOD =[1]+[0]*12

for D in S:
    if D == '?':
        MOD = [sum([MOD[N] for N in M])%AM for M in R]
    else:
        C = int(D)
        MOD = [MOD[M[C]] for M in R]
    #end if
#end for

print(MOD[5])


Measured memory_bytes: 3188
import java.util.Scanner;

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

        String a = scanner.nextLine();
        String p = scanner.nextLine();
        
        String custom_a = a + a;
        if(custom_a.indexOf(p) != -1){
            System.out.println("Yes");  
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26224
a, b, k = map(int, input().split())
ab = [a, b]
turn = 1
for _ in range(k):
  turn = not turn
  if ab[turn] % 2 == 1:
    ab[turn] -= 1
  ab[turn] //= 2
  ab[not turn] += ab[turn]
print(*ab)

Measured memory_bytes: 3060
// DPL_1_A.cpp
// Combinatorial - Coin Changing Problem
// TLE - ??????8???????????¨???

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 50000;
const int MAXM = 20;
const int INF = 50000;
int res;
vector<int> nums(MAXM);
vector<int> dp(MAXN);
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> nums[i];
    }
    for (int i = 0; i <= n; i++)
        dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j + nums[i] <= n; j++) {
            dp[j + nums[i]] = min(dp[j + nums[i]], dp[j] + 1);
        }
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 3104
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
p = [0] + list(map(lambda x: int (x) + 1, input().split()))
cum = list(accumulate(p))
res = 0
for i in range(len(p)-k):
    res = max(res, cum[i+k] - cum[i])
print(res / 2)


Measured memory_bytes: 33196
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main()
{
	int X, Y;
	cin >> X >> Y;
	string board[60];

	rep(i, X) {
		cin >> board[i];
	}

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

	bool can = true;
	rep(i, X) {
		rep(j, Y) {
			if (board[i][j] == '.') continue;
			if (board[i + 1][j] != '#' && board[i][j + 1] != '#' && board[i - 1][j] != '#' && board[i][j - 1] != '#') can = false;
		}
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        double b = in.nextDouble();
        int bint = (int)Math.round(b * 100);
        long mul = a*bint;
        String ans100 = Long.toString(mul);
        String ans = "0";
        if(ans100.length() > 2) {
            ans = ans100.substring(0, ans100.length()-2);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 37328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}
vector<ll> divisor(ll x){
    vector<ll> div;
    for(int i=1;i*i<=x;i++){
        if(i*i!=x && x%i==0){
            div.pb(i);
            div.pb(x/i);
        }
        else if(x%i==0) div.pb(i);
    }
    sort(all(div));
    return div;
}
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}
ll binary_search(vector<ll> v,ll key){ //key以上が初めて出てくる添字(0-index)
    int l=0,r=sz(v)-1;
    while(r-l>=1){
        int i=(l+r)/2;
        //cout<<l<<" "<<r<<" "<<i<<endl;
        if(v[i]<key) l=i+1;
        else r=i;
    }
    if(v[l]>=key) return l;
    else return INF;
}

int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string s,t; cin>>s>>t;
    ll ans=0;
    rep(i,sz(s)){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans;
    
}


Measured memory_bytes: 3900
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 51;
int n;
char s[N][N];

ll f[N][N][N][N],g[N][N][N][N];
inline ll dfs(int l,int r,int L,int R);
inline ll dfs2(int l,int r,int L,int R){
	if (l>r&&L>R) return 1;
	if (l>r||L>R) return 0;
	if (~g[l][r][L][R]) return g[l][r][L][R];
	ll ret=0;
	For(i,l,r) For(j,L,R) if (s[i][j]){
		ret+=dfs(l,i-1,i+1,r)*dfs(L,j-1,j+1,R);
	}
	return g[l][r][L][R]=ret;
}
inline ll dfs(int l,int r,int L,int R){
	if (l==r&&L==R) return s[l][R];
	if (l>r&&L>R) return 1;
	if (l>r||L>R) return 0;
	if (~f[l][r][L][R]) return f[l][r][L][R];
	ll ret=0;
	For(i,l-1,r) For(j,L,R+1) if (i!=r||j!=L){
		ret+=dfs(l,i,j,R)*dfs2(i+1,r,L,j-1);
	}
	return f[l][r][L][R]=ret;
}

int main(){
	n=read()*2;
	For(i,1,n){
		scanf("%s",s[i]+1);
		For(j,1,n) s[i][j]-='0';
	}
	if (n==2) return printf("%d\n",s[1][2]),0;
	ll ans=0;
	fil(f,-1),fil(g,-1);
	For(i,3,n) if (s[1][i]) ans+=dfs(2,i-1,i+1,n);
	printf("%lld\n",ans);
}

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

const bool DEBUG = false;

int N;
vector<int> A;

void input() {
  cin >> N;
  A = vector<int>(N);
  for (size_t i = 0; i < N; i++) cin >> A[i];
}

int main(int argc, char const *argv[]) {
  input();

  int first = max(A[0], A[1]), second = min(A[0], A[1]);
  for (size_t i = 2; i < N; i++) {
    if (A[i] > first) {
      second = first;
      first = A[i];
    } else if (A[i] > second) {
      second = A[i];
    }
  }

  for (size_t i = 0; i < N; i++) {
    if (A[i] == first) {
      cout << second << endl;
      continue;
    }
    cout << first << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////



int main(){
    scanf("%d",&n);
    printf("%d",1110-n);
    return 0;
}

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

using namespace std;

int main()
{
    int n, x, m[1024], m_min, rem;

    cin >> n >> x >> m[0];
    rem = x - m[0];
    m_min = m[0];
    for (int i = 1; i < n; i++) {
        cin >> m[i];
        m_min = min(m_min, m[i]);
        rem -= m[i];
    }
    cout << n + (int)(rem/m_min) << endl;
}

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

int main(){
    int H,W;
    cin >> H >> W;
    int c[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++) cin >> c[i][j];
    }
    int A[200][200];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) cin >> A[i][j];
    }

    priority_queue<pair<int,int>> Q;
    for(int i=0;i<10;i++) if(i!=1) Q.push(make_pair(-c[i][1],i));

    int d[10];
    bool det[10];
    for(int i=0;i<10;i++) det[i]=false;
    d[1]=0;
    det[1]=true;

    while(!Q.empty()){
        pair<int,int> t=Q.top();
        Q.pop();

        if(!det[t.second]){
            d[t.second]=(-t.first);
            det[t.second]=true;
            for(int i=0;i<10;i++) if(!det[i]) Q.push(make_pair(-c[i][t.second]+t.first,i));
        }
    }

    int min=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(A[i][j]==-1) continue;
            min+=d[A[i][j]];
        }
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 384
n=int(input())
c_list=[[]]*n
p_list=[-1]*n
for _ in range(n):
    id,k,*c=map(int,input().split())
    c_list[id]=c
    for i in c:
        p_list[i]=id
root=p_list.index(-1)
depth=[0]*n
next=c_list[root].copy()
while next:
    now=next.pop()
    depth[now]=depth[p_list[now]]+1
    next+=c_list[now]
for i in range(n):
    if i==root:
        type="root"
    elif c_list[i]==[]:
        type="leaf"
    else:
        type="internal node"
    print("node {}: parent = {}, depth = {}, {}, {}".format(i,p_list[i],depth[i],type,c_list[i]))


Measured memory_bytes: 23148
N, K = map(int, input().split())
h = []
min_d = 10 ** 10

h = [int(input()) for i in range(N)]
h = sorted(h)

for i in range(N-K+1) : 
    d = h[i+K-1] -h[i]
    min_d = min(d, min_d)
    
print(min_d)

Measured memory_bytes: 8280
fn solve(n: &str) -> usize {
    let n: usize = n.parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).unwrap();
    let a: Vec<usize> = a.split_whitespace().map(|x|x.parse().unwrap()).collect();
    let mut p = vec![0;n+1];
    let mut l = vec![0;n+2];
    let mut r = vec![n+1;n+2];
    for i in 0..n {
        let v = a[i];
        p[v] = i+1;
        l[i+1] = i;
        r[i+1] = i+2;
    }
    let p=p;
    let mut t=0;
    for v in (1..n+1).rev() {
        let i = p[v];
        t=t+v*(r[i]-i)*(i-l[i]);
        l[r[i]]=l[i];
        r[l[i]]=r[i];
    }
    t
}
fn main() {
    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right();
        if s=="" { break; }
        println!("{}",solve(&s));
    }
}

Measured memory_bytes: 9528
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 5100
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

ll C[26];

int main(){
    string s;
    cin>>s;
    ll n=s.size();
    for(int i=0;i<(int)s.size();i++){
        C[s[i]-'a']++;
    }
    ll ans=1+n*(n-1)/2;
    for(int i=0;i<26;i++){
        ans-=C[i]*(C[i]-1)/2;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+7;
int n,h,w;
struct node{
    int a,r,c;
    bool operator<(const node b)const{
        return a>b.a;
    }
    void scan(){
        scanf("%d%d%d",&r,&c,&a);
        c+=h;
    }
}ed[N];
int fa[2*N];
int find(int x){
    return (fa[x]==x)?x:fa[x]=find(fa[x]);
}
int main(){
    scanf("%d%d%d",&n,&h,&w);
    for(int i=0;i<=h+w;i++)fa[i]=i;
    for(int i=0;i<n;i++)
        ed[i].scan();
    sort(ed,ed+n);
    bool can[2*N];
    for(int i=0;i<=h+w;i++)can[i]=1;
    ll ans=0;
    for(int i=0;i<n;i++){
        if(find(ed[i].r)==find(ed[i].c)){
            if(can[find(ed[i].r)]){
                ans+=ed[i].a;
                //cout<<ed[i].r<<' '<<ed[i].c-h<<' ';
                //cout<<ed[i].a<<endl;
                can[find(ed[i].r)]=0;
            }
            continue;
        }
        if(can[find(ed[i].r)]==0&&can[find(ed[i].c)]==0){
            continue;
        }
        if(can[find(ed[i].r)]==0||can[find(ed[i].c)]==0){
            can[find(ed[i].r)]=0;
            can[find(ed[i].c)]=0;
        }
        fa[find(ed[i].r)]=find(ed[i].c);
        ans+=ed[i].a;
        //cout<<ed[i].r<<' '<<ed[i].c-h<<' ';
        //cout<<ed[i].a<<endl;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2688
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int maxPotision = 0;
		int maxValue = 0;
		int secondValue = 0;
		boolean maxDup = false;
		for (int i = 0; i < N; i++) {
			int tmp = sc.nextInt();
			if (tmp == maxValue) {
				maxDup = true;
			} else if (tmp > maxValue) {
				secondValue = maxValue;
				maxValue = tmp;
				maxPotision = i;
				maxDup = false;
			} else if (tmp > secondValue) {
				secondValue = tmp;
			}
		}
		if (maxDup) {
			for (int i = 0; i < N; i++) {
				System.out.println(maxValue);
			}
		} else {
			for (int i = 0; i < N; i++) {
				if (i == maxPotision) {
					System.out.println(secondValue);
				} else {
					System.out.println(maxValue);
				}
			}
		}
	}
}

Measured memory_bytes: 84492
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>

#define div 1000000000+7

typedef long long ll;

using namespace std;


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(b-a == c-b){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;

	vi a(n); for (int i = 0; i<n; i++) cin >> a[i];

	ll ans = M;

	for (int i = 0; i<n - k + 1; i++) {
		ll l = i;
		ll r = i + k - 1;
		ll pos1 = abs(a[l]) + abs(a[r] - a[l]);
		ll pos2 = abs(a[r]) + abs(a[r] - a[l]);
		ans = min(ans, min(pos1, pos2));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1;rrp(i,n-r+1,n+1){ans*=i;ans%=mod;}return ans/=fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
double ans=0;
////////////////////////////////////////////////////////////
int main(){
 vector<ll>odd,even;
 ll n;
 sc(n);
 ll b;
 rep(i,0,n){
  sc(b);
  if((i+1)%2==0)push(even,b);
  else push(odd,b);
 }
 if(n%2==0){
  rrp(i,n/2,0)cout<<even[i]<<" ";
  rep(i,0,n/2)cout<<odd[i]<<" ";
  pnn;return 0;
 }
 rrp(i,n/2+1,0)cout<<odd[i]<<" ";
 rep(i,0,n/2)cout<<even[i]<<" ";
 pnn;
return 0;}


Measured memory_bytes: 5044
N, M, P = map(int, input().split())
edge = []

for i in range(M):
    A, B, C = map(int, input().split())
    edge.append((A, B, P-C))

inf = float('inf')
cost = [inf] * (N+1)
cost[1] = 0
for i in range(N-1):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            cost[b] = cost[a] + c

for i in range(N):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            if b == N:
                print(-1)
                exit()
            else:
                cost[b] = cost[a] + c
        
print(max(-cost[N], 0))





Measured memory_bytes: 47576
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H, W, c, n, x;
    cin >> H >> W;
    string s, w;
    for(int i = 0; i < H; i++) {
        cin >> w;
        s += w;
    }
    for(int h = 0; h < H; h++)
    for(int w = 0; w < W; w++){
        c = 0;
        n = h*W+w;
        if(s.at(n) == '.') {
            for(int i = -1; i < 2; i++)
            for(int j = -1; j < 2; j++){
                x = n+i+j*W;
                if(n-w+j*W <= x
                    && x < n+(W-w)+j*W
                    && x > -1 && x < s.size()){
                    if(s.at(x) == '#') c++;
                }
            }
            s.at(n) = '0' + c;
        }
    }
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            cout << s.at(h*W+w);
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi s(n),t(n);
	rep(i,n)cin>>s[i];
	rep(i,n)cin>>t[i];

	int out=0;
	rep(i,29){
		vi a=s,b=t;
		int q=1<<(i+1);
		rep(i,n)a[i]%=q,b[i]%=q;
		q>>=1;
		sort(all(b));
		int co=0;
		rep(j,n){
			co+=lower_bound(all(b),2*q-a[j])-lower_bound(all(b),q-a[j]);
			co+=lower_bound(all(b),4*q-a[j])-lower_bound(all(b),3*q-a[j]);
		}
		if(co%2)out|=q;
	}
	cout<<out<<endl;
}










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


int main(){
    int k;
    string s;

    cin >> k;
    cin >> s;
    
    if(s.size() > k){
        s = s.substr(0,k) + "...";
    }

    cout << s << endl;;
    return 0;
}

Measured memory_bytes: 3636
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(n);
	if((n%10)==n/100)printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

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

int main() {
  string S, T;
  cin >> S >> T;
  bool f = true;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] != T[i]) {
      f = false;
    } 
  }
  if(T.size() - S.size() != 1) {
    f = false;
  }

  if(f) cout << "Yes" << endl;
  if(f == false) cout << "No" << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int sum = A * X + B * Y;
    for (int i = 0; i <= max(X, Y) + 1; i++) {
        int temp = 0;
        temp += C * 2 * i;
        temp += max(A * (X - i), 0);
        temp += max(B * (Y - i), 0);
        sum = min(sum, temp);
    }

    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String str=br.readLine();
        String[] nm=str.split(" ");
         
        int n=Integer.parseInt(nm[0]);
        int m=Integer.parseInt(nm[1]);
        int[][] a=new int [n+1][m+1];
         
        for(int i=1;i<=n;i++){
            str=br.readLine();
            String[] div=str.split(" ");
            for(int j=1;j<=m;j++){
                a[i][j]=Integer.parseInt(div[j-1]);
            }
        }
        int [] b=new int [m+1];
         
        for(int i=1;i<=m;i++){
            str=br.readLine();
            b[i]=Integer.parseInt(str);
        }
         
        int c[]=new int[n+1];
        Arrays.fill(c,0); //c[]に初期値0を設定     
      
        //行列Cを算出
        for(int j=1;j<=n;j++){
            for(int i=1;i<=m;i++){
                c[j]+=a[j][i]*b[i];
            }
            System.out.println(c[j]);
        }
    }
}

Measured memory_bytes: 22388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 998244353

vector<ll> T(100010, 0);

ll modp(ll x, ll y) {
	ll a = x, ans = 1;
	while (y) {
		if (y % 2)ans *= a;
		y /= 2;
		ans %= MOD;
		a *= a;
		a %= MOD;
	}
	return ans;
}

int main(){
	int N;
	cin >> N;
	vector<ll> D(N);
	for (int i = 0;i < N;i++) {
		cin >> D[i];
	}
	if (D[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	sort(all(D));
	for (int i = 0;i < N;i++) {
		T[D[i]]++;
	}

	if (T[0] > 1) {
		cout << 0 << endl;
		return 0;
	}

	ll fans = 1, c;
	for (ll i = 1;i <= D[N - 1];i++) {
		c = modp(T[i - 1], T[i]);
		fans *= c;
		fans %= MOD;
	}
	cout << fans << endl;
}

Measured memory_bytes: 1792
S = input()

while len(S) >= 5:
    if len(S) >= 7 and S[-7:] == "dreamer":
        S = S[:-7]
        continue

    if len(S) >= 6 and S[-6:] == "eraser":
        S = S[:-6]
        continue

    elif S[-5:] == "dream" or S[-5:] == "erase":
        S = S[:-5]
        continue

    else:
        break

if len(S) == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3236