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

#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr long long INFLL = 1e18;

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  const int mPN = 998244353;
  ll n, k;
  cin >> n >> k;
  vector<ll> l(k);
  vector<ll> r(k);

  for (int i = 0; i < k; i++) {
    cin >> l.at(i) >> r.at(i);
  }

  vector<ll> alSum(n + 1, 0);
  vector<ll> dp(n + 1, 0);

  dp.at(1) = 1;
  alSum.at(1) = 1;

  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < k; j++) {
      ll tempL, tempR;
      tempL = i - l.at(j);
      tempR = i - r.at(j);
      if (tempR >= 1) {
        if (tempR == tempL) {
          dp.at(i) += dp.at(tempL);
        } else {
          dp.at(i) += alSum.at(tempL) - alSum.at(tempR - 1);
        }
      } else if (tempL >= 0) {
        dp.at(i) += alSum.at(tempL) - alSum.at(0);
      }
      dp.at(i) %= mPN;
    }
    alSum.at(i) = alSum.at(i - 1) + dp.at(i);
    alSum.at(i) %= mPN;
  }
  if (dp.at(n) < 0) {
    dp.at(n) += mPN;
  }
  cout << dp.at(n) << endl;
  return 0;
}

Measured memory_bytes: 5920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string K= "Three";
  for(int i=0 ; i < N ; i++){
    string S;
    cin >> S;
    if (S == "Y"){
      K="Four";
      break;
    }
    else K="Three";
  }
  cout << K << endl;
}
  


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

#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define rep(x, l, r) for (x = l; x < r; x++)

const ll mod=1000000007;


void solve()
{
	ll i, j, k, l, m, n, x, y, u, v, r, p,a,b;
    cin>>n;
    ll ans=0;
    for(i=1;i<=n;i++){
        m=(n/i);
        ans+= i*((m*(m+1))/2);
    }
    cout<<ans;

}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
//    cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


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

int main(){
int x,y;
cin>>x>>y;

int a[1000][1000]={};
for(int i=1;i<=x;i++){
for(int g=1;g<=y;g++){
cin>>a[i][g];
}}

for(int i=1;i<=x;i++){
for(int g=1;g<=y;g++){
a[i][y+1]+=a[i][g];
}}
for(int i=1;i<=x;i++){
for(int g=1;g<=y;g++){
a[x+1][g]+=a[i][g];
}}
for(int g=1;g<=y;g++){
a[x+1][y+1]+=a[x+1][g];
}

for(int i=1;i<=x+1;i++){
for(int g=1;g<=y+1;g++){
cout<<a[i][g];
if(g<=y){cout<<" ";}
}
cout<<endl;
}


return 0;
}


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

int main() {
  int A,B;
  int ans = 0;

  cin >> A >> B;

  //AとBが9以下の時計算する
  if (A < 10 && B < 10) {
    ans = A * B;
  }
  else {
    ans = -1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll ans = 0;
	ll base = 1;
	for (int i = 0; i < 60; i++) {
		ll x = 0, y = 0;
		for (int j = 0; j < n; j++) {
			if (a[j] & (1LL << i)) {
				x++;
			}
			else y++;
		}
		x = x * y%mod;
		x = x * base%mod;
		ans += x;
		ans %= mod;
		base *= 2;
		base %= mod;
	}
	cout << ans << endl;
}

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

int main() {
    int n,k,cnt=1000000000-1;
    cin>>n>>k;

    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }
    sort(h.begin(),h.end());

    for(int i=0;i<=n-k;i++){
        cnt=min(h.at(i+k-1)-h.at(i),cnt);
    }

    cout<<cnt<<endl;

}


Measured memory_bytes: 640
# standard input
S = input()
Q = int(input())
Query = []
num_reverse = 0

L = ''
R = ''

rev = False

for _ in range(Q):

    q = tuple(map(str, input().split()))

    if q[0] == '1':
        rev = (not rev)

    else:
        if (rev and q[1] == '1') or (not rev and q[1] == '2'):
            R = R + q[2]
        else:
            L = q[2] + L 

if rev:
    print( R[::-1] + S[::-1] + L[::-1])
else:
    print( L + S + R )


