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

using namespace std;

int main(){
    int n, ara[100003][3];

    cin >> n;

    for(int i = 1; i <= n; i++)cin >> ara[i][0] >> ara[i][1] >> ara[i][2];

    int dp[100005][3];

    dp[0][0] = dp[0][1] = dp[0][2] = 0;

    for(int i = 1; i <= n; i++){
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + ara[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + ara[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + ara[i][2];
    }


    cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;

    return 0;
}


Measured memory_bytes: 2560
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include<map>

using namespace std;


int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main(){
    int N;
    cin >> N ;
    vector<int> v(N);
    for(int i = 0; i < N; i++){
        cin >> v[i];
    }
    map<int,int> even,odd;
    for(int i = 0; i < N; i++){
        if(i%2==0)odd[v[i]]++;
        else even[v[i]]++;
    }
int even_1=0,even_2=0,odd_1=0,odd_2=0;
int e1=0,e2=0,o1=0,o2=0;
int cnt = 0;
for(auto itr = even.begin(); itr !=even.end(); ++itr){
    if(itr->second > cnt){
        cnt = itr->second;
        even_1 = itr->first;
    }
}
e1 = cnt;
cnt = 0;
for(auto itr = even.begin(); itr !=even.end();++itr){
    if(itr->second > cnt && itr->first!=even_1){
        cnt = itr->second;
        even_2 = itr->first;
    }
}
    e2 = cnt;
    cnt=0;
for(auto itr = odd.begin(); itr !=odd.end(); ++itr){
    if(itr->second > cnt){
        cnt = itr->second;
        odd_1 = itr->first;
    }
}
o1 = cnt;
cnt = 0;
for(auto itr = odd.begin(); itr !=odd.end();++itr){
    if(itr->second > cnt && itr->first!=odd_1){
        cnt = itr->second;
        odd_2 = itr->first;
    }
}
o2 = cnt;
if(even_1 == odd_1){
    cout << min(N-e1-o2,N-e2-o1) << endl;
}
else cout << N-e1-o1 << endl;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define MOD 998244353

int ar[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
signed main(){
	int k;
	cin>>k;
	cout<<ar[k-1];
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
typedef long long int ll;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};

int main(void)
{
	int n,p;scanf("%d %d",&n,&p);
	int a[60];
	while(n>0&&p>0){
		int now = p;
		int index =0;
		int i;
		for(i=0;i<n;i++)a[i]=0;
		while(1){
			if(now>0){
				a[index]++;
				now--;
				if(now==0){
					int abc=1;
					for(i=0;i<n;i++){
						if(i==index)continue;
						if(a[i]>0){
							abc=0;
							break;
						}
					}
					if(abc==1){
						printf("%d\n",index);
						break;
					}
				}
			}
			else{
				now=a[index];
				a[index]=0;
			}

			index++;
			if(index==n)index=0;
		}

		scanf("%d %d",&n,&p);
	}
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
 
int main () {
string S;
cin >> S ;
if ( S == "ARC") {
 cout << "ABC" << endl;
}
else {
  cout << "ARC" << endl;}

return 0;
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
        int r = in.nextInt();
        int c = in.nextInt();
        int sum = 0;
        int[][] sheet = new int[r][c]; 
        int[] sumofrow = new int[r];
        int[] sumofcolumn = new int[c];
        
        for (int i = 0; i < r; i++) {
          for (int j = 0; j < c; j++) {
            sheet[i][j] = in.nextInt();
            sum += sheet[i][j];
          }
        }
        
        for (int i = 0; i < r; i++) {
          for (int j = 0; j < c; j++) {
            sumofrow[i] += sheet[i][j];
            sumofcolumn[j] += sheet[i][j];
          }
        }
        
        for (int i = 0; i < r; i++) {
          for (int j = 0; j < c; j++) {
            out.print(sheet[i][j] + " ");
          }
          out.println(sumofrow[i]);
        }
        
        for (int i = 0; i < c; i++) {
          out.print(sumofcolumn[i] + " ");
        }
        
        out.println(sum);
        
//      End solve()
    }
//    End Solution
}

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }


  }

}

Measured memory_bytes: 29752
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

ll GCD(ll u, ll v) {
    while (v != 0) {
        ll r = u % v;
        u = v;
        v = r;
    }
    return u;
}

int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    auto n = GCD(a,b);
    vector<ll> z;
    for(int i=1 ; i<=n ; ++i){
        if(n%i==0) z.push_back(i);
    }
    // z.push_back(n);
    sort(alll(z));
    reverse(alll(z));
    pr(z[c-1]);
    // prr(z);
    
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 5100000;
const int mod = 1000000007;

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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    //エラトステネスの篩
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        //最小素因数がかかれるようにしている
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  //素因数列挙
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  //頻度を集計したもの
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      //小さい順に出てくるので前回と同じなら足す作業でmapが作れる
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};



