akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<functional>
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <stdio.h>
#include<iterator>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
int h, w, n;
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d %d %d", &h, &w, &n);
	int mx = max(h, w);
	printf("%d\n", (n + mx - 1) / mx);
	return 0;
}

Measured memory_bytes: 256
import itertools

h, w, k = [int(i) for i in input().split()]

dp = [[0 for i in range(w)] for j in range(h+1)]
dp[0][0] = 1

if w == 1:
    print(1)
    exit()

for i in range(1, h + 1):
    for kuji_list in itertools.product([0, 1], repeat = w - 1):
        for l in range(len(kuji_list)-1):
            if kuji_list[l] == 1 and kuji_list[l+1] == 1:
                break
        else:
            for j in range(w):

                if j == 0:
                    if kuji_list[j] == 1:
                        dp[i][j] += dp[i - 1][j + 1]
                    else:
                        dp[i][j] += dp[i - 1][j]

                elif j == w - 1:
                    if kuji_list[j-1] == 1:
                        dp[i][j] += dp[i - 1][j - 1]
                    else:
                        dp[i][j] += dp[i - 1][j]

                else:
                    if kuji_list[j-1] == 1:
                        dp[i][j] += dp[i - 1][j - 1]
                    elif  kuji_list[j] == 1:
                        dp[i][j] += dp[i - 1][j + 1]
                    else:
                        dp[i][j] += dp[i - 1][j]

                dp[i][j] %= (10 ** 9 + 7)

ans = dp[-1][k - 1] % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#define ll long long
#define Freopen(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using namespace std;
void init(),solve();
int a,b;
int main()
{
	init();
	solve();
	return 0;
}
void init()
{
	scanf("%d%d",&a,&b);
	return;
}
void solve()
{
	printf("%d",max(a+b,max(a-b,a*b)));
	return;
}

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