Measured memory_bytes: 4616
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace Project
{
    class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.ReadLine;
            var T = cin.ReadLine;
            var ans = 0;

            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != T[i])
                {
                    ans += 1;
                }
            }

            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } } // intの範囲は-2147483648～2147483648
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N)
        { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N)
        { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N)
        { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }

    }
}


Measured memory_bytes: 27728
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(v) (v.begin(), v.end())
#define ff(i, x, n, k) for(int i=x;i<n;i+=k)
#define rf(i, x, n, k) for(int i=n-1;i>=x;i+=k)
#define ef(i, x, n, k) for(int i=x;i<=n;i+=k)
#define pb push_back
#define eb emplace_back
#define pp pop_back
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define input(n) scanf("%lld", &n)
#define output(n) printf("%lld", n);

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int MOD = 1e9+7;
const ll INF = pow(10, 18)+5;

int main()
{
  fast_cin();
  vector<int> vct;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      vct.pb(i*j);
    }
  }
  int n;
  cin>>n;
  for(int i=0;i<vct.size();i++){
    if(vct[i] == n){
      cout<<"Yes"<<"\n";
      exit(0);
    }
  }
  cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

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

    int X, N;
    unordered_set<int> s;
    cin >> X >> N;
    while(N > 0){
        int num;
        cin >> num;
        s.insert(num);
        N--;
    }

    int diff = 1;

    
    int X_is = s.count(X);
    if(!X_is) {
        cout << X;
        return 0;
    }
    while(true){
        if(!s.count(X-diff)){
            cout << X-diff;
            return 0;
        }
        if(!s.count(X+diff)){
            cout << X+diff;
            return 0;
        }
        diff++;
    }
    
}

Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  //INPUT
  llint N;
  string S;
  cin >> N;
  cin >> S;

  //SOLVE
  char ans[20000];
  llint len;

  len = S.length();

  char buf;
  for(int i=0;i<len;i++) {
    buf = (char)((int)(S[i])+N);
    while(buf>'Z') {
      buf = (char)((int)(buf)-26);
    }
    ans[i] = buf;
  }

  //OUTPUT
  for(int i = 0; i<len; i++) {
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import collections
x,n=map(int,input().split())
if n!=0:
    l=list(map(int,input().split()))
    v=collections.Counter(l)
if n==0:
    print(x)
else:
    for i in  range(101):
        if x not in v:
            ans=x
            break
            
        if x-i not in v:
            ans=x-i
            break
        if x+i not in v:
            ans=x+i
            break
    print(ans)
        

        

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

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

Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_11_C_BreadthFirstSearch
{
	class Program
	{
		static void Main ( string[] args )
		{
			int vertexCount = int.Parse (Console.ReadLine ());
			Graph graph = new Graph (vertexCount);

			for (int lp = 0; lp < vertexCount; lp++)
			{
				int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

				for (int lp2 = 0; lp2 < inputNum[1]; lp2++)
				{
					graph.GetPath (inputNum[0], inputNum[lp2 + 2]);
				}
			}

			int[] result = graph.BreadthFirstSeach (1);
			StringBuilder output = new StringBuilder (result.Length * 2);

			for (int lp = 0; lp < result.Length; lp++)
			{
				output.Append (lp + 1);
				output.Append (" ");
				output.Append (result[lp]);
				output.AppendLine ();
			}

			Console.Write (output);
		}
	}

	class Graph
	{
		public Graph ( int size )
		{
			this.Size = size;
			this.Path = new bool[this.Size][];

			for (int lp = 0; lp < this.Path.Length; lp++)
			{
				this.Path[lp] = new bool[this.Size];	
			}
		}

		private bool[][] Path { set; get; }
		private int Size { set; get; }
		private const bool Exist = true;

		private enum State
		{
			NotVisited, Stay, Visited
		};

		public void GetPath ( int beginPoint, int adjacencyPoint )
		{
			Path[beginPoint - 1][adjacencyPoint - 1] = Exist;
		}

		public int[] BreadthFirstSeach ( int beginSearchPoint )
		{
			beginSearchPoint -= 1;

			//initialize
			Queue<int> searchQueue = new Queue<int> (Size);

			State[] visitState = Enumerable.Repeat (State.NotVisited, Size).ToArray ();

			const int CannotVisit = -1;
			int[] distance = Enumerable.Repeat (CannotVisit, Size).ToArray ();

			//process
			searchQueue.Enqueue (beginSearchPoint);
			distance[beginSearchPoint] = 0;

			while (searchQueue.Count != 0)
			{
				int item = searchQueue.Dequeue ();

				visitState[item] = State.Visited;

				for (int lp = 0; lp < Size; lp++)
				{
					//??£??\????????????
					if (Path[item][lp] == Exist)
					{
						//????¨??????????
						if (visitState[lp] == State.NotVisited)
						{
							//????´¢????±??????\??????
							searchQueue.Enqueue (lp);
							visitState[lp] = State.Stay;
							distance[lp] = distance[item] + 1;
						}
					}
				}
			}

			return distance;
		}
	}
}

Measured memory_bytes: 10556
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *h = map(int, read().split())
h = h[::-1]
for i, (bf, af) in enumerate(zip(h, h[1:])):
    if bf + 1 < af:
        print('No')
        exit()
    if bf < af:
        h[i + 1] -= 1
print('Yes')


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  ll vmin = LLONG_MAX;
  for (ll i = 0; i < 5; i++) {
    ll x; cin >> x;
    vmin = min(vmin, x);
  }
  cout << 4 + (N + vmin - 1) / vmin << endl;

  return 0;
}



