akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

long int value(long int a, long int b) {
	if (a > b) {
		return a - b;
	}
	else {
		return b - a;
	}
}

int main() {
	int n;
	long int temp = 0;
	long int sum1 = 0;
	long int sum = 0;
	long int min = 2e+9;
	scanf("%d", &n);
	
	long int *a;
	a = (long int *)malloc(n * sizeof(long int));
	 
	for (int i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
		sum += a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		sum1 += a[i];
		temp = value(2 * sum1, sum);
		if (temp < min) {
			min = temp;
		}
	}
	printf("%ld", min);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;

const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

int main(){
    int n, k; cin >> n >> k;
    vi a(n);
    REP(i, n) cin >> a[i];
    int ans = (n-1) / (k-1);
    int m = (n-1) % (k-1);

    if (m == 0) cout << ans << endl;
    else cout << (ans + 1) << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n ; 
    ll k ;
    cin >> n >> k ;
    vll a(n) ;
    REP(i,n){
        ll b ;
        cin >> b ;
        a[i] = b-1 ;
    }
    vint cnt(n,-1) ;
    ll i = 0 ;
    ll len ;
    ll x = 0 ;
    ll ke ;
    while(1){
        if(cnt[x]==-1){
            cnt[x] = i ;
            i++ ;
            x = a[x] ;
        }
        else{
            len = i - cnt[x] ;
            ke = cnt[x] ;
            break ;
        }
    }
    /*
    cout << "len " <<len <<endl ;
    cout <<"ke " <<ke << endl ;
    REP(i,n){
        cout << i<<" " <<cnt[i] <<endl ;
    }
    */

    if(k<=ke){
        REP(i,n){
            if(cnt[i]==k){
                cout << i+1 <<endl ;
                return 0 ;
            }
        }
    }
    else{
        REP(i,n){
            if(cnt[i]==ke+(k-ke)%len){
                cout << i+1 <<endl ;
                return 0 ;
            }
        }
    }





    


    

    return 0;
}


Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 998244353
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 a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll N; cin >> N;
    vl a(N);
    rep(i, N) cin >> a[i];
    rep(i, N) a[i] -= i+1;

    sort(all(a));

    ll ans = 0;
    rep(i, N) ans += abs(a[i] - a[N / 2]);

    cout << ans << endl;

}

Measured memory_bytes: 4448
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main()
{
    int n; cin >> n;
    map<string,int> mp;
    rep(i, n){
        string s; cin >> s;
        mp[s]++;        
    }
    int mx_size = 0;
    for(auto p : mp) mx_size = max(mx_size,p.second);
    for(auto p : mp) if(p.second==mx_size) cout << p.first << endl;
}

