akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> v(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;a--;b--;
        v[a].push_back(b);v[b].push_back(a);
    }
    rep(i,n){
        cout<<v[i].size()<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define I inline
#define LL long long
using namespace std;
const int N=2e5+5;bool vis[N];LL G,s;
int n,m,X,f[N],sz[N],son[N],rt,o,hd[N],V[N*2],a[N],W[N*2],nx[N*2],t;
struct O{int u,v;LL w;}p[N*50];
int get(int x){return x==f[x]?x:f[x]=get(f[x]);}
I void add(int u,int v,int w){
	nx[++t]=hd[u];V[hd[u]=t]=v;W[t]=w;
}
#define v V[i]
I void getrt(int x,int fa){
	sz[x]=1;son[x]=0;
	for (int i=hd[x];i;i=nx[i])
		if (v!=fa && !vis[v])
			getrt(v,x),sz[x]+=sz[v],
			son[x]=max(son[x],sz[v]);
	son[x]=max(o-sz[x],son[x]);
	if (son[x]<son[rt]) rt=x;
}
void find(int u,int fa,LL w){
	if (w+a[u]<G) G=w+a[u],X=u;
	for (int i=hd[u];i;i=nx[i])
		if (!vis[v] && v!=fa)
			find(v,u,w+W[i]);
}
void ins(int u,int fa,LL w){
	p[++m]=(O){u,X,G+w+a[u]};
	for (int i=hd[u];i;i=nx[i])
		if (!vis[v] && v!=fa)
			ins(v,u,w+W[i]);
}
I void work(int x){
	vis[x]=1;G=2e18;X=0;
	find(x,0,0ll);ins(x,0,0ll);
	for (int i=hd[x];i;i=nx[i])
		if (!vis[v]) rt=0,o=sz[v],
			getrt(v,x),work(rt);
}
#undef v
bool cmp(O A,O B){return A.w<B.w;}
int main(){
	son[0]=1e9;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),f[i]=i;
	for (int x,y,z,i=1;i<n;i++)
		scanf("%d%d%d",&x,&y,&z),
		add(x,y,z),add(y,x,z);
	t=0;o=n;getrt(1,0);work(rt);
	sort(p+1,p+m+1,cmp);
	for (int u,v,i=1;i<=m;i++){
		u=get(p[i].u);v=get(p[i].v);
		if (u!=v) s+=p[i].w;f[u]=v;
	}
	cout<<s<<endl;return 0;
}

Measured memory_bytes: 67584
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i=0;i<n;i++)
            a[i] = sc.nextInt();

        Arrays.sort(a);
        boolean check = false;
         for(int i=0;i<n-1;i++)
         {
             if(a[i]==a[i+1])
             {
                 System.out.println("NO");
                 check = false;
                 break;
             }
             else
                 check = true;
         }
         if(check)
             System.out.println("YES");
    }
}


Measured memory_bytes: 64764
#include<stdio.h>


int main(void){

  int i, j, n;
  long long int max, sum;
  int x[5000];

  while(1){
    scanf("%d", &n);
    if(n==0) break;

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

    for(i=0; i<n; i++){
      if(max<x[i]) max=x[i];
      sum=x[i];
      for(j=i+1; j<n; j++){
	sum+=x[j];
	if(max<sum) max=sum;
      }
    }
    printf("%lld\n", max);
  }

  return(0);
}



Measured memory_bytes: 2120
def count(n):
    c = 1
    while(n>=10):
        n = n//10
        c += 1
    return c
s = 0
n = int(input()) 
x = count(n)-1
for i in range(0,x,+2):
    s += 9*(10**i)
if (x+1) % 2:
    s += n-pow(10,x)+1
print(s)

Measured memory_bytes: 9004
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 1<<18;
const int mxL = 1e5;
llong a[mxN+3],b[mxN+3];
int dep[mxN+3];
llong f[515][100003];
int n,B,q; llong ans;

vector<int> vec;