Measured memory_bytes: 3652
N, K = map(int, input().split())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
    k = 0
    for j in range(i):
        if A[i]>A[j]:
            k += 1
    cnt += (K-1)*(k + k*(K-1))//2

    l = 0
    for j in range(i+1, N):
        if A[i]>A[j]:
            l += 1
    cnt += K*(l + l*K)//2

print(cnt % (10**9 + 7))


Measured memory_bytes: 3188
#include<stdio.h>

struct dice
{
    int n[6] ; //number
};
struct dice dice1 ;


int east()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[3] ;
    dice1.n[3] = dice1.n[5] ;
    dice1.n[5] = dice1.n[2] ;
    dice1.n[2] = mem ;
}

int west()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[2] ;
    dice1.n[2] = dice1.n[5] ;
    dice1.n[5] = dice1.n[3] ;
    dice1.n[3] = mem ;
}

int south()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[4] ;
    dice1.n[4] = dice1.n[5] ;
    dice1.n[5] = dice1.n[1] ;
    dice1.n[1] = mem ;
}

int north()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[1] ;
    dice1.n[1] = dice1.n[5] ;
    dice1.n[5] = dice1.n[4] ;
    dice1.n[4] = mem ;
}

int main()
{
    int i=0 ;
    int cmp=0 ;

    char a[101] = {0} ;

    for (i=0 ;i < 6 ;i++)
    {
        scanf("%d" ,&cmp) ;

        dice1.n[i] = cmp ;

    }
    scanf("%s" ,a) ;

    for (i=0 ;i < 101 ;i++)
    {
        if (a[i] == '\0') break ;

        if (a[i] == 'E') east() ;
        if (a[i] == 'W') west() ;
        if (a[i] == 'S') south() ;
        if (a[i] == 'N') north() ;

    }

    printf ("%d\n" ,dice1.n[0]) ;
    return 0 ;
}

Measured memory_bytes: 596
N, L = gets.split.map(&:to_i)
a = N.times.map do |i|
  L + (i + 1) - 1
end
ans = 0

if L >= 0
  ans = a[1..-1].inject(&:+)
elsif L < 0 && N.abs > L.abs
  ans = a.inject(&:+)
else
  ans = a[0..-2].inject(&:+)
end

puts ans


Measured memory_bytes: 1788
import numpy as np
N,M = map(int,input().split())
L = np.array([list(map(int,input().split())) for _ in range(N)])
l = [[1,1,1],[1,1,-1],[1,-1,1],[-1,1,1],[1,-1,-1],[-1,-1,1],[-1,1,-1],[-1,-1,-1]]
ans = 0
for i in range(8):
    su = L[:,0]*l[i][0]+L[:,1]*l[i][1]+L[:,2]*l[i][2]
    s = np.sort(su)[::-1]
    ans = max(ans,np.sum(s[:M]))
print(ans)

