akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


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

  VV G(n);
  rep(i, m) {
    int u, v; cin >> u >> v;
    --u; --v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  rep(i, n) {
    sort(all(G[i]));
    G[i].erase(unique(all(G[i])), G[i].end());
  }

  VV deg(n, V(2));
  
  rep(u, n) for (auto v : G[u]) {
    int k = s[v] - 'A';
    ++deg[u][k];
  }

  Vbo rmv(n, false);
  queue<int> que;
  rep(u, n) if (deg[u][0] == 0 || deg[u][1] == 0) que.push(u);

  while (!que.empty()) {
    int u = que.front(); que.pop();
    int k = s[u] - 'A';
    rmv[u] = true;
    for (auto v : G[u]) {
      if (rmv[v]) continue;
      --deg[v][k];
      if (deg[v][k] == 0) que.push(v);
    }
  }

  int cnt = 0;
  rep(u, n) if (rmv[u]) ++cnt;
  if (cnt < n) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 21072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

vector<vector<ll> > dp;
int n;
vector<int> a;
ll dfs(int l, int r) {
  if (dp[l][r] != INF) return dp[l][r];
  if (l + 1 == r) return dp[l][r] = 0;
  ll sum = 0;
  rep3(i, l, r) sum += a[i];
  rep3(i, l + 1, r) chmin(dp[l][r], dfs(l, i) + dfs(i, r) + sum);
  return dp[l][r];
}
void solve() {
  cin >> n;
  dp = vector<vector<ll> >(n, vector<ll>(n + 1, INF));
  a.resize(n);
  cin >> a;
  cout << dfs(0, n) << endl;
  // rep(i, n) cout << dp[i] << endl;
}


Measured memory_bytes: 1536
n = int(input())
C = input()
sR = [0]*(n+1)
sW = [0]*(n+1)

for i in range(n):
    sR[i+1] = sR[i] + (C[i] == "R")
    sW[i+1] = sW[i] + (C[i] == "W")

ans = 10**10
for i in range(n+1):
    r = sR[n] - sR[i]
    w = sW[i]
    ans = min(ans, max(r,w))
print(ans)


Measured memory_bytes: 80464
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int N;
    cin >> N;
    string str;
    while(N != 0)
    {
        int r = N % (2);
        if(r < 0) r+= 2;
        N = (N - r) / (-2);
        str += (char)('0' + r);
        
    }
    reverse(str.begin(), str.end());
  if (str == "") str = "0"; 
  cout << str << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, k);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    sort(all(data));
    vector<i_i> hoge(0);
    int bef = data[0], cnt = 1;
    Rep(i, n) {
        if (data[i] != bef) {
            hoge.pb(mp(cnt, bef));
            bef = data[i];
            cnt = 1;
        } else {
            cnt++;
        }
    }
    hoge.pb(mp(cnt, bef));
    sort(all(hoge));
    //cout << hoge.size() << endl;
    int ans = 0;
    for (int i = 0; i < (int)hoge.size() - k; i++) {
        ans += hoge[i].fir;
    }
    cout << ans << endl;
    

    return 0;
}





Measured memory_bytes: 7280
N = int(input())
CSF = [list(map(int,input().split())) for i in range(N-1)]
ans = []

for i in range(N-1):
	res = 0
	for c,s,f in CSF[i:]:
		if res < s:
			res = s
		if res % f != 0:
			res += f - res % f
		res += c
	ans.append(res)
ans.append(0)
for a in ans:
	print(a)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;

int S[200000];

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

    rep(i, N) cin >> S[i];

    int ma = 0;

    for (int i = 1, to = sqrt(N); i <= to; ++i) {
        if (N % i == 0) {
            for (int j = i; j < N; j += i) {
                for (int k = 0; k < i; ++k) {
                    if (S[k] != S[j + k]) goto nxt1;
                }
            }
            chmax(ma, N / i);
            break;
nxt1:;
            for(int j = N / i; j < N; j += N / i) {
                for (int k = 0; k < N / i; ++k) {
                    if (S[k] != S[j + k]) goto nxt2;
                }
            }
            chmax(ma, N / (N / i));
nxt2:;
        }
    }

    cout << ma << endl;
}

