akhauriyash/Code-Regression huggingface dataset:
#N, M, C = 5,2,-4
#B = [-2,5]
#A = [
#    [100,41],
#    [100,40],
#    [-3,0],
#    [-6,-2],
#    [18,-12],
#]
N, M, C = map(int, input().split(" "))
B = list(map(int, input().split(" ")))
A = []
for _ in range(N):
    A.append(list(map(int, input().split(" "))))

n = 0
for a in A:
    if sum([a[i] * B[i] for i in range(M)]) + C > 0:
        n += 1
print(n)


Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    cin >> N;
    int T[3];
    rep(i,3) cin >> T[i];
    vector<int> L(N);
    rep(i,N) cin >> L.at(i);

    int DP[3][1<<8] = {0};
    for(int i = 1; i < 1<<N; i++) {
        rep(j, 3) {
            int WA = 0, num = 0;
            rep(k, N) {
                if (1<<k & i) WA += L[k], num++;
            }
            DP[j][i]= (num - 1) * 10 + abs(T[j] - WA);
        }
    }
    int mi = 1 << 30;
    for (int i = 1; i < 1<<N; i++) for (int j = 1; j < 1<<N; j++) if ((i & j) == 0)
      for (int k = 1; k < 1<<N; k++) if ((i & k) == 0 && (j & k) == 0) {
          mi = min(mi, DP[0][i] + DP[1][j] + DP[2][k]);
      }
    
    cout << mi << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
struct state {
	vector<int> v;
	long long cost;
};
int n, id[19], p[19], w[19], sum[32777], popcount[32777]; state dp[19][32777];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> id[i] >> p[i] >> w[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			sum[j] = sum[j - (1 << i)] + w[i] * 20;
			popcount[j] = popcount[j - (1 << i)] + 1;
		}
	}
	for (int i = 0; i < n; i++) dp[i][1 << i] = state({ vector<int>({i}), 0 });
	for (int i = 1; i < 1 << n; i++) {
		if (popcount[i] == 1) continue;
		for (int j = 0; j < n; j++) {
			if (!(i & (1 << j))) continue;
			dp[j][i].cost = 1LL << 60;
			int sub = i - (1 << j);
			for (int k = 0; k < n; k++) {
				if (!(sub & (1 << k))) continue;
				long long cost = dp[k][sub].cost + 1LL * (70 + sum[sub]) * abs(p[j] - p[k]);
				if (dp[j][i].cost > cost) {
					dp[j][i].cost = cost;
					dp[j][i].v = dp[k][sub].v;
					dp[j][i].v.push_back(j);
				}
			}
		}
	}
	int pos = 0;
	for (int i = 1; i < n; i++) {
		if (dp[i][(1 << n) - 1].cost < dp[pos][(1 << n) - 1].cost) {
			pos = i;
		}
	}
	vector<int> ret = dp[pos][(1 << n) - 1].v;
	for (int i = 0; i < n; i++) {
		if (i) cout << ' ';
		cout << id[ret[i]];
	}
	cout << endl;
	return 0;
}

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


