akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 105

bool ok[MAXN]{};

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,k; cin>>n>>k;
	forn(i,0,k){
		int d; cin>>d;
		for(int j=0;j<d;j++){
			int x; cin>>x; x--;
			ok[x]=1;
		}
	}
	
	int cnt=0;
	forn(i,0,n){
		if(ok[i]==0) cnt++;
	}
	
	cout<<cnt<<'\n';
	
	return 0;
}


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

#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 MOD 1000000007

typedef long long int ll;

//const ll INF=(ll)1e18;
const int INF=(1<<30);


int main(){
  int N,K;
  cin >> N >> K;

  int ans=1;
  REP(i,N){
    ans=min(ans*2,ans+K);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();

    let mut result = 1 << 30;
    for a in 1..n {
        let b = n - a;
        let a_string = a.to_string();
        let b_string = b.to_string();
        let res1 = a_string.chars().into_iter().fold(0, |sum, c| {
            sum + c.to_digit(10).unwrap_or(0)
        });
        let res2 = b_string.chars().into_iter().fold(0, |sum, c| {
            sum + c.to_digit(10).unwrap_or(0)
        });
        result = std::cmp::min(result, res1 + res2);
    }
    println!("{}", result);
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	auto set = [](double v) {if (v >= 360) { v -= 360; }return v; };
	int32_t arg1, arg2;
	in >> arg1>> arg2;
	using std::abs;
	int32_t res = arg2 - arg1;
	int32_t tmp = (arg2 + 360) - arg1;
	if (abs(res) > abs(tmp)) { res = tmp; }
	tmp = (arg1 + 360) - arg2;
	if (abs(res) > abs(tmp)) {
		out << set(tmp / 2.0 + arg2) << endl;
	}
	else {
		out << set(res / 2.0 + arg1) << endl;
	}

	return 0;
}
#endif

Measured memory_bytes: 3216
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


string s;

main(){
	while(cin >> s){
reverse(ALL(s));
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>

using namespace std;

int main(){
    int X;
    cin >> X;
    if (X == 7){
        cout << "YES" << endl;
    } else if (X == 5){
        cout << "YES" << endl;
    } else if (X == 3){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll H[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> H[i];
    }
    ll ans = 0;
    while (true) {
        bool update = false;
        ll last = -1;
        REP(i, N) {
            if (H[i] > 0) {
                H[i]--;
                update = true;
                continue;
            }
            if (last != i - 1)
                ans++;
            last = i;
        }
        if (last != N - 1)
            ans++;
        if (!update)
            break;
    }
    cout << ans << endl;
    return 0;
}

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

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

    int cnt = 1, ans = 0;
    for (int i = 1; i < n;++i){
        if(a[i-1]==a[i])
            ++cnt;
        else{
            ans += cnt / 2;
            cnt = 1;
        }
    }

    ans += cnt / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll f[100010];  //f[i]:gcd(a1+a2+...+an)=i的排列个数

ll binaryPow(ll a,ll b,ll m){
    if(m==1) return 0;
    ll ans=1;
        while(b>0){
            if(b&1) ans=ans*a%m;
            a=a*a%m;
            b>>=1;
        }
        return ans;
}

int main(){
    int n,k;
    cin>>n>>k;
    for(int i=k; i>=1; i--){
        //1~k中i的倍数有k/i个，f[i]=(k/i)^n
        f[i] = binaryPow(k/i, n, mod);
        for(int j=2*i; j<=k; j+=i){  //去除倍数关系
            if(f[i]>=f[j]) f[i]-=f[j];
            else f[i]=f[i]+mod-f[j];
        }
    }
    ll ans=0;
    for(int i=1;i<=k;i++) ans=(ans+(f[i]*i)%mod)%mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define all(_v) _v.begin(), _v.end()

double n;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cin >> n;
    cout << 2 * n * acos(-1);
    return 0;
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
nodes = [[] for i in range(N)]
edges = {}
for i in range(N-1):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)
    edges[(a, b)] = [i, -1]


stack = [(0, -1)]
mx = 0
ans = [0] * (N-1)
while stack:
    u, prev = stack.pop()
    color = 0
    # 自分の子ノードを順番に塗り進めていく
    for v in nodes[u]:
        if v == prev:
            continue
        stack.append((v, u))
        color += 1
        a, b = min(u, prev), max(u, prev)
        # 親-自分間で使用済の色だったら1つ進める
        if a != -1 and color == edges[(a, b)][1]:
            color += 1
        a, b = min(u, v), max(u, v)
        edges[(a, b)][1] = color
        i = edges[(a, b)][0]
        ans[i] = str(color)
    # 各ノードから使った色数の最大を取る
    mx = max(mx, color)

print(mx)
print('\n'.join(ans))


Measured memory_bytes: 53552
n, m = map(int, input().split())
cities = []
for i in range(n):
    cities.append(0)
for i in range(m):
    x = list(input().split())
    for j in range(2):
        cities[int(x[j]) - 1] += 1
for i in range(len(cities)):
    print(cities[i])


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

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

    int x,d;

    cin >> x >> d;

    int ans = 0;

    for(int m = 1;m <= x;m++) for(int i = 1;i <= d;i++) 
    {
        int x = i/10,y = i%10;
        if(x>=2 and y>=2 and x*y==m) ans++;
    }

    cout << ans;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i; i < n; i++)
    cin >> v.at(i);
  
  vector<int> c(n);
  for(int i; i < n; i++)
    cin >> c.at(i);
  
  vector<int> w(n);
  for(int i; i < n; i++)
    w.at(i) = (v.at(i) - c.at(i));
  
  int j = 0;
  int s = 0;
  
  while(j < n){
    if(w.at(j) > 0)
      s += w.at(j);
    j++;
  }
  cout << s << endl;
}



Measured memory_bytes: 256
n = int(input())
monsters = list(map(lambda x : int(x), input().split()))
heros = list(map(lambda x : int(x), input().split()))

monster_point = 0
hero_point = 0

ans = 0

for i in range(n):
    monster1 = monsters[i]
    monster2 = monsters[i+1]
    hero1 = heros[i]
    
    if monster1 >= hero1:
        ans += hero1
    elif hero1 <= (monster1 + monster2):
        ans += hero1
        monsters[i+1] -= (hero1 - monster1)
    else:
        ans += (monster1 + monster2)
        monsters[i+1] = 0

print(ans)

Measured memory_bytes: 18624
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

/*******************************************************/

int main() {
  int n; cin >> n;
  vi a(n); Loop(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  bool ans;
  if (a[n - 1] - a[0] >= 2) ans = false;
  else if (a[n - 1] - a[0] == 1) {
    int b = a[0];
    int cnt = 0;
    Loop(i, n) {
      if (a[i] == b) cnt++;
      else break;
    }
    if (n - cnt == 1) ans = false;
    else {
      int cnt2 = (n - cnt) / 2;
      if (cnt <= a[0] && a[n - 1] <= cnt + cnt2) ans = true;
      else ans = false;
    }
  }
  else {
    if (a[0] == n - 1 || a[0] <= n / 2) ans = true;
    else ans = false;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007

bool check(int n, vvi &grid, int w)
{
    int h_ = n / w;
    int w_ = n % w;

    return grid[h_][w_];
}

int main()
{
    boost
    int h, w;
    cin >> h >> w;

    vvi grid(h, vi(w, 0));

    char c;
    loop(z, grid)
    {
        loop(q, z)
        {
            cin >> c;
            if(c == '.') q = 1;
        }
    }

    vvi ans(402, vi(402, INT_MAX));
    for(int i = 0; i < h*w; i++)
    {
        if(!check(i, grid, w)) continue;
        for(int j = 0; j < h*w; j++)
        {
            if(!check(j, grid, w)) continue;
            if(i / w == j / w && abs(i%w - j%w) == 1) ans[i][j] = 1;
            else if(i%w == j%w && abs(i / w - j / w) == 1) ans[i][j] = 1;
            else if(i == j) ans[i][j] = 0;
        }
    }

    for(int k = 0; k < h*w; k++)
    {
        if(!check(k, grid, w)) continue;
        for(int i = 0; i < h*w; i++)
        {
            if(!check(i, grid, w)) continue;
            for(int j = 0; j < h*w; j++)
            {
                if(!check(j, grid, w)) continue;
                ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j]);
            }
        }
    }

    // return 0;
    ll an = -1;
    for(int i = 0; i < h*w; i++)
    {
        for(int j = 0; j < h*w; j++)
        {
            // cout << ans[i][j] << " ";
            if(ans[i][j] != INT_MAX) an = max(an, (ll)ans[i][j]);
        }
        // cout << nl;
    }

    cout << an << nl;
    return 0;
}

Measured memory_bytes: 1536
N, K = input().split()
N = int(N)
K = int(K)
i = 1

ans = 0

while i <= N:
    j = 0
    n = 0
    while n <= K-1:
        n = i * 2**j
        j += 1
    #print(j)
    ans += 1/N * (1/2)**(j-1)
    i += 1
            
print(ans)

Measured memory_bytes: 3064
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }
void printint(uint32_t x){ if(x<0){x=-x; putchar_unlocked('-');}else if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }
void rsort_str(void *base, const int count, const int size);

char str[200000][16];

int main(void){
	uint32_t n=nextpint();
	for(uint32_t i=0; i<n; i++){
		nextstr(str[i]);
	}
	rsort_str(str, n, 16);
	uint32_t ans=1;
	for(uint32_t i=1; i<n; i++){
		if(strcmp(str[i], str[i-1])) ans++;
	}
	printint(ans);
}

void rsort_str(void *base, const int count, const int size){
	char (*a)[size]=base;
	char (*b)[size]=malloc(count*size);
	int c[0x100];
	for(int j=size-1; j>=0; j--){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[a[i][j]]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ memcpy(&b[--c[a[i][j]]], a[i], size); }{void *t=a; a=b; b=t;}
	}
	if((size&1)==0){
		free(b);
	}else{
		memcpy(b, a, count*size);
		free(a);
	}
}


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

// a < b + c --> c > a - b
// b < a + c --> c > b - a
// c > abs(b-a)
// c < a + b


bool isTriangle(int a, int b, int c){
  return a < b + c && b < a + c && c < a + b;
}

int main()
{
  int n, ans=0;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  for(int i=0; i<n; i++) for(int j=i+1; j<n; j++) {
    ans += lower_bound(v.begin() + j + 1, v.end(), v[i]+v[j]) - upper_bound(v.begin() + j + 1, v.end(), abs(v[i]-v[j]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    int A,B;
    cin>>A>>B;
    int count=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                if(A<=i*10000+j*1000+k*100+j*10+i & i*10000+j*1000+k*100+j*10+i<=B){
                    count+=1;
                }
            }
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
using namespace std;
typedef long long ll;

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

int gcd_2(vector<ll> a){
  
  int ans = a[0];
  
  for (int i = 1; i < a.size(); i++){
    ans = gcd(ans, a[i]);
  }
  
  return ans;
}

int main(){
  int n;
  cin >> n;
  
  vector<ll> a(n);
  
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  cout << gcd_2(a);
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;

set<int> st;
map<int, bool> mp, mp2;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		if (st.count(x)) mp[x] = true;
		st.insert(x);
	}
	int ans = 0;
	for (auto i : st) {
		if (mp2[i]) continue;
		for (int j = i + i; j <= MAXN; j += i)
			mp2[j] = true;
		ans += !mp[i] and !mp2[i];
	}
	cout << ans << "\n";
}


Measured memory_bytes: 59784
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;


void solve(){
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<vector<ll>>dp(n+5,vector<ll>(n+5));
  REP(w,1,n+1){
    for(int i=n-1;i>=0;--i){
      int j=i+w;
      if(j>n)continue;
      if((j-i)%2==n%2)dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1]);
      else dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1]);
    }
  }
  cout<<dp[0][n]<<"\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

