akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main()
{
	for(;;){
		char henkan[100000][2];
		char str[100000];
		int n,m;
		char temp;
		bool flg = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			cin >> henkan[i][0] >> henkan[i][1];
		}
		/*
		for(int i = 0; i < n; i++){
			cout << henkan[i][1] << endl;
		}
		*/
		
		cin >> m;
		
		for(int i = 0; i < m; i++){
			cin >> str[i];
		}
		
		for(int i = 0; i < m; i++){
			flg = 0;
			for(int j = 0; j < n; j++){
				if(str[i] == henkan[j][0]){
					temp = henkan[j][1];
					flg = 1;
				}
			}
			if(flg == 1){
				printf("%c",temp);
			}
			else{
				printf("%c",str[i]);
			}
		}
		cout << endl;
	}
}
		

Measured memory_bytes: 948
n = gets.to_i
as = n.times.map{gets.to_i}.sort
corrent = as.shift
res = 1
ans = 0
as.each do |a|
  if corrent == a
    res += 1
  else
    ans += 1 if res.odd?
    corrent = a
    res = 1
  end
end
ans += 1 if res.odd?
puts ans


Measured memory_bytes: 4528
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            
            var h = cin.nextInt();
            var a = cin.nextInt();

                       

            
            Console.WriteLine((h +(a - 1)) / a);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
package main

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

const max int = 44
var ans []int = make([]int, max+1)

func generateFib() {
	ans[0] = 1
	ans[1] = 1
	for i:=2; i<=max; i++ {
		ans[i] = ans[i-1] + ans[i-2]
	}
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	i := nextInt(scanner)
	generateFib()
	fmt.Printf("%d\n", ans[i])
}


Measured memory_bytes: 1092
H, W = map(int, input().split())

def WarshallFloyd(lst):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                lst[i][j] = min(lst[i][j], lst[i][k] + lst[k][j])
#i --> 0　への最短経路問題
c = [list(map(int, input().split())) for _ in range(10)]
WarshallFloyd(c)

A = [list(map(int, input().split())) for _ in range(H)]

ans = 0
for i in A:
    for j in i:
        if j == -1:
            pass
        else:
            ans += c[j][1]

print (ans)


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <set>
#include <algorithm>

using namespace std;