int main (){
    int N;
    cin>>N;
    vector <int> Coll(1);
    Coll.at(0)=N;
    bool Clear=true;
    while(Clear){
        int Back=(Coll.at(Coll.size()-1)%2==0?Coll.at(Coll.size()-1)/2:3*Coll.at(Coll.size()-1)+1);
        Coll.push_back(Back);
        for(int i=0; i<Coll.size()-1; i++){
            if(Coll.at(i)==Coll.at(Coll.size()-1)){
                cout<<Coll.size()<<endl;
                Clear=false;
                break;
            }

        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x3f3f3f3f
#define inff -30000000
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1000000+10;
bool notprime[MAX];
int num=0;
void init(){
    memset(notprime,0,sizeof(notprime));
    for(int i=2;i*i<=MAX;i++){
        if(!notprime[i]){
            for(int j=i*i;j<=MAX;j+=i)
                notprime[j]=1;
        }
    }
}
int main(){
    #ifdef SIYU
    freopen("in.txt","r",stdin);
    #endif // SIYU
    int n;
    init();
    while(cin>>n){
        //int *p=upper_bound(prime,prime+num,n);
        //int ans=p-prime;
        //cout<<ans<<endl;
        int ans=0;
        for(int i=2;i<=n;i++){
            if(!notprime[i])
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3980
#include "bits/stdc++.h"
using namespace std;

// A*Aの最低値から最高値を二分探索
const long long INF = 1LL << 61;

int main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

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

    long long left = -INF, right = INF;
    while (right - left > 1) { // left, mid, rightの値はチェック済み
        long long x = (left + right) / 2;
        long long S = 0, T = 0;

        for (int i = 0; i < N; ++i) {
            if (A[i] > 0) {
                int left2 = -1, right2 = N;
                while (right2 - left2 > 1) {
                    int m = (left2 + right2) / 2;
                    if (A[i] * A[m] <= x) left2 = m;
                    else right2 = m;
                }
                S += right2;
            }
            else if (A[i] < 0) {
                int left2 = -1, right2 = N;
                while (right2 - left2 > 1) {
                    int m = (left2 + right2) / 2;
                    if (A[i] * A[m] <= x) right2 = m;
                    else left2 = m;
                }
                S += N - right2;
            }
            else if (x >= 0) S += N;
            if (A[i] * A[i] <= x) ++T;
        }
        long long num = (S - T) / 2;
        if (num >= K) right = x;
        else left = x;
    }
    cout<<right;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>

using namespace std;

int main() {
  int N;
  string S;
  int calc_1[10], calc_2[10], calc_3[10];
  int flg_1 = 0, flg_2 = 0, flg_3 = 0;
  int n;
  int total = 0;

  cin >> N;
  cin >> S;

  memset(calc_1, 0, sizeof(calc_1));
  for (int i = 0; i < N-2; i++) {
    n = (int)(S[i]-'0');
    if (calc_1[n] > 0) continue;
    calc_1[n]++;
    flg_1 += n+1;
    memset(calc_2, 0, sizeof(calc_2));
    flg_2 = 0;

    for (int j = i+1; j < N-1; j++) {
      n = (int)(S[j]-'0');
      if (calc_2[n] > 0) continue;
      calc_2[n]++;
      flg_2 += n+1;
      memset(calc_3, 0, sizeof(calc_3));
      flg_3 = 0;

      for (int k = j+1; k < N; k++) {
        n = (int)(S[k]-'0');
        if (calc_3[n] > 0) continue;
        calc_3[n]++;
        flg_3 += n+1;

        total++;
      }
    }
    if (flg_1 == 55) break;
  }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for B - Between a and b ...
	var a, b, x int
	fmt.Scanf("%d %d %d", &a, &b, &x)

	var ans int
	if a != 0 {
		ans = (b/x + 1) - ((a-1)/x + 1)
	} else {
		ans = (b/x + 1)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1832
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int A, B, K;
  vector<int> data;
  cin >> A >> B >> K;
  for(int i = 1; i <= max(A, B); i++){
    if(A % i == 0 && B % i == 0) data.push_back(i);
  }
  sort(all(data), greater<ll>());
  cout << data[K - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    int N;
    cin >> N;
    vint A(N);
    vvint x(N), y(N);
    rep(i, N)
    {
        cin >> A[i];
        x[i].resize(A[i]);
        y[i].resize(A[i]);
        rep(j, A[i])
        {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ans = 0;
    for (int bit = 1; bit < (1 << N); bit++)
    {
        int cnt = 0;
        for (int i = 0; i < N; i++)
        {
            if (bit & (1 << i)) //人iが正直なとき
            {
                cnt++;
                //人iの証言を全部みていく
                rep(j, A[i])
                {
                    if (((bit & (1 << x[i][j])) != 0) != y[i][j]) //証言y[i][j]と仮定が食い違ったら
                    {
                        goto L;
                    }
                }
            }
        }
        ans = max(ans, cnt);
    L:;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
/*C - Snack MCM*/
#include <bits/stdc++.h>

using namespace std;
using Number = long long;

inline pair<Number, int> getPower(Number& n, const Number& p)
{
	pair<Number, int> powerP(p, 0);

	while (n % p == 0)
	{
		++powerP.second;
		n /= p;
	}

	return powerP;
}

inline vector< pair<Number, int> > getPrimeFactors(Number n)
{
	vector< pair<Number, int> > primeFactors;

	pair<Number, int> powerP = getPower(n, 2);

	if (powerP.second > 0)
		primeFactors.push_back(powerP);

	const Number sqrtN = sqrt(n);

	for (Number i = 3; i <= sqrtN and n > 1; i += 2)
	{
		powerP = getPower(n, i);

		if (powerP.second > 0)
			primeFactors.push_back(powerP);
	}

	if (n > 1)
		primeFactors.push_back(make_pair(n, 1));

	return primeFactors;
}

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

	Number a, b, num;
	int p;

	cin >> a >> b;

	vector < pair<Number, int> > primeFactorsA = getPrimeFactors(a);
	vector < pair<Number, int> > primeFactorsB = getPrimeFactors(b);

	map <Number, int> :: iterator it;
	map <Number, int> MCM;
	Number ans = 1ll;

	for (int i = 0; i < primeFactorsA.size(); ++i){
		num = primeFactorsA[i].first;
		p = primeFactorsA[i].second;
		MCM[num] = p; 
	}


	for (int i = 0; i < primeFactorsB.size(); ++i)
	{
		num = primeFactorsB[i].first;
		p = primeFactorsB[i].second;
	
		if(MCM.count(num)){
		
			if(MCM[num] < p)
				MCM[num] = p;
		}
		else{
			MCM[num] = p;
		}
	}
    
	for (it = MCM.begin(); it != MCM.end() ; ++it)
	{

		num = it -> first;
		p = it -> second;

		for (int j = 0; j < p; ++j)
			ans *= num;

	}

	cout << ans; 

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
#include <set>

typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector<int> mem(N-1);
	map <int,int> data;
	for (int i = 0;i<N-1;i++)
	{
		cin >> mem[i];
		data[mem[i]]++;
	}

	for (int i = 1;i<=N;i++)
	{
		cout << data[i] << endl;
	}
	
	
	return 0;

}


Measured memory_bytes: 13556
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
    int n;cin>>n;
    int a;cin>>a;
    if(n%500<=a) cout<<"Yes";
    else cout<<"No";
    cout<<endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var a = new int[N + 1];
            var memo = new int[N + 1];
            for (var i = 1; i <= N; i++)
            {
                a[i] = ReadInt();
            }

            Action<int> dfs = null;
            var ans = 0;
            dfs = i =>
            {
                if (memo[i] == 1)
                {
                    ans = -1;
                    return;
                }

                if (i == 2) return;
                memo[i] = 1;
                ans++;
                dfs(a[i]);
            };

            dfs(1);
            Println(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 16444
/*
~Like a small boat
~On the ocean
~Sending big waves
~Into motion
!Like how a single word
!Can make a heart open
!I might only have one match
!But I can make an explosion
#And all those things I didn't say
#Wrecking balls inside my brain
#I will scream them loud tonight
#Can you hear my voice this time?
@This is my fight song
@Take back my life song
@Prove I'm alright song
@My power's turned on
$Starting right now I'll be strong
$I'll play my fight song
$And I don't really care if nobody else believes
$'Cause I've still got a lot of fight left in me!!!
*/

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

#define  F  first
#define  S  second
#define  mp make_pair
#define  pb push_back
typedef long long int ll;
const int N = 2e5+5,mod = 1e9+7;
ll Arr[N],T[2*N],n;

void updt( int idx )
{
    idx += 1e5+2;
    while(idx<=2e5+5)
    {
        T[idx] += 1;
        idx += (idx&-idx);
    }
}

ll qry( int idx )
{
    idx += 1e5+2;
    ll Ret = 0;
    while(idx>0)
    {
        Ret += T[idx];
        idx -= (idx&-idx);
    }
    return Ret;
}

bool Ok( ll x )
{
    ll now = 0,cur = 0,total = (n*(n+1))/2;
    memset( T,0,sizeof T );
    updt(cur);
    total /= 2;
    total += 1;
    for(int i=1;i<=n;i++)
    {
        if( Arr[i]<x )++cur;
        else --cur;
        now += qry(cur-1);
        updt(cur);
    }
    return now<total;
}

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

    cin>>n;
    int Brr[n+2];
    Brr[0] = 0;
    for(int i=1;i<=n;i++)
    {
        cin>>Arr[i];
        Brr[i] = Arr[i];
    }
    sort(Brr+1,Brr+n+1);
    *Brr = unique(Brr+1,Brr+n+1)-Brr-1;
    int lo = 1,hi = *Brr,mid,now = 0;
    while(lo<=hi)
    {
        mid = (lo+hi)>>1;
        //cout<<mid<< "*\n";
        if( Ok(Brr[mid]) )lo = mid+1,now = mid;
        else hi = mid-1;
    }
    cout<<Brr[now]<< "\n";










    return 0;
}



Measured memory_bytes: 4736
#include<stdio.h>

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < vi, int > a, pair < vi, int > b)//true for a before b
{
	if(a.F.empty())
		return 1;
	if(b.F.empty())
		return 0;
	int i;
	fo(i,0,min(sz(a.F),sz(b.F)))
	{
		if(a.F[i] < b.F[i])
			return 1;
		else if(a.F[i] > b.F[i])
			return 0;
	}
	return (sz(a.F) <= sz(b.F));
}

const int N = (2e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;
const int SQRT = BUCK+9;

string s;
int cnt[26];

void solve()
{
	int n, i, j;
	ll ans = 1;
	cin >> s;
	n = s.length();
	for(i = n-1; i >= 0; i--)
	{
		fo(j,0,26)
			if(j != s[i]-'a')
				ans += cnt[j];
		cnt[s[i]-'a']++;
	}
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<int,int,int> T;

typedef struct Edge {
    ll to, cost;
} Edge;

vector<vector<Edge>> g;
bool ok = true;
ll dist[252525];
bool vi[252525];

void dfs(int x, ll d) {
    if (vi[x]) return;
    vi[x] = true;
    dist[x] = d;
    for (auto &&e: g[x]) dfs(e.to,d+e.cost);
    return;
}

int main(int argc, char const *argv[]) {
    int n,m;
    cin >> n >> m;
    vector<ll> l(m),r(m),d(m);
    g.resize(n);

    REP(i,m) {
        cin >> l[i] >> r[i] >> d[i];
        --l[i],--r[i];
        g[l[i]].push_back({r[i],d[i]});
        g[r[i]].push_back({l[i],-1ll*d[i]});
    }

    memset(dist,0,sizeof(dist));
    memset(vi,0,sizeof(vi));

    for (int i = 0; i < n; ++i) dfs(i, 0);
    

    REP(i,m) {
        if (dist[r[i]]-dist[l[i]] != d[i]) ok = false;
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

typedef long long ll;
const int N = 1e5 + 100, LOG = 62;

ll n, m, k, dex, x[N], d[N], is[N], go[N][LOG];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if(i)
			d[i] = x[i] - x[i - 1], go[i][0] = i;
	}
	cin >> m >> k;
	while(m--) {
		cin >> dex;
		dex--;
		swap(go[dex][0], go[dex + 1][0]);
	}
	for (int j = 1; j < LOG; j++)
		for (int i = 0; i < n; i++)
			go[i][j] = go[go[i][j - 1]][j - 1];
	iota(is, is + n, 0);
	for (int j = LOG - 1; ~j; j--)
		if(k >= (1LL << j)) {
			k -= 1LL << j;
			for (int i = 1; i < n; i++)
				is[i] = go[is[i]][j];
		}
	ll now = x[0];
	cout << now << ' ';
	for (int i = 1; i < n; i++) {
		now += d[is[i]];
		cout << now << ' ';
	}
	return 0;
}

Measured memory_bytes: 52096
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll a,v,b,w,t;
    cin >> a >>v >> b >>w >>t;

    if(v-w<=0){
        cout<<"NO"<<endl;
    }
    else{
        ll sa = v-w;
        sa*=t;
        if(abs(a-b)<=sa){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
}
    



Measured memory_bytes: 3632
s=input()
l=len(s)

dp=[[0]*3 for i in range(l)]
mod=10**9+7
c=0

for i in range(l):
    if s[i]=="A":
        dp[i][0]=dp[i-1][0]+pow(3,c,mod)
        dp[i][1]=dp[i-1][1]
        dp[i][2]=dp[i-1][2]
    elif s[i]=="B":
        dp[i][0]=dp[i-1][0]
        dp[i][1]=dp[i-1][1]+dp[i-1][0]
        dp[i][2]=dp[i-1][2]
    elif s[i]=="C":
        dp[i][0]=dp[i-1][0]
        dp[i][1]=dp[i-1][1]
        dp[i][2]=dp[i-1][2]+dp[i-1][1]
    else:
        dp[i][0]=dp[i-1][0]*3+pow(3,c,mod)
        dp[i][1]=dp[i-1][1]*3+dp[i-1][0]
        dp[i][2]=dp[i-1][2]*3+dp[i-1][1]
        c+=1
    dp[i][0]=dp[i][0]%mod
    dp[i][1]=dp[i][1]%mod
    dp[i][2]=dp[i][2]%mod

print(dp[-1][2])


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,m,a;

int main(){
    while(cin >> n >> m >> a && n){
        vector<P> vp(m);
        ll num;
        rep(i,m)cin >> vp[i].first >> vp[i].second >> num;
        sort(ALL(vp));
        reverse(ALL(vp));
        vector<ll> ans(n);
        rep(i,n)ans[i] = i+1;
        rep(i,m){
            ll num = vp[i].second;
            num--;
            swap(ans[num],ans[num+1]);
        }
        rep(i,n){
            if(ans[i] == a)cout << i+1 << endl;
        }
    }
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi xs(n);
    for (int& x:xs) cin>>x;
    int ans=0;
    for (int i=1; i<n; i++)
        if (xs[i]==xs[i-1])
            ans++, xs[i]=-1;
    cout << ans << '\n';
}


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

ll mod = 1e9+7 ;
const ld error = 1e-9;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll

inline ll MOD(ll x, ll m = mod){
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = 1e3+10;
///===========================================  template  =======================================================

char grid[nmax][nmax];
int dist[nmax][nmax];
#define valid(i, j) (unsigned(i) < n && unsigned(j) < m)
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};


void bfs(vector<pair<int, int>> &v, int n, int m){
    for(int i = 0; i<n; i++)
        for(int j = 0; j<m; j++) dist[i][j] = inf;
    queue<pair<int, int> > q;
    for(auto p: v){
        dist[p.first][p.second] = 0;
        q.push(p);
    }

    while(!q.empty()){
        auto p = q.front();
        q.pop();
        int d = dist[p.first][p.second]+1;
        for(int i = 0; i<4; i++){
            int x = p.first+dx[i];
            int y = p.second+dy[i];
            if(!valid(x, y)) continue;
            if(dist[x][y] > d){
                dist[x][y] = d;
                q.emplace(x,y);
            }
        }
    }
    return;
}

int main(){
    FASTIO;
    int n, m;
    cin>>n>>m;
    vector<pair<int, int>> v;
    for(int i= 0; i<n; i++){
        cin>>grid[i];
        for(int j = 0; j<m; j++){
            if(grid[i][j] == '#')
                v.emplace_back(i, j);
        }
    }

    bfs(v, n, m);
    int ans = 0;
    for(int i = 0; i<n; i++)
        for(int j = 0; j<m; j++)
            ans = max(ans, dist[i][j]);
    cout<<ans;
    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int N;
ll maximum[100001];
ll A[100001];

ll solve() {
  if (N == 0) {
    if (A[0] == 1) {
      return 1;
    } else {
      return -1;
    }
  }

  maximum[0] = 1;
  for (int i = 1; i <= N; ++i) {
    if (maximum[i - 1] - A[i - 1] < 0) {
      return -1;
    }
    maximum[i] = min((maximum[i - 1] - A[i - 1]) * 2, 100000000000000000LL);
    DBG(i, maximum[i]);
  }

  if (A[0] > 0) {
    return -1;
  }

  if (maximum[N] < A[N]) {
    return -1;
  }

  ll nodes = A[N];
  ll ans = A[N];
  for (int i = N - 1; i >= 0; --i) {
    DBG(i, nodes, A[i], maximum[i]);
    if (nodes / 2 + nodes % 2 + A[i] > maximum[i]) {
      return -1;
    }
    nodes = min(nodes + A[i], maximum[i]);
    ans += nodes;
    DBG(nodes, ans);
  }
  return ans;
}

int main() {
  cin >> N;

  REP(i, N + 1) cin >> A[i];

  cout << solve() << endl;
}


Measured memory_bytes: 5184
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin); i < (end); i++)
#define _irep3(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

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

  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  rep(i, N) cin >> w[i] >> v[i];

  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, -INF));
  rep(i, N) dp[i][0] = 0;
  rep(i, N) {
    rep(j, W + 1) {
      dp[i + 1][j] = dp[i][j];
    }
    rep(j, W) {
      if (dp[i][j] == -INF || j + w[i] > W) continue;
      dp[i + 1][j + w[i]] = max(dp[i][j] + v[i], dp[i + 1][j + w[i]]);
    }
  }

  ll ans = -INF;
  irep(i, W + 1) {
    ans = max(dp[N][i], ans);
  }
  out(ans);
}


Measured memory_bytes: 80256
h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d={a*(10**9)+b-1 for a,b in ab}

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[None for _ in [0]*25]
    for i in range(5):
        for j in range(5):
            if 0<a+i-2<=h and 0<b+j-2<=w:
                if (a+i-2)*(10**9)+b+j-3 in ab_d:
                    temp[i*5+j]=1
                else:
                    temp[i*5+j]=0
    for i in range(3):
        for j in range(3):
            cnt=[temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
            if None not in cnt:
                ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)
                
for i in range(9):
    ans[i]=len(ans[i])

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)

Measured memory_bytes: 118888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w;
  cin>>n>>w;
  long long int wt[n],val[n];
  for(int i=0;i<n;i++)
    cin>>wt[i]>>val[i];
 long long  int dp[n+1][w+1];
 
  for(int i=0;i<=n;i++){
    for (int k=0;k<=w;k++){
    	if(i==0||k==0) dp[i][k]=0;
        else if(wt[i-1]<=k)
          dp[i][k]=max(dp[i-1][k-wt[i-1]]+val[i-1],dp[i-1][k]);
        else dp[i][k]=dp[i-1][k];
    }
  }
  
   
   cout<<dp[n][w]<<endl;
}
      

Measured memory_bytes: 79104
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>//辞書順はnext_permutation
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<utility>//swap(数値交換)
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define please return
#define AC 0

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
int a,b,c;
asas;
cin>>a>>b>>c;
if(a==7){
if(c==5&&b==5){
ans++;
}
}
if(b==7){
if(c==5&&a==5){
ans++;
}
}
if(c==7){
if(a==5&&b==5){
ans++;
}
}
YES(ans==1);
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr = reader.readLine();
    System.out.println(reverse(readStr));
  }

  public static String reverse(String str) {
    char[] strChars = str.toCharArray();
    
    for (int i = 0; i < strChars.length / 2; i++) {
      char stack = strChars[i];
      strChars[i] = strChars[strChars.length-1-i];
      strChars[strChars.length-1-i] = stack;
    }
    return new String(strChars);
  }
  
}

Measured memory_bytes: 16860
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <queue>
#include <map>

using namespace std;

int N;
vector<vector<int> > tree;

int fcost[500001];
int scost[500001];

void bfs(int sp, int cost[])
{
    queue<pair<int, int> > q;
    q.push(make_pair(sp, 0));

    while(q.empty() == false)
    {
        pair<int, int> e = q.front();
        q.pop();
        if (cost[e.first] != -1)
        {
            continue;
        }
        //cout << "cell : " << e.first << " cost : " << e.second << endl;
        cost[e.first] = e.second;
        for (int i = 0; i < tree[e.first].size();i++)
        {
            pair<int, int> t = make_pair(tree[e.first][i], e.second + 1);
            q.push(t);
            //cout << "b" << endl;
        }
    }
}

int main()
{
    cin >> N;

    tree.resize(N + 1);

    for (int i = 0; i < N - 1; i++)
    {
        int from, to;
        cin >> from >> to;
        tree[from].push_back(to);
        tree[to].push_back(from);
    }

    fill(fcost, fcost + 500001, -1);
    fill(scost, scost + 500001, -1);

    bfs(1, fcost);
    bfs(N, scost);

    int fn = 0;
    int sn = 0;

    for (int i = 1; i <= N;i++)
    {
        if(fcost[i] <= scost[i])
        {
            fn++;
        }
        else
        {
            sn++;
        }
    }

    if(fn > sn)
    {
        cout << "Fennec" << endl;
    }
    else
    {
        cout << "Snuke" << endl;
    }

    return 0;
}

Measured memory_bytes: 9984
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; }
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    // spf:
    // store smallest prime factor of number
    // 最小の素因数を格納
    // is_prime:
    // 配列番号が素数であるかどうかを示す
    let mut spf = vec![None; n + 1];
    let mut is_prime = vec![true; n + 1];
    let mut primes = Vec::new();

    // 0 と 1 は素数ではない
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n + 1 {
        // is_prime[i]:
        // それ以下の素数で割り切られていなければ True となる
        if is_prime[i] {
            // この if 文より i は素数なので
            primes.push(i);

            // 素数はそれ自身の最も小さい素因数であるから
            spf[i] = Some(i);
        }

        // 全ての prime の倍数(prime * i)を取り除く
        for prime in &primes {
            // prime が i の最も小さい因数よりも大きくなってしまったら探索終了
            if i * prime >= n + 1 || prime > &spf[i].unwrap() {
                break;
            }

            is_prime[i * prime] = false;

            // i * primes[j] の最も小さい素数は primes[j] 自身
            spf[i * prime] = Some(*prime);
        }
    }
    primes
}

fn main() {
    input!(x: usize);
    let primes = sieve_of_eratosthenes(1000003);

    for i in primes {
        if i >= x {
            println!("{}", i);
            return ();
        }
    }
}


Measured memory_bytes: 22780
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)


int main() {
	ll a, b, c, d, e=0, f,i, g,l[100];
	cin >> a >> b;
	rep(i, a) {
		cin >> l[i];
		e = e + l[i];
		if (e > b) {
			cout << i + 1;
			break;
		}
		if (i == a - 1)cout << a + 1;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include<set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;
int main() {
	int x, a; cin >> x >> a;
	if (x < a)printf("0");
	else printf("10");
	return 0;
}

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

int n,a[1010][1010],h[1000100],dist[1000100];
vector<int>to[1000100];

int encode(int i, int j){
  if(i>j)swap(i,j);
  return i*n+j;
}

int main(){
  cin>>n;
  rep(i,n)rep(j,n-1){
    cin>>a[i][j];
    a[i][j]--;
  }
  rep(i,n)rep(j,n-2){
    int v=encode(i,a[i][j]);
    int u=encode(i,a[i][j+1]);
    to[v].push_back(u);
    h[u]++;
  }
  stack<int>st;
  rep(i,n*n)if(h[i]==0)st.push(i),dist[i]=1;
  while(st.size()){
    int v=st.top(); st.pop();
    for(int u:to[v]){
      h[u]--;
      if(h[u]==0)st.push(u);
      dist[u]=max(dist[u],dist[v]+1);
    }
  }
  int mx=0,in=0;
  rep(i,n*n)mx=max(mx,dist[i]);
  rep(i,n*n)in=max(in,h[i]);
  if(in!=0)cout<<-1<<endl;
  else cout<<mx<<endl;
}

Measured memory_bytes: 56436
#include <bits/stdc++.h> 
using namespace std; 
#define vector <int> vi;
void solve(); 
int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("error.txt", "w", stderr); 
    freopen("output.txt", "w", stdout); 
#endif 
  
    int t = 1; 
    ///*is Single Test case?*/ cin >> t; 
    while (t--) { 
        solve(); 
        cout << "\n"; 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 
void solve() 
{ 
	int a,b;
	cin>>a>>b;
	cout<<(a*b);
} 

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

using namespace std;

const int INF = 1 << 29;
using int64 = long long;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << ((b - a) % 2 ? "Borys" : "Alice") << endl;
  return 0;
}


Measured memory_bytes: 256
import Text.Printf

main = getLine >>=
        \l -> let a:b:_ = map read . words $ l :: [Int]
              in let resDiv = a `div` b
                     resMod = a `mod` b
                     resDivF = ((fromIntegral a) :: Double) / ((fromIntegral b) :: Double) :: Double
                     in do
                        printf "%d %d %.5f\n"  resDiv resMod resDivF

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m;
	cin>>n>>m;
	(((n%10)%2==0&&(m%10)%2==0)||((n%10)%2==0&&(m%10)%2==1)||((m%10)%2==0&&(n%10)%2==1))?cout<<"Even"<<endl:cout<<"Odd"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<char,int> mp;
int main(){
int n,k;
cin>>n>>k;
vector<ll> v(n+1,0);
for(int i=0;i<n;i++)cin>>v[i];
int m=n+1;
int ma=min(k,n);
ll ans=0;
for(int i=ma;i>=1;i--){//iは区間
for(int j=m-i-1;j<m;j++){
    ll res=0;
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    int l=0;
while(l!=i+1){res+=v[(l+j)%m];pq.push(v[(l+j)%m]);l++;}
    int times=k-i;
   while(times--){
       if(pq.empty())break;
        ll tmp=pq.top();
        pq.pop();
        if(tmp>=0)break;
        res-=tmp;
    }
ans=max(ans,res);
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,i;
    double c=0,x;
    scanf("%d",&N);
    for(i=1;i<=N;i++)
    {
        if(i%2==1)
        {
            c++;
        }
    }
    x=c/N ;
    printf("%0.10f\n",x);
    return 0;

}



Measured memory_bytes: 1732
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let s:Vec<char> = read::<String>().chars().collect();
    let w:u32 = read();

    for (i, &ch) in s.iter().enumerate() {
        if i as u32 % w == 0 {print!("{}",ch)}
    }
    println!("");

}


Measured memory_bytes: 4352
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    string S, C;
    string pre, suf;
    int T;
    int Q, q;
    cin >> S >> Q;
    bool isReversed = false;
    for (int i = 0; i < Q; i++) {
        cin >> q;
        if (q == 1) {
            isReversed = !isReversed;
        } else {
            cin >> T >> C;
            if (T == 1) {
                if (isReversed) {
                    suf += C;
                } else {
                    pre += C;
                }
            } else {
                if (!isReversed) {
                    suf += C;
                } else {
                    pre += C;
                }
            }
        }
    }
    
    if (isReversed) {
        for (long i = suf.length() - 1; i >= 0 ; i--) {
            cout << suf[i];
        }
        for (long i = S.length() - 1; i >= 0 ; i--) {
            cout << S[i];
        }
        for (long i = 0; i < pre.length(); i++) {
            cout << pre[i];
        }
    } else {
        for (long i = pre.length() - 1; i >= 0 ; i--) {
            cout << pre[i];
        }
        for (long i = 0; i < S.length(); i++) {
            cout << S[i];
        }
        for (long i = 0; i < suf.length(); i++) {
            cout << suf[i];
        }
    }
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  ll n, k; 
  cin >> n >> k;

  vector<ll> h(n);
  rep(i, n) {
      cin >> h[i];
  }
  sort(h.begin(), h.end());
//   rep(i, n) {
//       cout << h[i] << endl;
//   }

  ll diff_with_k = 1e9 + 1;
  rep(i, n-k+1) {
    diff_with_k = min(diff_with_k,h[i+k-1] - h[i]);
  }
  cout << diff_with_k << endl;
  return 0;
}

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b;
  cin >> a >> b;
  int ans = max(a+b, a-b);
  ans = max(ans, a*b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int n;
int a[200];

int main()
{
    int ans=0;
    int top=10000;
    cin>>n;
    for (int i=0; i<n; ++i)
    {
        cin>>a[i];
        if (i && a[i]==a[i-1]) 
        {
            a[i]=top--;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256