Measured memory_bytes: 12512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(void){
  int N, M;
  cin >> N >> M;
  vector<pair<long,long> > pairs(N);
  for(int i = 0; i < N; i++){
    long a, b;
    cin >> a >> b;
    pairs[i] = make_pair(a, b);
  }
  sort(pairs.begin(), pairs.end());
  long ans = 0;
  int i = 0;
  while(M > 0){
    if(pairs[i].second > M){
      ans += pairs[i].first * M;
      M -= M;
    }else{
      ans += pairs[i].first * pairs[i].second;
      M -= pairs[i].second;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------



main :: IO ()
main = do
	n <- readLn
	ps <- map read . words <$> getLine
	qs <- map read . words <$> getLine
	let perms = List.sort $ List.permutations [1..n]
	let np = Maybe.fromJust $ List.findIndex (== ps)  perms
	let qp = Maybe.fromJust $ List.findIndex (== qs)  perms
	print $ abs (np - qp)


Measured memory_bytes: 21116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

struct edge{
    int to, cap, rev;
};

const int MAX_V = 5010;
const int INF = 1000000000;

// 入力
int N, R;
vector<edge> G[MAX_V];  // グラフの隣接リスト表現
bool used[MAX_V];       // DFSですでに調べたかのフラグ

// fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, int(G[from].size())-1});
}

// 増加パスをDFSで探す
int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < int(G[v].size()); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流を求める
// O(FE) 小さい定数倍
int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}


int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    vll c(n), d(n);
    rep(i, n){
        cin >> c[i] >> d[i];
    }
    
    // 二部マッチング
    rep(i, n)rep(j, n){
        if(a[i] < c[j] && b[i] < d[j]){
            add_edge(i, 5*n+j, 1);
        }
    }
    rep(i, n){
        add_edge(122, i, 1);
    }
    rep(i, n){
        add_edge(5*n+i, 800, 1);
    }
    rep(i, MAX_V){
        for(auto&& e: G[i]){
            //cout << e.to << " " << e.cap << " " << e.rev << endl;
        }
    }
    cout << max_flow(122, 800) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

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

	queue<int> segments;
	int val     = 0;
	int max_val = 0;

	bool prev_zero = false;
	segments.push(1);
	val++;
	prev_zero = (s[0] == '0');

	int evaluate = 0;
	FOR_LT(i, 1, s.size()) {
		if (prev_zero && s[i] == '1') {
			if (segments.size() == k) {
				evaluate = val;
				val -= segments.front();
				segments.pop();
			}
			segments.push(0);
		}
		if (s[i] == '1') {
			if (evaluate != 0) evaluate++;
		}
		if (s[i] == '0') {
			if (evaluate != 0) {
				max_val = max(max_val, evaluate);
			}
			evaluate = 0;
		}

		segments.back()++;
		val++;
		prev_zero = (s[i] == '0');
	}

	if (evaluate != 0) {
		max_val = max(max_val, evaluate);
	}
	else {
		max_val = max(max_val, val);
	}

	cout << max_val << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};




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

    int H,W;
    cin>>H>>W;
    string S[H];
    rep(i,H){
        cin>>S[i];
    }
    int ans=-1;
    rep(i,H){
        rep(j,W){
            if(S[i][j]=='#') continue;
            vector<vector<int>> dist(H,vector<int>(W,-1));
            queue<pair<int,int>> que;
            dist[i][j]=0;
            que.push(make_pair(i,j));

            while(!que.empty()){
                pair<int,int> nv=que.front();
                que.pop();
                int x=nv.first;
                int y=nv.second;
                rep(k,4){
                    int nx=x+dx[k];
                    int ny=y+dy[k];
                    if(nx<0 || ny<0 || nx>=H || ny>=W) continue;
                    if(S[nx][ny]=='#') continue;
                    if(dist[nx][ny]==-1){
                        que.push(make_pair(nx,ny));
                        dist[nx][ny]=dist[x][y]+1;
                    }
                }

            }
            rep(k,H){
                rep(l,W){
                    ans=max(ans,dist[k][l]);
                }
            }

        }
    }
    cout << ans << endl;

    




}


Measured memory_bytes: 256
program main
Implicit None
	integer(8)::n,i,m,p=1
	integer(8),allocatable::h(:)
	
	read*,n
	
	allocate(h(n))
	read*,h
	
	m =h(1)
	do i = 2,n
		if(m <= h(i))then
			p = p+1
			m = h(i)
		endif
	enddo
	
	print"(i0)",p
end program main

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

