akhauriyash/Code-Regression huggingface dataset:
// AOJ 0275 Railroad
// 2018.2.21 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 10000
typedef struct { int t, s; } QUE;
QUE que[QMAX+2]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x10101010
#define MAX 100003

int S; 
int   hi[MAX], *to[MAX]; short *w[MAX];
int dist[MAX];
char  mk[MAX];
int hi2[MAX], *to2[MAX];

int   q[MAX], top, tail;
typedef struct { int s, e, d; } T;
T ord[3*MAX]; int sz;

int c[40002], d[40002];
unsigned long long dp[MAX];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void dijkstra(int start)
{
	int i, s, e, d;

	memset(dist, INF, S << 2);
	qsize = 0;
	enq(start, 0), dist[start] = 0;
	while (qsize) {
		s = que[0].s, deq();
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], d = dist[s] + w[s][i];
			if (dist[e] > d) hi2[e] = 0, enq(e, d);
			if (dist[e] >= d) dist[e] = d, to2[e][hi2[e]++] = s;
		}
	}
}

int cmp(T *a, T *b) { return a->d - b->d; }

void order(int goal)
{
    int i, s, e;

	memset(hi, 0, S << 2);
	q[0] = goal, top = 0, tail = 1;
	mk[goal] = 1;
	sz = 0;
	while (top < tail) {
		s = q[top++];
		for (i = 0; i < hi2[s]; i++) {
			e = to2[s][i];
			ord[sz].s = e, ord[sz].e = s, ord[sz++].d = dist[s];
			if (!mk[e]) mk[e] = 1, q[tail++] = e;
		}
	}
	qsort(ord, sz, sizeof(T), cmp);
}

int main()
{
	int R, Q, u, v, _w, a, b, i, j, k, ii;
	int *memo;
	
	S = in()+1, R = in();
	memo = malloc(R*3*sizeof(int));
	j = 0, i = R; while (i--) {
		memo[j++] = u = in(), hi[u]++;
		memo[j++] = v = in(), hi[v]++;
		memo[j++] = in();
	}
	for (i = 0; i < S; i++) if (hi[i]) {
		to [i] = malloc(hi[i] << 2), w[i] = malloc(hi[i] << 1);
		to2[i] = malloc(hi[i] << 2);
	}

	memset(hi, 0, S << 2);
	j = 0; while (R--) {
		u = memo[j++], v = memo[j++], _w = memo[j++];
		k = hi[u]++, to[u][k] = v, w[u][k] = _w;
		k = hi[v]++, to[v][k] = u, w[v][k] = _w;
	}
	free(memo);
	
	a = in(), b = in();
	dijkstra(a);
	order(b);

	Q = in();
	for (i = 0; i < Q; i++) c[i] = in(), d[i] = in();
	ii = (Q+63)>>6; for (i = 0; i < ii; i++) {
        memset(dp, 0, sizeof(dp));
		for (j = 0; j < 64; j++) if ((i<<6)+j < Q) dp[c[(i<<6)+j]] |= 1LL << j;
		for (j = 0; j < sz; j++) dp[ord[j].e] |= dp[ord[j].s];
        for (j = 0; j < 64; j++) if ((i<<6)+j < Q) {
            puts(dp[d[(i<<6)+j]] & (1LL<<j)? "Yes": "No");
		}
    }
	return 0;
}



Measured memory_bytes: 22724
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
	int N;
  get(N);
  vector<ll> A(N);
  getv(A);
  sort(ALL(A));
  int c=0;
  vector<ll> B(N);
  ll ans1=0,ans2=0;
  if(N%2==1){
    int l=0,r=N-1,flg=0;
    int center=N/2;
    B[center]=A[l++];
    for(int i=1;i<=(N-1)/2;++i){
      if(flg==0){
        B[center-i]=A[r--];
        B[center+i]=A[r--];
      }else{
        B[center-i]=A[l++];
        B[center+i]=A[l++];
      }
      flg=~flg;//debug(B);
    }
    FOR(i,N-1)ans1+=abs(B[i]-B[i+1]);
    l=0,r=N-1;
    flg=0;
    reverse(ALL(A));
    B[center]=A[l++];
    for(int i=1;i<=(N-1)/2;++i){
      if(flg==0){
        B[center-i]=A[r--];
        B[center+i]=A[r--];
      }else{
        B[center-i]=A[l++];
        B[center+i]=A[l++];
      }
      flg=~flg;//debug(B);
    }
    FOR(i,N-1)ans2+=abs(B[i]-B[i+1]);
  }else{
    int p=0;
    for(int i=1;i<N;i+=2){
      B[i]=A[p++];
    }
    for(int i=0;i<N;i+=2){
      B[i]=A[p++];
    }
    FOR(i,N-1)ans1+=abs(B[i]-B[i+1]);
    ans2=ans1;
  }
  print(max(ans1,ans2));
  return 0;
}


Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	vector<vector<int>>dp(50001, vector<int>(5));
	dp[0][0] = 1;
	for (int i = 1; i <= 200; i++) {
		for (int j = 1; j <=4; j++) {
			for (int k = 50000; k >= i * i; k--) {
				dp[k][j] += dp[k - i * i][j - 1];
			}
		}
	}
	while (cin >> N, N) {
		cout << accumulate(dp[N].begin(), dp[N].end(), 0LL) << endl;
	}
}


