akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;

struct mint{
  ll x;
  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 { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
  int n;
  cin >> n;
  int zero = 0;
  map<pair<ll, ll>, pair<int, int>> mp;
  rep (i,n) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 and y == 0) {
      zero++;
      continue;
    }
    ll g = gcd(x, y);
    x /= g;
    y /= g;
    if (y < 0) {
      x = -x;
      y = -y;
    }
    bool rot90 = (x <= 0);
    if (rot90) {
      ll tmp = x;
      x = y;
      y = -tmp;
    }
    if (rot90) mp[{x, y}].first++;
    else mp[{x, y}].second++;
  }
  mint ans = 1;
  for (auto p : mp) {
    int s = p.second.first;
    int t = p.second.second;
    mint now = 1;
    now += mint(2).pow(s) - 1;
    now += mint(2).pow(t) - 1;
    ans *= now;
  }
  ans -= 1;
  ans += zero;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15888
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

void factor(map<ll,ll> f, ll n){
    ll p = sqrt(n)+1;
  for(int i = 2;i < p && n!=0;i++){
    //cout << i << endl;
    if(n%i == 0){
      f[i]++;
      n/=i;
    } 
  }
  for(int  i = 2;i < p;i++){
      cout << f[i] << endl;
  }
}

  map<ll, ll> fa,fb;
void solve(){
  ll a,b;
  cin >> a >> b;
  for(int i = 1;i <=b;i++){
    if(a*i%b==0) {
      cout << a*i << endl;
      break;
    }
  }
}

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


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
//#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

void dfs(vector<int> adj[], int sv, vector<bool> &vis){
	vis[sv] = true;
	for(int i = 0; i < adj[sv].size(); i++){
		if(!vis[adj[sv][i]]){
			dfs(adj, adj[sv][i], vis);
		}
	}
}
ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
}  
ll nCr(ll n, ll r) {
    ll x = 1, y = 1;
    rep(i, 0, r) {
        x = x * (n - i) % mod;
        y = y * (i + 1) % mod;
    }
    return x * power(y, mod - 2) % mod;
}

