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

double hayami_saori(int uesaka_sumire,
const double hanazawa_kana[], const double murakawa_rie[], double mimori_suzuko) {
	int utida_maaya;
	double tange_sakura = 0;
	for (utida_maaya = 0; utida_maaya < uesaka_sumire; utida_maaya++) {
		tange_sakura += pow(fabs(hanazawa_kana[utida_maaya] - murakawa_rie[utida_maaya]), mimori_suzuko);
	}
	return pow(tange_sakura, 1.0 / mimori_suzuko);
}

double minase_inori(int mizuki_nana,
const double fukuenn_misato[], const double mizuhasi_kaori[]) {
	int komatu_mikako;
	double tamura_yukari = 0;
	for (komatu_mikako = 0; komatu_mikako < mizuki_nana; komatu_mikako++) {
		double oohasi_ayaka = fabs(fukuenn_misato[komatu_mikako] - mizuhasi_kaori[komatu_mikako]);
		if (oohasi_ayaka > tamura_yukari) tamura_yukari = oohasi_ayaka;
	}
	return tamura_yukari;
}

int main(void) {
	int asumi_kana, kitamura_eri;
	double tomatu_haruka[128], iguti_yuka[128];
	if (scanf("%d", &asumi_kana) != 1) return 1;
	for (kitamura_eri = 0; kitamura_eri < asumi_kana; kitamura_eri++) {
		if (scanf("%lf", &tomatu_haruka[kitamura_eri]) != 1) return 1;
	}
	for (kitamura_eri = 0; kitamura_eri < asumi_kana; kitamura_eri++) {
		if (scanf("%lf", &iguti_yuka[kitamura_eri]) != 1) return 1;
	}
	for (kitamura_eri = 1; kitamura_eri <= 3; kitamura_eri++) {
		printf("%.15f\n", hayami_saori(asumi_kana, tomatu_haruka, iguti_yuka, kitamura_eri));
	}
	printf("%.15f\n", minase_inori(asumi_kana, tomatu_haruka, iguti_yuka));
	return 0;
}



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

int main(){
  int n,m,x,a,cntL,cntR;
  cin >> n >> m >> x;
  vector<int> A(n+1);
  for(int i = 0; i < m;i++){
    cin >> a;
    A.at(a)++;
  }

  cntL = 0;cntR = 0;
  for(int i = x;i >= 0;i--){
    if(A.at(i) != 0){
      cntL++;
    }
  }
  for(int j = x;j < n+1;j++){
    if(A.at(j) != 0){
      cntR++;
    }
  }
  cout << min(cntR,cntL) << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		if(R<=1199) {
			System.out.println("ABC");
		} else if (R<=2799) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}


Measured memory_bytes: 23124
N, Q = map(int, input().split())
S = list(input())

# cum[i]: S[0]~S[i]におけるACの数
cum = [0]
cnt = 0
for i in range(1, N):
    if S[i-1]+S[i] == 'AC':
        cnt+=1
    cum.append(cnt)

ans = []
for i in range(Q):
    l, r = map(int, input().split())
    ans.append(cum[r-1] - cum[l-1])

for i in ans:
    print(i)

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

namespace AtCoder178
{
    class Program
    {
        static int[] RI()
        {
            return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        }

        static long[] RL()
        {
            return Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        }

        static string RS()
        {
            return Console.ReadLine();
        }

        static void W(string msg)
        {
            Console.WriteLine(msg);
        }

        static void Main(string[] args)
        {
            QA();
        }

        static void QA()
        {
            W("0".Equals(RS()) ? "1" : "0");
        }

        static void QB()
        {

        }

        static void QC()
        {

        }

        static void QD()
        {

        }

        static void QE()
        {

        }
    }
}


