akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int64_t a){if(a<=1)return false;for(int64_t i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }


// r->s->p->r
// r->p->s->r

int	rsp(char c)
{
	if (c == 's')
		return (0);
	if (c == 'p')
		return (1);
	return (2);
}

int main()
{
	int n, k, ans = 0;
	vector<int> rsp_v(3);
	string t;
	char c;
	bool flag;

	cin >> n >> k >> rsp_v[0] >> rsp_v[1] >> rsp_v[2] >> t;
	for (int i = 0; i < k; i++)
	{
		flag = false;
		ans += rsp_v[rsp(t[i])];
		// cout << rsp_v[rsp(t[i])] << " ";
		c = t[i];
		for (int j = 1; j < n / k; j++)
		{
			char temp = t[i + j * k];
			if (flag || c != temp)
			{
				flag = false;
				ans += rsp_v[rsp(temp)];
				// cout << rsp_v[rsp(temp)] << " ";
			}
			else
				flag = true;
			c = temp;
		}
		if (i < n % k)
		{
			char temp = t[i + (n / k) * k];
			if (flag || c != temp)
			{
				flag = false;
				ans += rsp_v[rsp(temp)];
				// cout << rsp_v[rsp(temp)] << ":" << i << " ";
			}
			else
				flag = true;
			c = temp;
		}
	}
	// cout << endl;
	cout << ans << endl;
}

// 6 8 8 7 6

Measured memory_bytes: 3864
n, k, s = map(int, input().split())
a = []
for i in range(k):
    a.append(s)
for i in range(n - k):
    if s == 1:
        a.append(2)
    else:
        a.append(s - 1)
for i in a:
    print(i, end = " ")

Measured memory_bytes: 8092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000

int main()
{

    ll n;
    cin >> n;
    ll s = 0;
    repp(i, n) {
        if (i % 3 != 0 && i % 5 != 0) {
            s += i;
        }
    }
    cout << s << endl;
    return 0;
}

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

int main() {
    map<ll,ll> mp;
    ll N, MOD;
    cin >> N >> MOD;
    ll sum[N+1];
    sum[0] =0;
    mp[0]++;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        sum[i+1] = sum[i] + a;
        sum[i+1] %=MOD;
        mp[sum[i+1]]++;
    }
    ll ans =0;
    for(auto itr = mp.begin();itr != mp.end();++itr){
        ll n = itr->second;
        ans += (n*(n-1))/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
using namespace std;
 
int main() 
{
   int n,count=0,val,ans,temp;
   cin>>n;
   temp=n;
   
   while(n)
   {
       n/=10;
       count++;
   }
   
   val=pow(10,count-1);
   
   if(count==1)
   {
       ans=temp;
   }
   
   else if(count==2)
   {
       ans=9;
   }
   
   else if(count==3)
   {
       ans=(temp-val+1)+9;
   }
   
   else if(count==4)
   {
       ans=909;
   }
   
   else if(count==5)
   {
       ans=(temp-val+1)+909;
   }
   
   else
   {
       ans=90909;
   }
   
   cout<<ans;
}

Measured memory_bytes: 384
use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let s: Vec<String> = sc.vec(n);
    let mut st: BTreeSet<String> = BTreeSet::new();
    for e in s.iter() {
        st.insert(e.clone());
    }
    println!("{}", st.len());
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

int main(){
  int A,B;
  cin>>A>>B;
  if(A<=5){
    cout<<0<<endl;
  }
  else if(A<=12){
    cout<<B/2<<endl;
  }
  else{
    cout<<B<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;
 
int main(){
	int q=1;
	//cin>>q;
 
	while(q--){
		int n,m;
		cin>>n>>m;
		vi a(n);
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			ans+=a[i];
		}
 
		sort(a.begin(), a.end());
		int b=1;

		for(int i=n-1;i>=n-m;i--){
			if(a[i]<ans/(float)(4*m)){
				b=0;
				break;
			}
		}
 
		if(b)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
}

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


int main(){//main_program
  int a,b,c;
  string N;
  char num;
  vector<char> m = {'0','1','2','3','4','5','6','7','8','9'};
  cin >> N;
  a = N.size();
  num = N.at(a-1);
  
  if(m.at(2) == num || m.at(4) == num || m.at(5) == num || m.at(7) == num || m.at(9) == num ){
    cout << "hon" << endl;
  }else{
    if( m.at(3) == num ){
      cout << "bon" << endl;
    }else{
      cout << "pon" << endl;
    }
  }
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn = 105;

int h,w,n;
int b[maxn][maxn],a[100005];

int main() {
    //freopen("in.cpp","r",stdin);
    cin>>h>>w>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    int d=1,x=0,y=0,cur=0;
    while(x<h){
      b[x][y]=cur+1;
      a[cur]--;
      if(a[cur]==0)cur++;
      y+=d;
      if(y==w){
        x++,y=w-1;
        d=-1;
      } else if(y==-1){
        x++,y=0;
        d=1;
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++) {
        printf("%d%c",b[i][j],j==w-1?'\n':' ');
      }
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
ll a[100001];
ll t[100001]={};
ll c=0,c2=0;
ll t2[100001]={},t3[100001]={};
int main(){

	int n;
	cin>>n;
	rep(i,n){
		cin>>a[i+1];
		t[i+1]=t[i]+a[i+1];
		t2[i+1]=t2[i]+a[i+1];
		t3[i+1]=t3[i]+a[i+1];
		if(i%2==0&&t2[i+1]<=0){
			c=c-t2[i+1]+1;
			t2[i+1]=1;
		}
		if(i%2>0&&t2[i+1]>=0){
			c+=t2[i+1]+1;
			t2[i+1]=-1;
		}
		if(i%2==0&&t3[i+1]>=0){
			c2+=t3[i+1]+1;
			t3[i+1]=-1;
		}
		if(i%2>0&&t3[i+1]<=0){
			c2-=t3[i+1]-1;
			t3[i+1]=1;
		}
	}
	cout<<min(c,c2)<<endl;

	return 0;

}




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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) {
    cin >> a[i];
    --a[i];
  }
  sort(a.begin(), a.end(), greater<int>() );
  int num[] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
  int dp[n+1] = {};

  for (int i = 1; i <= n; ++i) {
    int max = -Inf;
    for (int j = 0; j < m; ++j) {
      if (i - num[a[j]] < 0) continue;
      int tmp = dp[i - num[a[j]] ] + 1;
      if (tmp > max) {
        max = tmp;
      }
    }
    dp[i] = max;
  }

  int res = n;
  for (int i = 0; i < dp[n]; ++i) {
    for (int j = 0; j < m; ++j) {
      if (res - num[a[j]] < 0) continue;
      if (dp[res - num[a[j]] ] == dp[res] - 1) {
        res -= num[a[j]];
        printf("%d", a[j] + 1);
        break;
      }
    }
  }
  return 0;
}

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

struct UnionFind{
	vector<int> rnk,par,num;
	UnionFind(int N) : rnk(N),par(N),num(N){
		init();
	}
	void init(){
		for(int i = 0;i < rnk.size();i++){
			rnk[i] = 0;
			par[i] = i;
			num[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rnk[x] < rnk[y]){
			par[x] = y;
			num[y] += num[x];
		}
		else{
			par[y] = x;
			num[x] += num[y];
			if(rnk[x] == rnk[y]) rnk[x]++;
		}
	}
	bool same(int x,int y){
		return (find(x) == find(y));
	}
	int size(int x){
		return num[find(x)];
	}
};

signed main(){
  int N, M; cin >> N >> M;
  vector<int> a(M), b(M);
  for(int i = 0; i < M; i++) cin >> a[i] >> b[i];
  int ans = 0;
  for(int i = 0; i < M; i++){
    UnionFind tree(N);
    for(int j = 0; j < M; j++){
      if(i == j) continue;
      tree.unite(a[j] - 1, b[j] - 1);
    }
    if(!tree.same(a[i] - 1, b[i] - 1)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int a,b;
    string s,t,u;
    cin>>s>>t>>a>>b>>u;
    if(u==s){
        cout<<a-1<<" "<<b<<endl;
    }
    else{
        cout<<a<<" "<<b-1<<endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	public void run() {
		while (true) {
			int N = in.nextInt(), A = in.nextInt(), B = in.nextInt(), C = in.nextInt(), X = in.nextInt();
			if (N == 0) break;
			
			int[] Y = new int[N];
			
			for (int i = 0; i < Y.length; i++) {
				Y[i] = in.nextInt();
			}
			
			int idx = X == Y[0] ? 1 : 0;
			int value = X;
			int res = 0;
			while (res <= 10000 && idx != N) {
				int next = (A * value + B) % C;
				if (next == Y[idx]) idx++;
				value = next;
				res++;
			}
			
			System.out.println(res <= 10000 ? res : "-1");
		}
		out.close();
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 24544
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
long long modpow(long long a, long long n, long long mod=(1LL<<62)){
	long long res = 1;
	while (n > 0){
		if (n & 1)
		res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main(){
	int n;
	int ans = INF;
	cin >>n;
	Vi a(n);
	input(a);
	sort(all(a));
	int cnt = 0;
	for (int i = a[0]; i <= a[n - 1]; i++) {
		cnt = 0;
		rep(j, n) { cnt += modpow(i - a[j], 2); }
		chmin(ans, cnt);
	}
	cout << ans << endl;
}

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

int gcd( int x, int y )
{
    return (x % y)? gcd(y, x % y): y;
}
int main()
{
    int k;
    cin >> k;
    ll sum = 0;
    for( int a = 1; a <= k; a++ ){
        for( int b = 1; b <= k; b++ ){
            for( int c = 1; c <= k; c++ ){
                int gcd_1 = gcd( a, b );
                int gcd_2 = gcd( c, gcd_1 );
                sum = sum + gcd_2;
            }
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

vector<set<int>> G;
map<vector<int>,int> h2id;

int tree_hash(int v, int par){
    vector<int> hs;
    for(int ch:G[v])if(ch!=par){
        hs.pb(tree_hash(ch,v));
    }
    sort(all(hs));

    if(!h2id.count(hs)) h2id[hs] = h2id.size();
    return h2id[hs];
}

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

int CALC(int h, int w){
    vector<string> p(h+2, string(w+2,'.'));
    rep(i,h)rep(j,w) cin >>p[i+1][j+1];

    h += 2;
    w += 2;

    auto IN = [&](int y, int x){
        return 0<=y && y<h && 0<=x && x<w;
    };

    vector<vector<int>> f(h,vector<int>(w,-1));
    int idx = 0;
    rep(i,h)rep(j,w)if(f[i][j] == -1){
        char color = p[i][j];
        int b = color=='#';

        f[i][j] = idx;
        queue<pi> que({{i,j}});
        while(!que.empty()){
            pi now = que.front();
            que.pop();
            rep(d,D[b]){
                int ny = now.fi+dy[b][d], nx = now.se+dx[b][d];
                if(IN(ny,nx) && f[ny][nx]==-1 && p[ny][nx]==color){
                    f[ny][nx] = idx;
                    que.push({ny,nx});
                }
            }
        }

        ++idx;
    }

    G.clear();
    G.resize(idx);
    rep(i,h)rep(j,w){
        rep(d,D[0]){
            int ny = i+dy[0][d], nx = j+dx[0][d];
            if(IN(ny,nx)){
                int u = f[i][j], v = f[ny][nx];
                if(u!=v){
                    G[u].insert(v);
                    G[v].insert(u);
                }
            }
        }
    }

    return tree_hash(0,-1);
}

int main(){
    int h,w;
    while(cin >>h >>w,h){
        h2id.clear();
        int t1 = CALC(h,w);
        cin >>h >>w;
        int t2 = CALC(h,w);
        cout << (t1==t2?"yes":"no") << "\n";
    }
    return 0;
}



Measured memory_bytes: 3032
import sys
 
def main():
    S = [int(i) for i in input()]
 
    N = len(S)
 
    ol = [0] * N
    lo = [0] * N
    for i in range(N):
        if i % 2 ==0:
            ol[i] = 0
            lo[i] = 1
        else:
            ol[i] = 1
            lo[i] = 0
 
    ol_cnt = 0
    lo_cnt = 0
    for j in range(N):
        if ol[j] == S[j]:
            ol_cnt += 1
        if lo[j] == S[j]:
            lo_cnt += 1
 
    print(min(ol_cnt, lo_cnt))
 
main()

Measured memory_bytes: 5532
#include<stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r<0||x+r>W||y-r<0||y+r>H){
  printf("No\n");
  }
  else if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 2692
n=int(input())
A=list(map(int,input().split()))

from fractions import gcd

L=[0]*(n+1)
R=[0]*(n+1)
M=[0]*n

for i in range(1,n+1):
    L[i]=gcd(L[i-1],A[i-1])

for i in range(n,1,-1):
    R[i-1]=gcd(R[i],A[i-1])

max_M=0
for i in range(n):
    M[i]=gcd(L[i],R[i+1])
    if max_M < M[i]: max_M=M[i]
print(max_M)

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

using namespace std;

int main(){
    int N;
    string color;
    cin >> N >> color;
    queue<char> s;
  s.push(color[0]);
    for (int i = 1 ; i < N; ++i){
        if(s.back() != color[i]) s.push(color[i]);
    }
    cout << s.size() <<"\n";
    return 0;
}


Measured memory_bytes: 512
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a(n);
    vi b(n);
    fori(n) {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a.begin(), a.end());
    int idx=n-2;
    while(a[idx]==a[n-1])
        idx--;

    for(int i=0; i<n; i++) {
        if(b[i]==a[n-1])
            cout<<a[n-2]<<endl;
        else 
            cout<<a[n-1]<<endl;
    }

}



Measured memory_bytes: 3200
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    long pt, px, py;
    foreach (_; 0 .. N)
    {
        long t, x, y;
        scan(t, x, y);
        long d = abs(px - x) + abs(py - y);
        // writeln(d);
        if (t - pt < d)
        {
            writeln("No");
            return;
        }
        if (((t - pt) - d) % 2 == 1)
        {
            writeln("No");
            return;
        }
        pt = t;
        px = x;
        py = y;
    }
    writeln("Yes");
}


Measured memory_bytes: 1276
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int n,A,B,C;
V<int> d;
int fanc(int i,int a,int b, int c){
  int res=INT_MAX;
  if(i==n){
      if(a&&b&&c)return abs(a-A)+abs(b-B)+abs(c-C);
       else return 1e5;
  }
  chmin(res,fanc(i+1,a,b,c));
  chmin(res,fanc(i+1,a+d[i],b,c)+(a?10:0));
  chmin(res,fanc(i+1,a,b+d[i],c)+(b?10:0));
  chmin(res,fanc(i+1,a,b,c+d[i])+(c?10:0));
  return res;
}
int main(){
  cin>>n>>A>>B>>C;
  d.resize(n);
  for(int i=0;i<n;i++)cin>>d[i];
  cout<<fanc(0,0,0,0)<<endl;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
count_0 = 0
count_2 = 0

for i in range(1,N+1):
    if i % K == 0:
        count_0 += 1
    if i % K == K / 2:
        count_2 += 1
if K % 2 == 0:
    print(count_0**3 + count_2**3)
else:
    print(count_0**3)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  int x = 800*n;
  int y = (n/15)*200;
  cout << x - y << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int x1,x2,y1,y2;
  scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
  int x3=x2-(y2-y1),y3=y2+(x2-x1),x4=x3-(y3-y2),y4=y3+(x3-x2);
  printf("%d %d %d %d\n",x2-(y2-y1),y2+(x2-x1),x4,y4 );
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    int n,a=0,u=0;
    bool flag = true;
    cin >> n;
    REP(i,n){
        string s;
        cin >> s;
        if(s=="A")a++;
        else u++;
        if(a<u)flag=false;
    }
    if(flag && a==u){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}



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

long long A[100000], B[100000], ans = 0, m = 1e9;

int main(){
    int N;
    cin >> N;
    bool is_same_set = true;
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
        if(A[i] != B[i]){
            is_same_set = false;
        }
        ans += A[i];
        if(A[i] > B[i] && B[i] < m){
            m = B[i];
        }

    }
    if(is_same_set){
        cout << 0 << endl;
        return 0;
    }
    cout << ans - m << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい


int N;
bool isprime[1001];

void era(){
	Rep(i,1001) isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(int i=1;i*i<=1000;i++){
		if(isprime[i]){
			for(int j=2;i*j<=1000;j++){
				isprime[i*j]=false;
			}
		}
	}
}





int main(){
	cin>>N;
	era();
	vector<int> prime;
	rep(i,N){
		if(isprime[i]) prime.push_back(i);
	}
	ll a[N+1];
	Rep(i,N) a[i]=0;
	for(int i=2;i<=N;i++){
		int n=i;
		for(int j=0;j<prime.size();j++){
			while(n%(prime[j])==0){
				n=n/prime[j];
				a[j]++;
			}
		}
	}
	ll ans=1;
	Rep(i,N){
		ans=(ans*(a[i]+1))%mod;
	}
	cout<<ans<<endl;
	  return 0;
  }


Measured memory_bytes: 256
n=int(input())
li = [int(input()) for _ in range(5)]  # li = ['hoge', 'bar', 'foo']

li.sort()
m = li[0]
ans = 0
if n % m == 0:
    ans += n//m
else:
    ans += n//m + 1
ans += 4
print(ans)

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

#define ll long long int

int main() {
    int n; cin>> n;
    ll s=0;

    for(int i=1; i<=n; i++) {
        if(i%3!=0 && i%5!=0) s+=i;
    }
    cout << s;
}

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

int main() {
    int m1,d1,m2,d2; cin >> m1 >>d1>>m2>>d2;
    if(d2==1){
        cout << 1 << endl;

    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		int values[] = new int[5];
		for(int i = 0;i<5;i++){
			values[i] = Integer.parseInt(sc.next());
		}
		int W = values[0];
		int H = values[1];
		int x = values[2];
		int y = values[3];
		int r = values[4];
		
		if((0<=x-r && x+r <= W) && (0<=y-r && y+r <=H)){
			
			System.out.println("Yes");
		}else{
			
			System.out.println("No");
		}
		
		sc.close();
		
	}

}


Measured memory_bytes: 26172
#Nへの代入
N=int(input())

#データのリストdata [x座標,y座標,高さ]
k=0
data=list()
for i in range(N):
    l=list(map(int,input().split()))
    data.append(l)
    if(l[2]>0):
        k=i

#中心点の探索
for x in range(101):
    for y in range(101):
        H=data[k][2]+abs(x-data[k][0])+abs(y-data[k][1])
        if all([max(H-abs(x-l[0])-abs(y-l[1]),0)==l[2] for l in data]):
            print(x,y,H)
            exit()

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a;
	vector<int> b;
	rep(i,n){
		int x;
		cin >> x;
		if(x%10==0) b.pb(x);
		else a.pb(x);
	}
	if(a.size()==0) cout << 0 << endl;
	else{
		int sum=0;
		sort(a.begin(),a.end());
		rep(i,a.size()) sum+=a.at(i);
		if(sum%10==0){
			sum-=a.at(0);
		}
		rep(i,b.size()) sum+=b.at(i);
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [[] for _ in range(n)]
ans = 0
for _ in range(m):
    a, b = map(int, input().split())
    l[a-1].append(h[b-1])
    l[b-1].append(h[a-1])
    
for i in range(n):
    s = h[i]
    x = l[i]
    if len(x) == 0:
        ans += 1
        continue
    if s > max(x):
        ans += 1
print(ans)
    

Measured memory_bytes: 23092
# include <bits/stdc++.h>
using namespace std;
const int N = 15, oo = 1e9 + 100;
int a[N][N], c[N], p[N], ans = oo;
void solve(){
	int n, m, x;
	cin >> n >> m >> x;
	for(int i = 0; i < n; ++i){
		cin >> c[i];
		for(int j = 0; j < m; ++j){
			cin >> a[i][j];
		}
	}
	for(int mask = 0; mask < (1 << n); ++mask){
		for(int i = 0; i < m; ++i)p[i] = 0;
		int cost = 0;
		bool ok = true;
		for(int bit = 0; bit < n; ++bit){
			if(mask >> bit & 1){
				cost += c[bit];
				for(int j = 0; j < m; ++j){
					p[j] += a[bit][j]; 
				}
			}
		}
		for(int i = 0; i < m; ++i){
			if(p[i] < x){
				ok = false;
				break;
			}
		}
		if(ok){
			ans = min(ans, cost);
		}
	}
	if(ans == oo)ans = -1;
	cout << ans << '\n';
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    ll x;
    cin>>x;
    rep(i,0,200){
        rep(j,0,200){
            int hoge_a = -1 * i;
            int hoge_b = -1 * j;

            if(pow(i,5) - pow(j,5) == x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }

            else if(pow(i,5) - pow(hoge_b,5) == x){
                cout<<i<<" "<<hoge_b<<endl;
                return 0;
            }
            
            else if(pow(hoge_a,5) - pow(j,5) == x){
                cout<<hoge_a<<" "<<j<<endl;
                return 0;
            }

            else if(pow(hoge_a,5) - pow(hoge_b,5) == x){
                cout<<hoge_a<<" "<<hoge_b<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4120
/*
        |___Arshit Mangukiya___|
        |___DA-IICT____|
        |___201801173____|
*/
        //__WRITE  YOUR  CODE  HERE___//
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define f(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x)        cout<< x << " ";
#define pe(x)       cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;
        /*  bool fun(pair<int,int>a , pair<int,int>b)
            {
                if(a.ff == b.ff)    return a.ss < b.ss;
                else            return a.ff < b.ff;
            }*/
 /*void bfs(ll x)
 {
    queue<ll> q;
    q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
                l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/

void solve()
{ 
   ll n;
   cin >> n;
   vector<ll> a(n);
   ll s=0;
   for(ll i=0;i<n;i++)
   {
      cin>>a[i];
   }
   sort(a.rbegin(),a.rend());
   ll j=0;
   if(n>1)
   {
      s += a[j];
      j++;
   }
   for(ll i=1;i<n-1;i++,j++)
   {
      s += a[j];
      i++;
      if(i+1 < n)
      {
         s+=a[j];
      }
   }
   cout << s;
}
    
int32_t main(){
    mr_ad_0501;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    
}

Measured memory_bytes: 4756
date0=input().rstrip().split(" ")
day=int(date0[0])
num=int(date0[1])
date1=input().rstrip().split(" ")
sum=0
for i in range(num):
  sum+=int(date1[i])
if day-sum>=0:
  print(day-sum)
else:
  print(-1)

Measured memory_bytes: 9684
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int N;
  cin >> N;
  cout << N * 800 - N/15 * 200 << endl;
}

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

int main()
{
    cout << fixed << setprecision(10);

    int N;
    cin >> N;

    priority_queue<double, vector<double>, greater<double>> q;
    for (int i = 0; i < N; i++)
    {
        double vi;
        cin >> vi;
        q.push(vi);
    }
    while (q.size() > 1)
    {
        double v0 = q.top();
        q.pop();
        double v1 = q.top();
        q.pop();
        q.push((v0 + v1) / 2);
    }
    cout << q.top() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

string solve(ll n){
    string str;
    cin >> str;

    unsigned ll mbit = 1;
    unsigned ll ebit = 0;

    for(int i = 0; i < 52; i++){
        mbit *= 2;
        if(str[i] == '1'){
            mbit += 1;
        }
    }

    unsigned ll base = (1LL << 53);
    unsigned ll ans = mbit;

    for(int i = 0; i < 53; i++){
        unsigned ll need = base - ans;
        unsigned ll tbit = (mbit >> i);
        unsigned ll addNum = (need + tbit - 1)/tbit;
        if(addNum > n){
            ans += (tbit * n);
            break;
        }else{
            ans += (tbit * addNum);
            ans >>= 1;
            ebit++;
            n -= addNum;
        }
    }

    string eret = "",mret = "";

    for(int i = 0; i < 12; i++){
        if(ebit & 1){
            eret += '1';
            ebit -= 1;
        }else{
            eret += '0';
        }
        ebit >>= 1;
    }

    for(int i = 0; i < 52; i++){
        if(ans & 1){
            mret += '1';
            ans -= 1;
        }else{
            mret += '0';
        }
        ans >>= 1;
    }

    string ret = "";

    for(int i = 11; i >= 0; i--){
        ret += eret[i];
    }
    for(int i = 51; i >= 0; i--){
        ret += mret[i];
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    vector<string> ans;

    while(true){
        ll n;
        cin >> n;
        if(n == 0){
            break;
        }
        ans.push_back(solve(n));
    }

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

    return 0;
}


Measured memory_bytes: 3292
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>

constexpr intmax_t MOD=1e9+7;

std::vector<intmax_t> fact, ifact;

intmax_t modpow(intmax_t n, intmax_t iexp) {
  intmax_t res=1;
  for (intmax_t dbl=n; iexp; iexp>>=1) {
    if (iexp & 1) res = res * dbl % MOD;
    dbl = dbl * dbl % MOD;
  }
  return res;
}

intmax_t modinv(intmax_t n) {
  return modpow(n, MOD-2);
}

intmax_t ncr(intmax_t n, intmax_t r) {
  if (r == 0 || r == n) return 1;
  if (r < 0 || r > n) return 0;
  return fact[n] * ifact[r] % MOD * ifact[n-r] % MOD;
}

int main() {
  size_t n;
  intmax_t m;
  scanf("%zu %jd", &n, &m);

  if (m == 1)
    return !printf("1\n");

  std::map<int, int> div;
  for (intmax_t i=2; i*i<=m; ++i) {
    while (m % i == 0) {
      ++div[i];
      m /= i;
    }
  }
  if (m > 1)
    ++div[m];

  fact.assign(131072, 0);
  ifact = fact;
  intmax_t NMAX=100100;
  fact[0] = 1;
  for (intmax_t i=1; i<=NMAX; ++i)
    fact[i] = fact[i-1] * i % MOD;
  ifact[NMAX] = modinv(fact[NMAX]);
  for (intmax_t i=NMAX; i--;)
    ifact[i] = ifact[i+1] * (i+1) % MOD;

  for (intmax_t i=0; i<=NMAX; ++i)
    assert(fact[i] * ifact[i] % MOD == 1);

  intmax_t res=1;
  for (const auto &p: div) {
    if (p.first == 1) continue;
    fprintf(stderr, "%d ^ %d\n", p.first, p.second);
    res = res * ncr(p.second+n-1, n-1) % MOD;
  }

  printf("%jd\n", res);
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define ll long long 
#define a109 10000007
using namespace std;

ll n,k,w,sum,mx;
ll dizi[105][5];
ll dp[103][100003];
ll dpf(int crr,int kalan){
	if(kalan<0){
		return -mx;
	}
	if(crr>=n || kalan==0){
		return 0;
	}
	if(dp[crr][kalan]!=-1){
		return dp[crr][kalan];
	}
	dp[crr][kalan]=max(   (dpf(  crr+1,kalan-dizi[crr][0]  ) + dizi[ crr ][ 1 ]),  dpf(crr+1,kalan)    );
	// printf("%d %d %d\n",crr,kalan,dp[crr][kalan] );
	return dp[crr][kalan];
}


int main(){
	// freopen("a.gir","r",stdin);
 //    freopen("a.cik","w",stdout);
    for(int i=0;i<102;i++){
   		for(int j=0;j<100002;j++){
   			dp[i][j]=-1;
   		}
  	}

	scanf("%lld %lld",&n,&w);

	for(int i=0;i<n;i++){
		scanf("%lld %lld",&dizi[i][0],&dizi[i][1]);
		mx=max(mx,dizi[i][1]);
	}
	mx++;
	cout<<dpf(0,w);
}

Measured memory_bytes: 80128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n   = Integer.parseInt(scanner.nextLine());
		int[] list = new int[n];
		int[] ans  = new int[n];

		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(scanner.nextLine());
			ans[i]  = list[i];

		}

		Arrays.sort(list);

		for(int i = 0; i < n; i++) {


			if(list[n - 1] != ans[i]) {

				System.out.println(list[n - 1]);

			}else{

				System.out.println(list[n - 2]);

			}

		}




	}
}


Measured memory_bytes: 162784
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 200001

int main() {
    int N;
    long time, finish;
    vector <pair<long, long>> job;

    scanf("%d", &N);

    for (int i=0; i<N; i++) {
        scanf("%ld %ld", &time, &finish);
        job.push_back(make_pair(finish, time));
    }

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

    time = 0;
    bool status = true;

    for (int i=0; i<N; i++) {
        time += job[i].second;
        if (time > job[i].first) status=false;
    }

    if (status) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 6384
import Control.Applicative

import Control.Monad
    (replicateM)
    
import Data.List
    (intercalate)
    
import Data.Map.Strict
    ((!), Map, fromList)

type Dice
    = [Int]

type Question
    = (Int, Int)
    
type Table
    = Map Int (Map Int Int)

type Problem
    = (Dice, [Question])

type Result
    = [Int]

table :: Dice -> Table

table [s1, s2, s3, s4, s5, s6]
    = fromList [(s1, l1), (s2, l2), (s3, l3), (s4, l4), (s5, l5), (s6, l6)] where
        l1 = fromList [(s1, 0), (s2, s3), (s3, s5), (s4, s2), (s5, s4), (s6, 0)]
        l2 = fromList [(s1, s4), (s2, 0), (s3, s1), (s4, s6), (s5, 0), (s6, s3)]
        l3 = fromList [(s1, s2), (s2, s6), (s3, 0), (s4, 0), (s5, s1), (s6, s5)]
        l4 = fromList [(s1, s5), (s2, s1), (s3, 0), (s4, 0), (s5, s6), (s6, s2)]
        l5 = fromList [(s1, s3), (s2, 0), (s3, s6), (s4, s1), (s5, 0), (s6, s4)]
        l6 = fromList [(s1, 0), (s2, s4), (s3, s2), (s4, s5), (s5, s3), (s6, 0)]

right :: Dice -> Question -> Int

right dice (top, front)
    = table dice ! top ! front

solve :: Problem -> Result

solve (dice, questions)
    = map (right dice) questions

output :: Result -> String

output result
    = intercalate "\n" $ map show result
    
input :: IO Problem

input
    = do
        dice <- map read <$> words <$> getLine
        n <- read <$> getLine
        questions <- replicateM n inputQuestion
        return (dice, questions)
        
inputQuestion :: IO Question

inputQuestion
    = do
        [top, front] <- map read <$> words <$> getLine
        return (top, front)

main :: IO ()

main
    = putStrLn <$> output =<< solve <$> input

Measured memory_bytes: 4064
import javax.management.monitor.CounterMonitor;
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Euclid e1=new Euclid();//ユークリッドの互除法
        //Compute c1=new Compute();//累積和，
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        int answer=0;
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B =sc.nextInt();

        if(A>=13)
        {
            answer=B;
        }else if(A<13 && A>=6)
        {
            answer=B/2;
        }else if(A<=5)
        {
            answer=0;
        }
        //出力
        //System.err.println();//標準エラー出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        System.out.println(answer);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
vector <int> adj[200001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll ans=(n*(n+1)*(n+2))/6;
        for(int i=1;i<n;i++){
            ll u,v;
            cin>>u>>v;
            ll val=min(u,v)*(n-max(u,v)+1);
            ans-=val;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 8352
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int k,s; cin>>k>>s;
  int ans=0;
  rep(i,k+1){
    rep(j,k+1){
      int z=s-(i+j);
      if(0<=z&&z<=k)
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define ll long long
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
struct line
{
	ll x,val;
}L[200005];
bool operator <(const struct line &a,const struct line &b)
{
	return a.x<b.x;
}
int main(int argc, char** argv) {
	int n;
	ll d,a;
	scanf("%d%lld%lld",&n,&d,&a);
	for(int i=1;i<=n;i++)
	scanf("%lld%lld",&L[i].x,&L[i].val);
	sort(L+1,L+1+n);
	map<ll,ll>cf;
	ll now=0,ans=0,j=1;
	for(int i=1;i<=n;i++)
	{
		now+=cf[i];
		if(L[i].val-now>0)
		{
		while(L[j].x<L[i].x+2*d+1&&j<=n)j++;
		cf[j]-=((L[i].val-now)/a+((L[i].val-now)%a>0?1:0))*a;
		ans+=((L[i].val-now)/a+((L[i].val-now)%a>0?1:0));
//		cout<<ans<<endl;
		now+=((L[i].val-now)/a+((L[i].val-now)%a>0?1:0))*a;
		}
	}
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int c[6][2] = {
	{1,4},
	{-1,2},
	{5,3},
	{4,1},
	{1,-1},
	{3,4}
};
int main() {
	string a;
	while (cin>>a,a!="#")
	{
		int now = 0;
		for (int b = 0; b < a.length(); b++) {
			if (c[now][a[b] - 48] != -1) {
				now = c[now][a[b] - 48];
			}
			else { now = -1; break; }
		}
		if (now == 3)puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int b=0,i,x,Max=0;
    int a[4]={0};
    cin>>a[0]>>a[1]>>a[2];
    for(i=0;i<3;i++)
    {
        if(a[i]>Max)
        {
            Max=a[i];
        }

    }
    x=Max*10;
    for(i=0;i<3;i++)
    {
        b+=a[i];
    }
    b-=Max;
    cout<<x+b<<endl;
    return 0;
}


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

#define MAX(x, y) ((x) > (y) ? (x) : (y))

int dp[1002][1002];

int main(void)
{
	int w;
	int n;
	int cnt;
	int max;
	
	cnt = 1;
	while (1){
		int value[1000];
		int weight[1000];
		
		scanf("%d", &w);
		
		if (w == 0){
			break;
		}
		
		scanf("%d", &n);
		
		memset(dp, -1, sizeof(dp));
		
		for (int i = 0; i < n; i++){
			scanf("%d,%d", &value[i], &weight[i]);
			dp[i][0] = 0;
		}
		
		for (int i = 1; i <= n; i++){
			for (int j = 0; j <= w; j++){
				if (dp[i - 1][j] != -1 && j + weight[i - 1] <= w){
					dp[i][j + weight[i - 1]] = MAX(dp[i - 1][j] + value[i - 1], dp[i][j + weight[i - 1]]);
				}
				if (dp[i - 1][j] != -1){
					dp[i][j] = MAX(dp[i - 1][j], dp[i][j]);
				}
			}
		}
		
		max = 0;
		for (int i = 1; i <= w; i++){
			if (dp[n][i] > dp[n][max]){
				max = i;
			}
		}
		
		printf("Case %d:\n%d\n%d\n", cnt++, dp[n][max], max);
	}
	
	return (0);
}

Measured memory_bytes: 0
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

d, n = na()
ct = 0
s = 100
if d == 0:
    if n != 100:
        print(n)
    else:
        print(101)
elif d == 1:
    if n != 100:
        print(100 * n)
    else:
        print(10100)
else:
    if n != 100:
        print(10000 * n)
    else:
        print(1010000)

Measured memory_bytes: 5132