int main(){
  //前処理
  Sieve sieve(1e6);
  //入力
  ll N;cin>>N;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];

  //最小公倍数を求める
  map<ll,ll> m;
  rep(i,N){
    auto f = sieve.factor(a[i]);
    for(auto p: f){
      m[p.first] = max(m[p.first], (ll)p.second);
    }
  }

  mint lcm = 1;
  for(auto p : m){
    rep(i,p.second){
      lcm *= p.first;
    }
  }

  mint ans = 0;

  rep(i,N){
    mint b = lcm/a[i];
    ans += b;
  }
  cout<<ans.x<<endl;

}


Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e+9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
int main() {
  int H,W;
  cin>>H>>W;
  vector<string> s(H);
  rep(i,H) cin>>s[i];
  int ans = 0;
  rep(si,H) rep(sj,W) {
    if (s[si][sj] == '#') continue;
    vector<vector<int>> dist(H, vector<int>(W, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i,j)); // .emplace(i,j)
    };
    update(si,sj,0);
    while(!q.empty()){
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(dir,4) {
        int ni = i + di[dir];
        int nj = j + dj[dir];
        if (ni<0 || ni>=H || nj<0 || nj>=W) continue;
        if (s[ni][nj] == '#') continue;
        update(ni,nj,dist[i][j]+1);
      }
    }
    rep(i,H)rep(j,W) {
      if (dist[i][j]==INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::string s;
	std::cin >> s;
	int n = (int) s.size() + 1;
	int on = 0;
	long long ans = 0;
	if(s[0] == '>') {
		int size = 0;
		char c = s[on];
		while(on < n-1 && s[on] == c) {
			size++;
			on++;
		}
		ans += (long long) size * (size + 1) / 2;
	}
	while(on < n-1) {
		int size = 0;
		while(on < n-1 && s[on] == '<') {
			size++;
			on++;
		}
		int size2 = 0;
		while(on < n-1 && s[on] == '>') {
			size2++;
			on++;
		}
		if(size2 <= size) {
			ans += (long long) size * (size + 1) / 2 + (long long) size2 * (size2 - 1) / 2;
		} else {
			std::swap(size2, size);
			ans += (long long) size * (size + 1) / 2 + (long long) size2 * (size2 - 1) / 2;
		}
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 1172
#include<cstdio>
const int mod=1000000007;
int N,A[610],c[610],f[610][310][310];
bool del[610];
int main(){
	scanf("%d",&N);
	for(int i=0;i<N*2;i++)scanf("%d",A+i),c[A[i]]++;
	int m=0;
	for(int i=0;i<N;i++){
		if(A[i*2]!=-1&&A[i*2+1]!=-1)del[A[i*2]]=del[A[i*2+1]]=1;
		if(A[i*2]==-1&&A[i*2+1]==-1)m++;
	}
	int s=0,t=0;
	f[N*2][0][0]=1;
	for(int i=N*2;i;i--){
		for(int j=0;j<=N;j++)
			for(int k=0;k<=N;k++)if(f[i][j][k]){
				if(del[i])f[i-1][j][k]=f[i][j][k];
				else{
					if(c[i])(f[i-1][j][k+1]+=f[i][j][k])%=mod;
					else(f[i-1][j+1][k]+=f[i][j][k])%=mod;
					if(c[i]){
						if(j)(f[i-1][j-1][k]+=f[i][j][k])%=mod;
					}
					else{
						if(k)f[i-1][j][k-1]=(f[i-1][j][k-1]+1ll*k*f[i][j][k])%mod;
						if(j&&m+s+(j-k-t)/2>0)f[i-1][j-1][k]=(f[i-1][j-1][k]+1ll*(m+s+(j-k-t)/2)*f[i][j][k])%mod;
					}
				}
			}
		if(!del[i])s+=c[i],t++;
	}
	printf("%d\n",f[0][0][0]);
}

Measured memory_bytes: 225408
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut x: Vec<(usize, i64)> = (0..n).map(|i| (i, read())).collect();

    x.sort_by_key(|&k| k.1);
    let candidate = [x[(n / 2) - 1].1, x[n / 2].1];
    for i in 0..n / 2 {
        x[i].1 = candidate[1];
    }
    for i in n / 2..n {
        x[i].1 = candidate[0];
    }
    x.sort_by_key(|&k| k.0);

    for x_i in x {
        println!("{}", x_i.1);
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end() 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    ll n;cin>>n;
    double a=1.08;
    ll ans=0;
    REP(i,1,n+1){

        if(floor(i*a)<=n&&floor(i*a)+1>n){
            ans=i;
        }
    }
    if(ans==0)cout<<":("<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    uint32_t H, W;   
    cin >> H >> W;

    if (H == 1 || W == 1)
        cout << 1 << endl;
    else
        cout << W * (uint64_t)(H / 2) + (H % 2) * ((uint64_t)((W + 1) / 2)) << endl;

    return 0;
}

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

typedef long long ll;
const int N = 1e5 + 5;
struct Edge {
    int v, nex;
}edges[N<<1];
int head[N];
int col[N];
int last[N];
vector<tuple<int, int, int> > vec;
int n, m, q, etot;

void init_graph() {
    memset(head, -1, sizeof(head));
    etot = 0;
}

void add_edge(int u, int v) {
    edges[etot] = Edge{v, head[u]};
    head[u] = etot++;
}

void paint(int u, int d, int c) {
    if (!col[u]) col[u] = c;
    if (last[u] >= d) return ;
    last[u] = d;
    if (!d) return ;
    for (int i=head[u]; ~i; i=edges[i].nex) {
        int v = edges[i].v;
        paint(v, d-1, c);
    }
}


int main() {
    scanf("%d%d", &n, &m);
    init_graph();
    for (int i=1; i<=m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        add_edge(u, v);
        add_edge(v, u);
    }
    scanf("%d", &q);
    for (int i=0; i<q; ++i) {
        int v, d, c;
        scanf("%d%d%d", &v, &d, &c);
        vec.push_back(make_tuple(v, d, c));
    }
    reverse(vec.begin(), vec.end());
    for (int i=0; i<q; ++i) {
        int v, d, c;
        tie(v, d, c) = vec[i];
        paint(v, d, c);
    }
    for (int i=1; i<=n; ++i) {
        printf("%d\n", col[i]);
    }
    return 0;
}


Measured memory_bytes: 4724
import sys
from collections import deque
import bisect
import math
import itertools
from queue import deque
from math import gcd

INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inp_list(): return list(map(int, sys.stdin.readline().split()))


def lcm(x, y): return (x * y) // gcd(x, y)


K = inp()
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[:K] + "...")


Measured memory_bytes: 9948
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, P;
  cin >> N >> P;
  bool flag=false;
  for(int i=0; i<N; i++){
    int A; cin >> A;
    if(A%2==1) flag=true;;
  }
  if(!flag){
    if(P==0) cout << (long long)pow(2,N) << endl;
    else cout << "0" << endl;
    return 0;
  }
  cout << (long long)pow(2, N-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,c[1000],s[1000],f[1000],ans[1000]={0};
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
    	cin>>c[i]>>s[i]>>f[i];
    }
    int waitime=0;
    for(int i=0;i<n-1;i++)
    {
    	int tt=s[i]+c[i];
    	for(int j=i+1;j<n-1;j++)
    	{
           if(tt<=s[j])
           {
           	tt+=s[j]-tt;
           }
           else
           {
           	if(tt%f[j])
           	tt+=f[j]-tt%f[j];	
           }
           tt+=c[j];
    	}
    	ans[i]=tt;
    }
    for(int i=0;i<n;i++)
    {
    	cout<<ans[i]<<endl;
    }
	return 0;
}

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

int main() {
    long long int a,b,c,k;
    long long int ans;
    cin >> a >> b >> c >> k;
    
    if(k % 2 == 0){
        ans = a-b;
    }else{
        ans = b-a;
    }
    
    if(ans > 1000000000000000000){
        cout << "Unfair";
    }else{
        cout << ans << endl;
    }
}

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

struct target {
  int target;
  int weight;
};

void bfs(int N, vector<target> *adjlist, int *color) {
  bool visited[N+1];
  queue<int> q;
  for (int i=1; i<N+1; i++) visited[i] = false;
  q.push(1);
  color[1] = 0;
  visited[1] = true;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (target t : adjlist[u]) {
      int v = t.target;
      int w = t.weight;
      if (!visited[v]) {
        q.push(v);
        visited[v] = true;
        if (w % 2 == 0){
          color[v] = color[u];
        } else {
          color[v] = (color[u] + 1) % 2;
        }
      }
    }
  }
}

int main() {
  int N;
  scanf("%d", &N);
  vector<target> adjlist[N+1];
  int color[N+1];
  int u, v, w;
  for (int i=0; i<N-1; i++){
    scanf("%d %d %d", &u, &v, &w);
    target t1 = {v, w};
    target t2 = {u, w};
    adjlist[u].push_back(t1);
    adjlist[v].push_back(t2);
  }
  bfs(N, adjlist, color);
  for (int i=1; i<N+1; i++) {
    printf("%d\n", color[i]);
  }
}


Measured memory_bytes: 6912
#include <stdio.h>

int main(void){
  int a,b,n,x,i;

  for(;;){
    i=0;
    scanf("%d%d",&n,&x);
    if(n+x == 0) break;

    for(a=1;a<=n;a++)
      for(b=a+1;b<=n;b++)
        if(b < x-a-b && x-a-b <= n)
          i++;

    printf("%d\n", i);
  }

  return 0;
}

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

int main()
{
    int n;
    int a[100]={0},b[100]={0};
    int sumPoint = 0;
    
    scanf("%d",&n);
    b[0] = 9999999;
    b[n] = 9999999;
    for(int i = 1; i < n; i++){
        scanf("%d ",&b[i]);
        // printf("%3d ",a[i]);
    }

    for(int i = 1; i <= n; i++){
        a[i] = (int)fmin(b[i-1],b[i]);
        sumPoint += a[i];
        // printf("%3d ",a[i]);
    }
    


    printf("%d",sumPoint);


}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const int mod = 1000000007;

int main(){
	ll r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
	 	x = r*x - d;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

typedef int Weight;
struct Edge{
    int from, to;
    Weight weight;
    int rev;     // 無向グラフの対の辺
    Edge(int from, int to, Weight weight) :
        from(from), to(to), weight(weight) { }
    Edge(int from, int to, Weight weight, int rev) :
        from(from), to(to), weight(weight), rev(rev){ }
};
bool operator < (const Edge &a, const Edge &b){
    if(a.weight != b.weight) return a.weight > b.weight;
    if(a.from != b.from) return a.from > b.from;
    return  a.to > b.to;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void addFlowEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, 0, g[a].size() - 1));
}
void addUndirectedEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, c, g[a].size() - 1));
}