Measured memory_bytes: 17160
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<map> 
using namespace std;
typedef long long ll;
const int mmax=1e9+10;
map<ll,ll> book1;
int main()
{
	ll n;
	while(cin>>n)
	{	
		ll ans=0;
		for(int i=1;i<=n;i++)
		{
			ll a;
			cin>>a;
			if(book1[a]==1)
			{
				book1[a]--;
				ans--;	
			}	
			else if(book1[a]==0)
			{
				book1[a]++;
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 6528
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846
#ifdef LOCAL
#include <sys/types.h>
#include <sys/timeb.h>
#include <intrin.h> 
#include <thread>
#else
#include <sys/time.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)


int main(){
	string s;
	cin >> s;
	int n = s.length();
	LL ret = 0;
	LL b = 0;
	REP(i, n) {
		if (s[i] == 'B')b++;
		else ret += b;
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = 0, sum = 0;
    for(int i = 0; i < N; i++){
      int tmp = sc.nextInt();
      max = max > tmp ? max : tmp;
      sum += tmp;
    }
    if(max < sum - max){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

ll knapsack(vector<pair<int,ll>>v,int n,int c)
{   
    ll a[n+1][c+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=c;j++)
        {
            a[i][j] = 0;
        }
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=c;j++)
        {
            if(i==0 || j==0)
            {
                a[i][j] = 0;
            }
            else if(v[i-1].first<=j)
            {
                a[i][j] = max(v[i-1].second+a[i-1][j-v[i-1].first],a[i-1][j]);
            }
            else
            {
                a[i][j] = a[i-1][j];
            }
        }
    }
    return a[n][c];
}

int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,c;
    cin>>n>>c;
    vector<pair<int,ll>> v(n);   // first will be weight and second will be value
    for(int i=0;i<n;i++)
    cin>>v[i].first>>v[i].second;  
    cout<<knapsack(v,n,c)<<endl;
}

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

int main() {
  int N;
  int64_t sum=0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  }
  for (int i = 0; i < N; i++) {
    sum = (sum ^ vec.at(i));
  }
  for (int i = 0; i < N; i++) {
    cout << (sum ^ vec.at(i)) << " ";
  }
  cout << endl;
}


Measured memory_bytes: 4052
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> h = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			h.add(sc.nextInt());
		}
		Collections.reverse(h);
		int ans = 0;
		int count = 0;
		for(int i = 1;i < n; i++) {
			if(h.get(i-1)<=h.get(i)) {
				count++;
			}
			else {
				count = 0;
			}
			ans = Math.max(ans, count);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 58908
#include<iostream>
#include<string>

using namespace std;

int conv(char str)
{
	if(str=='I')
	{
		return 1;
	}
	else if(str=='V')
	{
		return 5;
	}
	else if(str=='X')
	{
		return 10;
	}
	else if(str=='L')
	{
		return 50;
	}
	else if(str=='C')
	{
		return 100;
	}
	else if(str=='D')
	{
		return 500;
	}
	else if(str=='M')
	{
		return 1000;
	}
}

int conv(string str)
{
	int ans=0;
	for(int i=0;i<str.length();i++)
	{
		if(i==str.length()-1)
		{
			ans+=conv(str[i]);
		}
		else if(conv(str[i])<conv(str[i+1]))
		{
			ans-=conv(str[i]);
		}
		else ans+=conv(str[i]);
	}
	return ans;
}

int main(void)
{
	string str;
	while(cin>>str)
	{
		cout<<conv(str)<<endl;
	}
}

Measured memory_bytes: 1184
#include<iostream>
#include<string>

using namespace std;


int main() {

	string s;

	cin >> s;
	int ans;
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		ans = 3;
	}
	else if ((s[0] == 'R' && s[1] == 'R')  || (s[1] == 'R' && s[2] == 'R')) {
		ans = 2;

	}
	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
		ans = 1;
	}
	else {
		ans = 0;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3580
using System;
namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int K = s2i(Console.ReadLine())+1;
            int sum = 0;
            for(int a = 1;a<K;a++)
            {
                for (int b = 1; b < K; b++)
                {
                    for (int c = 1; c < K; c++)
                    {
                        sum += Gcd(a,b,c);
                    }
                }
            }
            RESULT(sum);
                 
        }
        public static int Gcd(int a, int b,int c)
        {
            return Gcd(Gcd(a,b),c);
        }

        public static int Gcd(int a, int b)
        {
            if (a < b)
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine(); 
            }
            return res;
        }

        static int[] S2Iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 27552
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
fn main() {
    input!(N: usize);
    input!(A: [usize; N]);
    let mut ans = 0;
    let mut mx = 0;
    for i in 0..N {
        let now = A[i];
        if now < mx {
            ans += (mx - now);
        } else {
            mx = now;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 5636
import java.util.Scanner;
public class Main
{
	public static void main(String args[])
	{
		int a, b;
		Scanner inp = new Scanner(System.in);
		while( true )
		{
			a = inp.nextInt();
			b = inp.nextInt();
			if(a == 0 && b == 0)
				break;
			else {
				if(a > b)
					System.out.println(b + " " + a);
				else
					System.out.println(a + " " + b);
			}
		}
	}
}

Measured memory_bytes: 36892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n, m) for (int i = n; i <= m; ++i)
#define mem(a, b) memset(a, b, sizeof(a))
#define dbg(x) cout << #x << "=" << x << endl
const int maxm = 1e9 + 7;
const int maxn = 2e5 + 10;
#define gc getchar
#define ll long long
#define P pair<int, int>
template <class I>
inline void read(I &x)
{
    char c;
    I f;
    for (f = 1, c = gc(); c < '0' || c > '9'; c = gc())
        if (c == '-')
            f = -1;
    for (x = 0; c <= '9' && c >= '0'; c = gc())
        x = (x << 1) + (x << 3) + (c & 15);
    x *= f;
}
char s[1000005];
int ss[1000005];
int dp[1000005][2];
int main()
{
    int T;
    // read(T);
    T = 1;
    while (T--)
    {

        scanf("%s", s);
        int l = strlen(s);
        // dbg(l);
        for (int i = 0; i < l; ++i)
            ss[i] = s[i ] - '0';
        ll ans = 0;
        dp[0][0]=ss[0];
        dp[0][1]=10-ss[0]+1;
        rep(i, 1, l-1)
        {
            dp[i][0]=ss[i]+min(dp[i-1][0],dp[i-1][1]);
            dp[i][1]=10-ss[i]+min(dp[i-1][0]+1,dp[i-1][1]-1);
        }
        //    mem(jin,0);
        //    for(int i=l;i>0;--i)
        //    {
        //        if(ss[i]>5)
        //        {
        //            ss[i]=10-ss[i];
        //            jin[i-1]++;
        //        }
        //    }
        //    for(int i=l-1;i>0;--i)
        //    {
        //        if(jin[i])
        //        {
        //            if(ss[i]+jin[i]>9)
        //            {
        //                ss[i]+=jin[i];
        //                ss[i]%=10;
        //                jin[i-1]++;
        //            }
        //            else ss[i]+=jin[i];
        //        }
        //    }
        //    rep(i,0,l) ans+=ss[i];
        cout <<min(dp[l-1][0],dp[l-1][1])<< endl;
    }
}

// abcda
// cbad

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

vector<pair<int, int>> segment_union(vector<pair<int, int>> segments) {
    sort(segments.begin(), segments.end());
    vector<pair<int, int>> res;
    for (auto s : segments) {
        if (res.empty() || s.first > res.back().second)
            res.push_back(s);
        else
            res.back().second = s.second;
    }
    return res;
}

const int mod = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> segments(k);
    for (int i = 0; i < k; i++) {
        cin >> segments[i].first >> segments[i].second;
    }
    segments = segment_union(segments);
    vector<int> dp(n, 0);
    vector<int> pref(n + 1, 0);
    dp[0] = 1;
    pref[0] = 0;
    for (int i = 1; i < n; i++) {
        pref[i] = pref[i - 1] + dp[i - 1];
        pref[i] %= mod;
        for (auto s : segments) {
            if (i - s.first < 0)
                continue;
            int l = max(0, i - s.second), r = i - s.first;
            dp[i] += pref[r + 1] - pref[l];
            dp[i] %= mod;
            if (dp[i] < 0)
                dp[i] += mod;
        }
    }
    cout << dp[n - 1];
    return 0;
}


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

int main(){
    int x;
    cin >> x;
    if(400 <= x && x <= 599) cout << 8 << endl;
    else if(600 <= x && x <= 799) cout << 7 << endl;
    else if(800 <= x && x <= 999) cout << 6 << endl;
    else if(1000 <= x && x <= 1199) cout << 5 << endl;
    else if(1200 <= x && x <= 1399) cout << 4 << endl;
    else if(1400 <= x && x <= 1599) cout << 3 << endl;
    else if(1600 <= x && x <= 1799) cout << 2 << endl;
    else if(1800 <= x && x <= 1999) cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>



void PRINT(int* A,int Len){
    for(int i = 0;i<Len-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[Len-1]);
    return;
}

void insertionSort(int* A,int n,int g,int* cnt){     //[0,g,2g,...,]と[1,g+1,2g+1,...,]...のをそれぞれ整列。行列自体はg個ある。
    for(int i = g;i < n;i++){     //それぞれの行列を同時に実行。
        int v = A[i];
        int j = i - g;      //行列で一つ下の要素
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            *cnt += 1;
        }
        A[j+g] = v;
    }
    return;
}


void shellSort(int* A,int n){
    int cnt = 0;
    int m = 0;
    while(pow(2,m) <= n){
        m ++;
    }
    int G[m];
    for(int i=0;i<m;i++){
        G[i] = (int)pow(2,m-1-i);        //ソートのいくつ置きか。
    }

    for(int i = 0;i < m;i++){
        insertionSort(A, n, G[i],&cnt);
    }
    printf("%d\n",m);     //何回の挿入ソートをしたか。
    for(int i = 0;i<m-1;i++){
        printf("%d ",G[i]);
    }
    printf("%d\n",G[m-1]);
    printf("%d\n",cnt);     //何回の移動したか
    return;
}



int main(){
    int n;
    scanf("%d",&n);

    int A[n];

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

    shellSort(A,n);
    for(int i =0;i<n;i++){
        printf("%d\n",A[i]);
    }


    return 0;
}



Measured memory_bytes: 6632
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;


const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 400;

int a[MAX][MAX];
int p[MAX] = {0};
int numb[MAX] = {0};

int main()
{
	//freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, n)
	{
		FOR(j, 0, m) cin >> a[i][j];
	}

	int ans = n;
	set<int> sett;
	FOR(k, 0, m - 1)
	{
		FILL(numb, 0);
		FOR(i, 0, n)
		{
			numb[a[i][p[i]]]++;
		}

		int maxx = 0;
		FOR(i, 0, m + 1)
		{
			if (numb[i] > numb[maxx]) maxx = i;
		}

		sett.insert(maxx);
		ans = min(numb[maxx], ans);
		FOR(i, 0, n)
		{
			while (sett.find(a[i][p[i]]) != sett.end())
			{
				p[i]++;
			}
		}
	}

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

Measured memory_bytes: 768
#include "bits/stdc++.h"

using namespace std;

static const int maxn = 300 + 5;
static const int inf  = 1e8 + 8;

struct Edge
{
      int v;
      long long w;
      Edge(int v = 0, long long w = 0) : v(v), w(w) {}
};

struct Info
{
      int v;
      int d;
      Info(int v = 0, int d = 0) : v(v), d(d) {}

      bool operator < (const Info &p) const
      {
            return d < p.d;
      }
};

vector < vector <Edge> > graph;
int dist[maxn];
long long remaind[maxn];
int ans[maxn][maxn];
int tnode;
int tedge;
long long toil;

void dijkstra(int src)
{
      for (int i = 0; i < maxn; i++)
      {
            dist[i] = inf;
            remaind[i] = 0;
      }
      priority_queue <Info> pq;
      pq.emplace(src, 0);
      dist[src] = 0;
      remaind[src] = toil;
      while (!pq.empty())
      {
            int u = pq.top().v;
            long long remOil = remaind[u]; pq.pop();
            for (Edge E : graph[u])
            {
                  int v = E.v;
                  long long w = E.w;
                  if (remOil >= w)
                  {
                        if (dist[v] > dist[u])
                        {
                              dist[v] = dist[u];
                              remaind[v] = remOil - w;
                              pq.emplace(v, dist[v]);
                        }
                        else if (dist[v] == dist[u] && remaind[v] < remOil - w)
                        {
                              dist[v] = dist[u];
                              remaind[v] = remOil - w;
                              pq.emplace(v,dist[v]);
                        }
                  }
                  else
                  {
                        if (toil >= w && dist[v] > dist[u] + 1)
                        {
                              dist[v] = dist[u] + 1;
                              remaind[v] = toil - w;
                              pq.emplace(v, dist[v]);
                        }
                        else if (toil >= w && dist[v] == dist[u] + 1 && remaind[v] < toil - w)
                        {
                              dist[v] = dist[u] + 1;
                              remaind[v] = toil - w;
                              pq.emplace(v, dist[v]);
                        }
                  }
            }
      }
      for (int i = 1; i <= tnode; i++)
      {
            ans[src][i] = dist[i];
            if (ans[src][i] == inf) ans[src][i] = -1;
      }
}

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);

      cin >> tnode >> tedge >> toil;
      graph.resize(tnode + 1);
      for (int e = 1; e <= tedge; e++)
      {
            int u, v;
            long long w;
            cin >> u >> v >> w;
            if (w > toil) continue;
            graph[u].emplace_back(v, w);
            graph[v].emplace_back(u, w);
      }
      for (int i = 1; i <= tnode; i++)
      {
            dijkstra(i);
      }
      int q;
      cin >> q;
      while (q--)
      {
            int u, v;
            cin >> u >> v;
            cout << ans[u][v] << '\n';
      }
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl '\n'
#define maxl __LONG_LONG_MAX__
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define rep(i, n) for(int i = 0; i < n; i++)
#define rev(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i=1; i < n; i++)
#define rev1(i, n) for(int i=n ; i > 0; i--)
#define FOR(i, a, b) for(int i=a ; i < b; i++)
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define n_ones(x) __builtin_popcountll(x)
#define n_trailzero(x) __builtin_ctzll(x)
#define n_leadingzero(x) __builtin_clz(x)
#define sz(a) (ll)(a.size())

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef stack<ll> stk;
typedef queue<ll> que;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_setll;
typedef tree<char,null_type,less<char>,rb_tree_tag,
tree_order_statistics_node_update> indexed_setc;

ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}

ll mod = 1e9 + 7;

ld dp[305][305][305];
ll vis[305][305][305];
ll n;

ld ans(ll c1, ll c2, ll c3)
{
	if(vis[c1][c2][c3])
		return dp[c1][c2][c3];
		
	vis[c1][c2][c3]++;
	
	if(c1 == 0 && c2 == 0 && c3 == 0)
		return dp[c1][c2][c3] = 0;
		
	ld sum = c1 + c2 + c3;
	ld pro = (n - (ld)sum) / ((ld)sum);
	//trace3(c1, c2, c3);
	//trace(pro);
	if(c1 != 0)
		pro += c1 * ((ans(c1 - 1, c2, c3) + 1) / (ld)sum);
	if(c2 != 0)
		pro += c2 * ((ans(c1 + 1, c2 - 1, c3) + 1) / (ld)sum);
	if(c3 != 0)
		pro += c3 * ((ans(c1, c2 + 1, c3 - 1) + 1) / (ld)sum);
	
	return dp[c1][c2][c3] = pro;
}
void solve()
{
	cin>>n;
	ll c1 = 0, c2 = 0, c3 = 0;
	rep(i, n)
	{
		ll temp;
		cin>>temp;
		if(temp == 1)
			c1++;
		else if(temp == 2)
			c2++;
		else
			c3++;
	}
	cout<<setprecision(10)<<ans(c1, c2, c3)<<endl;
	
	return;
}

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	ll t = 1;
	//cin>>t;
	rep(i, t)
		solve();
	return 0;
	
}

