akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;


template <int p>
struct Modint
{
	int value;

	Modint() : value(0) {}
	Modint(long x) : value(x >= 0 ? x % p : (p + x % p) % p) {}

	inline Modint &operator+=(const Modint &b)
	{
		if ((this->value += b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator-=(const Modint &b)
	{
		if ((this->value += p - b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator*=(const Modint &b)
	{
		this->value = (int)((1LL * this->value * b.value) % p);
		return (*this);
	}
	inline Modint &operator/=(const Modint &b)
	{
		(*this) *= b.inverse();
		return (*this);
	}

	Modint operator+(const Modint &b) const { return Modint(*this) += b; }
	Modint operator-(const Modint &b) const { return Modint(*this) -= b; }
	Modint operator*(const Modint &b) const { return Modint(*this) *= b; }
	Modint operator/(const Modint &b) const { return Modint(*this) /= b; }

	inline Modint &operator++(int) { return (*this) += 1; }
	inline Modint &operator--(int) { return (*this) -= 1; }

	inline bool operator==(const Modint &b) const { return this->value == b.value; }
	inline bool operator!=(const Modint &b) const { return this->value != b.value; }
	inline bool operator<(const Modint &b) const { return this->value < b.value; }
	inline bool operator<=(const Modint &b) const { return this->value <= b.value; }
	inline bool operator>(const Modint &b) const { return this->value > b.value; }
	inline bool operator>=(const Modint &b) const { return this->value >= b.value; }

	//requires that "this->value and p are co-prime"
	// a_i * v + a_(i+1) * p = r_i
	// r_i = r_(i+1) * q_(i+1) * r_(i+2)
	// q == 1 (i > 1)
	// reference: https://atcoder.jp/contests/agc026/submissions/2845729 (line:93)
	inline Modint inverse() const
	{
		assert(this->value != 0);
		int r0 = p, r1 = this->value, a0 = 0, a1 = 1;
		while (r1)
		{
			int q = r0 / r1;
			r0 -= q * r1;
			swap(r0, r1);
			a0 -= q * a1;
			swap(a0, a1);
		}
		return Modint(a0);
	}

	friend istream &operator>>(istream &is, Modint<p> &a)
	{
		long t;
		is >> t;
		a = Modint<p>(t);
		return is;
	}
	friend ostream &operator<<(ostream &os, const Modint<p> &a)
	{
		return os << a.value;
	}
};

const int MOD = 1e9 + 7;

using Int = Modint<MOD>;

Int pow(Int e, int64_t x)
{
	if (x == 0)
		return 1;
	Int res = (x & 1 ? e : 1), tmp = pow(e, x >> 1);
	res *= tmp * tmp;
	return res;
}

void solve(void)
{
	int n, m;
	cin >> n >> m;
	vector<int> s(n), t(m);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> t[i];
	}
	vector<vector<Int>> dp(n+1, vector<Int>(m+1)), dp2(n+1, vector<Int>(m+1, 1));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (s[i-1] == t[j-1])
			{
				dp[i][j] = dp2[i-1][j-1];
			}
			dp2[i][j] = dp[i][j] - dp2[i-1][j-1] + dp2[i-1][j] + dp2[i][j-1];
		}
	}
	cout << dp2[n][m] << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 31744
import random
import sys
input = sys.stdin.readline
d=int(input())
c=list(map(int,input().split()))
cn=sorted(c)
h=cn[12]
P=[k+1 for k,v in enumerate(c) if v>=h]
s=[]
for _ in range(d):
    s.append(list(map(int,input().split())))
# t=[]
# for _ in range(d):
#     t.append(int(input()))
# m=int(input())
t=[]
for _ in range(d):
    z=random.randrange(len(P))
    t.append(P[z])
print(*t)

Measured memory_bytes: 78068
A, B, M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = min(a)+min(b)
m = []
for i in range(M):
    x, y, c = list(map(int, input().split()))
    tmp = a[x-1] + b[y-1] - c
    if res > tmp:
        res = tmp
print(res)

Measured memory_bytes: 18736
import java.util.*;
public class Main{
	public static void main(String args[]) {
		 Scanner sc=new Scanner(System.in);
		 int n=sc.nextInt();
		 int a[]=new int[n];
		 for(int i=0;i<n;i++)
		 {
			 a[i]=sc.nextInt();
		 }
		 int j;
		 for(int x=0;x<n-1;x++)
			{
				System.out.print(a[x]+" ");
			}
		 System.out.print(a[n-1]);
			System.out.println();
		 for(int i=1;i<n;i++)
		 {
			 int t=a[i];
			for(j=i-1;j>=0;j--)
			{
				if(a[j]>t)
				{
					t=a[j+1];
					a[j+1]=a[j];
					a[j]=t;
				}
				else {
					break;
				}
			}
			a[j+1]=t;
			 for(int x=0;x<n-1;x++)
				{
					System.out.print(a[x]+" ");
				}
			 System.out.print(a[n-1]);
				System.out.println();
		 }
	}
}


Measured memory_bytes: 32028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int odd = 0;
		for (int i=1; i<=N; i++){
			if (i % 2 == 1){
				odd++;
			}
		}
		System.out.println((double)odd/(double)N);
	}
}

Measured memory_bytes: 22612
from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))

