akhauriyash/Code-Regression huggingface dataset:
#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 LL long long

LL a,b,c;

int main(){
  cin>>a>>b>>c;
  cout<<b+min(a+b+1,c)<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

ll ans=0;

void water(vi a){
  ll n=a.size();
  ll m=1001;
  rep(i,n) chmin(m,a[i]);
  ans+=m;
  rep(i,n) a[i]-=m;
  bool f=false;
  rep(i,n) if(a[i]>0) f=true;
  if(!f) return;
  a.eb(0);
  vi v;
  rep(i,n+1){
    if(a[i]==0){
      if(v.size()==0) continue;
      water(v);
      v={};
    }
    v.eb(a[i]);
  }
  return;
}

void solve() {
  ll n;
  cin>>n;
  vi h(n);
  rep(i,n) cin>>h[i];
  h.eb(0);
  vi v;
  rep(i,n+1){
    if(h[i]==0){
      if(v.size()==0) continue;
      water(v);
      v={};
    }
    else v.eb(h[i]);
  }
  out(ans);
}

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


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

bool in_bounds(int x, int y, int H, int W)
{
    return (1 <= x && x <= W-2) && (1 <= y && y <= H-2);
}

int main()
{
    ll H, W, N;
    cin >> H >> W >> N;

    unordered_map<int, unordered_map<int, int>> m;

    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;

        for (int dx = -1; dx <= +1; ++dx) {
            for (int dy = -1; dy <= +1; ++dy) {
                int y = a + dx;
                int x = b + dy;

                if (in_bounds(x, y, H, W)) {
                    m[y][x]++;
                }
            }
        }
    }

    vector<ll> ans(10);
    ll count = 0;
    for (auto&& mm : m) {
        for (auto&& p : mm.second) {
            ans[p.second]++;
            ++count;
        }
    }

    ans[0] = (ll)(W-2)*(H-2) - count;

    for (auto&& ai : ans) {
        cout << ai << endl;
    }

    return 0;
}