Measured memory_bytes: 5304
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
*/
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        double n=sc.nextDouble(),m=sc.nextDouble();
        out.println((long)((100*(n-m)+1900*m)*pow(2,m)));
    }
}

Measured memory_bytes: 24404
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
  size_t n, wmax;
  std::cin >> n >> wmax;

  std::vector<size_t> w(n);
  std::vector<size_t> v(n);
  for (size_t i = 0; i < n; ++i) std::cin >> w[i] >> v[i];

  const auto vmax = std::accumulate(v.begin(), v.end(), (size_t)0);
  std::vector<size_t> dp(vmax + 1, SIZE_MAX);

  dp[0] = 0;
  for (size_t i = 1; i <= n; ++i) {
    const auto wi = w[i - 1];
    const auto vi = v[i - 1];
    for (size_t j = vmax; j <= vmax; --j) {
      if (j < vi) continue;
      if (dp[j - vi] == SIZE_MAX) continue;
      dp[j] = std::min(dp[j], dp[j - vi] + wi);
    }
  }

  size_t ans = 0;
  for (size_t i = 0; i <= vmax; ++i)
    if (dp[i] <= wmax) ans = i;
  std::cout << ans << std::endl;
}


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

#define nxt(x) bian[x].nxt
#define ed(x) bian[x].ed

using namespace std;

const int maxn=1e6;

struct edge{
	int nxt,ed;
}bian[maxn];

int n;

int t[maxn],cnt=2;

int w[maxn];

bool bl[maxn];

void lj(int x,int y) {
	ed(cnt)=y;
	nxt(cnt)=t[x];
	t[x]=cnt++;
	w[x]++;
}

queue<int> q;

void bfs() {
	while(!q.empty()) q.pop();
	
	for (;;) {
		bool wy=0;
		for (int l=1;l<=n;l++) {
			if (w[l]==1&&bl[l]==0) {
				q.push(l);
			}
		}
		while(!q.empty()) {
			int u=q.front();
			q.pop();
			for (int l=t[u];l;l=nxt(l)) {
				int v=ed(l);
				if (bl[v]==1||w[v]!=2) continue;
				for (int j=t[v];j;j=nxt(j)) {
					int x=ed(j);
					w[x]--;
					if (w[x]==1&&bl[x]==0) q.push(x);
				}
				bl[u]=bl[v]=1;
				wy=1;
			}
		}
		if (wy==0) break;
	}
}

int main() {
	cin>>n;
	for (int l=1;l<n;l++) {
		int u,v;
		cin>>u>>v;
		lj(u,v);
		lj(v,u);
	}
	bfs();
	int ans=0;
	for (int u=1;u<=n;u++) {
		if (bl[u]==0) {
			ans++;
		}
	}
	if (ans!=2) cout<<"First"<<endl;
	else cout<<"Second"<<endl;

}


Measured memory_bytes: 6240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    long long x;
    cin>>x;
    long long ans=0;
    ans=x/11;
    ans*=2;
    long long r=x%11;
    if(r>6){
        ans+=2;
    }else if(r>0){
        ans++;
    }else{

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

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

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

int main() {
  
  int n;
  int w[10000], h[10000];
  while(cin >> n && n) {
    for(int i=0; i<n; i++) cin >> w[i];
    for(int i=0; i<n; i++) cin >> h[i];
    sort(h, h+n, greater<int>());
    
    for(int i=0; i<n; i++)
      for(int j=0; j<n; j++)
	if(w[j]) w[j] --, h[i] --;
    
    bool ok = 1;
    for(int i=0; i<n; i++)
      if(h[i]) { ok = 0; }
    
    if(ok) cout << "Yes" << endl;
    else cout << "No"<< endl;
  }
  
  return 0;
}

Measured memory_bytes: 1248
//Is it Convex?
#include<bits/stdc++.h>
using namespace std;

typedef complex<double> P;
typedef vector<P> G;
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1)%P.size()]