P = [((x+1) * x / 2) / x for x in P]
A = list(accumulate(P))

ans = A[K-1]
for i in range(K, N):
    ans = max(ans, A[i] - A[i-K])

print(ans)


Measured memory_bytes: 31848
/*
[abc136] C - Build Stairs
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
int H[MAX_N];

ll solve() {
    for (int i = N - 1; i > 0; i--) {
        if (H[i - 1] - H[i] == 1) {
            H[i - 1]--;
        } else if (H[i - 1] > H[i]) {
            return false;
        }
    }

    return true;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

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

    return 0;
}


Measured memory_bytes: 640
Module P1
Sub main()

    Dim RD As String
    Dim SD() As String
    
    Dim N As Long
    Dim A As String
    Dim B As String
    Dim C As String
    
    
'    RD = Console.Readline
'    SD = Split(RD, " ")
'    N = SD(0)
'    A = SD(1)
'    B = SD(2)
'    C = SD(3)
    
    N = Console.Readline
    A = Console.Readline
    B = Console.Readline
    C = Console.Readline
    
    
    Dim ChrIdx As Long
    Dim Cnt As Long
    
    For ChrIdx = 1 To CLng(N)
    
        If Mid(A, ChrIdx, 1) = Mid(B, ChrIdx, 1) And _
           Mid(A, ChrIdx, 1) = Mid(C, ChrIdx, 1) And _
           Mid(B, ChrIdx, 1) = Mid(C, ChrIdx, 1) Then
            Cnt = Cnt + 0
        ElseIf _
           Mid(A, ChrIdx, 1) = Mid(B, ChrIdx, 1) And _
           Mid(A, ChrIdx, 1) <> Mid(C, ChrIdx, 1) Then
            Cnt = Cnt + 1
        ElseIf _
           Mid(A, ChrIdx, 1) <> Mid(B, ChrIdx, 1) And _
           Mid(A, ChrIdx, 1) = Mid(C, ChrIdx, 1) Then
            Cnt = Cnt + 1
        ElseIf _
           Mid(A, ChrIdx, 1) <> Mid(B, ChrIdx, 1) And _
           Mid(A, ChrIdx, 1) <> Mid(C, ChrIdx, 1) And _
           Mid(B, ChrIdx, 1) = Mid(C, ChrIdx, 1) Then
            Cnt = Cnt + 1
        ElseIf _
           Mid(A, ChrIdx, 1) <> Mid(B, ChrIdx, 1) And _
           Mid(A, ChrIdx, 1) <> Mid(C, ChrIdx, 1) And _
           Mid(B, ChrIdx, 1) <> Mid(C, ChrIdx, 1) Then
            Cnt = Cnt + 2
        End If
        
    
           
    Next
    
    Console.Writeline (Cnt)

End Sub

end Module

Measured memory_bytes: 19920
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

string s;
ll a[300010], b[300010], c[300010];
signed main(void)
{
	int n, m;
	cin >> n >> m;
	cin >> s;
	a[0] = 1;
	REP(i, n) {
		a[i+1] = a[i]*MOD;
		b[i+1] = b[i]*MOD+s[i];
	}
	int l=0, r=1;
	VL v;
	REP(i, m) {
		string t;
		cin >> t;
		if(t == "R++") {
			r++;
		} else if(t == "R--") {
			r--;
		} else if(t == "L++") {
			l++;
		} else if(t == "L--") {
			l--;
		}
		v.PB(b[r]-b[l]*a[r-l]);
	}

	//for(ll i: v) cout << i << endl;
	sort(ALL(v));
	cout << unique(ALL(v))-v.begin() << endl;

	return 0;
}

Measured memory_bytes: 12172
//
//  main.cpp
//  Prefix_And_Suffix
//
//  Created by Uttam Datta on 31/05/19.
//  Copyright © 2019 Uttam Datta. All rights reserved.
//

#include <iostream>
using namespace std;

int N;
string a,b;

bool from(int posa){
    int l = posa,i=0;
    bool dodo = true;
    while(l < N && dodo){
        if(a[l] == b[i]){
            l++;
            i++;
        }
        else{
            dodo = false;
        }
    }
    return dodo;
}


int ans(){
    int common = 0;
    int posa = N-1;
    for(;posa >= 0; posa--){
        if(a[posa] == b[0] && from(posa) == true){
            common = N - posa;
        }
    }
    return (2*N)-common;
}

int main(){
    cin >> N >> a >> b;
    int res = ans();
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
  public struct Vector
  {
    public int x, y;
  }

  public static double norm(Vector v)
  {
    return v.x*v.x + v.y*v.y;
  }

  public static double dot (Vector v1, Vector v2)
  {
    return v1.x*v2.x + v1.y*v2.y;
  }
  public static void Main()
  {
    string[] s1 = Console.ReadLine().Split(' ');
    Vector baseV;
    baseV.x = int.Parse(s1[2]) - int.Parse(s1[0]);
    baseV.y = int.Parse(s1[3]) - int.Parse(s1[1]);

    int n = int.Parse(Console.ReadLine());

    for(int i=0; i<n; i++)
    {
      string [] s2 = Console.ReadLine().Split(' ');
      Vector v;
      v.x = int.Parse(s2[0]) - int.Parse(s1[0]);
      v.y = int.Parse(s2[1]) - int.Parse(s1[1]);

      double r = dot(v, baseV) / norm(baseV);

      double x = int.Parse(s1[0]) + baseV.x*r;
      double y = int.Parse(s1[1]) + baseV.y*r;

      Console.WriteLine("{0:f10} {1:f10}", x, y);
    }
  }
}

Measured memory_bytes: 9328
z[9][101][101];n,m,t,c,b,*p;char*f="%d%d%d%d\n";main(a){for(;scanf(f+4,&n,&m)*n;){for(memset(z,9,9e4);n--;z[0][a][b]=z[0][b][a]=c)scanf(f,&a,&b,&c,&t),z[1][a][b]=z[1][b][a]=t;for(t=++m;--t;)for(c=m;--c;)for(b=m;--b;)for(a=2;a--;p[c]=fmin(p[c],p[t]+z[a][t][c]))p=z[a]+b;for(scanf(f+6,&n);n--;printf(f+6,z[a][b][c]))scanf(f+2,&c,&b,&a);}}

Measured memory_bytes: 512
#include<stdio.h>
void pc(int,int);
void pc(int x,int y){
    int h,w,z;
    for(h=1;h<=x;h++){
        for(w=1;w<=y;w++){
            z=h+w;
            if(z%2==0){
                printf("#");
            }
            else{
                printf(".");
            }
        }
        printf("\n");
    }
    printf("\n");
    return;
}
int main(void){
    int H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0){
            break;
        }
        else{
            pc(H,W);
        }
    }
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int main(){

	string s2[27]={};
	string s3[27]={};
	string ans={};
	int n;
	cin>>n;
	rep(i,26){
		s3[i]="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
	}
	rep(j,n){
		string s;
		cin>>s;
		rep(i,s.size()){
			if(s[i]=='a')s2[0]+='a';
			if(s[i]=='b')s2[1]+='b';
			if(s[i]=='c')s2[2]+='c';
			if(s[i]=='d')s2[3]+='d';
			if(s[i]=='e')s2[4]+='e';
			if(s[i]=='f')s2[5]+='f';
			if(s[i]=='g')s2[6]+='g';
			if(s[i]=='h')s2[7]+='h';
			if(s[i]=='i')s2[8]+='i';
			if(s[i]=='j')s2[9]+='j';
			if(s[i]=='k')s2[10]+='k';
			if(s[i]=='l')s2[11]+='l';
			if(s[i]=='m')s2[12]+='m';
			if(s[i]=='n')s2[13]+='n';
			if(s[i]=='o')s2[14]+='o';
			if(s[i]=='p')s2[15]+='p';
			if(s[i]=='q')s2[16]+='q';
			if(s[i]=='r')s2[17]+='r';
			if(s[i]=='s')s2[18]+='s';
			if(s[i]=='t')s2[19]+='t';
			if(s[i]=='u')s2[20]+='u';
			if(s[i]=='v')s2[21]+='v';
			if(s[i]=='w')s2[22]+='w';
			if(s[i]=='x')s2[23]+='x';
			if(s[i]=='y')s2[24]+='y';
			if(s[i]=='z')s2[25]+='z';
		}
		rep(i,26){
			if(s2[i].size()<s3[i].size())s3[i]=s2[i];
			s2[i]={};
		}
	}
	rep(i,26)ans+=s3[i];
	cout<<ans<<endl;
	return 0;

}




Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 100000000000000003;
int ne[200001], he[100001];
char C[1200100];

ll num[524300];
int kazu[524300];
const int ma = (1 << 19) - 1;
int query(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2];
		n2 = n2 * 61 % 524287;
	}
	return 0;
}
void add(ll n, int b) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			kazu[n2] |= b;
			return;
		}
		n2 = n2 * 61 % 524287;
	}
	num[n2] = n + 1;
	kazu[n2] = b;
}

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


	fread(C, 1, 1200100, stdin);
	char* ci = C, c;
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';

	ll dekai[10];
	int d = 0;
	char* s[200001];
	rep1(i, N) {
		s[i] = ci;
		while (*ci++ >= '0');
		int n = ci - s[i] - 1;	
		if (n <= 100000) {
			ne[i] = he[n];
			he[n] = i;
		}
		else {
			dekai[d++] = (ll(n) << 30) + s[i] - C;
		}
	}

	ll kotae = 0;

	for (int M = 1; M <= 100000; M++) {
		for (int p = he[M]; p; p = ne[p]) {
			auto S = s[p];
			int k[26] = {};
			ll are = 0;
			for (int i = M - 1; i >= 1; i--) {
				int tmp = query(are);
				if (tmp) {
					rep(j, 26) if ((tmp >> j & 1)) {
						k[j]++;
					}
				}
				kotae += k[S[i] - 'a'];
				k[S[i] - 'a'] = 0;
				are = (are * 30 + S[i] - 'a' + 1) % mod;
			}

			kotae += k[S[0] - 'a'];
			k[S[0] - 'a'] = 0;

			add(are, 1 << (S[0] - 'a'));
		}
	}
	sort(dekai, dekai + d);
	rep(p, d) {
		auto S = C + (dekai[p] & (1 << 21) - 1);
		int k[26] = {};
		ll are = 0;
		for (int i = (dekai[p] >> 30) - 1; i >= 1; i--) {
			int tmp = query(are);
			if (tmp) {
				rep(j, 26) if ((tmp >> j & 1)) {
					k[j]++;
				}
			}
			kotae += k[S[i] - 'a'];
			k[S[i] - 'a'] = 0;
			are = (are * 30 + S[i] - 'a' + 1) % mod;
		}

		kotae += k[S[0] - 'a'];
		k[S[0] - 'a'] = 0;

		add(are, 1 << (S[0] - 'a'));
	}
	printf("%lld\n", kotae);


	Would you please return 0;
}

Measured memory_bytes: 12596
var
	i,n,t:longint;
	a:array[0..100010] of longint;
function gcd(x,y:longint):longint;
var
	t,r:longint;
begin
	if x<y then
	begin
		t:=x; x:=y; y:=t;
	end;
	r:=x mod y;
	while r<>0 do
	begin
		x:=y; y:=r;
		r:=x mod y;
	end;
	exit(y);
end;
procedure qsort(l,r:longint);
var
	i,j,t,mid:longint;
begin
	i:=l; j:=r; mid:=a[(l+r) div 2];
	repeat
		while a[i]<mid do inc(i);
		while a[j]>mid do dec(j);
		if i<=j then
		begin
			t:=a[i]; a[i]:=a[j]; a[j]:=t;
			inc(i); dec(j);
		end;
	until i>j;
	if l<j then qsort(l,j);
	if i<r then qsort(i,r);
end;
begin
	readln(n,a[1]);
	inc(n);
	for i:=2 to n do read(a[i]);
	qsort(1,n);
	t:=a[2]-a[1];
	for i:=3 to n do t:=gcd(t,a[i]-a[i-1]);
	writeln(t);
end.

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

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());

	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var H = (int)inputArray[0];
			var W = (int)inputArray[1];

			//光の情報を格納する
			var lumpInfo = new bool[H, W];
			for (int i = 0; i < H; i++) {
				var rightinfo = retreiveStringArray()[0];
				var rightarray = rightinfo.Select(x => x == '.').ToArray();
				for (int j = 0; j < W; j++) {
					lumpInfo[i, j] = rightarray[j];
				}
			}
			//左方向に照らす数を記録する
			var leftInfo = new int[H, W];
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {

					if (lumpInfo[i,j]) {
						leftInfo[i,j]= j-1 >= 0 ? leftInfo[i,j - 1] + 1:1;
					}
					else {
						leftInfo[i,j] = 0;
					}
				}
			}
			//右方向に照らす数を記録する
			var rightInfo = new int[H, W];
			for (int i = 0; i < H; i++) {
				for (int j = W-1; j >= 0; j--) {

					if (lumpInfo[i, j]) {
						rightInfo[i, j] = j < W-1 ? rightInfo[i, j + 1] + 1 : 1;
					}
					else {
						rightInfo[i, j] = 0;
					}
				}
			}
			//下方向に照らす数を記録する
			var downInfo = new int[H, W];
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {

					if (lumpInfo[i, j]) {
						downInfo[i, j] = i - 1 >= 0 ? downInfo[i-1, j] + 1 : 1;
					}
					else {
						downInfo[i, j] = 0;
					}
				}
			}
			//上方向に照らす数を記録する
			var upInfo = new int[H, W];
			for (int i = H-1; i >= 0; i--) {
				for (int j = W - 1; j >= 0; j--) {

					if (lumpInfo[i, j]) {
						upInfo[i, j] = i < H - 1 ? upInfo[i+1, j] + 1 : 1;
					}
					else {
						upInfo[i, j] = 0;
					}
				}
			}
			var max = 0;

			//最も強く照らす場所を探す
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					var right = leftInfo[i,j] + rightInfo[i,j] + upInfo[i,j] + downInfo[i,j];
					max = Math.Max(max, right);
				}

			}
			//答えの出力
			var ans = max-3;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 81708
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int H, W, A, B, C, **ans, flag=0, i, j, ans_0=0, ans_W=0;
	char S[3], T[10], U[10];


	scanf("%s", S);


	if (S[0] == S[1] && S[1] == S[2]){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}


	/*
	ans = (int **)malloc(sizeof(int *)* H);


	for (i = 0; i<H; i++) {
		ans[i] = (int *)malloc(sizeof(int)* W);
	}

	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++){
			ans[i][j] = 0;
		}
	}
	*/

	return 0;

}
    


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