Measured memory_bytes: 69044
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N,M;
	cin >> N >> M;
	vector<vector<int>> jobs(M+1);
	for(int i=0;i<N;i++){
		int a,b;
		cin >> a >> b;
		if(a>M)continue;
		jobs[M-a].push_back(b);
	}
	priority_queue<int> q;
	ll ans = 0;
	for(int i=M-1;i>=0;i--){
		for(int b:jobs[i]){
			q.push(b);
		}
		if(!q.empty()){
			ans += q.top();
			q.pop();
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5504
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	var n, p int
	fmt.Scan(&n)
	fmt.Scan(&p)

	var max int

	reader := bufio.NewScanner(os.Stdin)

	dan := make([][]string, n, n)
	l, r, d, t := [2000][2000]int{}, [2000][2000]int{}, [2000][2000]int{}, [2000][2000]int{}
	for i := 0; i < n; i++ {
		reader.Scan()
		dan[i] = strings.Split(reader.Text(), "")
	}

	for i := 0; i < n; i++ {
		for j := 0; j < p; j++ {
			if dan[i][j] == "#" {
				d[i][j] = 0
				l[i][j] = 0
			} else {
				if i == 0 {
					d[i][j] = 1
				} else {
					d[i][j] = d[i-1][j] + 1
				}
				if j == 0 {
					l[i][j] = 1
				} else {
					l[i][j] = l[i][j-1] + 1
				}
			}
		}
	}

	nn := n - 1
	pp := p - 1
	for i := nn; i >= 0; i-- {
		for j := pp; j >= 0; j-- {
			if dan[i][j] == "#" {
				r[i][j] = 0
				t[i][j] = 0
			} else {
				if j == pp {
					r[i][j] = 1
				} else {
					r[i][j] = r[i][j+1] + 1
				}
				if i == nn {
					t[i][j] = 1
				} else {
					t[i][j] = t[i+1][j] + 1
				}
			}
		}
	}
	for i := 0; i < n; i++ {
		for j := 0; j < p; j++ {
			if dan[i][j] != "#" {
				v := l[i][j] + r[i][j] + t[i][j] + d[i][j] - 3
				if v > max {
					max = v
				}
			}
		}
	}

	fmt.Printf("%#v\n", max)
}


Measured memory_bytes: 327808
import java.util.Scanner
import math._

object Main extends App {
  val sc = new Scanner(System.in)
  val A, B, H, M = sc.nextDouble

  val c = cos(abs(((H*60 + M) / (12*60) - M / 60) * 2 * Pi))
  val z = sqrt(A * A + B * B - 2 * A * B * c)
  println(f"$z%.20f")
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back
#define fir first
#define sec second

const int mxn = 2006;

int n;
char a[mxn];
char b[mxn];

int mr(int x) { return (x % n + n) % n; }

int M[mxn];

int dl[mxn];
int dr[mxn];

void ini() {
	fill(M, M + n, 0);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			M[i] += a[mr(j + i)] != b[j];
	fill(dl, dl + n, 0);
	fill(dr, dr + n, 0);
	for (int i = 0; i < n * 2; ++i)
		dl[mr(-i)] = b[mr(-i)] == '1' ? 0 : dl[mr(-i + 1)] + 1;
	for (int i = 0; i < n * 2; ++i)
		dr[mr(+i)] = b[mr(+i)] == '1' ? 0 : dr[mr(+i - 1)] + 1;
}

int getm(int r) {
	int re = INT_MAX;
	for (int i = 0; i < n; ++i)
		re = min(re, M[i] + min(mr(i - r), mr(r - i)));
	return re;
}


int getl(int r) {
	int re = 0;
	for (int i = 0; i < n; ++i) if (a[i] == '1')
		if (dr[i] > r)
			re = max(re, dl[i]);
	return re * 2;
}

int solve() {
	ini();
	int re = INT_MAX;
	for (int i = 0; i < n; ++i)
		re = min(re, getl(i) + getm(i) + i);
	return re;
}

int main() {
	scanf("%s%s", a, b);
	n = strlen(a);
	
	if (count(b, b + n, '1') == 0) {
		if (count(a, a + n, '1') == 0)
			puts("0");
		else
			puts("-1");
		return 0;
	}
	
	int ans = solve();
	
	reverse(a, a + n);
	reverse(b, b + n);
	
	ans = min(ans, solve());
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string.h>

using namespace std;

typedef long long ll;

int INF = 10000000;

int N;
double p[100];
int m[100], a[100][100];

class Tp{
public:
  int V;
  vector<int> G[100];
  vector<int> rG[100];
  vector<int> vs;
  bool used[100];
  int cmp[100];
  double rsum[100];
  void add(int from, int to) {
    G[from].push_back(to);
    rG[to].push_back(from);
  }
  void dfs(int v) {
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
      if(!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
  }
  void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for (int i = 0; i < rG[v].size(); i++) {
      if (!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
  }

  int scc() {
    memset(used, 0, sizeof(used));
    vs.clear();
    for (int v = 0; v < V; v++)
      if(!used[v]) dfs(v);
    memset(used, 0, sizeof(used));
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--)
      if (!used[vs[i]]) rdfs(vs[i], k++);
    return k;
  }
  double ans() {
    int num = scc();
    for (int i = 0; i < num; i++) rsum[i] = 1.0;
    for (int i = 0; i < V; i++) rsum[cmp[i]] *= p[i];
    bool isTop[num];
    for (int i = 0; i < num; i++) isTop[i] = true;
    for (int i = 0; i < V; i++)
      for (int j = 0; j < m[i]; j++)
        if (cmp[i] != cmp[a[i][j]]) isTop[cmp[a[i][j]]] = false;
    double ans = 1.0;
    for (int i = 0; i < num; i++)
      if(isTop[i]) ans *= 1.0 - rsum[i];
    return ans;
  }
};

int main() {
  while (1) {
    scanf("%d", &N);
    if (N == 0) break;

    Tp t;
    t.V = N;

    for (int i = 0; i < N; i++) {
      scanf("%lf%d", &p[i], &m[i]);
      for (int j = 0; j < m[i]; j++) {
        scanf("%d", &a[i][j]);
        a[i][j]--;
        t.add(i, a[i][j]);
      }
    }
    printf("%f\n", t.ans());
  }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


typedef pair<i64, i64> P;

int main() {
    i64 N; cin >> N;
    vector<P> pos(N);
    vector<i64> h(N);
    REP(i, N) {
        cin >> pos[i].F >> pos[i].S >> h[i];
    }

    REP(cx, 101) REP(cy, 101) {
        bool ok = true;
        i64 ch_ub = 1152921504606846976;
        i64 ch = -1;
        auto calcCH = [&](i64 x, i64 y, i64 h) {
            return h + abs(x - cx) + abs(y - cy);
        };
        REP(i, N) {
            if (h[i] > 0) {
                if (ch < 0) ch = calcCH(pos[i].F, pos[i].S, h[i]);
                else if (ch != calcCH(pos[i].F, pos[i].S, h[i])) ok = false;
            } else {
                chmin(ch_ub, abs(pos[i].F - cx) + abs(pos[i].S - cy));
            }
        }
        if (ok) {
            if (ch < 0 && ch_ub == 1) {
                cout << cx << " " << cy << " " << 1 << endl;
                return 0;
            } else if (1 <= ch && ch <= ch_ub) {
                cout << cx << " " << cy << " " << ch << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    FIN;

    //freopen("../input.txt", "r", stdin);freopen("../output.txt", "w", stdout);
    
    double obj;cin>>obj;

    double act = 100;
    int steps = 0;
    double imp = 1.01;

    while(act < obj){
        steps++;
        act = floor(act*(imp));
        //cout<<act<<"\n";
    }
    cout<<steps<<"\n";
	return 0;
}

Measured memory_bytes: 3732
import itertools
N=int(input())
A=[int(input()) for _ in range(N)]
B=list(itertools.accumulate(A,func=max))
C=list(itertools.accumulate(A[::-1],func=max))[::-1]
print(C[1])
for i in range(1,N-1):
    print(max(B[i-1],C[i+1]))
print(B[-2])


Measured memory_bytes: 15784
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

struct SegmentTree {
private:
    int n;
    vector <ll> node;

public:
    SegmentTree(int sz) {
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1, 0);
    }

    void update(int x, ll val) {
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }

    ll getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return node[k];
        ll vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};

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

    int n;
    cin >> n;

    vector <P> flower(n);
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        flower[i] = P(h, i);
    }

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

    vector <ll> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];

    SegmentTree seg(n);
    for (int i = 0; i < n; i++) {
        int idx = flower[i].second;
        ll mx = 0;
        if (idx) mx = seg.getmax(0, idx);
        seg.update(idx, A[idx] + mx);
    }

    cout << seg.getmax(0, n) << "\n";
    return 0;
}

Measured memory_bytes: 7424
#include  <iostream>
#include  <stdio.h>
using namespace std;


int main(){

    int a[6];
    int index;

    index = 0;
    cin >> a[index];
    index = index + 1;
    cin >> a[index];
    index = index + 1;
    cin >> a[index];
    index = index + 1;
    cin >> a[index];
    index = index + 1;
    cin >> a[index];
    index = index + 1;
    cin >> a[index];

    int cnt[4];
    index = 0;
    cnt[index]=0;
    index = index + 1;
    cnt[index]=0;
    index = index + 1;
    cnt[index]=0;
    index = index + 1;
    cnt[index]=0;
    
    index = 0;
    for(int i1 = 0;i1<6;i1++){
        if(a[i1]==1){
            cnt[index] = cnt[index] + 1;
        }
    }

    index = 1;
    for(int i1=0;i1<6;i1++){
        if(a[i1]==2){
            cnt[index] = cnt[index] + 1;
        }
    }

    index = 2;
    for(int i1=0;i1<6;i1++){
        if(a[i1]==3){
            cnt[index] = cnt[index] + 1;
        }
    }

    index = 3;
    for(int i1=0;i1<6;i1++){
        if(a[i1]==4){
            cnt[index] = cnt[index] + 1;
        }
    }

    int max_cnt,min_cnt;
    max_cnt = 0;
    min_cnt = 6;
    for(int i1=0;i1<4;i1++){
        if(cnt[i1] > max_cnt){
            max_cnt = cnt[i1];
        }
        if(cnt[i1] < min_cnt){
            min_cnt = cnt[i1];
        }

    }

    if(max_cnt < 3 && min_cnt >0){
        cout << "YES";
    }else{
        cout << "NO";
    }



}

Measured memory_bytes: 256
A = list(input())
B = list(input())
C = list(input())
#終わり条件（手札を持っていない条件を定義)
A.append('f')
B.append('f')
C.append('f')

now = A.pop(0)

while(len(A) != 0 and len(B) != 0 and len(C) != 0):
    if(now == 'a'):
        now = A.pop(0)
        if(len(A) == 0):
            winner = 'A'
    elif(now == 'b'):
        now = B.pop(0)
        if(len(B) == 0):
            winner = 'B'
    elif(now == 'c'):
        now = C.pop(0)
        if(len(C) ==0):
            winner = 'C'

print(winner)
    


Measured memory_bytes: 3064
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]

ans=sum(b)
for i,j in zip(a[:-1],a[1:]):
  if j==i+1:
    ans+=c[i-1]
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int a, b, k;

  cin >> a >> b >> k;

  for(int i=max(a, b); i>=0; i--){
    k -= a%i == 0 && b%i == 0;
    if(k == 0) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    sort(A, A+N, greater<int>());
    int n = A[0], m = -1, k;
    rep2(i, 1, N-1){
        if(chmax(m, min(A[i], n-A[i]))) k = A[i];
    }
    cout << n << ' ' << k << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}
ll n;
vector<ll> v;
ll dp[3000][3000]={};

ll dfs(int l,int r,int p){
   if(l==r)return v[l]*mpow(-1,p);

   ll a,b;
   if(dp[l+1][r]>=LINF){
      a=dfs(l+1,r,p^1);
      dp[l+1][r]=a;
   }else{
      a=dp[l+1][r];
   }

   if(dp[l][r-1]>=LINF){
      b=dfs(l,r-1,p^1);
      dp[l][r-1]=b;
   }else{
      b=dp[l][r-1];
   }

   if(!p){
      return max(a+v[l],b+v[r]);
   }else{
      return min(a-v[l],b-v[r]);
   }
}



signed main(){
   cin.tie(0);ios::sync_with_stdio(false);
   cout<<fixed<<setprecision(20);
   cin>>n;
   v.assign(n,0);
   rep(i,0,3000)rep(j,0,3000){
      dp[i][j]=LINF;
   }
   rep(i,0,n){
      cin>>v[i];
      dp[i][i]=v[i]*mpow(-1ll,n+1);
   }

   cout<<dfs(0,n-1,0)<<endl;

}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 70784
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		sc.close();
		if(k%2>0) System.out.print(k/2*((k+1)/2));
		else System.out.print(k/2*(k/2));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(ll i=0;i<n;i++)
#define revf(i,n) for(ll i=n-1;i>=0;i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define inp(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define outp(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "
#define outp1(a,n) for(ll i=1;i<n;i++)cout<<a[i]<<" "
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define pb push_back
#define mp make_pair
#define mem(x,n) memset(x,n,sizeof(x))
#define BINSC binary_search
#define BITOUT __builtin_popcount
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define cn cout<<"\n";
int main()
{
     fast;
     ll k;
     cin>>k;
     if(k%2==0||k%10==5)
     cout<<-1;
     else if(k==1)
     cout<<1;
     else
     {
          ll x=7;ll out=0,divd=x;
          while(1)
          {
               if(x<k){
                    x=x*10+7;out++;}
               else
               {
                    ll y=x/k;
                    if(x%k==0)
                    break;
                    x=(x-y*k)*10+7;
                    out++;
               }
          }
          cout<<out+1;
     }
}

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

int main()
{
    int a, b, c, m, n, out=0;
    cin >> a >> b >> c;

    m = max(a, max(b, c));
    n = (m - a) + (m - b) + (m - c);
    if (n % 2 == 0)
    {
        out = n / 2;
    }
    else
    {
        out = (n+3) / 2;
    }

    cout << out << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1<<8;
int n, k;
int DP1[101][N], DP2[101][N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  setF(n, MOD);
  DP1[0][0] = DP2[0][0] = 1;
  FOR(_, 0, n){
    int a;
    cin >> a;
    FOR(i, 0, n)FOR(j, 0, N) DP2[i+1][j] = (DP2[i+1][j] + DP1[i][j^a]) % MOD;
    memcpy(DP1, DP2, sizeof DP1);
  }
  ll ans = 0;
  FOR(i, 1, n+1) ans += F[i]*DP1[i][k]%MOD;
  cout << ans%MOD << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B=0,C,D=0,E,F=INF;
  cin >> A>>C;
  vector<lli>P(A);
  rep(i,A)cin >> P[i];
  Sort(P);
  rep(i,A){
    if(C+1>P[i])B++;
    else break;
    if(i==A-1){
      if(C!=P[A-1])B--;
    }
    if(i!=A-1)C-=P[i];
    } 
  Out(B);
}
  

Measured memory_bytes: 256
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

s,w = map(int, input().split())
if(s >w):
    print('safe')
else:
    print('unsafe')


Measured memory_bytes: 62032
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

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

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
    int n, m, p;
    while(cin >> n >> m >> p){
        if(n+m+p==0) break;
        int athlete[101];
        int all = 0;
        for(int i=1;i<n+1;i++){
            cin >> athlete[i];
            all += athlete[i];
        }
        int divident = all * (100 - p);
        if(athlete[m]==0) cout << 0 << endl;
        else{
            int ans = divident / athlete[m];
            cout << ans << endl;
        }
    }
    return 0;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

string s ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>s ;
	if(s[2] == s[3] && s[4] == s[5])
		return cout<<"Yes\n" , 0 ;
	else
		return cout<<"No\n" , 0 ;
	return 0 ;
}		

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

using namespace std;

int a[1000001];

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int cnt0 = 0, cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 2 || a[i] * 2 % 4 == 0 && a[i] % 4 != 0) {
            cnt2++;
        } else {
        if (a[i] % 4 == 0) {
            cnt0++;
        } else {
            cnt1++;
        }
        }
    }
    if (cnt2 % 2 != 0) {
        cnt1++;
    }
    if (cnt0 >= cnt1 - 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
fun main(){
    var (N, K) = readLine()!!.split(" ").map(String::toLong)
    N = N % K
    while(true){
        if(K == 1L) {println("0"); return}
        if(N <= java.lang.Math.abs(N-K)) {println(N); return}
        else {N = java.lang.Math.abs(N-K)}
    }
}

Measured memory_bytes: 36336
#include <stdio.h>

typedef unsigned char   u1;
typedef unsigned short  u2;
typedef unsigned long   u4;
typedef signed char     s1;
typedef signed short    s2;
typedef signed long     s4;

#define IN_SIZE 4U
#define OUT_SIZE 10U

int main (void)
{
    u2 u2In;
    u2 u2Upper, u2Lower;
    const char *strOut;

    scanf("%d", &u2In);
    u2Upper = u2In / 100U;
    u2Lower = u2In % 100U;

    if (0U < u2Upper && u2Upper < 13U)
    {
        // MMYY?
        if (0U < u2Lower && u2Lower < 13U)
        {
            strOut = "AMBIGUOUS";
        }
        else
        {
            strOut = "MMYY";
        }
    }
    else
    {
        // YYMM?
        if (0U < u2Lower && u2Lower < 13U)
        {
            strOut = "YYMM";
        }
        else
        {
            strOut = "NA";
        }
    }

    printf("%s\n", strOut);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int a,b,k,x,tmp,i,d[100];
  scanf("%d%d%d",&a,&b,&k);
  if(1 > a){
    printf("エラー\n");
    return 1;
  }else if(b > 100){
    printf("エラー\n");
    return 1;
  }

  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }

  for(i=1;i<=a;i++){
    if(a%i == 0 && b%i == 0){
      x++;
      d[x] = i;
    }
  }

  printf("%d\n",d[x-k+1]);


  return 0;
}

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

int main(){
  string s;
  cin >>s;
  
  int len = s.size();
  string ans;
  ans = s[0] + to_string(len-2) + s[len-1];
  
  cout <<ans<< endl;
}

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

int main() {
  string str;
  cin >> str;
  string ans="";
  for (int i=0; i<(int)str.length(); i++) {
    if (i%2==0) {
      ans += str[i];
    }
  }

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


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    sort(all(data));
    auto yui = unique(all(data));
    data.erase(yui, data.end());
    cout << data.size() << endl;


    return 0;
}


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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k, ans = 0;
  cin >> n >> k;
  while (n >= k) { 
    ans++;
    long long res = n % k;
    n = (n - res) / k;
  }
  ans++;
  cout << ans << '\n';
  return 0;
} 

