akhauriyash/Code-Regression huggingface dataset:
using System;

namespace teeeeeeeeeeeeeeest
{
    class Program
    {
        static void Main(string[] args)
        {
            string n,m;
            int N,a=1;
            n = Console.ReadLine();
            N = int.Parse(n);
            m = Console.ReadLine();
            string[] M;
            M = m.Split();
            for(int i = 0; i < N - 1; i++)
            {
                if (int.Parse(M[i]) >= int.Parse(M[i + 1]))
                {
                    a++;
                }
            }
            Console.WriteLine(a);
            Console.WriteLine(N);
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 22604
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string s;
    cin>>s;
    set<char> st;
    rep(i, s.size()){
        st.insert(s[i]);
    }
    if(st.size() == s.size()){
        cout<<"yes"<<endl;
    }
    else cout<<"no"<<endl;
    return 0;
}

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

char *tmp[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

char buf[2000];
string out;

int main() {
	int n;
	cin >> n;
	while(n--) {
		cin >> buf;
		int slen = strlen(buf);
		int i, j;
		
		for( i = 0; i < slen; i++ ) {
			char c = buf[i];
			j = -1;
			for( ; i < slen; i++ ) {
				if ( buf[i] == '0' )
					break;
				j++;
			}
			
			if ( j >= 0 )
				out += tmp[c-'0'][ j % strlen(tmp[c-'0'])];
		}
		cout << out << endl;
		out.clear();
	}
	return 0;
}

Measured memory_bytes: 1204
unittest
{
	assert( [ "1 2 10 20 15 200" ].parse.expand.solve == "110 10" );
	assert( [ "1 2 1 2 100 1000" ].parse.expand.solve == "200 100" );
	assert( [ "17 19 22 26 55 2802" ].parse.expand.solve == "2634 934" );
}



import std.algorithm;
import std.conv;
import std.functional;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abcdef = input.front.split.to!( long[] );
	return tuple( abcdef[ 0 ], abcdef[ 1 ], abcdef[ 2 ], abcdef[ 3 ], abcdef[ 4 ], abcdef[ 5 ] );
}

auto solve( long a, long b, long c, long d, long e, long f )
{
	a *= 100;
	b *= 100;
	
	auto ws = memoize!combisum( a, b, f );
	ws.popFront;		// 0は削る
	
	auto pm = -1.0f;
	auto wm = 0L;
	auto sm = 0L;
	foreach( w; ws )
	{
		auto st = min( w / 100 * e, f - w );
		auto s = memoize!combisum( c, d, st ).reduce!max;
		auto p = 100.0f * s / ( w + s );
		
		if( pm < p )
		{
			pm = p;
			wm = w;
			sm = s;
		}
	}
	
	return format( "%d %d", wm + sm, sm );
}

auto combisum( long x, long y, long t )
{
	long[] cs;
	
	for( auto xi = 0; true; xi++ )
	{
		auto xc = x * xi;
		if( t < xc ) break;
		
		for( auto yi = 0; true; yi++ )
		{
			auto yc = y * yi;
			auto c = xc + yc;
			if( t < xc + yc ) break;
			
			cs ~= xc + yc;
		}
	}
	
	return cs.sort().uniq;
}


Measured memory_bytes: 1404
import sys
sys.setrecursionlimit(10000000)


def gcd(aa, b):
    if b == 0:
        return aa
    return gcd(b, aa % b)


mod = int(1e9 + 7)
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) // gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek // a[i]
print(int(s % mod))




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

using namespace std;

int main(){

  long long int n, a, b;
  cin>>n>>a>>b;

  long long int x[n]; 
  for(int i=0; i<n; i++) cin>>x[i];
  
  long long int walk_max=b/a;
  long long int tired=0;

  for(int i=0; i<n-1; i++){
    if(x[i+1]-x[i]>walk_max) tired+=b;
    else if(x[i+1]-x[i]<=walk_max){
      tired+=a*(x[i+1]-x[i]);
    }
  }

  cout<<tired<<endl;
}


Measured memory_bytes: 4428
#include<stdio.h>
#include<string.h>
#include<math.h>
int a,s,d[1001],f,g,h;
char z[21];
int main(void)
{
	int i,j,k;
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
		h=a;
		for(i=1;i<=a;i++) d[i]=i;
		j=0;
		for(i=1;i<=s;i++){
			scanf("%s",z);
			if(h>1){
				f=0;
				j++;
				while(1){
					if(j>a) j=1;
					if(d[j]==0) j++;
					if(j>a) j=1;
					if(d[j]!=0) break;
				}
				if(i%3==0){
					if(i%5!=0){
						f=strcmp(z,"Fizz\0");
						if(f!=0){
							h--;
							d[j]=0;
						}
					}
					else if(i%5==0){
						f=strcmp(z,"FizzBuzz\0");
						if(f!=0){
							h--;
							d[j]=0;
						}
					}
				}
				else if(i%5==0){
					if(i%3!=0){
						f=strcmp(z,"Buzz\0");
						if(f!=0){
							d[j]=0;
							h--;
						}
					}
				}
				else if(i%3!=0&&i%5!=0){
					f=0;
					for(k=0;k<strlen(z);k++){
						f*=10;
						f+=z[k]-'0';
					}
					if(f!=i){
						d[j]=0;
						h--;
					}
				}
			}
		}
		for(i=1;i<=a;i++){
			if(d[i]!=0){
				printf("%d",i);
				h--;
				if(h>0) printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<a) cout<<k;
	else if(a+b>=k) cout<<a;
	else cout<<a-(k-(a+b));
	return 0;
}

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

using namespace std;
#define ll long long
const int MAX =1e5+9;
ll n, m, k, a[MAX],a1[MAX],a2[MAX], b[MAX],b1[MAX],b2[MAX];
int l,s,c;




int main ()
{

    string s1,s2,s3 ;
    cin>>s1>>s2>>s3;

	cout<<s1[0]<<s2[1]<<s3[2];
}


Measured memory_bytes: 256
N, M = map(int, input().split())
mod = 1000000007

if abs(N - M) > 1:
    print(0)
elif (N + M) % 2 == 1:
    x = max(N, M)
    y = min(N, M)
    Sum = 1
    for i in range(N + M):
        if i % 2 == 0:
            Sum *= x - (i // 2)
            Sum %= mod
        else:
            Sum *= y - (i // 2)
            Sum %= mod
    print(Sum)
else:
    Sum = 1
    for i in range(2 * N):
        Sum *= N - (i // 2)
        Sum %= mod
    Sum *= 2
    Sum %= mod
    print(Sum)
     

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

vector<int> LIS(vector<int>& A){
    int N = A.size();
    const int INF = 1e9;
    vector<int> dp(N+1, INF), dp2(N+1), prev(N+1);
    int last = 0;
    for(int i=0; i<N; i++){
        int pos = upper_bound(dp.begin(), dp.end(), A[i]) - dp.begin();
        dp[pos] = A[i];
        dp2[pos] = i;
        prev[i] = pos>0 ? dp2[pos-1] : -1;
        last = max(last, pos);
    }

    vector<int> ret;
    int idx = dp2[last];

    while(idx >= 0){
        ret.push_back(A[idx]);
        idx = prev[idx];
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i] *= -1;
    }
    cout << LIS(A).size() << endl;
    return 0;
}


Measured memory_bytes: 2428
#include <iostream>
#include <algorithm>
#include <string>
#define all(a) (a).begin(), (a).end()
using namespace std;

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

  string s, t; cin >> s >> t;
  sort(all(s));
  sort(all(t), greater<char>());

  cout << (s < t ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    lli n;
    cin >> n;
    vector<lli> a(n);
    map<lli, lli> m;
    rep(i, n)
    {
        cin >> a[i];
        m[a[i]]++;
    }
    lli ans = 0;
    for (auto s : m) {
        if (s.first <= s.second) {
            ans += s.second - s.first;
        } else {
            ans += s.second;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7040
N = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
counter = 0

for _ in range(N):
	s = input()[0]
	if s == 'M':
		m += 1
	elif s == 'A':
		a += 1
	elif s == 'R':
		r += 1
	elif s == 'C':
		c += 1
	elif s == 'H':
		h += 1

ans = m*a*(r+c+h) + m*r*(c+h) + m*c*h \
			+ a*r*(c+h) + a*c*h + r*c*h

print(ans)

Measured memory_bytes: 3064
N,K=map(int,input().split())
a=list(map(int,input().split()))
#dp[i]:=i個の山の時に、直後のプレイヤーの勝ち負け判定（１：勝　０：負）

dp=[-1]*(K+1)
dp[0]=0

for i in range(1,K+1):
    if all(dp[i-a[j]] if i-a[j]>=0 else 1 for j in range(N)):#直後のプレイヤーが取った後の手が全て勝ちパターンなら、負け確定
        dp[i]=0
    else:
        dp[i]=1

print('First' if dp[K] else 'Second')

Measured memory_bytes: 45404
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    int h1,h2,m1,m2;
    ll k;
    cin>>h1>>m1>>h2>>m2>>k;
    int k1=0,k2=0;
    if(m1<=m2) {
        k1 =(h2-h1)*60+(m2-m1);
    }
    else {
        k1 =(h2-h1-1)*60+(m2+60-m1);
    }
  cout <<k1-k<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vull = vector<ull>;
#define rep(i, n) for (ull i = 0; i < n; ++i)
#define rep1(i, n) for (ull i = 1; i < n; ++i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}
template <typename T> void arrout(const T arr, int n) {
  for (int i = 0; i < n; ++i, cout << (i != n ? " " : "\n")) {
    cout << arr[i];
  }
}

void solve() {
  // main coding
  ll a,b,c; cin>>a>>b>>c;
  cout<<min(c,b/a)<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

void walk(vector<ll> & distance, vector<ll> & values, vector<ll> & consumption, vector<ll> & nutrition, vector<ll> & gain_max_reminder, ll N){
    for (auto &&i: boost::irange(1LL, N+1)){
        consumption.at(i) = distance.at(i-1);
        nutrition.at(i) = nutrition.at(i-1) + values.at(i-1);
    }
    ll maximum = 0;
    for (auto &&i: boost::irange(1LL, N+1)){
        if (maximum < nutrition.at(i) - consumption.at(i)){
            maximum = nutrition.at(i) - consumption.at(i);
        }
        gain_max_reminder.at(i) = maximum;
    }
}



int main() {
    ll N, C;
    cin >> N >> C;
    vector<ll> xs_right(N, 0), vs_right(N, 0);
    for (auto &&i: boost::irange(0LL, N)){
        cin >> xs_right.at(i) >> vs_right.at(i);
    }
    vector<ll> xs_left(xs_right.begin(), xs_right.end());
    vector<ll> vs_left(vs_right.begin(), vs_right.end());
    reverse(xs_left.begin(), xs_left.end());
    reverse(vs_left.begin(), vs_left.end());
    for (auto &&i: boost::irange(0LL, N)){
        xs_left.at(i) = C - xs_left.at(i);
    }
    ll right_max, right_idx, left_max, left_idx;
    vector<ll> consumption_right(N+1, 0), consumption_left(N+1, 0), nutrition_right(N+1, 0), nutrition_left(N+1, 0), gain_max_reminder_left(N+1, 0), gain_max_reminder_right(N+1, 0);
    walk(xs_right, vs_right, consumption_right, nutrition_right, gain_max_reminder_right, N);
    walk(xs_left, vs_left, consumption_left, nutrition_left, gain_max_reminder_left, N);

    vector<ll> gain_right_left(N+1, 0), gain_left_right(N+1, 0);
    for (auto &&i: boost::irange(0LL, N + 1)){
        gain_right_left.at(i) = nutrition_right.at(i) - consumption_right.at(i) * 2 + gain_max_reminder_left.at(N - i);
    }
    for (auto &&i: boost::irange(0LL, N + 1)){
        gain_left_right.at(i) = nutrition_left.at(i) - consumption_left.at(i) * 2 + gain_max_reminder_right.at(N - i);
    }

    ll maximum = 0;
    for (auto &&i: boost::irange(0LL, N+1)){
        maximum = max(gain_right_left.at(i), max(gain_left_right.at(i), maximum));
    }
    cout << maximum;
    return 0;
}

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

#define fst() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef long double ld;

vector< pair<int,int > > gr[200005];
int val[200005];
bool visit[200005],flag;

void dfs(int a,int wt)
{
  val[a]=wt;
  visit[a]=true;
  int i;
  for(i=0;i<gr[a].size();i++)
  {
    if(!visit[gr[a][i].first])
      dfs(gr[a][i].first,wt+gr[a][i].second);
    else
    {
      if(val[gr[a][i].first]!=wt+gr[a][i].second)
        flag=false;
    }
  }
}
int main()
{
  fst();
  int n,m,i,l,r,d;
  cin>>n>>m;
  for(i=0;i<m;i++)
  {
    cin>>l>>r>>d;
    gr[l].pb(mp(r,d));
    gr[r].pb(mp(l,-d));
  }
  flag=true;
  for(i=0;i<n;i++)
  {
    if(!visit[i])
    {
      dfs(i,0);
    }
  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

const int M = 2e3 + 2;

bool mat[M][M];
int preC[M][M], preR[M][M], suffC[M][M], suffR[M][M];

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

    int n, m, ans = 0;
    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            char c;
            cin >> c;
            mat[i][j] = (c == '.');
        }

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (mat[i][j]) {
                preC[i][j] = 1 + preC[i][j - 1];
                preR[i][j] = 1 + preR[i - 1][j];
            }

    for (int i = n; i >= 1; i--)
        for (int j = m; j >= 1; j--)
            if (mat[i][j]) {
                suffC[i][j] = 1 + suffC[i][j + 1];
                suffR[i][j] = 1 + suffR[i + 1][j];
            }

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (mat[i][j])
                ans = max(ans, 1 + preC[i][j - 1] + suffC[i][j + 1] + preR[i - 1][j] + suffR[i + 1][j]);

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 66816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h[100001];
ll dp[100001];
int main() {
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for (int i = 3; i <= n; i++) {
        ll temp = 1LL << 60;
        for (int j = 1; j <= k; j++)
            if (i - j >= 1)
                temp = min(temp, dp[i-j] + abs(h[i] - h[i-j]));
        dp[i]= temp;
      
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;

class _0106
{
    public static void Main()
    {
        Dictionary<string, int> index = new Dictionary<string, int>();
        string bar;
        int ans, tans, ca, cb, cc;
        for (int i = 100; i <= 50000; i += 100)
        {
            ans = int.MaxValue;
            for (int a = 0; a <= i / 200; a++ )
                for(int b = 0; b <= i / 300; b++)
                    for (int c = 0; c <= i / 500; c++)
                    {
                        if (a * 200 + b * 300 + c * 500 == i)
                        {
                            ca = a % 5; cb = b % 4; cc = c % 3;
                            tans = (int)(380 * (a - ca) * 0.8 + 550 * (b - cb) * 0.85 + 850 * (c - cc) * 0.88)
                                    + 380 * ca + 550 * cb + 850 * cc;
                            if (tans < ans) ans = tans;
                        }
                    }
            index[i.ToString()] = ans;
        }
        while ((bar = Console.ReadLine()) != null && bar[0] != '0')
            Console.WriteLine(index[bar].ToString());
    }
}

Measured memory_bytes: 5784
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void) {
  int n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }
  return EXIT_SUCCESS;
}



Measured memory_bytes: 256
while True:
	n = int(raw_input())
	if n == 0: break
	data = {}
	order = []
	for i in range(n):
		id,price,quant = map(int, raw_input().split())
		if id in data:
			data[id] += price*quant
		else:
			data[id] = price*quant
			order.append(id)
	if max(data.values()) < 1000000:
		print "NA"
	else:
		for k in order:
			if data[k] >= 1000000: print k
	

Measured memory_bytes: 4332
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    string S,T;
    cin >> S >> T;

    out(T+S);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <queue>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	map<char, vector<int>> da;
	for (int i = 0;i < n;i++) {
		if (da.count(s[i])) {
			da[s[i]].push_back(i);
		}
		else {
			da[s[i]] = { i };
		}
	}
	int no = -1,gg=0;
	long long ans = 0;
	for (int i = 0;i < m;i++) {
		if (da.count(t[i])) {
			int z = da[t[i]].size();
			if (da[t[i]][z - 1] > no) {
				no = *upper_bound(da[t[i]].begin(), da[t[i]].end(), no);
			}
			else {
				no = da[t[i]][0];
				gg++;
			}
		}
		else {
			ans = -1;
			break;
		}
	}
	if (ans == -1) {
		cout << -1 << endl;
	}
	else {
		cout << (long long)gg*n + no + 1<< endl;
	}
}

Measured memory_bytes: 1216
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll ans = 0 ;
	for(int i=0;i<=n;i++){
		if(i%3!=0&&i%5!=0) ans += i ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define rep(p,a,b)    for(ll p=a;p<b;p++)
#define sz(v) ((int)v.size())
#define all(v) (v).begin(), (v).end()
#define INF 0x3f3f3f3f

typedef pair<int,pair<int,int>> ppi;

ll nextPowerOf2(ll n)   
{ 
	n--; 
	n |= n >> 1ll; 
	n |= n >> 2ll; 
	n |= n >> 4ll; 
	n |= n >> 8ll; 
	n |= n >> 16ll; 
	n++; 
	return n; 
}


int main() {
	
	#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll t,i,j,n,ans,k;
	
	//cin>>t;
	//cout<<t;
	t = 1;
	while(t--)
	{
		cin>>k>>n;
		ans = LLONG_MAX;
		
		vector<ll> v(n);
		rep(p,0,n)cin>>v[p];

		rep(p,0,n-1)ans = min(ans,k-abs(v[(p+1)%n] - v[p]));
		ans = min(ans,k-(k-v[n-1]+v[0]));
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

void solve() {
  int n; string s; cin >> n >> s;

  if (n%2) {
    cout << "No\n";
    return;
  }
  
  rep(i,n/2) {
    if (s[i] != s[i+n/2]) {
      cout << "No\n";
      return;
    }
  }

  cout << "Yes\n";
  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
map<ll,ll> ma;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int n,m;  cin >> n >> m;
  vector<ll> v(n+1,0);
  rep(i,0,m){
    int x,y;  cin >> x >> y;
    --x;  --y;
    v[x]++;
    v[y+1]--;
  }
  rep(i,0,n){
    v[i+1] += v[i];
  }
  ll cnt = 0;
  rep(i,0,n){
    if(v[i]==m) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//素数判定O(√n)
bool is_prime(ll n){
  for(ll i=2;i*i<=n;i++){
    if(n%i==0)return false;
  }
  return n!=1;
}
int main(){
  ll n;cin>>n;
  vl vec;
  ll i=1;
  while(true){
    ll k=5*i+1;
    if(is_prime(k))vec.push_back(k);
    if(vec.size()==n)break;
    i++;
  }
  rep(i,n-1){
    cout<<vec[i]<<" ";
  }
  cout<<vec[n-1]<<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<(ll)(n); i++)

int main(){
  ll n, m, p, cnt=0 ;
  cin >> n >> m;
  REP(i, m) {
    cin >> p;
    cnt += p;
  }
  
  if (cnt > n) cout << -1 << endl;
  else cout << n - cnt << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>
 int main(void){
int a,b,c,d;
scanf("%d%d%d",&a,&b,&c);
while(1){

if(a>b)
   d = a,a = b,b = d;
if(b>c)
    d = b,b = c,c =d;
if(a>c)
    d =a,a = c,c = d;
if(a<=b&&b<=c){
    printf("%d %d %d\n",a,b,c);
    break;
    }
}
return 0;

 }

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define INF 1e9
#define MOD 1000000007
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(void) {
    int N;
    cin >> N;
    vector<vector<int>> D(N, vector<int>(2));

    for (int i = 0; i < N; i++)
    {
        cin >> D[i][0] >> D[i][1];
    }
    
    vector<int> streak(N+1, 0);
    
    for (int i = 0; i < N; i++)
    {
        if(D[i][0] == D[i][1]){
            streak[i+1] = streak[i] + 1;
        } else {
            streak[i+1] = 0;
        }
    }

    int maxStreak = *max_element(streak.begin(), streak.end());
    if(maxStreak >= 3){
        cout << "Yes" << endl;
    } else{
        cout << "No" <<endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#define P pair<int, int>

using namespace std;

int n, d[109];
vector<int> G[109];
bool check[109];


int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    int u, k, v;
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> v;
      G[u].push_back(v);
    }
  }
  memset(check, false, sizeof(check));
  memset(d, -1, sizeof(d));
  queue<P> Q;
  Q.push(P(1, 0));
  check[1]=true;
  while(!Q.empty()){
    P p = Q.front();Q.pop();
    int n=p.first, dis = p.second;
    d[n] = dis;
    for(int i=0;i<G[n].size();i++){
      if(!check[G[n][i]]){
        check[G[n][i]]=true;
        Q.push(P(G[n][i], dis + 1));
      }
    }
  }
  for(int i=1;i<=n;i++)cout << i << ' ' << d[i] << endl;
}


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

int main(){
	ll n, d;
  	cin >> n >> d;
  	int ans = 0;
  	ll d2 = d * d;
  
  	rep(i, n){
    	ll x, y;
      	cin >> x >> y;
      	ll test = x * x + y * y;
 
      	if(d2 >= test) ans++;
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)



using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}


int main() {

    string o,e;

    cin >> o >> e;

    for(int i = 0; i < e.length(); i ++){
        cout << o[i] << e[i];
    }

    if(o.length() - e.length() == 1) cout << o[o.length()-1];

    return 0;
}











Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
struct dat{
  int T,t,f,lap;
  dat(){T=t=f=lap=0;}
  vector<dat> V;
  bool operator > (const dat &a)const{return T-t>a.T-a.t;}
};

bool onFront(const dat &a,const dat &b){return a.f==b.f&&1.0*a.t/a.T<1.0*b.t/b.T;}
bool checkJam(const dat &a,const dat &b){return onFront(a,b)&&a.T-a.t<b.T-b.t;}

int merge(vector<dat>&A,int idx){
  dat &a = A[idx];
  for(int i=0;i<(int)A.size();i++){
    dat &b = A[i];
    if(!checkJam(a,b))continue;
    a.t=0, a.lap-=a.f, a.f=!a.f;
    b.V.push_back(a);
    A.erase(A.begin()+idx);
    return 1e9;
  }
  return a.T-a.t;
}

void Push(vector<dat>&A,dat &a){
  for(int i=0;i<(int)a.V.size();i++)Push(A,a.V[i]);
  a.V.clear();
  if(a.lap) A.push_back(a);
}

int sim(vector<dat> A){
  int res=0,idx=0;
  vector<dat> tmp[2]={A};
  while(1){
    vector<dat> &A = tmp[idx];idx=!idx;
    if(A.empty())break;
    sort(A.begin(),A.end(),greater<dat>());
    int mn = 1e9;
    for(int i=A.size()-1;i>=0;i--)mn=min(mn,merge(A,i));

    vector<dat>&nA=tmp[idx];tmp[idx].clear();
    for(int i=0;i<(int)A.size();i++)
      if(A[i].t+mn<A[i].T) A[i].t+=mn,nA.push_back(A[i]);
      else A[i].t=0, A[i].lap-=A[i].f, A[i].f=!A[i].f,Push(nA,A[i]);
    res+=mn;
  }
  return res;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<dat> A(n);
    for(int i=0;i<n;i++)cin>>A[i].T>>A[i].lap;
    cout<<sim(A)<<endl;
  }
  return 0;
}

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

int main() {
  int n,x,t,ans;
  cin >> n >> x >> t;
  if (n%x==0) ans = (n/x)*t;
  else ans = ((n/x) +1)*t;
  cout << ans << endl;
}

Measured memory_bytes: 3620
from math import floor, sqrt

Q = int(input())
for q in range(Q):
  a, b = map(int, input().split())
  K = floor(sqrt(a*b))
  if a== b:
    print(2*K-2)
  elif a*b == K*K:
    print(2*K-3)
  elif K*(K+1) < a*b:
    print(2*K-1)
  else:
    print(2*K-2)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
  string A, B;
  cin >> A >> B;

  if (A.size() > B.size()){
    cout << "GREATER" << endl;
  }else if (B.size() > A.size()){
    cout << "LESS" << endl;
  }else{
    if (int(A[0]) > int(B[0])){
      cout << "GREATER" << endl;
    }else if (int(A[0]) < int(B[0])){
      cout << "LESS" << endl;
    }else{
      cout << "EQUAL" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//#include<iostream>
#include<cstring>
#include<cstdio>
//#include<math.h>
//#include<set>
//#include<queue>
//#include<bitset>
//#include<vector>
#include<algorithm>
#include<stdlib.h>
using namespace std;

#define LL long long
int qread()
{
	char c; int s=0,f=1; while ((c=getchar())<'0' || c>'9') (c=='-') && (f=-1);
	do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s*f;
}

//Pay attention to '-' , LL and double of qread!!!!

int n,m;
#define maxn 711
bool mp[maxn][maxn];
bool f[2][maxn*2]; int cur=0;

bool vis[maxn],mark[maxn];
int p[maxn],lp=0;
bool play(int x,int col)
{
	vis[x]=1; mark[x]=col;
	if (mark[x]) p[lp]++; else p[lp]--;
	for (int y=1;y<=n;y++) if (mp[x][y])
	{
		if (vis[y])
		{
			if (mark[y]==col) return 0;
			continue;
		}
		if (!play(y,col^1)) return 0;
	}
	return 1;
}

int main()
{
	n=qread(); m=qread();
	for (int i=1,x,y;i<=m;i++)
	{
		x=qread(); y=qread();
		mp[x][y]=mp[y][x]=1;
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			mp[i][j]^=1;
	for (int i=1;i<=n;i++) mp[i][i]=0;
	
	memset(vis,0,sizeof(vis));
	lp=0;
	for (int i=1;i<=n;i++) if (!vis[i])
	{
		lp++;
		if (!play(i,0)) {puts("-1"); return 0;}
	}
	
	f[cur=0][700]=1;
	for (int i=1;i<=lp;i++)
	{
		memset(f[cur^1],0,sizeof(f[cur^1])); int v=p[i]; if (v<0) v=-v;
		for (int i=0;i<=1400-v;i++) f[cur^1][i]|=f[cur][i+v];
		for (int i=v;i<=1400;i++) f[cur^1][i]|=f[cur][i-v];
		cur^=1;
	}
	int cha=0x3f3f3f3f;
	for (int i=700,j=0;i<=1400;i++,j++) if (f[cur][i]) {cha=j; break;}
	for (int i=700,j=0;~i;i--,j++) if (f[cur][i]) {cha=j; break;}
	int A=(n-cha)>>1,B=n-A;
	printf("%d\n",A*(A-1)/2+B*(B-1)/2);
	return 0;
}

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

int main(void) {
	while(1) {
		int n; cin >> n;
		if(n == 0) break;
		string f[110];
		for(int i = 0; i < n; i++) {
			cin >> f[i];
		}
		
		int prev = 0;
		int cnt = 0;
		int r = 0, l = 0;
		for(int i = 0; i < n; i++){
			string t = f[i];
			if(t == "lu") l++;
			else if(t == "ru") r++;
			else if(t == "ld") l--;
			else if(t == "rd") r--;
			
			if(r == l) {
				if(r - 1 == prev || r + 1 == prev) cnt++;
				prev = r;
			}
		}
	
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include<stdio.h>

int main(void){
   int n,i;
   scanf("%d",&n);
   int a[n-1];

   for(i=0;i<n;i++){
      scanf("%d",&a[i]);
   }
   for(i=0;i<n;i++){
      if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0){
         printf("DENIED\n");
         return 0;
      }
   }
   printf("APPROVED\n");

   return 0;
}


Measured memory_bytes: 1644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long x = sc.nextInt();
		long y = sc.nextInt();
		sc.close();

		long max = Math.max(x, y);
		long ans = Long.MAX_VALUE;
		for (int i = 0; i <= max; i++) {
			long val = c * i * 2 + a * Math.max(x - i, 0) + b * Math.max(y - i, 0);
			ans = Math.min(ans, val);
		}
		System.out.println(ans);
	}
}


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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

template<class T>
inline bool change_max(T&a, const T&b){
  if(b > a){
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool change_min(T&a, const T&b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

template<class T>
inline void readv(vector<T>&v){
  if(v.empty()){
    cerr << "void readv(vector<T>&v) v.empty()\n";
  }
  for(auto&&e:v){
    cin >> e;
  }
}

int main(){
  int k, x;cin >> k >> x;
  for(int i = x - k + 1; i < x + k; ++i){
    if(i != x - k + 1)cout << ' ';
    cout << i;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x,y,a,b;
	
	scanf("%d%d%d",&x,&a,&b);
	y=x;
	if(x<a){
		x^=a;
		a^=x;
		x^=a;
	}
	x-=a;
	
	if(y<b){
		y^=b;
		b^=y;
		y^=b;
	}
	y-=b;
	
	if(x>y){
		puts("B");
	}else{
		puts("A");
	}
	return  0;
}

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

using namespace std;

bool flag[1000001]={false};
int N, M, K;

int main(){
        for(int i=0;i<1000001;i++){
                flag[i]=false;
        }
        cin>>N>>M>>K;
        int now=0;
        for(int i=0;i<N;i++){
                now+=M;
                int now2=now;
                for(int j=0;j<M;j++){
                        now2+=N;
                        now2-=(i+1)*2;
                        flag[now2]=true;
                }
                flag[now]=true;
        }
        /*for(int i=0;i<=N*M;i++){
                if(flag[i]){
                        cout<<i<<endl;
                }
        }*/
        if(flag[K]){
                cout<<"Yes"<<endl;
        }
        else{
                cout<<"No"<<endl;
        }
        return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
	int n,p;
	while(cin>>n>>p){
		if(n==-1&&p==-1) break;
		int a[p][2],so[p];
		for(int i=0;i<p;i++){
			a[i][0]=0;
			a[i][1]=0;
		}
		int ct=0,nn=n+1;
		while(ct<p){
			if(nn%2==0&&nn!=2){
				goto end;
			}
			else if(nn%3==0&&nn!=3){
				goto end;
			}
			for(int i=1;i<(sqrt(nn)/6)+3;i++){
				if(nn%(6*i+1)==0&&6*i+1!=nn) goto end;
				if(nn%(6*i-1)==0&&6*i-1!=nn) goto end;
			}
			if(nn==1) goto end;
			so[ct]=nn;
			ct++;
			end:;
			nn++;
		}
		int wa=2*n+2,c=0;
		while (c<p){
			for(int i=0;i<p;i++){
				for(int j=0;j<=i;j++){
					if(so[i]+so[j]==wa){
						a[c][0]=min(so[i],so[j]);
						a[c][1]=max(so[i],so[j]);
						c++;
						if(c==p){
							goto endend;
						}
					}
				}
			}
			wa++;
		}
		endend:;
		cout<<a[p-1][0]+a[p-1][1]<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

class union_find {
  std::vector<intmax_t> tree;

public:
  union_find(size_t n): tree(n, -1) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    return (tree[v] = find(tree[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-tree[u] >= -tree[v])
      std::swap(u, v);

    tree[v] += tree[u];
    tree[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<std::pair<size_t, size_t>> AB(M);
  for (auto& p: AB) {
    scanf("%zu %zu", &p.first, &p.second);
    --p.first;
    --p.second;
  }
  std::reverse(AB.begin(), AB.end());

  union_find uf(N);
  std::vector<size_t> res{0};

  for (size_t i = 0; i+1 < M; ++i) {
    size_t a, b;
    std::tie(a, b) = AB[i];

    size_t u = uf.size(a);
    size_t v = uf.size(b);
    size_t tmp = res[i];
    if (uf.unite(a, b)) tmp += u*v;
    res.push_back(tmp);
  }

  for (size_t i = M; i--;)
    printf("%zu\n", N*(N-1)/2-res[i]);
}


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

using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	int souwa = 0;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		souwa += d[i];
	}
	int answer = souwa * souwa;

	for (int i = 0; i < n; i++) {
		answer -= d[i] * d[i];
	}

	answer /= 2;

	cout << answer << endl;
	return 0;
}

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

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;
const int MAX_L = 500001;

int a[MAX_N];
int k[MAX_N];
multimap<int,int> mp;
ll t[MAX_N];
int n,L;

int main()
{
	scanf("%d%d",&n,&L);
	rep(i,n){
		scanf("%d",&a[i]);
		k[i] = a[i];
		mp.emplace(a[i],i);
	}
	sort(a,a+n,greater<int>());
	int id = 0;
	while(id<n){
		auto p = mp.equal_range(a[id]);
		auto it = p.first;
		int i = 0;
		while(it != p.second){
			int prev = it->second;
			if(prev!=0&&prev!=n-1){
				if(k[prev] > k[prev-1] && k[prev] > k[prev+1]){
					t[prev] = L-a[id];
				}else if(k[prev] < k[prev-1] && k[prev] > k[prev+1]){
					t[prev] = t[prev-1] + L-a[id];
				}else if(k[prev] > k[prev-1] && k[prev] < k[prev+1]){
					t[prev] = t[prev+1] + L-a[id];
				}else{
					t[prev] = max(t[prev-1],t[prev+1])+L-a[id];
				}
			}else if(prev==0){
				if(k[0] > k[1]){
					t[0] = L-a[id];
				}else{
					t[0] = t[1] + L-a[id];
				}
			}else{
				if(k[n-1] > k[n-2]){
					t[n-1] = L-a[id];
				}else{
					t[n-1] = t[n-2] + L-a[id];
				}
			}
			it++;
			i++;
		}
		id += i;
	}
	printf("%lld\n",*max_element(t,t+n));
	return 0;
}

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

namespace q5
{
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            var N = input1[0];
            var K = input1[1];
            var C = input1[2];
            var S = Console.ReadLine().Trim().Select(x => x == 'o').ToArray();

            var counts = new int[N+1];
            var poss1 = new int[K];
            var poss2 = new int[K];

            var c = 0;
            for (var i = 0; i < K; i++)
            {
                var hit = false;
                for (var j = c; j < N; j++)
                {
                    if (S[j])
                    {
                        hit = true;
                        c = j;
                        break;
                    }
                }
                if (!hit) return;
                poss1[i] = c;
                c = c + C + 1;
            }
            c = N - 1;
            for (var i = K-1; i >= 0; i--)
            {
                var hit = false;
                for (var j = c; j >= 0; j--)
                {
                    if (S[j])
                    {
                        hit = true;
                        c = j;
                        break;
                    }
                }
                if (!hit) return;
                poss2[i] = c;
                c = c - C - 1;
            }

            for (var i = 0; i < K; i++)
            {
                if (poss1[i] == poss2[i])
                {
                    Console.WriteLine(poss1[i] + 1);
                }
            }
        }
    }
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    char c;cin >> c;
    switch(c){
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            cout << "vowel" << endl;
            break;
        default:
            cout << "consonant" << endl;
            break;
    }
    return 0;
}


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

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

Measured memory_bytes: 5632
// To the MOTHER OF DRAGONS	

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(x) x.begin(), x.end()
#define deb(x) cout << ">> " << #x << " : " << x << endl;
#define RAGE ios::sync_with_stdio(0); cin.tie(0);

void solve()
{
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";
}

int main()
{
	RAGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ll t;
	//cin >> t;
	//while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout(v) if(false);
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;



void Main()
{
	int N;
	cin>>N;
	ll ans=0;
	for(int i = 0; i < N; i++){
		ans += i;
	}
	cout<<ans<<endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

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

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

long long gcd(long long x, long long y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

long long lcm(long long x, long long y) {
    return x * (y / gcd(x, y));
}

int main() {

    long long N;
    cin >> N;

    vector<long long> T(N);
    for (int i = 0; i < N; i++)cin >> T[i];

    long long ans = 1;
    for (int i = 0; i < N; i++) ans = lcm(ans, T[i]);

    cout << ans << endl;

}






















































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

int main() {
    int N,M;
    cin >> N >> M;
    vector< vector<int> > A(N, vector<int>(0));
    for(int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        A[a-1].push_back(b-1);
        A[b-1].push_back(a-1);
    }

    vector<bool> P(N, false);
    P[0] = P[A[0][0]] = true;
    deque<int> path(2);
    path[0] = 0;
    path[1] = A[0][0];
    while(true) {
        bool flag = true;
        for(int to : A[path[0]]) {
            if(!P[to]) {
                path.push_front(to);
                P[to] = true;
                flag = false;
                break;
            }
        }
        for(int to : A[path[path.size() - 1]]) {
            if(!P[to]) {
                path.push_back(to);
                P[to] = true;
                flag = false;
                break;
            }
        }
        if(flag) break;
    }

    cout << path.size() << endl;
    for(int v : path) cout << v + 1 << ' ';
    cout << endl;
}

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

using namespace std;

int main()
{   string S ,T,U;
    int A,B;
    cin>>S>>T;
    cin>>A>>B;
    cin>>U;
    if (U==S){
        A--;
    }
    else{
        B--;
    }
    cout <<A<<" "<<B;

    return 0;
}


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

using ll = long long;
constexpr int INF = (1<<30) - 1;
constexpr ll LLINF = (1ll<<60);

int main() {
        int C, N, M; cin >> C >> N >> M;

        ll dp[10005];
        fill_n(dp, 10005, -LLINF);
        dp[0] = 0;

        for (int i = 0; i < N; i++) {
                ll S, P; cin >> S >> P;
                for (int j = C; j >= 0; j--) {
                        if (j + S <= C) dp[j+S] = max(dp[j+S], dp[j] + P);
                }
        }
        for (int i = 1; i <= C; i++) {
                dp[i] = max(dp[i], dp[i-1]);
        }       

        for (ll k = 1; k <= M; k++) {
                cout << dp[C/k]*k << '\n';
        }       
        return (0);
}



Measured memory_bytes: 3188
import java.util.*;

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

		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		String s1, s2;
		int q = scan.nextInt();
		int len = str.length();
		for(int i = 0; i < q; i++){
			String com = scan.next();
			if(com.equals("print")){
				int a = scan.nextInt();
				int b = scan.nextInt();
				s1 = str.substring(a, b + 1);
				System.out.println(s1);
			}
			if(com.equals("reverse")){
				int a = scan.nextInt();
				int b = scan.nextInt();
				s1 = str.substring(0, a);
				s2 = str.substring(b + 1, len);
				for(int j = b; j >= a; j--){
					s1 += str.charAt(j);
				}
				str = s1 + s2;
			}
			if(com.equals("replace")){
				int a = scan.nextInt();
				int b = scan.nextInt();
				String p = scan.next();
				s1 = str.substring(0, a);
				s2 = str.substring(b + 1);
				str = s1 + p + s2;
			}
		}
	}
}

Measured memory_bytes: 62164
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
 
const int MaxN = 2e5;
int n, size[MaxN + 5];
int all, last[MaxN + 5], other[2 * MaxN + 5], pre[2 * MaxN + 5];
bool ok = 0;
int c = -1;
LL sum, cost[2 * MaxN + 5];
vector <pair<int , int> >G[MaxN + 5];
void Build(int x, int y, LL w) {
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = w;
}
 
void Dfs(int x, int y) {
	int ed = last[x], dr;
	bool flag = 1;
	size[x] = 1;
	while(ed != -1) {
		dr = other[ed];
		if(dr != y) {
			Dfs(dr, x);
			flag &= (2 * size[dr] < n);
			sum += ((LL)min(size[dr], n - size[dr]) * cost[ed] * 2LL);
			if(size[dr] == n - size[dr]) sum -= cost[ed], ok = 1;
			size[x] += size[dr];
		}
		ed = pre[ed];
	}
	flag &= (2 * (n - size[x]) < n);
	if(flag) c = x;
}
 
int main()
{
	all = -1; memset(last, -1, sizeof(last));
	scanf("%d", &n);
	LL Min = 1LL << 60;
	for(int i = 1; i < n; i++) {
		int u, v; LL w;
		scanf("%d%d%lld", &u, &v, &w);
		Build(u, v, w);
		Build(v, u, w);
		G[u].push_back(make_pair(v , w));
		G[v].push_back(make_pair(u , w));
	}
	sum = 0; ok = 0;
	Dfs(1, 0);
	if(ok) printf("%lld\n", sum);
	else{
		for(int i = 0;i < G[c].size();i++){
			LL t = G[c][i].second;
			Min = min(Min , t);
		}
		printf("%lld\n" , sum - Min);
	}
}

Measured memory_bytes: 20992