int main() {

  vector< pair< long long int, long long int > > cnt;

  long long int n;
  cin >> n;

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

    long long int in0, in1;
    cin >> in0 >> in1;
    cnt.push_back( make_pair( -in1, in0 ) );

  }

  sort( cnt.begin(), cnt.end() );

  cout << cnt[0].second << " " << -cnt[0].first << endl;

  return 0;

}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmp(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second > right.second;
}
lli d(lli x,lli y, lli r, lli h){
	return abs(x-r)+abs(y-h);
}

const int movr[]={0,1},movh[]={1,0};

int main() {
	lli k, x, y;
	int p[] = { 1,1 };
	cin >> k >> x >> y;
	if (x < 0)p[0] = -1;
	if (y < 0)p[1] = -1;
	x = abs(x); y = abs(y);

	if ((x + y) % 2 == 1 && k % 2 == 0) {
		cout << -1;
		return 0;
	}

	vector<pair<lli, lli>> vec;
	int r=0, h=0;
	
	while(d(x,y,r,h)>=2*k){
		rep0(i,k){
			rep0(j,2){
				if(d(x,y,r,h)>d(x,y,r+movr[j],h+movh[j])){
					r+=movr[j];h+=movh[j];
					break;
				}
			}
		}
		vec.emplace_back(r,h);
	}
	
	if(d(x,y,r,h)!=k){
		if(d(x,y,r,h)%2!=0&&k%2!=0){
			lli i=k;
			while(d(x,y,r,h)!=0&&i>0){
				rep0(j,2){
					if(d(x,y,r,h)>d(x,y,r+movr[j],h+movh[j])){
						r+=movr[j];h+=movh[j];
						break;
					}
				}
				i--;
			}	
			r+=i;	
			vec.emplace_back(r,h);
			if(i>0)vec.emplace_back(r-d(x,y,r,h)/2, h-(k-d(x,y,r,h)/2));
			else{
				if(d(x,y,r,h)/2<abs(x-r)){
					vec.emplace_back(r+d(x,y,r,h)/2, h-(k-d(x,y,r,h)/2));	
				}else{
					
				vec.emplace_back(r+(k-(y-r-d(x,y,r,h)/2)), y-d(x,y,r,h)/2);
				}
			}
		}else{
			if(d(x,y,r,h)/2<abs(x-r)){
				vec.emplace_back(r+d(x,y,r,h)/2, h-(k-d(x,y,r,h)/2));	
			}else{
				vec.emplace_back(r+(k-(y-h-d(x,y,r,h)/2)), y-d(x,y,r,h)/2);		
			}
		}
	}
	vec.emplace_back(x,y);
	cout << vec.size() << '\n';
	for (const auto e : vec) {
		cout << p[0]*e.first << ' ' << p[1]*e.second << '\n';
	}
}


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

