akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

#define MAX 2500

int main() {
    int K, S;
    int ans = 0;

    cin >> K >> S;

    for (int X = 0; X <= K; ++X) {
        for (int Y = 0; Y <= K; ++Y) {
            int Z = S - X - Y;
            if (Z <= K && Z >= 0) {
                ans += 1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	ll n;
	cin>>n;
	vector<ll>a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	unordered_set<int>cnt;
	cnt.insert(0);
	ll ans = 0;
	for(int i=0;i<n;i++){
		if(cnt.count(a[i]-1)){
			cnt.insert(a[i]);
			ans = max(ans,a[i]);
		}
	}
	if(ans == 0)cout<<-1;
	else cout<<n-ans;
}

Measured memory_bytes: 12972
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }

    a.sort();
    let a_len = *a.iter().max().unwrap();
    let mut dp = vec![true; a_len+1];

    let mut previous = 0;
    for na in &a {
        if previous == *na {
            dp[*na] = false;
            continue;
        }
        previous = *na;
        let mut mul = 2;
        let mut i = *na * mul;
        while i <= a_len {
            dp[i] = false;
            //println!("na : {} i {}", *na, i);
            mul+=1;
            i = *na * mul;
        } 
    }

    let mut count = 0;
    for na in &a {
        if dp[*na] {
            count+=1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 6068
import sys
s = input()
L = []
alp = [chr(ord('a') + i) for i in range(26)]
TF = [False]*26
for i in range(len(s)):
  if not s[i] in L:
    L.append(s[i])
    TF[ord(s[i])-97] = True
if len(L) != 26:
  for i in range(26):
    if TF[i] == False:
      k = alp[i]
      break
  print(s+k)
else:
  right = s[-1]
  for i in reversed(range(len(s))):
    k = s[i]
    if k < right:
      for j in range(ord(k),ord(k)+26):
        if chr(j) in s[i+1:]:
          print(s[:i]+chr(j))
          break
      sys.exit()
    else:
      right = max(k,right)
  print(-1)

Measured memory_bytes: 38384
X,Y=map(int, input().split())
ok = 0
for i in range(101):
  for j in range(101):
    if (i+j == X) and ((i*2)+(4*j)==Y):
      ok = 1
      break
  if ok == 1:
    break
if ok == 1:
  print("Yes")
else:
  print("No")


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

using namespace std;

typedef pair<int, int> II;
typedef pair<long long, int> LLI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<II> VII;

#define For(i,a,b) for(int i = a;i <= b; i++)
#define Rep(i,a,b) for(int i = a;i >= b; i--)
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, f) for(auto i : f)
#define fi first
#define se second
#define pb push_back
#define sz(s) int(s.size())
#define reset(f, x) memset(f, x, sizeof(f))
#define all(x) x.begin(), x.end()
#define two(x) (1LL << x)
#define getbit(x, i) ((x >> (i-1)) & 1LL)
#define onbit(x, i) (x | (1LL << (i-1)))
#define offbit(x, i) (x & ~(1 << (i-1)))

const int M = 1e9 + 7;
const int N = 1e6 + 1;

int n;
LL f[N], res, g[N];

LL pw(LL a, int n) {
    LL res = 1;
    while (n) {
        if (n & 1) res = (res*a) % M;
        a = (a*a) % M;
        n >>= 1;
    }
    return res;
}

LL C(int k, int n) {
    LL res = (g[n]*pw(g[k], M-2)) % M;
    res = (res*pw(g[n-k], M-2)) % M;
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    //freopen("","w",stdout);
    cin >> n;
    g[0] = g[1] = 1;
    For(i, 2, n) g[i] = (g[i-1]*i) % M;
    //cout << C(1, 2) << "\n";
    for(int k = (n+1)/2; k < n; k++) {
        f[k] = (C(n-k-1, k-1)*g[k]) % M;
        f[k] = (f[k]*g[n-1-k]) % M;
        res = (res + ((f[k] - f[k-1] + M)*k) % M) % M;
    }
    cout << res;
}




Measured memory_bytes: 13824
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[][] g=new int[n+1][n+1];
		int[][] c=new int[n+1][n+1];
		int INF = (int) 1e9;
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=n;j++) {
				g[i][j] =  INF;
			}
			g[i][i] = 0;
		}
		
		for(int i=0;i<m;i++) {
			int u=sc.nextInt(),v=sc.nextInt(),w=sc.nextInt();
			g[u][v] = w;
			g[v][u] = w;
			c[u][v] = w;
			c[v][u] = w;
		}
		
		for(int k=1;k<=n;k++) {
			for(int i=1;i<=n;i++) {
				for(int j=1;j<=n;j++) {
					g[i][j] = Math.min(g[i][j],g[i][k]+g[k][j]);
				}
			}
		}
		int ans =0;
		for(int i=1;i<=n;i++) {
			for(int j=i+1;j<=n;j++) {
				if(c[i][j]>g[i][j])
					ans++;
			}
		}
		System.out.print(ans);
	}
}