int main(void){
    int N,tmp;
    scanf("%d", &N);
    set<int> A;

    for(int i = 0; i < N; i++){
        scanf("%d", &tmp);
        A.insert(tmp);
    }

    cout << A.size() << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
main()
{
    fast;
    ll t;
     t =1;
    while(t--)
    {
        ll n;
        cin>>n;
        if(n%1000 == 0)
        {
            cout<<"0"<<"\n";
            continue;
        }
        cout<<1000 - n%1000<<"\n";
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int n;
  cin>>n;
  long long a[n];
  long long s[n];
  REP(i,n){
    cin>>a[i];
    if(i==0){
      s[i]=a[i];
    }else{
      s[i]=s[i-1]+a[i];
    }
  }
  
  long long ans=inf;
  long long x;
  long long y;
  REP(i,n-1){
    x = s[i];
    y = s[n-1]-s[i];
    ans = min(ans,abs(x-y));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3328
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab.sort()
p = [0]*n
for i in range(q):
  a, b = map(int, input().split())
  p[a - 1] += b
s = ""
for i in ab:
  p[i[1]-1] += p[i[0]-1]
print(*p)

Measured memory_bytes: 66632
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll x, y;
    cin >> x >> y;
    cout << (llabs(x-y) > 1 ? "Alice\n" : "Brown\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
ll power(ll x, ll n) {
    ll res = 1;
    for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    }
    return res;
}

int main()
{

  IOS
  ll n;
  cin>>n;
  map<string,ll> m;
  ll maxi =0;
  for(ll i=0;i<n;i++)
  {
    string s;
    cin>>s;
    m[s]++;
    maxi = max(maxi,m[s]);
  }
  for(auto i:m)
  {
    if(i.ss == maxi)
    {
      cout<<i.ff<<endl;
    }
  }
  
  
  
  
  
  
  

}

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


int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll>a[m];
  for(int i=0; i<n; i++){
    ll b,c;
    cin >> b >> c;
    if(b>m)continue;
    a[m-b].push_back(c);
  }
  priority_queue<ll>que;
  ll ans=0;
  for(int i=m-1; i>=0; i--){
    for(int b : a[i]) que.push(b);
    if(!que.empty()){
      ans += que.top();
      que.pop();
    }
  }
  
  
  cout << ans << endl;
}
  
  
  


Measured memory_bytes: 5632
#include<stdio.h>
#define MAX 500001

void maxHeapify(int *,int);
int left(int);
int right(int);


int H;


int main(){
  int i,A[MAX];
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--)
    maxHeapify(A,i);
  for(i=1;i<=H;i++)
    printf(" %d",A[i]);
  printf("\n");
  return 0;

}


void maxHeapify(int A[],int i)
{
  int l, r, largest,tmp;
  l=left(i);
  r=right(i);

  if(l<=H && A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=H&&A[r]>A[largest])
    largest=r;

  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(A,largest);
  }

}

int left(int n){
  return n*2;
}

int right(int n){
  return n*2+1;
}



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

int main() {
    int n, m, c; cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b.at(i);
    vector<vector<int>> a(n, vector<int>(m));

    rep(i, n) {
        rep(j, m) {
            cin >> a.at(i).at(j);
        }
    }

    int ans = 0;
    int sum;
    rep(i, n) {
        sum = 0;
        rep(j, m) {
            sum += a.at(i).at(j) * b.at(j);
        }
        if (sum + c > 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric
import Data.Char

main :: IO ()
main = do
  { ln <- getLine
  ; putStrLn (map conv ln)
  }

conv :: Char -> Char
conv c | isLower c = toUpper c
       | otherwise = toLower c 
  
    
--

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 3920
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

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

    if (x == 0)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}

ll arr[55];
int main()
{ 
  IOS;

ll x,n;
cin>>x>>n;

ll val=1e8,ans=-1;

set<ll>s;

for(int i=0;i<n;i++){
  ll x;cin>>x;
  s.insert(x);
}

for(ll i=-1000;i<=1000;i++){
  if(!s.count(i)){
    if(abs(x-i)<val){
      ans=i;
      val=abs(x-i);
    }
  }
}

cout<<ans<<endl;

 return 0;

 
 
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n;
    cin >> n;
    vec<int> v(100000+1);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        v.at(a)++;
        v.at(a+1)++;
        if (a!=0)
        {
            v.at(a-1)++;
        }
    }
    cout << *max_element(v.begin(),v.end()) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

int main(void)
{
	char a;
	cin >> a;

	cout << char(a+1) << endl;

	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val Seq(a, b, c): Seq[Int] = io.StdIn.readLine().split(' ').map(_.toInt)

    val ls = for(i <- 1 to b) yield (a * i) % b
    val ans = ls.find(_ == c) match {
      case Some(_) => "YES"
      case _ => "NO"
    }
    println(ans)
  }
}

Measured memory_bytes: 25424
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
const int maxn = 2e5+5;
typedef long long ll;
int a[maxn];
int main(void)
{
	int k, n;
	scanf("%d %d", &k, &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(a, a + n);
	int Max = a[0] + k - a[n - 1];
	for (int i = 1; i < n; i++) {
		int dis = a[i] - a[i - 1];
		dis = min(dis, k - dis);
		Max = max(Max, dis);
	}
	printf("%d\n", k - Max);
	return 0;
}

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  ll x;
  cin>>x;
  for(ll i=0; i<=10000; ++i){
    for(ll j=0; j<=10000; ++j){
      if(i*i*i*i*i-j*j*j*j*j==x){
        cout<<i<<' '<<j<<'\n';
        return 0;
      }
      if(i*i*i*i*i+j*j*j*j*j==x){
        cout<<i<<' '<<-j<<'\n';
        return 0;
      }
    }
  }
  return 0;
}


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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    string s;
    cin>>s;
    rep(i,0,sz(s)-1){
        if(s[i]=='7'){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;
	if( a != c ) cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main(int argc, char const *argv[])
{
	ll int a;
	cin>>a;

	std::vector<int> v(a);
	for (int i = 0; i < a; ++i)
	{
		cin>>v[i];
		/* code */
	}

	int curr=1;
	for(auto x:v){
		if(x==curr){
			curr++;
		}
	}
	if(curr==1){
		cout<<"-1"<<endl;
	}
	else{
		cout<<a-curr+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
def is_prime(n):
    if n <= 1:
        return False
    elif n == 2:
        return True
    else:
        for i in range(2, int((n**(1/2)))+1):
            if n % i == 0:
                return False
        return True

from collections import Counter
N = int(input())
MOD = 10**9+7

primes = [i for i in range(N+1) if is_prime(i)] # N以下の素数

c = Counter(primes) # 各素数で何回割れるかを記録する
                    # 最後に約数の個数を求める時、
                    # (各素因数の指数+1)を掛け合わせるので1で初期化されるCounterは都合が良い

for j in range(2, N+1):
    for prime in primes:
        while j % prime == 0:
            j //= prime
            c[prime] += 1

ans = 1
for cnt in c.values():
    ans *= cnt # 初期値が1なので1を足す必要はない
print(ans%MOD)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		while(true){
			int N=cin.nextInt();
			if(N==0)break;
			N++;
			int[] a=new int[N];
			for(int i=0;i<N;i++){
				a[i]=cin.nextInt();
			}
			for(int i=0;i<N;i++){
				int diff=0;
				if(i>2){
					diff=a[1]-a[0];
				}
				else{
					diff=a[a.length-1]-a[a.length-2];
				}
				boolean ans=true;
				for(int j=0;j<N-1;j++){
					if(j+1!=i&&j!=i){
						if(diff!=a[j+1]-a[j]){
							ans=false;
							break;
						}
					}
					else if(j+1==i){
						if(j+2>=N)continue;
						if(diff!=a[j+2]-a[j]){
							ans=false;
							break;
						}
					}
					else if(j==i){
						
					}
				}
				
				if(ans){
					System.out.println(a[i]);
					break;
				}
				
			}
		}

	}

}

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

int main() {
  ll a,b,t,ans=0;
  cin >> a >> b >> t;
  ans=t/a*b;
  cout << ans << endl;
}


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

using namespace std;

int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (i <= S.size() - 2) {
			if (S[i] == S[i + 2]) {
				cout << i + 1 << " " << i + 3 << endl;
				return 0;
			}
		}
		if (i <= S.size() - 1) {
			if (S[i] == S[i + 1]) {
				cout << i + 1 << " " << i + 2 << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

const int inf = 1e9;

int main(){
    int n,m,X;
    cin>>n>>m>>X;
    vi C(n);
    vvi a(n, vi(m));

    int min_mask = -1;
    int min_cost = inf;

    forn(i,n){
        cin>>C[i];
        forn(j,m) cin>>a[i][j];
    }
    // print_vv(a);

    for(int mask=0; mask<(1<<n); ++mask){
        int cost = 0;
        vi filled(m);
        for(int i=0; i<n; ++i){
            if((mask>>i)&1){
                cost+=C[i];
                forn(j,m){
                    filled[j]+=a[i][j];
                }
            }
        }

        bool valid = true;
        forn(j,m){
            valid&=(filled[j]>=X);
        }

        if(valid && cost<min_cost){
            min_cost = cost;
            min_mask = mask;
        }
    }

    if(min_cost==inf){
        cout<<-1<<endl;
        return 0;
    }
    cout<<min_cost<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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; }

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 { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

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

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int n;
	cin >> n;
	vector<char> k;
	k.push_back('a');

	vector<pair<int, string>> before;
	vector<pair<int, string>> ans;

	//n =1
	pair<int, string> check = make_pair(1, "a");
	before.push_back(check);
	if (n == 1)
	{
		cout << "a";
		return 0;
	}
	for (int i = 2; i <= n; i++)
	{
		for (auto a : before)
		{
			for (int j = 0; j < i; j++)
			{
				pair<int, string> tmp = a;
				if (tmp.first >= j)
				{
					tmp.first = max(tmp.first, j + 1);
					tmp.second += (char)('a' + j);
					ans.push_back(tmp);
				}
			}
		}
		before = ans;
		ans.clear();
	}
	for (auto ans : before)
	{
		cout << ans.second << endl;
	}
}


Measured memory_bytes: 43172
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int A=0,B=0,C=0,D=0;
    int N;
    cin >> N;
    int P[4]={0};
    int res=0;
    while(N>0){
        P[res]=N%10;
        N=N/10;
        ++res;
    }
    D=P[0];
    C=P[1];
    B=P[2];
    A=P[3];
    char op1='+',op2='+',op3='+';
    if(A+B+C+D==7){
        op1='+';
        op2='+';
        op3='+';
    }
    if(A-B+C+D==7){
        op1='-';
        op2='+';
        op3='+';
    }
    if(A+B-C+D==7){
        op1='+';
        op2='-';
        op3='+';
    }
    if(A+B+C-D==7){
        op1='+';
        op2='+';
        op3='-';
    }
    if(A-B-C+D==7){
        op1='-';
        op2='-';
        op3='+';
    }
    if(A+B-C-D==7){
        op1='+';
        op2='-';
        op3='-';
    }
     if(A-B+C-D==7){
        op1='-';
        op2='+';
        op3='-';
    }
    if(A-B-C-D==7){
        op1='-';
        op2='-';
        op3='-';
    }
    cout << A << op1 << B << op2 <<  C << op3 << D << "=" << 7;
}

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

L = {}
for i in range(N):
    n = int(input())
    if n-1 in L:
        L[n] = L.pop(n-1)
        L[n] += 1
    else:
        L[n] = 1
    
ans = N
for k,v in L.items():
    if N-v < ans:
        ans = N-v
        
print(ans)

Measured memory_bytes: 27020
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int n = sc.nextInt();

		int[] B = new int[n];
		int minus = 0;
		boolean flg = true;

		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			if(a<0){
				a = -a;
				minus++;
			} else if(a==0){
				flg = false;
			}
			B[i] = a;
		}

		if(minus%2==1&&flg){
			Arrays.sort(B);
			B[0]=-B[0];
		}

		long sum = 0;

		for(int i=0;i<n;i++){
			sum += B[i];
		}

		// 出力
		System.out.println(sum);
	}
}


Measured memory_bytes: 53048
#include <stdio.h>
int main(void)
{
  int i;
  int n;
  int a[50];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int b=0;
  for(i=0;i<n;i++){
    if(a[i]!=i+1){
      b++;
    }
  }
  if(b<=2)
    printf("YES");
  else
    printf("NO");
  return 0;
}
  


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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int N, K, L; cin >> N >> K >> L;
    UnionFind uf1(N), uf2(N);
    for (int i = 0; i < K; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        uf1.merge(a, b);
    }
    for (int i = 0; i < L; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        uf2.merge(a, b);
    }

    using pint = pair<int,int>;
    map<pint, int> ma;
    for (int v = 0; v < N; ++v) {
        pint p(uf1.root(v), uf2.root(v));
        ma[p]++;
    }

    for (int v = 0; v < N; ++v) {
        pint p(uf1.root(v), uf2.root(v));
        cout << ma[p] << " ";
    }
}


Measured memory_bytes: 13568
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  int n; cin >> n;
  
  double res = 0.0;
  for(int i = 0; i  < n; i++)
  {
	int t; cin >> t;
    res += 1.0/(double)t;
  }
  printf("%.9lf\n", 1.0/res);
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 k, a, b;
    cin >> a >> b >> k;
    i64 t = min(k, a);
    a -= t;
    b -= min(b, k - t);
    cout << a << ' ' << b << endl;
}

