akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
int n;
int x[102],cnt=0;

int main(){
    
    double N,K;cin>>N>>K;
    double sum=0.0;
    for(int i=1;i<=N;i++){
        if(i>=K){
            sum += 1.0/N;
        }
        else{
            int l = 0;
            while(pow(2,l)<K/i){
                l++;
            }
            sum += 1.0/(N*pow(2,l));
        }

    }
    
    printf("%.16f",sum);
return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x = scan.nextInt();
		int[] m = new int[n];
		int i = 0;
		for(i = 0; i < n; i++) {
			m[i] = scan.nextInt();
			x = x - m[i];
		}
		Arrays.sort(m);
		x = x / m[0];
		System.out.println(x + n);
	}
}

Measured memory_bytes: 21844
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main(){
	int N;
	cin>>N;
	vector<ll> hoge;
	ll temp[60],sum=0;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		hoge.pb(a);
	}
	ll ans=0;
	while(1){
		sum=0;
		rep(i,N){
			temp[i]=hoge[i]/(ll)N;
			ans+=temp[i];
			hoge[i]=hoge[i]%N;
			sum+=temp[i];
		}
		if(sum==0)break;
		rep(i,N){
			hoge[i]+=(sum-temp[i]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    if (x >= a)
    {
        cout << 10 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

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

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void solve()
{
    int n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++)
        cin>>s[i];
    int arr[4]={0};
    for(int i=0;i<n;i++)
    {
        if(s[i]=="AC")
            arr[0]++;
        else if(s[i]=="WA")
            arr[1]++;
        else if(s[i]=="TLE")
            arr[2]++;
        else
            arr[3]++;
    }
    cout<<"AC x "<<arr[0]<<"\n";
    cout<<"WA x "<<arr[1]<<"\n";
    cout<<"TLE x "<<arr[2]<<"\n";
    cout<<"RE x "<<arr[3]<<"\n";
    
}

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

Measured memory_bytes: 6780
def get_digit_sum(n):
    result = 0
    while n > 0:
        result += n % 10
        n //= 10
    return result


def main():
    ab_sum = int(input())
    answer = float("inf")
    for i in range(1, ab_sum // 2):
        answer = min(answer, get_digit_sum(i) + get_digit_sum(ab_sum - i))
    print(answer if ab_sum > 3 else 2)


if __name__ == '__main__':
    main()



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

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

    let answer = solve(&buf);

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

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

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let odd: usize = n / 2 + n % 2;
    let ans: f64 = odd as f64 / n as f64;
    return ans.to_string();
}


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

int n;
long long a,b,c,d,i;

int main()
{
	cin>>n>>a>>b>>c>>d;
	n--;
	for(i=0;i<=n;i++)
		if(i*c-(n-i)*d<=b-a&&i*d-(n-i)*c>=b-a)
		{
			printf("YES");
			return 0;
		}
	printf("NO");
	return 0;
}


Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] An = Console.ReadLine().Split(' ');
            int A1 = int.Parse(An[0]);int A2 = int.Parse(An[1]);int A3 = int.Parse(An[2]);
            if(A1+A2+A3 >= 22)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }
        }
    }
}


Measured memory_bytes: 27456
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var hwab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int h = hwab[0];
        int w = hwab[1];
        int a = hwab[2];
        int b = hwab[3];
        ModInt res = 0;
        for (int i = 0; i < h - a; i++) res += (Factorial(i + b - 1) / (Factorial(i) * Factorial(b - 1))) * (Factorial((w - b - 1) + (h - i - 1)) / (Factorial(w - b - 1) * Factorial(h - i - 1)));
        Console.WriteLine(res);
    }
    static List<ModInt> factorialMemo = new List<ModInt>() { 1 };
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static ModInt Factorial(int x)
    {
        for (int i = factorialMemo.Count; i <= x; i++) factorialMemo.Add(factorialMemo.Last() * i);
        return factorialMemo[x];
    }
}

struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt modInt) => modInt.Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long val) => new ModInt(val);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, ModInt b)
    {
        long res = a.Data + b.Data;
        return new ModInt() { Data = res >= MOD ? res - MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, ModInt b)
    {
        long res = a.Data - b.Data;
        return new ModInt() { Data = res < 0 ? res + MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);

    public override string ToString() => Data.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 16864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
   char c;cin >> c;
   cout << (char)(c+1) << endl;
   return 0;
}

Measured memory_bytes: 256
S=input()
T=input()

Rs = {}
Rt = {}
for i in range(len(S)):
    if S[i] in Rs.keys():
        if Rs[S[i]] != T[i]:
             print("No")
             exit()
    else:
        Rs[S[i]] = T[i]

    if T[i] in Rt.keys():
        if Rt[T[i]] != S[i]:
            print("No")
            exit()
    else:
        Rt[T[i]] = S[i]
print("Yes")


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> p, len;
int main() {
  cin >> n; read_n(p, n);
  init_n(len, n+1, 0);
  lli ans = 0;
  for (lli i=0; i<n; ++i) {
    len[p[i]] = len[p[i]-1] + 1;
    ans = max(ans, len[p[i]]);
  }
  cout << n - ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 1000000001
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int main(){

	string s;
	cin>>s;
	int a=s.size()-8;
	rep(i,a){
		cout<<s[i];
	}
	cout<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 int M;
 cin >> N >> M;
 if(M==0)cout << 0 << " " << 0 << endl;
 else{
 int p[M];
 int a[N]={0};
 int b[N]={0};
 int i;
 for(i=0;i<M;++i){
     string ans;
   cin >> p[i] >> ans;
   if(ans=="AC")a[p[i]-1]++;
   if(ans=="WA" && a[p[i]-1]<1)b[p[i]-1]++;
   }
int count = 0;
int coun = 0;
 for(i=0;i<N;++i){
  if(a[i]>0){count++;
coun+=b[i];}
 }
cout << count << " " << coun << endl;
 }
}

Measured memory_bytes: 1408
#include<stdio.h>
long gcd(long,long);

int main(void){
    long a,b,gc;
    while(EOF!=scanf("%ld %ld",&a,&b)){
        gc=gcd(a,b);
        printf("%ld %ld\n",gc,a/gc*b);
    }
    return 0;
}
long gcd(long x,long y){
    long box=x;
    if(x<y){
        x=y;
        y=box;
    }
    do{
        x%=y;
        box=x;
        x=y;
        y=box;
    }while(0!=y);
    return x;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	long long int A[100005];
	long long int count=0;
	cin>>n;
	A[n]=0;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	for(int i=0;i<n;i++){
		if(A[i]%2==0||i==n-1){
			count+=A[i]/2;
		}
		else{
			if(A[i+1]!=0){
				count+=A[i]/2 + 1;
			 	A[i+1]--;
			}
			else{
				count+=A[i]/2;
			}
		}
	}
	cout<<count<<endl;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int dp[50][100010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  VI v;
  v.PB(1);
  int idx = 6;
  while(idx <= n) {
    v.PB(idx);
    idx *= 6;
  }
  idx = 9;
  while(idx <= n) {
    v.PB(idx);
    idx *= 9;
  }

  int m = v.size();
  REP(i, m) REP(j, n+1) dp[i][j] = INF;
  dp[0][0] = 0;

  REP(i, m) {
    REP(j, n+1) {
      if(j < v[i]) {
        dp[i+1][j] = dp[i][j];
      } else {
        dp[i+1][j] = min(dp[i][j], dp[i+1][j-v[i]] + 1);
      }
    }
  }

  // REP(i, m) {
  //   REP(j, n+1) cout << dp[i][j] << " ";
  //   cout << endl;
  // }

  cout << dp[m][n] << endl;

  return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    string s, t;
    cin >> s;
    REP(i, s.length()) {
        if (i % 2 == 1)continue;
        t += s[i];
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int count = 0;
		String str = sc.next();

		for (int i = 0; i < str.length(); i++) {

			if (str.charAt(i) == '1') {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21460
N = int(input())
s = list(input())

l, r = [[0]*2 for _ in range(N+1)], [[0]*2 for _ in range(N+1)]
for i,j in enumerate(s, start=1):
    if j=="#":
        l[i][1] = l[i-1][1]
        l[i][0] = l[i-1][0] + 1
    else:
        l[i][0] = l[i-1][0]
        l[i][1] = l[i-1][1] + 1

for i,j in enumerate(s[::-1], start=1):
    if j=="#":
        r[N-i][1] = r[N-i+1][1]
        r[N-i][0] = r[N-i+1][0] + 1
    else:
        r[N-i][0] = r[N-i+1][0]
        r[N-i][1] = r[N-i+1][1] + 1

ans = N
for i in range(N+1):
    ans = min(ans, l[i][0]+r[i][1])

print(ans)

Measured memory_bytes: 92616
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	int a, b, x;
	cin >> a >> b >> x;
	int V = a * a * b;
	double theta;
	if (x <= V / 2.0) {
		theta = M_PI / 2 - atan(2.0 * x / (a * b * b));
	}
	else
	{
		theta = atan(2.0 / (a * a * a) * (V - x));
	}
	printf("%.9lf\n", theta / M_PI * 180);
	return 0;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

vector<tuple<int, int, char>> v;
int main()
{
	int n;
	cin>>n;
	rep(i, 0, n)
	{
		int x, y;
		cin>>x>>y;
		v.pb(make_tuple(x, y, 'R'));
	}
	rep(i, 0, n)
	{
		int x,y;
		cin>>x>>y;
		v.pb(make_tuple(x, y, 'B'));
	}
	sort(v.begin(), v.end());
	int ans = 0;
	int r = 0;
	set<int> s;
	for(auto x: v)
	{
		if(get<2>(x) == 'R')
		{
			s.insert(get<1>(x));
			r++;
		}
		else if(r > 0)
		{
			int y = get<1>(x);
			auto itr = s.lower_bound(y);
			if(itr == s.begin()) continue;
			itr--;
			ans++;
			r--;
			s.erase(itr);
		}
	}
	cout<<ans<<endl;
}


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

int main(){

  int n;
  int tmp[26], cnt[26];
  cin >> n;
  memset(cnt, 10000, sizeof(cnt));
  string s;
  for(int i = 0; i < n; i++){
    cin >> s;
    memset(tmp, 0, sizeof(tmp));
    for(int j = 0; j < s.size(); j++) tmp[s[j] - 'a']++;
    for(int k = 0; k < 26; k++) cnt[k] = min(cnt[k], tmp[k]);
  }
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < cnt[i]; j++){
      cout << (char)('a' + i);
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vector<string> m;
vector<vint> res;

int main() {
	int h,w;
	while(cin>>w>>h,h){
		m.clear();
		res.clear();
		int i,j;
		vint buf;
		for(i=0;i<w;i++)buf.push_back(100100100);
		for(i=0;i<h;i++){
			string str;
			cin>>str;
			m.push_back(str);
			res.push_back(buf);
		}
		for(i=0;i<w;i++)res[0][i]=res[h-1][i]=0;
		for(i=0;i<h;i++)res[i][0]=res[i][w-1]=0;
		bool update=true;
		int xx[]={1,-1,0,0},yy[]={0,0,1,-1};
		int k;
		while(update){
			update=false;
			for(i=1;i<h-1;i++){
				for(j=1;j<w-1;j++){
					for(k=0;k<4;k++){
						if(m[i+yy[k]][j+xx[k]]=='#'&&m[i][j]!='#'){
							if(res[i+yy[k]][j+xx[k]]+1<res[i][j]){
								res[i][j]=res[i+yy[k]][j+xx[k]]+1;
								update=true;
							}
						}else{
							if(res[i+yy[k]][j+xx[k]]<res[i][j]){
								res[i][j]=res[i+yy[k]][j+xx[k]];
								update=true;
							}
						}
					}
				}
			}
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
//cout<<res[i][j]<<" ";
				if(m[i][j]=='&'){
					cout<<res[i][j]<<endl;
				}
			}
//cout<<endl;
		}
	}
	return 0;
}

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

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

    vector<pair<int,int>> xy(n);
    for(auto &t: xy) cin >> t.first >> t.second;


    vector<int> x(n);
    vector<int> y(n);
    for(int i=0; i<n; i++) x[i] = xy[i].first;
    for(int i=0; i<n; i++) y[i] = xy[i].second;

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    vector<vector<int>> cnt(n, vector<int>(n));
    for(int i=0; i<n; i++) {
        int yy = find_if(xy.begin(), xy.end(), [&](auto xy){return xy.first == x[i];})->second;
        int iy = lower_bound(y.begin(), y.end(), yy)-y.begin();

        cnt[iy][i] = 1;
    }

    for(int i=0; i<n; i++)
        for(int j=0; j<n-1; j++)
            cnt[i][j+1] += cnt[i][j];

    for(int i=0; i<n-1; i++)
        for(int j=0; j<n; j++)
            cnt[i+1][j] += cnt[i][j];

    long res = LONG_MAX;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            for(int ii=i+1; ii<n; ii++)
                for(int jj=j+1; jj<n; jj++) {
                    int c = cnt[ii][jj];
                    c -= i>0 ? cnt[i-1][jj] : 0;
                    c -= j>0 ? cnt[ii][j-1] : 0;
                    c += i>0&&j>0 ? cnt[i-1][j-1] : 0;
                    if(c >= k) {
                        res = min(res, 1L*(y[ii]-y[i])*(x[jj]-x[j]));
                    }
                }

    cout << res << endl;
}


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

using namespace std; 

int main() {
   string s, t;
   cin >> s >> t;
   sort(s.begin(), s.end());
   sort(t.begin(), t.end(), greater<int>());
   s < t ? cout << "Yes" : cout << "No";
   cout << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    int cnt = 1;
    vector<vector<int>> ans(h, vector<int>(w, -1));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                ans[i][j] = cnt;
                int t = 1;
                while(j - t >= 0 && s[i][j - t] != '#' && ans[i][j - t] == -1){
                    ans[i][j - t] = cnt;
                    t++;
                }
                t = 1;
                while(j + t < w && s[i][j + t] != '#' && ans[i][j + t] == -1){
                    ans[i][j + t] = cnt;
                    t++;
                }
                cnt++;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(ans[i][j] != -1){
                int t = 1;
                while(i - t >= 0 && ans[i - t][j] == -1){
                    ans[i - t][j] = ans[i][j];
                    t++;
                }
                t = 1;
                while(i + t < h && ans[i + t][j] == -1){
                    ans[i + t][j] = ans[i][j];
                    t++;
                }
            }
        }
    }
    for(int i = 0; i < h; i++){
        cout << ans[i][0];
        for(int j = 1; j < w; j++){
            cout << " " << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(){
    char x;
    int n,ans=0,tmp=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x=='I')tmp++;
        else if(x=='D') tmp--;
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define MAXN 200000 + 5
#define ll long long
#define int long long
using namespace std;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define con continue
#define endl "\n"
 
//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
signed main(){
    int h , n;
    cin >> h >> n;
    int sum = 0;
    rep(i , 0 , n)
    {
        int x;
        cin >> x;
        sum += x;
    }
    if (sum >= h){
        cout << "Yes\n";
    }
    else
        cout <<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}


int main(){
    ll n; cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<int> tok(n,0), aok(n,0);
    tok[0] = 1;aok[n-1] = 1;
    for(int i = 1;i < n;i++){
        if(t[i] > t[i-1])tok[i] = 1;
        else tok[i] = 0;
    }
    for(int i = n-2;0 <= i;i--){
        if(a[i] > a[i+1])aok[i] = 1;
        else aok[i] = 0;
    }
    ll res = 1;
    bool ok = true;
    rep(i,n){
        if(tok[i] && aok[i] && a[i] != t[i])ok = false;
        if(tok[i] && t[i] > a[i])ok = false;
        if(aok[i] && t[i] < a[i])ok = false;
        if(!tok[i] && !aok[i]) res = (res * min(a[i],t[i]))%MOD;
    }

    // print(tok);
    // print(aok);
    res %= MOD;
    cout << (ok ? res : 0) << endl;
    return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;

int main() {
  int N;
  cin >> N;
  vector<int> C(N-1);
  vector<int> S(N-1);
  vector<int> F(N-1);

  REP(n,N-1){
    cin >> C[n] >> S[n] >> F[n];
  }

  REP(n,N-1){
    int time = 0;

    for(int m = n;m < N-1;m++){
      if (time < S[m]) {
        time = S[m];
      } else if(time % F[m] == 0) {
        time = time;
      } else{
        time = time + F[m] - time%F[m];
      }
      time += C[m];  
      
    }
    cout << time << endl;

  }

  cout << 0 << endl;

}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>

int main(){
    std::string str;
    std::cin >> str;
    for(auto &it : str){
        if (it == 'C') it = 'A';
        else if (it == 'G') it = 'A';
        else if (it == 'T') it = 'A';
    }
    int ret = 0;
    std::vector<int > vlst;
    for(auto it : str){
        if (it == 'A') ret ++;
        if (it != 'A') {
            vlst.push_back(ret);
            ret = 0;
        }
    }
    vlst.push_back(ret);
    ret = 0;
    for(auto it : vlst){
        ret = ret > it ? ret : it;
    }
    std::cout << ret;
}

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

#define int ll
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

const int N = 1e5 + 5;

int GCD(int a, int b) { return !b ? a : GCD(b, a % b); }

int32_t main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int a, b; cin >> a >> b;
	cout << a * b / GCD(a, b) << endl;

	return 0;
}


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


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	
	int n;
	cin>>n;
	int t,f=0;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		if(t%2==0 && t%3!=0 && t%5!=0)
			f=1;
	}
	if(f==1)
		cout<<"DENIED"<<endl;
	else
		cout<<"APPROVED"<<endl;
	return 0;
}


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

using namespace std;

long long gcd(long long a, long long b) {
    long long r;
    while ( (r = a % b) != 0) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
   long long N, K;
   cin >> N >> K;
   
   long long A[N];
           for (int i = 0; i < N; ++i) cin >> A[i];
   
   if (N==1) {
       if (K== A[0]) cout << "POSSIBLE" << endl;
       else cout <<"IMPOSSIBLE" << endl;
   }
   
   else {
          
           
           long long m = *max_element(A, A+N);
           
           long long d= gcd(A[0], A[1]);
           for (int i = 0; i < N; ++i) {
               d = gcd(d, A[i]);
           }
           
           if ( K <= m && K % d == 0) cout << "POSSIBLE" << endl;
           else cout <<"IMPOSSIBLE" << endl;
   }
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		FastReader reader = new FastReader();
		PrintWriter writer = new PrintWriter(System.out);

		char[] s = reader.nextLine().toCharArray();
		char[] t = reader.nextLine().toCharArray();

		int n = s.length;

		boolean ans = false;
		for (int i=0; i<n; i++)
		{
			boolean temp = true;
			for (int j=0; j<n; j++)
			{
				if (s[j]!=t[(i+j)%n])
					temp = false;
			}

			ans |= temp;
		}

		if (ans)
			writer.println("Yes");
		else
			writer.println("No");
		writer.close();
	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int h,w;
int mp[1410][1410];
int dp[14010][1410];
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>mp[i][j];
		}
	}
	int Max=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			dp[i][j]=(mp[i][j]+1)%2;
			Max|=dp[i][j];
		}
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(mp[i][j]==1){
				dp[i][j]=0;
			}
			else{
				dp[i][j]=min(min(dp[i-1][j],dp[i-1][j-1]),dp[i][j-1])+1;
			    if(dp[i][j]>Max){
			    	Max=dp[i][j];
				}
			}
		}
	}
	cout<<Max*Max<<endl;
	
	
	return 0;
} 