Measured memory_bytes: 25968
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
check = [0,0];c = 0;check_num = 0
for i in range(len(a)-1):
    if c == 1:
        c = 0
        continue
    if check_num == 2:break
    if a[i] == a[i+1]:
        check[check_num] = a[i]
        check_num += 1
        c = 1
print(check[0]*check[1])

Measured memory_bytes: 14244
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7

def main():
    N, K = map(int, readline().rstrip().split())
    ans = 0
    m = (N * (N + 1)) // 2
    for k in range(K, N+2):
        mi = ((k-1) * k) // 2
        ma = m - ((N-k) * (N-k+1)) // 2
        ans += (ma - mi + 1)

    print(ans % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9204
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
using ll = long long int;

int main() {
  ll n;
  cin >> n;
  vector<ll> r(n);
  
  ll ai = 0;
  for (ll i = 0; i < n; i++)
  {
    cin >> r[i];
    ai = max(ai, r[i]);
  }

  long double pre = 1e9;
  long double mid = ai / 2.0;

  ll aj = ai;
  for (ll i = 0; i < n; i++)
  {
    if (r[i] == ai) {
      continue;
    }
    long double now = abs((long double)r[i] - (long double)mid);
    if (pre > now) {
      aj = r[i];
      pre = now;
    }
  }
  cout << ai << " " << aj << endl;
}

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

using namespace std;

typedef long long ll;

bool isPalin(string s, int l, int r) {
	int m = (r - l) / 2;
	for (int i = 0; i <= m; i++) {
		if (s[l + i] != s[r - i]) return false;
	}
	return true;
}

bool isPalin(string s) {
	return isPalin(s, 0, s.length() - 1);
}

bool solve(string s) {
	int n = s.length();
	return isPalin(s) && isPalin(s, 0, (n - 1) / 2 - 1) && isPalin(s, (n + 3) / 2 - 1, n - 1);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	
	cout << (solve(s) ? "Yes" : "No") << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
#include <functional>
// #include <iomanip>
// #include <iterator> // inserter . setのintersection するとき．
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N, M; cin >> N >> M;
vector<pair<int64_t, int64_t>> CB(M);
priority_queue<int64_t, vector<int64_t>, greater<int64_t>> A;
int a;
rep(i, 0, N) {
    cin >> a;
    A.push(a); 
}
rep(i, 0, M) cin >> CB[i].second >> CB[i].first;

sort(ALL(CB), greater<pair<int64_t, int64_t>>());

rep(i, 0, M){
    for (int j = 0; j < CB[i].second && A.top() < CB[i].first; j++){
        A.pop();
        A.push(CB[i].first);
    }
}

int64_t sum = 0; 
while (!A.empty()){
    sum += A.top();
    A.pop();
}

cout << sum << "\n";

}

// 境界，出力文字列 チェック



Measured memory_bytes: 2936
N = int(input())
a = list(map(int,input().split()))

color = [0] * 8
ext = 0
for i in range(N):
    for j in range(1,9):
        if a[i] < (j*400):
            color[j-1] += 1
            break
    else:
        ext += 1 
        
        
cnt = 0
for i in color:
    if i > 0:
        cnt += 1
        
minim = max(0,cnt+1 * int(ext>0 and cnt == 0))
maxim = cnt+ext

print(minim,maxim)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(1);
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  //for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 200005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;

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

map<pair<ll,ll>,int> memo;

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

  ll z = 0;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    if(a==0 && b==0){
      z++;
    }else if(a==0){
      memo[make_pair(0,1)]++;
    }else if(b==0){
      memo[make_pair(1,0)]++;
    }else{
      ll g = gcd(abs(a),abs(b));
      if(b<0) g *= -1;
      memo[make_pair(a/g,b/g)]++;
    }
  }

  vector<pair<ll,ll>> v;
  FOR(it,memo){
    if(it->second == -1) continue;
    pair<ll,ll> x = it->first;
    ll a = x.first;
    ll b = x.second;

    ll ra = abs(b);
    if(a > 0) ra *= -1;
    ll rb = abs(a);
    
    v.emplace_back(it->second, memo[make_pair(ra,rb)]);
    memo[make_pair(ra,rb)] = -1;
  }

  mint ret(1);
  rep(i,v.size()){
    //cout << v[i].first << " " << v[i].second << endl;
    ret *= (mutil.pow(2, v[i].first) - 1) + (mutil.pow(2, v[i].second) - 1) + 1;
    //cout << (mutil.pow(2, v[i].first) - 1) + (mutil.pow(2, v[i].second) - 1) + 1 << endl;
  }
  ret -= 1;
  
  ret += z;
  
  cout << ret << endl;
  
  return 0;
}



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

