akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll inf = 1e18;

int main() {
  int n,x;
  cin >> x >> n;
  
  if(n == 0){
    cout << x << endl;
    return(0);
  }
  
  vector<ll> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  
  int index = -1;
  sort(p.begin(),p.end());
  
  
  if(p.at(0) > x){
    cout << x << endl;
  }else if(p.at(n-1) < x){
    cout << x << endl;
  }
  
  ll ans=x;
  ll cnt=0;
  ll muki=1;
  while(true){
    if(!binary_search(p.begin(),p.end(),ans) ){
      cout << ans << endl;
      return(0);
    }
  	cnt++;
    muki *= -1;
    ans = ans + cnt*muki;
    //cout << ans << endl;
  }
  return(0);
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	double x1,x2,xp,y1,y2,yp,slope,ansx,ansy;
	int q;
	bool X_FLG = false,Y_FLG = false;

	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	scanf("%d",&q);

	if(y1 == y2){
		X_FLG = true;
	}else if(x1 == x2){
		Y_FLG = true;
	}else{
		slope = (y2-y1)/(x2-x1);
	}

	for(int i=0;i<q;i++){
		scanf("%lf %lf",&xp,&yp);
		if(X_FLG){
			printf("%.10lf %.10lf\n",xp,y1);
		}else if(Y_FLG){
			printf("%.10lf %.10lf\n",x1,yp);
		}else{
			ansx = (yp*(x2-x1)*(y2-y1)+xp*(x2-x1)*(x2-x1)-y1*(y2-y1)*(x2-x1)+x1*(y2-y1)*(y2-y1))/((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
			ansy = ((x1-x2)*ansx+yp*(y2-y1)+xp*(x2-x1))/(y2-y1);
			printf("%.10lf %.10lf\n",ansx,ansy);
		}

	}

	return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

set<int> s;

int check(int n,int x)
{
	if(x==1)
		return 0;
	while(n%x==0)
		n = n/x;
	if(n%x==1)
		return 1;
	return 0;
}

void isPrime1(int N)
{
	int i;
	int c=0;
	for(i=2;i*i<=N;i++)    // O(sqrt(n))
	{
		if(N%i==0)
		{
			if(i*i==N)
			{
				s.insert(i);
			}
			else
			{
				s.insert(i);
				s.insert(N/i);
			}
		}
	}
	return;
}

void isPrime2(int N)
{
	int i;
	int c=0;
	for(i=1;i*i<=N;i++)    // O(sqrt(n))
	{
		if(N%i==0)
		{
			if(i*i==N && check(N,i)==1)
			{
				s.insert(i);
			}
			else
			{
				if(check(N,i)==1)
					s.insert(i);
				if(check(N,N/i)==1)
					s.insert(N/i);
			}
		}
	}
	return;
}

int32_t main()
{
	//IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T = 1;
	while(T--)
	{
		int n;
		cin >> n;
		int x =n;
		x--;
		isPrime1(x);
		s.insert(x);
		isPrime2(n);
		s.erase(1);
		cout << s.size() << endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;


int main() {
 
  int64_t N;
  cin>>N;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
 if(N>=30) cout << "Yes" << endl;
else cout<<"No"<<endl;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  ll n, t;
  cin >> n >> t;
  vector<ll> ta(n);
  rep(i, n) cin >> ta[i];

  ll ans = 0;
  for(int i = 0; i < n-1; ++i){
    ans += min(t, ta[i + 1] - ta[i]);
  }
  ans += t;
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

ll X[100010], Y[100010];
ll turnR[100010], turnL[100010];

int main() {
  ll N, C;
  cin >> N >> C;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }

  ll sum = 0, maxv = 0;
  for(int i = 0; i < N; i++) {
    sum += Y[i];
    maxv = max(maxv, sum - X[i]);
    turnL[i] = maxv;
  }

  sum = 0, maxv = 0;
  for(int i = N -1; i >= 0; i--) {
    sum += Y[i];
    maxv = max(maxv, sum - (C -X[i]));
    turnR[i] = maxv;
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll tmp = turnL[i];
    if (i < N -1) {
      tmp += max(0LL, turnR[i + 1] - X[i]);
    }
    ans = max(ans, tmp);
  }
  for (int i = N -1; i >= 0; i--) {
    ll tmp = turnR[i];
    if (i) {
      tmp += max(0LL, turnL[i - 1] - (C- X[i]));
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

#define MAX 1000000
typedef long long ll;

void ESieve(vector<bool> &isPrime) {
  isPrime.assign(MAX + 1, true);
  isPrime[0] = isPrime[1] = false;
  for(int i=2; (ll)i*i<=MAX; i++) {
    if(isPrime[i]) {
      for(int j=2*i; j<=MAX; j+=i) {
	isPrime[j] = false;
      }
    }
  }
}

int main() {
  
  vector<bool> isPrime;
  ESieve(isPrime);

  int n;
  while(cin>>n, n) {
    int res = 0;
    for(int i=2; i <= n/2; i++) {
      if(isPrime[i] && isPrime[n-i]) {
	res ++;
      }
    }
    cout << res << endl;
  }
  
  return 0;
}

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


public class MyProgram
{	

    public static void Main()
	{
        int N = int.Parse(Console.ReadLine());
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[] dif = new int[N];
        long Sum = 0;
        long B = 0;
        for(int i = 0 ; i < N ; i++)
        {
            dif[i] = (n[i]-(i+1));
        }
        Array.Sort(dif);
        
    
        B = dif[N / 2];     

        
        for(int i = 0 ; i < N ; i++)
        {
            Sum += Math.Abs(n[i] - (B+i+1));
        }
        Console.WriteLine(Sum);
	}
}

Measured memory_bytes: 28892
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

string S[100010];

int main()
{
	int N; cin >> N;
	cout << 0 << endl;
	cin >> S[0];
	int ng = 0;
	int ok = N;
	while (abs(ng - ok) > 1) {
		int mid = (ng + ok) / 2;
		cout << mid << endl;
		cin >> S[mid];
		if (S[mid] == "Vacant") return 0;
		if ((ng + mid) % 2 == 0) {
			if (S[ng] == S[mid]) {
				ng = mid;
			}
			else {
				ok = mid;
			}
		}
		else {
			if (S[ng] == S[mid]) {
				ok = mid;
			}
			else {
				ng = mid;
			}
		}
	}
}


Measured memory_bytes: 1620
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>
 
using namespace std;

int main()
{
	long long H, W; 
	scanf("%lld%lld",&H,&W);
	long long product=(H*W)+1;
	if(H==1||W==1)
		printf("%lld", 1);
	else
		printf("%lld",product/2);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
	const int M=1000000007;
	int n;
	long long x, s1=0, s2=0;
	cin>>n;
	while(n--){
		cin>>x;
		s2+=s1*x;
		s2%=M;
		s1+=x;
		s1%=M;
	}
	cout<<s2<<endl;
	return 0;
}

Measured memory_bytes: 3168
n = int(input())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
d = [int(m) for m in d]#int型に直す
cnt = 0
for i in range(n):
    if d[i] % 2 == 0:
        cnt += 1
if cnt == n:
    print("second")
else:
    print("first")

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

map<tuple<int, int, int>, int> Map;
int N, A[3], E;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[0] >> A[1] >> A[2];
        sort(A, A + 3);
        if (Map[make_tuple(A[0], A[1], A[2])] == 1) E++;
        Map[make_tuple(A[0], A[1], A[2])] = 1;
    }
    cout << E << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
     int n,a;
     cin>>n;
     for(a=1;a<=n;a++){
		 if(a%3==0||a%10==3||(a/10)%10==3||(a/100)%10==3||(a/1000)%10==3){
			 cout<<" "<<a ;
		 }
	 }
	 cout<< endl;
}



Measured memory_bytes: 3100
//
// Created by Myabu on 2020/01/25.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    string S;
    
    cin>>S;

    int ans = 10000;
    for (int i = 0; i < S.length() - 2; ++i) {
        ans = min(ans, abs(753-stoi(S.substr(i,3))));
    }

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

Measured memory_bytes: 760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>

using namespace std;

int base=0;
int score = 0;
int out=0;

void addRunner(){
	switch (base){
	case 0:base = 1; break;
	case 1:base = 11; break;
	case 10:base = 101; break;
	case 11:base = 111; break;
	case 100:base = 1; score++; break;
	case 101:base = 11; score++; break;
	case 111:base = 111; score++; break;
	default:printf("any error"); break;
	}
}

int main(){
	int cining=0,ining;
	char eventName[9];

	cin >> ining;

	while(1){
		cin >> eventName;
		if (strcmp("HIT", eventName) == 0){
			addRunner();
		}
		else if (strcmp("OUT",eventName) == 0){
			out++;
			if (out == 3){
				printf("%d\n", score);
				score = out = base = 0;
				cining++;
				if (cining == ining)break;
			}
		}
		else if (strcmp("HOMERUN", eventName) == 0){
			switch (base){
			case 0:score++; break;
			case 1:score += 2; break;
			case 10:score += 2; break;
			case 11:score += 3; break;
			case 100:score += 2; break;
			case 101:score += 3; break;
			case 110:score += 3; break;
			case 111:score += 4; break;
			default:printf("any error"); break;
			}
			base = 0;
		}
	}

	return 0;
}

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

using namespace std;

long long gcd(long long a, long long b){
    return b ? gcd(b, a % b) : a;
}

using namespace std;

int main(){
    vector<bool> isPrime(1000001, true);
    isPrime[0] = isPrime[1] = false;
    for(int i = 2; i * i <= 1000000; i += 2){
        if(!isPrime[i]) continue;
        for(int j = i * i; j <= 1000000; j += i){
            isPrime[j] = false;
        }
        i -= i == 2;
    }
    vector<long long> primeNumber;
    for(int i = 0; i <= 1000000; i++){
        if(isPrime[i]){
            primeNumber.push_back(i);
        }
    }
    long long a, b;
    cin >> a >> b;
    long long score = gcd(a, b);
    int cnt = 0;
    for(long long i = 1; i * i <= score; i++){
        if(score % i) continue;
        if(i == 1 || isPrime[i]) cnt++;
        if(i * i < score){
            long long num = score / i;
            bool check = true;
            for(int i = 0; i < primeNumber.size() && primeNumber[i] * primeNumber[i] <= num; i++){
                if(num % primeNumber[i] == 0){
                    check = false;
                    break;
                }
            }
            if(check){
                cnt++;
            }
        }
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int A, B, C;
    int X, Y;
    cin >> A >> B >> C;
    cin >> X >> Y;
    ll ans = (ll)1e18;
    rep(i, max(X, Y) + 1){
        ll tmp = i * 2 * C;
        tmp += X > i  ? (X -  i) * A : 0;
        tmp += Y > i  ? (Y - i) * B : 0;
        ans = min(tmp, ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
//#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
/*
#pragma comment(linker, "/STACK: 20000000005")
*/


using namespace std;

int F (string a, string b){
    int pas = 0;
    int n = (int)a.size(), m = (int)b.size();
    for (int i = 0; i < min (n, m); i++){
        if (a[i] != b[i])
            break;
        pas++;
    }
    return pas;
}

const int N = 3005, MOD = 998244353;

int n, S;
int a[N];
int dp[N];
int ans;

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> S;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++){
        for (int j = S - a[i]; j >= 0; j--){
            dp[j + a[i]] += dp[j];
            dp[j + a[i]] %= MOD;
        }
        dp[a[i]] += i;
        ans += dp[S];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

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

    map<string, int> mymap;
    for(int i = 0; i < n; i++) {
        cin >> s;
        mymap[s]++;
    }
    
    int gt = 0;
    for(auto value : mymap) {
        gt = max(gt, value.second);
    }

    for(auto value : mymap) {
        if (value.second == gt) {
            cout << value.first << '\n';
        }
    }
    
    return 0;
}

Measured memory_bytes: 25216
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(solve(s[0], s[1]));
    }
    static int solve(int a, int b) {
        int count = 0;
        for(int i = a; i <= b; i ++) {
            char[] c = i.ToString().ToCharArray();
            Array.Reverse(c);
            string s = new string(c);
            int tmp = int.Parse(s);
            if(i == tmp) count ++;
        }
        return count;
    }
}

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

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

        public void Solve(ConsoleInput cin)
        {
            // ここに処理を書く
            var alist = Enumerable.Range(0, cin.ReadInt + 1);
            var blist = Enumerable.Range(0, cin.ReadInt + 1);
            var clist = Enumerable.Range(0, cin.ReadInt + 1);
            var x = cin.ReadInt;

            var combination = alist.SelectMany(a => blist.SelectMany(b => clist.Select(c => new {a, b, c})));
            int cnt = 0;
            foreach (var item in combination)
            {
                if (((item.a * 500) + (item.b * 100) + (item.c * 50)) == x )
                {
                    cnt++;
                }
            }

            Console.WriteLine(cnt);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) 
                {
                    return inputStream.Dequeue();
                }

                string[] tmp = _stream.ReadLine().Split(_separator);
                
                for (int i = 0; i < tmp.Length; ++i)
                {
                    inputStream.Enqueue(tmp[i]);
                }
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 15568
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C,N;
  cin >> A >> B >> C >> N;
  int sum = A + B + C;
  int D = max({A,B,C});
  rep(i,N)
  {
    sum += D;
    D *= 2;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define vii vector<pair<int,int> >
#define vi vector<ll>
#define ll long long
#define rep(i,a,b) for(i=a;i<=b;i++)
#define inf 100000000000000000

using namespace std;

int n,k;
ll h[100001];
ll dp[100001]; 

// ll f(int id)
// {
//     if(id==n) return 0;
//     if(dp[id]!=-1) return dp[id];
//     ll a,b;
//     if(id+1<n)
//     {
//         a=abs(h[id]-h[id+1])+f(id+1);
//     }
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    //fill(dp,dp+n,-1);
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--)
    {
        dp[i]=inf;
        for(int j=i+1;j<=min(i+k,n-1);j++)
        {
            dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j]);
        }
    }
    cout<<dp[0]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

char s[100001];
int val[50001];
int sub[50001];
int par[50001];
int n, m;
struct oper {
    int l, r;
    void scan() {
        cin >> l >> r;
        --l; --r;
    }
} op[100000];

int find(int x) {
    if (par[x] != x) return par[x] = find(par[x]);
    return x;
}

int merge(int x, int y) {
     x = find(x);
     y = find(y);
     if (x == y) return 0;
     par[y] = x;
     sub[x] += sub[y];
     return 1;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> s >> n;
	m = strlen(s);
	int od = m & 1;
	if (od) {
        for (int i = m >> 1; i + 1 < m; ++i) {
            s[i] = s[i + 1];
        }
	}
	m = (m >> 1) << 1;
	for (int i = 0; i < n; ++i) {
        op[i].scan();
        if (od) {
            if ((m >> 1) < op[i].l) --op[i].l;
            if ((m >> 1) <= op[i].r) --op[i].r;
            if (op[i].r < op[i].l) {
                --i; --n;
                continue;
            }
        }
        if ((m >> 1) <= op[i].l) {
            op[i].l = m - 1 - op[i].l;
            op[i].r = m - 1 - op[i].r;
            swap(op[i].l, op[i].r);
        }
        else if ((m >> 1) <= op[i].r) {
            op[i].r = m - 1 - op[i].r;
            if (op[i].r < op[i].l) swap(op[i].l, op[i].r);
            --op[i].r;
            if (op[i].r < op[i].l) {
                --i; --n;
                continue;
            }
        }
        
	}
	for (int i = 0; i < (m >> 1); ++i) {
        val[i] = (s[i] - s[m - 1 - i] + 26) % 26;
	}
	sub[0] = val[0];
	for (int i = 1; i <= (m >> 1); ++i) {
        sub[i] = ((val[i] - val[i - 1]) % 26 + 26) % 26;
	}

	for (int i = 0; i <= (m >> 1); ++i) {
        par[i] = i;
	}
	
	for (int i = 0; i < n; ++i) {
        merge(op[i].l, op[i].r + 1);
	}
	for (int i = 0; i <= (m >> 1); ++i) {
        if (find(i) != i) continue;
        if (sub[i] % 26) {
            printf("NO\n");
            return 0;
        }
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 1792
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w; cin>>h>>w;
  constexpr ll MOD = 1e9+7;
  vector<vector<ll>> dp(h, vector<ll>(w, 0));
  dp[0][0] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c; cin>>c;
      if (c == '#')
        continue;
      if (i > 0)
        (dp[i][j] += dp[i-1][j])%=MOD;
      if (j > 0)
        (dp[i][j] += dp[i][j-1])%=MOD;
    }
  }
  cout << dp[h-1][w-1] << endl;

  return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define rep(i,a,b) for(register int i=(a);i<(b);++i)
#define pb push_back
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
	const uint32 Buffsize=1<<15,Output=1<<24;
	static char Ch[Buffsize],*S=Ch,*T=Ch;
	inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
	static char Out[Output],*nowps=Out;
	
	inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

	template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}

	inline void readmd(int&x)
	{
		x=0;static char ch;
		for(ch=getc();!isdigit(ch);ch=getc());
		for(;isdigit(ch);ch=getc())x=(x*10ll+(ch^48))%998244353;
	}
}
using namespace IO;

void file()
{
	FILE*DSD=freopen("water.in","r",stdin);
	FILE*CSC=freopen("water.out","w",stdout);
}

const int MAXN=1e5+7;

static int n,p;

static int cnt[2];

inline void init()
{
	read(n),read(p);
	static int x;
	Rep(i,1,n)read(x),++cnt[x&1];
}

inline ll power(int u,int v)
{
	register ll sm=1;
	Rep(i,1,v)sm*=u;
	return sm;
}

inline void solve()
{
	if(p==1)cout<<(cnt[1]?power(2,cnt[0]+cnt[1]-1):0)<<endl;
	else cout<<((cnt[1]?power(2,cnt[0]+cnt[1]-1):power(2,cnt[0])))<<endl;
}

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

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        int leng = str.Length;
        char []ans=new char[leng];
        for (int i=0;i<leng;i++)
        {
            ans[i]=str[leng-1-i];
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 5260
def solve(n, x, y):
    res_list = [0] * n
    for i in range(n - 1):
        for j in range(i + 1, n):
            d = min(j - i, abs(i - x + 1) + abs(j - y + 1) + 1)
            res_list[d] += 1
    # print(res_list)
    return res_list[1:]


def main():
    n, x, y = map(int, input().split())
    res_list = solve(n, x, y)
    for res in res_list:
        print(res)


def test():
    assert solve(5, 2, 4) == [5, 4, 1, 0]
    assert solve(3, 1, 3) == [3, 0]
    assert solve(7, 3, 7) == [7, 8, 4, 2, 0, 0]


if __name__ == "__main__":
    test()
    main()


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

int main()
{
	while(1){
		double X, Ha;
		cin >> X >> Ha;
		if (X== 0 && Ha == 0)
		{
			break;
		}
		double x = (double)X;
		double h = (double)Ha;
		double S, H;
		H = sqrt(x * x + x * x) / 2;
		H = sqrt(H * H + h * h);
		H = sqrt(H * H - x * x / 4);
		S = x * x + x * H * 2;
		printf("%.10f\n", S);
	}	
}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
int main( void )
{
  while( 1 ){
    int N,M,x,y,r,dx,dy;
    char dir;
    int d[21][21];
    for( x=0; x<=20; x++ ){
      for( y=0; y<=20; y++ ){
        d[x][y] = 0;
      }
    }

    cin >> N;
    if( N == 0 ) break;
    for( int i=0; i<N; i++ ){
      cin >> x >> y;
      d[x][y] = 1;
    }

    cin >> M;
    x = y = 10;
    int n = d[x][y];
    d[x][y] = 0;
    for( int i=0; i<M; i++ ){
      cin >> dir >> r;
      switch( dir ){
        case 'N' : dx=0; dy=1; break;
        case 'E' : dx=1; dy=0; break;
        case 'S' : dx=0; dy=-1; break;
        case 'W' : dx=-1; dy=0; break;
      }
      for( int j=0; j<r; j++ ){
        x += dx; y += dy;
        n += d[x][y];
        d[x][y] = 0;
      }
    }
    if( N == n ){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1152
a,b,c,x,y=map(int,input().split())

loop=max(x*2,y*2)+1
ans=10**9

for i in range(loop):
  ab=i//2
  if x-ab>=0 and y-ab>=0:
    ans=min(ans,a*(x-ab)+b*(y-ab)+c*i)
  if x>=ab and y<ab:
    ans=min(ans,a*(x-ab)+c*i)
  if x<ab and y>=ab:
    ans=min(ans,b*(y-ab)+c*i)
  if x<ab and y<ab:
    ans=min(ans,c*i)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        //1 番目の数と 2 番目の数を比べて逆順ならば交換する。
        //2 番目の数と 3 番目の数を比べて逆順ならば交換する。
        //1 番目の数と 2 番目の数を比べて逆順ならば交換する。

        int tmp;
        if (a > b) {
            tmp = b;
            b = a;
            a = tmp;
        } if (b > c) {
            tmp = c;
            c = b;
            b = tmp;
        } if (a > b) {
            tmp = b;
            b = a;
            a = tmp;
        }
        System.out.println(""+a+' '+b+' '+c);
    }
}


Measured memory_bytes: 26144
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
//#include "cxx-prettyprint/prettyprint.hpp"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  vector<set<int>> pos(26);
  rep(i, s.size()) {
    pos.at(s[i] - 'a').insert(i);
  }
  rep(i, t.size()) {
    if (pos.at(t[i] - 'a').lower_bound(0) == pos.at(t[i] - 'a').end()) {
      cout << "-1" << endl;
      return 0;
    }
  }
  ll cur = -1;
  ll ans = 0;
  rep(i, t.size()) {
    auto it = pos.at(t[i] - 'a').lower_bound(cur+1);
    if (it == pos.at(t[i] - 'a').end()) {
      cur = *pos.at(t[i] - 'a').lower_bound(0);
      ans += s.size();
    } else {
      cur = *it;
    }
    if (i == t.size() - 1) {
      ans += cur+1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5120
// O(n log^2 n)

#include<set>
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

int n,hp[300000],emit[300000];

// num 匹の微生物を生かせるかを判定
bool check(int num){
	multiset<int> S;
	ll emit_sum=0;
	for(int i=n-1;i>=0;i--){ // 生かす微生物の最小 HP を決めうち
		emit_sum+=emit[i];
		S.insert(emit[i]);
		if(S.size()<num) continue;
		if(S.size()>num){ // S.size()==num+1
			// emit が一番大きい微生物は使わない
			emit_sum-=*S.rbegin();
			S.erase(--S.end());
		}
		if((ll)num*hp[i]>=emit_sum) return true;
	}
	return false;
}

int main(){
	scanf("%d",&n);
	static pair<int,int> tmp[300000];
	rep(i,n) scanf("%d%d",&tmp[i].second,&tmp[i].first);
	sort(tmp,tmp+n);
	rep(i,n){
		hp[i]=tmp[i].first;
		emit[i]=tmp[i].second;
	}

	int lo=0,hi=n;
	while(lo<hi){
		int mi=(lo+hi+1)/2;
		if(check(mi)) lo=mi; else hi=mi-1;
	}
	printf("%d\n",lo);

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   string s;
   cin >> s;

   bool flg = 0;
   if(s[0]==s[1] && s[1]==s[2]) flg = 1;
   else if( s[1]==s[2] && s[2]==s[3]) flg = 1;

   cout << (flg? "Yes":"No") << endl;


   return 0;
}

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

int main() {
  int N,a,b,c;
  cin >> N >> a>>b>>c;
  if (abs(N-b)<=c||(abs(N-a)<=c&&abs(a-b)<=c)) {
    cout << "Yes"<< endl;
  }
  else {
  cout << "No" <<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    float num;
    if (int(n) % 2 == 0)
    {
        num = n / 2;
    }
    else
    {
        num = (n + 1) / 2;
    }

    float a = num / n;
    printf("%.10f\n", a);

    return 0;
}

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

ll N,M,X;
vector<ll> C;
vector<vector<ll>> A;
ll ans = INF;

void dfs(ll i, vector<ll> books){
    if (i == N){
        ll total = 0;
        vector<ll> t(M, 0);
        for (auto book : books){
            total += C[book];
            rep(j, M){
                t[j] += A[book][j];
            }
        }

        bool is_OK = true;
        rep(j,M){
            if (t[j] < X){
                is_OK = false;
                break;
            }
        }
        if (is_OK){
            ans = min(ans, total);
        }
        return;
    }

    dfs(i+1, books);
    books.push_back(i);
    dfs(i+1, books); 
}

int main(){
    cin >> N >> M >> X;
    C.assign(N, 0);
    A.assign(N,vector<ll>(M,0));
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> A[i][j];
        }
    }

    dfs(0,vector<ll>());
    if (ans != INF) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define vi vector<int>
#define pii pair<int,int>
#define se second
using namespace std;
int t,a,b,c,x,y,k,n,q;
vi v(200005);
ll ans;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n ;
	ll x = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		x^=v[i];
	}       
	for (int i = 0; i < n; i++) {
		cout << (x^v[i])<<' ';
	}
	
}

Measured memory_bytes: 3900
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;


int main(){
    int N,M;
    cin >> N >> M;
    cout << N*(N-1)/2 + M * (M-1)/2 << endl;
}


Measured memory_bytes: 256
x = int(input())
import sys
for a in range(1000):
  for b in range(1000):
    if (a ** 5 - b ** 5) == x:
      print(str(a)+" "+str(b))
      sys.exit()
    elif(a ** 5 - (-b) ** 5) == x:
      print(str(a)+" "+str(-b))
      sys.exit()
    elif((-a) ** 5 - b ** 5) == x:
      print(str(-a)+" "+str(b))
      sys.exit()
    elif((-a) ** 5 - (-b) ** 5) == x:
      print(str(-a)+" "+str(-b))
      sys.exit()

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> ball(n);
  for(int i = 0; i < n; i++){
    int x, y;
    cin >> x >> y;
    ball.at(i) = {x, y};
  }
  
  map<pair<int, int>, int> cnt;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j) continue;
      cnt[{ball.at(i).first - ball.at(j).first, ball.at(i).second - ball.at(j).second}]++;
    }
  }
  
  int ans = 0;
  for(auto now : cnt){
    ans = max(ans, now.second);
  }
  
  cout << n - ans << endl;
}

Measured memory_bytes: 3676
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	string s;
	cin >> n >> s;
	int mn = 0, cnt = 0;
	for(char c : s){
		if(c == '('){ ++cnt; }
		else{ --cnt; }
		chmin(mn, cnt);
	}
	cout << string(-mn, '(') << s << string(cnt - mn, ')') << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 256
def main():
  n , y = map(int, input().split())
  y = y // 1000
  
  if n*10 >= y :
    for i in range(n+1):
      if 10 * i > y :
        break
      elif 10 * i + 5 * (n - i) < y:
        continue
      else:
        for j in range(n-i+1):
          if i * 10 + j * 5 > y:
            break
          elif i * 10 + j * 5 + (n - i - j) == y:
            return print(i, j, n - i - j)
            exit()
  return print(-1, -1, -1)

if __name__=='__main__':  
  main() 

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

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

int main() {
	int K, N;
	cin >> K >> N;
	vector<int> vec(N),vecl(N);
	rep(i, N) {
		cin >> vec.at(i);
		if (i > 0) vecl.at(i - 1) = vec.at(i) - vec.at(i - 1);
	}
	vecl.at(0) = vec.at(0) + K - vec.at(N - 1);
	sort(vecl.begin(), vecl.end());
	cout << K - vecl.at(N - 1) << endl;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int intNum = scan.nextInt();
		int b;
		int f;
		int r;
		int v;
		int[][] intArray1 = new int[3][10];
		int[][] intArray2 = new int[3][10];
		int[][] intArray3 = new int[3][10];
		int[][] intArray4 = new int[3][10];

		for(int i = 0; i < intNum; i++){
			b = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			v = scan.nextInt();
			if(b == 1){
				intArray1[f-1][r-1] = intArray1[f-1][r-1] += v;
			}else if(b == 2){
				intArray2[f-1][r-1] = intArray2[f-1][r-1] + v;
			}else if(b == 3){
				intArray3[f-1][r-1] = intArray3[f-1][r-1] + v;
			}else if(b == 4){
				intArray4[f-1][r-1] = intArray4[f-1][r-1] + v;
			}
		}

		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 10; j++){
				System.out.print(" " + intArray1[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 10; j++){
				System.out.print(" " + intArray2[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 10; j++){
				System.out.print(" " + intArray3[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 10; j++){
				System.out.print(" " + intArray4[i][j]);
			}
			System.out.println();
		}
		scan.close();
	}
}

Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int a, b;
  cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout<<"Possible"<<endl;
  }else{
    cout<<"Impossible"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
#define MAX 500000
#define SENTINEL 2000000000

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
struct Node
{
    ll key;
    Node *right,*left,*parent;
};
Node *root, *NIL;

Node *find(Node *u,ll k){
    while(u!=NIL&&k!=u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(ll k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    //メモリの確保
    z = (Node *)malloc(sizeof(Node));
    z -> key = k;
    z -> left = NIL;
    z -> right = NIL;

    while( x!=NIL ){
        y = x;
        if(z -> key < x ->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z -> parent = y;
    if(y ==NIL){
        root = z;
    }else{
        if(z ->key < y->key){
            y ->left = z;
        }else{
            y ->right = z;
        }
    }
}
void PreorderWalk(Node *u){
    if(u == NIL)return;
    cout << " "<< u->key; 
    PreorderWalk(u->left);
    PreorderWalk(u->right);
}

void InorderWalk(Node *u){
    if(u == NIL)return; 
    InorderWalk(u -> left);
    cout << " "<< u->key;
    InorderWalk(u -> right);
}


int main(){
    ll n,i,x;
    string com;
    cin >> n;
    REP(i,n){
        cin >> com;
        if(com == "insert"){
            cin >> x;
            insert(x);
        }else if(com =="print"){
            InorderWalk(root);
            cout << endl;
            PreorderWalk(root);
            cout << endl;
        }else if(com[0] == 'f'){
            cin >> x;
            Node *t = find(root,x);
            if(t!=NIL){cout << "yes" << endl;}
            else{cout << "no" << endl;}
        }
    }
    return 0;
}


Measured memory_bytes: 21904
from math import pi,cos,sqrt
a,b,h,m = map(int,input().split())
minutes = h*60 + m
Dh = minutes * 0.5 % 360
Dm = minutes * 6 % 360
arg = abs(Dh-Dm)*pi/180
print(sqrt(a**2 + b**2 - 2*a*b*cos(arg)))

Measured memory_bytes: 9172
/*input
1817181712114



*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;
    
int fast_exp(int base, int exp,int MOD) {
    int res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%MOD;
       base=(base*base)%MOD;
       exp/=2;
    }
    return res%MOD;
}


int32_t main() {
    IOS;
	int n,p = 2019;
	string s;
	cin >> s;
	n = s.length();
	map<int,int> mx;
	int count = 0;
	int sum=0;
	int ans = 0;
	mx[0] = 1;
	for(int i=n-1;i>=0;i--){
		sum += ((s[i]-'0')*fast_exp(10,count,p))%p;
		
		sum=sum%p;
		//cout<<sum<<endl;
		mx[sum]++;
		ans+=(mx[sum]-1);
		count++;
	}
	cout<<ans<<endl;
    return 0;
}       



Measured memory_bytes: 3800
#include <stdio.h>

typedef long long ll;

int main() {

	ll N,K;

	scanf("%lld %lld",&N,&K);

	ll i;

	ll ans=0ll;

	for(i=K+1ll;i<=N;i+=1ll){
	ll r=N%i;
	ll p=N/i;
	if(i-K>0ll){ans+=p*(i-K);}
	if(r-K+1ll>0){ans+=r-K+1ll;}
	}

	if(K==0ll){ans=N*N;}

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

class BinomialCoefficient(object):

    def __init__(self, N=510000, MOD=10**9+7):
        self.fac = [1, 1]
        self.finv = [1, 1]
        self.inv = [0, 1]
        self.MOD = MOD
        for i in range(2, N + 1):
            self.fac.append((self.fac[-1] * i) % MOD)
            self.inv.append((-self.inv[MOD % i] * (MOD // i)) % MOD)
            self.finv.append((self.finv[-1] * self.inv[-1]) % MOD)

    def comb(self, n, r):
        if r < 0 or n < r or r < 0:
            return 0
        return self.fac[n] * self.finv[r] * self.finv[n - r] % self.MOD

K = I()
S = input()

bi = BinomialCoefficient(N=10 ** 6 * 2 + 1)
ans = 0
# i := Snのindex
for i in range(len(S) - 1, len(S) + K):
    tail = len(S) + K - i - 1
    lans = bi.comb(i, len(S) - 1)
    lans = lans * pow(25, K - tail, MOD) % MOD
    lans = lans * pow(26, tail, MOD) % MOD
    ans = (ans + lans) % MOD
print(ans)

Measured memory_bytes: 198576
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

sum1 = 0
sum2 = 0
for a in A:
  sum1 = (sum1 + a)
  sum2 = (sum2 + a**2)

answer = ((sum1**2 - sum2) // 2) % mod
print(answer)

Measured memory_bytes: 31748
n = int(input())
r = [int(input()) for i in range(n)]
min_r = r[0]
max_d = r[1]-r[0]
for i in range(1,n):
    max_d = max(max_d, r[i] - min_r)
    min_r = min(min_r, r[i])
print(max_d)



Measured memory_bytes: 13592
#include <iostream>

using namespace std;

int main() {
    string s;
    int joi_count = 0, ioi_count = 0;
    while (cin >> s) {
        for (int i = 0; i < s.length()-2; i++) {
            if (s.substr(i, 3) == "JOI") {
                joi_count++;
            } else if (s.substr(i, 3) == "IOI") {
                ioi_count++;
            }
        }
        cout << joi_count << endl;
        cout << ioi_count << endl;
        joi_count = 0;
        ioi_count = 0;
    }
    
}


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

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

	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES";
	}
	else cout << "NO";
}


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

int main() {
  string s;
  cin >> s;
  if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  double W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << fixed << setprecision(10) << (H * W) / 2.0 << " " << ((x + x == W) && (y + y == H)) << endl;

  return 0;
}


Measured memory_bytes: 3800
#include <stdio.h>

int main(void) {
	long i,n, k;
	scanf("%ld", &n);
	scanf("%ld", &k);
	long tmp;
	tmp = n % k;
	long tmp2 = -1 * (tmp - k);
	if(tmp > tmp2) {
		printf("%ld", tmp2);
	}
	else {
		printf("%ld", tmp);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main() {
  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);
  vector<vector<int> > is(26);
  for(int i = 0; i < n; i++) {
    is[s[i]-'a'].push_back(i);
  }
  for(int i = 0; i < n; i++) {
     is[s[i]-'a'].push_back(i+n);
  }
  ll ans = 0;
  int p = 0; // after p
  for(int i = 0; i < m; i++) {
    int c = t[i]-'a';
    if (sz(is[c]) == 0) {
      puts("-1");
      return 0;
    }
    p = *lower_bound(is[c].begin(), is[c].end(), p)+1;
    if (p >= n) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
typedef long long ll;
#define db double
#define ui unsigned int
#define ll long long
#define ull unsiged ll
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l)for(int i=r;i>=l;i--)
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1e9+7
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define inf  INT_MAX
#define lnf LLONG_MAX
#define mii map<int,int>
#define mll map<ll,ll>
#define mil map<int,ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define boots ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
using namespace std;
const int MX = 3e5 + 7;
ll modulo(ll num, ll MOD = mod) { return ((num%MOD) + MOD) % MOD; }
ll power(ll b, ll e, ll MOD = mod) { ll ans = 1; while (e) { if (e % 2) ans = (ans*b) % MOD; b = (b*b) % MOD; e /= 2; } return ans; }
ll inv(ll num, ll MOD = mod) { return power(modulo(num), MOD - 2, MOD); } ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a%b)); }
ll dp[MX];
int main()
{
    //boots;
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=1;i<=n;i++)
        {
            int a;
            cin>>a;
            if(a>=k)ans++;
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 256