Measured memory_bytes: 764
#include<bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, V, P, A[101010];
//---------------------------------------------------------------------------------------------------
bool check(int i) {
	int bigger = 0, less = 0;
	ll other = 0;
	rep(j, 0, N) if (j != i) {
		if (A[i] + M < A[j]) bigger++;
		else if (A[j] <= A[i]) less++;
		else other++;
	}

	if (P <= bigger) return false;
	
	ll rest = V - 1 - bigger - less;
	if (rest <= 0) return true;

	ll tot = 0;
	ll cnt = 0;
	rep(j, 0, N) if (A[i] < A[j] and A[j] <= A[i] + M) {
		tot += A[i] + M - A[j];
		
		cnt++;
		ll ok = min({ tot / M, other, rest });
		ll ng = rest - ok;
		if (bigger + ng < P and cnt + ng <= other) {
			return true;
		}
	}

	return false;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> V >> P;
	rep(i, 0, N) cin >> A[i];
	sort(A, A + N);

	int ng = -1, ok = N;
	while (ng + 1 != ok) {
		int md = (ng + ok) / 2;
		if (check(md)) ok = md;
		else ng = md;
	}

	int ans = N - ok;
	cout << ans << endl;
}







Measured memory_bytes: 640
#include<stdio.h>
    #include<string.h>
    int main()
    {
    	char s[30];
    	scanf("%s",s);
    	int t=0;
    	int n=strlen(s);
    	for(int i=0;i<n;i++)
    		for(int j=0;j<n;j++)
    			if(s[i]==s[j]&&i!=j){
    				t=1;break;
    			}
    	if(t==0) printf("yes");
    	else printf("no");
    }

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}