signed main(){
	FASTIO
	int n;
	cin >> n;
	int a[n];
	unordered_map<int, vi> mp;
	rep(i, 0, n){
		cin >> a[i];
		mp[a[i]].pb(i);
	}
	
	int ans = 0, mx = *max_element(a, a + n);
	vector<bool> mark(n, true);
	rep(i, 0, n){
//		if(mark[i]){
			for(int j = a[i]; j <= mx; j += a[i]){
				if(mp.count(j) > 0){
					vi v = mp[j];
					vi t;
					rep(k, 0, v.size()){
						if(v[k] != i)
							mark[v[k]] = false;
						else
							t.pb(v[k]);	
					}
					mp[j] = t;
				}
			}
//		}
	}
	rep(i, 0, n){
		if(mark[i])
			ans++;
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 21492
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <cassert>

unsigned int bits_msb( unsigned int v )
{
  v = v | (v >>  1);
  v = v | (v >>  2);
  v = v | (v >>  4);
  v = v | (v >>  8);
  v = v | (v >> 16);
  return v ^ (v >> 1);
}

int main(void){
    Cin(int, n);
    if(n < 3){
        Cout("No");
        return 0;
    }
    if(!(n & (n-1))){
        Cout("No");
        return 0;
    }
    if(n % 4 == 0 && n < 12){
        Cout("No");
        return 0;
    }

    Cout("Yes");
    Cout(1, " ", 2);
    Cout(2, " ", 3);
    Cout(3, " ", n+1);
    Cout(n+1, " ", n+2);
    Cout(n+2, " ", n+3);
    
    for(int i = 4; i < n; i += 2){
        Cout(i, " ", 1);
        Cout(i+1, " ", 1);
        Cout(n+i, " ", i+1);
        Cout(n+i+1, " ", i);
    }
    if(n % 4 == 2){
        Cout(n, " ", n-1);
        Cout(2*n, " ", 2);
    }
    else if(n % 4 == 0){
        int u = bits_msb(n);
        int l = n - u;
        
        Cout(n, " ", u);
        Cout(2*n, " ", l+1);
    }
}





Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define fore(i, a) for(auto &i:a)
#define print(x) cout << x << "\n"
#define SORT(a, n) sort(a, a+n);
#define REVERSE(a,n) reverse(a,a+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end());
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
const ll mod = 1000000007;
const int inf = 1e9+7;
const ll infl = 1e18+7;

int main() {
    fastcin;
    int n, ans = 0;
    vi a;
    cin >> n;
    rep(i, 0, n) {
        int in;
        cin >> in;
        a.push_back(in);
    }
    rep(i, 0, n-2) {
        if(a[i]==a[i+1]) {
            if(a[i+1]==a[i+2]) {
                if(a[i]<n) a[i+1]++; 
                else a[i+1]--;
            } else {
                if(a[i]==1) {
                    if(a[i]+1!=a[i+2]) a[i+1]++;
                    else a[i+1]+=2;
                } else if(a[i]>1 && a[i]<n) {
                    if(a[i]+1!=a[i+2]) a[i+1]++;
                    else a[i+1]--;
                } else {
                    if(a[i]+1!=a[i+2]) a[i+1]--;
                    else a[i+1]-=2;
                }
            }
        ans++;
        }
    }
    if(a[n-2]==a[n-1]) ans++;
    print(ans);
    return 0;
}

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

void chmax(int64_t& a, int64_t b){
    a = max(a, b);
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    static int64_t dp[200001][6];
    for(int i=0; i<=N; i++) for(int j=0; j<3; j++) dp[i][j] = -1e18;
    for(int i=0; i<=2; i++) if(i<N) dp[i][i] = A[i];
    for(int i=0; i<N; i++) for(int j=0; j<3; j++){
        for(int d=0; j+d<3; d++){
            int bef = i-2-d;
            if(bef < 0) continue;
            chmax(dp[i][j+d], dp[bef][j] + A[i]);
        }
    }
    int64_t ans = -1e18;
    int D = 1 + N%2;
    for(int d=0; d<=D; d++){
        int i = N-1-d;
        if(i >= 0) chmax(ans, dp[i][D-d]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13508
c=[list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))]
f=True
if not c[1][0]-c[0][0]==c[1][1]-c[0][1]==c[1][2]-c[0][2]: # 0行-1行の成分が全て同じ
    f=False
if not c[2][0]-c[1][0]==c[2][1]-c[1][1]==c[2][2]-c[1][2]: # 1行-2行の成分が全て同じ
    f=False
if not c[0][1]-c[0][0]==c[1][1]-c[1][0]==c[2][1]-c[2][0]: # 0列-1列の成分が全て同じ
    f=False
if not c[0][2]-c[0][1]==c[1][2]-c[1][1]==c[2][2]-c[2][1]: # 1列-2列の成分が全て同じ
    f=False
print('Yes' if f else 'No')

Measured memory_bytes: 38384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


#define CALC_SQ_SUM(sum, data, x, y) (sum[y][x + 1] + (sum[y + 1][x] - sum[y][x]) + data[y][x])
#define SQ_SUM(sum, x, y, w, h) (sum[y + h][x + w] - (sum[y][x + w] + sum[y + h][x]) + sum[y][x])
int main()
{
	int n, w, h, ww, hh;
	while (cin >> n, n)
	{
		cin >> w >> h;
		int tree[128][128];
		clear(tree, 0);
		while (n--)
		{
			int x, y;
			cin >> x >> y;
			--x, --y;
			tree[y][x] = 1;
		}
		cin >> ww >> hh;

		int sum[128][128];
		clear(sum, 0);
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j)
				sum[i + 1][j + 1] = CALC_SQ_SUM(sum, tree, j, i);

		int res = 0;
		for (int i = 0; i + hh <= h; ++i)
			for (int j = 0; j + ww <= w; ++j)
				max_swap(res, SQ_SUM(sum, j, i, ww, hh));
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    int H,W,i,j;
    cin >> H >> W;
    while(W!=0 && H!=0){
    for (i = 1; i <= H; i++) { 
        for (j = 1; j <= W; j++){
            cout << '#';
        } 
            cout << endl;
    }
    cin >> H >> W;
    cout << endl;
    }
}


Measured memory_bytes: 3072
import sys
import numpy as np
sys.setrecursionlimit(10**9)
H, W = map(int, input().split())
S = [list('#' * (W + 2))]
for _ in range(H):
    S.append(list('#' + input() + '#'))
S.append(list('#' * (W + 2)))
S = np.array(S)
# print(S)

north = np.zeros_like(S, dtype='int')
for w in range(1, W + 1):
    north[:, w] = north[:, w - 1] + 1
    north[:, w][S[:, w - 1] == '#'] = 0
    north[:, w][S[:, w] == '#'] = 0

south = np.zeros_like(S, dtype='int')
for w in range(W, 0, -1):
    south[:, w] = south[:, w + 1] + 1
    south[:, w][S[:, w + 1] == '#'] = 0
    south[:, w][S[:, w] == '#'] = 0

east = np.zeros_like(S, dtype='int')
for h in range(1, H + 1):
    east[h, :] = east[h - 1, :] + 1
    east[h, :][S[h - 1] == '#'] = 0
    east[h, :][S[h, :] == '#'] = 0

west = np.zeros_like(S, dtype='int')
for h in range(H, 0, -1):
    west[h, :] = west[h + 1, :] + 1
    west[h, :][S[h + 1] == '#'] = 0
    west[h, :][S[h, :] == '#'] = 0
# print(west)

ans = north + south + east + west
print(ans.max() + 1)


Measured memory_bytes: 236272
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define SZ(c) int(c.size())
#define ff first
#define ss second
#define INF INT32_MAX
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
LL gcd(LL a,LL b)
{
	if(b==0)return a;
	return gcd(b,a%b);
}
bool findChar(string s,char ch)
{
	for(int i=0;i<s.length();i++)
	{
		if(s[i]==ch)
			return true;
	}
	return false;
}
int main() {
	El3zba;
	string s;
	cin>>s;
	int ans=0;
	string temp="ACGT";
	for(int i=0;i<(int)s.size();i++)
	{
		int cnt=0;
		if(findChar(temp,s[i]))
		{
			cnt++;
			for(int j=i+1;j<(int)s.size();j++)
			{
				if(findChar(temp,s[j]))
					cnt++;
				else break;
			}
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}


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

signed main()
{
   string s,t;
   cin>>s>>t;
   int m=s.length(),n=t.length();
   int dp[m+1][n+1];
   for(int i=0;i<=m;i++){
       for(int j=0;j<=n;j++){
           if(i==0 or j==0)
                dp[i][j] = 0;
            else if(s[i-1] == t[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
       }
   }
   
   int index = dp[m][n];
   char lcs[index+1];
   lcs[index] = '\0';
   
   int i=m,j=n;
   while(i>0 and j>0){
        if(s[i-1] == t[j-1]){
           lcs[index-1] = s[i-1];
           i--;j--;index--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
   }
   cout<<lcs<<"\n";
    
    return 0;
}


Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
        }
        for (int i = n - 1; i > 0; i--) {
            if (h[i] < h[i - 1]) {
                h[i - 1]--;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            if (h[i] > h[i + 1]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int K, S; cin >> K >> S;
    int ans = 0;
    for(int X = 0; X <= K; X++)
    {
        for(int Y = 0; Y <= K; Y++)
        {
            if(0 <= S-X-Y && S-X-Y <= K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

int main()

{
    int a,b,c,i,j,k,m,n,t;
    char s;
    scanf("%c",&s);
    if(s>='A'&&s<='Z')
    {
        printf("A\n");
    }
    else
    {
        printf("a\n");
    }


    return 0;
}


/*
presented by codeRumi
thanks for watching & being here,thank me later... :)
*/



Measured memory_bytes: 1552
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define rep1(i,n) for (long long int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

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

int main()
{
    int n;
    cin >> n;
    vector<int> t(n);
    rep(i,n) cin >> t[i];

    int m;
    cin >> m;
    rep(i,m) {
        vector<int> tmp = t;
        int p, x;
        cin >> p >> x;
        p--;
        tmp[p] = x;
        int sum = 0;
        rep(i,n) sum += tmp[i];
        cout << sum << endl;
    }
    return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;

int gcd( int a, int b ){
int temp;
if( a < b ) { temp = a; a = b; b = temp; }
if( b < 1 ) return -1;
if( a % b == 0 ) return b;
return gcd( b, a % b );}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    REP(i,n){
        cin>>a[i];
    }
    int ans = gcd(a[0],a[1]);
    FOR(i,2,n){
        ans = gcd(ans,a[i]);
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 640
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        S: chars,
    }
    // "("*L , S, ")"*R
    let (mut L, mut R) = (0,0);
    // "(" が余っている数
    let mut rem = 0;

    for i in 0..N{
        // ')'
        if S[i]==')'{
            if rem==0{
                L += 1;
            }else{
                R -= 1;
                rem -= 1;
            }
        // '('
        }else{
            R += 1;
            rem += 1;
        }
    }
    for _ in 0..L{
        print!("(");
    }
    for s in S{
        print!("{}", s);
    }
    for _ in 0..R{
        print!(")");
    }
}

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

#define pb push_back
#define fr first
#define sc second
typedef pair<int,int> pii;
typedef vector<int> vi;
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

char maze[1001][1001];
int d[1001][1001];
int h,w,n;
int sx,sy;

int bfs(int num){
  queue<pii> que;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      d[i][j]=INF;
    }
  }

  que.push(pii(sy,sx));
  d[sy][sx]=0;

  while(que.size()){
    pii p=que.front();que.pop();
    if(maze[p.fr][p.sc]=='1'+num) {
      sy=p.fr;
      sx=p.sc;
      return d[p.fr][p.sc];
    }
    for(int i=0;i<4;i++){
      int ny=p.fr+dy[i],nx=p.sc+dx[i];
      if(0<=ny && ny<h && 0<=nx && nx<w && maze[ny][nx]!='X' && d[ny][nx]==INF){
	que.push(pii(ny,nx));
	d[ny][nx]=d[p.fr][p.sc]+1;
      }
    }
  }
}

int main(){
  cin>> h>> w>> n;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>> maze[i][j];
      if(maze[i][j]=='S') {
	sy=i;sx=j;
      }
    }
  }

  int res=0;
  for(int i=0;i<n;i++){
    res+=bfs(i);
  }

  cout<< res<< endl;
}

Measured memory_bytes: 6108
N = int(input())
all1 = True
goukei = 0
existodd = False
for i in range(N):
    tmp = int(input())
    if tmp != 1:
        all1 = False
    if tmp % 2 == 1:
        existodd = True
    goukei += tmp
    
    
if(goukei%2==1 or all1 or existodd):
    print("first")
else:
    print("second")

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

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // -1 의 약수와 하나씩 까고 mod가 1인 애들의 합집합
    set<ll> ans;
    ll n;
    cin>>n;
    if(n==2) {
        cout<<1;
        return 0;
    }
    ans.insert(n); ans.insert(n-1);
    for(ll i=2;i*i<=n;i++){
        ll tmp_n = n;
        while(tmp_n%i==0)
            tmp_n/=i;
        if(tmp_n%i==1){
            ans.insert(i);
        }

        if((n-1)%i==0)
            ans.insert((n-1)/i);
    }

    cout<<ans.size()<<endl;
    return 0;
}

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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

const int N = (1 << 18) + 5;
const int LOG = 20;
const int Q = 1e5 + 5;

int n, q;
int value[N], weight[N];
vector<pii> qs[N];
int res[Q];
int bit[1 << 12];

void precalc() {
    for (int i = 0; i < 12; i++)
        bit[1 << i] = i;
}

void solve(const vector<pii> &qq, int lsz, int rsz, pii *lar, pii *rar) {
    int LL = 1 << lsz;
    int RR = 1 << rsz;

//    for (int i = 0; i < LL; i++) {
//        cout << "(" << lar[i].first << " " << lar[i].second << ") ";
//    }
//    cout << " | ";
//    for (int i = 0; i < RR; i++) {
//        cout << "(" << rar[i].first << " " << rar[i].second << ") ";
//    }
//    cout << "\n";

    for (auto pp : qq) {
        int L, id;
        tie(L, id) = pp;

        for (int i = 0; i < LL; i++) {
            if (lar[i].first <= L)
                res[id] = max(res[id], lar[i].second);
        }

        for (int i = 0; i < RR; i++) {
            if (rar[i].first <= L)
                res[id] = max(res[id], rar[i].second);
        }

        for (int j = 0, mx = 0, i = RR - 1; i >= 0; i--) {
            while (j < LL && lar[j].first + rar[i].first <= L)
                mx = max(mx, lar[j++].second);
            if (rar[i].first <= L)
                res[id] = max(res[id], mx + rar[i].second);
        }

//        cout << L << " : " << res[id] << "\n";
    }
//    cout << "\n==============\n";
}

void update(pii *dp, int sz, int w, int v) {
    int iters = (1 << (sz - 1));
    for (int mask = 0; mask < iters; mask++) {
        dp[mask | iters] = {
                dp[mask].first + w,
                dp[mask].second + v
        };
    }
}

pii _lar[1 << 12], _rar[1 << 12];
pii lar[1 << 12], rar[1 << 12];

void dfs(int v, int h = 1) {
    if (v > n)
        return;
    if (h <= 9) {
        update(_lar, h, weight[v], value[v]);
    } else {
        update(_rar, h - 9, weight[v], value[v]);
    }
    if (h == 9) {
        memcpy(lar, _lar, sizeof(pii) * (1 << h));
        sort(lar, lar + (1 << h));
    }
    if (!qs[v].empty()) {
        int lsz = min(h, 9);
        int rsz = h - lsz;

        memcpy(rar, _rar, sizeof(pii) * (1 << rsz));
        sort(rar, rar + (1 << rsz));

        if (h < 9) {
            memcpy(lar, _lar, sizeof(pii) * (1 << lsz));
            sort(lar, lar + (1 << lsz));
        }

        solve(qs[v], lsz, rsz, lar, rar);
    }
    dfs(v * 2, h + 1);
    dfs(v * 2 + 1, h + 1);
}

int main() {

    precalc();

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for (int v = 1; v <= n; v++) {
        cin >> value[v] >> weight[v];
    }

    cin >> q;

    for (int iter = 0; iter < q; iter++) {
        int v, L;
        cin >> v >> L;
        qs[v].emplace_back(L, iter);
    }

    dfs(1);

    for (int i = 0; i < q; i++) {
        cout << res[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 15284
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
 
int fa[100010],num[100010],n,m,cnt;
bool bo[100010],pd[100010];
ll ans;
 
inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}
 
inline int find(int x)
{
	if (!fa[x]) return x;
	int hh=find(fa[x]);
	num[x]^=num[fa[x]];
	return fa[x]=hh;
}
 
int main()
{
	n=rd();m=rd();
	for (int i=1;i<=m;i++)
	{
		int x=rd(),y=rd();
		bo[x]=true;bo[y]=true;
		int f1=find(x),f2=find(y);
		if (f1<f2) { swap(f1,f2);swap(x,y); }
		if (f1==f2&&num[x]==num[y]) pd[f1]=1;
		if (f1==f2) continue;
		pd[f2]|=pd[f1];fa[f1]=f2;
		num[f1]^=num[x]^num[y]^1;
	}
	for (int i=1;i<=n;i++) if (!bo[i]) cnt++;
	ans=(ll)cnt*(n-cnt)*2+(ll)cnt*cnt;
	cnt=0;
	for (int i=1;i<=n;i++) if (bo[i]&&!fa[i]) cnt++;
	ans+=(ll)cnt*cnt;
	cnt=0;
	for (int i=1;i<=n;i++) if (bo[i]&&!fa[i]&&!pd[i]) cnt++;
	ans+=(ll)cnt*cnt;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1280
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.sqrt

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

data class Point(val x: Long, val y: Long) {
    fun d(other: Point) = sqrt((x - other.x) * (x - other.x).toDouble() + (y - other.y) * (y - other.y))
}

fun solve() {
    val n = readInteger()
    val pointArray = Array(n) {
        val (x, y) = readLongList()
        Point(x, y)
    }

    val perm = permutationListFrom((0 until n).toList().toTypedArray())
    var ans = 0.0
    for (p in perm) {
        var pre = pointArray[p.first()]
        for (next in p.drop(1)) {
            val nextP = pointArray[next]
            ans += pre.d(nextP)

            pre = nextP
        }
    }
    out.println(ans / perm.size)
}

/** O((array.size)!) */
fun <T : Comparable<T>> permutationListFrom(array: Array<T>): List<Array<T>> {
    val current = array.copyOf()
    val permutationList = mutableListOf<Array<T>>()
    do { permutationList += current.copyOf() } while (nextPermutation(current))
    return permutationList
}

/** O(n): n = currentPermutation.size */
fun <T : Comparable<T>> nextPermutation(currentPermutation: Array<T>): Boolean {
    fun <T> Array<T>.reverse(start: Int, end: Int) {
        val midPoint = ((start + end) / 2) - 1
        if (midPoint < 0) return
        var reverseIndex = end - 1
        for (index in start..midPoint) {
            val tmp = this[index]
            this[index] = this[reverseIndex]
            this[reverseIndex] = tmp
            reverseIndex--
        }
    }

    val n = currentPermutation.size
    var i = n - 2
    while (i >= 0) {
        if (currentPermutation[i] < currentPermutation[i + 1]) break
        i--
    }
    if (i < 0) return false
    var j = n
    do { j-- } while (currentPermutation[i] > currentPermutation[j])
    if (currentPermutation[i] < currentPermutation[j]) {
        val tmp = currentPermutation[i]
        currentPermutation[i] = currentPermutation[j]
        currentPermutation[j] = tmp
        currentPermutation.reverse(i + 1, n)
        return true
    }
    return false
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 49468
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int a,b,c,d;
  cin >> a >> b >> c >>d;
  int bus,train;

  bus = a-b>0 ? b : a;
  train = c-d>0 ? d : c;
  cout << bus+train << endl;
  return 0;
} 

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


int main(){long N;
cin >> N;
vector<long> t(N+1); vector<long> a(N+1);

erep(i, N) cin >> t[i] >> a[i];
long x, y; long t1 = 1, a1 = 1;
erep(i, N){
  if(t1 % t[i] == 0) x = t1/t[i];
  else x = t1/t[i]+1;
  if(a1 % a[i] == 0) y = a1/a[i];
  else y = a1/a[i]+1;
  t1 = t[i]*max(x, y);
  a1 = a[i]*max(x, y);
}
show(t1+a1);





return 0;
}

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

int main(void)
{
	int n;
	string p1,p2;
	cin >> p1;
	cin >> p2;
	
	if (p1.length() + 1 == p2.length())
	{
		p2.pop_back();
		if (p1 == p2)
		{

			cout << "Yes" << endl;
		}
		else {

			cout << "No" << endl;
		}

	}
	else {

		cout << "No" << endl;
	}
	



	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s; int ans=0;

void solve()
{
    cin >> s;
    for (int i=0; i<s.size()/2; i++) {
        if (s[i]!=s[s.size()-i-1]) ans++;
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
//
//  main.cpp
//  ABC107B
//
//  Created by KJC of Kindai University on 2019/08/04.
//  Copyright © 2019 KJC of Kindai University. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

int main(int argc, const char* argv[]) {
	// insert code here...
	int H, W;
	cin >> H >> W;
	//cout << H << endl;
	//cout << W << endl;

	vector<string> s(H);// スペース区切りではないので、string型として行ごとに読み込む
	vector<vector<int>>Table(H, vector<int>(W));

	vector<int>memo_h(H, 0);
	vector<int>memo_w(W, 0);
	for (int i = 0; i < H; i++)
	{
		cin >> s.at(i);
		for (int j = 0; j < W; j++)
		{
			if (s.at(i).at(j) == '#') //Char型のときは' 'で囲む
			{
				Table.at(i).at(j) = 1;
				memo_h.at(i)++;
				memo_w.at(j)++;
			}
			else
			{
				Table.at(i).at(j) = 0;
			}
		}
	}
	//
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (memo_h.at(i) != 0 && memo_w.at(j) != 0)
			{
				cout << s.at(i).at(j);
			}
			if (memo_h.at(i) != 0&&j==W-1)
			{
				cout << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;


int modpow(int a, int n) {
	int r = 1;
	while (n) {
		r = r * ((n % 2) ? a : 1) % mod;
		a = a * a%mod, n >>= 1;
	}
	return r;
}

int comb(int P, int Q) {
	if (P < 0 || Q<0 || Q>P)return 0;
	int p = 1, q = 1;
	Q = min(Q, P - Q);
	eFOR(i, 1, Q) {
		p = p * P%mod;
		q = q * i%mod;
		P--;
	}
	return p * modpow(q, mod - 2) % mod;
}

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

	int N, M, K;
	cin >> N >> M >> K;
	
	int ret = 0;
	REP(i, N) {
		int d = 1LL * i*(i + 1) / 2 % mod;
		d = d * M%mod*M%mod;
		ret += d;
	}
	REP(i, M) {
		int d = 1LL * i*(i + 1) / 2 % mod;
		d = d * N%mod*N%mod;
		ret += d;
	}

	cout << ret % mod*comb(N*M - 2, K - 2) % mod << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
 
int main(){
  int m;
  cin >> m;
 
  for(int i=0;i<m;i++){
    string train;
    cin >> train;
    set<string> st;
    for( int i = 1, length = train.length() ; i < length ; ++i ){
      string forward, backward;
      forward = train.substr(0,i);
      backward = train.substr(i, length-i);
      st.insert(forward+backward);
      st.insert(backward+forward);
      reverse(backward.begin(), backward.end());
      st.insert(forward+backward);
      st.insert(backward+forward);
      reverse(forward.begin(), forward.end());
      st.insert(forward+backward);
      st.insert(backward+forward);
      reverse(backward.begin(), backward.end());
      st.insert(forward+backward);
      st.insert(backward+forward);
    }
    cout << st.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1288
n, sec = gets.split(" ").map(&:to_i)
time = 0
que = []
n.times do
  que << gets.split(" ").map{|i|(/[a-zA-Z]/ =~ i) ? i:i.to_i}
end
while que.length > 0
  if que[0][1] <= sec
    puts [que[0][0], (time + que[0][1])].join(" ")
    time += que[0][1]
    que.shift
  else
    que[0][1] -= sec
    que.push(que.shift)
    time += sec
  end
end

Measured memory_bytes: 25676
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    vector<ll> a;
    vector<ll> SUM;
    vector<vector<ll> > dp;

    void input() {
        cin >> N;
        a.resize(N);
        rep(i, 0, N) cin >> a[i];
        dp.resize(N, vector<ll>(N, -1));
        SUM.resize(N + 1);
        SUM[0] = a[0];
        for (int i = 1; i < N; ++i) {
            SUM[i] = SUM[i - 1] + a[i];
        }

    }

    ll rec(int i, int j) {
        if (dp[i][j] != -1) return dp[i][j];

        ll ret = INFl;
        if (i == j) return 0;
        if (i + 1 == j) return a[i] + a[j];

        for (int k = i; k < j; ++k) {
            ll tmp = rec(i, k) + rec(k + 1, j);
            ll more = 0;
            if (i == 0) more = SUM[j];
            else more = SUM[j] - SUM[i - 1];

            tmp += more;

            chmin(ret, tmp);
        }

        return dp[i][j] = ret;
    }

    void solve() {
        input();

        ll ans = rec(0, N - 1);
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;
struct Rank {
    string city;
    int point;
    int id;
    bool operator<(const Rank &another) const
    {
        if(city == another.city){
            return point > another.point;
        }
        return city < another.city;//年齢を比較
    };
};

int main() {
    int N;
    cin >> N;
    vector<Rank> data(N);
    for(int i = 0;i< N; i++){
        string s;
        int p;
        cin >> s >> p;
        Rank r;
        r.city = s;
        r.point = p;
        r.id = i;
        data[i] = r;
    }
    sort(data.begin(),data.end());
    for(int i = 0; i < N; i++){
        cout << data[i].id + 1 << endl;
    }
}

Measured memory_bytes: 256
from collections import deque
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

A.append(-int(1e+100))
B.append(-int(1e+100))
C.append(-int(1e+100))

Aq = deque(A)
Bq = deque(B)
Ar = [Aq.popleft()]
Br = [Bq.popleft()]
maximum = min((len(A)-1) + (len(B)-1), 3001)
preA = Ar[0]
preB = Br[0]

while len(Ar) + len(Br) < maximum:
    if  Ar[0] - Aq[0] > Br[0] - Bq[0]:
        Br.append(Bq.popleft())
        preB = Br[-1]
    else:
        Ar.append(Aq.popleft())
        preA = Ar[-1]

AB = [Ar[i] + Br[j] for i in range(len(Ar)) for j in range(len(Br))]
AB = sorted(AB, reverse=True)

AB.append(-int(1e+15))

ABq = deque(AB)
Cq = deque(C)
ABr = [ABq.popleft()]
Cr = [Cq.popleft()]
maximum = min((len(AB)-1) + (len(C)-1), 3001)
preAB = ABr[0]
preC = Cr[0]
while len(ABr) + len(Cr) < maximum:
    if ABr[0] - ABq[0] > Cr[0] - Cq[0]:
        Cr.append(Cq.popleft())
        preC = Cr[-1]
    else:
        ABr.append(ABq.popleft())
        preAB = ABr[-1]

ABC = [ABr[i] + Cr[j] for i in range(len(ABr)) for j in range(len(Cr))]
ABC = sorted(ABC, reverse=True)

for i in range(K):
    print(ABC[i])


Measured memory_bytes: 218268
#include<bits/stdc++.h>
    using namespace std;
    int main(){
        string s;
        while(cin >> s,s!="0"){
            int n=s.size();
            vector<int> a(n+1,0);
            for (int i = 0; i < n; i++) {
                a[i+1]=(a[i]+11+(i&1?-1:1)*(s[i]-'0'))%11;
            }
            vector<int> ma(11,0),mi(11,0);
            int ans=0;
            for (int i = 0; i < n+1; i++) {
                ans+=ma[a[i]]++; 
            }
            for (int i = n; i > 0; i--) {
                mi[a[i]]++;
                if(s[i-1]=='0') ans-=mi[a[i]];
            }
            cout << ans << endl;
        }
        return 0;
    }


Measured memory_bytes: 3460
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest_01_Valeo_P3
{
    class Program
    {
        static void Main(string[] args)
        {
            //while (true)
            //{
                //Console.WriteLine("start problem");
                string input = Console.ReadLine();
                int h = int.Parse(input.Split(' ')[0]);
                int k = int.Parse(input.Split(' ')[1]);
                input = Console.ReadLine();
                string[] a_string = input.Split(' ');
                List<long> health = new List<long>();
                a_string.ToList().ForEach(x => health.Add(long.Parse(x)));
                long result = getNumberOfAttacks(h, k, health);
                Console.WriteLine(result );
            //    Console.Write("press y to exit : ");
            //    if (Console.ReadLine() == "y")
            //        return;
            //}
        }

        private static long getNumberOfAttacks(int h, int k, List<long> health)
        {
            long c = 0;
            if (k >= h)
                return 0;
            if (k == 0)
            {
                health.ForEach(x => c += x);
                return c;
            }
            health.Sort();
            int count = 0;
            for (int i = health.Count - 1; i >= 0; i--)
            {
                health[i] = 0;
                count++;
                if (count == k)
                    break;
            }
            health.ForEach(x => c += x);
            return c;
        }
    }
}


Measured memory_bytes: 35072
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define sz(x) (int)(x.size())

signed main() {
    string s;
    cin >> s;
    map<char, bool> mp;
    for (int i = 0; i < sz(s); i++) {
        mp[s[i]] = true;
    }
    if (mp['N'] ^ mp['S'] || mp['E'] ^ mp['W']) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
}

Measured memory_bytes: 256
# 20200610_yorukatsu_b.py
N = int(input())
A = []
B = []
for i in  range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

push = 0
for i in range(N):
    if (A[N-i-1] + push) % B[N-i-1] != 0:
        push += abs(B[N-i-1] - ((push + A[N-i-1]) % B[N-i-1]))
print(push)


Measured memory_bytes: 11048
N, M = map(int, input().split())
K = [0 for _ in range(N)]
A = [[0 for _ in range(M)] for _ in range(N)]
like = [0 for _ in range(M)]
for i in range(N):
    n = list(map(int, input().split()))
    K[i] = n[0]
    for j in range(1, K[i] + 1):
        A[i][j-1] = n[j]

    for n in A[i]:
        if not n == 0:
            like[n-1] += 1
print(like.count(N))


Measured memory_bytes: 3064
N = int(input())
l = []
for i in range(N):
    l.append(input())
l = sorted(l)
new_list = []
new_list.append(l[0])
for i in range(1,len(l)):
    if l[i-1] != l[i]:
        new_list.append(l[i])
print(len(new_list))



Measured memory_bytes: 25452
#include<bits/stdc++.h>
using namespace std; 
int main(){
	string s,n="CODEFESTIVAL2016";
    int t;
    cin>>s;
    for(int i=0;i<17;i++){
        if(s[i]!=n[i]) t++;
    }
    cout<<t;
    return 0;
}

Measured memory_bytes: 256