akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Dice and Coin
	var N int
	var K float64
	fmt.Scanf("%d %f", &N, &K)

	var ans float64
	var temp float64
	var j int
	for i := 1; i <= N; i++ {
		j = 0
		for {
			temp = float64(i) * math.Pow(2, float64(j))
			if K <= temp {
				break
			} else {
				j++
			}
		}
		ans += 1 / (float64(N) * math.Pow(2, float64(j)))
	}

	fmt.Printf("%.12f\n", ans)
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
}*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1LL<<60;

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

  reverse(all(s));
  int cur = 0;
  vi ans;
  while(cur < n){
    for(int to = cur+m; to >= cur; to--){
      if(to == cur){
        cout << -1 << endl;
        return 0;
      }

      if(s[to] == '0'){
        ans.emplace_back(to-cur);
        cur = to;
        break;
      }
    }
  }

  reverse(all(ans));
  rep(i, 0, sz(ans)) cout << ans[i] << " \n"[i==sz(ans)-1];

  return 0;
}



Measured memory_bytes: 1528
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N;
ll A[50], B[50];

int main() {
    fastio();
    cin >> N;
    REP(i, N) cin >> A[i];
    ll ans = 0, tmp, M = N + 1;
    while (true) {
        tmp = 0;
        REP(i, N) {
           B[i] = A[i] / N;
           tmp += B[i];
           A[i] -= B[i] * M;
        }
        if(tmp==0) break;
        ans += tmp;
        REP(i, N) A[i] += tmp;
    }
    cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100
#define INFTY 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

void sssp(void );

int  n, G[MAX][MAX];

void sssp(){
    int minv,i,v,u;
    int d[MAX],color[MAX];

    for(i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    while(1) {
        minv = INFTY;
        u = -1;
        for(i = 0; i < n; i++) {
            if(minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) {
          break;
        }
        color[u] = BLACK;
        for(v = 0; v < n; v++) {
            if(color[v] != BLACK && G[u][v] != INFTY) {
                if(d[v] > d[u] + G[u][v]) {
                    d[v] = d[u] + G[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(i = 0; i< n; i++){
        printf("%d ",i);
        if(d[i] == INFTY) printf("-1\n");
        else printf("%d\n", d[i]);
    }
}

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

    scanf("%d", &n);

    for(i = 0; i < n; i++)
        for(j = 0; j < n; j++)
            G[i][j] = INFTY;

    for(i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        for(j = 0; j < k; j++) {
            scanf("%d %d", &v, &c);
            G[u][v] = c;
        }
    }

    sssp();

    return 0;
}



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

template <std::uint_fast64_t Modulus> class modint {
  using u64 = int;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

const int mod = 1e9+7;
const int MX = 2e5;

int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

int modInverse(int n, int p){
	return power(n,p-2,p);
}

int fac[MX+5];
void init(int mod){
	fac[0] = 1;
	for (int i=1 ; i<=MX; i++)
		fac[i] = fac[i-1]*i%mod;
}

int C(int n,int r,int p){
	if (r==0)return 1;
	return (fac[n]*modInverse(fac[r],p)%p * modInverse(fac[n-r],p)%p)%p;
}

int H(int n,int r,int p){
  if(n<1||r<0)return 0;
  return C(n+r-1,r,p);
}

signed main(){
  using mint=modint<mod>;
  init(mod);
  
  int n,k;
  mint res=0;
  cin>>n>>k;
  k=min(k,n-1);
  for(int z=0;z<min(n,k+1);++z){
    mint pr=C(n,z,mod);
    pr*=H(n-z,z,mod);
    res+=pr;
  }
  cout<<res.value();
}

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

using namespace std;

struct DATA{
  int s, g, v;
  DATA(int s_, int g_){ s=s_; g=g_; v=g_-s_+1; }
};

void convert(vector<int>& in, vector<DATA>* data){
  vector<int>::iterator i, j;
  i = in.begin();
  while(i != in.end()){
    j = i;
    while(1){
      if(j+1 == in.end()) break;
      if(*j +1 != *(j+1)) break;
      ++j;
    }
    data->push_back(DATA(*i, *j));
    i = j+1;
  }
}

int solve(bool& is, vector<DATA>& data){
  int ans=0;
  if(is){
    for(vector<DATA>::iterator i=data.begin(); i!=data.end()-1; ++i){
      if(i->g +2 == (i+1)->s) ans = max(ans, i->v + (i+1)->v +1);
      else ans = max(ans, i->v +1);
    }
    ans = max(ans, (data.end()-1)->v +1);
  }else{
    for(vector<DATA>::iterator i=data.begin(); i!=data.end(); ++i)
      ans = max(ans, i->v);
  }
  return ans;
}

int main(){
  int n, k;
  bool is=false;
  while(1){
    cin >> n >> k;
    if(!n && !k) break;
    vector<int> in(k, 0);
    for(int i=0; i<k; ++i) cin >> in[i];
    sort(in.begin(), in.end());
    if(in[0] == 0){
      is = true;
      in.erase(in.begin());
    }
    vector<DATA> data;
    convert(in, &data);
    cout << solve(is, data) << endl;
  }
  return 0;
}

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

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

  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 1;
  int as = a;
  while (as < b) {
    as--;
    as += a;
    ans++;
  }

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

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

int v[10][10];

bool check1(vector<int> d) {
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 10; j++) {
            if (d[i] == j) continue;
            auto t = d;
            t[i] = j;

            int e = 0;
            for (int k = 0; k < 5; k++) e = v[e][t[k]];

            if (!e) return false;
        }
    }

    return true;
}

bool check2(vector<int> d) {
    for (int i = 0; i < 4; i++) {
        auto t = d;
        if (t[i] == t[i+1]) continue;
        swap(t[i], t[i+1]);

        int e = 0;
        for (int j = 0; j < 5; j++) e = v[e][t[j]];

        if (!e) return false;
    }

    return true;
}

int main() {
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++) cin >> v[i][j];

    int ans = 0;
    for (int i = 0; i < 10000; i++) {
        vector<int> d(5);
        for (int j = 0, x = i; j < 4; j++) {
            d[3-j] = x % 10;
            x /= 10;
        }

        int e = 0;
        for (int j = 0; j < 4; j++) e = v[e][d[j]];
        d[4] = e;

        bool flag = true;
        if (!check1(d)) flag = false;
        if (!check2(d)) flag = false;

        if (!flag) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3160
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N) {
		map<ll, bool> h;
		REP(i, N) {
			cin>>M;
			h[M] = !h[M];
		}
		ll ans = 0;
		for(auto kv : h) if(kv.second) ans++;
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;

class Program
    {
        static void Main(string[] args)
        {           
            string[] str = Console.ReadLine().Split(' ');
           
            int a = int.Parse(str[0]);
            
            int b = int.Parse(str[1]);
            
            int k = int.Parse(str[2]);

            var listA = new List<int>();
            var listB = new List<int>();
            var listK = new List<int>();

            int count = 0;
            for(int i = 1; i <= a; i++)
            {
                if(a%i == 0)
                {
                    listA.Add(count);
                    listA[count] = i;
                    count++;
                }
            }

            count = 0;
            for (int i = 1; i <= b; i++)
            {
                if (b % i == 0)
                {
                    listB.Add(count);
                    listB[count] = i;
                    count++;
                }
            }

            count = 0;
            foreach(int i in listB)
            {
                foreach(int j in listA)
                {
                    if(i == j)
                    {
                        listK.Add(count);
                        listK[count] = i;
                        count++;
                    }
                }
            }
            Console.WriteLine(listK[listK.Count() - k]);
        }
    }

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

int main() {
  
  int a;
  int x, y, z;
  cin >> a;
  x = a/100;
  y = (a-x*100)/10;
  z = (a-x*100-y*10)/1;
  
  cout << x+y+z << endl;
}

Measured memory_bytes: 3616
import std.algorithm,
       std.string,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] g1 = [1,3,5,7,8,10,12],
        g2 = [4,6,9,11],
        g3 = [2];
  int[] xy = readln.chomp.split.to!(int[]);
  int x = xy[0],
      y = xy[1];

  bool found;

  foreach (g; [g1, g2, g3]) {
    if ([x, y].all!(e1 => g.canFind(e1))) {
      found = true;
      break;
    }
  }

  writeln(found ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

saken s, b;

bool check(int m) {

    for(int i = 0; i < m - 1; ++i) {

        if(b[i] != b[i + 1]) {return 0;}

    }

    return 1;

}

int main(){

cin >> s;

int full_ans = (int)1e9;

for(int i = 0; i < s.sz(); ++i) {

    b = s;

    int m = s.sz();

    int ans = 0;
    char a = s[i];

    while(!check(m)) {

        ++ans;
        m--;

        for(int i = 0; i < m; ++i) {

            if(b[i + 1] == a) {b[i] = a;}

        }
    }

    full_ans = min(full_ans, ans);

}


cout << full_ans;

return 0;
}



Measured memory_bytes: 256
import sys
def S(): return sys.stdin.readline().rstrip()
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    h,w = IL()
    m = [S() for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if i==h-1 or j==w-1:
                continue
            if m[i][j+1]=='#' and m[i+1][j]=='#':
                print('Impossible')
                exit()
    print('Possible')
    exit()

Measured memory_bytes: 9052
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int S,W;
    cin >> S >> W;
    if(S <= W){
        cout << "unsafe" << enld; 
    }else{
        cout << "safe" << enld;
    }
    return 0;
}

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

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

using namespace std;

//v.push_back(123);
//sort(v.begin(), v.end(),greater<int>());
//for(int x : v) {cout << x << endl;}

//for(int x: v) cout << x << endl;
//vector<vector<char>> v(H, vector<char>(W));
//vector<int> v(1000);

signed main(){
  string N;
  cin>>N;
  int count = 15;
  rep(i, N.length()){
    if(N[i]=='x'){
      count--;
    }
  }
  if(count>=8){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
//vector<ll> a(n,0),b(n,0),c(n,0);

int main(){
    cin>>n;
    vector<ll> a(n,0),b(n,0),c(n,0);
    for(int i = 0;i < n; i++){
        cin>>a[i];
    }
    //cout<<"aaa"<<endl;
    for(int i = 0;i < n; i++){
        cin>>b[i];
    }
    for(int i = 0;i < n; i++){
        cin>>c[i];
    }
    sort(a.begin(),a.end());
    //sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll sum=0;
    for(int i = 0;i < n; i++){
        int x;
        int y;
        auto Iter = lower_bound(a.begin(),a.end(),b[i]);
        long n1=Iter-a.begin();
        auto Iter2 = upper_bound(c.begin(),c.end(),b[i]);
        long n2=c.end()-Iter2;
        sum+=n1*n2;
    }
    /*
    auto it = lower_bound(v.begin(), v.end(), 3);
    //探索したい値以上が現れる最初の位置のイテレータを取得。
    //ある値 keyより小さい配列Aの要素の個数nを求める場合
    auto Iter = lower_bound(A.begin(), A.end(), key);
    long n = Iter - A.begin();
    */
   cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
int mian(){
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;++i)
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	cout<<"NG"<<endl;
	return 0;
}
signed main(){
	int t=1;
//	cin>>t;
	while(t--)
		mian();
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_E = 1000000;
const int MAX_V = 1000;

struct edge{int from, to; ll cost;};
edge es[MAX_E];

ll d[MAX_V];
int V, E;

bool bellman_ford(int s){
  REP(i,V)d[i] = INFll;
  d[s] = 0;
  REP(i,V-1){
    REP(j,E){
      edge e = es[j];
      if(d[e.from] != INFll && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
      }
    }
  }

  ll ans = d[V-1];

  REP(i,V){
    REP(j,E){
      edge e = es[j];
      if(d[e.from] != INFll && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
      }
    }
  }

  if(d[V-1]!= ans){
    return false;
  }else{
    return true;
  }

}


int main(){
  int n, m;
  cin >> n >> m;
  E = m;
  V = n;
  int a[m], b[m];
  ll c[m];
  REP(i,m){
    cin >> a[i] >> b[i] >> c[i];
    es[i] = (edge){a[i]-1, b[i]-1, -c[i]};
  }

  bool flag =  bellman_ford(0);
  if(!flag){cout << "inf" << endl;}
  else{cout << -d[n-1] << endl;}


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
using namespace std;
template <typename lx> inline void read(lx &x){
	x = 0;int f = 1;char c = getchar();
	for(;c < '0' || '9' < c; c = getchar()) if(c == '-') f = -1;
	for(;'0' <= c && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;return;
}
template <typename lx> inline void print(lx x){
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + 48);
	return;
}
#define rg register
#define ll long long
#define r_2(a,b) read(a),read(b)
#define r_3(a,b,c) read(a),read(b),read(c)
#define print_n(a) print(a),puts("")
#define print_(a) print(a),putchar(' ')
const int inf = 2147483647;
const int maxn = 1e5 + 7;
ll n,ans;
ll a[maxn],b[maxn];
int main()
{
	read(n);n++;
	for(rg int i = 1;i <= n; i++) read(a[i]);n--;
	for(rg int i = 1;i <= n; i++) read(b[i]);
	for(rg int i = 1;i <= n; i++){
		if(a[i] >= b[i]) ans += b[i];
		else{
			ans += a[i];
			b[i] -= a[i];
			if(a[i + 1] >= b[i]) ans += b[i],a[i + 1] -= b[i];
			else ans += a[i + 1],a[i + 1] = 0;
		}
	}
	print(ans);
	return 0;
}

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n, a[100001], b[100000], l, it;
	bool pos = false;
	cin >> n >> l;
	rep(i, n) cin >> a[i];
	rep(i, n - 1) {
		b[i] = a[i] + a[i + 1];
		if(b[i] >= l) {
			pos = true;
			it = i;
		}
	}
	if(!pos) {
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	rep(i, it) {
		cout << i + 1 << endl;
	}
	for(int i = n - 2; i >= it; i--) {
		cout << i + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#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 INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXRR 1000 //√MAXR以上の数を設定する
#define MAXR 200000

ll fac[MAXR], finv[MAXR], inv[MAXR];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAXR; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void Prime_factorize(vector<ll>& v,ll n){
    if(n<=1) return;
    ll l=ll(sqrt(n));
    for(ll i=2;i<l+1;i++){
        if(n%i==0){
            Prime_factorize(v,i);Prime_factorize(v,ll(n/i));return;
        }
    }
    v.push_back(n);return;
}

//エラトステネスのやつ加える
//素数ライブラリ整理


signed main(){
    COMinit();
    map<ll,ll> ma;
    ll n,m;cin >> n >> m;
    vector<ll> vp;
    Prime_factorize(vp,m);
    REP(i,SIZE(vp)){
        ma[vp[i]]++;
    }
    ll ans=1;
    for(auto i=ma.begin();i!=ma.end();i++){
        ans*=COM(i->S+(n-1),n-1);
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<stack>

int main(){

	std::string str;
	while (true){
		std::getline(std::cin, str);
		std::stack<char>s;

		if (str == ".")break;

		bool flg = true;
		for (int i = 0; i < str.size(); i++){
			if (str[i] == '(' || str[i] == '[')s.push(str[i]);
			if (str[i] == ')' || str[i] == ']'){
				if (s.empty()){
					flg = false;
					break;
				}

				char a = s.top();
				s.pop();
				
				if (a == '('&&str[i] == ')');
				else if (a == '['&&str[i] == ']');
				else {
					flg = false;
					break;
				}
			}
		}
		if (s.empty() && flg)std::cout << "yes" << std::endl;
		else std::cout << "no" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    ll N;
    cin >> N;
    FOR(h, 1, 3501) {
        FOR(w, 1, 3501) {
            ll n = N * h * w;
            ll d = 4 * h * w - N * (w + h);
            if (d <= 0) continue;
            if (n % d == 0) {
                cout << h << " " << n / d << " " << w << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
s = list(input())
n = len(s)
ans = [1]*n
for i in range(n-1):
    if s[i] == s[i+1] == "R":
        ans[i+2] += ans[i]
        ans[i] = 0
for j in range(n-1,0,-1):
    if s[j] == s[j-1] == "L":
        ans[j-2] += ans[j]
        ans[j] = 0
print(' '.join([str(a) for a in ans]))

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

int main() {
    int H, W;
    cin >> H >> W;
    string A[H];
    for (int i=0; i<H;i++) cin >> A[i];
    for (int i=0; i<W+2; i++) cout << "#";
    cout << endl;
    for (int i=0; i<H; i++){
        cout << "#";
        cout << A[i];
        cout << "#";
        cout << endl;
    }
    for (int i=0; i<W+2; i++) cout << "#";
    cout << endl;
}


Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(int n, int a, int b) {
    return Math.abs(a - b) % 2 == 0 ? "Alice" : "Borys";
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int a = reader.nextInt();
    int b = reader.nextInt();
    out.println(solve(n, a, b));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 21332
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

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
for i in range(M):
    AB[i][0]-=1
    AB[i][1]-=1
AB.reverse()
countlst=[N*(N-1)//2]
uf=UnionFind(N)
for A,B in AB:
    if uf.find(A)!=uf.find(B):
        countlst.append(countlst[-1]-uf.size(A)*uf.size(B))
        uf.union(A,B)
    else:
        countlst.append(countlst[-1])

countlst.reverse()
for i in range(1,M+1):
    print(countlst[i])


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

int main(){
  int a,b,sum=0;
  cin>>a>>b;
  int n[b];
  for(int i=0;i<b;i++){
    cin>>n[i];
    sum+=n[i];
  }
  if(sum>=a)cout<<"Yes";
  else cout<<"No";
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(N);
  rep(i,N){
    cin >> a.at(i);
  }
  int x,y;
  vector<int> b(N);
  rep(i,M){
    cin >> x >> y;
    if(a.at(x-1)>a.at(y-1)){
      b.at(x-1)++;
      b.at(y-1)=b.at(y-1)-10000;
    }
    else if(a.at(x-1)<a.at(y-1)){
      b.at(y-1)++;
      b.at(x-1)=b.at(y-1)-10000;
    }
    else{
      b.at(x-1)=b.at(x-1)-10000;
      b.at(y-1)=b.at(y-1)-10000;
    }
  }
  int count;
  rep(i,N){
    if(b.at(i)>=0){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 4056
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] rank = new int[n];
		String[] str = (br.readLine()).split(" ");
		for (int i = 0; i < n ; i++ ) {
			rank[i] = Integer.parseInt(str[i]);
		}
		//??°????????????
		for (int i = 0;  i<n ; i++ ) {
			if ( i < n-1) {
				System.out.print(rank[i]+" ");
			}else{
				System.out.println(rank[i]);
			}


		}

		int key;
		//sort
		for ( int i = 1; i <= rank.length-1 ; i++ ) {
			key = rank[i];
			int j = i-1;
			while(j>=0 && rank[j]>key){
				rank[j+1] = rank[j];
				j--;
				rank[j+1] = key;
			}
		//output
			for (int k = 0;  k<n ; k++ ) {
				if ( k < n-1) {
					System.out.print(rank[k]+" ");
				}else{
					System.out.println(rank[k]);
				}


			}
		}
	}
}

Measured memory_bytes: 29064
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a = N/100;
    int b = (N/10)%10;
    int c = N%10;
  //  System.out.println(N);
  //  System.out.println(a);
  //  System.out.println(b);
  //  System.out.println(c);
    if((a == 7) || (b == 7) || (c == 7)){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35736
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 998244353;
const ull mod1 = 2e18 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 1e5 + 5;
int t;
int a[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	while (cin >> n)
	{
		f(i, 1, n)cin >> a[i];
		ll ans = 0;
		f(i, 1, n)
		{
			f(j, i + 1, n)
			{
				ans += a[i] * a[j];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int Pow(int n, int k) {
	int i, ans = 1;
	for (i = 0; i < k; i++) {
		ans *= n;
	}
	return ans;
}

int main(void) {
	int num, i, j, k, x, ans = 0;
	string s;
	cin >> num >> s;
	vector<vector<vector<int>>> dp(num + 1, vector<vector<int>>(3, vector<int>(1000, 0)));
	for (k = 1; k <= num; k++) {
		x = s[k - 1] - '0';
		dp[k][0][x] = true;
		for (i = 1; i < 3; i++) {
			for (j = 0; j < Pow(10, i); j++) {
				dp[k][i][j * 10 + x] |= dp[k - 1][i - 1][j];
			}
		}
		for (i = 0; i < 3; i++) {
			for (j = 0; j < 1000; j++) {
				dp[k][i][j] |= dp[k - 1][i][j];
			}
		}
	}
	for (i = 0; i < 1000; i++) {
		if (dp[num][2][i])
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 356352
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        String[] A = new String[N];
        String[] B = new String[M];
        for(int i=0;i<N;i++) A[i] = sc.next();
        for(int i=0;i<M;i++) B[i] = sc.next();
        for(int row=0;row<=N-M;row++){
            for(int col=0;col<=N-M;col++){
                boolean flag = true;
                for(int j=0;j<M;j++){
                    if(!B[j].equals(A[j+row].substring(col,col+M))){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21588
import fractions
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

a,b = map(int,input().split())
c = fractions.gcd(a,b)
lis = make_divisors(c)
cnt=0
for i in lis:
    if(is_prime(i)):
        cnt+=1
print(cnt+1)

Measured memory_bytes: 5340
#####segfunc#####
def segfunc(x, y):
    return max(x,y)
#################

#####ide_ele#####
ide_ele = 0
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


N,K=map(int,input().split())
A=[]
for i in range(N):
  A.append(int(input()))

N=300000
  
data = [0]*N
seg = SegTree(data, segfunc, ide_ele)

for i in A:
  l=min(N,max(0,i-K))
  r=max(0,min(N,i+K))
  v=seg.query(l,r+1)
  seg.update(i,v+1)

print(seg.query(0,N))

Measured memory_bytes: 148008
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  s <- getLine
  t <- getLine
  let s' = zip [1..length s] s
  putStrLn $ rotation s' t
  
rotation s' t
  |rots==t   = "Yes"
  |rotn==1   = "No"
  |otherwise = rotation rot t
    where rot = [last s'] ++ init s'
          rots = map snd rot
          rotn = fst $ head rot

Measured memory_bytes: 4144
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
int main() {
    int a,b,ans=0;
    cin>>a>>b;
    if(a<=0&&b>=0){puts("Zero");return 0;}
	for(int i=a;i<=b;i++)
	  ans+=i<0?1:0;
	if(ans%2==1)puts("Negative");
	else puts("Positive");
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  long long int count=0;
  stack<char> stac;
  for (auto i : s) {
    if (stac.size()==0) stac.push(i);
    else {
      if ((stac.top()=='0' && i=='1') || (stac.top()=='1' && i=='0')) {
        stac.pop();
        count+=2;
      } else stac.push(i);
    }
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
const int MAX_N = 200010;

int bit[MAX_N], n;

int SUM(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}
typedef pair<int, int> P;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, k;
    cin >> N >> k;
    n = N + 2;
    int a[200010];
    rep(i, N) cin >> a[i];
    P sum[200010] = {};
    sum[0] = {0, 0};
    rep(i, N) sum[i + 1] = {sum[i].first + a[i] - k, i + 1};
    sort(sum, sum + N + 1);
    //int sum2[200010] = {};
    map<int, int> mp;
    rep(i, N + 1) mp[sum[i].first] = i + 1;
    sort(sum, sum + N + 1, [](const P& a, const P& b){return a.second < b.second;});

    // rep(i, N + 1) cout << mp[sum[i].first] <<" ";
    // cout << endl;
    int ans = 0;
    rep(i, N + 1) {
        add(mp[sum[i].first], 1);
        //cout << mp[sum[i].first] << " " << SUM(mp[sum[i].first]) - 1 << endl;
        ans += SUM(mp[sum[i].first]) - 1;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  double odd, ans, even;
  int n;
  cin >> n;

  if(n % 2 == 1){
  odd = (n / 2) + 1;

  ans = odd / n;

  cout << ans << endl;
  }else{
    cout << "0.5000000000" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

ll k;
ll t[55], r[55];

int main() {
	scanf("%lld", &k);
	int n=50;
	FOR(i,n) t[i] = k/n;
	FOR(i,k%n) t[i]++;
	FOR(i,n) r[i] = t[i]*(n+1) + (n-1) - k;
	printf("50\n");
	FOR(i,n) printf("%lld ", r[i]);
	printf("\n");
	return 0;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i64 n;
    cin >> n;
    cout << n*(n+1)/2 - (n/3)*(n/3+1)/2*3 - (n/5)*(n/5+1)/2*5 + (n/15)*(n/15+1)/2*15 << endl;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

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

int main() {
  string s;
  cin >> s;
  rep(i,0,8) {
    int x = s[0] - '0';
    rep(j,0,3) {
      if(((i>>j)&1)) {
        x += s[j + 1] - '0';
      } else {
        x -= s[j + 1] - '0';
      }
    }
    if(x == 7) {
      cout << s[0];
      rep(j,0,3) {
        if(((i>>j)&1)) {
          cout << "+";
        } else {
          cout << "-";
        }
        cout << s[j + 1];
      }
      cout << "=7\n";
      return 0;
    }
  }
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n,m,k;cin >> n>>m>>k;
    int ans=0;
    UnionFind tree(n);
    vector<int> f(n);
    REP(i,m)
    {
        int x, y;
        cin >> x >> y;
        tree.unite(x - 1, y - 1); // xの木とyの木を併合する
        f[x - 1]++;
        f[y - 1]++;
    }
    REP(i,k){
        int c, d;
        cin >> c >> d;
        if (tree.same(c-1, d-1)){
            f[c - 1]++;
            f[d - 1]++;
        }
    }
    map<int, int> g;
    vector<int> z(n), v(n), sg(n);
    REP(i,n){
        z[i] = tree.root(i);
    }
    /*
    REP(i,n){
        if(sg[i]!=0){
            continue;
        }
        int cnt=0;
        queue<int> sa;
        REP(j,n){
            if(z[i]==z[j]){
                cnt++;
                sa.push(j);
            }
        }
        while(!sa.empty()){
            int aaa = sa.front();
            sa.pop();
            sg[aaa] = cnt;
        }
    }
    */
    REP(i, n)
    v[i] = z[i];
    sort(ALL(z));
    REP(i,n){
        if(g.count(z[i])==0){
            int ccc = 0;
            //REP(j,n){
            //    ccc += (z[i]==z[j]);
           // }
            FOR(j,i,n){
                if(z[i]!=z[j]){
                    break;
                }
                ccc++;
            }
            g[z[i]] = ccc;

        }
    }
    
    REP(i,n){
        sg[i] = g[v[i]];
    }
    
    REP(i,n-1)cout << sg[i]-f[i]-1 <<" ";
    cout << sg[n-1] - f[n-1] - 1 << "\n";

    return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <tuple>
using namespace std;

int N, A[100009], sum;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 0; i <= N; i++) sum += abs(A[i] - A[i + 1]);
	cout << sum / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int n,i,x;
	int f;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) {
		for (x = i, f = 0; 0 < x; x /= 10)
			if (!(i % 3) || (x % 10 == 3)) f = 1;
		if(f) printf(" %d", i);
	}
	putchar('\n');
	return 0;
}



Measured memory_bytes: 2044