Measured memory_bytes: 18516
fun main(args: Array<String>) {
    val N = nextInt()
    val P = listOfInt().sorted()
    val c = N / 2
    val ans = P[c] - P[c - 1]
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

Measured memory_bytes: 52460
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var a = ReadLong();
            return a + a * a + a * a * a;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27368
#include <cstdio>
#include <algorithm>
using namespace std;

#define int long long

int modpow(int x, int y, int z) { int a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }

const int M = 998244353;
int a[300];
int d[90310];
int e[90310];

signed main() {
  int n;
  scanf("%lld", &n);
  int sum = 0;
  d[0] = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
    for (int t = sum; t >= 0; --t) {
      d[t + a[i]] += d[t] * 2 % M;
    }
    sum += a[i];
  }
  int ans = modpow(3, n, M);
  for (int t = 0; t <= sum / 2; ++t) {
    ans = (ans - d[t] * 3) % M;
  }
  if ((sum & 1) == 0) {
    int u = 0;
    e[0] = 1;
    for (int i = 0; i < n; ++i) {
      for (int t = min(sum / 2, u + 1); t >= 0; --t) {
        int *p = e + t + a[i];
        *p += e[t];
        if (*p >= M) *p -= M;
      }
      u += a[i];
    }
    ans = (ans + e[sum / 2] * 3) % M;
  }
  ans = (ans + M) % M;
  printf("%lld", ans);
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(){
  int size,ans=0;
  scanf("%d",&size);
  int num[size];
  int i;
  for(i=0;i<size;i++){
    scanf("%d",&num[i]);
  }
  int flag=0;
  while(1){
    for(i=0;i<size;i++){
      if(num[i]%2!=0){
        flag =1;
        break;
      }
      num[i]=num[i]/2;
    }
    if(flag==1)break;
    ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n;
    string s[100],ans="Yes";
    cin>>n;
    cin>>s[0];
    for(int i=1;i<n;i++){
        cin>>s[i];
        if(s[i][0]!=s[i-1][s[i-1].length()-1]){
            ans="No";
            i=n;
        }else{
            for(int j=0;j<i;j++){
                if(s[j]==s[i]){
                    ans="No";
                    i=n;
                    j=n;
                }
            }
        }
    }
    cout<<ans<<endl;
}


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

int gcd(int a, int b){
    if (a%b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a%b));
    }
}