#define endl '\n'
#define LL long long
#define MP make_pair
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define FORR(i, a, b) for(int i = b - 1; i >= a; --i)
#define EB emplace_back
#define ST first
#define ND second
#define S size()
#define RS resize

using VI = vector<int>;
using VVI = vector<VI>;
using PI = pair<int, int>;
using VPI = vector<PI>;
using VVPI = vector<VPI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

int main()
{ 
    int n;
    cin >> n;
    VVI h(n), dp(n);
    REP(i, n)
    {
		int a, b, c;
		cin >> a >> b >> c;
		h[i].EB(a);
		h[i].EB(b);
		h[i].EB(c);
	}
	REP(i, n)
	    dp[i].RS(3);
	dp[0][0] = h[0][0];
	dp[0][1] = h[0][1];
	dp[0][2] = h[0][2];
	FOR(i, 1, n)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + h[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + h[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + h[i][2];
	}
	int wyn = max(dp[n - 1][0], dp[n - 1][1]);
	wyn = max(wyn, dp[n - 1][2]);
	cout << wyn;
}

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

int main(){
    int n, i;
    cin >> n;
    long long t, a[n], dif = 9999999999999;
    for(i=0; i<n; i++){
        cin >> t;
        if(i == 0){
            a[i] = t;
        }else{
            a[i] = a[i-1] + t;
        }
    }
    for(i=0; i<n-1; i++){
        dif = min(dif, abs(a[n-1]-2*a[i]));
    }
    cout << dif;
    return 0;
}

Measured memory_bytes: 1792
const Main = (input) => {
  const nSplitted = input.split(" ");
  const N = nSplitted[0];
  const A = nSplitted[1];
  const B = nSplitted[2];
  if (A * N < B) {
    console.log(A * N);
  } else {
  	console.log(B);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
const int N = 2000006;

bool np[N];
vector<ll> prims;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	np[0] = np[1] = 1;
	for(int i=4;i<N;i+=2) np[i] = 1;
	prims.push_back(2);
	for(int i=3;i<N;i+=2){
		if(!np[i]){
			prims.push_back(i);
			for(ll j = 1ll*i*i;j<N;j+=i){
				np[j] = 1;
			}
		}
	}
	
	ll a,b;
	cin>>a>>b;
	
	ll g = __gcd(a,b);
	int ans = 1;
	ll t = g;
	for(int i=0;i<(int)prims.size();i++){
		if(g % prims[i] == 0)ans++;
		while(t%prims[i] == 0) t/=prims[i];
	}
	if(t > 1)ans++;
	cout<<ans;
	
	return 0;
}


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

using namespace std;

typedef long long ll;

#define INF 2000000000
#define SIZE 1000000
#define pb push_back
#define showint(x) cerr<<#x<<" is "<<x<<endl;
#define showarr(x,n) for(int I=0;I<n;I++) {cerr<<#x<<"["<<I<<"]"<<" is "<<x[I]<<endl;}
//#define fin cin

int main()
{
  ifstream fin("input.txt",ios::in);
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
  cout<<setprecision(10);
  cout<<fixed;
  int a,b,c;
  cin>>a>>b>>c;
  cout<<(a-b+1)*(a-c+1);
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans = -LINF, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll dp[ohara][4];

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

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

  rep(i, n) rep(j, 3) dp[i][j] = -LINF;

  if (n % 2 == 0) {
    for (ll i = n - 2; i >= 0; i -= 2) {
      //そのまま
      dp[i][0] = max(dp[i + 2][0], dp[i + 2][1]) + a[i];
      //
      dp[i][1] = dp[i + 2][1] + a[i + 1];
      // debug(dp[i][0]);
    }
    ans = max(dp[0][0], dp[0][1]);
    Cout(ans);
  } else {
    for (ll i = n - 2; i >= 0; i -= 2) {
      //そのまま
      dp[i][0] = max(dp[i + 2][0], dp[i + 2][1]) + a[i];
      //
      dp[i][1] = dp[i + 2][1] + a[i + 1];
      //
      dp[i][2] = max({dp[i + 2][0], dp[i + 2][1], dp[i + 2][2]}) + a[i - 1];
      // debug(dp[i][0]);
    }
    ans = max({ans, dp[1][0], dp[1][1], dp[1][2]});
    Cout(ans);
  }
  return 0;
}


Measured memory_bytes: 11424
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[300006];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=n;i<3*n;i+=2)
    {
        a[i]=a[(i-n)/2]+1;
        a[i+1]=a[(i-n)/2]-1;
    }
  //  for(int i=0;i<3*n;i++)
   //     cout<<a[i]<<" ";
    sort(a,a+3*n);
    int t=1,ans=-1;
    for(int i=1;i<3*n;i++)
    {
        if(a[i-1]==a[i])
           t++;
        else
        {
            ans=max(ans,t);
            t=1;
        }
    }
    cout<<ans;
}


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

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split(" ");
        var n = decimal.Parse(s[0]);
        var x = decimal.Parse(s[1]);
        var t = decimal.Parse(s[2]);
        Console.WriteLine((long)Math.Ceiling(n / x) * t);
    }
}


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

