akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(){

int n,x=0,m=0;
cin>>n;
while(n-500>=0){

    x++;
    n=n-500;
}


while(n-5>0){
    m++;
    n=n-5;
}

cout<<(x*1000)+(m*5);

return 0;

}


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

struct Graph {
    vector<vector<int>> adj;
    vector<int> color;
    int colorID;
    Graph(int n) {
        adj.assign(n, vector<int>());
        color.assign(n, -1);
        colorID = 0;
    }
};

void dfs(Graph& g, int u, int colorID)
{
    g.color[u] = colorID;
    for (auto v : g.adj[u]) {
        if (g.color[v] == -1) {
            g.color[v] = colorID;
            dfs(g, v, colorID);
        }
    }
}

int main()
{
    int n, k;
    cin >> n >> k;
    Graph g(n);
    for (int i = 0; i < k; i++) {
        int u, v;
        cin >> u >> v;
        g.adj[u].push_back(v);
        g.adj[v].push_back(u);
    }

    for (int u = 0; u < n; u++) {
        if (g.color[u] == -1) {
            dfs(g, u, g.colorID++);
        }
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int u, v;
        cin >> u >> v;
        if (g.color[u] == g.color[v]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}



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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(long long i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
int A, B, K;
cin >> A >> B >> K;
int cnt = 0;
for(int i = B; i >= 0; i--){ 
   if(A % i == 0 && B % i == 0) cnt++;
   if(cnt == K) {
     print(i);
     return 0;
   }
}

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
	int n;
	int a[105];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	if(n&2==0){
		return 0;
	}
	int c=0;
	for(int i=0;i<n;i++){
		if((i+1)%2==1){
			if(a[i]%2==1){
				c+=1;
			}
		}
	}
	printf("%d",c);
	
	return 0;
 } 

Measured memory_bytes: 3760
from collections import deque

def dfs(start):
    S = deque([start])
    link = {start}
    VL[start] = 1
    while S:
        node = S.pop()
        for f in AB[node]:
            if VL[f] == 1:
                continue
            link.add(f)
            S.append(f)
            VL[f] = 1
    for l in link:
        res[l] = len(link) - len(link & AB[l]) - len(link & CD[l]) - 1

N, M, K = map(int, input().split())

AB = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    AB[a].add(b)
    AB[b].add(a)

CD = [set() for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    CD[c].add(d)
    CD[d].add(c)

VL = [0] * N
res = [0] * N

for i in range(N):
    if VL[i] == 0:
        dfs(i)

print(*res)


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

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

	map<char, int>mp;
	rep(i, s.size()) {
		mp[s[i]]++;
	}

	bool ok = true;
	rep(i, s.size()) {
		if (mp[s[i]] != 1) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
//const int SIZE=;
const double EPS=1e-6;

int main(){
	/*main function start*/
	int a,b;
	scanf("%d%d",&a,&b);
	if((a+b)%2){
		puts("IMPOSSIBLE");
	}
	else{
		printf("%d\n",(a+b)/2);
	}
	return 0;
}


Measured memory_bytes: 256
s = input()
answer = "Yes"
if "N" in s and "S" not in s:
	answer = "No"
elif "S" in s and "N" not in s:
	answer = "No"
elif "W" in s and "E" not in s:
	answer = "No"
elif "E" in s and "W" not in s:
	answer = "No"
print(answer)


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];
void push(int);
int pop();

int main(){
  int a,b;
  top = 0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;

  return S[top+1];
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> w(m,vector<int>(n,0));
  vector<int> p(m);
  rep(i,m){
    int k;
    cin >> k;
    int s;
    rep(j,k){
      cin >> s;
      w[i][s-1]=1;
    }
  }
  rep(i,m) cin >> p[i];
  int ans=0;
  rep(i,(1<<n)){
    int tmp=0;
    rep(j,m){
      int x=0;
      rep(k,n){
        if((i&(1<<k))&&w[j][k]) x++;
      }
      if(x%2==p[j]) tmp++;
    }
    if(tmp==m) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int n,k;
vector<int> b[10];
int dp[10][2001] = {-1};
int d[2001];

int saiki(int index,int g,int m){
    int ret = 0;
    if(index > k){
	return 0;
    }if(index == k){
	return dp[g][index] = m;
    }else if(g == 10) return 0;
    if(dp[g][index] > 0) return dp[g][index];
    REP(i,b[g].size()){
	ret = max(ret,saiki(index+i,g+1,m+b[g][i]));
    }
    return dp[g][index] = ret;
}

int main(){
    cin >> n >> k;
    memset(dp,-1,sizeof(dp));
    memset(d,0,sizeof(d));
    REP(i,10){
	b[i].PB(0);
    }
    REP(i,n){
	int c,g;
	cin >> c >> g;
	b[g-1].PB(c);
    }
    REP(i,10){
	sort(b[i].begin()+1,b[i].end(),greater<int>());
	if(b[i].size() <= 0) continue;
	REP(j,b[i].size()-1){
	    b[i][j+1] += b[i][j];
	}
	REP(j,b[i].size()){
	    b[i][j] += (j-1)*j;
	}
    }

    d[0] = 0;
    REP(i,10){
	RREP(j,n+1){
	    if(d[j] < 0) continue;
	    int s = min(n-j,(int)b[i].size() - 1);
            for(int l=s;l >= 0;l--){
		d[j+l] = max(d[j+l],d[j]+b[i][l]);
	    }
	}
    }
    int ans = 0;
    REP(i,n){
	ans = max(ans,d[i]);
    }
    cout << d[k] << endl;
    /*
    int ans = saiki(0,0,0);
    cout << ans << endl;
    */
    return 0;
}

Measured memory_bytes: 1324
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    h: usize,
    w: usize,
    k: usize,
    s: [chars; h],
  }
  let mut sum = vec![vec![0usize; w+1]; h+1];
  for i in 0 .. h {
    for j in 0 .. w {
      sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] +
        if s[i][j] == '1' {1} else {0};
    }
  }
  let white = |u: usize, d: usize, l: usize, r: usize| {
    sum[d][r] + sum[u][l] - sum[d][l] - sum[u][r]
  };
  let mut ans = 1_000_000_000;
  'outer: for pat in 0 .. 1 << (h - 1) {
    let find_right = |left| {
      let mut right = left + 1;
      while right <= w {
        let mut up = 0;
        let mut down = 1;
        while up < h {
          if down == h || (pat >> (down - 1)) & 1 != 0 {
            if white(up, down, left, right) > k {
              return right - 1;
            }
            up = down;
          }
          down += 1;
        }
        right += 1;
      }
      right
    };
    let mut cut = 0;
    for c in 0 .. h {
      if (pat >> c) & 1 != 0 {
        cut += 1;
      }
    }
    let mut left = 0;
    while left < w {
      let right = find_right(left);
      if left == right {
        continue 'outer;
      }
      left = right;
      cut += 1;
    }
    ans = cmp::min(ans, cut-1);
  }

  puts!("{}\n", ans);
}


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

int main(){
  int n,m;
  cin>> n >> m;
  vector<vector<int>> lights(m);
  int k,s;
  for (int i=0; i<m; i++){
    cin>> k;
    for (int j=0; j<k; j++){
      cin>> s;
      lights.at(i).push_back(s-1);
    }
  }
  vector<int> p(m);
  for (int i=0; i<m; i++){
    cin>> p.at(i);
  }
  
  int ans=0;
  for (int i=0; i<(1<<n); i++){
    bitset<10> bits(i);
    bool success=true;
    for (int j=0; j<m; j++){
      int sum=0;
      for (auto k: lights.at(j)){
        if (bits.test(k)) sum++;
      }
      if (sum%2!=p.at(j)){
        success=false;
        break;
      }
    }
    if (success) ans++;
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main()
{
    int n,m;
    cin >> n >> m;
    ll dp[n+1];
    ll res = m-n+1;
    dp[0] = 1;
    dp[1] = m-n;
    for(int i = 2; i <= n; i++)
    {
        dp[i] = ( (m-n+i-1) * dp[i-1] + (i-1) * dp[i-2]) % mod;
        res   = res * (m-i+2) % mod;
    }
    cout << res * dp[n] % mod << endl;
}


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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
vector<int> cnt;

ll get(int N) {
    ll ret = 0;
    for(int i = 0; i < 101; i++) {
        if (cnt[i] >= N) ret++;
    }
    return ret;
}

void solve() {
    int N;
    cin >> N;
    // 75 = 3 * 5 * 5 = 15 * 5 = 3 * 25 = 75
    //      2   4   4   14   4   2   24   74
    cnt.resize(101);
    
    for(int i = 2; i <= N; i++) {
        int now = i;
        for(int j = 2; j * j <= i; j++) {
            while(now % j == 0) {
                now /= j;
                cnt[j]++;
            }
        }
        if (now > 1) cnt[now]++;
    }

    cout << get(74) + get(24) * (get(2) - 1) + get(14) * (get(4) - 1) + get(4) * (get(4) - 1) * (get(2) - 2) / 2 << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

struct CumulativeSum {
  vector<long long> csum;
  template<typename T>
  CumulativeSum(vector<T> input) : csum(input.size() + 1, 0) {
    for(int i = 0; i < input.size(); i++) csum[i+1] = csum[i] + input[i];
  }
  long long query(int l, int r) { /* 0-indexed, inclusive */ return csum[r+1] - csum[l]; }
};

struct CumulativeSum2D {
  vector<vector<long long>> csum;
  template<typename T>
  CumulativeSum2D(vector<vector<T>> input) : csum(input.size() + 1, vector<long long>(input[0].size() + 1, 0)) {
    for(int i = 0; i < input.size(); i++) for(int j = 0; j < input[i].size(); j++)
      csum[i+1][j+1] += csum[i+1][j] + csum[i][j+1] - csum[i][j] + input[i][j];
  }
  CumulativeSum2D(vector<string> input, char target) : csum(input.size() + 1, vector<long long>(input[0].size() + 1, 0)) {
    for(int i = 0; i < input.size(); i++) for(int j = 0; j < input[i].size(); j++)
      csum[i+1][j+1] += csum[i+1][j] + csum[i][j+1] - csum[i][j] + (input[i][j]==target);
  }
  long long query(int x_left, int y_top, int x_right, int y_bottom) { /* 0-indexed, inclusive */
    return csum[x_right+1][y_bottom+1] - csum[x_right+1][y_top] - csum[x_left][y_bottom+1] + csum[x_left][y_top];
  }
};

signed main() {
#if 1 // https://atcoder.jp/contests/abc122/tasks/abc122_c
  int n,q; cin >> n >> q;
  string s; cin >> s;
  vector<bool> ac(n);
  for(int i=0; i<n-1; ++i) ac[i] = s[i] == 'A' && s[i+1] == 'C';
  CumulativeSum cs(ac);
  while(q--) {
    int l,r; cin >> l >> r; --l, r-=2;
    cout << cs.query(l,r) << endl;
  }
#elif 1 // https://atcoder.jp/contests/abc005/tasks/abc005_4
  int n; cin >> n;
  vector<vector<int>> grid(n, vector<int>(n, 0));
  for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) cin >> grid[i][j];
  CumulativeSum2D cs(grid);

  vector<int> ans(n*n+1);
  for(int x1=0; x1<n; ++x1) for(int y1=0; y1<n; ++y1) for(int x2=x1; x2<n; ++x2) for(int y2=y1; y2<n; ++y2) {
    int w = x2 - x1 + 1, h = y2 - y1 + 1;
    ans[w*h] = max(ans[w*h], (int)cs.query(x1,y1,x2,y2));
  }
  for(int i=1; i<= n*n; ++i) ans[i] = max(ans[i], ans[i-1]);

  int q; cin >> q;
  while(q--) {
    int p; cin >> p;
    cout << ans[p] << endl;
  }
#elif 1 // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0560
  int n,m,k; cin >> m >> n >> k;
  vector<string> grid(m);
  for(int i=0; i<m; ++i) cin >> grid[i];

  CumulativeSum2D J(grid, 'J');
  CumulativeSum2D O(grid, 'O');
  CumulativeSum2D I(grid, 'I');

  for(int i=0; i<k; ++i) {
    int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
    --x1, --y1, --x2, --y2;
    cout << J.query(x1,y1,x2,y2) << " ";
    cout << O.query(x1,y1,x2,y2) << " ";
    cout << I.query(x1,y1,x2,y2) << endl;
  }
#endif
}


Measured memory_bytes: 4300
n = int(input())
l = list(map(int, input().split()))
l.sort()
if n <= 2:
    print(0)
    exit()

cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if l[i] != l[j]:
            for k in l[j+1:]:
                if k < l[i]+l[j] and k != l[i] and k != l[j]:
                    cnt += 1
print(cnt)

Measured memory_bytes: 9180
n = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7

IND = [-1] * (n+1)
for i in range(n+1):
    if IND[A[i]] != -1:
        bet = i - IND[A[i]] - 1
        break
    else:
        IND[A[i]] = i

# print("bet", bet)

M = [1]
mul = 1
for i in range(1, n+3):
    mul = (mul * i) % mod
    M.append(mul)

# print(M[:10])

def inv(a, p):
    pp = p
    p -= 2
    ans = 1
    mul = a
    while p > 0:        
        if p % 2 == 1:
            ans = (ans * mul) % pp
            #print(ans, p)
        mul = (mul ** 2) % pp
        p //= 2
    return ans % pp

#print(inv(3, 13))

I = [1] + [inv(i, mod) for i in range(1, n+3)]
MI = [1]
mul = 1
for i in range(1, n+3):
    mul = (mul * I[i]) % mod
    MI.append(mul)

# print(MI[:10])
# print(I[:10])

D = [0, 0, 1]
for i in range(3, n+3):
    D.append((D[-1] * (n+1-(i-1)) * I[i-2]) % mod)

def C(x, y):
    if x < y or x < 0 or y < 0:
        return 0
    elif x == 0 or y == 0:
        return 1
    else:
        ans = M[x]
        ans = (ans * MI[y]) % mod
        ans = (ans * MI[x-y]) % mod
        return ans

#print(C(6,3))

for k in range(1, n+1):
    ans = C(n-1, k)
    ans = (ans - C(n-1-bet, k-1)) % mod
    ans = (ans + 2 * C(n-1, k-1)) % mod
    ans = (ans + C(n-1, k-2)) % mod
    print(ans)
print(1)

Measured memory_bytes: 72940
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	map<int, int>mp;
	rep(i, 3) {
		int a; cin >> a;
		mp[a]++;
	}
	cout << mp.size() << "\n";

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  while(cin >> n >> m&&n && m){
    vary(ll,p,n,0);
    rep(i,n){
      cin >> p[i];
    }
    sort(all(p));
    ll cnt = 1,ans = 0;
    for(ll i = n-1; i >= 0; --i){
      if(cnt < m){
        ans += p[i];
        ++cnt;
      }
      else{
        cnt = 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>

using namespace std;

int f(int x) {
	int res = 0;
	while (x > 0) {
		res += x % 10;
		x /= 10;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	string ans = "No";
	if (n%f(n)==0)ans = "Yes";
	cout << ans << endl;
	return 0;
}

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

int main(){
  int a,b,c,d;
  int ans = 0;
  cin >> a >> b >> c >> d;

  if(a <= b) ans += a;
  else ans += b;

  if(c <= d) ans += c;
  else ans += d;

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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 dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int main(){
  string A,B,C; cin>>A>>B>>C;
  vector<vector<int> > v(3);
  v[0].resize(A.size());
  v[1].resize(B.size());
  v[2].resize(C.size());
  rep(i,0,A.size()){
    v[0][i] = A[i]-'a';
  }
  rep(i,0,B.size()){
    v[1][i] = B[i]-'a';
  }
  rep(i,0,C.size()){
    v[2][i] = C[i]-'a';
  }
  bool ok=true;
  int nowperson = 0;
  vector<int> now(3,0);
  while(ok){
    if(now[nowperson] == v[nowperson].size()){
      char man;
      switch(nowperson){
        case 0 : man = 'A';
        break;
        case 1 : man = 'B';
        break;
        case 2 : man = 'C';
        break;
      }
      cout << man << endl;
      return 0;
    }
    nowperson = v[nowperson][now[nowperson]++];
  }

  return 0;
}


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

int main(){
	int sec,h=0,m=0,s=0;

	cin >> sec;
	
	h=(sec-(sec%3600))/3600;
	sec=sec-3600*h;
	m=(sec-(sec%60))/60;
	sec=sec-60*m;
	s=sec;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    
   
    ll absx = abs(x), absy = abs(y);
    ans = abs(absx - absy);
    if(x > y){
        if(x > y && x >= 0 && y <= 0) ans++;
        else ans += 2;
    }
    if(x < y && x < 0 && y > 0) ans++;
    if(ans == 0 && x != y) ans++;

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

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 59, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int a, b, c;    cin >> a >> b >> c;
    cout << (b - a == c - b ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
long long int MOD=1000000007;
int n;
ll x,y;
vector<ll> a,b;
int main(){
	cin>>n>>x;
	ll ans=0;
	for(int i=0;i<n;i++){
		cin>>y;
		a.pb(y);
		b.pb(y);
		ans+=y;
	}
	for(int spin=0;spin<n;spin++){
		for(int i=0;i<n;i++){
			int j=(i-spin+n)%n;
			b[i]=min(a[j],b[i]);
		}
		ll sum=0;
		for(int i=0;i<n;i++){
			sum+=b[i];
		}
		sum+=spin*x;
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	
}

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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s.at(i);

    vector<long long> cnt(5, 0);
    string march = "MARCH";

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (s.at(i).at(0) == march.at(j))
            {
                cnt.at(j) = cnt.at(j) + 1;
            }
        }
    }

    long long answer = 0;
    for (int i = 0; i < 5; i++)
    {
        for (int j = i + 1; j < 5; j++)
        {
            for (int k = j + 1; k < 5; k++)
            {
                answer += cnt.at(i) * cnt.at(j) * cnt.at(k);
            }
        }
    }

    // rep(i, 5) cout << cnt.at(i) << endl;

    cout << answer << endl;
}

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstdio>
#define F(i,n) for(int i=0;i<(int)(n);i++)
#define INF 100000000
#define ll long long

using namespace std;
typedef pair<int, int> P;

int main() {
	ll n, m, d,p[10],q,ans;
	while (1) {
		ans = 0;
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		F(i, 10) {
			p[i] = 0;
		}
		F(i, n) {
			cin >> d >> q;
			p[q-1] += d;
		}
		for (int i = 9; i >= 0; i--) {
			if (m - p[i] < 0) {
				p[i] = p[i] - m;
				m = 0;
			}
			else {
				m -= p[i];
				p[i] = 0;
			}
		}
		F(i, 10) {
			ans += p[i]*(i+1);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
<?php
$i = 0;
	while(true) {
		$cnt = 0;
		$stdin = trim(fgets(STDIN));
		$years = explode(' ', $stdin);
		if($years[0] == 0 && $years[1] == 0) {
			break;
		}
		if ($i !== 0) {
			echo "\n";
		}
		for ($i=$years[0]; $i <= $years[1]; $i++) {
			if($i%4 === 0 && $i%100 !== 0 || $i%400 === 0) {
				echo $i . "\n";
				$cnt++;			
			}
		}
		if ($cnt == 0){
			echo "NA\n";
		}
		$i++;
	}

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

typedef pair<int,int> P;

int N, M, A[5005], B[5005][205], C[5005][5005];
map<P,int> point;

int getdis(int l, int r){ // [ l, r ]
  return A[r] - A[l];
}

void dfs(int l, int r, int x){ // [ l, r ]
  
  int m, maxv = 0;
  
  for(int i=l;i<=r;i++){
    
    if( maxv < B[i][x] ){
      maxv = B[i][x];
      m = i;
    }
    
  }
  
  C[l][m] += maxv;
  
  C[l][r+1] -= maxv;
  
  C[m+1][m] -= maxv;
  
  C[m+1][r+1] += maxv;
  
  if( l != m ) dfs( l, m - 1, x );
  
  if( m != r ) dfs( m + 1, r, x );
  
}

signed main(){
  
  cin>>N>>M;
  
  for(int i=1;i<N;i++){
    cin>>A[i];
    A[i] += A[i-1];
  }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>B[i][j];
    }
  }
  
  for(int i=0;i<M;i++) dfs( 0, N-1, i );
  
  for(int i=0;i<N;i++){
    
    for(int j=1;j<N;j++){
      
      C[i][j] += C[i][j-1];
      
    }
    
  }
  
  for(int i=0;i<N;i++){
    
    for(int j=1;j<N;j++){
      
      C[j][i] += C[j-1][i];
      
    }
    
  }
  
  int ans = 0;
  
  for(int i=0;i<N;i++){
    
    for(int j=i;j<N;j++){
      
      ans = max( ans, C[i][j] - getdis( i, j ) );
      
    }
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


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

int min(int x, int y){
    if(x<y)
        return x;
    return y;
}

int frog1_soln(int* arr, int N){
    vector<int> dp_1, dp_2, temp;
    dp_2.push_back(0);
    dp_1.push_back(abs(arr[1] - arr[0]));
    int diff1, diff2;
    int i = 2;
    while(i < N){
        diff1 = abs(arr[i] - arr[i-1]);
        diff2 = abs(arr[i] - arr[i-2]);
        
        temp.assign(dp_2.begin(), dp_2.end());
        dp_2.assign(dp_1.begin(), dp_1.end());

        for(int m = 0; m < 2; m++){
            dp_1[m] += diff1;
        }
        for(int m = 0; m < 2; m++){
            dp_1[m] = min(dp_1[m], temp[m] + diff2);
        }
        i++;
    }
    return min(dp_1[0], dp_1[0]);
}

int main(){
    int N;
    cin >> N;
    int* arr = new int[N];
    for(int i = 0; i < N; i++){
        cin >> arr[i];
    }
    cout << frog1_soln(arr, N);
    delete arr;
}

Measured memory_bytes: 3708
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < 4; i++) {
        bool a = false;
        for (int j = 0; j < 4; j++) {
            if (i == j) {
                continue;
            }
            if (s[i] == s[j] && !a) {
                a = true;
                continue;
            }
            if (s[i] == s[j] && a) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (!a) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val A = new Array[Int](N+2)
    (1 to N) foreach { i =>
      A(i) = sc.nextInt()
    }

    val MAX = A.sliding(2).foldLeft(0)((b, slide) => b + slide.reduce((a, b) => (b - a).abs))
    val r = (1 to N) map { i =>
      MAX - ((A(i) - A(i - 1)).abs + (A(i + 1) - A(i)).abs) + (A(i + 1) - A(i - 1)).abs
    }

    println(r.mkString("\n"))
  }

}


Measured memory_bytes: 72364
//https://onlinejudge.u-aizu.ac.jp/beta/room.html#KUPC2020Spring/problems/A
#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 rate[4];
//---------------------------------------------------------------------------------------------------
void _main() {
	rep(i, 0, 4) cin >> rate[i];

	int ans = inf;
	sort(rate, rate + 4);
	do {
		int ab = rate[0] + rate[1];
		int cd = rate[2] + rate[3];
		chmin(ans, abs(ab - cd));
	} while (next_permutation(rate, rate + 4));

	cout << ans << endl;
}





/* ///////////////////////// writeup1 start
///////////////////////// writeup2 start
チームの組み合わせはC(4,2)/2通りしかないので、全通り試して実力差が最も小さいものを答えよう。
実装では、1234の順列を全列挙して、前半2人と後半2任でグループを作ることで全列挙する。
無駄に組み合わせを考えてしまうが、速度を犠牲にして実装を簡単化するのはよくやる。
（漏れも軽減できるしね）
///////////////////////// writeup2 end */
//　


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long X;
	scanf("%lld",&X);
	long long Y;
	scanf("%lld",&Y);
	long long Z;
	scanf("%lld",&Z);

	cout << Z << " " << X << " " << Y << endl;

	return 0;
}


Measured memory_bytes: 256
S = input().strip()
N = len(S)
cur = 0
flag = 0
while cur<N:
    if S[cur:cur+5]=="dream":
        if cur+5==N:
            cur += 5
        elif cur+5<N and S[cur+5]=="d":
            cur += 5
        elif S[cur:cur+7]=="dreamer":
            if cur+7==N:
                cur += 7
            elif S[cur+7] in ["d","e"]:
                cur += 7
            elif S[cur+7]=="a":
                cur += 5
            else:
                flag = 1
                break
        else:
            flag=1
            break
    elif S[cur:cur+5]=="erase":
        if cur+5==N:
            cur += 5
        elif cur+5<N and S[cur+5]=="r":
            cur += 6
        elif cur+5<N and S[cur+5] in ["d","e"]:
            cur += 5
        else:
            flag = 1
            break
    else:
        flag=1
        break
if flag==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 67808
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    
    int n = 1;
    long result = 0;

    while(true){
      result = (long) Math.pow(2,n);
      if(result > H){break;}
      n++;
    }
    
    //a_n=2^(n-1)の等比数列の、n項までの和
    long s = (long) Math.pow(2,n) - 1;
    System.out.println(s);
    
  }
}

Measured memory_bytes: 23124
// 文字の長さ
// 文字列
// 文字列がある文字列の繰り返しで生成されたものかを判断する

"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf-8"));

function main(input) {
  input = input.split("\n");
  let num = parseInt(input.shift());
  input = input[0].split("");
  input = input.map(s => {
    return String.fromCharCode(
      s.charCodeAt(0) + num > 90
        ? 65 + (s.charCodeAt(0) + num - 91)
        : s.charCodeAt(0) + num
    );
  });

  console.log(input.join(""));
}


Measured memory_bytes: 7500
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> a(h); 

    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }

    for (int i = 0; i < w+2; ++i) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0;  i < h; ++i) {
        cout << "#" << a[i] << "#" << endl;
    }
    for (int i = 0; i < w+2; ++i) {
        cout << "#";
    }
    cout << endl;

    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A+B) > (C+D)) {
    cout << "Left" << endl;
  }
  else if ((A+B) == (C+D)) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;

int main(){
    string before;
    while (getline(cin, before)) {
        int swich = 0;
        for (int i = 0; i < 27 ;i++) {
            for (int j = 0; j < before.size(); j++) {
                if (isalpha(before[j])) {
                    before[j]++;
                }
                if (before[j]>'z') {
                    before[j] = 'a';
                }

            }
            for (int j = 0; j < before.size(); j++) {
                if (before[j]=='t'&& before[j+1]=='h'&& before[j+2]=='e') {
                    if (before[j+3]==' '|| before[j+3]=='.'|| before[j+3] == '\n') {
                        swich = 1;
                        break;
                    }
                }
                else if (before[j]=='t'&&before[j+1]=='h'&&before[j+2]=='a'&&before[j+3]=='t') {
                    if (before[j+4]==' '||before[j+4]=='.'|| before[j+4] == '\n') {
                        swich = 1;
                        break;
                    }
                }
                else if (before[j]=='t'&&before[j+1]=='h'&&before[j+2]=='i'&&before[j+3]=='s') {
                    if (before[j+4]==' '||before[j+4]=='.'|| before[j+4] == '\n') {
                        swich = 1;
                        break;
                    }
                }
            }
            if (swich == 1) {
                break;
            }
        }
        cout << before << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int H, W;
	cin >> H >> W;
	vector<vector<bool>>F(H, vector<bool>(W, false));
	for (int h = 0; h < H; ++h) {
		string S;
		cin >> S;
		for (int w = 0; w < W; ++w) {
			if (S[w] == '#') {
				F[h][w] = true;
			}
		}
	}
	vector<vector<LL>> A(H, vector<LL>(W, 0));
	vector<vector<LL>> B(H, vector<LL>(W, 0));

	for (int h = 0; h < H; ++h) {
		int cnt = 0;
		int start = -1;
		int end = 0;
		for (int w = 0; w < W; ++w) {
			if (F[h][w] == true) {
				if (start != -1) {
					for (int k = start; k <= end; ++k) {
						A[h][k] = cnt;
					}
				}
				cnt = 0;
				start = -1;
			}
			else {
				if (start == -1) {
					start = w;
				}
				end = w;
				++cnt;
			}
		}
		if (start != -1) {
			for (int k = start; k <= end; ++k) {
				A[h][k] = cnt;
			}
		}
	}

	for (int w = 0; w < W; ++w) {
		int cnt = 0;
		int start = -1;
		int end = 0;
		for (int h = 0; h < H; ++h) {
			if (F[h][w] == true) {
				if (start != -1) {
					for (int k = start; k <= end; ++k) {
						B[k][w] = cnt;
					}
				}
				cnt = 0;
				start = -1;
			}
			else {
				if (start == -1) {
					start = h;
				}
				end = h;
				++cnt;
			}
		}
		if (start != -1) {
			for (int k = start; k <= end; ++k) {
				B[k][w] = cnt;
			}
		}
	}
	LL ans = 0;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			LL res = 0;
			if (A[h][w] == 0) {
				res = B[h][w];
			}
			else if (B[h][w] == 0) {
				res = A[h][w];
			}
			else {
				res = A[h][w] + B[h][w] - 1;
			}
			chmax(ans, res);
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 63488
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846264338
using namespace std;
//
int main(){
  long long nx,ny,gx,gy;
  long long N;
  bool F=true;
  cin>>nx>>ny>>gx>>gy;
  if((nx>gx)^(ny>gy)){
    F=false;
  }
  if(nx>gx){
    swap(nx,gx);
  }
  if(ny>gy){
    swap(ny,gy);
  }
  long long W=gx-nx;
  long long H=gy-ny;
  cin>>N;
  vector<pair<long long,long long> > V;
  FOR(i,0,N){
    long long X,Y;
    cin>>X>>Y;
    if(nx<=X&&X<=gx&&ny<=Y&&Y<=gy){
      V.PB(MA(X,Y));
    }
  }
  if(V.empty()){
    printf("%.15f\n",(double)(W+H)*100);
    return 0;
  }
  if(F){
    sort(V.begin(),V.end());
  }else{
    sort(V.rbegin(),V.rend());
  }
  long long DP[200000];
  long long M=V.size();
  fill(DP,DP+M,INF);
  FOR(i,0,M){
    *lower_bound(DP,DP+M,V[i].SE)=V[i].SE;
  }
  long long res=lower_bound(DP,DP+M,INF)-DP;
  double ans=(W+H)*100-res*2*10;
  if(!W||!H){
    printf("%.15lf\n",res*PI*20/2+ans);
  }else{
    if(res==min(W,H)+1){
      printf("%.15lf\n",(res-1)*PI*20/4+PI*20/2+ans);
    }else{
      printf("%.15lf\n",res*PI*20/4+ans);
    }
  }
  return 0;
}


Measured memory_bytes: 6512
from collections import Counter, defaultdict, deque

N, M, K = [int(x) for x in input().split()]
MOD = 998244353


def modInverse(a, p):
    # Fermat's little theorem, a**(p-1) = 1 mod p
    return pow(a, p - 2, p)


# Precompute all factorials
fact = [1]
for i in range(1, 2 * (10 ** 5) + 1):
    fact.append((fact[-1] * i) % MOD)


def nCr(n, r, p=MOD):
    # Modulo binomial coefficients
    return (fact[n] * modInverse(fact[r], p) * modInverse(fact[n - r], p)) % p


total = 0
for i in range(K + 1):
    total += nCr(N - 1, i) * M * pow(M - 1, N - i - 1, MOD)
    total %= MOD
print(total)


Measured memory_bytes: 85004
n = int(input())

S = list(map(int, input().split()))

c = 0

def merge(A, left, mid, right):
  inf = float('inf')
  L = A[left:mid] + [inf]
  R = A[mid:right] + [inf]
  i = 0
  j = 0
  global c
  for k in range(left, right):
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
      c += 1
    else:
      A[k] = R[j]
      j += 1
      c += 1

def mergesort(A, left, right):
  if left+1 < right:
    mid = (left + right)//2
    mergesort(A, left, mid)
    mergesort(A, mid, right)    
    merge(A, left, mid, right)

mergesort(S, 0, n)

print(" ".join(map(str, S)))

print(c)


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) {
        cin >> l[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                if(i < j && j < k && l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
                    if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3576
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    String S = scanner.nextLine();
    String T = scanner.nextLine();
    
    if(T.length() != S.length() && T.substring(0,S.length()).equals(S)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
  }
}

Measured memory_bytes: 35752
//all possible//
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long a,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0,a9=0,n,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a;
		if(a>=1 && a<400)
		a1=1;
		if(a>=400 && a<800)
		a2=1;
		if(a>=800 && a<1200)
		a3=1;
		if(a>=1200 && a<1600)
		a4=1;
		if(a>=1600 && a<2000)
		a5=1;
		if(a>=2000 && a<2400)
		a6=1;
		if(a>=2400 && a<2800)
		a7=1;
		if(a>=2800 && a<3200)
		a8=1;
		if(a>=3200 && a<=4800)
		a9++;
	}
	if(a9==n)
	cout<<1<<" "<<a9;
	else
	cout<<a1+a2+a3+a4+a5+a6+a7+a8<<" "<<a1+a2+a3+a4+a5+a6+a7+a8+a9;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include<iomanip>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m; cin >> n >> m;
	vector<pair<long long, long long>> vec;
	for (int i = 0; i < n; ++i)
	{
		long long a; cin >> a;
		vec.push_back({ a, 1 });
	}
	for (int i = 0; i < m; ++i)
	{
		long long b, c; cin >> b >> c;
		vec.push_back({ c, b });
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	long long res = 0;
	long long y = n;
	for (pair<long long, long long> x : vec)
	{
		res += x.first * min(x.second, y);
		y = max(0LL, y - x.second);
	}
	cout << res << endl;
}

Measured memory_bytes: 6384
# AGC014A - Cookie Exchanges
def main():
    a, b, c = tuple(map(int, input().split()))
    if a == b == c:  # corner case
        print(0 if a % 2 == 1 else -1)
        return
    ans = 0
    while 1 not in (a % 2, b % 2, c % 2):
        a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
typedef vector<i64> vi;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 n,k;
  cin >> n >> k;

  vi a(n);
  rep(i,n) cin >> a[i];

  vector<bool> dp(k+1,false);
  rep(i,k)
    rep(j,n)
      if(i+a[j]<=k && !dp[i]) dp[i+a[j]] = true;

  if(dp[k]) cout << "First\n";
  else cout << "Second\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 256