int main() {
  string s, p, ans = "No";
  cin >> s >> p;
  s += s;
  for(int i = 0; i < s.size() / 2; i++) {
    if(s[i] == p[0]) {
      int j = 1;
      if(p.size() == 1) {
        ans = "Yes";
        goto OUT;
      }
      while(s[i + j] == p[0 + j]) {
        if(j == p.size() - 1) {
          ans = "Yes";
          goto OUT;
        }
        j++;
      }
    }
  }
  OUT:
  cout << ans << "\n";
}


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

#define pb push_back
#define SZ(x) ((int)x.size())

const int N = 2010 ;

int vis[N], ok[N][N], in[N], a[N] ;
vector <int> g[N] ;
int n ;

void dfs(int rt) {
    vis[rt] = 1 ;
    for (int i = 1; i <= n; i++)
    if (!vis[i] && ok[rt][i]) {
        in[i]++ ;
        g[rt].pb(i) ;
        dfs(i) ;
    }
}

void Top() {
    priority_queue <int> q ;
    for (int i = 1;  i <= n; i++) if (!in[i]) q.push(i) ;
    while (!q.empty()) {
        int now = q.top() ;
        q.pop() ;
        cout << a[now] << " " ;
        for (int i = 0; i < SZ(g[now]); i++) q.push(g[now][i]) ;
    }
}

signed main(){
    scanf("%d", &n) ;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]) ;
    sort(a + 1, a + n + 1) ;
    for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
    if (__gcd(a[i], a[j]) != 1) ok[i][j] = ok[j][i] = 1 ;
    for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i) ;//遍历连通块
    Top() ;
}

Measured memory_bytes: 16256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,x,a;
    vector<int> a_1,b_1;
    cin >> n >> m >> x;
    for(int i=0;i<m;i++){
        cin >> a;
        if(a<x){
            b_1.push_back(a);
        }
        else a_1.push_back(a);
    }
    cout << min(a_1.size(),b_1.size()) << endl;
    return 0;
}

Measured memory_bytes: 256
ss = str(input())
s = list(ss)

if s[0] == "A" and s.count("A") == 1:
    checklist = []
    for i in range(2,len(s)-1):
        checklist.append(s[i])
        
    if checklist.count("C") == 1:
        s.remove("A")
        s.remove("C")
        p = ""
        for i in s:
            p = p + i
        if p.islower():
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3064
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

cnt = 0

if H >= 2 and W >= 3:
	if s[0][0] == "#" and s[0][1] == "." and s[1][0] == ".":
		cnt += 1

	for w in range(1, W - 1):
		if s[0][w] == "#" and s[0][w - 1] == "." and s[0][w + 1] == "." and s[1][w] == ".":
			cnt += 1

	if s[0][W - 1] == "#" and s[0][W - 2] == "." and s[1][W - 1] == ".":
		cnt += 1 

	if H >= 3:
		for h in range(1, H - 1):
			if s[h][0] == "#" and s[h][1] == "." and s[h + 1][0] == "." and s[h - 1][0] == ".":
				cnt += 1

			for w in range(1, W - 1):
				if s[h][w] == "#" and s[h][w - 1] == "." and s[h][w + 1] == "." and s[h + 1][w] == "." and s[h - 1][w] == ".":
					cnt += 1

			if s[h][W - 1] == "#" and s[h][W - 2] == "." and s[h + 1][W - 1] == "." and s[h - 1][W - 1] == ".":
				cnt += 1 

	if s[H - 1][0] == "#" and s[H - 1][1] == "." and s[H - 2][0] == ".":
		cnt += 1

	for w in range(1, W - 1):
		if s[H - 1][w] == "#" and s[H - 1][w - 1] == "." and s[H - 1][w + 1] == "." and s[H - 2][w] == ".":
			cnt += 1

	if s[H - 1][W - 1] == "#" and s[H - 1][W - 2] == "." and s[H - 2][W - 1] == ".":
		cnt += 1

elif H == 1:
	if s[0][0] == "#" and s[0][1] == ".":
		cnt += 1

	for w in range(1, W - 1):
		if s[0][w] == "#" and s[0][w - 1] == "." and s[0][w + 1] == ".":
			cnt += 1

	if s[0][W - 1] == "#" and s[0][W - 2] == ".":
		cnt += 1