int main(){
  int N,K,count=0;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
    if(h[i]>=K) count++;
  }
  cout<<count;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T> inline void chmax(T& a, const T b){a=max(a,b);}

array<int,6000> A;
array<int,2000> B;
array<int,2000*2000> dp;

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    constexpr int inf = 12345678;
    int N; cin >> N;
    for(int i = 0; i < 3*N; ++i) cin >> A[i],A[i]--;
    corner(N==1,A[0]==A[1]&&A[1]==A[2]);

    for(int i=0;i<N*N;++i) dp[i]=-inf;
    for(int i=0;i<N;++i) B[i]=-inf;
    int ans=0,maxi=0;
    array<int,5> v;
    for(int i = 0; i < 5; ++i) v[i]=A[i];
    sort(ALL(v));
    do{
        int u = (v[2]==v[3]&&v[3]==v[4]);
        chmax(dp[v[0]*N+v[1]],u);
        chmax(maxi,u);
        chmax(B[v[0]],u);
        chmax(B[v[1]],u);
    } while(next_permutation(ALL(v)));

    for(int i=5; i+2 < 3*N; i+=3) {
        int& a=A[i];
        int& b=A[i+1];
        int& c=A[i+2];
        if(a==b&&b==c) {
            ans++;
            continue;
        }
        stack<pair<int,int>> vp;
        if(a==b) {
            for(int j=0;j<N;++j) {
                vp.emplace(c*N+j,max(dp[a*N+j]+1,B[j]));
            }
        }
        else {
            for(int j=0;j<N;++j) {
                vp.emplace(c*N+j,B[j]);
            }
        }
        if(b==c) {
            for(int j=0;j<N;++j) {
                vp.emplace(a*N+j,max(dp[b*N+j]+1,B[j]));
            }
        }
        else{
            for(int j=0;j<N;++j) {
                vp.emplace(a*N+j,B[j]);
            }
        }
        if(c==a) {
            for(int j=0;j<N;++j) {
                vp.emplace(b*N+j,max(dp[c*N+j]+1,B[j]));
            }
        }
        else{
            for(int j=0;j<N;++j) {
                vp.emplace(b*N+j,B[j]);
            }
        }
        {
            vp.emplace(b*N+c,max(dp[a*N+a]+1,maxi));
        }
        {
            vp.emplace(c*N+a,max(dp[b*N+b]+1,maxi));
        }
        {
            vp.emplace(a*N+b,max(dp[c*N+c]+1,maxi));
        }
        while(vp.size()) {
            auto p = vp.top(); vp.pop();
            int s=p.first/N,t=p.first%N,u=p.second;
            chmax(dp[s*N+t],u);
            chmax(dp[t*N+s],u);
            chmax(maxi,u);
            chmax(B[s],u);
            chmax(B[t],u);
        }
    }
    int& l=A[3*N-1];
    chmax(maxi,dp[l*N+l]+1);
    ans += maxi;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19304