func max(lhs, rhs int) int {
	if lhs < rhs {
		return rhs
	}
	return lhs
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var a []int
	for i := 0; i < n; i++ {
		a = append(a, nextInt())
	}
	sort.Ints(a)

	var ans int
	for i := 0; i < n-2; i++ {
		for j := i + 1; j < n-1; j++ {
			u := a[i] + a[j]
			k := sort.SearchInts(a, u)
			ans += k - j - 1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    a = lmi_0()
    b = lmi()
    c = lmi()
    ans = b[a[0]]
    for i in range(1, n):
        ans += b[a[i]]
        if a[i-1] + 1 == a[i]:
            ans += c[a[i-1]]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  vector <int> A(N);
  for( int i=0;i<N;i++ )
    cin >> A[i];
    
  if( (N-1)%(K-1) == 0 )
    cout << (N-1)/(K-1) << endl;
  else
    cout << (N-1)/(K-1)+1 << endl;
}


Measured memory_bytes: 640
object Main extends App {
  val nabInput  = scala.io.StdIn.readLine()
  val nabArray = nabInput.split(" ").map(_.toLong).toSeq
  val n = nabArray(0)
  val a = nabArray(1)
  val b = nabArray(2)
  val aplusb = a + b

  val syou = n / aplusb
  val amari = n % aplusb

  println(
    syou * a + (if (amari > a) a else amari)
  )
}

Measured memory_bytes: 25556
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */
namespace utils{

    class Repeater{
        int st;
        int ed;
        int d;
    public:
        class rep_iterator{
            int i; int d;
        public:
            rep_iterator(int x, int pd) :i(x), d(pd) {}

            int& operator*(){ return i; }
            bool operator==(const rep_iterator& k) const { return i == k.i; }
            bool operator!=(const rep_iterator& k) const { return i != k.i; }
            rep_iterator& operator++(){ i+=d; return *this; }
        };

        explicit Repeater(int N) :st(0), ed(N), d(1) {}
        Repeater(int b, int e) :st(b), ed(e), d(1) {if(st > ed){ st--; ed--; d = -1; } }

        rep_iterator begin() const{ return rep_iterator(st, d); }
        rep_iterator end() const{ return rep_iterator(ed, d); }

    };

    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N;
    is >> N;
    if(!is) return;
    vector<int> d(N);
    for (auto &&tmp : d) {
        is >> tmp;
    } // end tmp
    sort(ALL(d));
    int cnt;
    if(N % 2) {
        cnt = 1;
    }
    else{
        int pib = d.size() / 2;
        cnt = d[pib] - d[pib-1];

    }
    cout << cnt << endl;
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_C.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
signed main () {
	int n, m;
	cin >> n >> m;
	vector < int > a(n, -1);
	bool shit = 0;
	for (int i = 0; i < m; ++i) {
		int s, x;
		cin >> s >> x;
		--s;
		if (a[s] != -1 && a[s] != x) 
			shit = 1;
		else
			a[s] = x;
	}
	if (a[0] == 0 && n != 1)
		shit = 1;
	if (shit)
		cout << "-1\n";
	else {
		for (int i = 0; i < n; ++i) {
			if (a[i] == -1) {
				if (i || n == 1)
					cout << '0';
				else
					cout << '1';
			}
			else 
				cout << a[i];
		}
		cout << '\n';
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 10005

const int INF = 1e9+7;

int num[10] = {0,2,5,5,4,5,6,3,7,6};
bool use[10];
int dp[ARRAY_MAX];//dp[i]:i本使って条件を満たす整数を作る時の最大の桁数

int main(){

    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    for(int i = 0;i < m;i++){
        cin >> a[i];
        use[a[i]] = true;
    }
    memset(dp,-INF,sizeof(dp));
    dp[0] = 0;
    for(int i = 0;i < m;i++){
        for(int j = 0;j <= n;j++){
            if(j >= num[a[i]]){
                dp[j] = max(dp[j],dp[j-num[a[i]]]+1);//a[i]を使う場合と使わない場合
            }
        }
    }
    int tmp = dp[n];
    for(int i = 1;i <= tmp;i++){//1桁目からtmp桁目まで（条件を満たす整数の最大桁数がtmp桁のため）
        for(int j = 9;j >= 1;j--){//大きい順に調べるほうが最適なので
            if(use[j] == true && num[j] <= n && dp[n-num[j]] == dp[n]-1){
                cout << j;
                n -= num[j];
                break;
            }
        }
    }
    cout << endl;




    return 0;
}

Measured memory_bytes: 256
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

ans = 0

def check(s):
    t = math.sqrt(s)
    u = int(t)
    if u * u == s:
        return 1
    else:
        return 0

for i in range(n):
    for j in range(n - i - 1):
        l = j + i + 1
        s = 0
        for k in range(d):
            s += (x[i][k] - x[l][k]) ** 2
        ans += check(s)

print(ans)


Measured memory_bytes: 3064
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for(int i = 1; ; i++) {
            if(i * n % 360 == 0) {
                System.out.println(i);
                break;
            }
        }
        in.close();
    }
}

Measured memory_bytes: 35608
#include <bits/stdc++.h>
using namespace std;
#define int long long
int rev(int a){
  int p=0;
  while(a!=0){
    p+=a%10;
    p*=10;
    a/=10;
  }
  return p/10;
}
bool pallin(int a){
  if(a==rev(a))
    return true;
  else
    return false;
}
int32_t main()
{
   int a,b;
  cin>>a>>b;
  if(a==1 || b==1){
      if(a==1 && b==1)
      cout<<"1";// mistaken first time
      else
    cout<<a+b-3;
  }else{
    int ans=a*b;
    ans-=2*a;
    ans-=2*(b-2);
    cout<<ans;
  }
    return 0;
}


Measured memory_bytes: 256
#define  REP(i, s, e) for (int i = s; i <= e; i++)
#define DREP(i, s, e) for (int i = s; i >= e; i--)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)

#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 4000 + 10, MOD = 998244353;

int n, k, tot[maxn];
long long fac[maxn], Inv[maxn];
inline int C(int n, int m) {return fac[n] * Inv[m] % MOD * Inv[n-m] % MOD;}

int power_pow(long long base, int b)
{
	long long ans(1);
	while (b)
	{
		if (b & 1) (ans *= base) %= MOD;
		(base *= base) %= MOD;
		b >>= 1;
	}
	return ans;
}
#define inv(x) power_pow(x, MOD - 2)
inline void init()
{
	fac[0] = 1;
	REP(i, 1, 4000) fac[i] = fac[i-1] * i % MOD;
	Inv[4000] = inv(fac[4000]);
	DREP(i, 3999, 0) Inv[i] = Inv[i+1] * (i+1) % MOD;
}

int main()
{
#ifdef CraZYali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif
	init();
	cin >> k >> n;
	REP(i, 1, k) tot[i+1]++, tot[i+k+1]--;
	REP(i, 1, k + k) tot[i] += tot[i-1];
	REP(i, 2, k + k)
    {
		int cnt = tot[i] + 1 >> 1, ans(0);
		const int lim = min(cnt, n >> 1);
		REP(j, 0, lim)
			(ans += (j & 1 ? -1ll : 1ll) * C(cnt, j) * C(n-j-j+k-1, k-1) % MOD) %= MOD;
        printf("%d\n", (ans + MOD) % MOD);
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>

int main(){
   int N;
   std::cin >> N;
   std::map<long long int, int> A;
   for (int i=0; i<N; i++){
      long long int key;
      std::cin >> key;
      A[key]++;
   }
   int cnt = 0;
   for (auto x : A){
      if (x.second % 2 == 1){
         cnt++;
      }
   }
   std::cout << cnt << std::endl;
}



Measured memory_bytes: 9796
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = new int[10];
            for (int i = 0; i < 10; i++)
            {
                arr[i] = int.Parse(Console.ReadLine());
            }
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    if (arr[j] < arr[j + 1])
                    {
                        int t;
                        t = arr[j];
                        arr[j] = arr[j + 1];
                        arr[j + 1] = t;
                    }
                }
            }
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(arr[i]);
            }
        }
    }
}

