akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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 {
    long long to;
    long long cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
void dijkstra(const Graph &G, ll s, vector<long long> &dis) {
    ll N = G.size();
    dis.resize(N, INF);
    priority_queue<P, vector<P>, greater<P>> pq;  // 「仮の最短距離, 頂点」が小さい順に並ぶ
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {  // 最短距離で無ければ無視
            continue;
        }
        for (auto &e : G[v]) {
            if (dis[e.to] > dis[v] + e.cost) {  // 最短距離候補なら priority_queue に追加
                dis[e.to] = dis[v] + e.cost;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}
int main(){
    ll n;
    cin >> n;
    Graph g(n);
    for (ll i = 0; i < n - 1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }
    ll q, k;
    cin >> q >> k;
    k--;
    vector<ll> dist;
    dijkstra(g, k, dist);
    for (ll i = 0; i < q;i++){
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << dist[x] + dist[y] << endl;
    }
}

Measured memory_bytes: 13988
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
a.sort()
arr = [0, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
r = -1
for i in range(len(arr)):
    if a[0] < arr[i]:
        r = i
        break
ans = 1 if r != -1 else 0
ans2 = 0
for i in range(n):
    if a[i] >= arr[r]:
        r = -1
        for j in range(len(arr)):
            if a[i] < arr[j]:
                r = j
                break
        if r == -1:
            ans2 += 1
        else:
            ans += 1
print(ans if ans > 0 else 1, ans + ans2)


Measured memory_bytes: 5196
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()

s = input().strip()

ans = 0
tmp =  "_"
for c in s:
    if tmp != c:
        ans += 1

    tmp = c

print(ans)

Measured memory_bytes: 39536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

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

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        int k = Integer.parseInt(tokenizer.nextToken());
        int[] logs = new int[n];
        tokenizer = new StringTokenizer(f.readLine());
        for (int i = 0;i  < n; i++) logs[i] = Integer.parseInt(tokenizer.nextToken());

        double a = 1;
        double b = 1000000001;
        while (Math.ceil(a) != Math.ceil(b)) {
            double mid = (a + b) / 2;
            //System.out.println(a + " " + b);
            if (canReach(k, logs, mid)) {
                b = mid;
            } else {
                a = mid;
            }
        }

        out.println((int) Math.ceil(a));
        out.close();
    }

    boolean canReach(int k, int[] logs, double goal) {
        int neededMoves = 0;
        for (int log : logs) {
            neededMoves += Math.ceil(log / goal) - 1;
        }
        return neededMoves <= k;
    }
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll q,h,s,d,n,omin=1e9,tmin=1e9;
    cin >> q >> h >> s >> d >> n;
    if(omin>q*4) omin=q*4;
    if(omin>h*2) omin=h*2;
    if(omin>s) omin=s;
    if(tmin>omin*2) tmin=omin*2;
    if(tmin>d) tmin=d;
    cout << tmin*(n/2)+omin*(n%2) << endl;
    return 0;
}

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

using namespace std;

const int MAX_N = 1e5 + 200;

typedef long long ll;

int n, seq[MAX_N];
ll leaves, ans;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i <= n; i++)
		scanf("%d", &seq[i]), leaves += seq[i];
	if (n == 0)
		if (seq[0] == 1)
			puts("1"), exit(0);
		else
			puts("-1"), exit(0);
	if (seq[0] != 0)
		puts("-1"), exit(0);
	ll bas = ans = 1;
	for (int i = 1; i <= n; i++)
	{
		bas <<= 1;
		if (seq[i] > bas)
			puts("-1"), exit(0);
		ans += min(bas, leaves);
		bas = min(bas, leaves) - seq[i];
		leaves -= seq[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4204
#include <iostream>
#include <algorithm>
using namespace std;
int a;
int b;
int c;
int d;
int e;
int f;

int main(){
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	cin >> f;
	int x = max(e, f);
	int t = min(a, (min(b, (min(c,d)))));
	cout << x + (a + b + c + d) - t << endl;
	
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const int BTC2JPY = 380000;

int main() {
	int n;
	double x;
	string u;
	cin >> n;

	double ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> x >> u;

		if (u == "JPY") {
			ans += x;
		} else {
			ans += x * BTC2JPY;
		}
	}

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


Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
if x == b*(a**2):
  print(0)
elif x >= (a**2)*b/2 and x < b*(a**2):
  t = math.atan(2*((a**2)*b - x)/(a**3))
  deg = math.degrees(t)
  print(deg)

else:
  t = math.atan(a*(b**2)/(2*x))
  deg = math.degrees(t)
  print(deg)
  

Measured memory_bytes: 3060
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int n;cin >> n;
    int count=0;
    rep(i, n) {
        int a;cin >> a;
        if(a%2==0) {
            while(a%2==0) {
                a/=2;
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 2E5 + 10;

int n;
int a[N];
int mark[N];

int main(){
	scanf("%d", &n);
	bool flag = true;
	for (int i = 1; i <= n; ++i){
		scanf("%d", a + i);
		if (i == 1)
			flag &= a[i] == 0;
		else
			flag &= a[i] <= a[i - 1] + 1;
	}
	if (!flag){
		puts("-1");
		return 0;
	}

	int cnt = 0;
	ll ans = 0;
	for (int i = n; i >= 1; --i){
		if (!mark[i - a[i]])
			mark[i - a[i]] = true, ++cnt;
		cnt -= mark[i];
		ans += cnt;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
using System;

namespace _062_WhatistheBottommost
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int[] numArray = new int[10];

				//parse
				for (int lp = 0; lp < numArray.Length; lp++)
				{
					numArray[lp] = inputStr[lp] - '0';
				}

				//calculate
				for (int lp = 9; lp >= 1; lp--)
				{
					int[] tmpArray = new int[lp];

					for (int lp2 = 0; lp2 < numArray.Length - 1; lp2++)
					{
						int num = numArray[lp2] + numArray[lp2 + 1];
						num %= 10;
						tmpArray[lp2] = num;
					}

					numArray = tmpArray;
				}

				//output
				Console.WriteLine (numArray[0]);
			}
		}
	}
}

Measured memory_bytes: 8780
#include<iostream>
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
using namespace std;
vector<vector<ll>> edge;
vector<vector<ll>> dp;
vector<bool> visited;
int n;
void dfs(int i,int p){
    if(visited[i]) return;
    visited[i] = true;
    dp[i][0] = dp[i][1] = 1;
    for(int j=0;j<edge[i].size();j++){
        if(edge[i][j]==p) continue;
        if(!visited[edge[i][j]]){
            dfs(edge[i][j],i);
        }
        dp[i][0] = (dp[i][0]*(dp[edge[i][j]][0]+dp[edge[i][j]][1])%MOD)%MOD;
        dp[i][1] = (dp[i][1]*dp[edge[i][j]][0])%MOD;
    }
    return;
}
int main(){
    cin>>n;
    edge.resize(n);
    visited.resize(n,false);
    dp.resize(n,vector<ll>(2,0));
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        edge[x-1].push_back(y-1);
        edge[y-1].push_back(x-1);
    }
    dfs(0,-1);
    cout<<(dp[0][0]+dp[0][1])%MOD<<endl;
}

Measured memory_bytes: 16768
#include <bits/stdc++.h>
#include <atcoder/convolution>

using namespace std;
using namespace atcoder;
typedef long long ll;

const ll mod=998244353;
const int N=100000;

ll fpow(ll b,ll e)
{
    ll res=1;
    while(e)
    {
        if(e&1) res=(res*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> f(2*n+1,1);
    for(ll i=1;i<=2*n;i++) f[i]=(f[i-1]*i)%mod;
    vector<ll> finv(2*n+1,1);
    finv[2*n]=fpow(f[2*n],mod-2);
    for(ll i=2*n-1;i>=0;i--) finv[i]=(finv[i+1]*(i+1))%mod;
    auto c=[&](int a,int b)->ll
    {
        ll res=f[a];
        res=(res*finv[b])%mod;
        res=(res*finv[a-b])%mod;
        return res;
    };
    vector<int> cnt(N+1,0);
    for(int i=0;i<2*n;i++)
    {
        int a;
        cin >> a;
        cnt[a]++;
    }
    vector<ll> p(2*n+1,1);
    for(int i=1;i<=2*n;i++) p[i]=(2*p[i-1])%mod;
    multiset<pair<int,vector<ll>>> s;
    s.insert({1,{1}});
    for(int i=1;i<=N;i++)
    {
        if(cnt[i]<2) continue;
        vector<ll> now={1};
        for(int j=2;j<=cnt[i];j+=2)
        {
            ll x=c(cnt[i],j);
            x=(x*f[j])%mod;
            x=(x*fpow(p[j/2],mod-2))%mod;
            x=(x*finv[j/2])%mod;
            now.push_back(x);
        }
        s.insert({now.size(),now});
    }
    while(s.size()>1)
    {
        vector<ll> one=(*s.begin()).second;
        s.erase(s.begin());
        vector<ll> two=(*s.begin()).second;
        s.erase(s.begin());
        vector<ll> three=convolution<mod>(one,two);
        s.insert({three.size(),three});
    }
    vector<ll> bad=(*s.begin()).second;
    //for(int i=0;i<(int)bad.size();i++) cout << i << ": " << bad[i] << endl;
    ll res=0;
    for(int i=0;i<=n;i++)
    {
        if((int)bad.size()<=i) break;
        ll now=c(n,i);
        now=(now*f[i])%mod;
        now=(now*f[2*n-2*i])%mod;
        now=(now*p[i])%mod;
        now=(now*bad[i])%mod;
        //cout << "i=" << i << " -> " << now << endl;
        if((i%2)==0) res=(res+now)%mod;
        else res=(res-now+mod)%mod;
    }
    res=(res*finv[n])%mod;
    res=(res*fpow(p[n],mod-2))%mod;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 9452
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
//#define iinf (3000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int i,c=1;
	string s;
	cin>>s;	
	rep(i,s.length()-1){
		if(c==3){
			cout<<"Yes"<<endl;
			return 0;
		}
		if(s[i]==s[i+1]){
			c++;
		}
		else{
			c=1;
		}
	}	
	if(c==3){
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
} 


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define RREP(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define ALL(vector) vector.begin(), vector.end()

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

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
 
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n
 
const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;
 
void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}
 
void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}
 
void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}
 
int main(){
  int N,M,Q;
  cin >> N >> M >> Q;
  VVI c(N,VI(N,0));
  REP(i,M){
    int L,R;
    cin >> L >> R;
    L--;
    R--;
    c[L][R]++;  
  }
  REP(i,N){
    FOR(j,1,N){
      c[i][j]+=c[i][j-1];  
    }
  }
  REP(i,Q){
    int L,R;
    cin >> L >> R;
    L--;
    R--;
    int sum=0;
    FOR(j,L,R+1){
      sum+=c[j][R];
    }
    cout<<sum<<endl;
  }
  
 return 0;
}
 

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

using namespace std;

typedef long long ll;
typedef long double ld;

int n;
ll dp[105][100005];
int arr[105][2];

ll solve(int idx, int rem)
{
  if(rem < 0)
    return -1e10;
  if(idx == n)
    return 0;
  ll &ans = dp[idx][rem];
  if(ans != -1)
    return ans;
  return ans = max(solve(idx + 1, rem), solve(idx + 1, rem - arr[idx][0]) + arr[idx][1]);
}

int main()
{
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int w;
  cin >> n >> w;
  for(int i = 0; i < n; i++)
    cin >> arr[i][0] >> arr[i][1];
  memset(dp, -1, sizeof(dp));
  cout << solve(0, w);
  return 0;
}


Measured memory_bytes: 82304
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n, W;
    long long ans = 0;
    cin >> n >> W;

    vector<bool> p(W + 1, false); // constructed weight
    vector<int> w(n + 1, 0);     // item weight
    vector<long long> v(n + 1, 0);     // item value
    vector<long long> V(W + 1, 0);     // maximum value for constructed weight
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }

    p[0] = true;
    for (int k = 1; k <= n; k++) {
        for (int x = W; x >= 0; x--) {
            if (p[x] == true && x + w[k] <= W) {
                p[x + w[k]] = true;
                V[x + w[k]] = max(V[x + w[k]], V[x] + v[k]);
                ans = max(ans, V[x + w[k]]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3960
import java.io.*;

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

  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
  String[] strAry = str.split(" ");
  int a = Integer.parseInt(strAry[0]);
  int b = Integer.parseInt(strAry[1]);
  int c = Integer.parseInt(strAry[2]);  

  if(b>a&&c>b){
  
     System.out.println("Yes");

  }else {

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

Measured memory_bytes: 24228
#include<iostream>
#include<cstring>
using namespace std;
char s[100050];int a[30];
int main()
{
	int i;
	for(i=0;i<26;i++)
		a[i]=0;
	cin>>s;
	for(i=0;i<strlen(s);i++)
		if(a[s[i]-'a']!=1) a[s[i]-'a']=1;
	for(i=0;i<26;i++)
		if(a[i]==0){cout<<(char)(i+97);return 0;}
	cout<<"None";
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  vector<vector<bool>> L(N, vector<bool>(10, false));
  repp(i, 1, N - 1) {
    rep(j, 10) {
      if (L[i - 1][j])
        L[i][j] = true;
      L[i][S[i - 1] - '0'] = true;
    }
  }

  vector<vector<bool>> R(N, vector<bool>(10, false));
  repr(i, N - 2, 0) {
    rep(j, 10) {
      if (R[i + 1][j])
        R[i][j] = true;
      R[i][S[i + 1] - '0'] = true;
    }
  }


  vector<vector<vector<bool>>> cnt(
      10, vector<vector<bool>>(10, vector<bool>(10, false)));

  rep(i, N) {
    int c = S[i] - '0';
    rep(j, 10) {
      rep(k, 10) {
        if (L[i][j] && R[i][k])
          cnt[j][c][k] = true;
      }
    }
  }

  int ans = 0;
  rep(i, 10) {
    rep(j, 10) {
      rep(k, 10) {
        if (cnt[i][j][k])
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4480
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> v;
	char prev = s[0];
	int cnt = 1;
	for (int i = 1; i < n; i++) {
		if (s[i] == prev) {
			cnt++;
		} else {
			v.push_back(cnt);
			cnt = 1;
			prev = s[i];
		}
	}
	v.push_back(cnt);
	vector<int> vsum(v.size() + 1, 0);
	for (int i = 1; i <= v.size(); i++) {
		vsum[i] = vsum[i - 1] + v[i - 1];
	}
	int ans = 0;
	if (s[0] == '0') {
		ans = vsum[min((int)v.size(), 2 * k)];
		for (int i = 1; i <= v.size(); i += 2) {
			ans = max(ans, vsum[min((int)v.size(), i + 2 * k + 1)] - vsum[i]);
		}
	} else {
		for (int i = 0; i <= v.size(); i += 2) {
			ans = max(ans, vsum[min((int)v.size(), i + 2 * k + 1)] - vsum[i]);
		}
	}
	cout << ans << endl;
}

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

int main() {
    ll N, K;
    cin >> N >> K;
    ll A[N], F[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];
    sort(A, A + N);
    sort(F, F + N, greater<int>());

    ll l = -1, r = 10e12;
    while (l + 1 < r) {
        ll mid = (l + r) / 2, sum = 0;
        rep(i, N) {
            sum += max(A[i] - mid / F[i], 0ll);
        }
        if (sum > K) l = mid;
        else r = mid;
    }
    cout << r << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	vector<int> b(n + 1, 0);
	vector<int> wa(n + 1, 0);
	ll ac = 0;
	ll WA = 0;
	rep(i, m) {
		int P;
		string s;
		cin >> P >> s;
		if (s == "AC") b[P] = min(b[P] + 1, 1);
		else if (b[P] == 1) continue;
		else wa[P]++;
	}
	rep(i, n + 1) ac += b[i];
	rep(i, n + 1) {
		if (b[i] != 0) WA += wa[i];
	}
	cout << ac << " " << WA;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  vb bh(h, false);
  vb bw(w, false);
  rep(i, h)
  {
    rep(j, w)
    {
      cin >> a.at(i).at(j);
      if (a.at(i).at(j) == '#')
      {
        bh.at(i) = true;
        bw.at(j) = true;
      }
    }
  }
  rep(i, h)
  {
    rep(j, w)
    {
      if (bh.at(i) && bw.at(j))
      {
        cout << a.at(i).at(j);
      }
    }
    if(bh.at(i)){
      cout << endl;
    }
  }

  return 0;
}

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

using lli=long long int;

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

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

int main(){
  lli N, M;
  std::cin >> N >> M;
  std::vector<lli> a_arr(N);
  for(int i = 0; i < N; i++) std::cin >> a_arr[i];

  lli lcmt = a_arr[0]/2;
  for(int i = 1; i < N; i++){
    lcmt = lcm(lcmt, a_arr[i]/2);
    if(lcmt > M){
      std::cout << 0 << std::endl;
      return 0;
    }
  }
  for(int i = 0; i < N; i++){
    if(lcmt%a_arr[i] == 0){
      std::cout << 0 << std::endl;
      return 0;
    }
  }

  std::cout << (M/lcmt+1)/2 << std::endl;

  return 0;
}



Measured memory_bytes: 1024
coins = (500, 100, 50, 10, 5, 1)

def count(x, y):
    ret = 0
    while x >= y:
        x -= y
        ret += 1
    return x, ret

while True:
    n = input()
    if n == 0:
        break
    ans = 0
    n = 1000 - n
    for val in coins:
        n,  t = count(n, val)
        ans += t

    print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int p = max(a, c);
    int q = min(b, d);
    cout << max(0, q - p);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

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

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	int n, c = 0;
	cin >> n;
	for(int i=1;i<=n;i++) {
		int t;
		cin >> t;
		if(t != i) c++;
	}
	cout << (c <= 2 ? "YES" : "NO") << endl;

}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < n; i++)
//#define sum(start, end) accumulate(start, end, 0)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

using namespace std;
template <class T = ll> T in() { T _in; cin >> _in; return (_in); }


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

    string s = in<string>(), t = in<string>();

    sort(ALL(s));
    sort(ALL(t), greater<char>());

    if(s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N, M;
vector<pii> lv[301]; // [r_i] = (l_i, x_i)
ll dp[301][301][301];

int main() {
	cin >> N >> M;
	REP(i, M) {
		int l, r, x;
		scanf("%d %d %d", &l, &r, &x);
		lv[r].push_back(pii(l, x));
	}
	
	ll ans = 0;
	
	dp[0][0][0] = 1;
	REP(i, N + 1) {
		REP(j, N + 1) {
			REP(k, N + 1) {
				int r = max(i, max(j, k));
			
				REP(l, lv[r].size()) {
					int cnt = (i >= lv[r][l].fi) + (j >= lv[r][l].fi) + (k >= lv[r][l].fi);
					if (cnt != lv[r][l].se) dp[i][j][k] = 0;
				}
				
				if (dp[i][j][k] == 0) continue;
				
				if (r == N) {
					(ans += dp[i][j][k]) %= MOD;
					continue;
				}
				
				(dp[r + 1][j][k] += dp[i][j][k]) %= MOD;
				(dp[i][r + 1][k] += dp[i][j][k]) %= MOD;
				(dp[i][j][r + 1] += dp[i][j][k]) %= MOD;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 213376
#include <iostream>
using namespace std;
int memo[1000];
int fib(int n){
    if(n == 0 || n == 1){
        return (memo[n] = 1);
    }else{
        if(memo[n-2] == 0) memo[n-2] = fib(n-2);
        if(memo[n-1] == 0) memo[n-1] = fib(n-1);
        if(memo[n] == 0) memo[n] = memo[n-2] + memo[n-1];
        return memo[n];
    }
}

int main(){
    int n;
    cin >> n;
    cout << fib(n) << endl;
    return 0;
}


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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mp             make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));

int main()
{
	/*int n,q,l,r,ac=0;
	string str;
	cin>>n>>q>>str;
	int pre[n+5];
	mem(pre,0);
	for(int i=0;i<n;){
		if(str[i]=='A'&&str[i+1]=='C'){
			ac++;
			pre[i+2]=ac;
			pre[i+1]=ac-1;
			i+=2;
		}
		else{
			pre[i+1]=ac;
			i++;
		}
	}*/
	/*for(int i=1;i<=n;i++)cout<<pre[i]<<" ";
	cout<<endl;*/
	/*while(q--){
		cin>>l>>r;
		cout<<pre[r]-pre[l]<<endl;
	}*/
	char ch;
	cin>>ch;
	if(ch=='A')cout<<"T\n";
	if(ch=='T')cout<<"A\n";
	if(ch=='G')cout<<"C\n";
	if(ch=='C')cout<<"G\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int datanum;
	int card[100] = {};
	int i, j;
	int tmp = 0;
	int sumnum1 = 0;
	int sumnum2 = 0;
	scanf("%d", &datanum);
	for (i = 0; i < datanum; i++) {
		scanf("%d", &card[i]);
	}

	for (i = 0; i < datanum; i++) {
		for (j = i + 1; j < datanum; j++) {
			if (card[i] < card[j]) {
				tmp = card[i];
				card[i] = card[j];
				card[j] = tmp;
			}
		}
	}

	i = 0;
	while (i < datanum) {
		sumnum1 += card[i++];
		sumnum2 += card[i++];
	}
	printf("%d\n", (sumnum1 - sumnum2));
    return 0;
}

Measured memory_bytes: 128
#include<iostream>   //AA06( 15/ 07/ 20) If u see my code, Have a Good Day! (^_^)
#include<set>
#include<iterator>
#define JonSnow ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

using namespace std;

int main()
{
    JonSnow;

    int n, A;

    set <int> S;

    set <int> :: iterator I;

    cin >> n;

    while(n--) {

        cin >> A;

        I = S.find(A);

        if (I == S.end()) {

            S.insert(A);

        }

        else {

            S.erase(A);

        }

    }

    cout << S.size() << endl;

    return 0;
}


Measured memory_bytes: 8256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <numeric>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<pair<int,int> > s;
    REP(i,n)
    {
        int a,b;
        cin >> a >> b;
        s.push_back(make_pair(a,b));
    }
    sort(s.begin(),s.end());
    unsigned long long cost = 0;
    int drinks = 0;
    REP(i,n)
    {
        int buy;
        buy = min(s[i].second, m - drinks);
        drinks += buy;
        cost += (unsigned long long)s[i].first * buy;
        if(drinks == m)
        {
            break;
        }
    }
    cout << cost << endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int n,k;
while(cin>>n>>k){
    if(n==0)cout<<0<<endl;
    else {
        long long int minn=n%k;
        long long int x=abs(minn-k);
        if(x<minn) cout<<x<<endl;
        else cout<<minn<<endl;

    }
}
return 0;
}


Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

# N, M, X = list(map(int, sys.stdin.readline().split()))
# A = np.array(list(map(int, sys.stdin.readline().split())))
#
# print(min(len(A[A > X]), len(A[A<X])))

# A, B, K = list(map(int, sys.stdin.readline().split()))
#
# arr = list(range(A, B + 1))
#
# print('\n'.join(map(str, list(sorted(set(arr[:K] + arr[-K:]))))))


N = int(sys.stdin.readline())
D, X = list(map(int, sys.stdin.readline().split()))
A = [int(sys.stdin.readline()) for _ in range(N)]

c = 0
for a in A:
    c += len(range(1, D + 1, a))
print(c + X)


Measured memory_bytes: 15700
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll a,b,c,k,cnt=0;
	cin>>a>>b>>c>>k;
	while(b<=a){
		b=b*2;
		cnt++;
	}
	while(c<=b){
		c=c*2;
		cnt++;
	}
	if(cnt<=k)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;	
	
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - H * w - h * W + h * w << endl;
    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[0] == s[2]){
        cout << "Yes\n";
    }
    else if(s[1] == s[2] && s[1] == s[3]){
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#define INF 999999999
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
vector<int> p[130];
vector<int> cost[130];

int DistanceCalc(int dis,int com){
  int Index,totalcost;
  Index = totalcost = 0;
 
  /*
  rep(du,dis){
    // cout << "dis = " << dis << ", p[" <<com <<"]["<< Index <<"] = " << p[com][Index] << endl;  
     totalcost += cost[com][Index];
     if(p[com].size() != 0 && p[com][Index] == du){
      Index++;
    }
  
  }
  return totalcost;
  */
  int remain=0;
  rep(i,p[com].size()){
    if(remain <= dis && dis <= p[com][i])return totalcost+cost[com][i]*(dis-remain);
    else totalcost += cost[com][i]*(p[com][i]-remain);
    remain = p[com][i]; 
  }
  if(p[com].size() != 0)return totalcost+cost[com][p[com].size()]*(dis-p[com][p[com].size()-1]);
  else return cost[com][0]*dis;
}


int main(){
  int n,m,c,s,g,x,y,d,cc;
  int AllD[30][130][130];
  int D[130][130];
 
  while(cin >> n >> m >> c >> s >> g){
    if(n+m+c+s+g == 0)break;
    for(int i=0;i<25;i++){
      for(int j=0;j<130;j++){
	p[j].clear();
	cost[j].clear();
	for(int k=0;k<130;k++){
	  AllD[i][j][k] = INF;
	  D[j][k] = INF;
	}
      }
    }
    rep(i,m){
      cin >> x >> y >> d >> cc;
      AllD[cc-1][x-1][y-1] = min(d,AllD[cc-1][x-1][y-1]);//hukusu taisaku
      AllD[cc-1][y-1][x-1] = min(d,AllD[cc-1][y-1][x-1]);
    }
    int pin[c+1];
    rep(i,c){
      cin >> pin[i];
    }
    int pp;

    rep(j,c){// MINA
      rep(i,pin[j]-1){
	cin >> pp; 
	p[j].push_back(pp);//-1
      }
      rep(i,pin[j]){
	cin >> pp;
	cost[j].push_back(pp);
      }
    }// MIKE

 rep(j,c){
      rep(i,n){
	AllD[j][i][i] = D[i][i]= 0;
      }
    } 



    /*
    rep(i,c){
      cout << "会社 - " << i << endl;
      rep(j,n){
	rep(k,n){
	  cout << AllD[i][j][k] << " ";
	}
	cout << endl;
      }
    }
    cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^" << endl;
    */

    /*
    rep(i,c){
      rep(j,n){
	rep(k,n){
	  if(AllD[i][j][k] != INF){
	    cout << "i = " << i << ", j = " << j << ", k = " << k << endl;
	    cout << AllD[i][j][k] << endl;
	    AllD[i][j][k] = DistanceCalc(AllD[i][j][k],i);
	  }
	}
      }
    }
    */
   

    /*
    rep(i,c){
      rep(j,n){
	rep(k,n){
	  rep(l,n){
	    AllD[i][k][l] = min(AllD[i][k][l],AllD[i][k][j]+AllD[i][j][l]);
	    D[k][l] = min(D[k][l],AllD[i][k][l]);
	  }
	}
      }
    }
    */


    rep(i,c){
      rep(j,n){
	rep(k,n){
	  rep(l,n){
	    if(AllD[i][k][j] != INF && AllD[i][j][l] != INF && k!=l){ 
	      AllD[i][k][l] = min(AllD[i][k][l],AllD[i][k][j]+AllD[i][j][l]);
	      D[k][l] = min(D[k][l],DistanceCalc(AllD[i][k][l],i));
	    }
	  }
	}
      }
    }


    /*
 rep(i,n){
      rep(j,n)cout << D[i][j] << " ";
      cout << endl;
    }    
 cout << "----------------" << endl;
    */

    rep(k,n)rep(i,n)rep(j,n)D[i][j] = min(D[i][j],D[i][k]+D[k][j]);

    /*
    rep(i,n){
      rep(j,n)cout << D[i][j] << " ";
      cout << endl;
    }    
    */

    if(D[s-1][g-1] >= INF)cout << "-1" << endl;
    else cout << D[s-1][g-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 2640
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

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

/*
-9

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mxn = 1e5+5;
vector<int> adj[mxn];
vector<int> vis(mxn);
long long int dp[mxn][2];
const int modi = 1e9+7;

void add_mod(long long int& a, long long int b){
	a+=b;
	if(a>=modi)
		a-=modi;
}

void dfs(int u,int p=-1){
	vis[u] = 1;
	// cout << u << endl;
	if(adj[u].size()==1 && p !=-1){
		dp[u][0] = dp[u][1] = 1;
		// cout << u << endl;
		return;
	}

	long long int ifwhite =1,ifblack = 1;
	for(auto v:adj[u]){
		if(!vis[v]){
			dfs(v,u);
			ifwhite = ifwhite*(dp[v][1]+dp[v][0])%modi;
			ifblack = ifblack*(dp[v][0])%modi;
		}
	}
	add_mod(dp[u][0],ifwhite);
	add_mod(dp[u][1],ifblack);
}


int main(){
	int n;
	cin >> n;
	for(int i =0;i<n-1;i++){
		int u,v;
		cin >> u >> v;--u,--v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	if(n==1){
		cout << 2 << endl;return 0;
	}
	dfs(0);
	add_mod(dp[0][0],dp[0][1]);
	cout << dp[0][0] <<endl;
}

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += (long long) a[i] * a[j];
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3656
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: f64 = read();
    let ans = (n / 1.08).ceil();
    if n == (ans * 1.08).floor() {
        println!("{}", ans);
    } else {
        println!(":(");
    }
}


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

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  
  //3種類
  if (N >= 105) { //3*5*7
	cnt++;
  }
  if (N >= 165) { //3*5*11
    cnt++;
  }
  if (N >= 195) { //3 *5*13
    cnt++;
  }
  //2種類
  if (N >= 135) { //3^3*5
    cnt++;
  }
  if (N >= 189) { //3^3*7
    cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
array_s=[]
result=[]
flg=0
###入力############
text_s=input()

text_p=input()
###################

array_s=list(text_s)


##組み合わせを考える

end=len(array_s)
new=""
#配列は0から;endまで

for k in range(0,end):

    for i in range(k,end):
        new=new+array_s[i]
    for j in range(0,k):
        new=new+array_s[j]
    result.append(new)
    new=''

for i in result:
    if text_p in i:
        flg=1
    else:
        pass

if flg==1:
    print("Yes")
else:
    print("No")


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    rep(i, 100)
    {
        rep(j, 100)
        {
            if (4 * i + 7 * j == n)
            {
                OP("Yes");
                return 0;
            }
        }
    }

    OP("No");
    return 0;
}

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

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

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

// value
int N, D;
double X[12][12];

void solve() {

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

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			double dis = 0;
			for (int k = 0; k < D; k++) {
				dis += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
			dis = sqrt(dis);
			if (dis - int(dis) == 0.0) ans++;
		}
	}

	cout << ans << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5;
typedef long long ll;
ll a[maxn+5];
int n;
int main()
{

    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%lld",&a[i]),a[i]-=i;
    sort(a+1,a+n+1);
    ll ans=0;
    for(int i=1;i<=n;++i) ans+=abs(a[i]-a[(1+n)/2]);
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
    string S;
    cin >> S;
    int count0 = 0, count1 = 0;
    rep(i, 0, S.size()){
        if(S[i] == '0') count0++;
        if(S[i] == '1') count1++;
    }
    int ans = 2*min(count0, count1);
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int h = sc.nextInt();
    int ans = (a + b) * (h / 2);
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

print(
    min(
        len(list(filter(lambda x: x <= A, P))),
        len(list(filter(lambda x: A < x <= B, P))),
        len(list(filter(lambda x: B < x, P))),
    )
)


Measured memory_bytes: 2940