Measured memory_bytes: 1944
#include<stdio.h>
int main(void){
  char s[100000];
  scanf("%s",s);
  int len,i,dif1=0,dif2=0;
  len=sizeof(s);
  for(i=0;i<len;i++){
    if(s[i]=='\0') break;
    if(i%2==0){
      if(s[i]=='0') dif1++;
      if(s[i]=='1') dif2++;
    }
    if(i%2==1){
      if(s[i]=='1') dif1++;
      if(s[i]=='0') dif2++;
    }
  }
  if(dif1<dif2) printf("%d",dif1);
  else printf("%d",dif2);
  return 0;
}

Measured memory_bytes: 256
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int H,W;
vector<string>A;
void solve(){
    cin >> H >> W;
    A.resize(H);
    for(int i=0;i<H;i++){
        cin >> A[i];
    }
    int cnt=0;
    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            if(A[h][w]=='#')cnt++;
        }
    }
    if(cnt==H+W-1)cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    
 
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
map<int,int>d;
inline int read()
{
    char ch=getchar();
    int x=0,q=1;
    while(ch>'9' || ch<'0')q=ch==45?-1:q,ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
    return x*q;
}
inline int solve(int x)
{
    if(d[x]!=0)
        return d[x];
    else
    return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main()
{
    d[0]=1;
    d[1]=2; 
    int n;
    n=read(); 
    int ans=solve(n);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int w, h, n;
    cin >> w >> h >> n;
    int x, y, z;
    int a = 0;
    int b = w;
    int c = 0;
    int d = h;

    for(int i = 0; i < n; i++){
        cin >> x >> y >> z;
        if(z == 1){
            a = max(a, x);
        } else if(z == 2){
            b = min(b, x);
        } else if(z == 3){
            c = max(c, y);
        } else {
            d = min(d, y);            
        }
    }

    if(a >= b || c >= d){
        cout << 0 << endl;
    } else {
        cout << (b - a)*(d - c) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t2, a2 = map(int, input().split())
for _ in range(n-1):
  t, a = map(int, input().split())
  m = max((t2-1)//t, (a2-1)//a)+1
  t2 = m*t
  a2 = m*a
print(t2+a2)

Measured memory_bytes: 3060
R,G,B,N = map(int,input().split())
count = 0
for a in range(0,N+1,R):
    if a%R == 0:
        for b in range(0,N-a+1,G):
            if b%G == 0:
                c = N-a-b
                if c%B == 0:
                    count +=1
print(count)

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

int main()
{
    int n,i,d=0;
    char a[100];
    cin >> n;
    cin >> a;
    if(n%2==1){
        cout << "No" << endl;
    }
    else{
        for(i=0;i<n/2;i++){
            if(a[i]==a[i+(n/2)]){
                d++;
            }
        }
        if(d==(n/2)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No\n";
        }
    }

    return 0;
}

Measured memory_bytes: 3592
// https://atcoder.jp/contests/abc118/tasks/abc118_b

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

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

    long mask = (1 << m) - 1;
    for (int i = 0; i < n; i++)
    {
        int k;
        long b = 0;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int a;
            cin >> a;
            b |= 1 << (--a);
        }
        mask &= b;
    }

    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        if ((mask >> i) & 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
str = list(input())

m = False
a = False

mae = int(str[0])*10 + int(str[1])
ato = int(str[2])*10 + int(str[3])

if mae > 0 and mae < 13:
    m = True

if ato > 0 and ato < 13:
    a = True

if m and a:
    print("AMBIGUOUS")
elif m!= True and a:
    print("YYMM")
elif m and a != True:
    print("MMYY")
elif m != True and a != True:
    print("NA")

Measured memory_bytes: 3188
import java.util.Scanner;
import java.util.TreeSet;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String string = sc.next();
		int k = sc.nextInt();
		TreeSet<String> set = new TreeSet<String>();
		for(int i = 0;i < string.length();i++){
			for(int j = i;j < string.length();j++){
				if(j - i > 5){
					break;
				}
				String x = string.substring(i, j+1);
				String y = string.substring(j+1);
//				System.out.println(x);
//				System.out.println(y);
				set.add(x);
				set.add(y);
			}
		}
		int count = 0;
		for(String ss:set){
			if(count == k){
			System.out.println(ss);
				return;
			}
			count++;
		}
	}





}



class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 100032
//  Crane and Turtle
#include <bits/stdc++.h>
using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    if((y-2*x)%2==0 && (4*x-y)%2==0 && (y-2*x)>=0 && (4*x-y)>=0){
        cout << "Yes" << endl;
        return 0;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void) {
    int p,q,r;
    scanf("%d%d%d",&p,&q,&r);
    int ans = p+q;
    if(ans > q+r) {ans = q+r;}
    if(ans > p+r) {ans = p+r;}
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] a = new long[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextLong();
    }

    int range = 0;
    for(int j=0;j<n-1;j++){
      if (a[j+1] >= a[j] + 1){
        a[j+1] -= 1;
      }
      else{
        if (a[j+1] != a[j]){
          System.out.println("No");
          return;
        }
      }
    }
    System.out.println("Yes");

  }
}