inline double cross(const P &a, const P &b){return imag(conj(a)*b);}
inline double dot(const P &a, const P &b){return real(conj(a)*b);}

int ccw(P a, P b, P c){
  b-=a; c-=a;
  if(cross(b, c) > 0) return +1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}
bool isconvex(const G &p){
  for(int i=0; i<p.size(); ++i)
    if(ccw(prev(p, i), curr(p, i), next(p, i)) > 0)return false;
  return true;
}

int main(){
  char t;
  P a, b, c, d;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &a.real(), &a.imag(), &b.real(), &b.imag(), &c.real(), &c.imag(), &d.real(), &d.imag())!=EOF){
    bool flag=false;
    G g;
    g.clear();
    g.push_back(a); g.push_back(b); g.push_back(c); g.push_back(d);
    if(isconvex(g)){flag=true;}
    g.clear();
    g.push_back(d); g.push_back(c); g.push_back(b); g.push_back(a);
    if(isconvex(g)){flag=true;}

    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

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

using namespace std;

void forward(string& data)
{
	for(auto& c : data)
	{
		if(c < 'a' || 'z' < c)
			continue;

		c++;
		if('z' < c)
			c -= 26;
	}
}

bool test(const string& data)
{
	if(data.find("the") != string::npos)
		return true;
	if(data.find("this") != string::npos)
		return true;
	if(data.find("that") != string::npos)
		return true;

	return false;
}

int main()
{
	string line;
	while(getline(cin, line))
	{
		for(int i = 0; i < 26; i++)
		{
			if(test(line))
				break;
			forward(line);
		}

		cout << line << endl;
	}

	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    int n;
    cin >> n;
    VI d(n);
    FOR(i, 0, n)cin >> d[i];
    SORT(d);
    if (d[n / 2] == d[n / 2 - 1])cout << 0 << "\n";
    else cout << d[n / 2] - d[n / 2 - 1] << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define N 100010
char arr[N];
int main()
{
    int cnt = 0;
    scanf("%s", arr + 1);
    int n = strlen(arr + 1), k = n & 1;
    puts(abs(k - (arr[n] == arr[1])) & 1 ? "First" : "Second");
}


Measured memory_bytes: 384
#!/bin/python3

def main():

    # 変数宣言
    cnt = 0

    # 標準入力からデータの受け取り
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    # 提示条件成立判定＆カウント
    for i in range(0, n - 2):
        for j in range(i + 1, n -1):
            for k in range(j + 1, n):
                if (not((l_list[i] != l_list[j]) and (l_list[i] != l_list[k]) and (l_list[j] != l_list[k]))):
                    continue
                if (not((l_list[i] < l_list[j] + l_list[k]) and (l_list[j] < l_list[i] + l_list[k]) and (l_list[k] < l_list[i] + l_list[j]))):
                    continue
                cnt += 1
    # 結果表示
    print(cnt)


if __name__ == '__main__':
    main()


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int r, g, b; cin >> r >> g >> b;
  int v = r * 100 + g * 10 + b;
  if (v % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (int) 1000000007
using namespace std;
long long fact[200080];
long long inv[200080];

long long power(long long n, long long p)
{
    unsigned long long cur, res;
    cur = n;
    res = 1;
    while(p){
        if (p&1 == 1){
            res *= cur;
            res %= MOD;
        }
        p /= 2;
        cur *= cur;
        cur %= MOD;
    }
    return res;
}

void pre()
{
    fact[0] = inv[0] = 1;
    for (int i=1; i<=200000; i++)
    {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = power(fact[i], MOD-2);
    }
}

long long C(int n, int k)
{
    return ((fact[n] * inv[k])% MOD * inv[n-k]) % MOD;
}

int main() {
    long long H, W, A, B;
    scanf("%lld", &H);
    scanf("%lld", &W);
    scanf("%lld", &A);
    scanf("%lld", &B);

    pre();
    unsigned long long ans = C(H+W-2, H-1), temp=0;
    for (int i=0; i<B; i++)
    {
        temp = (temp + ((C(H-A+i-1, i)*C(W+A-i-2, A-1))%MOD))%MOD;
    }
    printf("%lld\n", (ans-temp+MOD)%MOD);
}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int m=sc.nextInt();
        int a[]=sc.nextIntArray(m);
        int d[]=new int[m-1];
        sort(a);
        for (int i = 0; i < d.length; i++) {
			d[i]=a[i+1]-a[i];
		}
        sort(d);
        long s=0;
        for (int i = 0; i < m-n; i++) {
			s+=d[i];
		}

        out.println(s);
        out.flush();
    }


    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

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

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//        this.a=a;
//        this.b=b;
//    }
//    public int compareTo(P p){
//        return b-p.b; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 33536
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	string s, t;
	cin >> s >> t;
	reverse(s.begin(), s.end());
	cout << (s == t ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  int x;cin >> x;
  
  //compute
 
  //output
  if(x == 0){
           cout << "1" << endl;
         }else{
           cout << "0" << endl;
         }
  
}

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

int main()
{
  int inputNum = 0;
  std::string sentens = "";
  std::string forword = "";
  std::string back = "";
  std::cin >> inputNum;
  std::cin >> sentens;
  forword = sentens.substr(0, inputNum / 2);
  back = sentens.substr(inputNum / 2);
  if(forword == back)
  {
    std::cout << "Yes" << std::endl;
  }
  else
  {
    std::cout << "No" << std::endl;
  }
  return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; ++i) {
    cin >> S[i];
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      char p = S[i][j];
      if (p == '.') {
        int cnt = 0;
        for (int k = -1; k <= 1; ++k) {
          if (i + k < 0 || H <= i + k) {
            continue;
          }
          for (int l = -1; l <= 1; ++l) {
            if (j + l < 0 || W <= j + l) {
              continue;
            }
            char around = S[i + k][j + l];
            if (around == '#') {
              ++cnt;
            }
          }
        }
        S[i][j] = '0' + cnt;
      }
    }
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cout << S[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
main()
{
	char a[15];
	int i, x=800;
	scanf("%s", a);
	for (i=0; i<(strlen(a)-2); i++)
	{
		if (abs((((a[i]-48)*100)+((a[i+1]-48)*10)+(a[i+2]-48))-753)<x)
		x=abs((((a[i]-48)*100)+((a[i+1]-48)*10)+(a[i+2]-48))-753);
	}
	printf("%d\n", x);
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    int it = 0;
    while (k--) {
        vector <int> b(n + 1, 0);
        for (int i = 0; i < n; i++) {
            b[max(0, i - a[i])]++;
            b[min(n, i + a[i] + 1)]--;
        }
        a[0] = b[0];
        for (int i = 1; i < n; i++) {
            b[i] += b[i - 1];
            a[i] = b[i];
        }
        bool good = true;
        for (int i = 0; i < n; i++) if (a[i] != n) good = false;
        if (good) {
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << ' ';
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 5000
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int L = H2 * 60 + M2 - H1 * 60 - M1;

  cout << L - K << endl;

  return 0;
}


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

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

const int INF = 1e9+7;


int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    int maxi = a[0];
    int sum = 0;
    for(int i = 1;i < a.size();i++){
        sum += a[i];
    }

    if(sum > maxi){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }







    return 0;
}

Measured memory_bytes: 256
#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(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, count = 0;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    if (mp.size() % 2 == 0)
        cout << mp.size() - 1 << endl;
    else
        cout << mp.size() << endl;
    return 0;
}

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

const int N=100100;
typedef long long ll;
int a[N],n,S;
ll b[N];

pair<ll,int>solve(int l,int r){
	if((a[l]<S)==(a[r]<S)){
		if(a[l]<S)return make_pair(S-a[l],a[l]);
		else return make_pair(a[r]-S,a[r]);
	}
	if(b[l]>=b[r]){
		b[l]+=b[r];auto s=solve(l,r-1);
		return make_pair(s.first+a[r]-s.second,a[r]);
	}else{
		b[r]+=b[l];auto s=solve(l+1,r);
		return make_pair(s.first+s.second-a[l],a[l]);
	}
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>S;
	for(int i=1;i<=n;++i)cin>>a[i]>>b[i];
	cout<<solve(1,n).first<<'\n';
	return 0;
}


Measured memory_bytes: 3968
import collections
import numpy as np
N,K = map(int,input().split())
A = [int(x) for x in input().split()]
B=collections.Counter(A)
C=sorted(list(B.values()))
if len(C)<=K:
  answer=0
else:
  answer=np.cumsum(C)[len(C)-K-1]
print(answer)

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

int Print(int a[], int p){
    for(int i=0;i<p;i++){
        if(i>0)printf(" ");
        printf("%d",a[i]);
    }
	printf("\n");
}

int main(){
    int n;
    int a[1000];
    cin >> n ;
    for(int i=0;i<n;i++)cin >> a[i] ;

    for(int i=0;i<n;i++){
        int v = a[i] ;
        int j = i-1 ;
        while(j>=0 && a[j]>v){
         a[j+1] = a[j];
         j-- ;
        }
        a[j+1] = v;
        Print(a,n);
    }
    
    return 0 ;
}


Measured memory_bytes: 3200
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    A.sort(reverse=True)

    v = []
    while len(A) > 1:
        if len(v) == 2:
            break

        if A[0] == A[1]:
            v.append(A[0])
            A.pop(0)
            A.pop(0)
        else:
            A.pop(0)

    if len(v) == 1 or len(v) == 0:
        print(0)
    else:
        print(v[0] * v[1])


Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef long double R;
typedef complex<R> P;

const R EPS = 1e-10;

int sgn(R a) {
    if (a < -EPS) return -1;
    if (a > EPS) return 1;
    return 0;
}

int sgn(R a, R b) {
    return sgn(b-a);
}

bool near(P a, P b) {
    return !sgn(abs(a-b));
}

R cross(P a, P b) { return a.real()*b.imag() - a.imag()*b.real(); }
R dot(P a, P b) { return a.real()*b.real() + a.imag()*b.imag(); }

int ccw(P a, P b, P c) {
    if (near(a, c) || near(b, c)) return 0;
    int s = sgn(cross(b-a, c-a));
    if (s) return s;
    if (dot(b-a, c-a) < 0) return 2;
    if (dot(a-b, c-b) < 0) return -2;
    return 0;
}

struct L {
    P x, y;
    L() {};
    L(P x, P y) : x(x), y(y) {};
};

P vec(const L &l) {
    return l.y-l.x;
}

R distLP(const L &l, const P &p) {
    return abs(cross(vec(l), p-l.x)/abs(vec(l)));
}

R distSP(const L &s, const P &p) {
    P s2 = vec(s)*P(0, 1);
    if (ccw(s.x, s.x+s2, p) == 1) return abs(s.x-p);
    if (ccw(s.y, s.y+s2, p) == -1) return abs(s.y-p);
    return min(min(abs(s.x-p), abs(s.y-p)), distLP(s, p));
}

struct C {
    P p;
    R r;
    C() {}
    C(P p, R r) : p(p), r(r) {}
};

struct T {
    P d[3];
    T() {}
    T(P x, P y, P z) {
        d[0] = x; d[1] = y; d[2] = z;
    }
    P& operator[](int p) {
        return d[p];
    }
    const P& operator[](int p) const {
        return d[p];
    }
    int size() const {
        return 3;
    }
};

P cu(const T &t, int i) {
    return t[(i%3+3)%3];
}

//0:P is out 1:P is on line 2:P is in
int contains(const T &pol, P p) {
    int in = -1;
    for (int i = 0; i < (int)pol.size(); i++) {
        P a=cu(pol,i)-p, b=cu(pol,i+1)-p;
        if (ccw(a, b, P(0, 0)) == 0) return 1;
        if (imag(a) > imag(b)) swap(a, b);
        if (imag(a) <= 0 && 0 < imag(b)) {
            if (cross(a, b) < 0) in *= -1;
        }
    }
    return in+1;
}

bool solve() {
    T t;
    for (int i = 0; i < 3; i++) {
        double x, y;
        if (scanf("%lf %lf", &x, &y) != 2) return false;
        t[i] = P(x, y);
    }
    C c;
    double x, y;
    cin >> x >> y;
    c.p = P(x, y);
    double r;
    cin >> r;
    c.r = r;

    R ma = -1e9, mi = 1e9;
    for (int i = 0; i < 3; i++) {
        ma = max(ma, abs(t[i]-c.p));
        mi = min(mi, distSP(L(cu(t, i), cu(t, i+1)), c.p));
    }
//    cout << ma << " " << mi << endl;
    if (sgn(ma, c.r) != -1) {
        cout << "b" << endl;
        return true;
    }

    if (contains(t, c.p) != 0 && sgn(c.r, mi) != -1) {
        cout << "a" << endl;
        return true;
    }

    if (sgn(mi, c.r) != -1) {
        cout << "c" << endl;
        return true;
    }
    cout << "d" << endl;
    return true;
}

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

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

void d_m_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input_dp.txt", "r", stdin);
	freopen("output_dp.txt", "w", stdout);
#endif
}

int knapsack(int weight[], int value[], int n, int W)
{
	int dp[n + 1][W + 1];

	memset(dp, 0, sizeof dp);

	for (int i = 0; i <= n; i++)
		dp[0][i] = 0;

	//for (int i = 1; i <= n; i++)
	dp[1][weight[1]] = value[1];

	for (int i = 2; i <= n; i++)
	{
		for (int w = 0; w <= W; w++)
		{
			dp[i][w] = dp[i - 1][w];
			if (weight[i] <= w)
				dp[i][w] = max(dp[i][w], value[i] + dp[i - 1][w - weight[i]]);
		}
	}

	return *max_element(dp[n], dp[n] + W + 1);
}


int32_t main()
{
	//d_m_c();

	int n, W;
	cin >> n >> W;

	int weight[n + 1], value[n + 1];

	for (int i = 1; i <= n; i++)
	{
		int a, b;
		cin >> a >> b;

		weight[i] = a;
		value[i] = b;
	}

	cout << knapsack(weight, value, n, W);


	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

bool comp(pair<ll, ll> &a, pair<ll, ll> &b) {
  return a.second > b.second;
}

int main() {
  ll n, m;
  cin >> n >> m;

  priority_queue<ll, vector<ll>, greater<ll>> a;
  for (ll i = 0; i < n; ++i) {
    ll tmp;
    cin >> tmp;
    a.push(tmp);
  }

  vector<pair<ll, ll>> bc(m);
  for (ll i = 0; i < m; ++i) {
    ll b, c;
    cin >> b >> c;
    bc[i] = pair<ll, ll>(b, c);
  }

  sort(bc.begin(), bc.end(), comp);

  for (ll i = 0; i < m; ++i) {
    ll b = bc[i].first;
    ll c = bc[i].second;

    for (ll j = 0; j < b; ++j) {
      if (c <= a.top()) break;
      a.pop();
      a.push(c);
    }
  }

  ll ans = 0;
  while (!a.empty()) {
    ans += a.top();
    a.pop();
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2676
D = gets.to_i
c = gets.split.map &:to_i
s = Array.new
D.times do
  s << gets.split.map(&:to_i)
end
# t = []
# D.times do
#   t << gets.to_i
# end
#
# last = Array.new(26){[0, false]}
#
#
#
# def cal_dec(c, last, day)
#   sum = 0
#   for i in 0..25
#     sum += c[i] * (day - last[i][0])
#   end
#   sum
# end
#
#
#
# point = 0
# for day in 1..D
#   point += s[day-1][t[day-1]-1]
#   last[t[day-1]-1][1] = true
#   last[t[day-1]-1][0] = day
#   point -= cal_dec(c, last, day)
#   puts point
# end


D.times do |i|
    max = s[i].max
  a = s[i].index(max) + 1
  b =  (i+2) % 26 + 1
  puts [a,b].sample
end


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int x = A % 2;
  
  if(x == 0) {
    if(A * 12.5 == B * 10 || A * 12.5 == B * 10 + 5)
      cout << A * 12.5 << endl;
    else if(A * 12.5 + 5 == B * 10 || A * 12.5 + 10 == B * 10)
      cout << B * 10 << endl;
    else
      cout << "-1" << endl;
  }
  else {
    if(A * 12.5 + 0.5 == B * 10 + 3 || A * 12.5 + 0.5 == B * 10 + 8)
      cout << A * 12.5 + 0.5 << endl;
    else if(A * 12.5 + 7.5 == B * 10 || A * 12.5 + 2.5 == B * 10)
      cout << B * 10 << endl;
    else
      cout << "-1" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int n, x, i, j, k, count;

  while(1){
    count = 0;

    scanf("%d %d", &n, &x);
    if(n == 0 && x == 0)break;

    for(i = n; i >= 3 ; i--){
      for(j = i-1; j >= 2;j--){
	for(k = j-1; k >= 1;k--){
	  if((i + j + k) == x)
	    count++;
	  }
	}
      }
    printf("%d\n", count);
  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,v,m,p;
ll a[100001];
ll b[100001];
bool check(int id){
	ll duh=0;
	int z=n-1;
	for(int i=1; i<=n ;i++){
		if(i!=id) b[i-(i>id)]=a[i];
	}
	ll sum=0;
	for(int i=z; i>v ;i--) sum+=b[i];
	ll gd=b[z];
	for(int i=v; i>=1 ;i--){
		sum+=b[i];
		gd=max(gd,(sum+m*(v-i+1)+z-i)/(z-i+1));
	}
	return (a[id]+m>=gd);
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m >> v >> p;
	for(int i=1; i<=n ;i++){
		cin >> a[i];
	}
	sort(a+1,a+n+1);
	if(v<=p){
		ll ans=0;
		for(int i=1; i<=n ;i++){
			if(a[i]+m>=a[n-p+1]) ans++;
		}
		cout << ans << '\n';
		return 0;
	}
	v-=p;n-=p-1;
	int l=1,r=n;
	while(l!=r){
		int mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	cout << n+p-l << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=3e3+10;
const int MOD=1e9+7;

int N;
int ct[4];
void input(){
    cin>>N;
    rep(_,N){
        int a;
        cin>>a;
        ct[a]++;
    }
}

double dp[301][301][301];
void solve(){
    rep(k,N+1)rep(j,N+1)rep(i,N+1)if(i+j+k<=N){
        if(i==0 && j==0 && k==0)dp[i][j][k]=0;
        else{
            double tmp=N;
            if(i>=1)tmp+=i*dp[i-1][j][k];
            if(j>=1)tmp+=j*dp[i+1][j-1][k];
            if(k>=1)tmp+=k*dp[i][j+1][k-1];
            dp[i][j][k]=tmp/(i+j+k);
        }
    }
}

void output(){
    cout<<fixed;
    cout<<setprecision(12)<<dp[ct[1]][ct[2]][ct[3]]<<endl;
}

int main(){
    input();
    solve();
    output();
}

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

char arr[100][100];

int main()
{
    int n,m;
    cin>>n>>m;
    int cnt=0;

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

        for(int j=0;j<m;j++)
        {
            cin>>arr[i][j];
            if(arr[i][j]=='#')
                cnt++;
        }
    }

    if(arr[0][0]!='#'||arr[n-1][m-1]!='#')
        cout<<5/0;

    if(cnt!=n+m-1)
        {
            cout<<"Impossible";
            return 0;
        }

    int i=0,j=0;
    int flag=0;
    while(i<n&&j<m)
    {
        if(i==n-1&&j==m-1)
            {
                flag=1;
                break;
            }
        if(j+1<m&&arr[i][j+1]=='#')
        {
            j++;
            continue;
        }
        if(i+1<n&&arr[i+1][j]=='#')
        {
            i++;
            continue;
        }
        break;
    }
    if(flag==1)
        cout<<"Possible";
    else
        cout<<"Impossible";

    return 0;
}


Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}
fn solve(s: Vec<char>) -> usize {

    let mut max = std::usize::MAX;
    let mut lastc = s[0];
    for (i, c) in s.iter().enumerate() {
        if lastc != *c {
            let k = std::cmp::max(i, s.len()-i);
            if k < max {
                max = k;
            }
            lastc = *c;
        }
    }

    if max == std::usize::MAX { s.len() } else { max }
}

fn main() {
    let s = read_line!();

    println!("{}", solve(s.chars().collect()));
}

#[test]
fn solve_test() {
    assert_eq!(solve("010".chars().collect()), 2);
    assert_eq!(solve("00001111".chars().collect()), 4);
    assert_eq!(solve("100000000".chars().collect()), 8);

    assert_eq!(solve("0110".chars().collect()), 3);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/

void go(){
    ll n;
    R(n);
    ll mi=1e16;
    rep(i,1,5){
        ll x;
        R(x);
        mi=min(mi,x);
    }
    ll ans=5;
    n-=mi;
    if(n>0){
        ans+=n/mi;
        if((n%mi)!=0){
            ans++;
        }
    }
    W(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll min(ll a,ll b)
{
  return a < b ? a : b;
}
ll func(vector<ll> val,vector<ll> wt,ll n,ll W)
{
  ll i,j,V=0;
  ll res=-1;
  for(i=0;i<n;i++)
    V+=val[i];
  
  int dp[n+1][V+1];
  for(i=0;i<=V;i++)
    dp[0][i]=INT_MAX;
  for(i=0;i<=n;i++)
    dp[i][0]=0;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=V;j++)
    {
      if(val[i-1]<=j)
        dp[i][j]=min(wt[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
     else
        dp[i][j]=dp[i-1][j];
    }
  }
  for(i=0;i<=V;i++)
  {
    if(dp[n][i]<=W)
      res=max(res,i);
      
  }
  return res;
}
int main()
{
  ll n,W,val,wt;
  vector<ll> v,w;
  cin>>n>>W;
  ll i;
  for(i=0;i<n;i++)
  {
    cin>>wt>>val;
    v.push_back(val);
    w.push_back(wt);
  }
  cout<<func(v,w,n,W)<<"\n";
}


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

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

    vector<int> a(n,0);
    int max=1;
    int min=1000000000;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]>max){
            max=a[i];
        }
        if(a[i]<min){
            min=a[i];
        }
    }

    int t=abs(max-min);
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    vector<int> a(n), a_cp(n);
    for (int i = 0; i < n; i++) {
        int c; cin >> c;
        a[i] = c; a_cp[i] = c;
    }
    
    sort(a_cp.begin(), a_cp.end(), greater<int>());
    if (a_cp[0] == a_cp[1]) {
        int c = a_cp[0];
        for (int i = 0; i < n; i++) {
            cout << c << endl;
        }
    } else {
        int M = a_cp[0], secM = a_cp[1];
        for (int i = 0; i < n; i++) {
            if (a[i] == M) cout << secM << endl;
            else cout << M << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3200
a = input()
# print(a)
if a[1]==a[0]:
    if a[3]==a[2] and a[3]!=a[0]:
        print("Yes")
    else:
        print("No")
else:
    if a[2]==a[0]:
        if a[3]==a[1]:
            print("Yes")
        else:
            print("No")
    elif a[2]==a[1]:
        if a[3]==a[0]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

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

int main() {
  char a[3];
  char b[3];
  
  cin >> a[0];
  cin >> a[1];
  cin >> a[2];
  cin >> b[0];
  cin >> b[1];
  cin >> b[2];
  
  int ans = 0;
  
  for(int i = 0;i < 3;i++){
    if(a[i] == b[i]){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define M 100
#define MX 1000000
int min(int ,int);
int main(){
  int k,j,l,i,n,p[M+1],m[M+1][M+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
    j=i+l-1;
    m[i][j]=MX;
    for(k=i;k<=j-1;k++){
      m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
    }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}

int min(int a,int b){
  if(a<b)return a;
  else return b;
}



Measured memory_bytes: 2048
#include <stdio.h>

int main(){
  int n, i, j, sum, sum2 = 0;

  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    sum = 0;
    if(i % 2){
      for(j = 1; j <= i; j++){
        if(i % j == 0)
          sum += 1;
      }
    }
  if(sum == 8)
    sum2 += 1;
  }
  printf("%d", sum2);
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

ll pw[20];


ll s(ll n) {
    ll ans = 0;
    while (n != 0) {
        ans += (n % 10);
        n /= 10;
    }
    return ans;
}

vector<ll> ketaList(ll n) {
    vector<ll> a(20);
    for (ll j = 0; j < 16; j++) {
        a[j] = n % 10;
        n /= 10;
    }
    return a;
}

int main() {
    pw[0] = 1;
    for (ll i = 1; i < 20; i++) pw[i] = pw[i - 1] * 10;
    ll k;
    cin >> k;
    ll now = 1;
    for (ll i = 0; i < k; i++) {
        vector<ll>keta_list = ketaList(now);
        for (ll j = 0; j < 16; j++) {
            if (keta_list[j] == 9) continue;
            if (now * s(now + pw[j] * 9) < (now + pw[j] * 9) * s(now)) {
                break;
            } else {
                now += (9 - keta_list[j]) * pw[j];
            }
        }
        cout << now << endl;
        now++;
    }

}




Measured memory_bytes: 256
fn main() {
    let abc = read_vec::<i32>();

    let a = abc[0];
    let b = abc[1];
    let c = abc[2];

    if c - a + b > 0 {
        println!("{}", c - a + b);
    } else {
        println!("{}", 0);
    }

}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    vi v(3);
    rep(i,3)cin>>v[i];
    sort(v.begin(),v.end(),greater<int>());
    int tsum=0;
    rep(i,3){
        tsum+=v[i];
    }
    if(tsum%2==(3*v[0])%2){
        cout<<(3*v[0]-tsum)/2<<endl;
    }
    else{
        cout<<(3*(v[0]+1)-tsum)/2<<endl;
    }
}




Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	static int N,W;
	static int v[]=new int[10000];
	static int w[]=new int[10000];
	public static void main(String[] args) {
		 N=sc.nextInt();
		 W=sc.nextInt();
		for(int i=0;i<N;i++) {
			v[i]=sc.nextInt();
			w[i]=sc.nextInt();
		}
		p(search(0,W));
	}
	static int res;
	static int memo[][]=new int[110][10001];
	static boolean done[][]=new boolean[110][10001];
	static int search(int i,int weight) {
		if(done[i][weight])return memo[i][weight];
		if(i>N) {
			return 0;
		}
		if(w[i]>weight)res= search(i+1,weight);
		else res=Math.max(search(i+1,weight), search(i+1,weight-w[i])+v[i]);
		memo[i][weight]=res;
		done[i][weight]=true;
		return res;
	}
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	



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

int X,Y,Z;

int main(int argc, char const *argv[])
{
   // freopen("in.txt", "r", stdin);
    while(~scanf("%d%d%d", &X, &Y, &Z)) {
        X -= Z;
        printf("%d\n", X/(Y+Z));
    }
    return 0;
}

Measured memory_bytes: 256