int main(){
  int k;
  cin>>k;
  long long ans;
  ans=0;
  for(int i=1;i<=k;i++){
    for(int g=1;g<=k;g++){
      for(int l=1;l<=k;l++){
        ans+=gcd(i,gcd(g,l));
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3624
//MD. HASNAIN ALI (UNSOLVED)
//I am nobody.

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

#pragma GCC               optimize ("Ofast")
#pragma GCC               optimize("O3")
#define ll                long long
#define lo(i,a,n,x)       for(i=a;i<=n;i=i+x)
#define loi(i,a,n,x)      for(i=a;i>=n;i=i-x) 
#define sca(n)            scanf("%lld", &n)
#define pri(n)            printf("%lld", n)
#define pb(a)             push_back(a)
#define pop()             pop_back()
#define mp                make_pair
#define ff                first
#define ss                second
#define sqr(x)            (x)*(x)
#define VI                vector <int>
#define SZ(a)             (int)a.size()
#define SORT(x)           sort(x.begin(), x.end())
#define REV(x)            reverse(x.begin(), x.end())
#define UNIQUE(v)         (v).erase(unique((v).begin(),(v).end()),(v).end())
#define REV(x)            reverse(x.begin(), x.end())
#define all(x)            x.begin(), x.end()
#define ODD(x)            ((x)&1)==0?(0):(1)
#define TEST_CASE(t)      for(int z=1;z<=t;z++)
#define distance(a,b)     (sq(a.x-b.x) + sq(a.y-b.y))
#define GCD(a, b)         __gcd(a, b)
#define lcm(a, b)         (a)*((b)/gcd(a,b))
#define end0              "\n"
#define end1              cout<<"\n";
#define pi                acos(-1)
#define mod               1000000007
#define inf               999999999999999999
#define eps               10e-9





int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("input-3.txt","r",stdin);
    //freopen("output-3.txt","w",stdout);

    char x[1005];
    cin>>x;
    int a=strlen(x);

    if(x[a-1]=='s'){
        x[a]='e';
        x[a+1]='s';
        x[a+2]='\0';
    }
    else{
        x[a]='s';
        x[a+1]='\0';
    }
    cout<<x<<endl;

    return 0;
}

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

using namespace std;
int a[15];
int dfs(int x, int y, int step)
{
    if( step == 11)
        return 1;
    if(x < a[step])  return dfs(a[step], y, step+1);
    else if(y < a[step]) return dfs(x, a[step], step+1);
    else
        return 0;
}
int main ()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int i;
        for(i = 1; i <= 10; i++)
            scanf("%d", &a[i]);
        if(dfs(0, 0, 1))
            printf("YES\n");
        else
            printf("NO\n");
    }
}

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

#define M 1046527
#define L 14
#define NIL -1

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
	return key % M;
}
int h2(int key){
	return (key % (M -1))+1;
}