n=int(input())
li=list(map(int,input().split()))
d={}
dif={-1}
ans={}
for i in range(n):
    if li[i] not in dif:
        dif|={li[i]}
    if d.get(li[i])!=None:
        d[li[i]]+=1
    else:
        d[li[i]]=1
dif.remove(-1)
g=0
for i in dif:
    g+=d[i]*(d[i]-1)//2
for i in dif:
    ans[i]=g-(d[i]-1)*d[i]//2+(d[i]-2)*(d[i]-1)//2
for i in li:
    print(ans[i])

Measured memory_bytes: 38992
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n,k=map(int,input().split())
mod=10**9+7
memo=[pow(k//i,n,mod) for i in range(1,k+1)] #gcdが1~kになる場合をメモする
for i in range(k-1,-1,-1):
    x=make_divisors(i+1)
    for j in x:
        if j!=i+1:
            memo[j-1]-=memo[i]
ans=0
for i in range(k):
    ans+=(memo[i]*(i+1))
    ans%=mod
print(ans)

Measured memory_bytes: 12108
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
ll mod=998244353;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    priority_queue<pp> q;
    rep(i,n){
        cin >> a.at(i);
    }
    rep(i,n){
        cin >> b.at(i);
        q.push(make_pair(b.at(i),i));
    }
    int uu=0;
    ll ans=0;
    while (true){
        int t=q.top().first,p=q.top().second;
        q.pop();
        int s=p+1,d=p-1;
        if (s==n) s=0;
        if (d==-1) d=n-1;
        int u=max(b.at(s),b.at(d));
        ll ti=(b.at(p)-u)/(b.at(s)+b.at(d))+1;
        if ((b.at(p)-u)%(b.at(s)+b.at(d))==0) ti--;
        if ((b.at(p)-a.at(p))%(b.at(s)+b.at(d))==0) ti=(b.at(p)-a.at(p))/(b.at(s)+b.at(d));
        ans+=ti;
        b.at(p)-=ti*(b.at(s)+b.at(d));
        if (b.at(p)==a.at(p)) {uu++;
        if (uu==n) break;
        continue;}
        if (b.at(p)<a.at(p)) {cout << -1 << endl;return 0;}
        q.push(make_pair(b.at(p),p));
        
        //cout << t << " " << p << " " << b.at(p) << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    map<string,int> cnt;
    int N;
    cin >> N;
    vector<int> D(N);
    REP(i,N){
        cin >> D[i];
    }

    set<int> S;
    for(auto x:D){
        S.insert(x);
    }
    int ans = S.size();
    
    cout << ans << endl;
}


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











#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    
   char s;
   cin >> s;

   if (isupper(s))
   {
       cout <<"A"<< endl;
   }
   else
   {
       cout <<"a"<< endl;
   }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 2100000000
#define MOD 1000000007

int main(){
  ll N;
  cin>>N;
  vector<pair<ll,ll>> P(N);
  for(ll i=0;i<N;i++){
    cin>>P.at(i).first;
    P.at(i).second=i;
  }
  sort(P.begin(),P.end());
  reverse(P.begin(),P.end());

  multiset<ll> S;
  S.insert(-1);
  S.insert(-1);
  S.insert(N);
  S.insert(N);
  ll ans=0;
  for(ll i=0;i<N;i++){
    auto iter=S.upper_bound(P.at(i).second);
    iter--;
    iter--;
    ll a1=*iter;
    iter++;
    ll a2=*iter;
    iter++;
    ll a3=*iter;
    iter++;
    ll a4=*iter;
    ans+=(ll)P.at(i).first*(((ll)a2-(ll)a1)*((ll)a3-(ll)P.at(i).second)+((ll)a4-(ll)a3)*((ll)P.at(i).second-(ll)a2));
    S.insert(P.at(i).second);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6528
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var r0 = int.Parse(line[0]);
            var w0 = int.Parse(line[1]);
            var c = int.Parse(line[2]);
            var r = int.Parse(line[3]);
            if (r0 == 0 && w0 == 0 && c == 0 && r == 0) break;
            var c0 = (double)r0 / w0;
            int nrb;
            if (c0 < c)
            {
                var nr = w0 * c - r0;
                nrb = (nr + r - 1) / r;
            }
            else nrb = 0;
            Console.WriteLine(nrb);
        }
    }
}

Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

map<int,int> flag;

void func(ll n)  
{  
    while (n % 2 == 0)  
    {  
        flag[2]++;
        n = n/2;  
    }

    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            flag[i]++;
            n = n/i;  
        }  
    }  

    if (n > 2)  
    {
        flag[n]++;
    } 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    
    ll n;
    cin >> n;
    func(n);

    int ans=0;
    for (auto it=flag.begin();it!=flag.end();it++)
    {
        int a=it->second;
        a=1+(8*a);
        a=sqrt(a);
        a--;
        a=a/2;

        ans=ans+a;
    }

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

Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
	int a,b;
	int money = -1;
	
	scanf("%d %d",&a,&b);
	
	for(float i = 1;i <= 1250;i++)
	{
		if((int)(i * 0.08) == a &&(int)(i * 0.1) == b)
		{
			money = i;
			break;
		}
	}
	
	printf("%d\n",money);
	
	return 0;
}


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