int main()
{
    solve();
    return 0;
}


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

int main(){
    char a,b;
    cin >> a >> b;
    if(a!=b)    cout << (a>b?'>':'<') << endl;
    else cout << '=' << endl;


}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
n = int(input())
class Node:
  def __init__(self,v):
    self.p = None
    self.key = v
    self.left = None
    self.right = None

sys.setrecursionlimit(1500)
r = None
def insert(z):
  global r
  y = None
  x = r
  while x != None:
    y = x
    if z.key < x.key:
      x = x.left
    else:
      x = x.right
  z.p = y

  if y == None:
    r = z
  elif z.key < y.key:
    y.left = z
  else:
    y.right = z

ret = []
def inorder(r):
  if r == None: return
  inorder(r.left)
  ret.append(r.key)
  inorder(r.right)

def preorder(r):
  if r == None: return
  ret.append(r.key)
  preorder(r.left)
  preorder(r.right)

def search(r,key):
  if r == None: return
  if r.key == key:
    return True
  if r.key < key:
    return search(r.right,key)
  else:
    return search(r.left,key)

for i in range(n):
  s = input()
  if s[0]=="i":
    insert(Node(int(s.split()[1])))
  elif s[0]=="f":
    if search(r,int(s.split()[1])):
      print("yes")
    else:
      print("no")
  else:
    ret = []
    inorder(r)
    print(""," ".join(map(str,ret)))
    ret = []
    preorder(r)
    print(""," ".join(map(str,ret)))