int main()
{
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    rep(i, d) {
        int s_max = 0;
        rep(j, 26) {
            if (s_max < s[i][j]) {
                s_max = s[i][j];
                t[i] = j+1;
            }
        }
        
    }
    rep(i, d) {
        cout << t[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, alice, bob;
  cin >> N;
  vector<int> a(N);
  
  alice = 0;
  bob = 0;
  
  for(int i=0; i<N; i++){
    cin >> a.at(i); 
  }
  
  int temp;
  for(int i=0; i<N; i++){
    for(int j=i; j<N; j++){
        if( a.at(i) < a.at(j) ) {
          temp = a.at(i);
          a.at(i) = a.at(j);
          a.at(j) = temp;
        }
    }
    
    if( i%2 == 0 )
      alice += a.at(i);
    else
      bob += a.at(i);
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=sc.Arr(s[1],()=>sc.Ia);
		Array.Sort(a,(u,v)=>u[1]-v[1]);
		var dp=Enumerable.Repeat(mod,s[0]+1).ToArray();
		dp[0]=0;
		for(int i = 0;i<s[1];i++) {
			for(int j = 0;j<s[0];j++) {
				dp[Min(j+a[i][0],s[0])]=Min(dp[Min(j+a[i][0],s[0])],dp[j]+a[i][1]);
			}
		}
		Console.WriteLine("{0}",dp[s[0]]);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13460
#include<stdio.h>

#define MAX 200000
#define SENTINEL 1000000001

long long gA[MAX+1],gn,gcnt;
long long gL[ (MAX/2)+1 ],gR[ (MAX/2)+1 ];
 
void merge( long long left, long long mid, long long right )
{
    long long i,j,k;
    long long n1=mid-left;
    long long n2=right-mid;
 
    for( i=0; i<n1; i++ ) {
        gL[i]=gA[ left+i ];
    }
    for( i=0; i<n2; i++ ) {
        gR[i]=gA[ mid+i ];
    }
     
    gL[n1]=gR[n2]=SENTINEL;
    i=j=0;
    for( k=left; k<right; k++ ) {
        if( gL[i] <= gR[j] ) {
            gA[k]=gL[i++];
        } else {
	        gcnt+=(n1-i);
            gA[k]=gR[j++];
        }
    }
    return;
}
 
void mergeSort( long long left, long long right )
{   
    long long mid;
    if( left+1 < right ) {
        mid=(left+right)/2;
        mergeSort( left, mid );
        mergeSort( mid, right );
        merge( left, mid, right );
    }
     
    return;
}

int main( void ) 
{	
	long long i;
	
    scanf( "%lld", &gn );

	for( i=0; i<gn; i++ ) {
		scanf( "%lld", &gA[i] );
	}
	gcnt=0;
	mergeSort( 0, gn );
	printf( "%lld\n",  gcnt );

    return 0;
}

Measured memory_bytes: 3720
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

typedef vector<vector<lint>> mat;

mat mtx{
    {1,0,1},//F(N-1),F(N-2),...,F(N-K)の係数
    {1,0,0},
    {0,1,0},
}; // K次正方行列

vector<lint> F{0,0,1}; //F(1)~F(K)の値

mat mul(mat &A,mat &B){
    mat C(A.size(),vector<lint>(B[0].size()));
    rep(i,A.size()) rep(j,B.size()) rep(k,B[0].size()){
        C[i][k]=(C[i][k]+A[i][j]*B[j][k])%MOD;
    }
    return C;
}

mat powmat(mat A,lint n){
    mat B(A.size(),vector<lint>(A.size()));
    rep(i,A.size()) B[i][i]=1;
    while(n){
        if(n&1) B=mul(B,A);
        A=mul(A,A);
        n>>=1;
    }
    return B;
}

lint calc(lint n){ //F(N)の計算
    if(n==0) return 0;
    mat A=mtx;
    A=powmat(A,n-1);
    lint res=0;
    rep(i,A.size()) res=(res+A[A.size()-1][i]*F[A.size()-1-i])%MOD;
    return res;
}

int main(void){
    lint S;
    cin >> S;
    cout << calc(S) << endl;
}

Measured memory_bytes: 3556
module subprogram
	implicit none
contains
subroutine heapsort2(n,array,turn)
  implicit none
  integer,intent(in)::n
  integer,intent(out)::turn(1:n)
  integer,intent(inout)::array(1:n)
  
  integer::i,k,j,l,m
  double precision::t
  
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  do i=1,N
     turn(i)=i
  enddo

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(l)
        m=turn(l)
     else
        t=array(k)
        m=turn(k)
        array(k)=array(1)
        turn(k)=turn(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           turn(1)=m
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           turn(i)=turn(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     turn(i)=m
  enddo
  return
end subroutine heapsort2
end module subprogram

program main
	use subprogram
	implicit none
	integer N, i
	integer(8) K, S
	integer, allocatable :: a(:), b(:), turn(:)
	read(*, *) N, K
	allocate(a(1:N))
	allocate(b(1:N))
	allocate(turn(1:N))
	do i = 1, N
		read(*, *) a(i), b(i)
	end do
	call heapsort2(N,a,turn)
	S = 0
	do i = 1, N
		S = S + b(turn(i))
		if(K <= S) then
			write(*, *) a(i)
			exit
		end if
	end do
end program main

Measured memory_bytes: 1408
{-# LANGUAGE ScopedTypeVariables #-}
     
    import qualified Data.ByteString.Char8 as B
    import qualified Data.Vector.Unboxed as VU
    import qualified Data.Vector.Unboxed.Mutable as VUM
    import Data.Char
    import Control.Monad
     
    -- Union-Find
    type Parent = VUM.IOVector Int
    type Size = VUM.IOVector Int

    makeUF :: Int -> IO (Parent, Size)
    makeUF n = do
        par <- VU.unsafeThaw $! VU.generate n id
        siz <- VUM.replicate n 1
        return (par, siz)
    
    root :: Int -> Parent -> IO Int
    root x par = do
        r <- VUM.read par x
        case compare x r of
            EQ -> return x
            _ -> do
                r' <- root r par
                VUM.write par x r'
                return r'
    
    same :: Int -> Int -> Parent -> IO Bool
    same x y par = do
        x' <- root x par
        y' <- root y par
        return $! x' == y'
    
    unite :: Int -> Int -> Parent -> Size -> IO Bool
    unite x y par siz = do
        x' <- root x par
        y' <- root y par
        sx <- VUM.read siz x'
        sy <- VUM.read siz y'
        case compare x' y' of 
            EQ -> return False
            _ -> do
                case compare sx sy of
                    LT -> do
                        VUM.modify siz (+sx) y'
                        VUM.write par x' y'
                    _ -> do
                        VUM.modify siz (+sy) x'
                        VUM.write par y' x'
                return True
    
    size :: Int -> Parent -> Size -> IO Int
    size x par siz = root x par >>= VUM.read siz
     
    toTuple :: B.ByteString -> (Int, Int)
    toTuple bs =
        let
            Just (a, bs') = B.readInt bs
            Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
        in
            (a, b)
        
    main = do
        [n,m,k] <- map read . words <$> getLine :: IO [Int]
        (par, siz) <- makeUF (n+1)
        (cnt :: VUM.IOVector Int) <- VUM.replicate (n+1) 0
        replicateM_ m $ do
            (a,b) <- toTuple <$> B.getLine 
            unite a b par siz
            VUM.modify cnt (+1) a
            VUM.modify cnt (+1) b
     
        replicateM_ k $ do
            (c,d) <- toTuple <$> B.getLine 
            branch <- same c d par
            when branch $ do
                VUM.modify cnt (+1) c
                VUM.modify cnt (+1) d
            
        forM_ [1..n] $ \i -> do
            s <- size i par siz
            c <- VUM.read cnt i
            putStr $ show (s - c - 1)
            putStr " "
        putStrLn ""

Measured memory_bytes: 4092
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val nm = inputs.head.split(" ").map(_.toInt)
  val n  = nm(0)
  val m  = nm(1)

  println(solve(n,m, inputs.tail))

  def solve(n: Int, m: Int, ab: Seq[String]): Long = {
    val hash = scala.collection.mutable.HashMap.empty[Long, Long]
    var ans = 0L
    var nowStock = 0L
    val keySet = ab.map { line =>
      val lineNum = line.split(" ").map(_.toLong)
      val key = lineNum(0)
      hash.update(key, hash.applyOrElse(key, (n: Long) => 0L) + lineNum(1))
      key
    }.distinct.sorted

    keySet.foreach { price =>
      val stock = hash(price)

      if (m < stock + nowStock) {
        val v = (m - nowStock)
        ans = ans + v * price
        nowStock = nowStock + v
      } else {
        nowStock = nowStock + stock
        ans = ans + (stock * price)
      }

      if (m == nowStock) {
        return ans
      }

    }

    -1L
  }
}

Measured memory_bytes: 83500
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String[] lines = sc.nextLine().split(" ");
        int N = Integer.parseInt(lines[0]);
        int M = Integer.parseInt(lines[1]);

        boolean oo = false;

        String[] sample = new String[N];
        for (int i = 0; i < N; i++) {
            sample[i] = "a";
        }

        String result = "";

        for (int i = 0; i < M; i++) {
            String[] line = sc.nextLine().split(" ");
            int s = Integer.parseInt(line[0]);
            String c = line[1];
            if (!sample[s - 1].equals("a") && !sample[s - 1].equals(c)) {
                result = "-1";
                oo = true;
                break;
            }

            sample[s - 1] = c;
        }

        sc.close();

        if (!oo) {

            StringBuilder sb = new StringBuilder();
            if (sample[0].equals("0") && sample.length > 1) {
                result = "-1";
            } else {
                if (sample[0].equals("a") && sample.length > 1) {
                    sample[0] = "1";
                }
                for (int i = 0; i < N; i++) {
                    sb.append(sample[i]);
                }
                result = sb.toString().replaceAll("a", "0");
            }
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};


int a[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int k,n;
    cin>>k>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    a[n+1]=k+a[1];
    int ans=0;
    for(int i=1;i<=n;i++)
        ans=max(ans,a[i+1]-a[i]);
    cout<<k-ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int X;
int M = 1e5 + 3;

int main() {
    cin >> X;
    vector<bool> Prime(M + 1, true);
    for (long long p = 2; p * p <= M; p++) {
        if (!Prime[p]) continue;
        for (int q = 2; p * q <= M; q++) {
            Prime[p * q] = false;
        }
    }
    int ans = X;
    while (!Prime[ans]) {
        ans++;
    }
    cout << ans << endl;
}


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

typedef long long ll;

int main(){
	ll n;
	ll a[100010];
	scanf("%lld",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%lld",&a[i]);
	}
	
	ll ret[2];
	for(int t = 0 ; t < 2 ; t ++){
		ll sum = 0;
		for(int i = 0 ; i < n ; i ++){
			sum += a[i];
			if((i&1) == t){
				if(sum <= 0){
					ret[t] += 1-sum;
					sum = 1;
				}
			}
			else {
				if(sum >= 0){
					ret[t] += sum+1;
					sum = -1;
				}
			}
		}
	}
	cout << min( ret[0] , ret[1] ) << endl;
}

Measured memory_bytes: 1024
N = int(input())
h = list(map(int, input().split()))
d = [0]
for i in range(1, len(h)):
    if i == 1:
        d.append(abs(h[i] - h[i-1]))
    if i > 1:
        d1 = abs(h[i] - h[i-1]) + d[i-1]
        d2 = abs(h[i] - h[i-2]) + d[i-2]
        d.append(min(d1, d2))
print(d[len(h) - 1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	
	if(k <= a){
		cout << k << endl;
	} else if (k <= a + b){
		cout << a << endl;
	} else {
		cout << a - (k - a - b);
	}
	
	return 0;
}



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


mod = 10**9+7
MAX_N = 10**6

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%mod)

fact_inv[-1] = pow(fact[-1],mod-2,mod)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%mod


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

if k > n-1:
    print(mod_comb_k(2*n-1,n-1,mod))
else:
    res = 1
    
    for i in range(1,k+1):
        res = (res+mod_comb_k(n,i,mod)*mod_comb_k(n-1,i,mod))%mod
    print(res)

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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int sum = 0;
    int[] prices = new int[n];
    for(int i = 0; i < n; i++){
      prices[i] = sc.nextInt();
    }
    Arrays.sort(prices);
    for(int i = 0; i < k; i++){
      sum += prices[i];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 38984
#include <bits/stdc++.h>
using namespace std;
string s;
int cnt[26];
vector<char>v;
int main(){
    cin>>s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout<<-1<<endl;
        return 0;
    }
    if(s.size()!=26){
        for(int i=0;i<s.size();i++)cnt[s[i]-'a']=1;
        for(int i=0;i<26;i++){
            if(cnt[i]!=1){
                cout<<s<<(char)('a'+i)<<endl;
                return 0;
            }
        }
    }
    v.push_back(s[25]);
    for(int i=24;i>=0;i--){
        sort(v.begin(),v.end());
        if(s[i]<s[i+1]){
            if(i==0){
                cout<<(char)(s[0]+1)<<endl;
                return 0;
            }
            cout<<s.substr(0,i);
            for(int j=0;j<v.size();j++){
                if(s[i]<v[j]){
                    cout<<v[j]<<endl;
                    return 0;
                }
            }
        }
        v.push_back(s[i]);
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

string st;
int a;
vector<int>nums;
int calc(const int a, const char c, const int b) {
	if (c == '-') {
		return 2 - a;
	}
	else if (c == '*') {
		return min(a, b);
	}
	else if (c == '+') {
		return max(a, b);
	}
	else {
		assert(false);
	}
}
int getnum() {
	if (isdigit(st[a])) {
		int num = st[a] - '0';
		a++;
		return num;
	}
	else {
		int num = nums[st[a] - 'P'];
		a++;
		return num;
	}
}

int getform() {
	if (st[a] == '-') {
		a++;
		int num = getform();
		return calc(num, '-', num);
	}
	else if (st[a] == '(') {
		a++;
		int num = getform();
		char c = st[a];
		a++;
		int anum = getform();
		assert(st[a] == ')');
		a++;
		return calc(num, c, anum);
	}
	else {
		return getnum();
	}
}
int solve() {
	int correct = 0;
	for (int i = 0; i < 27; ++i) {
		{
			int n(i);
			for (int j = 0; j < 3; ++j) {
				nums[j] = n % 3;
				n /= 3;
			}
		}
		a = 0;
		int ans = getform();
		if (ans == 2)correct++;
	}
	return correct;
}
int main() {
	nums.resize(3);
	while (1) {
		cin >> st;
		if (st == ".")break;
		int ans = solve();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
using System;

class Program
{
    static void Main () 
    {
        String[] inline = Console.ReadLine().Split(' ');
        long x = long.Parse(inline[0]);
        long y = long.Parse(inline[1]);
        String ans = "No";

        if (y % 2 == 0 && x * 4 >= y && x * 2 <= y)
        {
            ans = "Yes";
        }

        Console.WriteLine(ans);
    }
}

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

int main() {
    int n, m;
    cin >> n >> m;
    unsigned dp[1 << n], a[m];
    bitset<13> key[m];
    for (int i = 0, b; cin >> a[i] >> b; i++) {
        for (int j = 0, c; j < b; j++) {
            cin >> c;
            key[i][c - 1] = true;
        }
    }
    dp[0] = 0;
    for (int i = 1; i < 1 << n; i++) {
        dp[i] = -1;
        bitset<13> current(i);
        for (int j = 0; j < m; j++) {
            auto prev = key[j];
            prev.flip();
            prev = current & prev;
            if (prev != current && dp[prev.to_ulong()] != -1) {
                dp[i] = min(dp[i], dp[prev.to_ulong()] + a[j]);
            }
        }
    }
    cout << (int)dp[(1 << n) - 1];
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int d[303][303];
bool d_n[303][303];

int main(void){
  int n;
  cin >> n;

  long long ans = 0;
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      cin >> d[i][j];
    }
  }
  for(int k=0; k<n; k++){
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){

        if(d[i][j] > d[i][k] + d[k][j]){
          cout << "-1" << endl;
          return 0;
        }

        if(d[i][j] == d[i][k] + d[k][j] && d[i][k] > 0 && d[k][j] > 0){
          d_n[i][j] = true;
        }

      }
    }
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<=i; j++){

      if(d_n[i][j] == false){
        ans += d[i][j];
      }

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

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
    
    int a,b,c,d,e;
    cin>>a>>b;
    for(int i=0;i<=a;i++) {
        if(((i*2)+(a-i)*4)==b){
        cout<<"Yes";
        return 0;}
    }
    
    cout<<"No";
	return 0; 
} 


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<set>
using namespace std;

int main(){
  int i,size;
  vector<string> word;
  vector<int> page;
  string tmpw;
  int tmpp;
  set<string> idw;
  set<int> idp;

  while(cin >> tmpw >> tmpp){
    word.push_back(tmpw);
    page.push_back(tmpp);
  }

  size = word.size();
  for(i=0;i<size;i++)idw.insert(word[i]);

  size = page.size();
  set<string>::iterator itw = idw.begin();
  while(itw!= idw.end()){
    cout << *itw<< endl;
    for(i=0;i<size;i++){
      if(*itw== word[i]){
	idp.insert(page[i]);
      }
    }
    set<int>::iterator itp = idp.begin();
    int flag = 0;
    while(itp != idp.end()){
      if(flag)cout << " " << *itp;
      else cout << *itp;
      flag = 1;
      itp++;
    }
    cout << endl;
    idp.clear();
    itw++;
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define N 100

void trace(int num[],int n){
  int i;

  for(i = 1;i <= n;i++){
    if(i > 1) printf(" ");
    printf("%d",num[i]);
  }
  
  printf("\n");
}

int main(){
  int i,j,n,num[N + 1],a;

  scanf("%d",&n);
  
  for(i = 1;i <= n;i++) scanf("%d",&num[i]);

  trace(num,n);

  for(i = 2;i <= n;i++){
    a = num[i];
    j = i - 1;
    while(j > 0 && num[j] > a){
      num[j + 1] = num[j];
      j--;
    }
    num[j + 1] = a;

    trace(num,n);
  }

  return 0;
}




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

int main(){
  int a,b;
  cin>>a>>b;
  char c='0'+a ,d='0'+b;
  string x(a,d),y(b,c);
  if(x<y)cout<<x<<endl;
  else cout<<y<<endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    vector<lint> a(n);
    for(auto &i: a) scanf("%lld", &i);
    sort(a.begin(), a.end());
    vector<pll> p(m);
    for(auto &i: p) scanf("%lld%lld", &i.fi, &i.se);
    sort(p.begin(), p.end(), [](const pll &p1, const pll &p2){return p1.se > p2.se;});

    int cur = 0;
    lint ans = 0;
    rep(i, n){
        if(cur == m) ans += a[i];
        else if(a[i] >= p[cur].se) ans += a[i];
        else{
            ans += p[cur].se;
            --p[cur].fi;
            if(p[cur].fi == 0) ++cur;
        }
    }
    printf("%lld\n", ans);
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

double a, b, x;
int main(void){
    cin >> a >> b >> x;
    if(2*x > a*a*b) printf("%.10f\n", atan(2*(a*a*b-x) / (a*a*a)) * 180.0 / M_PI);
    else printf("%.10f\n", atan(a*b*b / (2*x)) * 180.0 / M_PI);
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
int main() {
  int N, M, a, b;
  cin >> N >> M;
  set<int> p, q;
  while (cin >> a >> b) if (a == 1) p.insert(b); else if (b == N) q.insert(a);
  cout << (any_of(begin(p), end(p), [&](int x) { return q.count(x); })
               ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


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

using namespace std;

int n, k, a[1005];

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    int ans = 0;
    for (int i = 1; i <= k; i++) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
    int n, x;    
    cin >> n;

    vector<PI> v;
    FOR(i, n){
        cin >> x;
        v.push_back({x, i+1});
    }

    sort(ALL(v));
    for(PI p:v){
        cout << p.second << " ";
    }

    return 0;
}



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

using namespace std;

typedef long long ll;

ll cmmdc(ll a, ll b) {
    return b == 0 ? a : cmmdc(b, a % b);
}
static int def = (int)1e5+10;

int main()
{
    ll nr,i,j,start;
    cin >> nr>>start;
    ll arr[def];
    arr[0]= start;
    for(i = 1 ; i<= nr; i++){
        cin >>arr[i];
    }
    sort(arr,arr+nr+1);
    ll rasp = arr[1]-arr[0];
    for(i = 2 ; i<= nr; i++){
        rasp = cmmdc(rasp,arr[i]-arr[i-1]);
    }
    cout<<rasp<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(int, k);
    
    ll ans = 0;
    for(int b = k+1; b <= n; b ++){
        auto a = ans;
        ans += n/b * (b-k) + ((n%b >= k) ? n%b-k+1 : 0) - ((k == 0) ? 1 : 0);
    }
    Cout(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  ll n; cin >> n;
  cout << n*(n-1LL)/2LL << endl;
  return 0;
}


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

namespace sentou
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] s = Console.ReadLine().Split(' ');
            String[] ss = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int t = int.Parse(s[1]);
            int[] a = new int[n];

            for(int i = 0; i < n; i++){
                a[i] = int.Parse(ss[i]);
            }

            int ans = t;
            for(int i = 0; i < n - 1; i++){
                if(a[i+1]-a[i] < t){
                    ans += a[i+1] - a[i];
                }else if(a[i+1]-a[i] >= t){
                    ans += t;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 26208
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int r = 0;
        for (int i = 1; i <= N; i++) {
            int sum = 0;
            for (int j = 1; j <= i; j++) {
                if (j % 2 != 0 && i % j == 0) {
                    sum++;
                }
            }
            if (sum == 8) r++;
        }
        System.out.println(r);
    }
}

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


from collections import deque
def bfs(maze, dist, sy, sx):
    d = deque()
    d.append([sy, sx])
    while d:
        y, x = d.popleft()
        for dy, dx in [1, 0], [-1, 0], [0, 1], [0, -1]:
            ny = y + dy
            nx = x + dx
            if ny < 0 or ny >= H or nx < 0 or nx >= W:
                continue
            if maze[ny][nx] == '#':
                continue
            if dist[ny][nx] == -1:
                dist[ny][nx] = dist[y][x] + 1
                d.append([ny, nx])

ans = -1
for sy in range(H):
    for sx in range(W):
        if maze[sy][sx] == '#':
            continue
        dist = [[-1] * W for _ in range(H)]
        for gy in range(H):
            for gx in range(W):
                if maze[gy][gx] == '#':
                    continue
                dist[sy][sx] = 0
                bfs(maze, dist, sy, sx)
                ans = max(ans, dist[gy][gx])
print(ans)



Measured memory_bytes: 50396
import java.util.ArrayDeque;
import java.util.Deque;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int w = Integer.parseInt(br.readLine());
        
        for (int i = 0; i < s.length(); i++) {
            if (i % w == 0) {
                System.out.print(s.charAt(i));
            }
        }
        System.out.println("");
    }
}


Measured memory_bytes: 20436
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm> // sort

using namespace std;

int main(){
    int N;
    string S,res;

    cin >> N;

    for(int i = 0; i < N; i++)
    {
        cin >> S;
        if(S == "Y")
        {
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;
int main()
{
    string s;
    cin>>s;
    bool isgood = true;
    if(s[0] == s[1]){
        isgood = false;
    }
    if(s[1] == s[2]){
        isgood = false;
    }
    if(s[2] == s[3]){
        isgood = false;
    }
    
    if(isgood ){
        cout<<"Good";
    }
    else{
        cout<<"Bad";
    }

    return 0;
}

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

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  int N, K; cin >> N >> K;

  double ans = 0;

  for (int i = 1; i <= N; i++)
  {
    double point = 1;
    int num = i;
    int count = 1;
    while (num < K) {
      num *= 2;
      count *= 2;
    }
    ans += point / count;
  }

  ans /= N;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
long long p[110000];
long long q[110000];
int pd[110000];
int qd[110000];
vector<pair<int,int> >row[110000];
vector<pair<int,int> >col[110000];
int cost[110000];
int v[110000];
int R[110000];
int C[110000];
int rind[110000];
int cind[110000];
int V[110000];
bool dame=false;
long long WP=999999999999999LL;
long long WQ=999999999999999LL;

void dfs(int u,long long a,long long b){
	int r=R[u];
	int c=C[u];
	v[u]=1;
	WP=min(WP,a);
	WQ=min(WQ,b);
	if(pd[r]){
		if(p[r]!=a)dame=true;
	}else{
		pd[r]=1;
		p[r]=a;
	}
	if(qd[c]){
		if(q[c]!=b)dame=true;
	}else{
		qd[c]=1;
		q[c]=b;
	}
	if(rind[u]){
		int to=row[r][rind[u]-1].second;
		if(!v[to]){
			dfs(to,a,b+V[to]-V[u]);
		}
	}
	if(rind[u]+1<row[r].size()){
		int to=row[r][rind[u]+1].second;
		if(!v[to]){
			dfs(to,a,b+V[to]-V[u]);
		}
	}
	if(cind[u]){
		int to=col[c][cind[u]-1].second;
		if(!v[to]){
			dfs(to,a+V[to]-V[u],b);
		}
	}
	if(cind[u]+1<col[c].size()){
		int to=col[c][cind[u]+1].second;
		if(!v[to]){
			dfs(to,a+V[to]-V[u],b);
		}
	}
	
}
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<c;i++){
		int s,t,u;
		scanf("%d%d%d",&s,&t,&u);
		s--;t--;
		R[i]=s;C[i]=t;V[i]=u;
		cost[i]=u;
		row[s].push_back(make_pair(t,i));
		col[t].push_back(make_pair(s,i));
	}
	for(int i=0;i<a;i++)std::sort(row[i].begin(),row[i].end());
	for(int i=0;i<b;i++)std::sort(col[i].begin(),col[i].end());
	for(int i=0;i<a;i++){
		for(int j=0;j<row[i].size();j++){
			rind[row[i][j].second]=j;
		}
	}
	for(int i=0;i<b;i++){
		for(int j=0;j<col[i].size();j++){
			cind[col[i][j].second]=j;
		}
	}
	
	for(int i=0;i<c;i++){
		if(v[i])continue;
		WP=WQ=99999999999999999LL;
		dfs(i,V[i],0);
		if(WP+WQ<0)dame=true;
	}
	for(int i=0;i<c;i++){
		if(V[i]!=p[R[i]]+q[C[i]])dame=true;
	}
	if(dame){
		printf("No\n");return 0;
	}
	/*long long wp=99999999999999999LL;
	long long wq=99999999999999999LL;
	for(int i=0;i<a;i++)if(pd[i])wp=min(wp,p[i]);
	for(int i=0;i<b;i++)if(qd[i])wq=min(wq,q[i]);
	if(wp+wq<0){
		printf("No\n");
	}else */printf("Yes\n");
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int H[N]; rep(i, N) cin >> H[i];
    sort(H, H+N);
    int ans = INF;
    for(int i = 0; i+K-1 <= N-1; i++){
        ans = min(ans, H[i+K-1]-H[i]);
    }
    cout << ans << endl;
    return 0;
}

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

const int mod = 1000000007;

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

mint dp[101][4][4][4];

int main(){
    int n;
    cin >> n;
    dp[0][3][3][3] = 1;
    for(int i = 0; i < n; i++){
        rep(j,4)rep(k,4)rep(l,4){
            rep(n,4){
                if(j == 0) {
                    if(n == 2){
                        if(k == 1)continue;
                        if(l == 1)continue;
                    }
                }
                if(k == 0){
                    if(l == 1 && n == 2) continue;
                    if(l == 2 && n == 1) continue;
                }
                if(k == 1){
                    if(l == 0 && n == 2) continue;
                }
                dp[i+1][k][l][n] += dp[i][j][k][l];
            }
        }
    }
    mint ans=mint(0);
    rep(i,4)rep(j,4)rep(k,4) ans += dp[n][i][j][k];
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3628
#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.at(i);}

  vector<int> dp(pow(10,5)+10, 0);
  rep(i, n){
    dp.at(a.at(i))++;
    dp.at(a.at(i)+1)++;
    dp.at(a.at(i)+2)++;
  }

  int ans = *max_element(dp.begin(), dp.end());
  cout << ans << endl;
}

Measured memory_bytes: 1024
a, b, k = map(int,input().split())

turn_flag = True
for i in range(k):
    if turn_flag == True:
        if a % 2 != 0:
            a -= 1
        a /= 2
        b += a
    else:
        if b % 2 != 0:
            b -= 1
        b /= 2
        a += b
    turn_flag = ~turn_flag
print(int(a), int(b))

Measured memory_bytes: 3060
A, B, C, D, E, F = map(int, input().split())

ret_w = 1
ret_s = -1
for a in range(F // (100 * A) + 1):
    w_a = a * A * 100
    for b in range((F - w_a) // (100 * B) + 1):
        if a + b == 0:
            continue
        w_b = b * B * 100

        max_suger = min(F - w_a - w_b, (w_a + w_b) // 100 * E)
        for c in range(max_suger // C + 1):
            s_c = c * C
            for d in range((max_suger - s_c) // D + 1):
                s_d = d * D
                if ret_s / ret_w < (s_c + s_d) / (w_a + w_b + s_c + s_d):
                    ret_s = s_c + s_d
                    ret_w = ret_s + w_a + w_b

print(ret_w, ret_s)



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

int main(){
  int N,A,result,count;
  cin >> N;
  for (int i=1;i<N+1;i++){
    int a=i;
    while(a%2==0){
      a /=2;
      count++;
    }
    if(count>=result){
      A = i;
      result=count;
    }
    count =0;
  }
      
  cout << A << endl;
}

Measured memory_bytes: 256
#(38)ICP得点集計ソフトウェア
while True:
     n=int(input())
     if n==0:
          break
     s=[int(input()) for i in range(n)]
     a=max(s)
     b=min(s)
     c=sum(s)
     d=(c-a-b)//(n-2)
     print(d)


Measured memory_bytes: 5604
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;

	vector<int> next;
	vector<vector<int>> A;
	for (auto i = 0; i < N; ++i)
	{
		vector<int> temp(N - 1);
		for (auto j = 0; j < N - 1; ++j)
		{
			int a;
			cin >> a;
			temp[N - 2 - j] = a - 1;
		}
		A.push_back(temp);
		next.push_back(i);
	}

	auto cnt = 0;
	while (!next.empty())
	{
		vector<int> list = next;
		next.clear();

		set<int> s;
		auto isCheck = false;
		for (auto i : list)
		{
			if (cnt > 0)
			{
				A[i].pop_back();
			}

			if (A[i].empty())
			{
				continue;
			}

			if (s.find(i) != s.end())
			{
				continue;
			}
			isCheck = true;

			auto j = *A[i].rbegin();
			if (i == *A[j].rbegin())
			{
				next.push_back(i);
				next.push_back(j);
				s.insert(i);
				s.insert(j);
			}
		}

		if (isCheck)
		{
			if (next.empty())
			{
				cnt = -1;
				break;
			}
			else
			{
				++cnt;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 4224
if __name__ == '__main__':
    d = {}
    
    N = int(input())
    for si in range(N):
        si = input()
        if si in d.keys():
            d[si] += 1
        else:
            d[si] = 1
            
    M = int(input())
    for ti in range(M):
        ti = input()
        if ti in d.keys():
            d[ti] -= 1
        else:
            d[ti] = -1
    
    X = max(d.values())
    if X > 0:
        print(X)
    else:
        print(0)

Measured memory_bytes: 3064
#include "iostream"

using namespace std;
long long int N;
long long int num;


int main() {
	cin >> N;
	for (long long int i = 1; i <= N; i++) {
		if (i*(i + 1) / 2 >= N) {
			num = i;
			break;
		}
	}
	for (long long int i = 1; i <= num; i++) {
		if (N != (num + 1)*num / 2 - i) {
			cout << i << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

real[12][1<<12] dp;
int[] cakes;
int n;

real saiki(int u,int v){
    if(dp[u][v] > 0) return dp[u][v];
    if( u == ((1<<n) - 1)) return cakes[v];

    real res = 10000000;
    for(int i=0;i<n;i++){
	if(( (1<<i) & u ) == 0){
	    res = min(res,saiki(u | (1<<i) ,i) + 2.0 * sqrt(to!real(cakes[i]*cakes[v]) )); 
	}
    }
    return dp[u][v] = res;
}

void main(){

    while(true){
	string s = readln();
	if(stdin.eof()) break;
	dp = new real[12][1<<12];
	auto s1 = s.split().to!(int[]);
	n = to!int(s1.length) - 1;
	cakes = (s1[1..$]).dup();
	cakes ~= 0;
	real ans = 1e8;
	for(int i=0;i<n;i++){
	    ans = min(saiki(1<<i,i) + cakes[i],ans);
	}
	writeln(ans <= s1[0] ? "OK" : "NA");

    }

}

Measured memory_bytes: 7652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if (a[0]==5 && a[1]==5 && a[2]==7) {
    cout << "YES";
  }
  else
    cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=3000+3;
const ll mod=1e9+7;
string x,y;
ll n,m;
string  fun()
{
    ll dp[MAX][MAX],i,j,c=1;
    memset(dp,0,sizeof(dp));
   /* for(i=0;i<=n;i++)
    {

           dp[i][0]=0;

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

           dp[0][i]=0;
    }*/
    for(i=1;i<=n;i++)
    {
       // cout<<"ram";
        for(j=1;j<=m;j++)
        {
            if(x[i-1]==y[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);

        }
    }
    /*for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            cout<<dp[i][j]<<" ";

        }
        cout<<endl;
    }*/
    string s="";
    for(i=n,j=m;i>0;)
    {
        for(;j>0;)
        {
            if(x[i-1]==y[j-1])
            {
                s+=x[i-1];
                i--;
                j--;
                break;
            }
            else if(dp[i][j]==dp[i][j-1])
            {
               j--;
            }
            else if(dp[i][j]==dp[i-1][j])
            {
                i--;
                break;
            }
        }
        if(j==0)
            break;
    }
    reverse(all(s));
    return s;
}

int main()
{
   //FASTIO
   int t=1;
  // cin>>t;
   while(t--)
  {
       // ll n,k;

      cin>>x>>y;
      n=x.size();m=y.size();
        string  ans=fun();
        cout<<ans;

   }
 return 0;
}


Measured memory_bytes: 70784
import math
N=int(input())

for h in range(1,3501):
    for n in range(1,3501):
        x,y=N*h*n,4*h*n-n*N-h*N
        if y==0:
            continue
        w=x/y
        if w>0 and math.floor(w)==math.ceil(w):
            print(h,n,math.floor(w))
            exit()

Measured memory_bytes: 40684
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n

dp[1] = abs(h[0] - h[1])
for i in range(n - 2):
    dp[i + 2] = min(dp[i] + abs(h[i] - h[i + 2]), dp[i + 1] + abs(h[i + 1] - h[i + 2]))
print(dp[n - 1])

Measured memory_bytes: 13928
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    q = int(input())
    cnt = [0]*(10**5+7)
    for i in range(n):
        cnt[a[i]]+=1
    ruiseki = sum(a)
    for i in range(q):
        b,c = map(int,input().split())
        d = cnt[b]
        e = d*(c-b)
        cnt[c] += d
        cnt[b] -= d
        ruiseki += e
        print(ruiseki)

Measured memory_bytes: 21336
N = int(input())

shiritori_set = set()

shiritori = input()
head = shiritori[len(shiritori) -1]

ans = "Yes"
shiritori_set.add(shiritori)
for i in range(N-1):
  shiritori = input()
  if shiritori[0] == head and shiritori not in shiritori_set:
    head = shiritori[len(shiritori)-1]
    shiritori_set.add(shiritori)
  else:
    ans = "No"
    break

print(ans)

Measured memory_bytes: 3064