vector<int> func(Graph &g, int v, int c, vector<int> &color) {
	color[v] = c;
	vector<int> res(2);
	res[c] = 1;
	for(auto e: g[v]) {
		if(color[e.to] == c) {
			return vector<int>();
		}
		if(color[e.to] >= 0) {
			continue;
		}
		vector<int> q = func(g, e.to, (c + 1) % 2, color);
		if(q.size() == 0) {
			return vector<int>();
		}
		res[0] += q[0];
		res[1] += q[1];
	}

	return res;
}

signed main(){
	int N, M;
	cin >> N >> M;

	vector<vector<int>> d(N, vector<int>(N, 0));
	for(int i = 0; i < M; ++i) {
		int A, B;
		cin >> A >> B;
		--A; --B;
		d[A][B] = d[B][A] = 1;
	}
	Graph g(N);
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < N; ++j) {
			if(d[i][j] == 0 && i != j) {
				g[i].push_back(Edge(i, j, 0));
			}
		}
	}

	vector<int> vst(N, -1);
	vector<vector<int>> w;
	for (int i = 0; i < N; ++i) if(vst[i] < 0) {
		vector<int> p = func(g, i, 0, vst);
		if (p.size() == 0) {
			cout << -1 << endl;
			return 0;
		}
		sort(ALL(p));
		w.push_back(p);
	}
	vector<vector<int>> dp(w.size() + 1, vector<int>(N + 1));
	dp[0][0] = 1;
	for(int i = 0; i < w.size(); ++i) {
		for(int j = 0; j <= N; ++j) {
			for(int k = 0; k < 2; ++k) {
				if(j - w[i][k] >= 0) {
					dp[i + 1][j] = dp[i + 1][j] || dp[i][j - w[i][k]];
				}
			}
		}
	}
	for(int i = N / 2; i >= 0; --i) {
		if(dp[w.size()][i]) {
			int b = N - i;
			cout << i * (i - 1) / 2 + b * (b - 1) / 2 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 22272
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
    vector<double> v(n);
    for(auto &i : v) cin >> i;
    sort(v.begin(),v.end());

    double ans=v[0];
    for(int i=1; i<n; ++i){
        ans = (ans+v[i])/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){

  int i,j,n = 0,count;
  int A[100];

  scanf("%d",&n);

  for(i = 0; i < n;i++){
    scanf("%d",&A[i]);
  }

  count = selectionSort(A,n);

  for(j = 0; j< n;j++){
    printf("%d",A[j]);
    if(j != n-1) printf(" ");

  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

int selectionSort(int A[],int N){
  int i,j,minj= 0,temp = 0,count=0;
  for(i =0; i < N;i++){
    minj = i;
    for(j =i;j < N; j++){
      if(A[j] < A[minj]) minj=j;
    }
    temp = A[i];
    A[i] = A[minj];
    A[minj] = temp;
    if(A[i]!=A[minj]){
      count++;
    }
  }
  return count;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mod 1e9+7
using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll a[n+1];
  
  for(ll i=1;i<n;i++)
  {
      cin>>a[i];
  }
  
  vector<ll>v(n+1,0);
  
  for(ll i=1;i<n;i++)
  {
      v[a[i]]++;
  }
  
  for(ll i=1;i<=n;i++)
  {
      cout<<v[i]<<endl;
  }
   
    return 0;
}


Measured memory_bytes: 6428
#include<stdio.h>
#include<string.h>

typedef struct D
{
	int n,r,l,d,p,dep,h,sub,deg;
}D;

D node[30];
int i,j,N,r,l,n;

int dfs(int p,int d)
{
	int a,b;
	if(p==-1)return -1;
	node[p].dep=d;
	a=dfs(node[p].r,d+1);
	b=dfs(node[p].l,d+1);
	if(a==-1&&b==-1)
		node[p].h=0;
	else
		node[p].h=(a>b?a:b)+1;
	return node[p].h;
}

int main()
{
	memset(node,-1,sizeof(node));
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d%d",&n,&l,&r);
		node[n].l=l;
		node[n].r=r;
		node[n].deg=(r!=-1)+(l!=-1);
		node[l].sub=r;
		node[r].sub=l;
		if(l!=-1)node[l].p=n;
		if(r!=-1)node[r].p=n;
	}
	for(i=0;i<N;i++)
		if(node[i].p==-1)
			dfs(i,0);

	for(i=0;i<N;i++)
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
		i,node[i].p,node[i].sub,node[i].deg,node[i].dep,node[i].h,node[i].p==-1?"root":node[i].l==-1&&node[i].r==-1?"leaf":"internal node");
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
int main() {
    string x;
    cin >> x;
    int max = 0;
    int temp = 0;
    char c;
    for(int i = 0; i < x.size(); i++){
        c = x[i];
        if(c =='A' || c=='C'||c=='G'||c=='T')
            temp++;
        else
            temp = 0;
        if (temp > max)
            max = temp;
    }
    cout << max;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"

ll a[200010], b[200010];
int main()
{
    ll n,m,k;
    cin>>n>>m>>k;

    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
        if(i) a[i]+=a[i-1];
    }
    for(int i=0; i<m; i++)
    {
        scanf("%lld",&b[i]);
        if(i) b[i]+=b[i-1];
    }
    ll ans=upper_bound(b,b+m,k)-b;
     for(ll i=0; i<n; i++)
     {
         if(k>=a[i])
         ans=max( ans, (upper_bound(b, b+m, k-a[i])-b)+i+1 );
     }

     cout<<ans<<endl;

}


Measured memory_bytes: 6876
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
using namespace std;
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout<<endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
int n;
int sum = 0;
vector<int>g[114514];
priority_queue<int>cnt;
queue<int>que;
int ans[114514];
signed main() {
	cin >> n;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rep(i, n) {
		int c;
		cin >> c;
		cnt.push(c);
		sum += c;
	}
	cout << sum - cnt.top() << endl;
	que.push(0);
	rep(i, n) ans[i] = inf;
	while (!que.empty()) {
		int p = que.front(); 
		que.pop();
		ans[p] = cnt.top();
		cnt.pop();
		rep(i, g[p].size()) {
			int np = g[p][i];
			if (ans[np] == inf) {
				que.push(np);
			}
		}
	}
	rep(i, n) cout << ans[i] << " ";
}

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


int main(void) {

	int A, B;


	scanf("%d %d", &A, &B);

	
	if (A <= 5) {
		printf("0\n");
	}
	else if (A <= 12) {
		printf("%d\n", B / 2);
	}
	else {
		printf("%d\n", B);
	}

	return 0;
}

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

void search(vector<vector<int>> &perms, vector<int> &perm, int n, int k, int r, int s)
{
    if (r == 0)
    {
        vector<int> tmp;
        for (int i:perm) tmp.push_back(i);
        perms.push_back(tmp);
        return;
    }
    else
    {
        for (int i = s; i < n - r + 2; i++) 
        {
            perm[k - r] = i;
            search(perms, perm, n, k, r-1, i+1);
        }
    }
}

int main(void)
{
    int n, m, q; cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for (int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<vector<int>> perms;
    vector<int> perm(n);
    search(perms, perm, n + m - 2, n, n, 0);
    int ans = 0;
    int tmp, diff;
    for (auto p:perms)
    {
        tmp = 0;
        for (int i = 0; i < q; i++)
        {
            diff = (p[b[i]-1] - (b[i] - 1)) - (p[a[i]-1] - (a[i] - 1));
            if (diff == c[i]) tmp += d[i];
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9772
s = input().split()
n=int(s[0])
s = input().split()
flag=0
for i in reversed(range(n-1)):
        if int(s[i])>int(s[i+1])+1:
                print('No')
                flag=1
                break
        if int(s[i])-int(s[i+1])==1:
                s[i]=int(s[i])-1
if flag<1:
        print('Yes')

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll A;
  scanf("%lld",&A);
  ll B;
  scanf("%lld",&B);
  cout << max({A+B, A-B, A*B}) << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>

int main() {
  int N;
  scanf("%d", &N);

  std::vector<int> a(N);
  for (int i=0; i<N; ++i) {
    scanf("%d", &a[i]);
    --a[i];
  }

  int cur=0;
  for (int i=1; i<=N; ++i)
    if ((cur = a[cur]) == 1)
      return !printf("%d\n", i);

  printf("-1\n");
  return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val valueList = readLine()!!.split(" ").map { it.toInt() }
    val cList = readLine()!!.split(" ").map { it.toInt() }

    val profits = valueList
        .mapIndexed { index, i -> i - cList[index] }
        .filter { i -> i > 0 }
        .sum()

    println(profits)
}


Measured memory_bytes: 36028
n, k = map(int, input().split())

treat_array = [0]*n
for i in range(k):
    d = int(input())
    for j in map(int, input().split()):
        treat_array[j-1] += 1

ans = 0
for i in range(n):
    if treat_array[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9104
#include<stdio.h>
int main(void)
{
    long int n,m,i,j,s=0;
    scanf("%ld",&n);
    m=n;
    while(m/10!=0){
        j=m%10;
        s+=j;
        m=(m-j)/10;
    }
    s+=m;
    if(n%s==0)
        printf("Yes\n");
    else 
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
// AOJ 0135 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135)
#include<cstdio>
#include<cmath>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

int h;

int main()
{
	scanf( "%d", &h );
	rep( i, h )
	{
		int hh, mm;
		scanf( "%d:%d", &hh, &mm );

		double diff = fabs(hh*30+mm/2.0-mm*6);
		diff = std::min( diff, 360-diff );

		puts( diff<30?"alert":diff<90?"warning":"safe" );
	}

	return 0;
}

Measured memory_bytes: 1008
package main

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

func sum(ws []int) int {
	s := 0
	for _, e := range ws {
		s += e
	}
	return s
}

func isOk(p, k int, ws []int) bool {
	remain := p
	for _, e := range ws {
		if e > p {
			return false
		}
		if remain >= e {
			remain -= e
		} else {
			if k <= 1 {
				// 最後の1台だった
				return false
			}
			k--
			remain = p
			remain -= e
		}
	}
	return true
}

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	k := eGetInt(scanner)
	ws := make([]int, n)
	for i := 0; i < n; i++ {
		ws[i] = eGetInt(scanner)
	}
	max := sum(ws)
	left := 0
	right := max
	for right-left > 1 {
		mid := (left + right) / 2
		if isOk(mid, k, ws) {
			right = mid
		} else {
			left = mid
		}
	}
	fmt.Println(right)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}



Measured memory_bytes: 2368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int a, b, k;
    int cnt = 0;

    cin >> a >> b >> k;

    for (int i = 100; i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            cnt++;
        }
        if (cnt == k) {
            cout << i << endl;
            return (0);
        }
    }
}


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

int main(void)
{
  int a, b;
  cin >> a;
  cin >> b;
  if (a < b)
  {
    cout << "a < b" << endl;
  }
  else if (a > b)
  {
    cout << "a > b" << endl;
  }
  else
  {
    cout << "a == b" << endl;
  }

  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define mdsaqib std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

signed main(){
    mdsaqib;
    int n;
    cin >> n;
    std::vector<int> A(n);
    for(int i=0;i<n;i++)cin >> A[i];
    int mx=A[0];
    int ans=0;
    for(int i=1;i<n;i++){
        if(A[i]>mx)mx=A[i];
        else ans+=mx-A[i];
    }
    cout << ans;
}

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

int main(){//A
/*
    string s;
    cin>>s;
    cout<<s.substr(0,3)<<endl;
    */
   //B
   ll a,v,b,w,t;
   cin>>a>>v;
   cin>>b>>w;
   cin>>t;
   if(a<b){
       if(a+v*t>=b+w*t) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
   }
   else if(a>b){
       if(a-v*t<=b-w*t) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
   }
   else cout<<"YES"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
#define rep1(i,n) for(int i = 1 ; i <= n ; ++i)
using namespace std;
typedef long long ll;
const int NMAX = 300010;
/***************RMQ(Range Minimum Query)************/
class RMQ{
public:
  ll dat[NMAX*2-1];
  int nn;
  RMQ(int n_);
  void update(int k,ll a);
  ll query(int a,int b,int k,int l,int r);
};
RMQ::RMQ(int n_){
  nn=1;
  while(nn<n_) nn*=2;
  for(int i = 0 ; i < 2*nn-1 ; ++i){
    dat[i]=0; 
  }
}
void RMQ::update(int k,ll a){
  k+=nn-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=max(dat[2*k+1],dat[2*k+2]);
  }
}
ll RMQ::query(int a,int b,int k,int l,int r) {
  if(r<=a||b<=l) return 0;
  if(a<=l&&r<=b) return dat[k];
  else{
    ll v1=query(a,b,2*k+1,l,(l+r)/2);
    ll v2=query(a,b,2*k+2,(l+r)/2,r);
    return max(v1,v2);
  }
}
/********************************************************/
int n;
int h[200010];
ll A[200010];
ll dp[200010];

int main()
{
  cin >> n;
  rep(i,n) cin >> h[i];
  rep(i,n) cin >> A[i];
  
  RMQ r(n+1);
  rep(i,n){
    ll hight = r.query(0,h[i]+1,0,0,r.nn);
    r.update(h[i],dp[h[i]] = hight + A[i]);
    //    rep(i,32) cout << r.dat[i] << " ";
    //    cout  << "\n";
    //    rep(i,n+1) cout << dp[i] << " ";
    //    cout  << "\n";
  }
  
  ll res = r.query(0,n+1,0,0,n+1);
  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 8832
def calc_score(list):
    list.remove(max(list))
    list.remove(min(list))
    return int(sum(list) / len(list))

while True:
  grader = int(input())
  if grader == 0:
      break
  scores = [int(input()) for _ in range(grader)]
  print(calc_score(scores))



Measured memory_bytes: 5600
N=int(input())
T,A=[list(map(int,input().split())) for i in range(2)]
tp,ap=0,A[0]
f=0
r=1
mod=10**9+7
x=0
if T[-1]!=A[0]:
    f=-1
for t,a in zip(T,A):
    if f==-1:
        break
    if f==0:
        if t==tp and a==ap:
            r=(r*t)%mod
        elif t==a==ap:
            f=1
        elif not (t>tp and a==ap):
            f=-1
    elif f==1:
        if t==a==ap:
            x+=1
        elif t==tp and a<ap:
            for j in range(x-1):
                r=(r*t)%mod
            f=2
        else:
            f=-1
    elif f==2:
        if t==tp and a==ap:
            r=(r*a)%mod
        elif not (t==tp and a<ap):
            f=-1
    tp,ap=t,a
if f==1:
    for j in range(x-1):
        r=(r*t)%mod
print(0 if f<1 else r)

Measured memory_bytes: 18752
def rec(n, s, v):
    # 9までor目標の値が対象の数値でうわまらない場合
    if v == 10 or v > s:
        return 0
    # 一致ケース
    if n == 1:
        if(s < 10):
            return 1
        else:
            return 0
    sum = 0
    for i in range(v, 10):
	    sum += rec(n - 1,s - i,i + 1)
    return sum

while True:
    n, s = (int(x) for x in input().split())
    if n == 0 and s == 0:
        break
    print(rec(n, s, 0))


Measured memory_bytes: 5596
N=int(input())

if N<=111:
    print(111)
elif N<=222:
    print(222)
elif N<=333:
    print(333)
elif N<=444:
    print(444)
elif N<=555:
    print(555)
elif N<=666:
    print(666)
elif N<=777:
    print(777)
elif N<=888:
    print(888)
elif N<=999:
    print(999)


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

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

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int L = C * D / gcd(C, D);
    int ans = B - A + 1;
    ans -= B / C - (A - 1) / C;
    ans -= B / D - (A - 1) / D;
    ans += B / L - (A - 1) / L;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    int mx = 0;
    int k;
    cin >> k;
    int temp;
    int cnt= 0;
    for(int i = 1; i < n; ++i)
    {
        temp = k;
        cin >> k;
        if(temp >= k)
        {
            ++cnt;
            mx = max(mx , cnt);
        }
        else
        {
            cnt = 0;
        }
    }
    cout << mx ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <limits>
//auto std::numeric_limits<float>::infinity() { return __builtin_huge_valf(); }
using namespace std;

int main()
{
    //A
    /*
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
        */
    //B

    long long N, A, B, C;
    cin >> N >> A >> B;
    /*/
    if (N <= A)
        cout << N << endl;
    else if (A == 0)
        cout << 0 << endl;
    else
    {*/
    C = N % (A + B);
    cout << N / (A + B) * A + min(C, A);
    // }

    //C
    /*
    int A, B;
    cin >> A >> B;
    float c;
    c = A / 0.08;
    if ((int)(10 * c) % 10 == 0)
    {
        if (floor(c * 0.1) == B)
        {
            cout << (int)c << endl;
        }
        else
            cout << -1 << endl;
    }
    else
    {
        if (floor((c + 1) * 0.1) == B)
            cout << (int)c << endl;
        else
            cout << -1 << endl;
    }
    */
    //Cやり直し
    /*
    int A, B;
    cin >> A >> B;
    for (int i = 1; i <= 1009; i++)
    {
        if (int(i * 0.08) == A && int(i * 0.1) == B)//intの対象を()でくくるように
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    */
}


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

import itertools

N = int(input())
name_dict = {"M":0, "A":0, "R":0, "C":0, "H":0}

# 各イニシャル毎に集計
for i in range(N):
    name_str = input()
    if name_str[0] == "M":
        name_dict["M"] += 1
    if name_str[0] == "A":
        name_dict["A"] += 1
    if name_str[0] == "R":
        name_dict["R"] += 1
    if name_str[0] == "C":
        name_dict["C"] += 1
    if name_str[0] == "H":
        name_dict["H"] += 1

# MARCHから3文字を選ぶ組み合わせ
cmb_list = list(itertools.combinations(["M","A","R","C","H"], 3))

ans = 0
for cmb in cmb_list:
    # 各イニシャルの人数毎に掛け合わせて合計していく
    ans += name_dict[cmb[0]] * name_dict[cmb[1]] * name_dict[cmb[2]]
    
print(ans)

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

int main()
{
  int K;
  string S;
  cin >> K;
  cin >> S;

  if (S.length() <= K)
  {
    cout << S << endl;
  }
  else
  {
    string s = S.substr(0, K) + "...";
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
n = int(input())
a,b,c = map(int,input().split())
dp = [0,0,0] * n
dp[0] = [a,b,c]
for i in range(1,n):
    a,b,c = map(int,input().split())
    dp[i] = [max(dp[i-1][1],dp[i-1][2])+a,max(dp[i-1][0],dp[i-1][2])+b,max(dp[i-1][0],dp[i-1][1])+c]

print(max(dp[n-1]))

Measured memory_bytes: 24332
package main

import (
	"fmt"
	"sort"
)

func getReverse(s string) (t string) {
	for _, r := range s {
		t = string(r) + t
	}
	return t
}

func getSorted(s string) (t string) {
	ss := make([]string, len(s))
	for i, r := range s {
		ss[i] = string(r)
	}
	sort.Strings(ss)
	for i := 0; i < len(s); i++ {
		t += ss[i]
	}
	return
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	if getSorted(s) < getReverse(getSorted(t)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

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


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	ll N, A, B, C;
	cin >> N >> A >> B >> C;
	ll L[N];
	rep(i, N)cin >> L[i];
	sort(L, L+N);
	ll M = 1 << 2*N;
	ll ans = 1ll<<60;
	rep(i, M){
		ll a = 0;
		ll nABC[3]={};
		ll abc[3]={};
		rep(j, N){
			ll k = i >> j*2 & 3;
			if (k != 3){
				nABC[k]++;
				abc[k]+=L[j];
			}
		}
		if (nABC[0]==0 || nABC[1]==0 || nABC[2]==0)continue;
		a += abs(A-abc[0]) + abs(B-abc[1]) + abs(C-abc[2]);
		rep(j, 3)a += 10 * max(0ll, nABC[j]-1);
		chmin(ans, a);
	}
	cout << ans << endl;

}








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

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }
        

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var a = Console.ReadLine().ToCharArray();
            var b = Console.ReadLine().ToCharArray();
            var c = Console.ReadLine().ToCharArray();
            var flag = 'a';
            var i = 0;
            var j = 0;
            var k = 0;
            var anwer = 's';
            while (true)
            {
                if (flag=='a')
                {
                    if (i == a.Length)
                    {
                        anwer = 'a';
                        break;
                    }
                    if (a[i] == 'a') flag = 'a';
                    else if (a[i] == 'b') flag = 'b';
                    else if (a[i] == 'c') flag = 'c';
                   
                    i++;
                }
                else if (flag == 'b')
                {
                    if (j == b.Length)
                    {
                        anwer = 'b';
                        break;
                    }
                    if (b[j] == 'a') flag = 'a';
                    else if (b[j] == 'b') flag = 'b';
                    else if (b[j] == 'c') flag = 'c';
                    j++;
                }
                else if (flag == 'c')
                {
                    if (k == c.Length)
                    {
                        anwer = 'c';
                        break;
                    }
                    if (c[k] == 'a') flag = 'a';
                    else if (c[k] == 'b') flag = 'b';
                    else if (c[k] == 'c') flag = 'c';
                    k++;
                }
            }

            if (anwer == 'a') Console.WriteLine("A");
            if (anwer == 'b') Console.WriteLine("B");
            if (anwer == 'c') Console.WriteLine("C");

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 13140
x,y=map(int,input().split())
k=(y-2*x)//2
t=(-y+4*x)//2
if t>=0 and t//2<=x and k>=0 and k<=x and (-y+4*x)%2==0 and (y-2*x)%2==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9184