akhauriyash/Code-Regression huggingface dataset:
S = gets.chomp
PTN = [['dream', 5], ['dreamer', 7], ['erase', 5], ['eraser', 6]]

solve = false
q = [0]

until q.empty?
  i = q.shift
  PTN.each do |p, s|
    if S[i, s] == p
      q << i + s
      if i + s == S.size
        solve = true
      end
    end
  end
end

puts solve ? 'YES' : 'NO'

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;
const ll INF = 1000000000000000001;


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

    ll bai = (n + k - 1) / k;
    ll k2 = k * bai;

    ll ans = min(k2 - n, min(n, abs(k - n)));

    cout << ans << endl;
}


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

int main() {
	int N, *L,Sum=0;
	cin >> N;
	L = new int[N * 2];
	for (int i = 0; i < N * 2;i++) cin >> L[i];
	sort(L, L + N*2);
	for (int i = 0, j = 1; i < N; i++) {
		if (L[i*2] > L[j]) Sum += L[j];
		else Sum += L[i*2];
		j += 2;
	}
	cout << Sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<set>
#include<algorithm>
#include<queue>
using namespace std;
const int N=2e5+5;
int a[N];
typedef long long ll;
int K,n;
ll de[N];
ll ans;
void ini(int,int);
int main(){
    scanf("%d%d",&n,&K);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    ini(1,n);
    printf("%lld",ans);
}
void ini(int s,int e){
    if(s==e){
        ans+=a[s]>=K;
        return;
    }
    int mid=(s+e)/2;
    ini(s,mid),ini(mid+1,e);
    int top=0;
    ll sum=0;
    for(int i=mid;i>=s;i--){
        sum+=a[i];
        de[top++]=-sum+1LL*K*(mid-i+1);
    }
    sort(de,de+top);
    sum=0;
    for(int i=mid+1;i<=e;i++){
        sum+=a[i];
        int t=upper_bound(de,de+top,sum-1LL*K*(i-mid))-de;
        ans+=max(0,t);
    }
}


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

namespace abc175_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var L = CIn.ReadIntArray(N);

      Array.Sort(L);

      var ans = 0;

      for (int i = 0; i < N - 2; i++)
      {
        for (int j = i + 1; j < N - 1; j++)
        {
          for (int k = j + 1; k < N; k++)
          {
            if (L[i] != L[j] && L[j] != L[k] && L[i] + L[j] > L[k])
            {
              ans++;
            }
          }
        }
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 27864
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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

ll gcd(ll a,ll b) {if(a%b==0) return(b); else return(gcd(b,a%b));}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,K; cin>>N>>K;
  string S; cin>>S;
  
  //ランレングス圧縮
  vector<ll> vec(0);
  int flag=1;
  ll count=0;
  for(auto cha:S){
    if(flag==cha-'0') count++;
    else{
      vec.push_back(count);
      flag=1-flag;
      count=1;
    }
  }
  vec.push_back(count);
  
  //for(auto v:vec) cout<<v<<'\n';
  
  ll n=2*K+1-vec.size();
  if(n>0) rep(i,n) vec.push_back(0);
  vec.push_back(0);
  
  ll sz=vec.size();
  vector<ll> cum(sz+1,0);
  rep(i,sz) cum[i+1]=cum[i]+vec[i];
  
  ll ans=0;
  for(int i=0;i+2*K<sz;i+=2) chmax(ans,cum[i+2*K+1]-cum[i]);
  
  cout<<ans<<'\n';
  
  //for(auto v:cum) cout<<v<<'\n';
  
  return 0;
}


Measured memory_bytes: 6576
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
ll MOD = 1000'000'007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS

    ll a,b;
    cin >> a >> b;
    cout << max(0ll, a - 2 * b);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x;
    cin >> x;
    cout << (x / 500) * 1000 + ((x % 500) / 5) * 5;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int num[105]; int n;
LL cal(int p)
{
     LL ans = 0;
    for(int i = 0;i<n;++i)
    {
        ans+=(num[i]-p)*(num[i]-p);
    }
    return ans;
}
int main()
{

    cin >> n;
    for(int i = 0;i<n;++i)
    {
        cin >> num[i];
    }
    sort(num,num+n);
   // int p = (num[0]+num[n-1])/2;
    LL ans = 1e18;
    for(int i = num[0];i<=num[n-1];++i)
    {
        ans = min(ans,cal(i));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string T; cin >> T;
  rep(i,T.size()) {
    if (T[i]=='?') cout << 'D';
    else cout << T[i];
  }
  cout << endl;
  
  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 3724
//AtCoder ABC093 A - abc of ABC
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

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

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

int main() {

	ll N;
	cin >> N;

	vector<ll> A(N + 1, 0); // 約数の個数を入れる
	A[1] = 1;

	for (ll i = 2; i <= N; i++) {
		if (A[i] == 0) {
			ll p = i;
//			cout << "prime " << p << endl;
			A[p] = 2;
			ll pp = p;
			while (pp * p <= N) {
				A[pp * p] = A[pp] + 1;
//				cout << pp * p << endl;
				pp *= p;
			}
			for (int j = 2; j * p <= N; j++) {
				if (A[j] != 0) {
					pp = p;
					while (j * pp <= N) {
						if (A[j] != 0 && A[j*pp] == 0) {
							A[j * pp] = A[j] * A[pp];
							//						cout << j << ":" << A[j] << " " << pp << ":" << A[pp] << " " << j * pp << ":" <<  A[j*pp] << endl;
						}
						pp *= p;
					}

				}
			}
		}
	}

	ll cumm = 0;
	for (ll i = 1; i <= N; i++) {
		cumm += A[i] * i;
//		cout << i << " " << A[i] << " " << cumm << endl;
	}
	cout << cumm << endl;
	return(0);
}


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

int main(){

	int alice,bob;

	cin >> alice >> bob;

	if(alice == 1) alice = 14;
	if(bob == 1) bob = 14;

	if(alice > bob)      cout << "Alice" << endl;
	else if(bob > alice) cout << "Bob" << endl;
	else                 cout << "Draw" << endl;
}

Measured memory_bytes: 256
s = input() + '@'

lst = [1]*len(s)
for i in range(1,len(s)):
  if s[i] == s[i-1]:
    lst[i] = lst[i-1] + 1

ans = 0
for i in range(0,len(s)):
	if s[i] == 'R':
		ans = max(ans,lst[i])

print(ans)



Measured memory_bytes: 9016
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<char,int> mp;
int main(){
int n,k;
cin>>n>>k;
vector<ll> v(n+1,0);
for(int i=0;i<n;i++)cin>>v[i];
if(n==1){
    cout<<max((ll)0,v[0])<<endl;
    return 0;
}
int m=n+1;
int ma=min(k,m);
if(ma==m)ma--;
ll ans=0;
for(int i=ma;i>=1;i--){//iは区間
for(int j=m-i-1;j<m;j++){
    ll res=0;
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    int l=0;
while(l!=i+1){res+=v[(l+j)%m];pq.push(v[(l+j)%m]);l++;}
    int times=k-i;
   while(times--){
       if(pq.empty())break;
        ll tmp=pq.top();
        pq.pop();
        if(tmp>=0)break;
        res-=tmp;
    }
ans=max(ans,res);
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<limits.h>
#define int long long
using namespace std;

int a[100001];
signed main() {
	int b; scanf("%lld", &b);
	int sum = 0;
	for (int c = 0; c < b; c++) {
		scanf("%lld", &a[c]);
		sum += a[c];
	}
	a[b] = a[0];
	int d = b*(b + 1) / 2;
	if (sum%d) { puts("NO"); return 0; }
	sum /= d;//行う回数
	int K = 0;
	for (int i = 0; i < b; i++) {
		int x = a[i], y = a[i + 1];
		y -= sum;
		if (x < y || (x - y) % b) { puts("NO"); return 0; }
		K += (x - y) / b;
	}
	if (sum == K)puts("YES");
	else puts("NO");
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int a,b;cin>>a>>b;cout<<(a+b+1)/2<<endl;
}







Measured memory_bytes: 256
import sys

input = sys.stdin.readline

N = int(input())
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)
for i in range(1, N+1):
    t[i], x[i], y[i] = map(int, input().split())


for i in range(1, N+1):
    if abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) > (t[i] - t[i-1]) or (((t[i] -x[i] -y[i]) % 2) != 0):
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 11636
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    using namespace std;
       
    int main(){
      string s;
      cin >> s;
      if(s == "A")
    	  cout << "T" << endl;
      if(s == "G")
          cout << "C" << endl;
      if(s == "T")
          cout << "A" << endl;
      if(s == "C")
          cout << "G" << endl;
    }

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
As=LI()
Bs=LI()
Cs=LI()

res = 0
lst = -1
for i in As:
    res += Bs[i-1]
    if i  == lst + 1: res += Cs[lst-1]
    lst = i
print(res)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){


  int n,a[10000],m,b,result=0,i,j;

  cin>>n;
  for(i=0;i<n;i++) cin>>a[i];
  cin>>m;
  for(i=0;i<m;i++){
    cin>>b;
    for(j=0;j<n;j++) if(b==a[j]){
        result++;
        break;
      }
  }

  cout<<result<<endl;

  return 0;

}

Measured memory_bytes: 3076
#include<stdio.h>
#define max(a,b) (a<b?b:a)
#define m(a,b,c) max(a,max(b,c))
int main(){
  int p,q,r;
  scanf("%d%d%d",&p,&q,&r);
  printf("%d",p+q+r-m(p,q,r));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FAST_IO   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Relocate freopen("./in.txt","r",stdin),freopen("./out.txt","w",stdout)
#define up(mi,a,b) for(mi=a;mi<=b;++mi)
#define down(mi,b,a) for(mi=b;mi>=a;--mi)
#define mfill(a,v) memset(a,v,sizeof(a))
#define INF 0x3f3f3f3f
#define MAX  2000005
#define v_n 5005
#define LL  long long
#define ULL unsigned long long 
#define e_n 50005
#define eps 1e-12
#define Blen 32
const LL MOD = 998244353;
using namespace std;
int main(void)
{
	int i, j, k;
	FAST_IO;
	//Relocate;
	LL N;
	cin >> N;
	LL ans = 0;
	for (LL a = 1; a*a <= N; a++)
	{
		if (N%a == 0 )
		{
			LL b = N / a-1;
			if(b>0&&N%b==N/b)
			   ans += b;
		}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[4][4];
int main()
{
    for(int i = 1; i <= 3; i++) for(int j = 1;j <= 3; j++) cin >> a[i][j];
    if(a[1][2] + a[2][3] + a[3][1] + a[1][3] + a[2][1] + a[3][2] == (a[1][1] + a[2][2] + a[3][3]) * 2) cout << "Yes\n";
    	else	cout << "No\n";
    return 0;
}

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

typedef long long ll;
map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

map<ll, int> merge(map<ll,int> m1, map<ll, int> m2){
  if(m1.size() > m2.size()){
    return merge(m2, m1);
  }
  for(auto m : m1){
    if(m2.count(m.first) == 0){
      m2[m.first] = m.second;
    } else {
      m2[m.first] += m.second;
    }
  }
  return m2;
}

int main(){
  ll N;
  int MOD = 1000000000 + 7;
  cin >> N;
  map<ll,int> m = prime_factor(2);
  for(int i = 3; i <= N; i++){
    map<ll,int> m2 = prime_factor(i);
    m = merge(m, m2);
  }
  
  ll ans = 1;
  for(auto x: m){
    cerr << x.first << " " << x.second << endl;
    ans =  ans * (x.second + 1);
    ans = ans % MOD;
  }
  if( N == 1){
    cout << 1 << endl;
  } else if(N == 2){
    cout << 2 << endl;
  } else {
    cout << ans << endl;
  }

}

Measured memory_bytes: 256
def f(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n,p = map(int,input().split())
arr = f(p)
l = []
for i in arr:
  if i[1] >= n:
    l.append((i[0],i[1]//n))
ans = 1
for i in l:
  ans *= i[0]**i[1]
print(ans)

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

int a[100005], b[100005];

int main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		if(i%2==0) b[1]-=a[i];
		else b[1]+=a[i];
	}
	cout<<b[1] <<" ";
	for(int i=2; i<=n; i++)
	{
		b[i]=2*a[i-1]-b[i-1];
		cout<<b[i] <<" ";
	}
}


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

void p(bool a[101][101], bool b[101][101]);
void pow(bool a[101][101],unsigned int z){
	bool e[101][101];
	memset(e,0,sizeof e);
	for(int i = 0 ;i < 101; i++) e[i][i] = 1;
	while(z){
		if(z&1){
			p(e,a);
		}
		p(a,a);
		z >>= 1;
	}
	memcpy(a,e,sizeof e);
}

void p(bool a[101][101], bool b[101][101]){
	bool c[101][101];
	memset(c,0,sizeof c);
	for(int i = 0; i < 101; i++){
		for(int j = 0; j < 101; j++){
			for(int k = 0; k < 101; k++){
				c[i][j] |= a[i][k]&b[k][j];
			}
		}
	}
	memcpy(a,c,sizeof c);
}

int main(){
	unsigned int n,m,z;
	cin >> n >> m >> z;
	while(n){
		int r[101][2];
		for(int i = 0; i < m; i++){
			int a,b;
			cin >> a >> b;
			r[i][0] = r[m+i][1] = a;
			r[i][1] = r[m+i][0] = b;
		}
		r[2*m][0] = 0;
		r[2*m][1] = 1;
		bool a[101][101];
		memset(a,0,sizeof a);
		for(int i = 0; i <= 2*m; i++){
			for(int j = 0; j <= 2*m; j++){
				if(r[i][1] == r[j][0] && r[i][0] != r[j][1]) a[j][i] = 1;
			}
		}
		bool v[101] = {false};
		v[2*m] = 1;
		pow(a,z);
		bool _v[101] = {false};
		for(int j = 0; j <= 2*m; j++){
			for(int k = 0; k <= 2*m; k++){
				if(a[j][k] && v[k]) _v[j] = 1;
			}
		}
		bool f = false;
		for(int i = 0; i < 2*m; i++){
			if(_v[i] && r[i][1] == n){
				f = true;
				break;
			}
		}
		if(f) cout << "yes" << endl;
		else cout << "no" << endl;
		cin >> n >> m >> z;
	}
}

Measured memory_bytes: 884
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void No() {
  print(-1);
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  ull a, b, X = 0;
  cin >> a >> b;
  rep(i, n-2){
    ull x;
    cin >> x;
    X ^= x;
  }
  ull S = a + b;
  if(S < X || (S - X) % 2) No();
  ull D = (S - X) / 2;
  if(D & X) No();
  if(D > a) No();
  ull A = D, B = D;
  repb(i, 63){
    ull j = 1ll << i;
    if(j & X){
      if(A + j <= a) A += j;
      else B += j;
    }
  }
  if(!A) No();
  print(a - A);
}


Measured memory_bytes: 3628
N = int(input())
p = list(map(int,input().split()))

if p == sorted(p):
    print('YES')
else:
    ret = 'NO'
    # 全通りの組み合わせをみて、昇順かどうか調べる
    for i in range(N-1):
        for j in range(i+1, N):

            # p[i]とp[j]より小さければ抜ける
            if p[i] < p[j]:
                is_sorted = False
                continue
            else:
                k = p.copy()
                k[i], k[j] = k[j], k[i]

            is_sorted = True
            for l in range(N-1):
                if k[l+1] < k[l]:
                    is_sorted = False
                    break

            if is_sorted:
                ret = 'YES'
                break
        if is_sorted:
            break

    print(ret)

Measured memory_bytes: 9136
#include<algorithm>
#include<cstring>
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef unsigned long long ull;
typedef set<int>::iterator sit;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second < b.second;}};
int lb(int x){return  x & -x;}
//friend bool operator < (Node a,Node b)   重载
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int maxn = 2e6+10;
int a[maxn];
int n,m;
bool pd(int x)
{
	ll s =0 ;
	for (int i = 1; i <= n; i ++ )
	{
		s += (a[i] + x - 1) / x - 1;
	}
	return s <= m;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i = 1; i <= n; i ++ )
		scanf("%d",&a[i]);
	int l = 1, r = 1e9;
	while(l < r)
	{
		int mid = l + r >> 1;
		if(pd(mid))
			r = mid;
		else
			l = mid + 1;
	}
	printf("%d\n",r);
}



Measured memory_bytes: 4004
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    vec<plint> A_list(N);
    range(i, 0, N) {
        lint A; cin >> A;
        A_list.at(i) = {A, i};
    };
    sort(A_list.begin(), A_list.end());
    range(i, 0, N) cout << A_list.at(i).second + 1 << " ";
    cout << "\n";
    // vec<lint> order(N);
    // range(i, 0, N) order.at(A_list.at(i).second) = i + 1;
    // range(i, 0, N) cout << order.at(i) << " ";
    // cout << "\n";
}

Measured memory_bytes: 2432
#include <stdio.h>
int main(){

  int S[100000],T[50000];
  int i,n,q;
  int count = 0;
  int left,right,mid,num;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }

  //ここから計算
  //配列SからバイナリサーチでTの値を探す

  for(i = 0; i < q; i++){

    num = T[i];
    left = 0;
    right = n;
    while(left <= right){
      mid = (left + right) / 2;
      if(S[mid] == num){
	count++;
	break;
      }else if(S[mid] < num){
	left = mid + 1;
      }else{
	right = mid - 1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



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

using namespace std;

map<long long, long long> mem;
const long long inf = 2e18;

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

void upd(long long & var, long long x) {
  if (var == -1 || var > x)
    var = x;
}
long long calc(long long v) {
  if (v <= 0)
    return 0;
  auto it = mem.find(v);
  if (it != mem.end()) {
    return it->second;
  }
  long long res = -1;
  if (inf / d >= v) {
    res = d * v;
  }
  for (int i = -5; i <= min(5LL, v); ++i) {
    long long cur = v - i;
    if ((cur % 5) == 0 &&  cur / 5 < v) {
      upd(res, calc(cur/5) + c + d * abs(i));
      // break;
    }
  }
  for (int i = -5; i <= min(5LL, v); ++i) {    
    long long cur = v - i;
    if ((cur % 3) == 0 &&  cur / 3 < v) {
      upd(res, calc(cur/3) + b + d * abs(i));
      // break;
    }
  }
  for (int i = -5; i <= min(5LL, v); ++i) {
    long long cur = v - i;
    if ((cur % 2) == 0 && cur / 2 < v) {
      upd(res, calc(cur/2) + a + d * abs(i));
      // break;
    }
  }
  return mem[v] = res;
}

int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    cin >> n >> a >> b >> c >> d;
    mem.clear();
    cout << calc(n) << '\n';
  }
  return 0;
}


Measured memory_bytes: 7232
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	char a[25];
	char b[25];
	int i = 0;
	cin >> a;
	int length = strlen(a);
	for(int t = 0;t<=length;t++)
		b[t]=a[length-t-1];
	b[length] = a[length];
	cout << b;
	cout << endl;

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  double t,x;
  cin >> t >> x;
  cout << t/x << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int  main()
{
    int a,b,c,m,n,o;
    scanf("%d%d%d",&a,&b,&c);
    if(a<b)
    {
        m=a;
        n=b;
    }
    else
    {
        m=b;
        n=a;
    }
    if(c<m)
    {
        m=c;
        if(a<b)
            n=a;
        else
            n=b;
    }
    else if(n>c)
    {
        n=c;
    }
    else
    {
        n=n;
    }
    o=(a+b+c)-(m+n);
    printf("%d %d %d\n",m,n,o);
    return 0;
}



Measured memory_bytes: 2120
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String str = sc.next();

        int[] accE = new int[N + 2];
        for (int i = 1; i <= N; i++) {
            accE[i] = accE[i - 1];
            if (str.charAt(i - 1) == 'W') {
                accE[i]++;
            }
        }

        int[] accW = new int[N + 2];
        for (int i = N; i >= 1; i--) {
            accW[i] = accW[i + 1];
            if (str.charAt(i - 1) == 'E') {
                accW[i]++;
            }
        }

        int minNum = Integer.MAX_VALUE;
        for (int i = 1; i <= N; i++) {
            int tmpChangeNum = accE[i - 1] + accW[i + 1];
            minNum = Math.min(minNum, tmpChangeNum);
        }

        out.println(minNum);
    }
}

Measured memory_bytes: 30732
#include <atcoder/all>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll mod = 998244353;
int main() {
	ll T;
	cin >> T;
	rep(i, T) {
		ll N, M, A, B;
		cin >> N >> M >> A >> B;
		cout << floor_sum(N, M, A, B) << endl;
	}
}

Measured memory_bytes: 3628
import Data.Maybe
import Control.Monad
import Control.Applicative

money :: [Int] -> Maybe Int
money [] = Nothing
money [_] = Nothing
money (a:b:_) = Just (a - b)


solver :: [[Int]] -> Int -> Int -> Int -> String
solver [] _ _ _ = "NA"
solver (m:ms) obj now month =
  let newNow = now + fromJust (money m)
  in
      if newNow >= obj
        then show (month + 1)
        else solver ms obj newNow (month + 1)


main :: IO()
main = do
  obj <- (read :: String -> Int) <$> getLine
  unless (obj == 0) $ do
    line <- map (map (read :: String -> Int) . words) <$> replicateM 12 getLine
    putStrLn $ solver line obj 0 0
    main

Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  double r; cin >> r;
  printf("%.10lf\n", 2* r * M_PI);
}

// EOF


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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll n,m,k;
string s;
int main() {
    INIT();

    cin >> k >> s;
    if(s.size() <= k) {
        cout << s;
    } else {
        REP(i, k) {
            cout << s[i];
        }
        cout << "...";
    }
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	int N;
	scanf("%d", &N);
	int count = 0;
	char s;
	for (int i = 0; i < N; i++) {
		scanf("%c", &s);
		if (s == 'Y') {
			count++;
			break;
		}
	}
	if (count == 0) {
		printf("Three");
	}
	else {
		printf("Four");
	}

	return 0;

}

Measured memory_bytes: 128
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cntr = Counter(A)


key_list = list(cntr.keys())

key_list.sort(reverse=True)

ans_cand = []
ans = 0
for key in key_list:
    if cntr[key] >= 4:
        ans_cand.append(key)
    if cntr[key] >= 2:
        ans_cand.append(key)
        
if len(ans_cand) < 2:
    ans = 0
else:
    ans = ans_cand[0] * ans_cand[1]
    
print(ans)

Measured memory_bytes: 18600
#include <iostream>
#include <cmath>

using namespace std;

//0.785398s

int main(){
  int a, b, x;
  cin >> a >> b >> x;
  double s = x / double(a);

  double rest_height;
  if( a*b/2.0 <= s ){
    rest_height = (a*b - s)*2 / double(a);
    printf("%.10f\n", atan2(rest_height, a) * 180 / M_PI);
  }else{
    rest_height = 2*s/double(b);
    printf("%.10f\n", atan2(b, rest_height) * 180 / M_PI);
  }
  return 0;
}


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

int main(){
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << setprecision(7) << double(w) * double(h) / 2.0 << " " <<(2 * x == w && 2 * y == h) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mpr make_pair
#define PB push_back
#define FS first
#define SC second
typedef pair < int , int > pii;
typedef long long LL;
int N,L,P[200005];
namespace BIT{
	int a[200005];
	void init(){
		memset(a,0,sizeof(a));
	}
	void add(int p,int v){
		++p;
		while(p<=N){
			a[p]+=v;
			p+=(p&(-p));
		}
	}
	int qry(int p){
		int r=0;
		++p;
		while(p){
			r+=a[p];
			p-=(p&(-p));
		}
		return r;
	}
}
int inr[200005];
int main(){
	int i,j,k;
	scanf("%d%d",&N,&L);
	for(i=0;i<N;++i) scanf("%d",P+i);
	for(i=0;i<N-1;++i) inr[i]=(P[i]>P[i+1]);
	for(i=1;i<N-1;++i) inr[i]+=inr[i-1];
	BIT::init();
	int res=1,cnt=(int)(L==1 || inr[L-2]==0);
	for(i=0;i<L;++i) BIT::add(P[i],1);
	for(i=1;i<N-L+1;++i){
		bool rem=1;
		if(BIT::qry(P[i-1])!=1) rem=0;
		BIT::add(P[i-1],-1);
		BIT::add(P[i+L-1],1);
		if(BIT::qry(P[i+L-1])!=L) rem=0;
		if(!rem) ++res;
		if(!rem && inr[i+L-2]==inr[i-1]) ++cnt;
	}
	printf("%d\n",res-max(cnt-1,0));
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
  bool num[1000001] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]){
      for(int j= i*i; j<1000001; j+=i){
	num[j] = true;
      }
    }
  }
  int n;
  while(cin >>n,n){
    int ans = 0;
    for(int i=3; i<=n/2; i+=2){
      if((!num[i]) && (!num[n-i])){ans++;}
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2140
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    H,W = LI()

    ans = INF
    for i in range(1,H):
        b1 = i * W
        b2 = (H-i) * (W//2)
        b3 = (H-i) * (W - W//2)
        ans = min(ans,max(b1,b2,b3) - min(b1,b2,b3))
        b2 = ((H-i)//2) * W
        b3 = ((H-i) - (H-i)//2) * W
        ans = min(ans,max(b1,b2,b3) - min(b1,b2,b3))
        
    for i in range(1,W):
        b1 = i * H
        b2 = (W - i) * (H // 2)
        b3 = (W - i) * (H - H // 2)
        ans = min(ans, max(b1, b2, b3) - min(b1, b2, b3))
        b2 = ((W - i) // 2) * H
        b3 = ((W - i) - (W - i) // 2) * H
        ans = min(ans, max(b1, b2, b3) - min(b1, b2, b3))

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 41580
def resolve():
    import math
    A, B, H, M = map(int, input().split())
    sita = abs(H*30+M*0.5-M*6)
    if sita > 180:
        sita = 360 - sita
    print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(sita))))
resolve()

Measured memory_bytes: 9580
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    ll n,m;
    cin>>n>>m;
    n=2*m+1;
    ll st=1,en,a,b=n;
    for(en=1;en<=n;++en){
        if((n-en)%2==0){
            if(en+1==n-en||en-1==n-en){break;}
        }
    }
    a=en+1;
    while(m>0&&st<en){
        cout<<st<<" "<<en<<endl;
        ++st;--en;
        --m;
    }
    while(m>0&&a<b){
        cout<<a<<" "<<b<<endl;
        ++a;--b;
        --m;
    }

    return (0);
}


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

int main(){
    string s;
    cin >> s;
    if(s.at(2)== s.at(3) and s.at(4)==s.at(5)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
  string s;
  cin>>s;
  
  bool flag = false;
  //AKIHABARA
  if(s=="KIHBR"||s=="AKIHBR"||s=="KIHABR"||s=="KIHBAR"||s=="KIHBRA")
     flag=true;
  else if(s=="AKIHABR"||s=="AKIHBAR"||s=="AKIHBRA"||s=="KIHABAR"||s=="KIHABRA"||s=="KIHBARA")
     flag=true;
  else if(s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"||s=="KIHABAR"||s=="KIHBARA"||s=="KIHABRA")
     flag=true;
  else if(s=="AKIHABARA")
     flag=true;
     
     if(flag)
       cout<<"YES"<<endl;
     else
       cout<<"NO"<<endl;
     return 0;
}

Measured memory_bytes: 256
use std::cmp::max;
fn main() {
    proconio::input! {
        n: usize,
        a: [i64; n],
    }
    let mut dp = [[0; 2]; 2];
    dp[0][1]=a[0];
    dp[1][1]=max(a[0],a[1]);
    for (i,a) in a[2..].iter().enumerate() {
        if (i&1)==0 {
            dp[0][0] = max(dp[0][0]+a,dp[1][1]);
            dp[0][1] += a;
        }
        else {
            dp[1][0] = max(dp[1][0]+a,dp[0][0]);
            dp[1][1] = max(dp[1][1]+a,dp[0][1]);
        }
    }
    println!("{}",if (n&1)==0 { dp[1][1] } else { dp[0][0] });
}

Measured memory_bytes: 5712
N,A,B,C=map(int,input().split())
L=[]
for i in range(N):
    l=int(input())
    L.append(l)
    
while len(L)<8:
    L.append(0)
    
#print(L)

ans=1000000000
a=[]
b=[]
c=[]
COU=0
D=1

for a1 in range(4):
    for a2 in range(4):
        for a3 in range(4):
            for a4 in range(4):
                for a5 in range(4):
                    for a6 in range(4):
                        for a7 in range(4):
                            for a8 in range(4):
                                for x in range(8):
                                    LIS=[a1,a2,a3,a4,a5,a6,a7,a8]
                                    if LIS[x]==0:
                                        a.append(L[x])
                                    elif LIS[x]==1:
                                        b.append(L[x])
                                    elif LIS[x]==2:
                                        c.append(L[x])
                                
                                A1=max((len(a)-a.count(0)-1),0)*10
                                B1=max((len(b)-b.count(0)-1),0)*10
                                C1=max((len(c)-c.count(0)-1),0)*10
                                A2=sum(a)
                                B2=sum(b)
                                C2=sum(c)
                                ARR=[A2,B2,C2]
                                ARR.sort(reverse=True)
                                cnt=A1+B1+C1+abs(A-ARR[0])+abs(B-ARR[1])+abs(C-ARR[2])
                                #print(a,b,c)
                                if cnt<ans and ARR[2]!=0:
                                    ans=cnt
                                    #print(ans)
                                    #print(a,A1,A2)
                                    #print(b,B1,B2)
                                    #print(c,C1,C2)
                                a=[]
                                b=[]
                                c=[]
                                if a7==3:
                                    D+=1
                                
print(ans)

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

#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double ld;

const ld pi=3.1415926535897932384626433;
const int mod = 1000000007;
const ll inf=3e18;
// 90DTG
ll dp[100001][3];
ll a[100001];
ll b[100001];
ll c[100001];
ll n;

ll god(ll ind, ll prev)
{
   if (ind>=n)
      return 0;
   if (dp[ind][prev]!=-1)
      return dp[ind][prev];

   ll ans=0;
   if (prev==0)
   {
      ans=max(b[ind]+god(ind+1,1),c[ind]+god(ind+1,2));
   }
   else if (prev==1)
   {
      ans=max(a[ind]+god(ind+1,0),c[ind]+god(ind+1,2));
   }
   else
      ans=max(b[ind]+god(ind+1,1),a[ind]+god(ind+1,0));
   return dp[ind][prev]=ans;
}
int main ()
{
   bolt;
   memset (dp,-1,sizeof(dp));
   cin>>n;
   for (ll i=0;i<n;i++)
   {
      cin>>a[i]>>b[i]>>c[i];
   }
   cout<<max({a[0]+god(1,0),b[0]+god(1,1),c[0]+god(1,2)});

}


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



public class P{


	public static void Main(){
	
		var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
		var N = input[0];
		var M = input[1];
		
		var cards = new List<long>(Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse));
		cards.Sort();
		var cardArray = cards.ToArray();
		List<change> changes = new List<change>();
		
		
		for(int i = 0; i < M; i++){
			changes.Add(new change(Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse)));
		}
		
		changes.Sort();
		
		
		
		long cardCurrent = 0;
		long changeCurrent = 1;
		
		foreach(var tgt in changes){
			changeCurrent = 1;
			while(cardCurrent < N && cardArray[cardCurrent] < tgt.power && changeCurrent <= tgt.lives){
				cardArray[cardCurrent] = tgt.power;
				cardCurrent++;
				changeCurrent++;
			}
		
		}
		
		Console.WriteLine(cardArray.Sum());
	
	
	}

	class change : IComparable<change>{
	
		public long power{get;set;}
		public long lives{get;set;}
	
		public change(long[] x){
			power = x[1];
			lives = x[0];
		}
		
		public int CompareTo(change x){
		
			return (x.power == this.power) ? 0 : (x.power - this.power < 0) ? -1 : 1;
		
		}
	}

}

Measured memory_bytes: 32340
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        if(i+2<n && s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include "math.h"


int main(int argc, char *argv[]){

  int i;
  int n;
  int m, l;

  scanf("%d", &n);

  l = 0;
  for(i=1; i<=9; i++){
    if(n % i == 0){
      m = n/i;
      if(m<=9){
        l++;
      }
    }
  }
  if(l==0){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string N; cin >> N;
    ll sum = 0;
    REP(i, (int)N.length())
    {
        sum += N[i]-'0';
        sum %= 9;
    }
    if(sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3740
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int v[n] = {0};
    for(int& val : v){
        cin >> val;
    }

    int c[n] = {0};
    for(int& cost : c){
        cin >> cost;
    }

    int total = 0;
    for(int i = 0 ; i < n ; i++){
        int profit = v[i] - c[i];
        if(profit > 0){
            total += profit;
        }
    }

    cout << total;
    return 0;
}


Measured memory_bytes: 256