int main()
{
    ll N;
    cin >> N;
    int a[N] = {0};
    for(int i = 0;i<N;i++)
        cin >> a[i];
    int dp[N] = {0};
    dp[N-2] = abs(a[N-2] - a[N-1]);
    int A,B;
    for(int i = N-3;i>=0;i--)
    {
        A = abs(a[i] - a[i+1]) + dp[i+1];
        B = abs(a[i] - a[i+2]) + dp[i+2];
        dp[i] = min(A,B);
    }
    cout<< dp[0];
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int n,k,min=0,i,x;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
		{
		scanf("%d",&x);
		if(x<=k/2){min+=2*x;}
		else{min+=2*(k-x);}
		}
	printf("%d",min);
return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return;
    }
    int ans = H * W / 2;
    ans += (H % 2 == 1 && W % 2 == 1);
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int N,K,C;
    cin>>N>>K>>C;
    if(N==1&&K==1) {cout<<1<<endl; return 0;}
    string S;
    cin>>S;
    int dp1[200000];
    int dp2[200000];
    int pos = -2*C-1;
    int num = 0;
    dp1[0] = 0;
    rep(i,N-1){
        if(S[i]=='o' && i>pos+C) {num++; pos = i;}
        dp1[i+1] = num;
    }
    reverse(S.begin(),S.end());
    dp2[N-1] = 0;
    num=0;
    pos = -2*C-1;
    rep(i,N-1){
        if(S[i]=='o' && i>pos+C) {num++; pos = i;}
        dp2[N-2-i] = num;
    }

    rep(i,N){
        // cout<<i<<" "<<dp1[i]+dp2[i]<<" ";
        if(dp1[i]+dp2[i]<K) cout<<i+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
int main(){
    int n;cin>>n;
    int ans=0,count=0;
    vector<ll> l(n);
    rep(i,n){
        cin>>l[i];
    }
    sort(l.begin(),l.end());
    rep(i,n-2)for(int j=i+1;j<n-1;j++)for(int k=j+1;k<n;k++){
        if(l[k]<l[i]+l[j]&&l[k]!=l[i]&&l[k]!=l[j]&&l[i]!=l[j]) {
            ans++;
        }
        //cout<<i<<" "<<j<<" "<<k<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,t,s;
	cin>>a>>b>>c;
	t=max(a,max(b,c));
	s=t;
	int k;
	cin>>k;
	t=t*pow(2,k);
	cout<<a+b+c+t-s;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

bool stone[200009];
bool cans[200009];
bool canf[200009];

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

	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	for (int i = 1; i <= N; i++) {
		char tmp; cin >> tmp;
		if (tmp == '#') stone[i] = true;
	}
	//for (int i = 1; i <= N; i++) cout << stone[i];

	// すぬけの移動可能場所を調べる
	cans[A] = true;
	for (int i = A; i <= C; i++) {
		if (cans[i]) {
			if (!stone[i + 1]) cans[i + 1] = true;
			if (!stone[i + 2]) cans[i + 2] = true;
		}
	}

	canf[B] = true;
	for (int i = B; i <= D; i++) {
		if (canf[i]) {
			if (!stone[i + 1]) canf[i + 1] = true;
			if (!stone[i + 2]) canf[i + 2] = true;
		}
	}

	if (cans[C] && canf[D]) {

		if (C < D) cout << "Yes" << endl;
		else {
			// BからDの間で3マス空いている場所があればok
			bool flag = false;
			for (int i = B; i <= D; i++) { // ふぬけがi+1にいるときに入れ替わる
				if (!stone[i-1] && !stone[i] && !stone[i + 1]) {
					flag = true;
					//cout << i << endl;
				}
			}
			if (flag) cout << "Yes" << endl;
			else cout << "No" << endl;
		}
	}
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 768
from collections import Counter
n=int(input())
a=[int(i) for i in input().split()]
s=Counter(a)
b=[]
for key, val in s.items():
 if 4>val>=2:
   b.append(key)
 elif val>=4:
   b.append(key)
   b.append(key)
if len(b)>1:
  b.sort()
  print(b[-1]*b[-2])
else:
  print(0)

Measured memory_bytes: 18600
using System;
class A
{
    static void Main()
    {
        ///////////////
        string a = Console.ReadLine().ToLower(); int ans = 0;
        while (true)
        {
            string gh = Console.ReadLine();
            if (gh == "END_OF_TEXT") { break; }
            string[] a1 = gh.Split();
            for (int i = 0; i < a1.Length; i++) { if (a1[i].ToLower() == a) { ans++; } }
        }
        Console.WriteLine(ans);
        ///////////////
    }
}

Measured memory_bytes: 9116
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,p,mx1,mx2;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		if(x>=mx1)
		{
			mx2=mx1;
			mx1=x;
			p=i;
		}
		else if(x>mx2)
		{
			mx2=x;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(i==p)
		{
			cout<<mx2<<endl;
		}
		else
		{
			cout<<mx1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
int32_t main()
{
  int n;int m;cin>>n>>m;
  priority_queue<pair<int,int>>pq;
  for(int i=1;i<=n;i++)
  {
    int a;cin>>a;pq.push({a,1});
  }
  for(int i=1;i<=m;i++)
  {
    int b;int c;cin>>b>>c;
    pq.push({c,b});
  }
  
  int ans=0;
  for(int i=0;i<n;i++)
  {
    pair<int,int> temp=pq.top();
    pq.pop();
    ans+=temp.first;
    if(temp.second>1)
      pq.push({temp.first,temp.second-1});
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7464
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;

vector<int> a[100100];
int d[100100];
bool mark[100100];
vector<int> order;
int n, m;
int deg[100100];

void dfs(int s) {
	mark[s] = true;
	for (int i : a[s])
		if (!mark[i]) dfs(i);
	order.pb(s);
}

void toposort() {
	for (int i = 1; i <= n; i++)
		if (!mark[i]) dfs(i);
	
	reverse(order.begin(), order.end());

	for (int i = 1; i <= n; i++) {
		mark[i] = 0;
		d[i] = -1e9;
	}

	for (int i : order)
		if (deg[i] == 0) d[i] = 0;
}

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

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		a[x].pb(y);
		deg[y]++;
	}

	toposort();

	for (int i : order) {
		for(int j : a[i]) 
			d[j] = max(d[j], d[i] + 1);
	}

	int mx = 0;
	for (int i : order) mx = max(mx, d[i]);

	cout << mx;

	return 0;
}

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; 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;

int main() {
  int A, B; cin >> A >> B;
  cout << max(0, A - 2*B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
	ll m,n;
	cin>>m>>n;
	ll t=0;
	t+=m/n;
	if(m%n)
		t++;
	cout<<t<<endl;
}


Measured memory_bytes: 256
import sys

def euclid(x, y):
	if y == 0: return x
	elif x < y: return euclid(y, x)
	else: return euclid(y, x%y)

for line in sys.stdin:
	a, b = map(int, line.split())
	gcd = euclid(a, b)
	lcm = a*b/gcd
	print str(gcd)+' '+str(lcm)


Measured memory_bytes: 4632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(b>=a)
    cout<<"unsafe";
    else
    cout<<"safe";
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

int main()
{
	int a; cin >> a;
	if (a % 2 == 0) {
		cout << (a/2) * (a/2) << endl;
	}
	else
	{
		cout << (a / 2) * (a / 2+1) << endl;

	}
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 200000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
   long long N,M;
   cin>>N>>M;
   int ans[N+1];
   for(int i=0;i<N+1;i++){
       ans[i]=-1;
   }
   int ans_sum=0;
   int p[M];
   string S[M];
   for(int i=0;i<M;i++){
       cin>>p[i]>>S[i];
       if(S[i]=="AC"){
           if(ans[p[i]]==-1){
           ans[p[i]]=i;}
       }
   }
   for(int i=0;i<N+1;i++){
       if(ans[i]>=0){
           ans_sum++;
       }
   }
   int wa_sum=0;
   for(int i=0;i<M;i++){
       if(S[i]=="WA"){
           if(ans[p[i]]>i){
               wa_sum++;
           }
       }
   }
   printf("%d %d\n",ans_sum,wa_sum);







}


Measured memory_bytes: 6528
import sys
input = sys.stdin.readline
from bisect import bisect_left
N, Q = map(int, input().split())
W = [tuple(map(int, input().split())) for _ in range(N)]
W.sort(key=lambda x:x[2])
D = [int(input()) for _ in range(Q)]
ans = [-1]*Q
skip = [-1]*Q
for s, t, x in W:
    l = bisect_left(D, s-x)
    r = bisect_left(D, t-x)
    while l < r:
        if skip[l] == -1:
            ans[l] = x
            skip[l] = r
            l += 1
        else:
            l = skip[l]
print(*ans, sep='\n')

Measured memory_bytes: 57064
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    i64 n;
    cin>>n;
    int sum = INT_MAX;
    for(i64 i=1;i*i<=n;i++){
        if(n%i==0){
            i64 d = n/i;
            int fa_b = max(log10(i),log10(d))+1;
            sum = min(sum, fa_b);    
        }
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3948
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;


void calc() {

	Int K, N; std::cin >> K >> N;
	std::vector<Int> A(N);
	rep(i, N) {
		std::cin >> A[i];
	}
	A.push_back(A[0] + K);
	Int l = -INF;
	rep(i, N) {
		l = std::max(l, A[i + 1] - A[i]);
	}
	std::cout << K - l << "\n";

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 4736