Measured memory_bytes: 5596
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<string, P>> v(n);
    rep(i,n){
        cin >> v[i].first >> v[i].second.first;
        v[i].second.second = i+1;
    }
    sort(v.begin(), v.end());
    string s = v[0].first;
    vector<P> w;
    rep(i,n){
        if(s == v[i].first){
            w.push_back(P(v[i].second.first, v[i].second.second));
        }
        else{
            sort(w.rbegin(), w.rend());
            for(auto p : w) cout << p.second << endl;
            w.clear();
            w.push_back(P(v[i].second.first, v[i].second.second));
        }
        s = v[i].first;
    }
    sort(w.rbegin(), w.rend());
    for(auto p : w) cout << p.second << endl;
    return 0;
}


Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long a = sc.nextLong();
		long b = sc.nextLong();

		ArrayList<Long> alist = new ArrayList<>();

		long index = 2;
		long upper = 1000000*(long)1000000;
		while(index<=a&&index<=upper) {
			if(a%index == 0) {
				a = a/index;
				alist.add(index);
			}else {
				upper = a/index+1;
				index++;
			}
		}
		alist.add(a);

		index=2;
		ArrayList<Long> common =  new ArrayList<>();
		upper = 1000000*(long)1000000;
		while(index<=b&&index<=upper) {
			if(b%index == 0) {
				b = b/index;
				if(alist.contains(index)) {
					if(!common.contains(index))common.add(index);
				}
			}else {
				upper = b/index+1;
				index++;
			}
		}
		
		if(b!=1) {
			if(alist.contains(b)) {
				if(!common.contains(b))common.add(b);
			}
		}

		System.out.println(common.size()+1);

		/*
		TreeMap<Integer,Integer> treeMap = new TreeMap<>();
		treeMap.put(b[n], n);
		*/

	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/

Measured memory_bytes: 22996