/*
g++ c.cpp
./a.out

oj d URL
oj t
*/

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void)
{
  string s;
  cin >> s;

  s[5] = ' ';
  s[13] = ' ';

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <string>
#define min_a 2800
#define max_a 5000

using namespace std;

int main (void)
{
  int a;
  string s;
  
  cin >> a;
  cin >> s;
  
  if(min_a <= a && a <= max_a)
  {
    if(a >= 3200)
      cout << s;
    else
      cout << "red";
  }
  else
  {
  	return 1;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main()
{
  cin.tie(0);
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  bool ans = false;

  if (b - a > k) ans = true;
  if (c - a > k) ans = true;
  if (d - a > k) ans = true;
  if (e - a > k) ans = true;
  if (c - b > k) ans = true;
  if (d - b > k) ans = true;
  if (e - b > k) ans = true;
  if (d - c > k) ans = true;
  if (e - c > k) ans = true;
  if (e - d > k) ans = true;

  cout << (ans ? ":(" : "Yay!") << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var N = input;

  var angles = (N - 2) * 180;

  console.log('%d', angles);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
vector<int> G[220];
bool visited[220];

int righ(int i) {
    //vをV0に入れる
    memset(visited, 0, sizeof(visited));

    set<int> par, vs, to;
    par.insert(i);
    visited[i] = true;
    for (int t:G[i]) {
        vs.insert(t);
        visited[t] = true;
    }
    int ans = 1;
    while (true) {
        if (vs.empty()) {
            rep(i, N) {
                if (!visited[i])return 0;
            }
            return ans;
        }
        for (int v:vs) {
            for (int t:G[v]) {
                if (!par.count(t)) {
                    if (visited[t]) {
                        return 0;
                    }
                    to.insert(t);
                }
            }
        }
        for (int t:to) {
            visited[t] = true;
        }
        par = vs;
        vs = to;
        to.clear();
        ans++;
    }
}

signed main() {
    cin >> N;
    rep(i, N) {
        rep(j, N) {
            char c;
            cin >> c;
            if (c == '1') {
                G[i].push_back(j);
            }
        }
    }
    int rightest = 0;
    rep(i, N) {
        rightest = max(rightest, righ(i));
    }
    if (rightest == 0)rightest = -1;
    cout << rightest << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 1;
	for(int i = 2; i * i <= n; i++){
		int now = i * i;
		while(now * i <= n){
			now *= i;
		}
		ans = max(ans, now);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;

int main(){
    ll n,k;cin>>n>>k;
    ll a,b,c,ans=0;
    vector<bool> visit(k,false);


    ll spare;//aに対しての、b,cのあまり(条件を満たすようにあまりで探索)
    for(a=1;a<=n;a++){
        if(a%k>=0){spare=k-(a%k);}
        else{spare=-(a%k);}

        if(!(visit[spare]) && (2*a)%k==0){ans+=(((n-spare)/k+1)*((n-spare)/k+1)*((n-spare)/k+1));}
        visit[spare]=true;
    }

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

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pp pair< ll, pair<ll,ll> >

int main()
{
    int x; cin>>x;
    cout << (x^1) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
//_____
#define pb push_back
#define mkp make_pair
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
//_______

vector <int> G[100005];
int group[100005];
int color = 1;

void dfs(int u)
{
   if(group[u] != 0)return;
   group[u] = color;

   rep(i, G[u].size())
      dfs( G[u][i] );
}

signed main()
{
   FAST();
   int N, M;
   cin >> N >> M;

   rep(i, M){
      int a,b;
      cin >> a >> b;
      G[a].pb(b);
      G[b].pb(a);
   }

   rep(i, N){
      dfs(i);
      ++color;
   }

   int Q;
   cin >> Q;
   while(Q--){
      int a,b;
      cin >> a >> b;
      outl( group[a] == group[b] ? "yes" : "no" );
   }
}



Measured memory_bytes: 12100
for i in range(3):
    A, B, C, D, E, F = map(int, input().split())

    t = 3600 * (D - A) + 60 * (E - B) + (F - C)
    h = t // 3600
    t %= 3600
    m = t // 60
    t %= 60
    s = t % 60
    print(h, m, t)



Measured memory_bytes: 5596
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    string s;cin>>s;
    vec<string> x = {"Sunny", "Cloudy", "Rainy"};
    
    if (s[0]=='S'){
        cout << x[1] << endl;
    }
    if (s[0]=='C'){
        cout << x[2] << endl;
    }
    if (s[0]=='R'){
        cout << x[0] << endl;
    }

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var xy = Console.ReadLine().Split().Select(long.Parse).ToArray();
            int ans = 1;
            while (xy[0] <= xy[1] / 2)
            {
                xy[0] *= 2;
                ans++;
            }

            Console.WriteLine(ans);





        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, M;
    cin >> N >> M;
    vector<P> items(M);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        ll s = 0;
        rep(j, b) {
            ll c;
            cin >> c;
            c--;
            s |= (1 << c);
        }
        items[i] = make_pair(a, s);
    }
    vector<ll> dp(1 << N, INF);
    dp[0] = 0;
    rep(i, 1 << N) {
        rep(j, M) {
            P p = items[j];
            dp[i | p.second] = min(dp[i | p.second], dp[i] + p.first);
        }
    }
    ll ans = dp[(1 << N) - 1];
    if (ans == INF) {
        cout << -1 << '\n';
    } else {
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;

	if(s.back() == 's') s += "es";
	else s += "s";
	printf("%s\n", s.c_str());
	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {
	int p[3];
	int max, min;
	int i;
	max = 0;
	min = 0;
	for (i = 0; i < 3; ++i) {
		scanf("%d", &p[i]);
		max = max + p[i];
		if (p[i]>min) {
			min = p[i];
		}
	}
	int ans = max - min;
	printf("%d", ans);
	return 0;
}

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

int main(){
  ll n, k;
  cin >> n >> k;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  ll l = -INF, r = INF;
  while(r - l > 1) {
    ll m = (l + r)/2;
    ll t = 0;
    rep(i,n) {
      if(a[i] == 0) {
        if(m >= 0) t += n; 
      } else if(a[i] > 0) {
        int b;
        if(m >= 0) {
          b = upper_bound(a,a+n,m/a[i]) - a;
        } else {
          ll x = -m;
          ll c = x/a[i];
          if(x % a[i]) c++;
          b = upper_bound(a,a+n,-c) - a;
        }
        t += b;
      } else {
        int b;
        if(m < 0) {
          ll x = -m, y = -a[i];
          b = lower_bound(a,a+n,(x+y-1)/y) - a; 
        } else {
          ll y = -a[i];
          b = lower_bound(a,a+n,-(m/y)) - a; 
        }
        t += n - b;
      }
      if(a[i]*a[i] <= m) t--;
    }
    if(t >= 2*k) r = m;
    else l = m;
  } 
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	while (n*n + m * m != 0) {
		vector<int> si(n);
		for (int i = 0; i < n; i++) {
			cin >> si[i];
		}
		int ma = 1;
		int kai = 0;
		while (ma < n) {
			kai++;
			int x;
			cin >> x;
			ma += x;
			if (ma < n) {
				ma += si[ma - 1];
			}
		}
		cout << kai << endl;
		for (int i = kai; i < m; i++) {
			int x; cin >> x;
		}
		cin >> n >> m;
	}
}



Measured memory_bytes: 3012
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) (y) < 0 || h <= (y) || (x) < 0 || w <= (x)
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

struct p {
    ll a, b;
    p(ll x, ll y) :a(x), b(y) {};
    bool operator<(p x) {
        if (a == x.a)return b > x.b;
        return a < x.a;
    }
};

int main() {
    init();

    int n, t; cin >> n >> t;
    vector<p> ab;
    FOR(i, 0, n) {
        ll a, b; cin >> a >> b;
        ab.emplace_back(a, b);
    }

    vector<vector<VL>> dp(n + 1, vector<VL>(t, VL(2)));
    FOR(i, 0, n)FOR(j, 0, t)FOR(k, 0, 2) {
        chmax(dp[i + 1][j][k], dp[i][j][k]);
        if (j + ab[i].a < t)chmax(dp[i + 1][j + ab[i].a][k], dp[i][j][k] + ab[i].b);
        if (k == 0)chmax(dp[i + 1][j][0], dp[i][j][1] + ab[i].b);
    }

    ll ans = max(dp[n][t - 1][0], dp[n][t - 1][1]);
    cout << ans << "\n";
}


Measured memory_bytes: 492928
#include<iostream>
using std::cout;
using std::cin;
using std::endl;

#include<vector>
using std::vector;

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int cntAC = 0;
    int cntWA = 0;
    int cntTLE = 0;
    int cntRE = 0;
    int n = sc.nextInt();
    for(int i = 0; i < n; i++){
      String type = sc.next();
      if("AC".equals(type)) cntAC++;
      if("WA".equals(type)) cntWA++;
      if("TLE".equals(type)) cntTLE++;
      if("RE".equals(type)) cntRE++;

    }
    System.out.println("AC x " + cntAC);
    System.out.println("WA x " + cntWA);
    System.out.println("TLE x " + cntTLE);
    System.out.println("RE x " + cntRE);
  }
}


Measured memory_bytes: 58536
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(s) (int)(s.size())
#define all(v) v.begin(),v.end()
#define endl "\n"
using namespace std;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
void Run() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin); freopen("outt.txt", "w", stdout);
#endif
}
const int N = 1e5 + 10;
int f[N];
int e[N];
vector<string> buildArray(vector<int>& v, int n) {

    vector<string>ans;
    int cur = 0;
    for (int i = 1; i <= n; i++)
    {
        if (cur < v.size() && i == v[cur] ) {
            ans.push_back("Push");
            cur++;
        }
        else if(i<v[v.size()-1])
        {
            ans.push_back("Push");
            ans.push_back("Pop");
        }

    }
    return ans;
}
int main()
{
    Run();
    string s, t; cin >> s >> t;
    bool ok = 1;
    for (int i = 0; i < sz(s); i++)
    {
        if (s[i] != t[i]) {
            ok = 0;
            break;
        }
    }
    ok ? cout << "Yes" : cout << "No";
}


Measured memory_bytes: 3644
def cross_product(a,b):
  return (a.conjugate()*b).imag
P = [] #頂点列
n = int(input())
for i in range(n):
    x,y = map(float,input().split())
    P.append(complex(x,y))
N=len(P)#頂点の個数
total = 0.0
for i in range(1,N-1):
    a,b,c = P[0],P[i],P[i+1]
    total += cross_product(b-a,c-a)
print('{:.1f}'.format(abs(total)/2.0))



Measured memory_bytes: 5628
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    vector<int> b(n), a(n);
    REP(i, n) cin >> b[i];
    a[0] = b[0];
    a[n-1] = b[n-2];
    FOR(i, 1, n-2) {
        a[i] = min(b[i-1], b[i]);
    }
    cout << accumulate(ALL(a), 0) << endl;
    return 0;
}

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

#include <atcoder/all>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#ifdef _DEBUG
#define PRE_COMMAND             \
    std::cin.rdbuf(in.rdbuf()); \
    std::cout << fixed << setprecision(15);
#else
#define PRE_COMMAND cout << fixed << setprecision(15);
#endif
const double EPS = 1e-10, PI = acos(-1.0);
template <class T> auto MAX(T& seq) {
    return *max_element(seq.begin(), seq.end());
}
template <class T> auto MIN(T& seq) {
    return *min_element(seq.begin(), seq.end());
}
template <class T> auto SUM(T& seq) {
    T temp{0};
    auto& temp2 = temp[0];
    return accumulate(seq.begin(), seq.end(), temp2);
}
template <class T> void SORT(T& seq) { sort(seq.begin(), seq.end()); }
template <class T, class S> void SORT(T& seq, S& sort_order) {
    sort(seq.begin(), seq.end(), sort_order);
}
template <class T> void SORTR(vector<T>& seq) {
    sort(seq.begin(), seq.end(), greater<T>());
}
template <class T, class S, class R> long long pow(T n_0, S k_0, R mod_0) {
    long long n = n_0, k = k_0, mod = mod_0, now = 1;
    while (true) {
        if (k & 1) { now = now * n % mod; }
        if ((k >>= 1) == 0) { return now; }
        n = (n * n) % mod;
    }
}

int main() {
    PRE_COMMAND
    int n, q, t, u, v;
    cin >> n >> q;
    atcoder::dsu uf(n);
    for (int i = 0; i < q; i++) {
        cin >> t >> u >> v;
        if (t == 0) { uf.merge(u, v); }
        if (t == 1) { cout << uf.same(u, v) << endl; }
    }
}


Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	double t,a;
	cin>>n>>t>>a;
	double min=10000000.0;
	int ans;
	rep(i,n){
		double h;
		cin>>h;
		if(min > abs(a-(t-h*0.006))){
			min = abs(a-(t-h*0.006));
			ans=i+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int a, b; cin >> a >> b;
    if (a*b % 2 == 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int n,a,f,ans;
map<int,int> m;
 
int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>a;
      if(m.find(a)==m.end())m[a]=1;
      else m[a]++;
    }
    f=0;
    map<int,int>::iterator ite;
    for(ite=m.begin();ite!=m.end();ite++){
      if((*ite).second>n/2){
    f=1;
    ans=(*ite).first;
    break;
      }
    }
    if(f)cout<<ans<<endl;
    else cout<<"NO COLOR"<<endl;
    m.clear();
  }
  return 0;
}

Measured memory_bytes: 2732
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

typedef long long ll;

int main() {
  ll a, b; cin >> a >> b;
  if (a * b <= 0) {
    cout << "Zero" << endl;
  } else if (b < 0 && !((a + b) % 2)) {
    cout << "Negative" << endl;
  } else {
    cout << "Positive" << endl;
  }
}

Measured memory_bytes: 256
program Project1;
         
{$APPTYPE CONSOLE}
     
uses
  SysUtils,math;
var
  g,l,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t:Integer;
  //l:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
  xc,yc,space:char;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(xc);
    Read(space);
    Readln(yc);

    if Ord(xc)>Ord(yc) then
      Writeln('>')
    else if Ord(xc)=Ord(yc) then
      Writeln('=')
    else
      Writeln('<');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 0
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

N,M,*f = map(int, open(0).read().split())
XYZ = [f[i:i+3] for i in range(0, len(f), 3)]
XY = [(x[0],x[1]) for x in XYZ]
uf = UnionFind(N)
ans = 0
for x, y in XY:
    uf.union(x-1,y-1)
for x in uf.parents:
    if x < 0:
        ans += 1
print(ans)

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

string S;

int str_check(string s)
{
    int count0 = 0;
    int count1 = 0;
    
    for (int i = 0; s[i]!= '\0'; i++)
    {
        if (s[i] == '0')count0++;
        if (s[i] == '1')count1++;
    }

    return min(count0,count1);

}

int main(void)
{
    cin >> S;

    cout << str_check(S)*2 << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>d(n);
  for(int i=0;i<n;i++)
    cin>>d[i];
  vector<int>dp(n, INT_MAX);
  dp[0]=0;
  for(int i=1;i<n;i++){
    for(int j=i-1;j>=i-2;j--){
      if(j>=0){
        dp[i]=min(dp[i], dp[j]+abs(d[j]-d[i]));
      }
    }
  }
  printf("%d\n", dp[n-1]);
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=305;
int n,k,mod,dp[N][N],s[N][N],C[N][N];

namespace MATHEMATICS
{
	int add(int x,int y)
	{
		int ret=x+y;
		if(ret>=mod) ret-=mod;
		return ret;
	}
	int mi(int x,int y)
	{
		int ret=x-y;
		if(ret<0) ret+=mod;
		return ret;
	}
	
	void inc(int &x,int y)
	{
		x+=y;
		if(x>=mod) x-=mod;
	}
	void dec(int &x,int y)
	{
		x-=y;
		if(x<0) x+=mod;
	}
	
	int mul(int x,int y)
	{
		return 1LL*x*y%mod;
	}
}
using namespace MATHEMATICS;

void prework()
{
	int i,j,mx=max(n,k);
	for(i=0;i<=mx;++i) C[i][0]=C[i][i]=1;
	for(i=2;i<=mx;++i)
		for(j=1;j<mx;++j)
			C[i][j]=add(C[i-1][j-1],C[i-1][j]);
}

void calc(int i,int j)
{
	int x;
	for(x=1;x<i;++x)
		inc(dp[i][j],mul(mul(C[i-2][x-1],dp[i-x][j]),s[x][j+1]));
}

void DP()
{
	int i,j,x;
	for(j=k;~j;--j) dp[1][j]=1;
	for(j=k;~j;--j) s[1][j]=add(s[1][j+1],dp[1][j]);
	for(i=2;i<=n;++i)
	{
		for(j=0;j<=k;++j) calc(i,j);
		for(j=k;~j;--j) s[i][j]=add(s[i][j+1],dp[i][j]);
	}
}

void query()
{
	int x,ans=0;
	for(x=1;x<=n;++x) inc(ans,mul(mul(C[n-1][x-1],dp[n+1-x][0]),s[x][1]));
	printf("%d\n",ans);
}

int main()
{
	int i,j,x;
	scanf("%d%d%d",&n,&k,&mod);
	prework();
	DP();
	query();
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	cin >> N;
	vector<vector<int>> adj(N, vector<int>(N));
	for(int i=0; i<N; i++){
		string s;
		cin >> s;
		for(int j=0; j<N; j++){
			if(i==j) adj[i][j] = 0;
			else if(s[j]=='1') adj[i][j] = 1;
			else adj[i][j] = 1e9;
		}
	}

	vector<vector<int>> dist(N, vector<int>(N));
	for(int i=0; i<N; i++) for(int j=0; j<N; j++) dist[i][j] = adj[i][j];
	for(int k=0; k<N; k++) for(int i=0; i<N; i++) for(int j=0; j<N; j++){
		dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
	}

	int ans = -1;
	for(int i=0; i<N; i++){
		debug("dist ", i);
		debugv(dist[i]);
		vector<vector<int>> hist(N);
		for(int j=0; j<N; j++){
			hist[dist[i][j]].push_back(j);
		}
		bool ok = true;
		for(int d=0; d<N; d++){
			if(hist[d].size()==0) continue;
			debug("hist ", d);
			debugv(hist[d]);
			for(int j=0; j<hist[d].size(); j++) for(int k=j+1; k<hist[d].size(); k++){
				if(adj[hist[d][j]][hist[d][k]]==1) ok = false;
			}
		}
		if(!ok) continue;
		int d = 0;
		while(d<N&&hist[d].size()>0) d++;
		ans = max(ans, d);
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	string s;
	cin >> s;
	string ans = "";
	for (int i = 0, end = SIZE(s); i < end; i += 2)
	{
		if (i > end - 1)
			break;
		ans += s[i];
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

bool m[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

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

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7
const int X= 1e5+5;
int main(){_
	 int n; cin>>n;
	 vl v(X,0);
	 lli sum = 0;
	 fore(i,0,n){int a; cin>>a; v[a]++;sum+=a;}
	 int q; cin>>q;
	 while(q--){
		 int a,b; cin>>a>>b;
		 sum-=(v[a]*a);
		 sum+=v[a]*b;
		 v[b]+=v[a];
		 v[a]=0;
		 cout<<sum<<ENDL;
	 }

}


Measured memory_bytes: 3984
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,m,x,y,dp[N],ans;
vector<int> v[N];
int dfs(int x)
{
	if(dp[x]!=-1)
		return dp[x];
	if(v[x].size()==0)
	{
		dp[x]=0;
		return 0;
	}
	for(int i=0;i<v[x].size();i++)
	{
		int y=v[x][i];
		dp[x]=max(dp[x],dfs(y)+1);
	}
	return dp[x];
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		v[x].push_back(y); 
	}
	for(int i=1;i<=n;i++)
		dfs(i);
	for(int i=1;i<=n;i++)
		ans=max(ans,dp[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}

typedef std::pair<ll, ll> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}
 
using namespace std;

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

    string a, b;

    rep(i, s.size()){
        if(i % 2 == 0){
            a += '0';
            b += '1';
        }else{
            a += '1';
            b += '0';
        }
    }

    ll cnt_a = 0;
    ll cnt_b = 0;

    rep(i, s.size()){
        if(s[i] != a[i]) cnt_a++;
        if(s[i] != b[i]) cnt_b++;
    }

    cout << min(cnt_a, cnt_b);

}

Measured memory_bytes: 768
n, m, k = map(int, input().split(" "))
a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
A = [0]
B = [0]
for i in a:
    if A[-1] > k:
        break
    A.append(A[-1] + i)
for i in b:
    if B[-1] > k:
        break
    B.append(B[-1] + i)

ans = 0
j = len(B) - 1

for i in range(len(A)):
    if A[i] > k:
        break
    while A[i] + B[j] > k:
        j -= 1
    ans = max(ans, i + j)

print(ans)


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

using namespace std;

typedef long long ll;
typedef long double ld;

int h, w, n;
set<pair<int, int>> is;
set<pair<int, int>> calc;

int get(int i, int j) {
  int sol = 0;
  for (int a = i; a <= i + 2; a++) {
    for (int b = j; b <= j + 2; b++) {
      sol += is.count({a, b});
    }
  }
  return sol;
}

int f[10];

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

  cin >> h >> w >> n;
  h -= 2;
  w -= 2;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    is.insert({x, y});
  }
  for (auto &it : is) {
    int x = it.first;
    int y = it.second;
    for (int a = x - 2; a <= x; a++) {
      for (int b = y - 2; b <= y; b++) {
        calc.insert({a, b});
      }
    }
  }
  for (auto &it : calc) {
    int x = it.first;
    int y = it.second;
    if (1 <= x && 1 <= y && x <= h && y <= w) {
      f[get(x, y)]++;
    }
  }
  ll f0 = (ll) h * w - (f[1] + f[2] + f[3] + f[4] + f[5] + f[6] + f[7] + f[8] + f[9]);
  cout << f0 << "\n";
  for (int i = 1; i <= 9; i++) {
    cout << f[i] << "\n";
  }
}


Measured memory_bytes: 47104
a = 2, 3, 5
 
def f(n):
  m = memo.get(n)
  if m is None:
    m = d * n
    for p, c in zip(a, b):
      k, r = divmod(n, p);
      m = min(m, f(k) + r * d + c, r  and f(k + 1) + (p - r) * d + c or m)
    memo[n] = m
  return m
 
t = int(input())
for _ in range(t):
  n, *b, d = map(int, input().split())
  memo = {0: 0, 1: d}
  print(f(n))


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

using namespace std;

int main() {
    //freopen("in.txt", "r", stdin);
    int n;
    cin >> n;
    vector<vector<int> > G(n + 1, vector<int>(n + 1, 0));
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        int v;
        for (int j = 0; j < k; j++) {
            cin >> v;
            G[u][v] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j < n) cout << G[i][j] << " ";
            else cout << G[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
n = gets.to_i
s = 0
b = gets.to_i

(n - 1).times do
  a = gets.to_i

  if b.odd? && a.positive?
    a -= 1
    s += 1
  end

  s += b / 2
  b = a
end

s += b / 2
p(s)


Measured memory_bytes: 2044
import math
while True:
  answer = 0
  count = int(input())
  if count == 0: break
  orders = input().split(' ')

  for i in range(int(math.floor(count / 2))):
    s = orders[ 2 * i: 2*i+2 ]
    if not(s[0][0] == s[1][0]) and (s[0][1] == s[1][1]):
      answer += 1
  
  print(answer)



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

int main(){
  int a,b,c;
  int cnt1=0,cnt2=0;
  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if((a*a+b*b)==c*c) cnt1++;
    if(a==b) cnt2++;
  }
  cout << cnt1<<endl;
  cout << cnt2<<endl;
  return 0;
}

Measured memory_bytes: 1208
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    A=list(map(int,input().split()))
    rgb=[-1,-1,-1]
    ans=1
    mod=10**9+7
    for a in A:
        ans=ans*Counter(rgb)[a-1]%mod
        if ans==0:break
        rgb[rgb.index(a-1)]+=1
    print(ans)
    

if __name__=='__main__':
    main()

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

int main() {
  int X;
  cin >> X;
  while(1) {
    bool check = true;
    for(int i = 2; i <= X / 2; i++) {
      if(X % i == 0) {
        check = false;
        break;
      }
    }
    if(check) {
      break;
    }
    else {
      X++;
    }
  }
  cout << X << endl; 
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    int count = 0, ind = 0;
    int64_t sum = 0;
    while(count < N-1){
        sum += A.at(ind);
        count ++;
        if(count % 2 == 1) ind++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 4056
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
typedef long long ll;
signed main() {
    double r;
    cin >> r;
    cout << r * 2 * 3.141592 << endl;
    r0
}


Measured memory_bytes: 3784