elif W == 1:
	if s[0][0] == "#" and s[1][0] == ".":
		cnt += 1

	for h in range(1, H - 1):
		if s[h][0] == "#" and s[h - 1][0] == "." and s[h - 1][0] == ".":
			cnt += 1

	if s[H - 1][0] == "#" and s[H - 2][0] == ".":
		cnt += 1

else: #W==2
	if s[0][0] == "#" and s[0][1] == "." and s[1][0] == ".":
		cnt += 1

	if s[0][1] == "#" and s[0][0] == "." and s[1][1] == ".":
		cnt += 1

	if H >= 3:
		for h in range(1, H - 1):
			if s[h][0] == "#" and s[h][1] == "." and s[h + 1][0] == "." and s[h - 1][0] == ".":
				cnt += 1

			if s[h][1] == "#" and s[h][0] == "." and s[h + 1][1] == "." and s[h - 1][1] == ".":
				cnt += 1 

	if s[1][0] == "#" and s[1][1] == "." and s[0][0] == ".":
		cnt += 1

	if s[1][1] == "#" and s[1][0] == "." and s[0][1] == ".":
		cnt += 1


if cnt == 0:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3320
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int A, B;
	scanf("%d%d", &A, &B);
	if (A + B >= 10) {
		printf("error\n");
	} else {
		printf("%d", A + B);
	}
	return 0;
}


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

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define pb push_back
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dq;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


// standard functions
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 


ll modexp(ll x, ll ex, ll modp) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x)%modp;
        ex >>= 1ll;
        x = (x * x)%modp;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