void dfs0(int pos,int id,llong sum,llong val)
{
	if(sum>mxL) {return;}
	if(pos==vec.size()) {f[id][sum] = max(f[id][sum],val); return;}
	dfs0(pos+1,id,sum,val);
	dfs0(pos+1,id,sum+a[vec[pos]],val+b[vec[pos]]);
}
void dfs(int pos,int id,llong sum,llong val)
{
	if(sum<0) {return;}
	if(pos==vec.size()) {ans = max(ans,val+f[id][sum]); return;}
	dfs(pos+1,id,sum,val);
	dfs(pos+1,id,sum-a[vec[pos]],val+b[vec[pos]]);
}

int main()
{
	n = read();
	for(int i=1; i<=n; i++) b[i] = read(),a[i] = read();
	q = read();
	for(int i=2; i<=n; i++) dep[i] = dep[i>>1]+1; B = n==1?1:(dep[n]+1)/2;// printf("dep=%d B=%d\n",dep[n],B);
	for(int i=2; i<=n; i++) if(dep[i]==B)
	{
		vec.clear(); for(int j=i; j>=1; j>>=1) {vec.push_back(j);}
		int id = i-(1<<B); dfs0(0,id,0ll,0ll);
		for(int j=1; j<=mxL; j++) {f[id][j] = max(f[id][j],f[id][j-1]);}
	}
	while(q--)
	{
		int u = read(),v,lim = read(); vec.clear(); ans = 0ll;
		for(v=u; v>=1; v>>=1) {if(dep[v]==B) {break;} vec.push_back(v);}
		dfs(0,v==0?(1<<B):v-(1<<B),lim,0ll);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 408840
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int main(){
    string s;
    cin >> s;
    s.pop_back();
    while(not s.empty()){
        if(s.size() % 2 == 0){
            bool f = true;
            int half = s.size() / 2;
            rep(i,s.size() / 2){
                if(s[i] != s[i + half]){
                    f = false;
                    break;
                }
            }
            if(f){
                cout << s.size() << endl;
                return 0;
            }
        }
        s.pop_back();
    }
    cout << 0 << endl;
    return 0;
}


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

int main(){
	int n;
	string s;
	cin>>n>>s;
	
	int wsum=0;
	REP(i,n){
		if(s[i]=='.') wsum++;
	}
	
	int bsum=0;
	int ans=wsum;//全部Bのとき.
	REP(i,n){//i番目はW.
		if(s[i]=='#'){
			bsum++;
			ans=min(ans,wsum+bsum);
		}else{
			wsum--;
			ans=min(ans,wsum+bsum);
		}
	}
	
	cout<<ans<<endl;
}//解説参考.

Measured memory_bytes: 640
n,m = gets.split.map(&:to_i)
infos = n.times.map { gets.split.map(&:to_i) }.sort
ans = 0
infos.each do |a,b|
  if b <= m
    ans += a*b
  else
    ans += a*m
  end
  m -= b
  break if m <= 0
end
puts ans

Measured memory_bytes: 12816
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"

int n, m, k;

bool read() {
	if  (scanf("%d%d%d", &n, &m, &k) < 3) {
		return 0;
	}
	return 1;
}

bool solve() {
	forn(i, n + 1) {
		forn(j, m + 1) {
			int cur = i * m + j * n - 2 * i * j;
			// if  (n == 3 && m == 5) {
			// 	eprintf("i = %d, j = %d, cur = %d\n", i, j, cur);
			// }
			if  (cur == k) {
				return 1;
			}
		}
	}
	return 0;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		puts(solve() ? "Yes" : "No");
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	a, _ := strconv.Atoi(Scanner())
	b, _ := strconv.Atoi(Scanner())
	c, _ := strconv.Atoi(Scanner())
	if (c-a-b)*(c-a-b) > 4*a*b && c-a-b > 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n>>m;
  vector<int> p(100010);
  vector<int> y(100010);
  vector<vector<int>>id(100010);
  for(int i=0;i<m;i++){
    cin >> p.at(i)>>y.at(i);
    id.at(p.at(i)-1).push_back(y.at(i));
  }
  for(int i=0;i<n;i++){
    sort(id.at(i).begin(),id.at(i).end());
  }
  for(int i=0;i<m;i++){
    printf("%06d",p.at(i));
    auto itr = lower_bound(id.at(p.at(i)-1).begin(),id.at(p.at(i)-1).end(),y.at(i));
    printf("%06d", itr-id.at(p.at(i)-1).begin()+1);
    cout <<endl;
  }
}

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

//公約数列挙
void div(long long a, vector<long long> &n) {
  n.push_back(1);
  for (long long i = 2; i <= sqrt(a); i++)
    if (a % i == 0) n.push_back(i);
  if (n.at(n.size() - 1) == sqrt(a))
    for (long long i = n.size() - 2; i >= 0; i--)
      n.push_back(a / n.at(i));
  else
    for (long long i = n.size() - 1; i >= 0; i--)
      n.push_back(a / n.at(i));
  return;
}

void comdiv(long long a, long long b, vector<long long> &n) {
  if (a > b) swap(a, b);
  vector<long long> m(0);
  div(a, m);
  for (long long i = 0; i < m.size(); i++)
    if (b % m.at(i) == 0) n.push_back(m.at(i));
  return;
}

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<ll> n(0);
  comdiv(a, b, n);
  cout << n.at(n.size() - k) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int n, balls[10]; cin >> n;
    while(n--){
        for(int i = 0; i < 10; i++) cin >> balls[i];
         
        bool sortable = false;
        for(int i = 0; i < (1 << 10); i++){
            int bit = i;
            bool ok = true;
             
            int top[2] = {0,0}; //top[0]: B, top[1]: C
            for(int j = 0; j < 10; j++){
                if(top[bit & 1] > balls[j]){
                    ok = false; break;
                }
                top[bit & 1] = balls[j];
                bit >>= 1;
            }
             
            if(ok) {
                sortable = true; break;
            }
        }

        cout << (sortable ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
int main(void)
{
    int a[1100]={0},b,m,n,i,j=0,k=0,l=0,p=0,x=0,y=0,z=0;
    char s[1000],ss[1000],c;

    scanf("%s",s);
    b=strlen(s);

    for(i=0; i<b; i++) a[s[i]-'a']++; 
    for(i=0; i<26; i++){
        if(a[s[i]-'a']%2!=0){ printf("No\n"); return 0;}
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>

using namespace std;

static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];   // 距離で訪問状態 (color) を管理する

void bfs(int s) {
    queue<int> q;
    int i;
    int u, v;

    q.push(s);
    for (i = 0; i < n; i++) d[i] = INFTY;
    d[s] = 0;

    while (!q.empty()) {
        u = q.front(); q.pop();
        for (v = 0; v < n; v++) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (i = 0; i < n; i++) {
        cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main()
{
    int u, k, v;
    int i, j;

    cin >> n;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) M[i][j] = 0;
    }

    for (i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

char R[505][505], B[505][505],A[505][505];
int H, W;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			cin >> A[i][j];
		}
	}
	REP(i, H) {
		REP(j, W) {
			R[i][j] = '.';
			B[i][j] = '.';
		}
	}

	REP(i, H) {
		REP(j, W) {
			if (A[i][j] == '#') {
				R[i][j] = '#';
				B[i][j] = '#';
			}
			if (j == 0) {
				R[i][j] = '#';
			}
			else if (j == W - 1) {
				B[i][j] = '#';
			}
			else {
				if (i % 2 == 0) {
					R[i][j] = '#';
				}
				else {
					B[i][j] = '#';
				}
			}
		}
	}

	REP(i, H) {
		REP(j, W) {
			cout << R[i][j];
		}
		cout << endl;
	}
	REP(i, H) {
		REP(j, W) {
			cout << B[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
 
using namespace std;
 
template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}
 
template <unsigned long long mod> class modint {
public:
    unsigned long long v;
    modint(const long long x = 0) : v(x % mod) {}
    modint operator+(const modint rhs) { return modint(*this) += rhs; }
    modint operator-(const modint rhs) { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) { return modint(*this) /= rhs; }
    modint operator-() { return modint(mod - this->v); }
    modint& operator+=(const modint rhs) {
        v += rhs.v;
        if (v >= mod) v -= mod;
        return *this;
    }
    modint& operator-=(const modint rhs) {
        if (v < rhs.v) v += mod;
        v -= rhs.v;
        return *this;
    }
    modint& operator*=(const modint rhs) {
        v = v * rhs.v % mod;
        return *this;
    }
    modint inverse(modint a) {
        unsigned long long exp = mod - 2;
        modint ret(1ULL);
        while (exp) {
            if (exp % 2) { ret *= a; }
            a *= a;
            exp >>= 1;
        }
        return ret;
    }
    modint& operator/=(modint rhs) {
        (*this) *= inverse(rhs);
        return *this;
    }
    friend ostream& operator<<(ostream& os, modint u) {
        os << u.v;
        return (os);
    }
    friend istream& operator>>(istream& is, modint& u) {
        is >> u.v;
        return (is);
    }
};

const int MOD = 1000000007;
using mint = modint<MOD>;

const int MAX = 500005;
mint fact[MAX], invfact[MAX], inv[MAX];

void facinit() {
    fact[0] = fact[1] = 1;	
    invfact[0] = invfact[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fact[i] = fact[i - 1] * i;
        inv[i] = - inv[MOD%i] * (MOD / i);
        invfact[i] = invfact[i - 1] * inv[i];
    }
}

mint nPr(int n, int r){
    return fact[n] * invfact[n-r];
}

mint nCr(int n, int r){
    if(n < 0|| r < 0 || n < r)return mint{0};
    return fact[n]*invfact[r]*invfact[n-r];
}

mint nHr(int n, int r){
    if(n == 0 && r == 0)return mint{1};
    return nCr(n+r-1, n);
}

class Solution {
public:
	void solve() {
        int n, m;
        cin >> n >> m;
        facinit();
        mint ret = 1;
        for(int i = 2; i*i <= m; i++){
            int cnt = 0;
            while(m % i == 0){
                m /= i;
                cnt++;
            }
            if(cnt){
                ret *= nHr(cnt, n);
            }
        }
        if(m != 1)ret *= n;
        cout << ret << endl;    
		return;
	};
};
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 12032
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String S = sc.next();
		String T = sc.next();

		int[] ms = new int[26];
		int[] mt = new int[26];
		Arrays.fill(ms, -1);
		Arrays.fill(mt, -1);

		String ans = "Yes";
		for (int i = 0; i < S.length(); i++) {
			int ss = S.charAt(i) - 'a';
			int tt = T.charAt(i) - 'a';

			if ((ms[ss] == -1 || ms[ss] == tt) && (mt[tt] == -1 || mt[tt] == ss)) {
				ms[ss] = tt;
				mt[tt] = ss;
			} else {
				ans = "No";
				break;
			}
		}

		out.println(ans);

		sc.close();

	}

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

}


Measured memory_bytes: 26796
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin() (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int N; cin >> N;
  int mn = 0, ans = 0;
  rep(i, N) {
    int h; cin >> h;
    if (h >= mn) {
      ans ++;
      mn = h;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	H := nextInt(sc)
	N := nextInt(sc)
	A := make([]int, N)
	B := make([]int, N)
	for i := range A {
		A[i] = nextInt(sc)
		B[i] = nextInt(sc)
	}
	// dp := make([]int, H*2+10) // WA - overkillケースに対応できていない
	dp := make([]int, int(1e4)*2+10)
	for i := 0; i < len(dp); i++ {
		dp[i] = int(1e9)
	}
	dp[0] = 0
	for i := 0; i < len(dp); i++ {
		for j := 0; j < N; j++ {
			if i-A[j] >= 0 {
				dp[i] = min(dp[i], dp[i-A[j]]+B[j])
			}
		}
	}
	ans := int(1e9)
	for i := H; i < len(dp); i++ {
		ans = min(ans, dp[i])
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 768
// 
// 問題URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_D&lang=jp
// 中央*右
// 
// よく分からなかったので、以下23pを参考に実装
// https://www.cs.princeton.edu/~wayne/kleinberg-tardos/pdf/05DivideAndConquerI.pdf

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define NUM 200000

int N, A[NUM + 5];

void print_vec(vector<int> vec){
    cout << "[";
    for(auto itr = vec.begin(); itr!=vec.end(); itr++) 
        cout << *itr << " ";
    cout << "] " << endl;
}

void print_arr(int l, int r){
    cout << "[";
    for(int i = l; i < r; i++) cout << A[i] << " ";
    cout << "]" << endl;
}

long long sort_and_binary_count(int l, int m, int r){// ソートして二分探索でcを数える
    // printf("l: %d m: %d r: %d\n", l, m, r);
    long long cnt = 0;
    vector<int> vecl(A+l,A+m);
    vector<int> vecr(A+m, A+r);

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

    // cout << "vecl: ";
    // print_vec(vecl);
    // cout << "vecr: ";
    // print_vec(vecr);
    
    for(auto itrl = vecl.begin(); itrl!=vecl.end(); itrl++){
        auto itrr = lower_bound(vecr.begin(), vecr.end(), *itrl);
        cnt += itrr - vecr.begin();
    }
    return cnt;
}

long long merge_and_count(int l, int r){ // range [l,r)
    // print_arr(l, r);
    if(l+1 >= r) return 0;
    if(l+2 == r){
        if(A[l] <= A[l+1]) return 0;
        swap(A[l], A[l+1]);
        return 1;
    }
    int m = (l+r)/2; //少数値だったら切り捨てて整数に
    long long cl = merge_and_count(l,m);
    long long cr = merge_and_count(m, r);
    long long c = 0;

    c = sort_and_binary_count(l,m,r);

    // printf("cl: %d cr: %d c: %d\n", cl,cr,c);
    return cl+cr+c;
}

int main(){
    cin >> N;

    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }

    cout << merge_and_count(0, N) << endl;
}




Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int N=1000;
const ll INF=LLONG_MAX/3;

int n,m;
struct edge{int to,cost;};
vector<edge> G[N];
ll d[N];

bool find_loop()
{
    set<int> v;
    fill(d,d+N,-INF);
    d[0]=0;
    rep(i,n)rep(j,n)for(const auto &e:G[j])
    {
        if(d[e.to] < d[j]+e.cost)
        {
            d[e.to] = d[j]+e.cost;
            if(i==n-1) v.insert(e.to);
        }
    }

    vector<bool> vis(n,false);
    queue<int> que;
    for(auto &x:v)
    {
        que.push(x);
        vis[x]=true;
    }
    while(!que.empty())
    {
        int now=que.front();
        que.pop();
        for(const auto &e:G[now])
        {
            if(!vis[e.to])
            {
                vis[e.to] = true;
                que.push(e.to);
            }
        }
    }

    return vis[n-1];
}

int main()
{
    scanf(" %d %d", &n, &m);
    rep(i,m)
    {
        int a,b,c;
        scanf(" %d %d %d", &a, &b, &c);
        --a;
        --b;
        G[a].pb({b,c});
    }

    if(find_loop()) printf("inf\n");
    else printf("%lld\n", d[n-1]);
    return 0;
}


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

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
   }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

    int n, k, l;
    cin >> n >> k >> l;
    
    UnionFind UF1(n), UF2(n);
    
    REP(i, k){
        int p, q;
        cin >> p >> q;
        p--; q--;
        UF1.unite(p, q);
    }

    REP(i, l){
        int r, s;
        cin >> r >> s;
        r--; s--;
        UF2.unite(r, s);
    }

    map<pair<int, int>, int> mp;
    REP(i, n){
        mp[{UF1.root(i), UF2.root(i)}]++;
    }

    REP(i, n){
        int ans = mp[{UF1.root(i), UF2.root(i)}];
        if(i > 0) cout << " " << ans;
        else cout << ans;
    }
    cout << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

ll yukurido(ll a, ll b)
{
	ll c = a % b;

	return c == 0 ? b : yukurido(b, c);
}

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll cd = (c * d) / yukurido(d, c);

	ll tmpc = b / c - (a - 1) / c;
	ll tmpd = b / d - (a - 1) / d;
	ll tmpcd = b / cd - (a - 1) / cd;

	cout << (b - a) - (tmpc + tmpd - tmpcd) + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter
sysinput = sys.stdin.readline

N = int(sysinput())
A = []

# O(N)
for i  in range(N):
  A.append(list(map(int, sysinput().split())))

A.sort(key=itemgetter(1))

now_time = 0
flag = True
for i in range(N):
  min_b = A[i][1]
  now_time += A[i][0]
  if now_time > min_b:
    flag = False
if flag:
  print('Yes')
else:
  print('No')




Measured memory_bytes: 53752
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 5010
#define inf 1000000000000000000ll
int n,A,B;long long f[N][N],ans;
int main()
{
	scanf("%d%d%d",&n,&A,&B);
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) f[i][j]=inf; f[0][0]=0;
	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		for(int j=0;j<=n;j++)
			if(x>j) f[i][j]=min(f[i][j],f[i-1][j]+A),f[i][x]=min(f[i][x],f[i-1][j]);
			else f[i][j]=min(f[i][j],f[i-1][j]+B);
	}
	ans=inf;
	for(int i=0;i<=n;i++) ans=min(ans,f[n][i]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 195968
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;
signed main(){
    int s;
    cin>>s;
    vector<int> v;
    int d=s;
    while(d>0){
        v.push_back(d%10);
        d/=10;
    }
    reverse(v.begin(),v.end());
    
    int num=v.size();
    string temp="";
    int ans=0;
    for(int i=0;i<(1<<num-1);i++){
        
        for(int j=0;j<num;j++){
            temp+=to_string(v[j]);
            if((i&(1<<j))||j==num-1){
                ans+=stoll(temp);
                temp="";
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
   cin.tie(0);  
   ios::sync_with_stdio(false);
   int n,a,b;
   cin>>n>>a>>b;
   cout<<min(n*a,b)<<endl;
   return 0;
}



Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

maxv = max(A)
max_id = A.index(maxv)
second = max(A[:max_id] + A[max_id+1:])

for i in range(N):
  if i == max_id:
    print(second)
  else:
    print(maxv)

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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n, q;
  cin >> n >> q;
  vector< list<int> > v(n);
  rep_i(i, n){
    list<int> a;
    v.push_back(a);
  }

  int tmp, tmp2, tmp3;
  rep_i(i, q){
    cin >> tmp;
    switch (tmp)
    {
    case 0:
      cin >> tmp2 >> tmp3;
      v[tmp2].push_back(tmp3);
      break;
    case 1:
      cin >> tmp2;
      if(v[tmp2].empty()){
        cout << endl;
        break;
      }

      for (list<int>::iterator i = v[tmp2].begin(); i != v[tmp2].end(); i++){
        if(i == --v[tmp2].end()){
          say(*i);
        }else{
          cout << *i << " ";
        }
      }
      
      // rep_i(i, v[tmp2].size()){
      //   if(i == v[tmp2].size() - 1){
      //     say(v[tmp2][i]);
      //   }else{
      //     cout << v[tmp2][i] << " ";
      //   }
      // }
      // say(v[tmp2].top());
      break;
    case 2:
      cin >> tmp2 >> tmp3;
      // これだと制限時間に間に合わなため、splintを使用する必要がある
      // v[tmp3].insert(v[tmp3].end(), v[tmp2].begin(), v[tmp2].end());
      // v[tmp2].clear();
      v[tmp3].splice(v[tmp3].end(), v[tmp2]);
      break;
    default:
      break;
    }
  }
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp[110][10101];
void solve() {
    ll n, W;
    cin >> n >> W;
    vec<ll> v(n), w(n);
    REP(i, n) {
        cin >> v[i] >> w[i];
    }

    REP(i, n + 1) {
        REP(j, W + 1) {
            dp[i][j] = -INF;
        }
    }
    dp[0][0] = 0;
    REP(i, n) {
        REP(j, W + 1) {
            chmax(dp[i + 1][j], dp[i][j]);
            if(j - w[i] >= 0)
                chmax(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
        }
    }

    ll ans = 0;
    REP(i, W + 1) { chmax(ans, dp[n][i]); }
    cout << ans << en;
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}



Measured memory_bytes: 11140
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793;

int main(){
    while(true){
        int n; cin >> n;
        if(n == 0) break;
        double sum_1 = 0, sum_2 = 0;
        for(int i = 0; i < n; i++){
            double a; cin >> a;
            sum_1 += a; sum_2 += a * a;
        }
        double st_dev = sqrt(sum_2 / n - pow(sum_1 / n, 2));
        printf("%.10f\n", st_dev);
    }
}


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


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

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

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


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(2000005);


//nPk
 mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}




//組み合わせの数nCrを計算
   int calcNumOfCombination(int n, int r){
       int num = 1;
       for(int i = 1; i <= r; i++){
           num = num * (n - i + 1) / i;
       }
       return num;
   }

int main() {
  ll k;
  cin >> k;
  string s;
  cin>>s;
  ll n=s.size();
  mint ans=0;
  vector<mint> p(1000005);
  vector<mint> P(1000005);
  /*
  p[0]=1;
  P[0]=1;
  rep(i,1000005){
    p[i+1]=p[i]*25;
    P[i+1]=P[i]*26;
  }
  */
  rep(i,k+1){
    mint temp=mint(26).pow(i);
    temp*=mint(25).pow(k-i);
    mint c=comb(n+k-i-1,n-1);
    temp*=c;
    ans+=temp;
  //  cout<<ans<<endl;
  }
cout<<ans.x;
}


Measured memory_bytes: 51248
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		if(N%2==0) {
			System.out.println(N);
		}else {
			System.out.println(N*2);
		}

	}

}


Measured memory_bytes: 21844
/**
 *    author:  tourist
 *    created: 06.07.2020 09:39:32       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << '\n';
  return 0;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<int>a(n),b(n),c(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    ll ans=0;

    rep(i,n){
        ll A=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        ll C=c.end()-upper_bound(c.begin(),c.end(),b[i]);

        ans+=A*C;
    }

    cout<<ans<<endl;

}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,k;cin>>n>>k&&n|k;){
		vi xs(n),ys(n);
		string cs(n,'.');
		rep(i,n) cin>>xs[i]>>ys[i]>>cs[i];

		vvi grid(3*k+1,vi(4*k+1));
		rep(i,n){
			int x=xs[i]%(2*k),y=ys[i]%(2*k);
			int xmin,xmax,ymin,ymax;
			if(cs[i]=='B'){
				xmin=x-(k-1),xmax=x+1;
				ymin=y-(k-1),ymax=y+1;
			}
			else{
				xmin=x+1,xmax=x+k+1;
				ymin=y-(k-1),ymax=y+1;
			}
			grid[k+ymin][k+xmin]++;
			grid[k+ymin][k+xmax]--;
			grid[k+ymax][k+xmin]--;
			grid[k+ymax][k+xmax]++;
		}
		rep(i,3*k+1) rep(j,4*k) grid[i][j+1]+=grid[i][j];
		rep(i,3*k) rep(j,4*k+1) grid[i+1][j]+=grid[i][j];

		vvi res(k,vi(2*k));
		rep(i,3*k+1) rep(j,4*k+1){
			int ii=i%(2*k),jj=j%(2*k);
			if(ii>=k){
				ii-=k;
				jj=(jj+k)%(2*k);
			}
			res[ii][jj]+=grid[i][j];
		}

		int ans=0;
		rep(i,k) rep(j,2*k) chmax(ans,res[i][j]);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 56064
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] v = new double[n];
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextDouble();
		}
		Arrays.sort(v);
		for (int i = 0; i < n - 1; i++) {
			v[i + 1] = (v[i] + v[i + 1]) / 2;
		}
		System.out.println(v[n - 1]);
	}
}


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

int main() {
    string s; cin >> s;
    int ans = 1000;
    for (int i = 0; i < s.size()-2; i++)
    {
        int x = (s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0';
        x = abs(x-753);
        ans = min(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int K = sc.nextInt();
   int X = sc.nextInt();

   for(int i = X-K+1;i<=X+K-1;i++)
     System.out.println(i+ " ");
 }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ; 
struct E {
	int to, next ; 
} e[N * 2] ; 
int cnt, head[N], n, sg[N] ; 
void add( int x, int y ) {
	e[++ cnt] = (E){ y, head[x] }, head[x] = cnt,
	e[++ cnt] = (E){ x, head[y] }, head[y] = cnt ;
}
void dfs( int x, int fa ) {
	sg[x] = 0 ;
	Next( i, x ) {
		int v = e[i].to ; if( v == fa ) continue ; 
		dfs( v, x ), sg[x] ^= ( sg[v] + 1 ) ;
	} 
}
signed main()
{
	n = gi() ; int x, y ; 
	rep( i, 2, n ) x = gi(), y = gi(), add( x, y ) ;
	dfs( 1, 1 ) ; if( sg[1] == 0 ) puts("Bob") ;
	else puts("Alice") ;
	return 0 ;
}


Measured memory_bytes: 8192
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    string s;
    cin >> s;
    rep(i, n)if(s[i] == '>')break;
    per(j, n)if(s[j] == '<')break;
    pri(n - min(i, n - 1 - j));

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ct[3];
    int count=0;
    for(int i=0;i<3;i++)
    {
        scanf("%c",&ct[i]);
        if(ct[i]=='A') count++;
    }
    if(count==3||count==0) cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 256
import sys
from collections import deque

rl = sys.stdin.readline


def solve():
    N = int(rl())
    graph = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = map(int, rl().split())
        u -= 1
        v -= 1
        graph[u].append([v, w])
        graph[v].append([u, w])
    
    ans = [-1] * N
    stack = deque([[0, 0]])
    while stack:
        node, dist = stack.pop()
        for child, weight in graph[node]:
            if ans[child] != -1:
                continue
            nd = dist + weight
            if nd % 2 == 0:
                ans[child] = 0
            else:
                ans[child] = 1
            stack.append([child, nd])
    
    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    solve()


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

int main(){
  	string N;
  	cin >> N;	
	for(int  i=0; i<N.length(); i++){
    	if(N[i]=='7'){
        	cout << "Yes" << endl;
          	return 0;
        }
    }
  	cout << "No" << endl;
 	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n; cin >> n;
  string a, b, c; cin >> a >> b >> c;
  int ans = 0;
  rep(i, n) {
    if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
      ans += 2;
    } else if (a[i] == b[i] && b[i] == c[i]) {
      ans += 0;
    } else {
      ans += 1;
    }
  }
  cout << ans << '\n';
}


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

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

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

  int A[N];
  int cnt = 0;
  int MIN = 1e9;
  long long ans = 0;
  for(int i = 0;i < N;i++){
    scanf("%d",&A[i]);
    if(A[i] < 0) cnt++;
    MIN = min(MIN,abs(A[i]));
    ans += abs(A[i]);
  }

  if(cnt%2 == 0) MIN = 0;
  else MIN *= 2;
  printf("%lld\n",ans-MIN);


  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
int n,m,a,b;
pair<int,int> p[100000];
priority_queue<int> que;
int ans;
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>a>>b,p[i]=make_pair(a,b);
    sort(p,p+n);
    int x=0;
    for(int i=1;i<=m;i++){
        for(;x<n&&p[x].first<=i;x++)que.push(p[x].second);
        if(!que.empty())ans+=que.top(),que.pop();
    }
    cout<<ans<<endl;
}

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = INT_MAX;
    
    ans = a * x + b * y;
    
    for (int i = 0; i <= max(x, y); i++) {
        ans = min(ans, a * max(x - i, 0) + b * max(y - i, 0) + c * i * 2);
    }
    
    cout << ans << endl;
    return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    string S;
    cin >> N >> S;

    vi left(N), right(N);

    for (int i = 1; i < N; i++) {
        left[i] = left[i-1] + (S[i-1] == 'W');
    }

    for (int i = N - 2; i >= 0; i--) {
        right[i] = right[i+1] + (S[i+1] == 'E');
    }

    int ans = N;
    for (int i = 0; i < N; i++) {
        ans = min(ans, left[i] + right[i]);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2964