int find(char str[]){

    long long key,i,k;
    key = getKey(str);
    for(i=0;;i++){
    	k = ( h1(key) + h2(key)*i) % M;
    	if(strlen(H[k]) == 0) return 0;
    	else if(strcmp(H[k],str) == 0) return 1;
    }
    return 0;
}

int insert(char str[]){

    long long key,i,k;
    key = getKey(str);
    for(i = 0;;i++){
    	k=(h1(key) + i*h2(key)) % M;
    	if(strcmp(H[k],str) == 0) return 1;
    	else if(strlen(H[k]) == 0){
    		strcpy(H[k],str);
    		return 0;
    	}
    }

}

int main(){
    int i, n, k;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 16032
#b
n = int(input())
a = list(map(int,input().split()))
ans = 1
e = 0
m = 10**18
a.sort()
for i in range(n):
    ans *= a[i]
    if a[i] == 0:
        ans = 0
        e = 0
        break
    if ans > m:
        e = 1
        break


if e == 1:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  ll ans=n*(n-1)/2;
  if(n%2==0) {
    cout << ans-n/2 << endl;
    rep(i,n){
      rep(j,n){
        if(i>=j) continue;
        if(i+j==n-1) continue;
        cout << i+1 << " " << j+1 << endl;
      }
    }
  }
  else {
    cout << ans-(n-1)/2 << endl;
    rep(i,n){
      rep(j,n){
        if(i>=j) continue;
        if(i+j==n-2) continue;
        cout << i+1 << " " << j+1 << endl;
      }
    }
  }
}


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