Measured memory_bytes: 118396
left_a, left_b, right_a, right_b = map(int, input().split())

left_weight = left_a + left_b
right_weight = right_a + right_b

if left_weight == right_weight:
    print('Balanced')
elif left_weight > right_weight:
    print('Left')
elif right_weight > left_weight:
    print('Right')


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

using namespace std;

void disp(vector<int> a, int n){
    for(int i = 0;i < n;i++){
        if(i == n-1) cout << a[i];
        else cout << a[i] << " ";
    }
    cout << endl;
}

void insertSort(vector<int> a, int n){
    for(int i = 1;i < n;i++){
        int v = a[i];
        int j = i-1;
        for(;j >= 0;j--){
            if(v < a[j]){
                a[j+1] = a[j];
            }else{
                break;
            }
        }
        a[j+1] = v;
        disp(a, n);
    }
}

int main(void){
    
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++) cin >> a[i];
    
    disp(a, n);
    insertSort(a, n);
    
    return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s;
ll ans,l,dp[20][10];
ll recur(int pos,int last,ll cur,ll sum)
{
    if(l==pos)
    {
        //cout<<cur<<" "<<sum<<endl;
        return cur+sum;
    }
    ll &ret=dp[pos][last];

    ret=0;
    if(pos)
    {
       //cout<<cur<<" " <<sum<<endl;
        ret+=recur(pos+1,1,s[pos]-48,sum+cur);
        ret+=recur(pos+1,0,(cur*10)+(s[pos]-48),sum);
    }
    else
        ret=recur(pos+1,last,cur+s[pos]-48,0);
    return ret;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    memset(dp,-1,sizeof(dp));
    cin>>s;
    l=s.length();
    cout<<recur(0,0,0,0)<<endl;;

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n>>s;
 rep(i,0,s.length())
 {
   if(i==n) break;
   cout<<s[i];
 }
 if(i!=s. length())
 cout<<"...";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3592
//ITP1_10_A_19140837_Ojima_Yukiya.cpp
//提出日 2020/6/24 wednesday
//プログラミング基礎演習2 CS 第７回課題 ITP1_10_A
//学修番号 19140837　小島優希也
#include <iostream>
#include <math.h>
using namespace std;

int main(void) {
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    printf("%lf", sqrt((a - c)*(a - c) + (b - d)*(b - d)));
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <cstdio>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;






template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}
string s,tmp;
char aa[]={'P','Q','R'};

string schange(string st,char a,char b){
	// cout<<a<<" "<<b<<endl;
	rep(i,st.size()){
		if(st[i]==a){
			st[i]=b;
		}
	}
	return st;
}

string NOT(string t){
	if(t[1]=='1') return "1";
	else if(t[1]=='2') return "0";
	return "2";
}
string AND(string t){
	int a,b;
	char r;
	stringstream ss1;
	ss1<<t;
	ss1>>a;
	ss1>>r;
	ss1>>b;
	if(a==0||b==0) return "0";
	else if(a==1||b==1) return "1";
	return "2";
}
string OR(string t){
	int a,b;
	char r;
	stringstream ss1;
	ss1<<t;
	ss1>>a;
	ss1>>r;
	ss1>>b;
	if(a==2||b==2) return "2";
	else if(a==1||b==1) return "1";
	return "0";
}
bool isnum(char t){
	if(t>='0'&&t<='2') return true;
	return false;
}

int calc(string tmp){
	// cout<<tmp<<endl;
	if(tmp.size()==1&&tmp[0]=='2') return 2;
	else if(tmp.size()==1) return 0;
	int tmps=tmp.size();
	bool f=false;
	while(1){
		rep(i,tmp.size()){
				if(tmp[i]=='('){
					if(tmp[i+2]==')'){
						tmp=tmp.substr(0,i)+tmp.substr(i+1,1)+tmp.substr(i+3);
	
					}
				}
				else if(tmp[i]=='-'){
					if(isnum(tmp[i+1])){
						tmp=tmp.substr(0,i)+NOT(tmp.substr(i,2))+tmp.substr(i+2);
	
					}
				}
				else if(tmp[i]=='*'&&f){
					if(isnum(tmp[i-1])&&isnum(tmp[i+1])){
	
						tmp=tmp.substr(0,i-1)+AND(tmp.substr(i-1,3))+tmp.substr(i+2);
	
				}
			}
			else if(tmp[i]=='+'&&f){
				if(isnum(tmp[i-1])&&isnum(tmp[i+1])){
					
					tmp=tmp.substr(0,i-1)+OR(tmp.substr(i-1,3))+tmp.substr(i+2);
				}
			}
		}
		if(f) break;
		if(tmps!=tmp.size()) break;
		else f=true;
	}
	return calc(tmp);
}

int solve(string s){
	int ans=0;
	int c=0;
	rep(i,3){
		if(s.find(aa[i])!=-1){
			s = schange(s,aa[i],'a'+c);
			c++;
		}
	}
	rep(i,3){
		rep(j,3){
			rep(k,3){
				tmp=s;
				tmp = schange(tmp,'a',i+'0');
				tmp = schange(tmp,'b',j+'0');
				tmp = schange(tmp,'c',k+'0');
				if(calc(tmp)==2){
					ans++;
				}
			}
		}
	}
	return ans;

}


int main(){
	while(cin>>s,s[0]!='.'){
			cout<<solve(s)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1248
import numpy as np
N, M = map(int, input().split())

num_class = []
foodlist = np.zeros(M)

for n in range(N):
    tmplist = list(map(int, input().split()))
    num_class.append(tmplist[0])
    for i in range(tmplist[0]):
        foodlist[tmplist[i+1]-1] += 1

count = 0
for m in range(M):
    if foodlist[m] == N:
        count += 1

print(count)


Measured memory_bytes: 12492
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
 
const int MOD = 1000000007;
double PI = 4*atan(1);

bool pos[100001];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string s; cin >> s;
	pos[0] = 1;
	FOR(i,1,s.length()+1) {
	    if (i >= 5) {
	        if (s.substr(i-5,5) == "dream" && pos[i-5]) pos[i] = 1;
	        if (s.substr(i-5,5) == "erase" && pos[i-5]) pos[i] = 1;
	    }
	    if (i >= 7) if (s.substr(i-7,7) == "dreamer" && pos[i-7]) pos[i] = 1;
	    if (i >= 6) if (s.substr(i-6,6) == "eraser" && pos[i-6]) pos[i] = 1;
	    // cout << pos[i] << "\n";
	}
	if (pos[s.length()] == 1) cout << "YES";
	else cout << "NO";
}

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

int main() {
	// your code goes here
	string s;
	cin>>s;
		if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
			cout<<"Yes"<<endl;}
			else{
			cout<<"No"<<endl;
		}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  int m=101,M=0;
  for (int i=0; i<N; i++) {
    cin >> X.at(i);
    if (X.at(i) > M) {
      M = X.at(i);
    }
    if (X.at(i) < m) {
      m = X.at(i);
    }
  }
  int ans=1000000;
  vector<int> vec(M);
  for (int j=m-1; j<M; j++) {
    vec.at(j) = 0;
    for (int i=0; i<N; i++) {
      vec.at(j) += pow((j+1-X.at(i)),2);
    }
    if (vec.at(j) < ans) {
      ans = vec.at(j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, k, a, b;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> k >> a >> b;
	cout << min(n, k)*a+max(0, n-k)*b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<array>
#include<vector>
using namespace std;

array<int, 10> ary;
vector<int> lf, rt;

int main(){
	bool dfs(int );
	
	
	int n;
	scanf("%d", &n);
	for(int i  = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			int t;
			scanf("%d", &t);
			ary[j] = t;
		}
		lf.clear();
		rt.clear();
		if(dfs(0)) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
} 

bool dfs(int i){
	if(i == 9){
		if(lf.size() == 0 || rt.size() == 0) return true;
		else if(ary[i] > *lf.rbegin() || ary[i] > *rt.rbegin()) return true;
		else return false;
	}
	lf.push_back(ary[i]);
	if(lf.size() == 1 || lf[lf.size() - 1] > lf[lf.size() - 2]) return dfs(i+1);
	lf.pop_back();
	rt.push_back(ary[i]);
	if(rt.size() == 1 || rt[rt.size() - 1] > rt[rt.size() - 2]) return dfs(i+1);
	return false;
}


Measured memory_bytes: 2596
n, l = map(int, input().split())
apple_sum = n * (2 * l + n - 1) // 2
ate_apple = []
num = 0
for i in range(n):
    ate_apple.append(l + i)
for i in range(1, n):
    if abs(ate_apple[i - 1]) > abs(ate_apple[i]):
        num = i
print(apple_sum - ate_apple[num])

Measured memory_bytes: 3060
import java.util.*;
class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			y[i] = sc.nextInt();
		}
		for(int p = 1; p <= 3; p++) {
			double dis = 0.0;
			for(int i = 0; i < n; i++) {
				dis += Math.pow(Math.abs(x[i] - y[i]),p);
			}
			System.out.println(Math.pow(dis, 1.0/p));
 		}
		int max = 0;
		for(int i = 0; i < n; i++) {
			max = Math.max(max, Math.abs(x[i] - y[i]));
		}
		System.out.println(max);
		
	}
}



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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.ne(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[200005], b[200005];
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i] >> b[i];

    bool same = true;
    rep(i, n) if (a[i] != b[i]) { same = false; break; }
    if (same) {
        cout << 0 << endn;
        return;
    }

    int c = 0;
    ll v = inf;
    rep(i, n) {
        if (a[i] > b[i] && b[i] < v) {
            c = i; v = b[i];
        }
    }

    ll ans = 0;
    rep(i, n) ans += a[i];
    cout << ans - b[c] << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 640