akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};


int main(){

    // input
    ll h, w, k;
    cin >> h >> w >> k;
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    VS s(h);
    rep(i, 0, h) cin >> s[i];

    const ll inf = 1e18;
    VVL d(h, VL(w, inf));
    
    queue<PL> que;
    que.push({x1, y1});
    d[x1][y1] = 0;
    while(!que.empty()){
        auto q = que.front();
        que.pop();
        rep(i, 0, 4){
            rep(j, 1, k+1){
                ll nx = q.first + j * d1[i];
                ll ny = q.second + j * d2[i];
                 if(nx < 0 || nx >= h) break;
                if(ny < 0 || ny >= w) break;
                if(s[nx][ny] == '@') break;
                if(d[nx][ny] <= d[q.first][q.second]) break;
                if(d[nx][ny] == inf) {
                    d[nx][ny] = d[q.first][q.second] + 1;
                    que.push({nx, ny});
                }
            }
        }
    }

    ll ans = d[x2][y2];
    cout << (ans == inf ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 19988
#include<algorithm>
#include<iostream>
#include<cstdio>
typedef long long ll;
using namespace std;
struct Node{
	int h,p;
}a[5005];
int n;
ll f[5005][5005];
bool cmp(Node a,Node b){
	return a.h+a.p<b.h+b.p;
}
int main(){
	ios::sync_with_stdio(false);
	int i,j;
	cin>>n;
	fill(f[0],f[0]+n+1,2e9+1);
	for(i=1;i<=n;i++)
		cin>>a[i].h>>a[i].p;
	sort(a+1,a+n+1,cmp);
	f[0][0]=0;
	for(i=1;i<=n;i++)
		for(j=0;j<=n;j++){
			f[i][j]=f[i-1][j];
			if(j&&f[i-1][j-1]<=a[i].h)
				f[i][j]=min(f[i][j],f[i-1][j-1]+a[i].p);
		}
	for(i=n;i>=0;i--)
		if(f[n][i]<=2e9)
			break;
	cout<<i;
	return 0;
}


Measured memory_bytes: 199248
#include <bits/stdc++.h>
using namespace std;
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAX_N = 100005, MAX_M = 200010;
// code
#define int long long
vector<pii> g[MAX_M];
int dist[MAX_M], n, m;
void dfs(int u){
    //cout << u << ' ';
    for (auto v:g[u]){
        if (dist[v.F] != INT_MIN){
            if (dist[v.F] != dist[u] + v.S){
                cout << "No";
                exit(0);
            }
        }else{
            dist[v.F] = dist[u] + v.S;
            dfs(v.F);
        }
    }
}
void Solve() {
    cin >> n >> m;
    //cout << n << ' ' << m;
    for (int i = 1; i <= n; i++){
        dist[i] = INT_MIN;
        //cout << "?";
    }
    for (int j = 1; j <= m; j++){
        int u, v, d;
        cin >> u >> v >> d;
        g[u].eb(v, d);
        g[v].eb(u, -d);
    }
    
    for (int i = 1; i <= n; i++){
        //cout << "? ";
        if (dist[i] == INT_MIN){
            dist[i] = 0;
            dfs(i);
        }
        //cout << dist[i] << ' ';
    }
    
    cout << "Yes";
}

signed main(){
    FAST_IO;
    int TC = 1; 
	//cin >> TC;
    while(TC--) Solve();
    return 0;
}


Measured memory_bytes: 22168
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll func(ll m, const vector<ll>& a) {
	ll res = 0;
	for (auto v : a) {
		res += (m % v);
	}

	return res;
}

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

	int n;
	cin >> n;

	vector<ll> a(n);
	for (auto& v : a) {
		cin >> v;
	}
	
	ll ans = accumulate(begin(a), end(a), 0LL, [](ll res, ll v) { return res + (v - 1); });
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
bl=int(input())
bldict={}
for i in range(bl):
    s=input()
    if(s in bldict):
        bldict[s]+=1
    else:
        bldict[s]=1

red=int(input())
reddict={}
for i in range(red):
    s=input()
    if(s in reddict):
        reddict[s]+=1
    else:
        reddict[s]=1

ans=[0]
bllist=bldict.items()
for youso in bllist:
    try:
        ans.append(youso[1] - reddict[youso[0]])
    except:
        ans.append(youso[1])
print(max(ans))

Measured memory_bytes: 3188
#include <iostream>
#include <stack>

using namespace std;

int main() {
	stack<int> st;
	int n,a;

	while(cin >> n){
		if(n != 0){
			st.push(n);
		}else{
			a = st.top();
			cout << a << endl;
			st.pop();
		}
	}
}

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

using namespace std;

const int MOD = 1e9 + 7;

int n,k,i,j,a[105];
long long dp[2][105][305];

int main(){
	scanf("%d%d", &n, &k);
	for(i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	dp[0][0][0] = 1;
	
	for(i = 0; i < n; i++){
		for(j = 0; j <= n; j++){
			for(int ii = 0; ii <= 255; ii++){
				dp[(i + 1) & 1][j][ii] = dp[i & 1][j][ii];
			}
			
			if(j > 0){
				for(int ii = 0; ii <= 255; ii++){
					int newval = ii ^ a[i];
					dp[(i + 1) & 1][j][newval] = (dp[(i + 1) & 1][j][newval] + (dp[i & 1][j - 1][ii] * j) % MOD) % MOD;
				}
			}
		}
	}
	
	long long res = 0;
	
	for(i = 1; i <= n; i++)
	res = (res + dp[n & 1][i][k]) % MOD;
	
	printf("%lld\n", res);
}


Measured memory_bytes: 768
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

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

	return 0;
}


Measured memory_bytes: 256
Y,N = gets.split.map(&:to_i)
a = 0
while a * 10000 <= N
  b = 0
  while b * 5000 + a * 10000 <= N
    c = (N - (a * 10000 + b * 5000)) / 1000
    if(a+b+c==Y&&a*10000+b*5000+c*1000==N)
      puts "#{a} #{b} #{c}"
      exit
    end
    b += 1
  end
  a += 1
end
puts "-1 -1 -1"

Measured memory_bytes: 1788
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean flag = false;
		int x = n / 7;
		while (x >= 0) {
			if ((n - 7 * x) % 4 == 0) {
				flag = true;
				break;
			}
			x -= 1;
		}
		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21716
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
string ans;
void dfs(int a,int b,int c,string aa,string bb,string cc)
{
    string nowa,nowb,nowc;
    if (a==0)
    {
        dfs(b,c,0,bb,cc,"");
        return;
    }
    if ((b==0)&&(c==0))
    {
        int i;
        for (i=0;i<a;i++)
        {
            ans+=aa;
        }
        return;
    }
    nowa=aa;
    int j;
    for (j=0;j<c/a;j++)
    {
        nowa+=cc;
    }
    int newc=c%a;
    nowc=nowa+cc;
    a-=newc;
    for (j=0;j<b/a;j++)
    {
        nowa+=bb;
    }
    int newb=b%a;
    nowb=nowa+bb;
    a-=newb;
    dfs(a,newb,newc,nowa,nowb,nowc);
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    dfs(a,b,c,"a","b","c");
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int n, m, *id, *a, result = 0, known = 0;
vector<int> undefined;
bool isCollectID(void) {
  int sum = 0;
  for (int i = 0; i < undefined.size(); i++) {
    int j = undefined[i];
    if ((n + j) % 2)
      sum += id[j];
    else
      sum += id[j] * 2 >= 10 ? id[j] * 2 - 9 : id[j] * 2;
  }
  return (known + sum) % 10 == 0;
}

void searchCadidate(int i) {
  if (i == undefined.size()) {
      if (isCollectID())
        result++;
  } else {
    /*                                                                                                                                                                                                                                                         
    for (int j = 0; j < n; j++)                                                                                                                                                                                                                                
      if (id[j] > 0)                                                                                                                                                                                                                                           
        cout << id[j];                                                                                                                                                                                                                                         
      else                                                                                                                                                                                                                                                     
        cout << '*';                                                                                                                                                                                                                                           
    cout << endl;                                                                                                                                                                                                                                              
    */
    for (int j = 0; j < m; j++) {
      id[undefined[i]] = a[j];
      searchCadidate(i + 1);
    }
  }
}

int main(int argc, char *argv[]) {
  string s;
  cin >> n;
  cin >> s;
  cin >> m;
  a = new int[m];
  for (int i = 0; i < m; i++)
    cin >> a[i];
  id = new int[n];
  for (int i = 0; i < n; i++)
    if (s[i] == '*') {
      id[i] = -1;// test                                                                                                                                                                                                                                       
      undefined.push_back(i);
    } else {
      id[i] = s[i] - '0';
      if ((n + i) % 2)
        known += s[i] - '0';
      else
        known += id[i] * 2 >= 10 ? id[i] * 2 - 9 : id[i] * 2;
    }

  searchCadidate(0);

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1796
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        String s = sc.next();
        String ans = "";
        for (int i = 0; i < s.length(); i++)
            ans += "x";
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 23764
n = int(input())
a = list(map(int, input().split()))

ans = 0
xor = 0
sum = 0
r = 0

for l in range(n):
    while r < n and xor ^ a[r] == sum + a[r]:
        xor ^= a[r]
        sum += a[r]
        r += 1
    
    ans += r - l
    if l == r:
        r += 1
    else:
        sum -= a[l]
        xor ^= a[l]

print(ans)

Measured memory_bytes: 24584
n = int(input())
li = list(map(int,input().split()))
x = 0

for i in range(n):
    if li[i] < 0:
        li[i] *= -1
        x += 1

if x%2 == 0:
    print(sum(li))
else:
    print(sum(li)-min(li)*2)

Measured memory_bytes: 14412
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

ll mod_pow(ll x, ll n) {
	ll ret = 1;
	while (n > 0) {
		if (n % 2)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}
struct perm {
private:
	int sz;
	vector<ll> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		rep1(i, sz - 1) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		per(i, sz - 1) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm p(1 << 15);

ll dp[2001][2001];
ll rdp[2001][2001];

void init() {
	rdp[0][0] = 1;
	dp[1][0] = 1;
	rdp[1][1] = rdp[1][2] = 1;
	for (int i = 2; i <= 2000; i++) {
		for (int j = 0; j < i; j++) {
			dp[i][j] = rdp[i-1][j + 1];
			(rdp[i][j + 1] += rdp[i][j]+dp[i][j])%=mod;
		}
		rdp[i][i + 1] = rdp[i][i];
	}

}

void solve() {
	//cout << dp[3][1] << endl;
	int n, k; cin >> n >> k;
	if (k == 1) {
		cout << mod_pow(2,n-2) << endl; return;
	}
	if (k == n) {
		cout << rdp[n - 1][n - 1] << endl; return;
	}

	ll ans = 0;
	for (int x = 0; x <= k-1; x++) {
		ll csum = p.comb(n - x - 2, k - 1 - x);
		//p.comb(k - 1, x) % mod;

		csum = csum * rdp[k-1][x+1] % mod;
		csum = csum * mod_pow(2, n - k-1) % mod;
		ans += csum; ans %= mod;
	}
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	init();
	solve();
	//stop
	return 0;
}


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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int x,y; cin >> x >> y;
    int a = 2*x;
    if(y < 2*x || y > 4*x || (y-a)%2==1) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    set<char> se;
    rep(i, 4){
        se.insert(s[i]);
    }
    if(se.size() != 2){
        cout << "No" << endl;
        return 0;
    }
    char c = s[0];
    int count = 1;
    rep(i, 4){
        if(c == s[i]) count++;
    }
    if(count == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			int n = Integer.parseInt(br.readLine());
			if (n == 0) break;

			ArrayList<Integer> number = new ArrayList<Integer>();
			ArrayList<Long> outCome = new ArrayList<Long>();

			for (int i = 0; i < n; i++) {
				String[] str = br.readLine().split(" ");
				int num = Integer.parseInt(str[0]);
				long price = Integer.parseInt(str[1]);
				long cnt = Integer.parseInt(str[2]);
				if (number.contains(num)) {
					int index = number.indexOf(num);
					outCome.set(index, outCome.get(index) + (price * cnt));
				} else {
					number.add(num);
					outCome.add(price * cnt);
				}
			}
			boolean naFlg = true;
			for (int j = 0; j <outCome.size(); j++) {
				if (outCome.get(j) >= 1000000) {
					naFlg = false;
					System.out.println(number.get(j));
				}
			}
			if (naFlg) System.out.println("NA");
		}

	}

}

Measured memory_bytes: 24960
#!/usr/bin/ruby
# encoding: utf-8

x1,y1,x2,y2 = gets.split.map(&:to_i)
x3 = x2+y1-y2
y3 = y2-x1+x2
x4 = x1+y1-y2
y4 = y1-x1+x2

puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

inline void YESNO(bool ans){cout<<(ans?"YES":"NO")<<endl;}
inline void YesNo(bool ans){cout<<(ans?"Yes":"No")<<endl;}
inline void yesno(bool ans){cout<<(ans?"yes":"no")<<endl;}

/*重み付きUnionFind*/
template<typename Type>
struct PotentializedUnionFind{
	vi par;			//par[i]:=(0以上の場合iの親. 0未満の場合はiを含むグループのサイズ).
	vector<Type> w;	//w[i]:=(iがもつポテンシャル).
	int num;		//num:=(グループの数).
	
	PotentializedUnionFind(int n):par(n,-1),w(n,0){}//constructor.
	
	void init(){fill(ALL(par),-1), fill(ALL(w),0), num=par.size();}
	int root(int x){
		if(par[x]<0) return x;
		else{
			int r=root(par[x]);
			w[x]+=w[par[x]];
			return par[x]=r;
		}
	}
	int size(int x){return -par[root(x)];}
	Type weight(int x){
		root(x);
		return w[x];
	}
	bool same(int x,int y){return root(x)==root(y);}
	Type diff(int x,int y){return weight(y)-weight(x);}//xからみたyのポテンシャルの高さ. O(log N).
	bool unite(int x,int y,Type d){
		d=d+weight(x)-weight(y);
		x=root(x), y=root(y);
		if(x==y) return false;
		if(size(x)<size(y)) swap(x,y), d=-d;//merge tec(x<-y).
		par[x]+=par[y];
		par[y]=x;
		w[y]=d;
		num--;
		return true;
	}
};

//解説参考.
int main(){
	int n,m;
	cin>>n>>m;
	
	PotentializedUnionFind<llong> uf(n);
	bool ans=true;
	REP(i,m){
		int l,r,d;
		cin>>l>>r>>d;
		l--, r--;
		if(uf.same(l,r)){
			if(uf.diff(l,r)==d){}
			else{
				ans=false;
				break;
			}
		}else uf.unite(l,r,d);
	}
	
	YesNo(ans);
}

Measured memory_bytes: 4552
S=input()
K=int(input())
N=len(S)
ans=None
if len(set(S))==1:
    ans=N*K//2
else:
    li=[]
    i=0
    while(i<N):
        j=i
        c=S[i]
        cnt=0
        while(j<N and c==S[j]):
            cnt+=1
            j+=1
        li.append((c,cnt))
        i=j
    res=0
    if li[0][0]!=li[-1][0]:
        for x,y in li:
            res+=y//2
        ans=res*K
    else:
        for i in range(1,len(li)-1):
            res+=li[i][1]//2
        ans=res*K+li[0][1]//2+li[-1][1]//2+(li[0][1]+li[-1][1])//2*(K-1)
print(ans)

Measured memory_bytes: 9104
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long M,A[1<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A,A+N);
	long L=0,R=3e5;
	while(R-L>1)
	{
		long mid=(L+R)/2;
		long cnt=0;
		int id=N;
		for(int i=0;i<N;i++)
		{
			while(id>i&&A[id-1]+A[i]>=mid)id--;
			if(id<i)id=i;
			cnt+=(N-id)*2-(i>=id);
		}
		if(cnt<=M)
		{
			R=mid;
		}
		else L=mid;
	}
	long rest=M;
	long ans=0;
	int id=N;
	long sum=0;
	for(int i=0;i<N;i++)
	{
		while(id>i&&A[id-1]+A[i]>=R)
		{
			id--;
			sum+=A[id];
		}
		while(id<i)sum-=A[id++];
		rest-=(N-id)*2-(i>=id);
		if(i<id)
		{
			ans+=A[i]*(N-id)*2+2*sum;
		}
		else
		{
			ans+=A[i]*(N-id)*2+2*(sum-A[i]);
		}
	}
	ans+=rest*L;
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int compare(const void *a, const void *b){
	long long *A = (long long *)a;
	long long *B = (long long *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}

int main(){
	long long N,M,i,ans=0;
	scanf("%lld%lld",&N,&M);
	
	long long x[N],y[N],z[N];
	for(i=0;i<N;i++)scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
	
	for(int k=0;k<8;k++){
		int bit=k;
		long long value[N];
		long long tmp=0;
		for(i=0;i<N;i++)value[i]=0;
		
		if(bit%2==0)for(i=0;i<N;i++)value[i]+=x[i];
		else for(i=0;i<N;i++)value[i]-=x[i];
		
		bit/=2;
		if(bit%2==0)for(i=0;i<N;i++)value[i]+=y[i];
		else for(i=0;i<N;i++)value[i]-=y[i];
		
		bit/=2;
		if(bit%2==0)for(i=0;i<N;i++)value[i]+=z[i];
		else for(i=0;i<N;i++)value[i]-=z[i];
		
		qsort(value,N,sizeof(long long),compare);
		
		for(i=0;i<M;i++)tmp+=value[i];
		if(tmp>ans)ans=tmp;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int t1,t2,i,j,k,n,m;
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++){
		scanf("%d",&j);
		if (j&1) t1++;else t2++;
	}
	puts((t1&1)?"NO":"YES");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  string s;
  cin >> s;
  ll res = 0;
  vector <char> v = {'A', 'C', 'G', 'T'};
  rep(i, s.size()) {
    ll tmp = 0;
    for (ll j = i; j < s.size(); j++) {
      bool flag = 0;
      rep(k, 4) {
        if (s.at(j) == v.at(k)) flag = 1;
      }
      if (flag) {
        tmp++;
      } else {
        break;
      }
    }
    chmax(res, tmp);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush, heappushpop

heap = []
# データの入力
while True:
    tmp = input()
    if tmp.startswith('end'):
        break
    elif tmp.startswith('insert'):
        k = int(tmp.split()[1])
        heappush(heap, -k)
    elif tmp.startswith('extract'):
        print(-heappop(heap))


Measured memory_bytes: 45308
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
    char a[11], b[11], c[11];
 
    cin >> a >> b >> c;
 
    if(a[strlen(a)-1] == b[0] && b[strlen(b)-1] == c[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
 
    return 0;
 
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 3e3+5;
const int MOD = 1e9+7;

double dp[MSIZE][MSIZE];
double pr[MSIZE];
double prob(int n,int x) {
    if(n==0)    return x==0;
    if(x==0)    return (1-pr[n])*prob(n-1,x);
    if(dp[n][x] != -1)  return dp[n][x];
    return dp[n][x] = pr[n]*prob(n-1,x-1) + (1-pr[n])*prob(n-1,x);
}

int main(){
    FIO
    int n; cin>>n;
    f(i,1,n)    cin>>pr[i];

    f(i,0,n)    f(j,0,n)  dp[i][j] = -1;

    double ans = 0;
    f(i,(n+1)/2,n)  ans+=prob(n,i);
    cout<<setprecision(10)<<ans<<endl;
    
    return 0;

}
    


Measured memory_bytes: 70912
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	vector<int> n(3);
	for (int i = 0; i < 3; i++)cin >> n[i];
	sort(n.begin(), n.end());
	int ans = 10 * n[2] + n[1] + n[0];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1000000000100000000;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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(){
    int R, C, K; cin >> R >> C >> K;
    vector<vector<ll>> items(R, vector<ll>(C));
    rep(i, K){
        int r, c; ll v; cin >> r >> c >> v; r--, c--;
        items[r][c] = v;
    }

    vector<vector<vector<ll>>> dp(R, vector<vector<ll>>(C, vector<ll>(4)));
    dp[0][0][0] = 0;
    if(items[0][0])dp[0][0][1] = items[0][0];

    rep(i, R){
        rep(j, C){
            rep(k, 4){
                if(dp[i][j][k] == -1)continue;
                //右に遷移
                if(j < C-1){
                    //アイテムを拾う
                    if(k < 3 && items[i][j+1]){
                        chmax(dp[i][j+1][k+1], dp[i][j][k] + items[i][j+1]);
                    }
                    //拾わない
                    chmax(dp[i][j+1][k],dp[i][j][k]);
                }
                //下に遷移
                if(i < R-1){
                    //アイテムを拾う
                    if(items[i+1][j]){
                        chmax(dp[i+1][j][1], dp[i][j][k] + items[i+1][j]);
                    }
                    //拾わない
                    chmax(dp[i+1][j][0], dp[i][j][k]);
                }
            }
        }
    }
    ll res = 0;
    rep(k, 4)chmax(res, dp[R-1][C-1][k]);
    cout << res << ln;
}


Measured memory_bytes: 706672
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N = int(readline())
XY = (tuple(int(x)-1 for x in line.split()) for line in readlines())

graph = [[] for _ in range(N)]
for x,y in XY:
    graph[x].append(y)
    graph[y].append(x)

visited = [True] + [False] * (N-1)
q = [0]
ord = [0]
par = [0] * N
while q:
    x = q.pop()
    for y in graph[x]:
        if visited[y]:
            continue
        ord.append(y)
        par[y] = x
        visited[y] = True
        q.append(y)

G = [0] * (N+1)
for x in ord[:0:-1]:
    p = par[x]
    G[p] ^= (G[x]+1)

answer = 'Alice' if G[0] != 0 else 'Bob'
print(answer)


Measured memory_bytes: 28588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  rep(i, N)
  {
    cin >> A[i];
  }
  rep(i, M)
  {
    cin >> B[i];
  }

  rep(y, N - M + 1) rep(x, N - M + 1)
  {
    bool is_ok = true;
    rep(i, M)
    {
      if (A[y + i].substr(x, M) == B[i])
      {
      }
      else
      {
        is_ok = false;
      }
    }
    if (is_ok)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

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

int main(void){
    string S;
    int al[26];

    cin>>S;

    for(int i=0;i<26;i++)
        al[i]=0;

    for(int i=0;i<S.length();i++){
        int n=S[i]-'a';
        al[n]++;
    }


    for(int i=0;i<26;i++){
        if(al[i]==0){
            char a=i+'a';
            cout<<a<<endl;
            return 0;
        }
    }

    cout<<"None"<<endl;

    return 0;
}


Measured memory_bytes: 512
K = int(input())

def f(n, k, a):
    if k == n:
        return 1
    res = 0
    res += f(n, k+1, a)
    if a > 0:
        res += f(n, k+1, a-1)
    if a < 9:
        res += f(n, k+1, a+1)
    return res


cnt = 0
for n in range(1, 12):
    c2 = 0
    for a in range(1, 10):
        c2 += f(n, 1, a)
        if cnt+c2 >= K:
            num = n
            ini = a
            cnt += c2-f(n, 1, a)
            c2 = -1
            break
    if c2 < 0:
        break
    cnt += c2

ans = [ini]
for k in range(2, num+1):
    for a in range(max(0, ans[-1]-1), min(10, ans[-1]+2)):
        cnt += f(num, k, a)
        if cnt >= K:
            ans.append(a)
            cnt -= f(num, k, a)
            break

for i in range(len(ans)):
    ans[i] = str(ans[i])
print("".join(ans))

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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    }
    vector<int> memo(N);
    
    memo.at(0) = 0;
    memo.at(1) = abs(A.at(1)-A.at(0));
    for (size_t i = 2; i < N; i++)
    {
        memo.at(i) = min(memo.at(i-2)+abs(A.at(i-2)-A.at(i)),memo.at(i-1)+abs(A.at(i-1)-A.at(i)));
    }
    cout << memo.at(N-1) << endl;

    return 0;
}

Measured memory_bytes: 3976
#include <algorithm>
#include <iostream>
typedef long long lld;
lld A, B, K;
lld M;

void fastio() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

int main() {
  fastio();
  std::cin >> A >> B >> K;
  M = std::min(A, K);
  A -= M;
  K -= M;
  M = std::min(B, K);
  B -= M;
  K -= M;
  std::cout << A << ' ' << B << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;


int main(){
	ll N,M,X; cin >> N >> M >> X;
    vector<ll> C(N,0);
    ll A[N][M] = {};
    REP(i,N){
      cin >> C[i];
      REP(j,M) cin >> A[i][j];
    }
    ll ans = 1000000000; 
    vector<int> S(M,0);
    ll tmp = 0;
  // {0, 1, ..., n-1} の部分集合の全探索
    for (ll bit = 0; bit < (1<<N); ++bit) {
        REP(i,M) S[i] = 0;
        tmp = 0;
        for (ll i = 0; i < N; ++i) {
            if (bit & (1<<i)){
              tmp += C[i];
              REP(j,M) S[j] += A[i][j];
            }
        }
        bool flg = true;
        REP(i,M) if(S[i] < X) flg = false;
        if(flg) ans = min(ans, tmp);
    }
    if(ans == 1000000000) cout << "-1";
    else cout << ans;
     
  	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <string>
#define MAX 100007
#define scn1(a) scanf("%d", &a);
#define scn2(a, b) scanf("%d %d", &a, &b);
#define scn3(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define lscn1(a) scanf("%lli", &a);
#define lscn2(a, b) scanf("%lli %lli", &a, &b);
#define lscn3(a, b, c) scanf("%lli %lli %lli", &a, &b, &c);
#define prnt(a) printf("%d\n", a);
#define forr(i, a, n) for(int i=a;i<n;i++)
#define nl puts("");
#define enl cout << "\n";
#define CHK(a) cout << (#a) << " = " << (a) << endl;
typedef long long int ll;
using namespace std;
void LOOPCHK(int a[],int n){for(int i=0;i<n;i++)cout<<a[i]<<" ";enl;}

int n, a[21], b[21][21], c[21][21];

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll tt=1;

    // cin >> tt;
    for(int cse=1; cse<=tt; cse++)
    {
        int ans=0;
        cin >> n;
        forr(i, 1, n+1)
        {
            cin >> a[i];
        	forr(j, 1, a[i]+1) cin >> b[i][j] >> c[i][j];
        }
        forr(i, 1, (1<<n))
        {
        	bool flg = 1;
        	forr(j, 1, n+1)
        	{
        		if( !(i & (1<<(j-1)))  ) continue;
        		forr(k, 1, a[j]+1) if(((i >> (b[j][k]-1)) & 1) ^ c[j][k]) flg = false;
        	}
        	if(flg)
        	{
        		int nm = i, cnt = 0;
        		while(nm!=0)
        		{
        			cnt += (nm&1);
        			nm >>= 1;
        		}
        		ans = max(ans, cnt);
        	}
        }
        // cout << "Case " << cse <<  ": ";
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3548
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;

public class Main {
	static int n;
	static long half;
	static int[] a;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		half = (long) n * (n + 1) / 4;
		TreeSet<Integer> set = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			set.add(a[i]);
		}
		Integer[] arr = set.toArray(new Integer[0]);

		int ok = -1;
		int ng = arr.length;
		while (Math.abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if (judge(arr[mid])) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		System.out.println(arr[ok]);
	}

	static boolean judge(int med) {
		int[] b = new int[n + 1];
		for (int i = 0; i < n; i++) {
			if (a[i] >= med) {
				b[i + 1] = 1;
			} else {
				b[i + 1] = -1;
			}
		}
		for (int i = 1; i < b.length; i++) {
			b[i] += b[i - 1];
		}

		long t = tentousuu(b);
		return t <= half;
	}

	static long tentousuu(int[] a) {
		int n = a.length;
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, a[i]);
			max = Math.max(max, a[i]);
		}
		min--;
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = a[i] - min;
		}

		BIT bit = new BIT(max - min);
		long ret = 0;
		for (int i = 0; i < n; i++) {
			ret += i - bit.sum(b[i]);
			bit.add(b[i], 1);
		}
		return ret;
	}

	static class BIT {
		int n;
		long[] arr;

		public BIT(int n) {
			this.n = n;
			arr = new long[n + 1];
		}

		void add(int idx, long val) {
			for (int i = idx; i <= n; i += i & -i) {
				arr[i] += val;
			}
		}

		long sum(int idx) {
			long sum = 0;
			for (int i = idx; i > 0; i -= i & -i) {
				sum += arr[i];
			}
			return sum;
		}
	}
}


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

	int a;
	int b;
	int c;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a < b && b < c)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


Measured memory_bytes: 2560
n=int(input())
l=list(map(int,input().split()))
Flag=1
cnt=0
for i in range(10**9):
    for j in range(n):
        if l[j]%2==0:
            l[j]//=2
        else:
            Flag=0
    if Flag==0: break
    cnt+=1
print(cnt) 

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin>>n;
  int a[n],b[n];
  for(i=0;i<n;i++){
	  cin>>a[i]>>b[i];
  }
  int count = 0;
  for(i=0;i<n;i++){
	  if(a[i]==b[i]){
		  count++;
	  }
	  else if(count<3){
		  count=0;
	  }
  }
  if(count>=3){
	  cout<<"Yes"<<endl;
  }
  else{
	  cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
constexpr int MOD = 1000000007;

typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned int ui;

template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;

struct input {
	std::istream &cin;
	explicit input(std::istream &cin) :cin(cin){}
	template <typename T> operator T() { T t; cin >> t; return t; }
};
#define $ input{cin}

int logceil(ll x) {int b=0;while(x){x>>=1;++b;}return b;}

namespace std {
    template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector<vector<T>>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector<vector<T>>>(a,vector<vector<T>>(b,vector<T>(c,t))){}};

// #include "../l/mod.h"

class E {
public:
    void solve(istream& cin, ostream& cout) {
		int N; cin >> N;
		vector<int> C(N, 0);
		int f = 0;

		int x1=MOD,x2=0,y1=MOD,y2=0;

		vector<pii> R(2*N);
		for (int i = 0; i < N; ++i) {
			int a,b; cin >> a >> b;
			if (a>b) swap(a,b);
			x1=min(x1,a);
			x2=max(x2,a);
			y1=min(y1,b);
			y2=max(y2,b);
			R[2*i]={a,i};
			R[2*i+1]={b,i};
		}

		sort(R.begin(),R.end());
		ll spread = R[2*N-1].x-R[0].x;
		ll ans = (ll)(x2-x1) * (ll)(y2-y1);
		int i = 0;
		for (int j = 0; j < 2*N; ++j) {
			if (C[R[j].y]++ == 0) {
				++f;
				if (f==N) {
					while (C[R[i].y] == 2) {
						C[R[i].y]--;
						i++;
						ans = min(ans, spread * (ll) (R[j].x - R[i].x));
					}

					C[R[i].y]--;
					i++;
					--f;
				}
			}



		}

		cout << ans << endl;

    }
};


int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	E solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



Measured memory_bytes: 4224
using System;
class Program {
    static void Main() {
        int inputSec = int.Parse(Console.ReadLine());
        int h = inputSec / 3600;
        int m = inputSec / 60 % 60;
        int s = inputSec % 60;

        Console.WriteLine("{0}:{1}:{2}", h, m, s);
    }
}

Measured memory_bytes: 9152
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		String str=sc.nextLine();
		int count=0;
		for(int i=0;i<str.length();i++){
			char ch=str.charAt(i);
			if(ch=='7'){
				count++;
			}
		}
		
		if(count>0)	System.out.println("Yes");
		else 	System.out.println("No");
	}
}

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

#define MAXN 1005
#define inf 0x3f3f3f3f

int n,m,k,q;
int a[12][MAXN];
int c[12];

void rd() {
	cin >> n >> m >> q;
	for(int i = 1; i <= n; i ++) {
		string s;
		cin >> s;
		for(int j = 1; j <= m; j ++)
			a[i][j] = s[j-1]-'0';
	}
}

int f[12],g[12];
int getans()
{
	int ans = 0;
	memset(f,0,sizeof(f));
	memset(g,0,sizeof(g));
	for(int i = 1; i <= m; i ++) {
		bool fl = 0;
		for(int j = 1; j <= n; ) {
			int k,p = 0;
			for(k = j; k <= n && c[k] == 1; k ++)
				if(c[k]) p += a[k][i];
			p += a[k][i];
		//	cout<<i<<" "<<j<<" "<<k<<"?\n";
			g[j] = p;
			if(g[j] > q) return inf;
			if(g[j] + f[j] > q) {
				fl = 1;
			}
			j = k+1;	
		}
	//	for(int j = 1; j <= n; j ++)
	//		cout<<f[j]<<" "<<g[j]<<"?\n";
	//	cout<<"\n";
		if(fl) {
			ans ++;
			for(int j = 1; j <= n; j ++)
				f[j] = g[j];
		} else {	
			for(int j = 1; j <= n; j ++)
				f[j] += g[j];
		}
	}
//	cout<<ans<<"?\n";
	return ans;
}

int an = inf;

void dfs(int x,int h)
{
	if(x == n) {
	/*	cout<<"---------";
		for(int i = 1; i <= n; i ++)
			cout<<c[i]<<" ";
		cout<<"---------\n";
	*///	if(an == 3) while(1);
		an = min(an,h+getans());
		return;
	}
	c[x] = 0;
	dfs(x+1,h+1);
	c[x] = 1;
	dfs(x+1,h);
}

signed main()
{
	rd();
	dfs(1,0);
	cout<<an;
	
	return 0;
}
/*
6 8 4
1100 0011
0110 1001

1001 0100
0011 1001

0110 0101
1001 1010


11 000011
01 101001
10 010100
00 111001
01 100101
10 011010


*/

Measured memory_bytes: 256
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int a[100010];
map<int,int> mp;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	int mx=0;
	for(int i=0;i<n;i++)mx=max(mx,mp[a[i]]+mp[a[i]-1]+mp[a[i]+1]);
	cout<<mx<<endl;
	return 0;
}

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

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(), h.end());
  vector<int> h_diff(n - 1);
  for(int i = 0; i < n - 1; i++) h_diff[i] = h[i + 1] - h[i];
  int diff = 0;
  for(int i = 0; i < k - 1; i++) diff += h_diff[i];
  int diff_min = diff;
  int left = 1; int right = k;
  while(right < n){
    diff = diff - h_diff[left - 1] + h_diff[right - 1];
    diff_min = min(diff, diff_min);
    left++;
    right++;
  }
  cout << diff_min << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
const ll MOD = 1e9 + 7;
using namespace std;
ll powermod(ll n, ll x){
	ll ret = 1;
	while(x){
		if(x&1){
			(ret*=n)%=MOD;
		}
		x >>= 1;
		(n*=n)%=MOD;
	}
	return ret;
}
int main(){
	ll N;
	cin >> N;
	ll a = powermod(10, N);
	ll b = (2 * powermod(9, N))%MOD;
	ll c = ((a-b)%MOD+MOD)%MOD;
	ll d = c + powermod(8, N);
	ll e = d % MOD;
	cout << e;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int a,b,c,d,e,k;

int main(){
    cin>>a>>b>>c>>d>>e>>k;

    int pmax=max(a,max(max(b,c),max(d,e)));
    int pmin=min(a,min(min(b,c),min(d,e)));

    string ans;
    if(pmax-pmin<=k){
        ans="Yay!";
    }else{
        ans=":(";
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<assert.h>
#include<vector>
#include<string.h>
#include<algorithm>
#include<memory.h>
#include<cmath>
#include<string>
#include<iostream>
#include<set>
#include<unordered_set>
#include<map>
#include<queue>
#include<functional>
#include<list>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 500005;
const int MM = 1000000007;

ll D[MX], A[MX], B[MX], ans[MX];
int N;

int main()
{
	scanf("%d%lld", &N, A);
	for(int i = 1; i <= N; i++) scanf("%lld", D+i);
	for(int i = 1; i <= N; i++){
		if( A[i-1]*2 <= D[i] ) A[i] = A[i-1];
		else A[i] = abs(A[i-1] - D[i]);
	}
	for(int i = N; i >= 1; i--){
		if( B[i+1]*2+1 < D[i] ) B[i] = B[i+1];
		else B[i] = B[i+1] + D[i];
	}
	for(int i = 1; i <= N; i++){
		if( A[i-1] <= B[i+1] ) ans[i] = 0;
		else ans[i] = 1;
	}
	int Q, a;
	scanf("%d", &Q);
	for(int i = 1; i <= Q; i++){
		scanf("%d", &a);
		printf("%s\n", ans[a]? "YES":"NO");
	}
}


Measured memory_bytes: 17664
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		double c = (double)(b-1)/(a-1);
		System.out.println((int)Math.ceil(c));
		
	}
	
	}

Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>

using namespace std;

const int MAX = 500000;
const int SENTINEL = 2000000000;
int L[MAX/2+2], R[MAX/2+2];
int count = 0;

void merge(int a[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; ++i) L[i] = a[left+i];
    for (int i = 0; i < n2; ++i) R[i] = a[mid+i];
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    int j = 0, k = 0;
    for (int i = left; i < right; ++i) {
        ++count;
        if (L[j] <= R[k]) a[i] = L[j++];
        else a[i] = R[k++];
    }
}

void merge_sort(int a[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(a, left, mid);
        merge_sort(a, mid, right);
        merge(a, left, mid, right);
    }
}

void print(int a[], int n) {
    for (int i = 0; i < n; ++i) {
        if (i) putchar(' ');
        printf("%d", a[i]);
    }
    putchar('\n');
}

int
main(int argc, const char *argv[])
{
    int n;
    int a[MAX];
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    merge_sort(a, 0, n);
    print(a, n);
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 7104
#include <iostream>

using namespace std;

int main() {
int n;
int k;
string s;
cin>>s;
int d=s[3]-48+(s[2]-48)*10;
int f=s[1]-48+(s[0]-48)*10;
if(f<=12&&f>=1&&d<=12&&d>=1)
cout<<"AMBIGUOUS";
else if(d<=12&&d>=1)
cout<<"YYMM";
else if(f<=12&&f>=1)
cout<<"MMYY";

else 
cout<<"NA";


    return 0;
}

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

int N, t[55], ans;
string s[55], X;
 
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s[i] >> t[i];
  }
  cin >> X;
  for (int i = N - 1; i >= 0; i--) {
    if (s[i] == X) break;
    ans += t[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
sonu_verma1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	int h,n;
	cin>>h>>n;
	int a[n],b[n],i,j;
	for(i=0;i<n;i++)
	{
	  cin>>a[i]>>b[i];
	}
	int c[10001]={0};
	for(i=1;i<=h;i++)
		c[i]=INT_MAX;
	for(i=1;i<=h;i++)
	{
		for(j=0;j<n;j++)
		{
			int id=max(0,i-a[j]);
			c[i]=min(c[i],c[id]+b[j]);
		}
	}
	cout<<c[h];
	
 
	return 0;
}

Measured memory_bytes: 256