int main() {
  int n;
  string s;
  cin >> n >> s;

  int64_t r,g,b;
  r=0; g=0; b=0;
  rep(i,n){
    if(s.at(i)=='R') r++;
    if(s.at(i)=='G') g++;
    if(s.at(i)=='B') b++;
  }

  int64_t ans = r*g*b;
  
  for(int i=0; i<n; i++){
    for(int t=1; t<=n; t++){
      if(i+2*t>=n) continue;
      
      char first = s.at(i);
      char second = s.at(i+t);
      char third = s.at(i+2*t);

      if(first != second && first != third && second != third) ans--;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

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

    while(true)
    {
      int n = sc.nextInt();
      if(n == 0) break;

      String blank = sc.nextLine();

      int sum = 0;
      double ave = 0;
      double dev = 0;

      int[] intArray = Arrays.stream(sc.nextLine().split(" "))
                           .mapToInt(Integer::parseInt)
                           .toArray();

      for(int i=0; i<n; i++){
        sum += intArray[i];
      }
      ave = sum / (double)n;

      for(int i=0; i<n; i++){
        dev += pow(intArray[i] - ave, 2.0);
      }
      System.out.printf("%.8f\n",sqrt(dev/(double)n));
    }
  }
}


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

struct union_find{
	int N;
	vector<int> parent;
	vector<int> siz;

	union_find(int N) : parent(N), siz(N, 1){
		for (int i = 0; i < N; i++) parent[i] = i;
	}

	int root(int x){
		if(parent[x] == x) return x;
		else return parent[x] = root(parent[x]);
	}

	void merge(int x, int y){
		x = root(x), y = root(y);
		if(x == y) return;
		if(siz[x] < siz[y]) swap(x, y);
		parent[y] = x;
		siz[x] += siz[y];
		siz[y] = 0;
	}

	bool are_same(int x, int y){
		return root(x) == root(y);
	}

	int size(int x){
		return siz[root(x)];
	}
};

int main(){
	int N, i;
	scanf("%d", &N);
	vector<int> A(N), B(N);
	vector<pair<int, int>> AB(N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
		AB[i].first = A[i];
	}
	for(i = 0; i < N; i++){
		scanf("%d", &B[i]);
		AB[i].second = B[i];
	}
	sort(AB.begin(), AB.end());
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	for(i = 0; i < N; i++){
		if(A[i] > B[i]){
			printf("No\n");
			return 0;
		}
	}
/*	for(i = 0; i < N; i++){
		if(B[i] == AB[i].second){
			printf("Yes\n");
			return 0;
		}
	}
*/	for(i = 1; i < N; i++){
		if(A[i] <= B[i - 1]){
			printf("Yes\n");
			return 0;
		}
		if(A[i] == A[i - 1]){
			printf("Yes\n");
			return 0;
		}
	}
	union_find uf(N);
	for(i = 0; i < N; i++){
		int k = lower_bound(B.begin(), B.end(), AB[i].second) - B.begin();
//		printf("(i, k) = (%d, %d)\n", i, k);
		uf.merge(i, k);
	}
	if(uf.size(0) == N){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

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

int main() {
    string s,t;
    cin >> s >> t;

    bool ok = true;
    rep(i,s.size()) {
        if(s[i] != t[i]) ok = false;
    }
    if(ok) {
        if(t.size() == s.size() + 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

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

int main(){
  int a,b,x,y;
  cin >> a >> b;
  x = a * b;
  y = x % 2;
  if(y == 0){
  cout << "Even" << endl;
  }
  else{
  cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep_1(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define rep_2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  ll sum = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != s[i + 1]) sum++;
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int a[] = {111, 222, 333, 444, 555, 666, 777, 888, 999};
int main()
{
	int n, m;
	cin >> n;
	for(int i=0; i<9; i++) 
		if( a[i] >= n ) {
			m = a[i];
			break;
		}	
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a = 0, rem10, rem100, rem1000, count = 0;
  cin >> a;
  rem10 = a % 10;
  rem100 = (a % 100 - rem10 )/10;
  rem1000 = (a % 1000 - rem100 *10 -rem10)/100;
  count = rem10 + rem100 + rem1000;
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
ll inf=1000000000000000,mod=1000000007;

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

     ll a,b;
     ll k;
     cin>>a>>b;
     if(a==1||b==1)
     cout<<"1"<<endl;
     else
     cout<<(a*b+1)/2<<endl;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int count=0;
  int aa=a, bb=b, cc=c;
  int aa0, bb0, cc0;
  do {
    //奇数になったら終了
    if (aa%2 || bb%2 || cc%2)	{
      cout << count << endl;
      return 0;
    }
    //交換
    aa0=aa, bb0=bb, cc0=cc;
    aa = bb0/2 + cc0/2;
    bb = aa0/2 + cc0/2;
    cc = aa0/2 + bb0/2;
    //元に戻ったら無限
    if (aa==a && bb==b && cc==c) {
      cout << -1 << endl;
      return 0;
    }
    count++;
  } while(1);
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  ll n,ans=0; cin>>n;
  for(ll i=1;i*i<=n-1;i++){
      if((n-1)%i==0){
          ans+=2;
          if((n-1)/i==i) ans--;
      }
  }
  for(ll i=2;i*i<=n;i++){
      if(n%i==0){
          ll a=i,b=n/i,N=n;
          while(N%a==0){
              N/=a;
          }
          if(N%a==1) ans++;
          N=n;
          while(N%b==0){
              N/=b;
          }
          if(N%b==1) ans++;
          if(a==b) ans--;
      }
  }
  cout<<ans<<endl;
}

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

typedef long long int ll;

int main()
{
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> t(n), kt(n);
    for(ll i = 0;i < n;i++){
        cin >> t[i];
        kt[i] = t[i] + k;
    }

    sort(t.begin(),t.end());

    ll s = t[0], ans = 0, p = 0;
    for(ll i = 0;i < n;i++){
        if(t[i] <= s + k && i + 1 - p <= c){

        }
        else{
            ans++;
            s = t[i];
            p = i;

        }
    }
    if(p != n){
        ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void) {
	// Your code here!
	long long a,b,z;
	cin >> a>>b>>z;
	long long cnt = 0;
	long long x = b / z +1 ;
	long long y = (a-1) / z +1;
	if (a == 0)
	{
		y = 0;
	}
	cnt = x - y;
	/*for (int i = a; i <= b; i++)
	{
		if (i % z == 0)
		{
			cnt++;
		}
	}*/

	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int i = 1;
    int x = s.nextInt();
    while (x != 0) {
      System.out.println("Case " + i + ": " + x);
      x = s.nextInt();
      i++;
    }
  }
}


Measured memory_bytes: 41644
/*{{{*/
#include "bits/stdc++.h"
using namespace std;

#define MT make_tuple
#define all(x) begin(x), end(x)
#define putchar(x) cout << (x)
static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename ...T> string format(const string& fmt, T&&... args) {
    size_t sz = snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
    unique_ptr<char[]> buf(new char[sz]);
    snprintf(buf.get(), sz, fmt.c_str(), args...);
    return string(buf.get(), buf.get() + sz - 1);
}

template<class T> struct rge { T b, e; auto begin() const { return b; } auto end() const { return e; } };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
template<class T> auto dud(T* x) -> decltype(cerr << *x, 0);
template<class T> char dud(...);

struct debug {
#ifdef LOCAL
    debug(int line) {
        if(line) cerr << "LINE(" << line << ") -> ";
    }
    template<class T> typename enable_if<sizeof dud<T>(0) != 1, debug&>::type operator<<(T i) {
        cerr << boolalpha << i; return * this;
    }
    template<class T> typename enable_if<sizeof dud<T>(0) == 1, debug&>::type operator<<(T i) {
        return *this << range(begin(i), end(i));
    }
    template<class T, class U> debug& operator<<(pair<T, U> d) {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    debug& operator<<(tuple<>&) { return *this << "()"; };
    template<class ...T> debug& operator<<(tuple<T...> d) {
        *this << "("; debug_tuple<sizeof...(T), 0>(d);
        return *this << ")";
    }
    template<size_t L, size_t I, class T> void debug_tuple(const T& t) {
        *this << (I == 0 ? "" : ", ") << get<I>(t);
        if(I + 1 < L) debug_tuple<L, (I + 1) % L>(t);
    }
    template<class T> debug & operator <<(rge<T> d) {
        *this << "[";
        for(auto it = d.b; it != d.e; ++it)
            *this << (it != d.b ?  ", " : "") << *it;
        return *this << "]";
    }
    debug& operator<<(ostream&(*pf)(std::ostream&)) {
        cerr << pf; return *this;
    }
#else
    debug(int) {}
    template<class T> debug& operator<<(T&&) { return *this; }
    debug& operator<<(ostream&(*)(std::ostream&)) { return *this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "] "

#define debug0()  debug(__LINE__)
#define debug1(x) debug(0)
#define GET_MACRO(_0, _1, NAME, ...) NAME
#define debug(...) GET_MACRO(_0, ##__VA_ARGS__, debug1, debug0)(__VA_ARGS__)
/*}}}*/
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

void solve(int) {
    int X, Y;
    cin >> X >> Y;
    for(int i = 0; i <= X; ++i) {
        if(i * 2 + (X - i) * 4 == Y) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main() {
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#define LLINF 110000000000000000

using namespace std;

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

  long long ans = LLINF;
  for (int X = -100; X <= 100; X++) {
    long long ret = 0;
    for (int i = 0; i < N; i++) {
      ret += (A[i] - X)*(A[i] - X);
    }
    ans = min(ret, ans);
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
	double x1, y1, x2, y2;
	
	scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
	printf("%.8lf\n", hypot(x1-x2, y1-y2));
	return 0;
}


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


#define en "\n"
#define sqrt(n) sqrt((long double) n)
#define all(c) (c).begin() , (c).end()
#define MOD 1000000007
#define mem(a) memset(a,0,sizeof(a))
#define flash() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file_input(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))


using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef set<int> seti;
typedef pair<double, double> pdd;
typedef long double ld;



const double EPS=0.000000001;
const double INFD32=1000000000;
const ll INF64=1000000000000000000;
const int INF32=1000000000;

#define maxN 30000000

signed main(void){
    int t=1;
    //cin>>t;
    while(t--){
      int n;
      cin>>n;
      string s;
      vector<string>v;
      for(int i=0;i<n;i++){
        cin>>s;
        sort(s.begin(),s.end());
        v.push_back(s);
      }
      sort(v.begin(),v.end());
      int i=0,j=1;
      long long ans=0;
      long long cnt=1;
      long long ans1=0;
      /*for(auto k:v){
        cout<<k<<" ";
      }*/
      cout<<"\n";
      while(i<n && j<n){
        string s1,s2;
        s1=v[i];
        s2=v[j];
        //cout<<s1<<" "<<s2<<"\n";
        if(s1==s2){cnt++;}
        else{
          cnt*=cnt-1;
          cnt/=2;
          ans1+=cnt;
          i=j;
          cnt=1;
          //cout<<ans1;
        }
        if(j==n-1){
          cnt*=cnt-1;
          cnt/=2;
          ans1+=cnt;
        }
        j++;
      }
      cout<<ans1;
    }
    return 0;
  }


Measured memory_bytes: 5748
#include <cmath>
#include <cstdio>
 
#define EPS 0.00000000001L
 
#define PI 3.141592653589793238462643383279L
 
int main()
{
    int q, x1, y1, x2, y2, x3, y3, x4, y4;
     
    scanf("%d", &q);
     
    for(int i = 0; i < q; i++)
    {
        scanf("%d", &x1);
        scanf("%d", &y1);
        scanf("%d", &x2);
        scanf("%d", &y2);
        scanf("%d", &x3);
        scanf("%d", &y3);
        scanf("%d", &x4);
        scanf("%d", &y4);
         
        long double angle1 = atan2l(y2 - y1, x2 - x1);
        long double angle2 = atan2l(y4 - y3, x4 - x3);
         
        long double sa = fabsl(angle2 - angle1);
         
        if(sa < -EPS) { sa += PI * 2.0; }
 
        if((sa - EPS < PI * 0.5 && PI * 0.5 < sa + EPS) || (sa - EPS < PI * 1.5 && PI * 1.5 < sa + EPS))
        {
            printf("1\n");
        }
        else if((sa - EPS < PI && PI < sa + EPS) || (sa - EPS < 0.0 && 0.0 < sa + EPS))
        {
            printf("2\n");
        }
        else
        {
            printf("0\n");
        }
    }
     
    return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  ll N; cin >> N;

  ll MOD = 1e9 + 7;
  ll ten = 1;
  for (ll i = 0; i < N; i++) {
    ten = (ten * 10) % MOD;
  }

  ll nine = 1;
  for (ll i = 0; i < N; i++) {
    nine = (nine * 9) % MOD;
  }

  ll eight = 1;
  for (ll i = 0; i < N; i++) {
    eight = (eight * 8) % MOD;
  }

  ll ans = (ten - nine - nine + eight) % MOD;
  ans = (ans + MOD) % MOD;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int a[100002];
int main()
{
    long long n,k,i,s=0;
    cin>>k>>n;
    if(k>=n)
    {
        cout<<0;
        return 0;
    }
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n-1;i++)
        a[i]=a[i+1]-a[i],s+=a[i];
    sort(a,a+n-1);
    for(i=2;i<=k;i++)
        s-=a[n-i];
    cout<<s;
    return 0;
}


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

int main(){
	ll x,n;
	cin >> x >> n;
	map<int,int> mp;
	rep(i,n){
		int p;
		cin >> p;
		mp[p]++;
	}
	for (int j = 0; j <= 1000 ; ++j) {
		ll l = x + j;
		ll r = x - j;
		if(mp[r] == 0){
			cout << r << endl;
			return 0;
		} else if (mp[l] == 0){
			cout << l << endl;
			return 0;
		}
	}
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
using namespace std;
#include <algorithm>
#include <string>

int main() {
	int n, a, b, t[1000], cnt = 0;

	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		if (t[i]<a || t[i] >= b)
			cnt++;
	}
	cout << cnt <<endl;
}

Measured memory_bytes: 256
while 1:
	try:
		N,M = map(int,raw_input().split())
		dp = [[0]*(M+1) for i in range(3)]
		for _ in range(N):
			name = raw_input()
			C,V,D,L = map(int,raw_input().split())
			VDL = [V,D,L]
			for i in range(3):
				try: dp[i][C] = max(dp[i][C],VDL[i])
				except: break
				for j in range(M):
					if dp[i][j]:
						try: dp[i][j+C] = max(dp[i][j+C],dp[i][j]+VDL[i])
						except: break
		print max(max(dp[0]),max(dp[1]),max(dp[2]))
	except:
		break

Measured memory_bytes: 4272
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    max_num = 0
    max_idx = 0
    for i in range(n):
        if abs(A[i]) > abs(max_num):
            max_num = A[i]
            max_idx = i

    res = []
    if max_num >= 0:
        for i in range(n):
            if A[i] < 0:
                A[i] += max_num
                res.append([max_idx + 1, i + 1])

        for i in range(1, n):
            A[i] += A[i - 1]
            res.append([i, i + 1])
    else:
        for i in range(n):
            if A[i] > 0:
                A[i] += max_num
                res.append([max_idx + 1, i + 1])

        for i in reversed(range(n - 1)):
            A[i] += A[i + 1]
            res.append([i + 2, i + 1])

    print(len(res))
    for k in res:
        print(*k)


if __name__ == '__main__':
    resolve()


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, d, x;
	cin >> n >> d >> x;
	vvi v(d, vi(n));
	REP(i, d)REP(j, n)cin >> v[i][j];
	REP(i, d - 1) {
		vvi dp(n + 1, vi(x + 1, 0));
		REP(j, n) {
			REP(k, x + 1) {
				if (v[i][j] > k)dp[j + 1][k] = dp[j][k];
				else dp[j + 1][k] = max(dp[j][k], dp[j+1][k - v[i][j]] + v[i + 1][j] );
			}
		}
		int a = -1;
		REP(j, dp[n].size()) {
			a = max(a, dp[n][j]-j);
		}
		x += a;

	}
	cout << x << endl;
}

Measured memory_bytes: 4180
#include<bits/stdc++.h>
using namespace std;
string s;
int dp[100005];
int dpl[100005];
int ans[100005];
int main(){
	cin>>s;
	int len=s.length();
	for(int i=0;i<100005;i++){
		dp[i]=-1;
		ans[i]=1;
		dpl[i]=-1;
	}
	for(int i=len-2;i>=0;i--){
		if(s[i]=='R'){
			if(s[i+1]=='L'){
				dp[i]=i+1;
			}else{
				dp[i]=dp[i+1];
			}
		}
	}
	for(int i=1;i<len;i++){
		if(s[i]=='L'){
			if(s[i-1]=='R'){
				dpl[i]=i-1;
			}else{
				dpl[i]=dpl[i-1];
			}
		}
	}
/*	for(int i=0;i<len;i++){
		cout<<dp[i]<<"\t";
	}
	cout<<endl;
	for(int i=0;i<len;i++){
		cout<<dpl[i]<<"\t"; 
	}
	cout<<endl;
*/	for(int i=0;i<len;i++){
		if(s[i]=='R'){
		if((dp[i]-i)%2==1){
			ans[i]--;
			ans[dp[i]-1]++;
		}else{
			ans[i]--;
			ans[dp[i]]++;
		}
		}else{
			if((i-dpl[i])%2==1){
				ans[i]--;
				ans[dpl[i]+1]++;
			}else{
				ans[i]--;
				ans[dpl[i]]++;
			}
		}
	}
//	cout<<endl;
	for(int i=0;i<len;i++){
		cout<<ans[i]<<" "; 
	}
	return 0;
}

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

int main(){
	int ans=0;
	
	int a,b;
	cin >> a >> b;
	if(a > b*2){
		ans = a-b*2;
	}

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


Measured memory_bytes: 256
f :: (Ord a, Num a) => (a, a, a, a, a) -> a
f (a,b,c,x,y) = if x > y
                then foldr1 min [a*x+b*y, 2*c*y+a*(x-y), 2*c*x]
                else foldr1 min [a*x+b*y, 2*c*x+b*(y-x), 2*c*y]

main :: IO ()
main = do
  [a,b,c,x,y] <- map (read :: String -> Int) . words <$> getLine
  print $ f (a,b,c,x,y)


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


//for(i=0; i<N; i++) cin >> a[i];

class sumSegTree {
public:
  ll n, height;
  vector<ll> data;
  
  sumSegTree(ll _n) {
    n=1;
    height=1;
    while(n<_n) {
      n*=2;
      height++;
    }
    data=vector<ll>(2*n-1);
  }
  
  void add(ll i, ll x) {
    i+=n-1;
    data[i]+=x;
    while(i>0) {
      i=(i-1)/2;
      data[i]+=x;
    }
  }
  
  //[a, b):要求区間，[l, r):対象区間
  ll _sum(ll a, ll b, ll k, ll l, ll r) {
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return data[k];
    else {
      ll s=_sum(a, b, 2*k+1, l, (l+r)/2);
      ll t=_sum(a, b, 2*k+2, (l+r)/2, r);
      return s+t;
    }
  }
  
  ll sum(ll a, ll b) {
    return _sum(a, b, 0, 0, n);
  }
  
};


ll c[MAX*5];
ll pos[MAX*5];

int main(void) {
  ll i, j, k;
  
  ll N, Q;
  cin >> N >> Q;
  for(i=1; i<=N; i++) cin >> c[i];
  
  vector<pair<pll, ll>> v;
  v.push_back({{1, 1}, -1});
  
  for(i=1; i<=Q; i++) {
    ll l, r;
    cin >> l >> r;
    //l--; r--;
    v.push_back({{r, l}, i});
  }
  sort(v.begin(), v.end());
  
  for(i=1; i<=Q; i++) swap(v[i].ft.ft, v[i].ft.sc);
  
  sumSegTree sst(N+5);
  
  set<ll> st;
  memset(pos, -1, sizeof(pos));
  
  ll ans[MAX*5];
  for(ll q=1; q<=Q; q++) {
    ll l=v[q].ft.ft;
    ll pr=v[q-1].ft.sc;
    ll r=v[q].ft.sc;
    
    for(i=(q==1)?1:v[q-1].ft.sc+1; i<=r; i++) {
      if(st.find(c[i])!=st.end()) sst.add(pos[c[i]], -1);
      
      st.insert(c[i]);
      pos[c[i]]=i;
      sst.add(i, 1);
    }
    
    ans[v[q].sc]=sst.sum(l, r+1);
  }
  
  for(i=1; i<=Q; i++) pt(ans[i]);
  
}




Measured memory_bytes: 58872
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;
int main() {
	int N;
	scanf("%d", &N);
	auto X = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", X + i);
	int min = mod;
	for (int i = 1; i <= 100; i++) {
		int sigma = 0;
		for (int j = 0; j < N; j++) {
			sigma += (X[j] - i)*(X[j] - i);
		}
		min = minimum(min, sigma);
	}
	printf("%d", min);
	return 0;
}

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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n>>k>>l;
      if(k*l>=n)
      cout<<"Yes";
      else
      cout<<"No";
      
  
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  deque<char> d(begin(s), end(s));
  int nq;
  cin >> nq;
  int r = 1;
  for (int i = 0; i < nq; i++) {
    int q, f;
    char c;
    cin >> q;
    if (q == 1) {
      r ^= 1 ^ 2;
    } else {
      cin >> f >> c;
      if (f == r)
        d.push_front(c);
      else
        d.push_back(c);
    }
  }
  if (r != 1) reverse(begin(d), end(d));
  for (char c : d) cout << c;
  return 0;
}


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

int main(){
	int n;
	cin>>n;
	long long r, sum;
	vector<long long> t(n), p(n), c(n);
	for(int i = 0; i < n; ++i){cin>>t[i]>>p[i];}
	for(int i = 0; i < n; ++i){c[i] = t[i] + p[i];}
	sort(c.begin(), c.end(), greater<long long> ());
	r = 0;
	for(int i = 0; i < n; i += 2){
		r += c[i];
	}
	sum = 0;
	for(int i = 0; i < n; ++i)sum += p[i];
	cout<<r - sum<<endl;		
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int n;cin>>n;
  vector<int> c(n);
  vector<int> s(n);
  vector<int> f(n);
  rep1(i,n-1)cin>>c[i]>>s[i]>>f[i];
  vector<int> res(n+1,0);
  for(int i=1;i<n;i++){
    int t=s[i];
    for(int j=i;j<n;j++){
      if(t<s[j])t=s[j];
      t=((t-1)/f[j]+1)*f[j];
      t+=c[j];
    }
    res[i]=t;
  }
  rep1(i,n){
    cout<<res[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b;
    char op;
    for(;;){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '+'){
            printf("%d\n",a+b);
        }
        else if(op == '-'){
            printf("%d\n",a-b);
        }
        else if(op == '*'){
            printf("%d\n",a * b);
        }
        else if(op == '/'){
            printf("%d\n",a/b);
        }
        else if(op == '?'){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2724