// code beigns in main
int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        string str;
        cin >> str;
        
        if(str[2]==str[3] && str[4]==str[5] && str.length()==6)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void) {

	int a, b, c;
	int sum1, sum2, sum3;
	int min;

	scanf("%d%d%d", &a, &b, &c);

	sum1 = a + b;
	sum2 = b + c;
	sum3 = c + a;

	if (sum1 <= sum2 && sum1 <= sum3) {
		min = sum1;
	}
	else if (sum2 <= sum1 && sum2 <= sum3) {
		min = sum2;
	}
	else {
		min = sum3;
	}

	printf("%d", min);


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define refor(x, v) for(auto& x: v)
#define all(x) x.begin(),x.end()

vector<pair<int,int>> calc(const std::vector<i64> A) {
  vector<i64> cnt(101010,0);
  refor(x, A) {
    cnt[x]++;
  }
  int i = max_element(all(cnt)) - begin(cnt);
  int mi = cnt[i];
  cnt[i] = 0;
  int j = max_element(all(cnt)) - begin(cnt);
  int mj = cnt[j];
  return { { mi, i }, { mj, j } };
}

int main() {
  std::size_t n;
  cin >> n;
  std::vector<i64> v(n);
  refor(x, v) cin >> x;
  std::vector<i64> a[2];
  for(int i = 0;i < n;i++) {
    a[i & 1].push_back(v[i]);
  }

  auto A = calc(a[0]);
  auto B = calc(a[1]);
  if(A[0].second != B[0].second) {
    cout << n - A[0].first - B[0].first << endl;
  }
  else {
    cout << n - max(A[0].first + B[1].first, A[1].first + B[0].first) << endl;
  }
}


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

int n;
char now;
char a[100005];
int ans=1;

int main(){
	cin>>n;
	cin>>a;
	now=a[0];
	for(int i=0;i<n;i++)
		if(a[i]!=now){
			ans++;
			now=a[i];
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    cout << min(b-1, n) * a / b << '\n';
    return 0;
}

Measured memory_bytes: 3604
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  cin>>n;
  vector<pair<ll,ll> >v(0,pair<ll,ll>());
  pair<ll,ll> p;
  ll maxl=0;
  ll minr=1e10;
  for(ll i=0;i<n;i++){
    cin>>p.first>>p.second;
    v.push_back(p);
    maxl=max(maxl,p.first);
    minr=min(minr,p.second);
  }
  sort(v.begin(),v.end());
  vector<ll>v2(n,0);
  v2[n-1]=v[n-1].second;
  for(ll i=n-2;i>=0;i--){
    v2[i]=min(v2[i+1],v[i].second);
  }
  ll rr=1e10;
  for(ll i=0;i<n;i++){
    if(v[i].first==maxl){
      rr=min(rr,v[i].second);
    }
  }
  ll lll=0;
  for(ll i=0;i<n;i++){
    if(v[i].second==minr){
      lll=max(lll,v[i].first);
    }
  }
  if(rr==minr){
    ll t=max((ll)0,minr-maxl+1);
    for(ll i=0;i<n;i++){
      if(!(v[i].first==maxl&&v[i].second==minr)){
        t=max(t,v[i].second-v[i].first+1);
      }
    }
    ans=t+max((ll)0,minr-maxl+1);
  }
  else{
    ll t=max((ll)0,minr-maxl+1);
    for(ll i=0;i<n;i++){
      t=max(t,v[i].second-v[i].first+1);
    }
    ans=t+max((ll)0,minr-maxl+1);

    ll i;
    for(i=0;i<n;i++){
      if(v[i].first==lll&&v[i].second==minr)break;
    }
    for(;i<n-1;i++){
      ll tmp=max((ll)0,minr-v[i].first+1);
      tmp+=max((ll)0,v2[i+1]-maxl+1);
      ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2544
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	int n;
	while(cin >> n, n) {
    vector< vector<int> > f(n);
    REP(i, f.size()) {
			int m; cin >> m;
      f[i] = vector<int>(m);
			REP(j, m) cin >> f[i][j];
		}
		int k; cin >> k;
    vector<int> l(k);
		int cnt, ans = 0;
		REP(i, k) cin >> l[i];
		REP(i, n) {
			cnt = 0;
      REP(j, f[i].size()) {
				REP(idx, l.size()) if(f[i][j] == l[idx]) cnt++; 
				if(cnt == k) {
					if(!ans) ans = i + 1;
					else ans = -1;
					break;
				}
			}
		}
		if(ans == 0) ans = -1;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

ll modfact(ll x){
  if(x==1) return 1;
  else return (x*modfact(x-1))%mod;
}

int main(){
  ll N,M;
  cin>>N>>M;
  
  if(abs(N-M)>1){
    cout<<0<<endl;
    return 0;
  }
  int ans=1;

  if(N==M){
    //N!*M!*2
    ans=(modfact(N)*modfact(M)*2)%mod;
  }else{
    ans=(modfact(N)*modfact(M))%mod;
  }

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




Measured memory_bytes: 1792
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2+2], R[MAX / 2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
    int i, j, k;
    int n1 = mid-left;
    int n2 = right-mid;
    for(i=0; i<n1; i++) L[i] = A[left + i];
    for(i=0; i<n2; i++) R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for(k = left; k<right; k++){
        if(L[i].value <= R[j].value){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right){
    int mid;
    if(left + 1 < right){
        mid = (left + right) /2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r){
    int i, j;
    struct Card t, x;
    x = A[r];
    i = p-1;
    for (j=p; j<r; j++){
        if(A[j].value <= x.value){
            i++;
            t=A[i]; A[i] = A[j]; A[j]=t;
        }
    }
    t = A[i+1]; A[i+1]=A[r]; A[r]=t;
    return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
    int q;
    if(p<r){
        q = partition(A, n, p, r);
        quickSort(A, n, p, q-1);
        quickSort(A, n, q+1, r);
    }
}

int main(){
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }

    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n-1);

    for(i=0; i<n; i++){
        if(A[i].suit != B[i].suit) stable = 0;
    }

    if(stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for(i=0; i<n; i++){
        printf("%C %d\n", B[i].suit, B[i].value);
    }

    return 0;
}


Measured memory_bytes: 5048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] line = br.readLine().split(" ");
            int a = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[2]);
            if (line[1].equals("+")){
                System.out.println(a + b);
            }
            else if (line[1].equals("-")) {
                System.out.println(a - b);
            }
            else if (line[1].equals("*")){
                System.out.println(a * b);
            }
            else if (line[1].equals("/")){
                System.out.println(a / b);
            }
            else{
                break;
            }
        }
    }
}

Measured memory_bytes: 24188
N, M = map(int, input().split())
L = []
R = []
for _ in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
max_L = max(L)
min_R = min(R)
ans = min_R - max_L + 1
if ans > 0:
    print(ans)
else:
    print(0)


Measured memory_bytes: 16904
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cctype>
using namespace std;

int main()
{
	int n, i;
	double  ma = 0,x[101], y[101], dis1=0, dis2=0, dis3=0,dis4;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for (i = 0; i < n; i++)
	{
		cin >> y[i];
	}
	for (i = 0; i < n; i++)
	{
		dis1 += fabs(x[i] - y[i]);
		dis2 += pow(fabs(x[i] - y[i]), 2);
		dis3 += pow(fabs(x[i] - y[i]), 3);
		ma = max(ma, fabs(x[i] - y[i]));
	}	
	dis2 = sqrt(dis2);
	dis3 = pow(dis3, 1.0/3);
	dis4=ma;
	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(8);
	cout << dis1 << endl;
	cout << dis2 << endl;
	cout << dis3 << endl;
	cout << dis4 << endl;
	return 0;
}


Measured memory_bytes: 3416
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;
	cin.ignore();
	map<ii, ll> mp;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		string str;
		getline(cin, str);
		int pnt = str.find('.');
		if(pnt == string::npos) {
			pnt = str.size();
			str += '.';
		}
		while(pnt + 9 >= str.size()) str += '0';
		str.erase(remove(str.begin(), str.end(), '.'), str.end());
		ll nmb = stoll(str);
		//debug(nmb);
		ii pr(-9, -9);
		while(nmb % 2 == 0) nmb /= 2, pr.fi++;
		while(nmb % 5 == 0) nmb /= 5, pr.se++;
		mp[pr]++;
	}

	//for(auto x: mp) debug(x.fi.fi, x.fi.se, x.se);
	for(auto x: mp) {
		for(auto y: mp) {
			if(x.fi.fi + y.fi.fi < 0 || x.fi.se + y.fi.se < 0) continue;
			if(x.fi == y.fi) ans += x.se * (x.se - 1);
			else ans += x.se * y.se;
		}
	}
	cout << ans / 2 << '\n';
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define MAXN 100005
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
#define KONJ 42-42
using namespace std;

ll n, k, q, a[MAXN];

void print(int arr[MAXN][MAXN], int r, int s) {
	cout << "\nTEST:\n";
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < s; j++) {
			cout << arr[i][j] << " ";
		}
		cout << "\n";
	}
	cout << "\n";
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> k >> q;
	for (int i = 0; i < n; ++i) a[i] = k;
	for (int i = 0; i < q; ++i) {
		ll x;
		cin >> x;
		a[--x]++;
	}
	for (int i = 0; i < n; ++i) {
		a[i] -= q;
		a[i] > 0 ? cout << "Yes\n" : cout << "No\n";
	}	
	
	return 0;
}


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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

