akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll mod_pow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1)res=res*x%MOD;
		x=x*x%MOD;
		n>>=1;
	}
	return res;
}

ll inverse_element(ll t){
	return mod_pow(t,MOD-2);
}

ll n,a,b,k;
ll c[300100];
int main(){
	cin>>n>>a>>b>>k;
	c[0]=1;
	FOR(i,0,n){
		c[i+1]=((c[i]*(n-i))%MOD)*inverse_element(i+1)%MOD;
	}
	ll ans=0;
	for(int i=0;i<=n;i++){
		if((k-a*i)%b!=0)continue;
		int j=(k-a*i)/b;
		if(j<0||j>n)continue;
		ans+=(c[i]*c[j]%MOD);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

A, B = iInM()
S = input()

ans = 'Yes'
for i in range(len(S)):
    if i == A:
        if S[i] != '-':
            ans = 'No'
            break
    else:
        if not S[i].isdigit():
            ans = 'No'
            break

print(ans)


Measured memory_bytes: 61804
// solv_A.cpp : 
//

#define INF 1000

#include <iostream>
#include <string>

using namespace std;

int H, W;

char mymap[100][100];
int costmap[100][100];

int make_costmap(int i, int j, char prev_state, int c) {
	
	char state;

	state = mymap[i][j];

	if (prev_state == '.' and state == '#') {
		c += 1;
	}

	if (costmap[i][j]==INF || costmap[i][j] > c) {
		costmap[i][j] = c;
	}
	else
		return 0;

	if (i < H - 1)
		make_costmap(i + 1, j, state, c);
	if (j < W - 1)
		make_costmap(i, j + 1, state, c);
	return 0;
}

int main()
{
	int i,j;

	cin >> H >> W;


	string line;


	for (i = 0; i < H; i++) {
		cin >> line;
		for (j = 0; j < W; j++) {
			mymap[i][j] = line[j];
			costmap[i][j] = INF;
		}
	}

/*
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cout << mymap[i][j];
		}
		cout << endl;
	}
*/

	make_costmap(0, 0, '.', 0);

/*
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cout << costmap[i][j] << " ";
		}
		cout << endl;
	}
*/

	cout << costmap[H - 1][W - 1] << endl;
}



Measured memory_bytes: 888
#include <iostream>

using namespace std;
int main() {
	long long n, y;

	cin >> n >> y;

	for (long long i = 0; i <= n; i++) {
		for (long long j = 0; j <= n - i; j++) {
			long long k = n - i - j;
			if ((i * 1000 + j * 5000 + k * 10000) == y) {
				cout << k << " " << j << " " << i << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
	return 0;
}


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


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

    string s, t;
    cin >> s >> t;
    int s_len = s.size();
    int t_len = t.size();

    int ans = 10000;
    for (int i = 0; i < s_len - t_len + 1; ++i) {
        int count = 0;
        for (int j = 0; j < t_len; ++j) {
            if (s[i + j] != t[j]) count++;
        }
        ans = min(ans, count);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

#取り除く橋は西側が出来るだけ大きいやつから取り除いても無駄がない
#（なぜならそうでない橋を取り除いた後にも上の橋を取り除かねばならないので）
N,M = map(int,input().split())
ab =[list(map(int,input().split())) for i in range(M)]
ab.sort(reverse=True)
ans = 0
tmp = inf
for i in range(M):
    if ab[i][1] > tmp:
        continue
    else:
        ans += 1
        tmp = ab[i][0]
print(ans)

Measured memory_bytes: 60632
import java.util.Arrays;
import java.util.Scanner;

/**
1 BubbleSort(C, N)
2   for i = 0 to N-1
3     for j = N-1 downto i+1
4       if C[j].value < C[j-1].value
5         C[j] と C[j-1] を交換
6
7 SelectionSort(C, N)
8   for i = 0 to N-1
9     minj = i
10    for j = i to N-1
11      if C[j].value < C[minj].value
12        minj = j
13    C[i] と C[minj] を交換 
 *
 * charAt(1)
 */

/**
 * C
 */
public class Main {

    void run() {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        String[] c = new String[n];
        String[] c_copy = new String[n];

        for(int i=0; i<n; i++) {
            c[i] = sc.next();
            c_copy[i] = c[i];
        }

        bubbleSort(c, n);
        show(c, n);
        System.out.println("Stable");
        selectionSort(c_copy, n);
        show(c_copy, n);
        if(Arrays.equals(c, c_copy)) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }

        sc.close();

        //Debug
        /*
        for(String str : c) {
            System.out.print(str+" ");
        }
        System.out.println();
        for(String str : c_copy) {
            System.out.print(str+" ");
        }
        System.out.println();
        */

    }

    void bubbleSort(String[] c, int n) {
        for(int i=0; i<n-1; i++) {
            for(int j=n-1; j>i; j--) {
                if(c[j].charAt(1)<c[j-1].charAt(1)) {
                    String tmp = c[j];
                    c[j] = c[j-1];
                    c[j-1] = tmp;
                }   
            }
        }
    }

    void selectionSort(String[] c, int n) {
        for(int i=0; i<n; i++) {
            int minj = i;
            for(int j=i; j<n; j++) {
                if(c[j].charAt(1) < c[minj].charAt(1)) {
                    minj = j;
                }
            }
                String tmp = c[i];
                c[i] = c[minj];
                c[minj] = tmp;
        }
    }

    void show(String[] c, int n) {
        
        StringBuilder sb = new StringBuilder();
        
        for(int i=0; i<n; i++) {
            sb.append(c[i]);
            if(i != n-1) {
                sb.append(" ");
            } else {
                sb.append("\n");
            }
        }

        System.out.print(sb);

    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 26152
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn
    xys <- U.unfoldrN n parseInt2 <$> C.getContents
    putStrLn.bool"No""Yes"$solve n xys

solve :: Int -> U.Vector (Int, Int) -> Bool
solve n xys = go 0 . L.sortOn snd $ U.toList xys
  where
    go !cur ((x,y):xys)
        | cur + x <= y = go (cur + x) xys
        | otherwise = False
    go _ [] = True

-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)


Measured memory_bytes: 68988
#include <vector>
#include <cstdio>
#include <climits>
#include <iostream>

struct Edge{
	Edge(int t, int d):to(t),distance(d){};
	int to, distance;
};
void f(int s, int t, int d, std::vector<std::vector<int>> &distance, std::vector<std::vector<int>> &to, std::vector<std::vector<int>> &from){
	distance.at(s).at(t) = d;to.at(s).push_back(t);from.at(t).push_back(s);
}
int main(){
	int v, e, r;
	std::scanf("%d %d %d", &v, &e, &r);
	//v = 4; e = 6; r = 0;
	std::vector<std::vector<int>> distance(v, std::vector<int>(v, 1000000000));
	std::vector<std::vector<int>> to(v);
	std::vector<std::vector<int>> from(v);
	for (auto i = 0; i < e; ++i){
		int s, t, d;
		std::scanf("%d %d %d", &s, &t, &d);
		distance.at(s).at(t) = d;
		to.at(s).push_back(t);
		from.at(t).push_back(s);
	}
	//f(0,1,2,distance,to,from);f(0,2,3,distance,to,from);f(1,2,-5,distance,to,from);f(1,3,1,distance,to,from);f(2,3,2,distance,to,from);f(3,1,0,distance,to,from);
	bool negative = false;
	for (auto i = 0; i < v; ++i){
		distance.at(i).at(i) = 0;
	}
	for (auto k = 0; k < v; ++k){
		for (auto i : from.at(k)){
			for (auto j : to.at(k)){
				//std::cout << "k = " << k << " i = " << i << " j = " << j << "dist" << distance.at(i).at(j) << "-" << distance.at(i).at(k) << "-" << distance.at(k).at(j) << std::endl;
				if (distance.at(i).at(j) > distance.at(i).at(k) + distance.at(k).at(j)){
					if (distance.at(i).at(j) > 10000000 and i != j){
						to.at(i).push_back(j); from.at(j).push_back(i);
					}
					distance.at(i).at(j) = distance.at(i).at(k) + distance.at(k).at(j);
				}
			}
			if (distance.at(i).at(i) < 0 and distance.at(r).at(i) <= 10000000){
				negative = true;
				k = v - 1;
			}
		}
	}
	for (auto i = 0; i < to.at(r).size(); ++i){
		if (negative){
			i = to.at(r).size();
		}else{
			negative = (distance.at(to.at(r).at(i)).at(to.at(r).at(i)) < 0);
		}
	}
	if (negative){
		std::printf("NEGATIVE CYCLE\n");
	}else{
		for (auto i : distance.at(r)){
			if (i <= 10000000){
				std::printf("%d\n", i);
			}else{
				std::printf("INF\n");
			}
		}
	}
}

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

namespace AtCoder.Abc
{
    // 問題:
    class A_159_The_Number_of_Even_Pairs
    { 
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int gusu = 0;
            int kisu = 0;

            for (int i = 1; i < inputLongArray[0]; i++)
            {
                gusu = gusu + inputLongArray[0] - i;
            }

            for (int i = 1; i < inputLongArray[1]; i++)
            {
                kisu = kisu + inputLongArray[1] - i;
            }

            int result = gusu + kisu;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

int N,L;
int R[210] = {};
int main(){
    cin >> N >> L;
    int sum = 0;
    for(int i=1;i<=N;i++){
        R[i] = L+i-1;
        sum += R[i];
    }
    int ans = 0,mi = 1e9;
    for(int i=1;i<=N;i++){
        int sum2 = 0;
        for(int j=1;j<=N;j++){
            if(i!=j) sum2 += R[j];
        }
        if(abs(sum-sum2)<mi){
            mi = min(mi,abs(sum-sum2));
            ans = sum2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
    }
    int su = 1;
    for(int i = 0; i < n; i++) {
        if(a[i] == su) su++;
    }
    if(su == 1) cout << "-1" << endl;
    else cout << n-su+1 << endl;

    return 0;
}

Measured memory_bytes: 4392
import { readFileSync } from 'fs'

function main(input: string) {
    let [n, ...S] = input.split('\n')
    console.log("AC x " + S.filter(s => s === 'AC').length)
    console.log("WA x " + S.filter(s => s === 'WA').length)
    console.log("TLE x " + S.filter(s => s === 'TLE').length)
    console.log("RE x " + S.filter(s => s === 'RE').length)
}

let lines: string;
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', function (line: string) {
  lines += line;
  lines += '\n';
});
reader.on('close', function () {
    main(lines)
});


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

using namespace std;

const int mod = 998244353;

map<string,int> f1,f2;

string s;

int solv(string s);

int solv2(string s)
{
	if(!s.size()) return 1;
	if(s.size() == 1) return s[0] == '1' ? 2 : 1;
	if(f2.find(s) != f2.end()) return f2[s];
	int as = 0;
	for(int i = 1;i * 2 <= s.size(); ++ i)
	{
		if(s.size() % i == 0)
		{
			string t = "";
			for(int j = 0;j < i; ++ j)
			{
				bool flg = 1;
				for(int k = j;k < s.size();k += i)
					if(s[k] == '0')
					{
						flg = 0;
						break;
					}
				t += flg ? "1" : "0";
			}
			as += solv(t);
			as %= mod;
		}
	}
	return f2[s] = as;
}

int solv(string s)
{
	if(!s.size()) return 1;
	if(s.size() == 1) return s[0] == '1' ? 2 : 1;
	if(f1.find(s) != f1.end()) return f1[s];
	int as = 0;
	for(int i = 1;i <= s.size(); ++ i)
	{
		as += solv2(s.substr(0,i)) * 1ll * solv(s.substr(i,s.size())) % mod;
		as %= mod;
	}
	return f1[s] = as;
}

int main()
{
	cin >> s;
	printf("%d\n",solv(s));
	return 0;
}

Measured memory_bytes: 12928
#include<stdio.h>

int main(void)
{
	int a, b, c, k, i;
	scanf("%d%d%d", &a, &b, &c);
	scanf("%d", &k);
	if (a >= b) {
		if (a >= c) {
			for (i = 0; i < k; i++) {
				a = a * 2;
			}
			printf("%d", a + b + c);
		}
		else {
			for (i = 0; i < k; i++) {
				c = c * 2;
			}
			printf("%d", a + b + c);
		}
	}
	else {
		if (b >= c) {
			for (i = 0; i < k; i++) {
				b = b * 2;
			}
			printf("%d", a + b + c);
		}
		else {
			for (i = 0; i < k; i++) {
				c = c * 2;
			}
			printf("%d", a + b + c);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
      double r,g;
      cin>>r>>g;
      cout<<2*g-r;
      
    } 
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
long long n, k=-1, j=1, a[200005], b[200005]; 
int main(){
       std::ios::sync_with_stdio(false);
	cin>>n;
	for(long long i=1; i<=n; i++)
	cin>>a[i];
	for(long long i=1; i<=n; i++)
	cin>>b[i];
	for(long long i=1; i<=n; i++){
		if(a[i]!=k) j=1;
		if(b[i]==a[i]){
		       for(; j<=n; j++)
		       if(b[j]!=a[i] && a[i]!=a[j]){
		              swap(b[i], b[j]);
		              break;
		       }
		       if(a[i]==b[i]){
		              cout<<"No"<<endl;
		              return 0;
		       }
		}
		k=a[i];
	}
	cout<<"Yes"<<endl;
	for(long long i=1; i<=n; i++)
	cout<<b[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 6744
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);

        int N = scn.nextInt();
        int[] L = new int[N];
        for(int i=0;i<N;i++) L[i] = scn.nextInt();

        int ans = 0;

        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                for(int k=j+1;k<N;k++) {
                    if(L[i]+L[j]>L[k]&&L[i]+L[k]>L[j]&&L[j]+L[k]>L[i])
                    if(L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k]){
                        ans++;
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 36684
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    string s;
    cin>>s;
    cout<<s.substr(0,3);
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
   int n;
   cin >> n;
   vl a(n), b(n);
   rep(i, n) cin >> a[i] >> b[i];
   if(a == b) {
       cout << 0 << endl;
       return 0; 
   }
   ll sum = 0LL;
   rep(i, n) sum += a[i];
   ll x = INF;
   rep(i, n) {
       if(a[i] > b[i]) x = min(x, b[i]);
   }
   cout << sum - x << endl;
   return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>

#define rep(i,m,n) for(unsigned long long int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<long long int> v;
vector<long long int> w;

int main() {
	int a, b;
	cin >> a >> b;
	if (b == 1) {
		cout << '0' << '\n';
		return 0;
	}

	int ans = 1;
	b -= a;
	while (b > 0) {
		b -= a - 1;
		++ans;
	}
	cout << ans << '\n';

	return 0;
}

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

#define endl '\n'
#define ll long long


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int i,j;
	char s[3][3];
	for(i=0;i<3;i++)
	for(j=0;j<3;j++)
	{
		cin >> s[i][j];
	}
	for(int i=0;i<3;i++)
	{
		cout << s[i][i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;


int main(){
  int n,m,c;
  cin >> n >> m >> c;
  int ans=0;
  int b[m+10];
  for (int i=0;i<m;i++) cin >> b[i];
  for (int i=0;i<n;i++){
    int hantei=0;
  int a[m+10];
    for (int j=0;j<m;j++) {
      cin >> a[j];
      hantei+=(a[j]*b[j]);
    }
  hantei+=c;
  if (hantei>0) ans++;
}
cout << ans << endl;
}

  
    



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

int main(){
	int n;
	long long int ans=1;
	cin>>n;
	rep(i,1,n+1){
		ans*=i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1156
import math
n = int(input())
x = list(map(int, input().split()))

# print(sum(x)/len(x))
mean = math.floor(sum(x)/len(x))
mean2 = mean + 1
ans = 0
ans2 = 0
for i in x:
    ans += (i - mean) ** 2
    ans2 += (i - mean2) ** 2

if ans <= ans2:
    print(ans)
    exit()
else:
    print(ans2)
    exit()

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    map<string, vector<pii>> M;
    for (int i = 0; i < N; i++) {
        string s;
        int p;
        cin >> s >> p;
        M[s].push_back({p, i + 1});
    }

    for(auto e : M) {
        vector<pii> &ee = e.second;
        sort(all(ee), greater<pii>());
        for (int j = 0; j < ee.size(); j++) {
            cout << ee[j].second << endl;
        }
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int x;cin>>x;
  if (x==3||x==5||x==7){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//Aの倍数を一つ以上選び、その総和をBで割った余りをCにできるか
int main() {
    int A,B,C;
    cin >> A >> B >> C;
    vector<int> v = {A,B,C};
    sort(v.begin(),v.end());
    int a0 = v[0];//一番小さいもの
    int a1 = v[1];//二番目に小さいもの
    int a2 = v[2];//最も大きいもの
    int ans = 0;
    ans += a2 -a1;
    a0 += a2 - a1;
    a1 = a2;
    if((a2 - a0)%2 == 0){
        ans += (a2 - a0)/2;
    }
    else{
        a1 += 1;
        a2 += 1;
        ans += 1;
        ans += (a2 - a0)/2;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int a,b,c,d = 0;
  cin >> a >> b;
  c = b-a;
  REP(i,c+1){
    d += i;
  }
  
  cout << d-b << endl;
}


Measured memory_bytes: 3612
n, k = map(int,input().split())

lst = [_ for _ in range(n+1)]
ans = 0

for i in range(k,n+2):
    min_value = i*(i-1)//2
    max_value = (i*(2*n - i + 1))//2
    ans += max_value - min_value + 1

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

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

using namespace std;

const int mod = 1e9+7;
#define ll long long int
const double epsilon = 1e-7;

ll ma(ll x, ll y){
    if(x>y)return x;
    return y;
}
ll fac[200100];
ll inv[200100];
ll facinv[200100];
void C_init(){
    fac[0] = 1;
    for(int i = 1;i < 200100;i++)fac[i] = (fac[i-1] * i)%mod;
    inv[1] = 1;
    for(int i = 2;i < 200100;i++)inv[i] = ((-(mod/i)*inv[mod%i])%mod+mod)%mod;
    facinv[0] = 1;
    for(int i = 1;i < 200100;i++)facinv[i] = (facinv[i-1] * inv[i])%mod;
    return;
}
ll nCr(ll n, ll r){
    return ((fac[n] * facinv[n-r])%mod * facinv[r])%mod;
}
int main(void){
    int h, w, a, b;
    scanf("%d %d %d %d", &h, &w, &a, &b);
    C_init();
    ll ans = 0;
    for(int i = 0;a + i < h && b + i < w;i++){
        ans += (nCr(h-a+b-1, h-a-i-1)*nCr(a+w-b-1, w-b-i-1))%mod;
        ans %= mod;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  int saidai;
  cin >> A >> B >> C >> K;
  
  if (A+B >= K){
    if (A > K){
      saidai = K;
    }
    else{
      saidai = A;
    }
  }
  else {
    saidai = 2 * A - K + B;
  }
  
  cout << saidai << endl;
}
  


Measured memory_bytes: 3636
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int ans;
int limit;

void recurse(long long num, int mask) {
    if (num > limit)
        return;
    if ((mask & 7) == 7)
        ans++;
    recurse(num * 10 + 3, mask | 1);
    recurse(num * 10 + 5, mask | 2);
    recurse(num * 10 + 7, mask | 4);
}

int main(void) {
	// in = fopen("C.in", "rt");
	
	fscanf(in, "%d", &limit);
	
	recurse(0, 0);
	fprintf(out, "%d\n", ans);
	
	return 0;
}

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

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'


int main(){
	IoFast;
	int w = 0,s = 0,n = 0,e = 0;
	string o;
	cin >> o;
	foor(i,0,sz(o)){
		if (o[i] == 'E')
			e = 1;
		if (o[i] == 'W')
			w = 1;
		if (o[i] == 'N')
			n = 1;
		if (o[i] == 'S')
			s = 1;
	}
	if ((s + n) % 2 == 1)
		cout << "No" << endl;
	else if ((w + e) % 2 == 1)
		cout << "No" << endl; 
	else
		cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<P> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//入力
ll n,m;
Graph g;

vector<ll>dist;
bool flag;
ll Ma,mi;

void dfs(ll v){
    for(P x:g[v]){
        ll r = x.first;
        ll c = x.second;
        if(dist[r]==INF){
            dist[r]=dist[v]+c;
            chmax(Ma,dist[r]);
            chmin(mi,dist[r]);
            dfs(r);
        }
        else{
            if(dist[r]!=dist[v]+c){
                flag = false;
            }
        }
    }
}


int main(){
    cin >> n >> m;
    g.resize(n);
    rep(i,m){
        ll l,r,d;
        cin >> l >> r >> d;
        l--;r--;
        g[l].push_back({r,d});
        g[r].push_back({l,-d});
    }
    dist.resize(n,INF);
    flag=true;
    rep(i,n){
        if(dist[i]!=INF)continue;
        Ma = 0;
        mi = 0;
        dist[i]=0;
        dfs(i);
        if(Ma-mi>(ll)1e9){
            flag=false;
        }
    }

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

Measured memory_bytes: 19312
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=0; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  string s ;
  cin >> s ;
  int n = s.size() ;
  int sum = 0 ;
  int ss = stoi(s) ;
  
  REP(i,n){
    sum += s.at(i)-'0' ;
  }
  
  if(ss%sum==0){
    cout << "Yes"<<endl ;
  }
  else{
    cout <<"No"<<endl ;
  }
    

  return 0 ;
}




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


int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n) {
    for (int j = i+1; j < n; j++) {
      ans = max(ans,abs(a[j] - a[i]));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//
//using namespace __gnu_pbds;
using namespace std;

#define pb                     push_back
#define ll                     long long
#define forn(i,n)              for(int i=0; i<(int)n; i++)
#define forn1(i,n)              for(int i=1; i<=(int)n; i++)

#define sfd(a)                 scanf("%d", &a)
#define sffd(a,b)              scanf("%d%d", &a, &b)
#define sffl(a,b)              scanf("%lld%lld", &a,&b)
#define sfl(a)                 scanf("%lld", &a)

#define pii                    pair<int , int>
#define pll                    pair<ll , ll>
#define ff                     first
#define ss                     second
#define mem(a, val)            memset(a, val, sizeof(a))
#define all(x)                 (x).begin(), (x).end()

#define mx                     200005
#define INF_mx                 1e18
#define gcd(a,b)               __gcd(a, b)
#define lcm(a,b)               (a*b)/__gcd(a,b)
#define PRINT                  cout<<"hi"<<endl
#define PI acos(-1)
#define fast_in_out          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Q    int q; cin>>q; while(q--)
/*
tree<
       int,
     null_type,
     less<int>,
     rb_tree_tag,
     tree_order_statistics_node_update>t;
*/

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<"\n";

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
void swap(ll *xp,ll *yp){
	ll temp = *xp;
	*xp = *yp;
	*yp = temp;
}

ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}

void solve(){
	string s;
	ll i,j;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 256
import itertools
N = int(input())
digits = [3, 5, 7]


def get_A_product(digits, N):
    A = []
    flag = False
    p = 3
    while True:
        for tup in itertools.product(digits, repeat=p):
            a = int("".join(list(map(str, tup))))
            if a > N:
                flag = True
                break
            A.append(a)
        if flag:
            break
        p += 1
    return A


count = 0
A = get_A_product(digits, N)
for a in A:
    if "3" in str(a) and "5" in str(a) and "7" in str(a):
        count += 1
print(count)


Measured memory_bytes: 4364
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;
#[allow(dead_code)]
const N_PRIME : i64 = 1000000007;

////////////////////////////////////////////////

fn main(){
    let xs = read_ints2(5);
    let k = read_int();

    println!("{}", if xs[4]-xs[0] > k {
        ":("
    }else{
        "Yay!"
    });
}

Measured memory_bytes: 4352
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = x-1
r = x+1
if not x in p:
    print(x)
    exit()
while True:
    if not l in p:
        print(l)
        break
    elif not r in p:
        print(r)
        break
    l -= 1
    r += 1

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

int main(){
  auto read = [](){
                int hh,mm,ss;
                scanf("%d:%d:%d",&hh,&mm,&ss);
                return hh*3600 + mm*60 + ss;
              };

  int n;
  while(cin >> n, n){

    vector<pair<int,int>> T;
    for(int i = 0; i < n; ++i){
      int in = read(), out = read();
      T.emplace_back(in,1);
      T.emplace_back(out,-1);
    }
    sort(T.begin(), T.end());
    int cnt = 0, t = 0;
    for(auto e : T){
      t -= e.second;
      if(t < 0) ++cnt, ++t;
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3340
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <bitset>
using namespace std;

typedef long long ll;
int main() {
    ll s, c, ans=0;
    cin>>s>>c;
    ans=min(s, c/2);
    s-=ans;
    c-=2*ans;
    ans+=c/4;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int n;
int cou  = 0;

int main()
{
    int ans = 0;
    scanf("%d",&n);
    if(n < 10)
        ans = n;
    else if(n < 100)
        ans = 9;
    else if(n < 1000)
        ans = (n - 99) + 9;
    else if (n < 10000)
        ans = 909;
    else if(n <= 99999)
        ans = 909 + (n - 9999);
    else if( n == 100000)
        ans = 909 + 90000;
    printf("%d\n",ans);
    return 0;
}


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

namespace KEYENCE2020
{
    class B
    {
        static void Main(string[] args)
        {
            //long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            //string S = Console.ReadLine();
            long N = long.Parse(Console.ReadLine());
            Tuple<long, long>[] t = new Tuple<long, long>[N];
            for (int i = 0; i < N; i++)
            {
                long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
                t[i] = Tuple.Create(input[0] - input[1], input[0] + input[1]);
            }
            t = t.OrderBy(x => x.Item2).ToArray();
            /*
            foreach (var item in t)
            {
                Console.WriteLine("{0} {1}", item.Item1, item.Item2);
            }
            */

            long res = 0;
            long end = int.MinValue;
            for (int i = 0; i < N; i++)
            {

                if (end <= t[i].Item1)
                {
                    res++;
                    end = t[i].Item2;
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 28084
using System;
class Program
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] cost = new int[3];
        for (int i = 0; i < 3; i++)
            cost[i] = int.Parse(str[i]);
        Array.Sort(cost);
        Console.WriteLine(cost[0] + cost[1]);
    }
}

Measured memory_bytes: 11220
x,y=map(int,input().split())
MOD=10**9+7
def comb(n, k):
    ret = 1
    for i in range(1, k + 1):
        ret = ret * (n - i + 1) % MOD        
        ret = ret * pow(i, MOD - 2, MOD) % MOD
        
    return ret
a=(2*y-x)/3
b=(2*x-y)/3
c=(x+y)/3
if (x+y)%3!=0 :
    print(0)
elif a<0 or b<0:
    print(0)
else:
    print(int(comb(int(c),int(a))))
    
    

Measured memory_bytes: 38648
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	int n,m,a,b,g[9][9] = {},z=0;
	cin >> n >> m;
	for (int i=0;i<m;i++) cin >> a >> b, g[a][b] = g[b][a] = 1;
	int c[8] = {1,2,3,4,5,6,7,8};
	do {
		bool y=1;
		for (int i=1;i<n;i++) {
			if (g[c[i-1]][c[i]]==0) y=0;
		}
		if (y) z++;
	} while (next_permutation(c+1,c+n));
	cout << z;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char w[101];
    scanf("%s", &w);
    for(int i=0; w[i]!='\0'; i++){
        int count=0;
        for(int j=0; w[j]!='\0'; j++) if(w[i]==w[j]) count++;
        if(count%2==1){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	sc.Scan()
	s := sc.Text()
	return strconv.Atoi(s)
}

func main() {
	sc.Split(bufio.ScanWords)

	a, _ := nextInt()
	b, _ := nextInt()

	fmt.Printf("%d %d %f\n", a/b, a%b, float64(a)/float64(b))
}



Measured memory_bytes: 1104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

	int n;
	cin >> n;
	vector<int> a(n);
	int maxA = 0;
	rep(i, n) {
		cin >> a[i];
		maxA = max(maxA, a[i]);
	}
	vector<int> sum(maxA + 1, 0);

	rep(i, n) {
		sum[a[i]]++;
	}

	int ans = 0;

	if (maxA == 0) ans = sum[0];
	else if (maxA == 1) ans = sum[0] + sum[1];
	else {
		rep(i, maxA - 1) {
			int tmp;
			tmp = sum[i] + sum[i + 1] + sum[i + 2];
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N,n,d,i,xMax,xMin,yMax,yMin,ix[200],iy[200],h,w;
  while(1){
    cin >> N;
    if(N==0) break;
    ix[0]=iy[0]=0;    //location(i)=(ix,iy)
    xMax=xMin=yMax=yMin=0;
    for(i=1;i<N;i++){
      cin >> n >> d;
      if(d==0){
	ix[i]=ix[n]-1;
	iy[i]=iy[n];
	xMin=min(ix[i],xMin);
      }
      else if(d==1){
	iy[i]=iy[n]-1;
	ix[i]=ix[n];
	yMin=min(iy[i],yMin);
      }
      else if(d==2){
	ix[i]=ix[n]+1;
	iy[i]=iy[n];
	xMax=max(ix[i],xMax);
      }
      else{
	iy[i]=iy[n]+1;
	ix[i]=ix[n];
	yMax=max(iy[i],yMax);
      }
    }
    w=xMax-xMin+1;
    h=yMax-yMin+1;
    cout << w << ' ' << h << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int d,t,s;
  cin >> d >> t >> s;
  if(s*t >= d){
    cout<<"Yes"<<endl;
  }
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let r: usize = iterator.next().unwrap().parse().unwrap();
    let ans: usize = 3 * r * r;
    return ans.to_string();
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int N, ans=0;
    cin >> N;
    vector<ll> B(0);
    for (int i = 0; i < N-1 ; ++i){
        ll r;
        std::cin >> r;
        B.push_back(r);
    }
    ans += B[0];
    REP(i, N-2){
        ans += min(B[i], B[i+1]);
    }
    ans += B[N-2];
    cout << ans;
 }




Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;
	bool[long] set;
	set[A] = true;
	set[B] = true;
	foreach (i; 1..4)
	{
		if (set.get(i, false) == false)
			writeln(i);
	}
	
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256