Measured memory_bytes: 60588
from collections import Counter
import sys
input = sys.stdin.readline

n = int(input())
v = list(map(int, input().split()))


def f(odd):
    l = Counter([x for i, x in enumerate(v) if i % 2 == odd]).most_common(2)
    l.append((0, 0))
    return l


a = f(0)
b = f(1)

if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    print(min(n - a[0][1] - b[1][1], n - a[1][1] - b[0][1]))


Measured memory_bytes: 15652
#include <map>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

void Get_Val(int &Ret)
{
	Ret = 0;
	char ch;
	while (ch = getchar(), ch > '9' || ch < '0')
		;
	do
	{
		(Ret *= 10) += ch - '0';
	}
	while (ch = getchar(), ch >= '0' && ch <= '9');
}

const int Max_N(200050);
typedef long long int LL;
const int MOD(1000000000 + 7);

inline int Mult(const int &a, const int &b)
{
	return (a * 1LL) * b % MOD;
}

void exgcd(const int &a, const int &b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(const int &a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

struct node
{
	node(const int &_pos = 0, const int &_w = 0) : pos(_pos), w(_w) {}
	int pos, w;
};
int N, X, Y, Father[Max_N], Fac[Max_N], Inv[Max_N];
map<int, int> S[Max_N];
vector<node> V[Max_N];

int Get_Father(const int &x)
{
	return Father[x] == x ? x : Father[x] = Get_Father(Father[x]);
}

inline void Link(const int &u, const int &v)
{
	Father[Get_Father(u)] = Get_Father(v);
}

inline bool comp(const node &a, const node &b)
{
	return a.w < b.w;
}

void init()
{
	Get_Val(N), Get_Val(X), Get_Val(Y);
	for (int i = 1, c, w;i <= N;++i)
		Father[i] = i, Get_Val(c), Get_Val(w), V[c].push_back(node(i, w));
	for (int c = 1;c <= N;++c)
		sort(V[c].begin(), V[c].end(), comp);
	Fac[0] = 1;
	for (int i = 1;i <= N;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[N] = inverse(Fac[N]);
	for (int i = N - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
}

//把每个球当做一个点，某个球当前所在的位置是该点的权值。我们将能够交换位置的两个球之间连一条边，那么有边的两个点之间可以交换权值
//考虑两个都在同一个联通块中的点1和n，他们之间的路径是1, 2, 3, ..., n
//可以形如1, 2, 3, ..., n  ->  2, 3, ..., n, 1  ->  n, 2, 3, ..., 1的方式交换，来做到交换两个点的权值而不影响其它点的权值
//可以只考虑联通块中W最小的点来优化连边
//最后每个联通块都是独立的，可以分开做 
void makegraph()
{
	for (int c = 1;c <= N;++c)
		for (int i = 1;i < V[c].size();++i)
			if (V[c][i].w + V[c][0].w <= X)
				Link(V[c][i].pos, V[c][0].pos);
	int Minpos(-1), Minw, Minc;
	for (int c = 1;c <= N;++c)
		for (int i = 0;i < V[c].size();++i)
			if (Minpos == -1 || V[c][i].w < Minw)
				Minpos = V[c][i].pos, Minw = V[c][i].w, Minc = c;
	for (int c = 1;c <= N;++c)
		if (c != Minc)
			for (int i = 0;i < V[c].size();++i)
				if (V[c][i].w + Minw <= Y)
					Link(V[c][i].pos, Minpos);
	Minpos = -1;
	for (int c = 1;c <= N;++c)
		if (c != Minc)
			for (int i = 0;i < V[c].size();++i)
				if (Minpos == -1 || V[c][i].w < Minw)
					Minpos = V[c][i].pos, Minw = V[c][i].w;
	if (Minpos == -1)
		return;
	for (int i = 0;i < V[Minc].size();++i)
		if (V[Minc][i].w + Minw <= Y)
			Link(V[Minc][i].pos, Minpos);
	
}

int js(const int &pos)
{
	int Sum(0), Ans(1);
	for (map<int, int>::iterator it = S[pos].begin();it != S[pos].end();++it)
		Ans = Mult(Ans, Inv[it -> second]), Sum += it -> second;
	return Mult(Ans, Fac[Sum]);
}

void work()
{
	for (int c = 1;c <= N;++c)
		for (int i = 0;i < V[c].size();++i)
			++S[Get_Father(V[c][i].pos)][c];
	int Ans(1);
	for (int i = 1;i <= N;++i)
		if (S[i].size())
			Ans = Mult(Ans, js(i));
	printf("%d", Ans);
}

int main()
{
	init();
	makegraph();
	work();
	return 0;
}

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

n = int(input().strip())
T,A = list(map(int, input().rstrip().split()))
nums_H = list(map(int, input().rstrip().split()))
#----------
diff=[]
for hight in nums_H:
    diff += [ abs((T - hight*0.006) - A) ]

print([ i+1 for i, v in enumerate(diff) if v == min(diff)][0] )


Measured memory_bytes: 3188
#include <stdio.h>

#define MAX 5000

int main(void)
{
    int i, j;

    int n;
    while (scanf("%d", &n) != EOF) {
        if (n == 0) {
            break;
        }

        int num[MAX];
        for (i = 0; i < n; i++) {
            scanf(" %d", num + i);
        }

        int max = -100000;
        for (i = 0; i < n; i++) {
            int sum_ij[MAX] = {0};
            int max_i;
            max_i = sum_ij[i] = num[i];
            for (j = i + 1; j < n; j++) {
                sum_ij[j] = sum_ij[j - 1] + num[j];
                if (sum_ij[j] > max_i) {
                    max_i = sum_ij[j];
                }
            }
            if (max_i > max) {
                max = max_i;
            }
        }

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

    return 0;
}

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


int main()
{
	string s;
	while (getline(cin, s))
	{
		if (s == "END OF INPUT")
			break;
		int c = 0;
		for (int i = 0; i < s.size(); i++)
		{
			if (s[i] != ' ')
				c++;
			else
				cout << c, c = 0;
		}
		cout << c << "\n";
	}
}



Measured memory_bytes: 3112
// Author: Jashan Bansal
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second	
#define mp make_pair
#define int long long
#define ll long long
#define pii pair<int,int>
#define all(arr) arr.begin(), arr.end()
#define sz(arr) ((long long)arr.size())
// const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
#define log1(x) cout << x << '\n'
#define log2(x,y) cout << x << " " << y <<'\n'
#define log3(x,y,z) cout << x <<" " << y <<" " << z << '\n'
#define logarr(arr,n) for(int __=0; __ < n; __++)	cout << arr[__] << " "; cout << '\n'

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


void solve(){
	int n,w; cin >> n >> w;
	vi wt(n), val(n);
	for(int i=0; i<n; i++) cin >> wt[i] >> val[i];

	vector<int> dp(w+1,0);

	for(int i=1;i<=n; i++){
		for(int j=w; j > 0; j--){
			dp[j] = (wt[i-1] > j) ? dp[j] : max(dp[j], dp[j-wt[i-1]] + val[i-1]);
		}
	}

	cout << dp[w] << '\n';
}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	// cin>>t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	if(n&1){
		for(ll i=1;i<=3500;i++){
			for(ll j=1;j<=3500;j++){
				ll a = n*i*j ;
				ll b = 4*i*j-n*j-n*i ;
				if(b>0&&a%b==0){
					cout << i << " " << j << " " << a/b << endl ;
					return 0 ;
				}
			}
		}
	}else{
		cout << n << " " << n << " " << n/2 << endl ;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n;
vector< int > arr( 1e5 + 5 );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> arr[ i ];		
	}
	sort( arr.begin() + 1, arr.begin() + n + 1 );
	cout << arr[ n / 2 + 1 ] - arr[ n / 2 ] << "\n";
	return 0;
}

Measured memory_bytes: 640
#import <stdio.h>
int main(){
    int n,d;
    scanf("%d %d",&d,&n);
    int count=0;
    int dd[] = {1,100,10000,1000000};
    int m = dd[d];
    for(int i=m;;i+=m){
        if (i % dd[d+1] != 0) count++;
        if (count == n) {
            printf("%d",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 2164
import sys
from collections import defaultdict
N, M = map(int, sys.stdin.readline().strip().split())
res = defaultdict(int)
for i in range(M):
    a, b = map(int, sys.stdin.readline().strip().split())
    a -= 1
    b -= 1
    res[a] += 1
    res[b] += 1
for i in range(N):
    print(res[i])



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

const int MOD = 1e9 + 7;
int dp[1001][1001];
signed main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    cin >> a;

    dp[0][0] = 1;
    REP(i, H) REP(j, W) {
        if (i + 1 < H && a[i + 1][j] != '#') (dp[i + 1][j] += dp[i][j]) %= MOD;
        if (j + 1 < W && a[i][j + 1] != '#') (dp[i][j + 1] += dp[i][j]) %= MOD;
    }
    cout << dp[H - 1][W - 1] << endl;
    return (0^_^0);
}



Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

bool f(ll bit, ll n) {
    return ((bit & (1 << n)) != 0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m, x;
    cin >> n >> m >> x;
    vector<vector<ll>> a(n, vector<ll>(m));
    vector<ll> c(n);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }
    ll ans = LONG_LONG_MAX;
    rep(bit, 1 << n) {
        ll tmp = 0;
        vector<ll> g(m, 0);
        rep(i, n) {
            if (f(bit, i)) {
                tmp += c[i];
                rep(j, m) {
                    g[j] += a[i][j];
                }
            }
        }
        ll can = true;
        rep(i, m) {
            if (g[i] < x) {
                can = false;
                break;
            }
        }
        if (can) {
            ans = min(ans, tmp);
        }
    }
    if (ans == LONG_LONG_MAX) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
def examA():
    X, Y = LI()
    ans = X + Y//2
    print(ans)
    return

def examB():
    N = I()
    T, A = LI()
    H = LI()
    cur = 10**9; ans = 0
    for i in range(N):
        now = abs(A - (T - H[i]*0.006))
        if cur>now:
            cur = now
            ans = i
    print(ans+1)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


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

const char color[5] = "RYGB";

int main()
{
	int h, w, d;
	scanf("%d %d %d", &h, &w, &d);
	for(int i = 1; i <= h; ++i)
	{
		for(int j = 1; j <= w; ++j)
		{
			int x = (i + j + 500) / d;
			int y = (i - j + 500) / d;
			printf("%c", color[((x & 1) << 1) + (y & 1)]);
		}
		puts("");
	}
	return 0;
}

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

using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef long long ll;
const int N=1e5+7;

int main(){
	int n,ans=0;	
	string s,t;
	cin>>n>>s>>t;
	int i=0,j=0;
	bool flag=false;
	while(i<n){
		int k=0;
		for(k=0;i+k<n;k++){
			
			if(s[i+k]!=t[k]){ j=0; break;}
			j++;
		}
		if(i+k==n) break;
		i++;
	}
	cout<<s.size()+t.size()-j<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>
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 ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    ll h,w;
    cin>>h>>w;

    if(h==1||w==1)cout<<1<<endl;

    else if(h%2==0||w%2==0){
        cout<<(h*w)/2<<endl;

    }
    else cout<<(h*w+1)/2<<endl;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (_, _, _, k) = scan!(usize, usize, usize, usize);
    let mut vs = scan!(i64;;);
    let mut ws = scan!(i64;;);
    let mut xs = scan!(i64;;);

    vs.sort();
    ws.sort();
    xs.sort();

    let mut sum = vec![];
    for v in vs.iter() {
        for w in ws.iter() {
            sum.push(v + w)
        }
    }
    sum.sort_by_key(|v| -v);

    let mut sum2 = vec![];
    for s in sum.iter().take(k) {
        for x in xs.iter() {
            sum2.push(s + x);
        }
    }
    sum2.sort_by_key(|v| -v);
    for s in sum2.iter().take(k) {
        println!("{}", s);
    }
}


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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=2e5+1e1;
const double eps=1e-10;

struct Node{
	int w2,w5,p;
};

Node a[MAXN<<1];
int b[3100][3100],n;
lint ans=0;

void Read(int id){
	int x=0,f=1,X=0,F=1,cnt=0;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	if(c=='.'){
		while(!isdigit(c)){	if(c=='-') F=-F;c=getchar();}
		while(isdigit(c)){X=(X<<3)+(X<<1)+(c-48);++cnt;c=getchar();}
	}
	lint k3=X*F;
	if(k3==0) cnt=0;
	while((k3) && (k3%10==0)) k3/=10,--cnt;
	lint k1=x*f;
	a[id].p=cnt;
	while(cnt--) k1*=10;
	lint k2=k1+k3;
	while((k2) && (k2%2==0)) ++a[id].w2,k2/=2;
	while((k2) && (k2%5==0)) ++a[id].w5,k2/=5;
	return;
}

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);
	for(int i=1;i<=n;i++) Read(i);
	// for(int i=1;i<=n;i++) printf("%d %d %d\n",a[i].w2,a[i].w5,a[i].p);
	for(int i=1;i<=n;i++){
		lint res=0;
		int w2=a[i].w2,w5=a[i].w5,p=a[i].p;
		for(int j=0;j<=w2-p+48;j++) for(int k=0;k<=w5-p+48;k++) res+=b[j][k];
		++b[p-w2+48][p-w5+48];
		ans+=res;
		// printf("%lld ",res);
		// printf("%d %d\n",max(a[i].p-a[i].w2,0),max(a[i].p-a[i].w5,0));
	}
	printf("%lld\n",ans);

	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;

    int ans = -1;
    for(int i=0;i<=1250;i++){
        if(i*8/100 == a && i/10 == b){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
    }
    double ans=0;
    rep(i,n){
      ans += (double)1/a[i];
    }
    ans  = 1/ans;
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
li  =   lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw  =   lambda : sys.stdin.readline().strip().split()
ni  =   lambda : int(sys.stdin.readline().strip())
nsi =   lambda : sys.stdin.readline().strip()

from collections import defaultdict as df
import math

n=ni()
l=list(map(int,input().split()))
mn=l[0]
ans=0
for i in range(1,n):
    if(mn<l[i]):
        mn=l[i]
    else:
        ans+=mn-l[i]
print(ans)


Measured memory_bytes: 33572
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int 
#define pb push_back
#define xx first
#define yy second


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t;
	t=1;
	while(t--)
	{
	    ll n,x,t;
	    cin>>n>>x>>t;
	    if(n%x==0)
	    {
	        cout<<(n/x)*t;
	    }
	    else
	    {
	        cout<<(n/x)*t + t;
	    }
	}
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const long long mod=1000000007;
const int maxn=200005;
ll inv[maxn],s[maxn];
int N,n,m,x,y;
ll Pow(ll a,int b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
ll C(int a,int b)
{
	if(a<0||b<0)
		return 1;
	return s[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
	scanf("%d%d",&n,&m);
    scanf("%d%d",&x,&y);
    N=n+m-2;
    s[0]=1;
    for(int i=1;i<=N;i++)
    	s[i]=s[i-1]*i%mod;
    inv[0]=1;
    inv[N]=Pow(s[N],mod-2);
    for(int i=N-1;i>0;i--)
    	inv[i]=inv[i+1]*(i+1)%mod;
    ll ans=0;
    for(int i=y+1;i<=m;i++)
    {
    	ans+=C(n-x+i-2,i-1)*C(x+m-i-1,x-1)%mod;
    	ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

int main()
{
	int i,j,k,n,tab[100010];
	bool cek[100010];
	memset(cek,0,sizeof(cek));
	cin>>n;
	for (i=1;i<=n;i++)
	 cin>>tab[i];
	if (1==tab[tab[1]])
	{
		if (tab[1]==2)
		 {
		 	cout<<1<<"\n";
		 	return 0;
		 }
		else 
		 {
		 	cout<<-1<<"\n";
		 	return 0;
		 }
	}
	else
	 {
	 	int now=1;
	 	int count=0;
	 	while (1)
	 	{
	 		memset(cek,0,sizeof(cek));
	 		count++;
	 		cek[tab[now]]=1;
	 		now=tab[now];
	 		if (count>=n)
	 		{
	 			cout<<-1<<"\n";
	 			return 0; 
			}
			if (cek[2])
			{
				cout<<count<<"\n";
				return 0;
			}
		}
	 }
}

Measured memory_bytes: 896
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int k, s, z[2501];

bool binary_search(int x) {
	int l = 0, r = k + 1;
	while (r - l >= 1) {
		int i = (r + l) / 2;
		if (z[i] == x) return true;
		else if (z[i] < x) l = i + 1;
		else r = i;
	}
	return false;
}

int main() {
	cin >> k >> s;

	// z=s-x-y のzを二分探索
	int count = 0;
	rep(i, 0, k + 1) {
		z[i] = i;
	}
	rep(x, 0, k + 1) {
		rep(y, 0, k + 1) {
			if (binary_search(s - x - y)) count++;
		}
	}

	cout << count << endl;

	return 0;
}

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

typedef long long ll;

namespace CF {
	#define ad(x) ((x - 1 ^ 1) + 1)

	const int N = 2054, M = 8000054;
	const ll INF = 0x3f3f3f3f3f3f3f3fll;

	struct edge {
		int u, v, c, f;
		edge (int u0 = 0, int v0 = 0, int c0 = 0, int f0 = 0): u(u0), v(v0), c(c0), f(f0) {}
	} e[M];

	int V, E, si = 1, ti = 2; ll flow, cost;
	int first[N], next[M];
	int cur[N], que[M << 1];
	ll dep[N];
	bool in_que[N], used[N];

	inline void addedge(int u, int v, int c, int f) {
		e[++E] = edge(u, v, c, f), next[E] = first[u], first[u] = E;
		e[++E] = edge(v, u, -c), next[E] = first[v], first[v] = E;
	}

	bool bfs() {
		int h = M, t = h + 1, i, x, y;
		memset(dep, 63, sizeof dep);
		que[h] = ti, dep[ti] = 0, in_que[ti] = true;
		for (; h < t; ) {
			x = que[h++], in_que[x] = false;
			for (i = first[x]; i; i = next[i])
				if (dep[y = e[i].v] > dep[x] - e[i].c && e[ad(i)].f) {
					dep[y] = dep[x] - e[i].c;
					if (!in_que[y])
						in_que[y] = true, (1 || dep[y] >= dep[que[h]] ? que[t++] : que[--h]) = y;
				}
		}
		return dep[si] < INF;
	}

	int dfs(int x, int lim) {
		int a, c, f = 0;
		if (x == ti || !lim) return lim;
		used[x] = true;
		for (int &i = cur[x]; i; i = next[i])
			if (dep[e[i].v] == dep[x] - e[i].c && e[i].f && !used[e[i].v]){
				a = std::min(lim - f, e[i].f);
				c = dfs(e[i].v, a);
				e[i].f -= c, e[ad(i)].f += c;
				if ((f += c) == lim) return f;
			}
		return f;
	}

	void Dinic() {
		int f;
		for (cost = flow = 0; bfs(); ) {
			memcpy(cur, first, sizeof cur);
			memset(used, 0, sizeof used);
			flow += f = dfs(si, INT_MAX);
			cost += dep[si] * f;
		}
	}
}

int main() {
	int i, n, w, x, y;
	scanf("%d", &n);
	for (i = 3; i < 3 + n; ++i) {
		scanf("%d%d%d", &x, &y, &w);
		CF::addedge(1, i, 0, w);
		CF::addedge(i, 3 + n * 2,  x + y, w);
		CF::addedge(i, 4 + n * 2,  x - y, w);
		CF::addedge(i, 5 + n * 2, -x + y, w);
		CF::addedge(i, 6 + n * 2, -x - y, w);
	}
	for (; i < 3 + n * 2; ++i) {
		scanf("%d%d%d", &x, &y, &w);
		CF::addedge(i, 2, 0, w);
		CF::addedge(3 + n * 2, i, -x - y, w);
		CF::addedge(4 + n * 2, i, -x + y, w);
		CF::addedge(5 + n * 2, i,  x - y, w);
		CF::addedge(6 + n * 2, i,  x + y, w);
	}
	CF::Dinic(), printf("%lld\n", -CF::cost);
	return 0;
}

Measured memory_bytes: 131072
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]
	fmt.Printf("%d", A*B)
	fmt.Printf("\n")
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 1760
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n,m,c,cnt=0,sum=0;
	cin>>n>>m>>c;
	vector<int>b(m);
	vector<vector<int>>a(n,vector<int>(m));
	for(int i=0;i<m;i++)cin>>b.at(i);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a.at(i).at(j);
			sum+=a.at(i).at(j)*b.at(j);
			if(j==m-1){
				sum+=c;
				if(sum>0){
					cnt++;
				}
				sum=0;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}



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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}
class trie{
public:
    trie* next[2];

    trie(){
        fill(next,next+2,(trie*)0);
    }
    void insert(const string &str){
        insert(str,0);
    }
    bool find(const string &str){
        return find(str,0);
    }
    void insert(const string &str,const int idx){
        if(idx==str.size()) return;
        if(this->next[str[idx]-'0']==NULL) this->next[str[idx]-'0']=new trie();
        this->next[str[idx]-'0']->insert(str,idx+1);
    }
    bool find(const string &str,const int idx){
        if(idx==str.size()) return true;
        if(this->next[str[idx]-'0']==NULL) return false;
        return this->next[str[idx]-'0']->find(str,idx+1);
    }
};


void solve(){
    i64 N,L;
    cin >> N >> L;

    trie tr;
    vector<string> s(N);
    rep(i,0,N){
        cin >> s[i];
        tr.insert(s[i]);
    }

    vector<i64> ds;
    queue<pair<trie*,int>> que;
    que.push(make_pair(&tr,0));
    while(!que.empty()){
        auto tmp=que.front();
        que.pop();
        auto tr=tmp.first;
        auto d=tmp.second;
        if(!tr->next[0] and !tr->next[1]) continue;
        if(tr->next[0] and tr->next[1]){
            que.push(make_pair(tr->next[0],d+1));
            que.push(make_pair(tr->next[1],d+1));
        }
        else if(tr->next[0]){
            que.push(make_pair(tr->next[0],d+1));
            ds.push_back(d+1);
        }else{
            que.push(make_pair(tr->next[1],d+1));
            ds.push_back(d+1);
        }
    }

    function<i64(i64)> grundy=[&](i64 d){
        if(d==0) return i64(0);
        i64 d_=d,res_=1;
        while(d%2==0){
            d/=2;
            res_*=2;
        }
        return res_;
    };

    i64 g=0;
    for(auto& d:ds){
        g^=grundy(L-d+1);
    }

    cout << (g?"Alice":"Bob") << endl;

}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 4680
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, p;
	while (cin >> n >> p, n) {
		int now = 0,wan=p;
		vector<int>person(n,0);
		while (true) {
			if (wan) {
				person[now]++; wan--;
				if (person[now] == p) {
					cout << now << endl;
					break;
				}
			}
			else if (person[now]) {
				wan = person[now]; person[now] = 0;
			}
			now++;
			if (now >= n)now = 0;
		}
	}
}

Measured memory_bytes: 3080
import math

listNK = list(map(int,input().split()))
N = listNK[0]
K = listNK[1]

output = 0

for i in range(N):
    X = i+1
    if X>=K:
        output += 1/N
    else:
        n = math.log2(K/X)
        n = math.ceil(n)
        output += (1/N)*(1/2)**n

print(output)

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

int main() {
  string S;
  cin >> S;
  int price = 700;

  for (int i = 0; i < 3; ++i) {
    if (S[i] == 'o') price += 100;
  }

  cout << price << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    string a,b;
    std::cin >> a >>b;
    if(a==b){
        std::cout << "EQUAL" << std::endl;
    }else if(a>b && a.length()>=b.length()){
        std::cout << "GREATER" << std::endl;
    }else{
        std::cout << "LESS" << std::endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    cout<<setprecision(16);
    ll n,k;
    cin>>n>>k;
    vector<double> v(n,0);
    rep(i,n){
        cin>>v[i];
    }
    ll l = 0;
    ll r = 1e9;

    while(r-l>1){
        ll mid = (l+r)/2.0;
        ll sum = 0;
        bool f= true;

        rep(i,n){
            ll c = v[i];
            if(mid!=0) {
                sum += (c / mid);

                if (c % mid == 0)sum--;

            }else{
                f=false;
            }
        }

        if(sum>k&&f){
            l=mid;
        }else{
            r=mid;
        }

    }



    cout<<r<<endl;






    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vii vector<vi>

int main() {
	int n, a, b;
	cin >> n >> a >> b;	
	cout << min(n*a, b) << endl;
	return 0;
}

Measured memory_bytes: 256