signed main(void)
{
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;

	if (u == s)
		a--;
	if (u == t)
		b--;
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
xyz = [[[0 for i in range(101)] for j in range(101)] for k in range(101)]
ans = [0 for i in range(n+1)]

def gen_n(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            num = gen_n(i, j, k)
            if n >= num:
                ans[num] += 1
for i in range(1, n+1):
    print(ans[i])


Measured memory_bytes: 18416
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define INF (1e9)
#define LINF (1LL << 60)
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,k,n) for(int i=(k);(i)<(n);(i)++)
#define REP(i,n) for(int i = 0;(i)<(n);(i)++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define F first
#define S second
#define MOD 1000000007

LL dp[101][4][4][4];

int main() {
	int n;
	cin >> n;
	dp[0][3][3][3] = 1;
	FOR(len, 1, n + 1) {
		REP(i, 4) {
			REP(j, 4) {
				REP(k, 4) {
					REP(l, 4) {
						if (j == 0 && k == 2 && l == 1) continue;
						if (j == 2 && k == 0 && l == 1) continue;
						if (j == 0 && k == 1 && l == 2) continue;
						if (i == 0 && k == 2 && l == 1) continue;
						if (i == 0 && j == 2 && l == 1) continue;
						dp[len][j][k][l] += dp[len - 1][i][j][k];
						dp[len][j][k][l] %= MOD;
					}
				}
			}
		}
	}
	LL ans = 0;
	REP(i, 4) {
		REP(j, 4) {
			REP(k, 4) {
				ans += dp[n][i][j][k];
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
<?php
$input = explode(' ', trim(fgets(STDIN)));
$number = array_sum($input);

if ($number % 3 == 0 || $input[0] % 3 == 0 || $input[1] % 3 == 0) {
  echo "Possible\n";
} else {
  echo "Impossible\n";
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  int n, k; cin >> n >> k;
  vec l(k), r(k);
  vector<mint> a(n), s(k);
  rep(i,k) {
    cin >> l[i] >> r[i];
  }
  a[0] = 1;

  for(int i = 1; i < n; i++) {
    rep(j,k) {
      if (i >= l[j]) {
        s[j] += a[i-l[j]];
      }
      if (i > r[j]) {
        s[j] -= a[i-r[j]-1];
      }
      a[i] += s[j];
    }
  }

  cout << a[n-1] << endl;
}


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

int ds = 6;

void dprint( int a[] ){
	for( int i = 0; i < ds; i++ ) {
		cout << a[i] << ":";
	}
	cout << endl;

	return; 
}

void dbigsort( int a[], int i0, int i1, int i2, int i3 ) {
	int ta[] = { a[i0], a[i1], a[i2], a[i3] };
	int max = ta[0];
	for( int i = 0; i < 4; i++ ) {
		if( max < ta[i] ) {
			max = ta[i];
		}
	}

	int t = 0;
	while( true ) {
		if( a[i0] == max ) {
			break;
		}
		t = a[i0];a[i0]=a[i1];a[i1]=a[i2];a[i2]=a[i3];a[i3]=t;
	}

	return;
}

bool dcomp( int a[], int b[] )
{
	for( int i = 0; i < ds; i++ ) {
		if( a[i] != b[i] ) {
			return false;
		}
	}

	return true;
}

bool dcheck( int a[], int b[] ) {
	bool ret = false;
	ret = dcomp( a, b );
	return ret;
}

int main()
{
	int dx[ds], dy[ds];

	for( int i = 0; i < ds; i++ ) {
		cin >> dx[i];
	}
	dbigsort( dx, 0, 1, 5, 4 );
	dbigsort( dx, 0, 3, 5, 2 );
	dbigsort( dx, 1, 2, 4, 3 );

	for( int i = 0; i < ds; i++ ) {
		cin >> dy[i];
	}
	dbigsort( dy, 0, 1, 5, 4 );
	dbigsort( dy, 0, 3, 5, 2 );
	dbigsort( dy, 1, 2, 4, 3 );

	if( false ) {
		dprint( dx );
		dprint( dy );
	}

	bool ret = false;
	ret = dcheck( dx, dy );
	cout << ( ret?"Yes":"No" ) << endl;

	return 0;
}


Measured memory_bytes: 3128
#include<cstdio>
#include<cstdlib>
int main(void){
	long long a[2000];
	int n;
	long long dp[2000];
	long long dq[2000];
	int x,y;
	long long ans;
	for (int i = 0; i < 2000; i++){
		a[i] = 0;
		dp[i] = 0;
		dq[i] = 0;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	for (int i = 0; i < n; i++){
		if (i % 2 == 1){
			for (int j = 0; j < n; j++){
				x = (i + j) % n;
				y = (j + n - 1) % n;
				if (a[x] < a[y]){
					if (dq[y] < dp[j])dq[y] = dp[j];
				}
				else{
					if (dq[j] < dp[j])dq[j] = dp[j];
				}
			}
		}
		else{
			for (int j = 0; j < n; j++){
					x = (i + j) % n;
					y = (j + 1) % n;
					dq[j] = dp[j] + a[x];
					if (dq[j] < dp[y] + a[j])dq[j] = dp[y] + a[j];
				}
			}
		for (int j = 0; j < n; j++){
			dp[j] = dq[j];
			dq[j] = 0;
		}
		}
	ans = 0;
	for (int i = 0; i < n; i++){
		if (ans < dp[i])ans = dp[i];
	}
	printf("%lld\n", ans);

	return 0;
	}

Measured memory_bytes: 2700
x,y=map(int,input().split())

if (x==y==1):
  output=1000000
elif (x*y==2):
  output=500000
elif (x*y==3):
  output=400000
#elif (x*y==4):4*1が存在
elif (x==y==2):
  output=400000
elif (x*y==6):
  output=300000
elif (x*y==9):
  output=200000
  
#x or y  
elif (x==1 or y==1):
  output=300000
elif (x==2 or y==2):
  output=200000
elif (x==3 or y==3):
  output=100000
else:
  output=0
print(output)


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

int main(){
  int W,H,x,y,r;
  
  cin >> W >> H >> x >> y >> r ;
  
  if (x - r < 0 || x + r > W) {
    cout << "No" << endl;
  }
  else if (y - r < 0 || y + r > H) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

ll l, r;

int calc(ll x){
    int msb = -1;
    while((1LL << (msb + 1)) <= x) msb++;
    return msb;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> l >> r;
    if(l == r) finish(1);
    int msb = 60;
    while(((r >> msb) & 1) == ((l >> msb) & 1)){
        if((l >> msb) & 1) l ^= (1LL << msb);
        if((r >> msb) & 1) r ^= (1LL << msb);
        msb--;
    }
    ll m = (1LL << msb);
    ll ans = m - l;
    ll h = r - m;
    h = (1LL << (calc(h) + 1)) - 1;
    h = min(h, l - 1);
    ans += h + 1;
    ans += m - l;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cstring>
using namespace std;
bool m[27];
int main()
{
    int n;
    string s;
    string a, b;
    while(cin>>n){
        cin>>s;
        int sLen = s.length();
        int maxn = 0;
        for(int i = 1; i < sLen; i++){
            int cnt = 0;
            memset(m,0,sizeof(m));
            a = s.substr(0,i);
            b = s.substr(i,sLen - i);
            int aLen = a.length();
            int bLen = b.length();
            for(int j = 0; j < aLen; j ++){
                int index = a[j] - 'a';
                if(m[index] == 0){
                    m[index] = 1;
                    for(int k = 0;k < bLen; k ++){
                        if(b[k]==a[j]){
                            cnt++;
                            break;
                        }
                    }
                }
            }
        maxn = max(maxn,cnt);
        }
        cout<<maxn<<endl;

    }
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, m;
	int[] ss, ls, ps, ws;

	void run(){
		n=sc.nextInt();
		ss=new int[n];
		ls=new int[n];
		ps=new int[n];
		for(int i=0; i<n; i++){
			ss[i]=sc.nextInt();
			ls[i]=sc.nextInt();
			ps[i]=sc.nextInt();
		}
		m=sc.nextInt();
		ws=new int[m];
		for(int i=0; i<m; i++){
			ws[i]=sc.nextInt();
		}
		solve();
	}

	void solve(){
		int M=394;
		int[] dp=new int[M];
		fill(dp, -1);
		for(int j=0; j<n; j++){
			for(int i=ss[j]; i<=ls[j]; i++){
				dp[i]=max(dp[i], ps[j]);
			}
		}
		for(int j=0; j<M; j++){
			for(int i=0; j+i<M; i++){
				dp[j+i]=max(dp[j+i], dp[j]+dp[i]);
			}
		}
		StringBuilder sb=new StringBuilder();
		boolean ok=true;
		for(int i=0; i<m; i++){
			sb.append(dp[ws[i]]).append('\n');
			ok&=dp[ws[i]]>=0;
		}
		// debug(dp);
		if(!ok){
			sb=new StringBuilder("-1\n");
		}
		print(sb.toString());
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 24776
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
using namespace std;
// I hope you understand what i have coded :D , All the best
// shubhamk840@gmail.com
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define endl '\n'
#define stackofi stack<int>
#define queueofi queue<int>  
#define vectoriterator vector<int>::iterator
#define mapiterator map<int,int>::iterator
#define setiterator set<int>:: iterator
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define MOD 1000000007
// macros for inputting 1-D and 2-D array.
#define stringiterator string:: iterator
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ai(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define ao(arr) for(auto wtf:arr) cout<<wtf<<" ";
#define mi(arr,m,n) for(int i=0;i<m;i++){ for(int j=0;j<n;j++) cin>>arr[i][j];}
#define mo(arr,m,n) for(int i=0;i<m;i++){ for(int j=0;j<n;j++) cout<<arr[i][j]<<" "; cout<<endl;}
#define countsetbits(x) __builtin_popcount(x)
#define ll long long
#define debugger cout<<"I AM EXECUTING"<<endl
#define debug(x) cout<<#x<<"->"<<x<<endl;
#define F first
#define S second
#define testcases int asdf; cin>>asdf; while(asdf--)
#define space cout<<endl
#define vi vector<int>
#define si set<int>
#define vc vector<char>
#define sc set<char>
#define vll vector<long long int>
#define vs vector<string>
#define vpp vector<pair<int,int>> 
#define mp make_pair
string sconvert(int n)
{
	stringstream ss;
	ss<<n;
	string str = ss.str();
	return str;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second > b.second); 
}
template<typename KeyType, typename ValueType>  // for finding max element in the map.
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>; 
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  }); 
}

int add(int a, int b, int mod = MOD) {
    if (a + b >= mod) {
        return a + b - mod;
    }
    return a + b;
}
 
int sub(int a, int b, int mod = MOD) {
    if (a - b < 0) {
        return a - b + mod;
    }
    return a - b;
}
 
int mul(int a, int b, int mod = MOD) {
    return (int)(1ll * a * b % mod);
}


int  single()
{
	int x;
	cin>>x;
	int y;
	cin>>y;
	if((y-2*x)>=0 and (y-2*x)%2==0 and (x-(y-2*x)/2>=0))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}
void multiple()
{
	testcases
    {
		single();
	}
}

int main()
{
  IOS;
  single();
  
}















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

int main(){
    int A, B, C, X;
    int cnt = 0;
    cin >> A >> B >> C >> X;
    for (int i = 0; i <= A; i++){
        for (int j = 0; j <= B; j++){
            for (int k = 0; k <= C; k++){
                if (500 * i + 100 * j + 50 * k == X) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int sx, sy, tx, ty;;
	cin >>sx >>sy >>tx >>ty;
	string ans;
	
	char cc;
	cc = ty>sy? 'U': 'D';
	ans += string(abs(ty-sy), cc);
	cc = tx>sx? 'R': 'L';
	ans += string(abs(tx-sx), cc);
	cc = ty>sy? 'D': 'U';
	ans += string(abs(ty-sy), cc);
	cc = tx>sx? 'L': 'R';
	ans += string(abs(tx-sx)+1, cc);
	cc = ty>sy? 'U': 'D';
	ans += string(abs(ty-sy)+1, cc);
	cc = tx>sx? 'R': 'L';
	ans += string(abs(tx-sx)+1, cc);
	cc = ty>sy? 'D': 'U';
	ans += string(1, cc);
	cc = tx>sx? 'R': 'L';
	ans += string(1, cc);
	cc = ty>sy? 'D': 'U';
	ans += string(abs(ty-sy)+1, cc);
	cc = tx>sx? 'L': 'R';
	ans += string(abs(tx-sx)+1, cc);
	cc = ty>sy? 'U': 'D';
	ans += string(1, cc);


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl
 
#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
 
#define INF 1000000000000000000

ll n;
pair<pair<ll, ll>, pair<ll, ll> > p[1001];
ll dp[1001][10002];

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

    cin >> n;

    fr(i,1,n)   
    {
        ll w,s,v;
        cin >> w >> s >> v;

        p[i] = mp(mp(s+w,s),mp(w,v));
    }

    sort(p, p+n+1);

    fr(i,1,n)
    {
        fr(j,0,10001)
        {
            dp[i][j] = dp[i-1][j];
        }

        ll s = p[i].ff.ss;
        ll w = p[i].ss.ff;
        ll v = p[i].ss.ss;

        fr(j,0,s)
        {
            if(j+w>10000)
                dp[i][10001] = max(dp[i][10001], dp[i-1][j]+v);
            else
                dp[i][j+w] = max(dp[i][j+w], dp[i-1][j]+v);
        }
    }

    ll ans = 0;

    fr(i,0,10001)
    {
        ans = max(ans, dp[n][i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 78464
a  = int(input())

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

flg = True

for i in l:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            flg = False
            break

if flg:
    print("APPROVED")
else:
    print("DENIED")

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

using namespace std;

const int MAXN = 3005;

int dp[MAXN][MAXN];

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	string s, t;
	cin >> s >> t;
		
	int len_s = (int) s.size();
	int len_t = (int) t.size();
	
	memset(dp, 0, sizeof dp);

	for (int i = 1; i <= len_s; i++) {
		for (int j = 1; j <= len_t; j++) {
			if (s[i - 1] == t[j - 1])
				dp[i][j] = 1 + dp[i - 1][j - 1];
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	int i = len_s, j = len_t;
	string ans = "";

	while(i && j) {
		if (dp[i][j] == dp[i - 1][j])
			i--;
		else if (dp[i][j] == dp[i][j - 1])
			j--;
		else {
			ans += s[i - 1];
			i--, j--;
		}
	}
	
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
N=int(input())
x0,y0=0,0
t0=0
for n in range(N):
  t,x,y=map(int,input().split())
  if abs(x-x0)+abs(y-y0) > t-t0:
    print('No')
    exit(0)
  if (abs(x-x0)+abs(y-y0))%2 != (t-t0)%2:
    print('No')
    exit(0)
  t0,x0,y0=t,x,y
print('Yes')

Measured memory_bytes: 9072
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

ll v[22],c[22];

int main(void){
	int n,i;
	ll ans=0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> v[i];
	}
	for(i=0; i<n; ++i){
		cin >> c[i];
	}
	for(i=0; i<n; ++i){
		ans += max(v[i]-c[i],0ll);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n;
    cin >> n;
    vector<int> up(n);
    vector<int> middle(n);
    vector<int> bottom(n);

    rep(i, n) {
        cin >> up[i];
    }

    rep(i, n) {
        cin >> middle[i];
    }

    rep(i, n) {
        cin >> bottom[i];
    }

    sort(vec_all(up));
    sort(vec_all(middle));
    sort(vec_all(bottom));

    // 中段までの組み合わせで可能な数
    int b_i;
    b_i = 0;
    vector<int> middle_cnt(n, 0);
    rep(m_i, n) {
        // middle[m_i]より大きいindex探し
        while (middle[m_i] >= bottom[b_i]) {
            b_i++;
            if (b_i == n) {
                break;
            }
        }

        if (b_i == n) {
            break;
        }
        middle_cnt[m_i] = n - b_i;
    }

    // 逆累積和
    vector<ll> middle_cnt_a_sum(n, 0);
    middle_cnt_a_sum[n - 1] = middle_cnt[n - 1];
    reprev(i, n - 1) {
        middle_cnt_a_sum[i] = middle_cnt_a_sum[i + 1] + middle_cnt[i];
    }

    ll all_cnt = 0;
    int m_i = 0;
    rep(u_i, n) {
        // up[u_i] より大きいindex探し
        while (up[u_i] >= middle[m_i]) {
            m_i++;
            if (m_i == n) {
                break;
            }
        }

        if (m_i == n) {
            break;
        }

        all_cnt += middle_cnt_a_sum[m_i];
    }

    cout << all_cnt << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int sum=0;
		double count1=0;
		double count2=0;
		while(sc.hasNext()){
			String[] str=sc.next().split(",");
			count1++;
			count2+=Integer.parseInt(str[1]);
			sum+=(Integer.parseInt(str[0])*Integer.parseInt(str[1]));
		}
		System.out.println(sum);
		System.out.println(Math.round(count2/count1));
	}
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
int main(){
	char cc[110];
	int i,j,k,l;
	cin>>k;
	cin>>cc+1;
	l=strlen(cc+1);
	for(i=1;i<=l;i++){
		if(i<=k)cout<<cc[i];
		else{
			cout<<"...";break;
		}
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<int> vd;
int main(){
  int N,d;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>d;vd.push_back(d);
  }
  sort(vd.begin(),vd.end());
  //cout << vd[N/2-1] << " " << vd[N/2] << endl;
  cout << vd[N/2]-vd[N/2-1] << endl;
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    string S, T; cin >> S >> T;
    array<int, 26> init;
    fill(begin(init), end(init), -1);
    vector<array<int, 26>> next(S.size(), init);
    int N = S.size();
    for (int i = S.size() * 2 - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            if (next[(i+1)%N][j] != -1) {
                next[i%N][j] = next[(i+1)%N][j] + 1;
            }
        }
        next[i%N][S[(i+1)%N]-'a'] = 1;
    }
    Int curr = S.size()-1, ans = 0;
    for (int i = 0; i < T.size(); i++) {
        int t = next[curr][T[i] - 'a'];
        if (t < 0) {
            ans = -1;
            break;
        }
        ans += t;
        curr = (curr + t) % S.size();
    }
    cout << ans << '\n';
    return 0;
}

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

#define REP(i,a,b) for(int i=a,i##_end_=b;i<=i##_end_;++i)
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
typedef long long ll;

using namespace std;

void File(){
	freopen("ARC074E.in","r",stdin);
	freopen("ARC074E.out","w",stdout);
}

template<typename T>void read(T &_){
	T __=0,mul=1; char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')mul=-1;
		ch=getchar();
	}
	while(isdigit(ch))__=(__<<1)+(__<<3)+(ch^'0'),ch=getchar();
	_=__*mul;
}

const int maxn=310;
const ll mod=1e9+7;
int n,m;
vector<pii>qu[maxn];
ll dp[maxn][maxn][maxn],ans;

void init(){
	read(n); read(m);
	int l,r,x;
	REP(i,1,m){
		read(l); read(r); read(x);
		qu[r].push_back(mk(l,x));
	}
}

void work(){
	dp[0][0][0]=1;
	REP(i,0,n)REP(j,0,n)REP(k,0,n){
		if((i && i==j) || (j && j==k) || (k && i==k))continue;
		int nex=max(i,max(j,k))+1,r=nex-1;
		bool flag=true;
		REP(f,0,qu[r].size()-1){
			int l=qu[r][f].fi,x=qu[r][f].se,cnt=0;
			if(i && i>=l)++cnt;
			if(j && j>=l)++cnt;
			if(k && k>=l)++cnt;
			if(cnt!=x){
				flag=false;
				dp[i][j][k]=0;
				break;
			}
		}
		if(!flag)continue;
		(dp[nex][j][k]+=dp[i][j][k])%=mod;
		(dp[i][nex][k]+=dp[i][j][k])%=mod;
		(dp[i][j][nex]+=dp[i][j][k])%=mod;
		if(r==n)(ans+=dp[i][j][k])%=mod;
	}
	printf("%lld\n",ans);
}

int main(){
	//File();
	init();
	work();
	return 0;
}


Measured memory_bytes: 227584
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=100000+10;
const int maxm=1000+10;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const ll LINF=(1LL<<62);
const double PI=acos(-1.0);
#define mst(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for (int i=(a);i<b;i++)
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define lowbit(x) x&(-x)
#define X first
#define Y second
int d[20][20];
int main(){
#ifdef local
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    //ios::sync_with_stdio(false); cin.tie(0);
    int n,m; scanf("%d%d",&n,&m);
    rep(i,0,10) rep(j,0,10) scanf("%d",&d[i][j]);
    rep(k,0,10) rep(i,0,10) rep(j,0,10){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
    int ans=0;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            int x; scanf("%d",&x);
            if (~x) ans+=d[x][1];
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int a,v;
    int b,w;
    int t;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;

    int xmx = a + t*v;
    int xmn = a - t*v;
    int ymx = b + t*w;
    int ymn = b - t*w;

    if ( ( a < b && xmx >= ymx ) || (a > b && xmn <= ymn) ) {
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3660
#include <stdio.h>

int main(void)
{
	int a,b,c,i=0;

	scanf("%d%d%d",&a,&b,&c);
		
	for(a;a<=b;a++)
	{
		if(c%a==0)
			i++;
	}
	
	printf("%d\n",i);
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int H,W;
string s[1010];
int d[1010][1010];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	cin >> H >> W;
	queue<P> q;
	for(int i=0;i<H;i++){
		cin >> s[i];
		for(int j=0;j<W;j++){
			if(s[i][j]=='#'){
				q.push(P(i,j));
				d[i][j]=0;
			}else{
				d[i][j]=INF;
			}
		}
	}
	while(!q.empty()){
		P a = q.front();
		q.pop();
		int x = a.fi,y = a.sec;
		for(int i=0;i<4;i++){
			int nx = x+dx[i];
			int ny = y+dy[i];
			if(nx<0||nx>=H)continue;
			if(ny<0||ny>=W)continue;
			if(d[nx][ny]!=INF)continue;
			d[nx][ny]=d[x][y]+1;
			q.push(P(nx,ny));
		}
	}
	int ans = 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			ans = max(ans,d[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13456