Measured memory_bytes: 657664
integer(16),dimension(10,10)::a
character(11)S
integer(16) answer,aki
read*,S
a=0
do i=1,len_trim(S)
	do j=i,len_trim(S)
    	if(j==i)then
        	a(i,j)=2**(i-1)
        else
        	a(i,j)=2**(j-2)
        endif
    end do
end do
answer=0
do i=1,len_trim(s)
	read(S(i:i),*) aki
    do j=i,len_trim(S)
    	answer=answer+aki*10**(len_trim(s)-j)*a(i,j)
    end do
end do
print"(I0)",answer
end

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

int main(){
	int a; cin>>a;
	string s; cin>>s;
	for(int i=0; i<s.size();++i){
		//cout<<char((s[i]+a)%65+'A');
		if (s[i]+a>90){
			cout<<char(s[i]-26+a);
		}
		else{
			cout<<char(s[i]+a);
		}
	}
    return 0;
}

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

using namespace std;

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

    int ans = (K - A[N - 1]) + A[0];

    for (int i = 0; i < N - 1; i++) {
        ans = max(ans, A[i + 1] - A[i]);
    }

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

Measured memory_bytes: 1024
#include <stdio.h>

int main(){

  int d,i;
  int ans = 0;

  while(scanf("%d",&d) != EOF){
    ans = 0;
    for(i = 1; i <  (600/d); i++){
      ans += d * (d*i)*(d*i);
    }
    printf ("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <numeric>


const int kN = 100000 + 5;
int n, m;
std::vector<int> edges[kN];
int a[kN];
bool vis[kN];
std::vector<int> vec;

void dfs(int u, int fa)
{
    vis[u] = true;
    vec.emplace_back(a[u]);
    for (int v : edges[u]) if (v != fa)
        dfs(v, u);
}

bool work()
{
    int com = 0;
    long long result = 0;
    std::vector<int> v;
    for (int i = 0; i < n; ++ i) if (!vis[i]) {
        vec.clear();
        dfs(i, -1);
        std::sort(vec.begin(), vec.end());
        result += vec[0];
        v.insert(v.end(), vec.begin() + 1, vec.end());
        ++ com;
    }
    if (com == 1) {
        return puts("0"), true;
    }
    if (com - 2 > v.size()) return false;
    std::sort(v.begin(), v.end());
    result += std::accumulate(v.begin(), v.begin() + com - 2, 0LL);
    printf("%lld\n", result);
    return true;
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i)
        scanf("%d", a + i);
    for (int i = 0; i < m; ++ i) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].emplace_back(b);
        edges[b].emplace_back(a);
    }
    if (!work())
        puts("Impossible");
}


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