int main(){
    string s; cin >> s;
    int a, z;

    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'A'){
            a = i;
            break;
        }
    }
    for(int i = s.size()-1; i > 0; i--){
        if(s[i] =='Z'){
            z = i;
            break;
        }
    }

    cout << z - a + 1 << endl;
} 

Measured memory_bytes: 640
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [0]*N
count = 0

for n in range(N):
  A[n] = list(map(int, input().split()))
  
  _sum = 0
  for i in range(M):
    _sum += A[n][i] * B[i]
    
  if _sum + C > 0:
    count += 1
  else:
    continue
    
print(count)


Measured memory_bytes: 9184
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>

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

int main() {
  long m, n;
  cin >> m >> n;
  long mod = 1000000007;

  long pows[50];

  pows[0]=1;
  pows[1]=m;
  for (long i=2, p=2; p<=n; p*=2, ++i) {
    pows[i] = pows[i-1] * pows[i-1] % mod;
  }

  long ans=1;
  for (long nn=n; nn>0; ) {
    long i, p;
    for (i=1, p=1; p*2<=nn; ++i, p*=2);
    ans *= pows[i];
    ans %= mod;
    nn -= p;
  }

  cout << ans << endl;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int N=count(S.begin(),S.end(),'N');
  int s=count(S.begin(),S.end(),'S');
  int E=count(S.begin(),S.end(),'E');
  int W=count(S.begin(),S.end(),'W');
  if((N*s==0&&N+s>0)||(E*W==0&&E+W>0))cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

int main() {
    string s;
    int n, m = 0;
    cin >> n >> s;
    if (n % 2 != 0) cout << "No" << endl;
    else {
        for (int i = 0; i < n / 2;i++) {
            if (s[i] != s[n / 2 + i]) m++;
        }
        if (m == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

        

    



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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

vector<map<string, int>> memo(101);
int N;
const int MOD = 1e9 + 7;

bool ok(string s) {
  if (s[0] == 'A' && s[2] == 'G' && s[3] == 'C') return false; // A?GC
  if (s[0] == 'A' && s[1] == 'G' && s[3] == 'C') return false; // AG?C
  if (s[0] == 'A' && s[1] == 'G' && s[2] == 'C') return false; // AGC?
  if (s[1] == 'A' && s[2] == 'G' && s[3] == 'C') return false; // ?AGC
  if (s[0] == 'G' && s[1] == 'A' && s[2] == 'C') return false; // GAC?
  if (s[1] == 'G' && s[2] == 'A' && s[3] == 'C') return false; // ?GAC
  if (s[0] == 'A' && s[1] == 'C' && s[2] == 'G') return false; // ACG?
  if (s[1] == 'A' && s[2] == 'C' && s[3] == 'G') return false; // ?ACG
  return true;
}
int dfs(int cur, string last3) {
  if (memo[cur].count(last3) == 1) {
    return memo[cur][last3];
  }
  if (cur == N) return 1;
  int ret = 0;
  char bases[] = {'A', 'C', 'G', 'T'};
  for (char c : bases) {
    if (ok(last3 + c)) {
      string s = last3.substr(1);
      s += c;
      ret = (ret + dfs(cur + 1, s)) % MOD;
    }
  }
  memo[cur][last3] = ret;
  return ret;
}

int main() {
  cin >> N;
  cout << dfs(0, "TTT") << endl;
}

Measured memory_bytes: 896