int n, m;

int main()
{
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2;
	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 sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    string S,T;
    cin>>S>>T;
    int a,b;
    a=sz(S),b=sz(T);
    if(a+1!=b){cout<<"No"<<endl;return 0;}
    rep(i,a){if(S.at(i)!=T.at(i)){cout<<"No"<<endl;return 0;}}
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w;
    cin >> h >> w;
    char A[h][w];
    queue<pair<int, int>> q;
    rep(i, 0, h) {
        rep(j, 0, w) {
            cin >> A[i][j];
            if (A[i][j] == '#') {
                q.push(make_pair(i, j));
            }
        }
    }

    int dist[h][w];
    rep(i, 0, h) {
        rep(j, 0, w) {
            if (A[i][j] == '#') dist[i][j] = 0;
            else dist[i][j] = -1;
        }
    }

    int dy[4] = {1, 0, -1, 0};
    int dx[4] = {0, 1, 0, -1};

    int ans = 0;
    while (!q.empty()) {
        int y = q.front().first;
        int x = q.front().second;
        q.pop();
        rep(i, 0, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
            if (A[ny][nx] == '#') continue;
            if (dist[ny][nx] != -1) continue;
            dist[ny][nx] = dist[y][x] + 1;
            ans = max(ans, dist[ny][nx]);
            q.push(make_pair(ny, nx));
        }
    }

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


Measured memory_bytes: 13328
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main() 
{
    ll n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        sum+=i;
    }
    cout<<sum;
}

        

Measured memory_bytes: 3636
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n + 1):
        for m in range(s+1, n):
            for e in range(m+1, n+1):
                if x == s + m + e:
                    count += 1

    print(count)

Measured memory_bytes: 7676
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int main() {
    ios_base::sync_with_stdio(false);

    ll a, b;
    cin >> a >> b;

    ll ans = (a * b) / gcd(a, b);
    cout << ans << endl;
}


Measured memory_bytes: 256