int n, t, a;

int main(void){
	cin >> n >> t >> a;
	int ans;
	int val = INT_MAX;
	rep(i, n){
		int h;
		cin >> h;
		if(abs(1000*t-6*h-1000*a) < val){
			val = abs(1000*t-6*h-1000*a);
			ans = i+1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3656
n=int(input())
march=[0,0,0,0,0]
for i in range(n):
    l=input()
    if l[0] in 'MARCH':
        index='MARCH'.find(l[0])
        march[index]+=1
result=0
result+=march[0]*march[1]*march[2]
result+=march[0]*march[1]*march[3]       
result+=march[0]*march[1]*march[4]
result+=march[0]*march[2]*march[3]
result+=march[0]*march[2]*march[4]
result+=march[0]*march[3]*march[4]
result+=march[1]*march[2]*march[3]
result+=march[1]*march[2]*march[4]
result+=march[1]*march[3]*march[4]
result+=march[2]*march[3]*march[4]
print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf=-1e9;
int main()
{
	ll t,l;
	cin>>l;
	float d,j;
	d=(float)l/3;
	cout<<fixed<<setprecision(12)<<(float)((float)d*d*d)<<endl;
	d=(float)d*(float)d*(float)d;
	//cout<<setprecision(12)<<d<<endl;
	
	
		
		
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
	int N,K;
	cin>>N>>K;
	string S;
	cin>>S;
	vi v;
	int cnt = 0;
	int now = 1;
	for(int i = 0; i < N; ++i){
		if(S[i] == char(now + '0')){
			cnt++;
		}
		else{
			v.push_back(cnt);
			now = 1 - now;
			cnt = 1;
		}
	}
	if(cnt!=0){
		v.push_back(cnt);
	}
	if(v.size()%2 == 1){
		v.push_back(0);
	}
	//累積和
	vi cum((int)v.size()+1);
	for(int i = 0; i < (int)v.size(); ++i){
		cum[i+1] = v[i]+cum[i];
	}
	print(v);
	print(cum);
	int tmp = 0;
	int ans = 0;
	for(int i = 0; i < v.size(); i+=2){
		int left = i;
		int right = min(i + 2*K+1, (int)v.size());
		tmp = cum[right]-cum[left];
		ans = max(tmp, ans);
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 998244353;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
 
  lint n, s; cin >> n >> s;
  vector<lint> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<vector<lint>> dp(n + 1, vector<lint>(s + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= s; j++) {
      if (dp[i][j] == 0) continue;
      // 選ばない
      dp[i + 1][j] += dp[i][j] * 2;
      dp[i + 1][j] %= MOD;

      // 選ぶ
      int nj = j + a[i];
      if (nj <= s) {
        dp[i + 1][nj] += dp[i][j];
        dp[i + 1][nj] %= MOD;
      }
    }
  }

  cout << dp[n][s] << endl;
  return 0;
}


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

using namespace std;
long long rec(long long n){
    if(n==1) return 1LL;
    return 2 * rec(n>>1) + 1LL;

}
int main(){
    long long n;
    scanf("%lld",&n);
    printf("%lld",rec(n));


}


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

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    int ans = 0;
    int min = 1;
    int max = INF;
    rep(i, m) cin >> l[i] >> r[i];

    for (int i = 0; i < m; i++) {
        if (min <= l[i])
            min = l[i];
        if (max >= r[i])
            max = r[i];
    }

    if (max < min) {
        cout << 0 << endl;
        return 0;
    }
    
    cout << max - min + 1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
 
int main(){
    long int N,M;
    long int ans;
    cin >> N >> M;
    if(N >= 2 && M >= 2) ans = (N-2)*(M-2);
    if(N == 1 && M == 1) ans = 1;
    if(N == 1 && M >= 2) ans = M - 2;
    if(N >= 2 && M == 1) ans = N - 2;
    cout << ans << endl;
}

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

int main() {

	int n; cin >> n;
	vector<pair<string, int>> pa;
	vector<int> point(n);
	for (int i = 0; i < n; i++) {
		string s;
		int p;
		cin >> s >> p;
		pa.push_back({ s,-p });
		point[i] = -p;
	}
	sort(pa.begin(), pa.end());
	for (int i = 0; i < n; i++) {
		int ans;
		ans = find(point.begin(), point.end(), pa[i].second) - point.begin() + 1;
		cout << ans << endl;
	}	
	return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  
  int count = 1;
  int position = 0;
  for (int i = 0; i < N; i++) {
    int L;
    cin >> L;
    
    position += L;
    if (position <= X) count++;
    else break;
  }
  
  cout << count << endl;
}

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

int main(){
	string type;
	int t[4]={0};
	while(cin>>type){
		type+=" ";
		int i;
		for(i=0;type[i]!=',';i++);
		i++;
		if(type[i]=='A'&&type[i+1]=='B'){
			t[2]++;
		}else if(type[i]=='A'){
			t[0]++;
		}else if(type[i]=='B'){
			t[1]++;
		}else if(type[i]=='O'){
			t[3]++;
		}
	}
	for(int i=0;i<4;i++){
		cout<<t[i]<<endl;
	}
}

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

int main(){
  ll n,t;
  std::cin >> n>>t;

  std::vector<ll> v(n+1,0);
  std::cin >> v[0];

  ll ans=0;;
  for (ll i =1; i < n; i++) {
    std::cin >> v[i];
    ans+=min(t,v[i]-v[i-1]);
  }
  std::cout << ans+t << '\n';

return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int ans=max(a,max(b,c))-min(a,min(b,c));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int H[] = CPUtils.readIntArray(N, in);
            Map<Integer, Integer> memo = new HashMap<>();
            out.print(solve(0, H, memo));
        }

        static int solve(int position, int cost[], Map<Integer, Integer> memo)
        {
            if (position + 1 >= cost.length) return 0;

            if (memo.containsKey(position))
            {
                return memo.get(position);
            }
            int r = Math.abs(cost[position] - cost[position + 1]) + solve(position + 1, cost, memo);
            if (position + 2 < cost.length)
            {
                r = Math.min(r, Math.abs(cost[position] - cost[position + 2]) + solve(position + 2, cost, memo));
            }
            memo.put(position, r);
            return r;
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



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

using namespace std;

int main() {
	int n;

	cin >> n;

	vector <set<int>> honest(n, set<int>()), unkind(n, set<int>());

	// honest.assign(n, vector<int>());
	// unkind.assign(n, vector<int>());

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;

		for (int j = 0; j < a; j++) {
			int x, y;
			cin >> x >> y;
			x--;

			if (y) {
				honest[i].insert(x);
			} else {
				unkind[i].insert(x);
			}
		}
	}

	int ans = 0;

	for (int mask = 0; mask < (1 << n); mask++) {
		bool can = true;
		
		// configuration according to mask
		vector <int> h(n, 0);
		vector <int> u(n, 0);

		for (int i = 0; i < n; i++) {
			if (mask & (1 << i)) {
				h[i] = 1;
			} else {
				u[i] = 1;
			}
		}

		// compare mask vs testimonies
		for (int i = 0; i < n; i++) {
			if (u[i]) {    // mask[i] is unkind; ignore this
				continue;
			}

			for (int x: honest[i]) {
				if (u[x]) {		// i says x is honest but x is unkind in testimony
					can = false;
				}
			}

			for (int x: unkind[i]) {
				if (h[x]) {		// i says x is unkind but x is honest in testimony
					can = false;
				}
			}
		}

		if (can) {
			ans = max(ans, __builtin_popcount(mask));
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3616
//---Vaidik Patel"---//-------------------Proud to be Indian--------------------------------//
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set,multi multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define pii pair<int,int>
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order()
#define deb1(x) cout<<#x<<" : "<<x<<"\n";
#define deb2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<"\n";
#define deb4(x,y,z,w) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<"\t"<<#w<<" : "<<w<<endl;
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rFOR(i,a,b) for(int i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vector<int>>
#define M 1000000007
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int powermodm(int x,int n,int m)
{int ans=1;   while(n){if(n&1){ans=(ans*x)%m;}x=(x*x)%m;n=n>>1;}return ans;}
void solve()
{
    int l,r,d;
    cin>>l>>r>>d;
    int c1=(l-1)/d;
    int c2=r/d;
    cout<<c2-c1<<"\n";

}
signed main()
{
    #ifndef ONLINE_JUDGE
   
    #endif
    FIO
    int t;
    t=1;
    //cin>>t;
    FOR(i,0,t)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

#define ABS(a) ((a)>(0)?(a):-(a))

#define SIZE (10*10*10*10*10)

int64 M[SIZE+1];
int64 B[SIZE+1];

void kill_monster (int64 *M, int64 *B, int64 *total)
{
  if (*M >= *B) {
    *total += *B;
    *M -= *B;
    *B = 0;
  } else {
    *total += *M;
    *B -= *M;
    *M = 0;
  }
  return;
}

// 4 4 4 4
// 6 6 2

int main()
{
  int cnt;
  int64 N;
  int i;
  int64 total = 0;

  get_N(&N);

  for (i=0; i<(N+1); i++) {
    cnt = scanf("%lld", &(M[i]));
  }
  for (i=0; i<N; i++) {
    cnt = scanf("%lld", &(B[i]));
  }

  for(i=0; i<N; i++) {
    kill_monster(&M[i], &B[i], &total);
    if (B[i] > 0) {
      kill_monster(&M[i+1], &B[i], &total);
    }
  }

  printf("%lld", total);

  return 0;
}



Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <cctype>
#define rgi register int
#define il inline
#define ll long long
#define maxn 60

using namespace std;

int n;
int a[maxn];

il int read()
{
	rgi x = 0, f = 0, ch;
	while(!isdigit(ch = getchar())) f |= ch == '-';
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

bool check()
{
	for(rgi i = 1; i <= n - 1; ++i)
		if(a[i] >= a[i + 1])
			return 0;
	return 1;
}

int main()
{
	n = read();
	for(rgi i = 1; i <= n; ++i)
		a[i] = read();
	if(check())
	{
		puts("YES");
		return 0;
	}
	for(rgi i = 1; i <= n; ++i)
	{
		for(rgi j = i + 1; j <= n; ++j)
		{
			swap(a[i], a[j]);
			if(check())
			{
				puts("YES");
				return 0;
			}
			swap(a[i], a[j]);
		}
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a[100005],b[100005],c[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=1;i<n;i++)scanf("%d",&c[i]);
	int ans=0;
	for(int i=1;i<=n;i++)ans+=b[i];
	for(int i=2;i<=n;i++)
	  if(a[i]==a[i-1]+1)
	    ans+=c[a[i-1]];
	printf("%d\n",ans);
	return 0;
}

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

ll GCD (ll a, ll b) { return b == 0 ? a : GCD(b, a % b); }
vector<pair<ll,ll>> prime(ll a) {
    vector<pair<ll,ll>> res;
    for (ll i = 2; i * i <= a; i++) {
        if (a % i != 0) continue;
        ll num = 0ll;
        while (a % i == 0) {
            num++;
            a /= i;
        }
        res.push_back(make_pair(i, num));
    }
    if (a > 1) res.push_back(make_pair(a, 1));
    return res;
}

int main() {
    ll a, b; cin >> a >> b;
    ll g = GCD(a, b);
    auto ans = prime(g);
    cout << (int)ans.size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int n, cnt = 0;
	vector<int>list;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	if (n == 2) {
		if (list[0] == list[1]) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		bool flag = false;

		for (int i = 1; i < n ; i++) {
			if (list[i - 1] == list[i] && flag == false) {
				cnt++;
				//i++;
				flag = true;
			}
			else if (list[i - 1] == list[i]) {
				flag = false;
			}
			else {
				flag = false;
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef long double ld;
ld a[1005];
ld sum;

int main(){
	int n;cin>>n;
	for(int i=1;i<=n;++i)
	scanf("%Lf",&a[i]),sum+=(1.0/a[i]);
	printf("%.12Lf\n",1.0/sum);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define enter putchar('\n')
#define space putchar(' ')
#define fi first
#define se second
//#define ivorysi
#define pii pair<int,int>
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}

template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;
char s[100005];
int nxt[100005][3],sum[100005],dp[100005];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    scanf("%s",s + 1);
    N = strlen(s + 1);
    bool flag = 0;
    for(int i = 2 ; i <= N ; ++i) {
        if(s[i] == s[i - 1]) {flag = 1;break;}
    }
    if(!flag) {puts("1");return;}
    for(int i = 1 ; i <= N ; ++i) {
        sum[i] = (sum[i - 1] + (s[i] - '0')) % 3;
    }
    for(int i = 0 ; i < 3 ; ++i) nxt[N + 1][i] = N + 1;
    for(int i = N ; i >= 1 ; --i) {
        for(int j = 0 ; j < 3 ; ++j) nxt[i][j] = nxt[i + 1][j];
        nxt[i][sum[i]] = i;
    }
    dp[0] = 1;
    for(int i = 0 ; i <= N ; ++i) {
        for(int j = 1 ; j <= 2 ; ++j) {
            update(dp[nxt[i + 1][(sum[i] + j) % 3]],dp[i]);
        }
    }
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(sum[i] == sum[N]) update(ans,dp[i]);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a==b && b==c) {
    cout << "No" << endl;
    return 0;
  }
  if (a == b || a == c || b == c) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256