akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

#define ll long long

ll MAX(ll a,ll b){

    if(a>b)return a;
    else return b;

}
int main(){
  
  int H,W;
  string S[60];
  cin>>H>>W;
  for(int i=0;i<H;i++){
    
    cin>>S[i];
    
  }
  
  if(H==1&&W==1){
    
    cout<<"No"<<endl;
    
  }else if(H==1){
    
    bool flag=true;
    for(int i=0;i<W;i++){
      
      if(S[0][i]=='#'){
        
        if(i==0){
          
          if(S[0][1]=='.')flag=false;
          
        }else if(i==W-1){
          
          if(S[0][W-2]=='.')flag=false;
          
        }else{
          
          if(S[0][i-1]=='.'&&S[0][i+1]=='.')flag=false;
          
        }
        
      }
      
    }
    
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
  }else if(W==1){
    
    bool flag=true;
    for(int i=0;i<H;i++){
      
      if(S[i][0]=='#'){
        
        if(i==0){
          
          if(S[1][0]=='.')flag=false;
          
        }else if(i==H-1){
          
          if(S[H-2][0]=='.')flag=false;
          
        }else{
          
          if(S[i-1][0]=='.'&&S[i+1][0]=='.')flag=false;
          
        }
        
      }
      
    }
    
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
  }else{
    
    bool flag=true;
    for(int i=0;i<H;i++){ 
      for(int j=0;j<W;j++){
        
        if(S[i][j]=='#'){
          
          if(i==0&&j==0){
            
            if(S[0][1]=='.'&&S[1][0]=='.')flag=false;
            
          }else if(i==0&&j==W-1){
            
            if(S[0][W-2]=='.'&&S[1][W-1]=='.')flag=false;
            
          }else if(i==H-1&&j==0){
            
            if(S[H-2][0]=='.'&&S[H-1][1]=='.')flag=false;
            
          }else if(i==H-1&&j==W-1){
            
            if(S[H-2][W-1]=='.'&&S[H-1][W-2]=='.')flag=false;
            
          }else if(i==0){
            
            if(S[0][j-1]=='.'&&S[1][j]=='.'&&S[0][j+1]=='.')flag=false;
            
          }else if(i==H-1){
            
            if(S[H-1][j-1]=='.'&&S[H-2][j]=='.'&&S[H-1][j+1]=='.')flag=false;
            
          }else if(j==0){
            
            if(S[i-1][0]=='.'&&S[i][1]=='.'&&S[i+1][0]=='.')flag=false;
            
          }else if(j==W-1){
            
            if(S[i-1][W-1]=='.'&&S[i][W-2]=='.'&&S[i+1][W-1]=='.')flag=false;
            
          }else{
            
            if(S[i][j-1]=='.'&&S[i][j+1]=='.'&&S[i-1][j]=='.'&&S[i+1][j]=='.')flag=false;
            
          }
          
        }
        
      }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
  }
  
    return 0;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
ans = []
while len(B)!=0:
    for i in range(len(B)-1, -1, -1):
        if B[i] == i+1:
            ans.append(i+1)
            del B[i]
            break
    else:
        print(-1)
        exit()
print(*ans[::-1], sep="\n")


Measured memory_bytes: 38768
#include <bits/stdc++.h>
#pragma GCC target ("arch=sandybridge")
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
template <class T> ostream& operator<<(ostream &O, const deque<T>& v) {for (const T &e: v) O << e; return O;}



void _main() {
        int n; cin >> n;
        int x = 0;
        while (x < n) x += 1000;
        cout << x - n;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3660
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        a = L[i]
        b = L[j]
        ok = j
        ng = N-1
        if b-a < L[ng] and L[ng] < a+b:
            ans += N-1-j
        else:
            while ng - ok > 1:
                mid = (ok+ng) // 2
                if b-a < L[mid] and L[mid] < a+b:
                    ok = mid
                else:
                    ng = mid
       
            ans += ok - j

print(ans)

Measured memory_bytes: 43500
S = input()
S.split(',')
#print(S)
lenS = len(S)
maru = 0
#print(lenS,maru)
for i in range(lenS):
    if S[i] == 'o':
        maru += 1
    else:
        maru = maru
if 15-lenS + maru >= 8:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int ans1=A*X+B*Y;
  int ans2;
  int tmp=max(X,Y);
  if(tmp==X){
    ans2=X*C*2;
  }else{
    ans2=Y*C*2;
  }
  int tm=min(X,Y);
  int ans3;
  if(tm==X){
    ans3=X*C*2+abs(X-Y)*B;
  }else{
    ans3=Y*C*2+abs(X-Y)*A;
  }
  ans2=min(ans2,ans3);
  ans1=min(ans1,ans2);
  cout<<ans1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string x;getline(cin,x);
	for(int i=0;i<x.size();i++)
		if(x[i]=='C') {
			for(int j=1+i;j<x.size();j++)
			if(x[j]=='F') {
				printf("Yes");return 0;
			}
		}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int count = 0;

	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1) {
			int divisor = 0;
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= n; k++) {
					if (j * k == i) divisor++;
				}
			}
			if (divisor == 8) count++;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    ll N;
    cin >> N;

    if(N%2){
        cout << 0 << endl;
    }else{
        // int digit = sz(to_string(N));  // 45435 -> 5
        // int tmp = digit - 1;
        ll ans = 0;

        ll M = (N/10) * 10;

        ll tmp = 5;

        while(tmp < M){
            ans += ((M / tmp) / 2);
            tmp *= 5;
        }

        
        cout << ans << endl;
    }

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,r[300000],i;
    int maxv=-999999999,minv;
    scanf("%d %d",&n,&r[0]);
    minv = r[0];
    for(i=1;i<n;i++){
        scanf("%d",&r[i]);
        if(maxv<r[i]-minv){
            maxv=r[i]-minv;
        }
        if(minv>r[i]){
            minv = r[i];
        }
    }
    printf("%d\n",maxv);
    return 0;
}



Measured memory_bytes: 2512
#include <iostream>


using namespace std;

int main(){
    int n, l;
    cin >> n >> l;
    int sum {n*(2*l + n -1)/2};
    if(l > 0){
        cout << sum - l << endl;
    }
    else if(l + n - 1 < 0){
        cout << sum - (l + n -1) << endl;
    }
    else{
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextInt64() int64 {
	sc.Scan()

	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	n = n
	s := nextLine()
	x := 0
	max := 0

	for i := 0; i < len(s); i++ {
		if string(s[i]) == "I" {
			x++
			if max < x {
				max = x
			}
		} else if string(s[i]) == "D" {
			x--
			if max < x {
				max = x
			}
		}
	}
	fmt.Println(max)

}


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

int main(){
  int k,x;
  cin >> k >> x;
  int ans = max(500*k,x);
    if(ans == 500*k){
      cout << "Yes" << endl;
    }
    else{
      cout << "No"  << endl;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <set>

using namespace std;

int main()
{
    int A, B, C, D, E, F;
    if (scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F) < 6) return 0;

    set<int> sugar;
    for (int i = 0; i <= F; i++)
    {
        for (int j = 0; j <= F; j++)
        {
            int s = C * i + D * j;
            if (s <= F) sugar.insert(s);
        }
    }

    set<int> water;
    for (int i = 0; i <= F; i++)
    {
        for (int j = 0; j <= F; j++)
        {
            int w = 100 * (i * A + j * B);
            if (w <= F) water.insert(w);
        }
    }

    float conc = 0.0F;
    int sw = 0;
    int sg = 0;
    for (auto s = sugar.begin(); s != sugar.end(); s++)
    {
        for (auto w = water.begin(); w != water.end(); w++)
        {
            float now = 0.0F;
            if (0 < *s + *w) now = (float) 100.0F * *s / (*s + *w);
            if (*s + *w <= F
                && now <= (float) 100.0F * E / (100.0F + E)
                    && conc <= now)
            {
                conc = now;
                sw = *s + *w;
                sg = *s;
            }
        }
    }

    printf("%d %d", sw, sg);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
int a[N];
int main(){
    int n; cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    int ans = 0;
    for(int i=0,j=0;i<n;i=j){
        while(a[j]==a[i]) j++;
        ans += (j - i) / 2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
FACT_MAX = 10 ** 5
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD)

N, K = map(int, input().split())
A = sorted(map(int, input().split()))
print(sum(comb(i, K - 1) * (A[i] - A[N - i - 1]) % MOD for i in range(K - 1, N)) % MOD)


Measured memory_bytes: 18516
#include <iostream>
#include <climits>

using namespace std;


const int max_n = 1 << 17;
const int max_array = max_n * 2 - 1;

const int INF = 2147483647;

int dat[max_array];

void init() {
	for (int i = 0; i < max_array ;i ++) {
		dat[i] = INF;
	}
}

void update(int k,int x) {
	k += max_n - 1;
	dat[k] = x;

	while(k > 0) {
		k = (k - 1) / 2;

		dat[k] = min(dat[k * 2 + 1] ,dat[k * 2 + 2]);
	}
}


int find(int a,int b,int k, int l, int m) {

	if (m <= a || b <= l) {
		return INF;
	}
	if (a <= l && m <= b) {
		return dat[k];
	}
	int lv = find(a,b,k * 2 + 1,l, (l + m) / 2);
	int mv = find(a,b,k * 2 + 2,(l + m) / 2, m);
	return min(lv,mv);
}


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

	init();

	for (int i = 0; i < q; i++) {
		int x,y,com;
		cin >> com >> x >> y;
		if (com == 0) {
			update(x,y);			
		} else {
			cout << find(x,y+1,0,0,max_n) << endl;
		}
	}

}

Measured memory_bytes: 2188
n = gets.to_i
as = gets.split.map(&:to_i)

def gcd(a,b)
  return a.abs if b == 0
  gcd(b, a%b)
end

def gcds(arr)
  ans = arr[0]
  (1..arr.size-1).each do |i|
    ans = gcd(ans, arr[i])
  end
  ans
end

puts gcds(as)

Measured memory_bytes: 8452
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int n, m, d;
  cin >> n >> m >> d;
  if (d == 0) printf("%.7f\n", (m - 1.0) * (n + 0.0) / (n * n));
  else printf("%.7f\n", (m - 1.0) * 2.0 * (n - d) / (n * n));
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = sorted([int(input()) for _ in range(n)])
sum_s = sum(s)
if sum_s % 10 == 0:
  for i in range(n):
    if s[i] % 10 == 0:
      continue
    else:
      sum_s -= s[i]
      break
if sum_s % 10 == 0:
  print(0)
else:
  print(sum_s)

Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var NK = ReadSplitInt();
            var N = NK[0];
            var K = NK[1];

            var sum = N;
            var count = 0;
            while (sum < K)
            {
                sum *= 2;
                count++;
            }

            double kakuritu = 0;
            for (int i = N; i > 0; i--)
            {
                if (i * Pow(2, count) < K)
                    count++;

                kakuritu += (1.0 / N) * Pow(1.0 / 2, count);
            }

            Println(kakuritu);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;

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

      int a,b,c,k; cin >> a >> b >> c >> k;
      //ll ans = 0;
      if(k<=a) cout << k << endl;
      else if(k>a && k<=b) cout << k << endl;
      else cout << a - (k-(a+b)) << endl;


      //cout << ans << endl;

      return 0;
}


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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int cnt[3000];
int main(){
	int n,x,y;cin>>n>>x>>y;x--;y--;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int dist=min(j-i,abs(i-x)+1+abs(j-y));
			cnt[dist]++;
		}
	}
	for(int k=1;k<=n-1;k++){
		cout<<cnt[k]<<endl;
	}
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
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);
}

//↑template↑




int main() {

	int a, b;
	cin >> a >> b;
	cout << a % b << endl;






}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

/**
 * @author: pashka
 */

fun prime(x: Int) : Boolean {
    for (i in 2 until x) {
        if (x % i == 0) return false
    }
    return true
}

private fun solve() {
    var x = nextInt()
    while (!prime(x)) {
        x++
    }
    println(x)
}

fun main(args: Array<String>) {
    solve()
    out.close()
}

private var br = BufferedReader(InputStreamReader(System.`in`))
private var st: StringTokenizer? = null
private var out = PrintWriter(System.out)

@Throws(IOException::class)
private fun next(): String {
    while (st == null || !st!!.hasMoreTokens()) {
        st = StringTokenizer(br.readLine())
    }
    return st!!.nextToken()
}

@Throws(IOException::class)
private fun nextInt(): Int {
    return next().toInt()
}

@Throws(IOException::class)
private fun nextLong(): Long {
    return next().toLong()
}


Measured memory_bytes: 31272
N = gets.to_i
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)
cs = gets.split.map(&:to_i)
ans = 0
prev = -2
as.each do |a|
  a -= 1
  ans += bs[a]
  ans += cs[prev] if prev + 1 == a
  prev = a
end
puts ans


Measured memory_bytes: 3836
Q=int(input())
SOSU={2}
from collections import defaultdict
data=dict()
data[-1]=0
data[0]=0
data[1]=0
data[2]=0
for i in range(3,10**5+1,2):
    data[i]=data[i-2]
    flag=True
    for j in range(3,int(i**0.5)+1):
        if i%j==0:
            flag=False
            break
    if flag:
        SOSU|={i}
        if (i+1)//2 in SOSU:
            data[i]+=1
for q in range(Q):
    l,r=map(int,input().split())
    print(data[r]-data[l-2])

Measured memory_bytes: 10004
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include <unordered_set>

using namespace std;

namespace {

}
int main()
{
	int N = 0, M = 0;

	cin >> N >> M;

	std::vector<int> ship1;
	// std::vector<int> shipN;
	//std::unordered_set<int> ship1;
	std::unordered_set<int> shipN;

	int a(0), b(0);
	for (int i = 0; i < M; ++i) {
		cin >> a >> b;
		if (a == 1) {
			ship1.push_back(b);
		}
		else if (b == N) {
			shipN.insert(a);
		}
	}

	bool isFound = false;
	for (auto& elem1 : ship1) {
		if(shipN.find(elem1) != shipN.end()){
			isFound = true;
			break;
		}
	}

	if (isFound) {
		cout << "POSSIBLE";
	}
	else {
		cout << "IMPOSSIBLE";
	}

	return 0;
}


Measured memory_bytes: 4764
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}

int X;
int main()
{
	cin >> X;
	int ans = X / 500;
	X %= 500;
	ans *= 1000;
	ans += (X / 5)*5;
	
	cout << ans << endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
ll prime[100002];
ll exp(ll a,ll b);
void sieve(ll n);
ll gcd(ll a ,ll b);
ll countdigit(ll n);
vector<ll>ft;

ll mul(ll a, ll b){
    ll ans= ((a%mod)*(b%mod))%mod;
    return ans%mod;
}
ll sub(ll a, ll b){
    ll ans = (a-b+mod)%mod;
    return ans;
}
ll add(ll a,ll b){
    ll ans = (a+b)%mod;
    return ans;
}

void solve() {
    ll n;
    cin >> n;
    ll c=0;
    rep(i,0,n){
        ll a,b;
        cin >> a >> b;
        if(a==b)c++;
        else c=0;
        if(c==3)break;
    }
    if(c==3)cout<<"Yes\n";
    else cout<<"No\n";
}


int main()
{
    flash;
    ll t=1;
    //ft.pb(1);
    //fact(10000001);
   // cin >> t;
    while(t--) { 
        solve();
    }
}

//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res%mod;
}
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
void sieve(ll n) {
    for(ll i=0;i<=n;i++) {
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(ll i=2;i<=n;i++) {
        if(prime[i]==1) {
            for(ll j=2;i*j<=n;j++) {
                prime[i*j]=0;
            }
        }
    }
}
ll countdigit(ll  n)
{
    return floor(log10(n) + 1);
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	string x;
	cin>>x;
	stack<char> sta;
	for(int i=0;i<x.size();i++){
		if(!sta.empty() && sta.top()=='S' && x[i] == 'T')sta.pop();
		else sta.push(x[i]);
	}
	cout<<sta.size()<<endl;
	return 0;
}

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

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 2e3 + 10;
const ll MOD  = 924844033;
const ll INF  = 1e18;

ll n, k, F[2 * N][N], fact[N], ans;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> k;
    fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = i * fact[i - 1] % MOD;
    }
    int len = n / k, t = 2 * (n % k), timer = 1;
    F[0][0] = 1;
    for (int i = 0; i < 2 * k; i++) {
        int l = (i < t ? len + 1 : len);
        for (int j = 0; j < l; j++) {
            for (int k = 0; k <= n; k++) {
                F[timer][k] = F[timer - 1][k];
                if (j)
                    F[timer][k] = (F[timer][k] + F[timer - 2][k - 1]) % MOD;
            }
            timer++;
        }
    }
    for (int i = 0; i <= n; i++) {
        ans += F[timer - 1][i] * fact[n - i] % MOD * pw(MOD - 1, i, MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 66436
# include <iostream>

using namespace std;


int main()
{
    int N, K;

    cin >> N >> K;

    int* p;
    p = new int[N];

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

    int sum = 0;
    int help;

    if (N == K)
    {
        for (int i = 0; i < N; i++)
        {
            sum += p[i];
        }
    }
    else
    {
        for (int i = 0; i < K; i++)
        {
            for (int i = 0; i < N; i++)
            {
                if (i < N - 1)
                {
                    if (p[i] < p[i + 1])
                    {
                        help = p[i];
                        p[i] = p[i + 1];
                        p[i + 1] = help;
                    }
                }
                if (i == N - 1)
                {
                    sum += p[i];
                }
            }
            N--;
        }
    }
    cout << sum;


    return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;

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


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

	if (s.substr(2,1) == s.substr(3,1) && s.substr(4, 1) == s.substr(5, 1)){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
    double r;
    cin>>r;
    double ans=2.0;
    ans*=r;
    ans*=3.14159;
    cout<<fixed<<setprecision(10)<<ans;
}


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

main()
{
   char str[10];
  
  gets(str);
  
  if(!strcmp(str,"SAT"))
  {
    printf("1");
  }
 else if(!strcmp(str,"FRI"))
  {
    printf("2");
  }
  else if(!strcmp(str,"THU"))
  {
    printf("3");
  }else if(!strcmp(str,"WED"))
  {
    printf("4");
  }else if(!strcmp(str,"TUE"))
  {
    printf("5");
  }else if(!strcmp(str,"MON"))
  {
    printf("6");
  }else if(!strcmp(str,"SUN"))
  {
    printf("7");
  }
}

Measured memory_bytes: 128
#include<stdio.h>
#define VMAX 100000
int Partition(int[VMAX],int,int);
void Swap(int *,int *);
int main(){
  int n;
  int A[VMAX];
  int i;
  int q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
q = Partition(A,0,n-1);

for(i=0;i<n;i++){
  if(i){
    printf(" ");
  }
  if(i==q){
    printf("[");
  }
  printf("%d",A[i]);
  if(i==q){
  printf("]");
}
}
printf("\n");
  return 0;
}

int Partition(int A[],int p,int r){
  int x,i,j;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      Swap(&A[i],&A[j]);
    }
  }
  Swap(&A[i+1],&A[r]);
  return i+1;
}

void Swap(int *x,int *y){
  int m;
  m = *x;
  *x = *y;
  *y = m;
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;

vector<pair<int,int> > graph[maxn];
bool color[maxn], visit[maxn];

void bfs(int s)
{
    queue<int> Q;
    Q.push(s);
    color[s] = false;

    while(!Q.empty())
    {
        int sz = (int) Q.size();

        while(sz--)
        {
            int u = Q.front();
            Q.pop();
            for(int i = 0; i < graph[u].size(); i++)
            {
                int v = graph[u][i].first;
                if(!visit[v])
                {
                    visit[v] = true;
                    Q.push(v);
                    if(graph[u][i].second == 1)
                    {
                        color[v] = !color[u];
                    }
                    else
                    {
                        color[v] = color[u];
                    }
                }
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    for(int i = 0; i < n-1; i++)
    {
        int u,v,w;
        cin >> u >>v >> w;
        graph[u].push_back({v, w & 1});
        graph[v].push_back({u, w & 1});
    }
    bfs(1);

    for(int i = 1; i <= n; i++)
        cout << color[i] << endl;
    return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main() {
  lli A,B=0,C=0,D,S;
  cin >> S;
  A=ceil(sqrt(S));
  B=A*A-S;
  cout <<0<<" "<<0<<" "<< A << " " << B << " " << 1 << " " << A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 100003

int main(){
	int n;
	long long jaw = 1e18;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = -100; i <= 100; i++){
		long long sum = 0;
		for(int x : a)
			sum = sum + 1LL * (x - i) * (x - i);
		jaw = min(jaw, sum);
	}
	cout << jaw << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    a, b, k = map(int, input().split())
    ans = set()
    for i in range(k):
        if a + i + 1 <= b: ans.add(a + i)
        if b - i >= a: ans.add(b - i)
    ans = list(ans)
    ans.sort()
    for x in ans: print(x)

if __name__ == "__main__":
    main()


Measured memory_bytes: 62484
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map{it.toInt()}
    var p=0
    var pp=list[0]
    var ppp=list[1]
    var count =0
    for(i in 2..n-1){
        p=pp
        pp=ppp
        ppp=list[i]
        if((pp>p&&pp<ppp)||(pp<p&&pp>ppp))count++
    }
    println(count)
}

Measured memory_bytes: 38032
n = int(input())
a = [[] for i in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))
    
ans = 0
nowlist = [a[i][0] for i in range(n)]
ans = 0
amap = [[0 for i in range(max(0,j))] for j in range(n+1)]
dokomade = [0 for i in range(n+1)]
todaylist = []
tomorrow = []

for i in range(n):
    i1 = min(nowlist[i],i+1)
    i2 = max(nowlist[i],i+1)
    amap[i2][i1] += 1
    if(amap[i2][i1]==2):
        todaylist.append([i1,i2])

#print(amap)

while(True):
    for i in range(len(todaylist)):
        i1=todaylist[i][0]
        i2=todaylist[i][1]
        dokomade[i1]+=1
        dokomade[i2]+=1
        if(dokomade[i1]<n-1):
            temp1=i1
            temp2=a[i1-1][dokomade[i1]]
            i3=max(temp1,temp2)
            i4=min(temp1,temp2)
            amap[i3][i4]+=1
            if(amap[i3][i4]==2):
                tomorrow.append([i3,i4])
        if(dokomade[i2]<n-1):
            temp1=i2
            temp2=a[i2-1][dokomade[i2]]
            i3=max(temp1,temp2)
            i4=min(temp1,temp2)
            amap[i3][i4]+=1
            if(amap[i3][i4]==2):
                tomorrow.append([i3,i4])
    
    ans += 1
    #print(dokomade)
    if(len(tomorrow)==0):
        if(sum(dokomade)!= n*(n-1)):
            ans = -1
        break
    todaylist = tomorrow
    tomorrow=[]
    
print(ans)

Measured memory_bytes: 67420
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *prev;
  struct node *next;
  long key;
};
typedef struct node * NP;
NP MN(long);
void IN(NP);
void DN(NP);
void FI(long);
NP dummy;

int main(){
  long int val,i,n;
  char op[12];
  NP roop;

  scanf("%ld",&n);
  dummy = MN(0);

  

  for(i=0;i<n;i++){
    scanf("%s",op);
    
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      IN(MN(val));
    }
    else if(strcmp(op,"delete") == 0){
      scanf("%ld",&val);
      FI(val);
    }
    else if(strcmp(op,"deleteFirst") == 0){
      DN(dummy->next);
    }
    else if(strcmp(op,"deleteLast") == 0){
      DN(dummy->prev);
    }
  }

  for(roop=dummy->next;roop!=dummy;roop =roop->next){
    printf("%ld",roop->key);
    if(roop->next != dummy)printf(" ");
  }  
  printf("\n");

  return 0;
}


void FI(long value){
  NP n;
  dummy->key = value;
  for(n = dummy->next;;n=n->next){
    if(n->key == value)break;
  }
  if(n != dummy)DN(n);
    
}


void DN(NP th){
  th->prev->next = th->next;
  th->next->prev = th->prev;
  th->prev = th->next = th;
  free(th);
  //delete th;
}


void IN(NP newn){
  newn->next = dummy->next;
  newn->next->prev = newn;
  dummy->next = newn;
  newn->prev = dummy;
}

NP MN(long key){
  NP no = (NP)malloc(sizeof(struct node));
  //n = new struct node();
  no->prev = no;
  no->next = no;
  no->key = key;
  return no;
} 



Measured memory_bytes: 32936
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string s;
vector<int> l,r;
int main(){
	int i,n,k,ans = 0;
	cin >> n >> k >> s;
	for(i=0;i<n;i++){
		if(s[i]=='L' && i!=0 && s[i - 1]=='L') ans++;
		if(s[i]=='R' && i!=n - 1 && s[i + 1]=='R') ans++;
	}
	for(i=0;i<n;i++){
		if((i!=0 && s[i - 1]!=s[i])){
			if(s[i - 1]=='L') l.push_back(2);
			else r.push_back(2);
		}
	}
	if(s[n - 1]=='L') l.push_back(1);
	else r.push_back(1);
	if(s[0]=='L'){
		l.pop_back(); l.push_back(1);
	}else{
		r.pop_back(); r.push_back(1);
	}
	sort(l.rbegin(),l.rend());
	sort(r.rbegin(),r.rend());
	int cnt1 = 0,cnt2 = 0;
	for(i=0;i<k;i++){
		if(i<l.size()) cnt1 += l[i];
		if(i<r.size()) cnt2 += r[i];
	}
	cout << min(n - 1,ans + max(cnt1,cnt2)) << endl;
}
	

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

int parent(int i)
{
  return i / 2;
}

int left(int i)
{
  return i * 2;
}

int right(int i)
{
  return i * 2 + 1;
}

int main()
{
  int i, H, k;
  vector<int> q; q.push_back(0);
  cin >> H;
  for (i = 1; i <= H; i++) {
    cin >> k;
    q.push_back(k);
  }
  for (i = 1; i <= H; i++) {
    cout << "node " << i << ": key = " << q.at(i) << ", ";
    if (1 != i)
      cout << "parent key = " << q.at(parent(i)) << ", ";
    int l, r;
    if ((l = left(i)) <= H)
      cout << "left key = " << q.at(l) << ", ";
    if ((r = right(i)) <= H)
      cout << "right key = " << q.at(r) << ", ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3072
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

  	int a;
  	multiprecision::cpp_dec_float_100 b;
  	cin >> a >> b;
  	b *= 100;
    b = a * b;

  	cout << int(b / 100) << '\n';

    return 0;
}


Measured memory_bytes: 3780
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  char a,b; 
  cin >> a >> b;
  if(a == b) cout << 'H' << endl;
  else cout << 'D' << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }
const int INF = 1000100100;

int main() {
    vector<ll> dishes(5);
    REP(i, 5) {
        cin >> dishes[i];
    }

    vector<ll> order(5);
    REP(i, 5) {
        order[i] = i;
    }

    ll ans = INF;
    do {
        ll time = 0;
        REP(i, 5) {
            if(time % 10 != 0) {
                time += 10 - (time % 10);
            }
            time += dishes[order[i]];
        }
        if(time < ans) {
            ans = time;
        }
    } while(next_permutation(order.begin(), order.end()));

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll cnt=0;
    string stmp;
    cin>>s;
    for(int i=0; i<s.length(); i++) {
        stmp=s[i];
//        dbg(i%2);
//        dbg(stmp);
        if((i%2 == 0)&&( stmp=="R" || stmp=="U" || stmp=="D")){
            cnt++;
        } else if ((i%2 == 1)&&( stmp=="L" || stmp=="U" || stmp=="D")) {
            cnt++;
        }else{
            break;
        }
    }
if(cnt==s.length()){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;   
}

    return  0;
}


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

using namespace std;

typedef long long ll;

ll N, K;
ll A[1000000];
map<int, int> mylist;
bool flag = true;

void rec2(ll n, ll num)
{
    if (num == K)
    {
        cout << n << endl;
        return;
    }
    if (flag)
    {
        std::map<int, int>::iterator iter = mylist.find(n);
        if (iter != end(mylist))
        {
            flag = false;
            ll tmp = num - mylist[n];
            ll tmp2 = (K - num) / tmp;
            num += tmp2 * tmp;
            if (num == K)
            {
                cout << n << endl;
                return;
            }
            rec2(A[n - 1], num + 1);
        }
        else
        {
            mylist.emplace(n, num);
            rec2(A[n - 1], num + 1);
        }
    }
    else
    {
        rec2(A[n - 1], num + 1);
    }
}

int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    if (N > K)
    {
        rec2(1, 0);
    }
    else
    {
        rec2(1, 0);
    }
}

Measured memory_bytes: 12688
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define INF 1e+10
#define MAX_V 10
 
 
// <最短距離, 頂点の番号>
using P = pair<int, int>;

 
 
signed main(){
    int n;
    cin >> n;
    vector<pair<int, int>> x(n),y(n);
    int x0,y0;
    for(int i=0;i<n;i++){
        cin >> x0 >>y0;
        x[i]=make_pair(x0,i);y[i]=make_pair(y0,i);
    }
    //P r[4][n];
    sort(x.begin(),x.end());sort(y.begin(),y.end());
  
    vector<vector<pair<int,int>>> r(4,vector<pair<int,int>>(n));
   
    for(int i =0;i<n-1;i++){
        r[0][x[i].second]=make_pair(x[i+1].first - x[i].first,x[i+1].second);
        r[1][x[i+1].second]=make_pair(x[i+1].first - x[i].first,x[i].second);
          r[2][y[i].second]=make_pair(y[i+1].first - y[i].first,y[i+1].second);
        r[3][y[i+1].second]=make_pair(y[i+1].first - y[i].first,y[i].second);
    }
    r[0][x[n-1].second]=make_pair(-1,-1);
     r[1][x[0].second]=make_pair(-1,-1);
      r[2][y[n-1].second]=make_pair(-1,-1);
       r[3][y[0].second]=make_pair(-1,-1);

    
    int d[n];
    fill(d,d+n,INF);
    int q[n]={};
    d[0]=0;
   int p=0;
   int ans=0;
   P o=make_pair(0,0);
   priority_queue<P, vector<P>, greater<P> > que;
   //cout << r[0][0].first<<endl;

   for(int i=0;i<n-1;i++){
       q[p]=1;
      
       for(int t=0;t<4;t++){
           if(r[t][p].first!=-1){
           if(r[t][p].first<d[r[t][p].second]){
               d[r[t][p].second]=r[t][p].first;
           }
           que.push(r[t][p]);
           }

       }
        //cout << que.top().first<< endl;
         //cout << que.top().second << endl;
        //cout <<q[ que.top().second ]<<' ';
       while(q[o.second]==1){
           o = que.top();
           que.pop();
            // cout <<q[ o.second ]<< endl;
       }
       ans+= o.first;
      // cout << ans << endl;
       p=o.second;
     //cout << p << endl;

       

   }
   cout << ans;
    return 0;
}

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

int main(){
 long long n;
  cin>>n;
  string s;
  cin>>s;
  while(n){
  n-=1;
    s+=n%26+'a';
    n/=26;
  }
  reverse(s.begin(),s.end());
  cout<<s;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
template<typename T>
inline T GET() {
	T val;
	cin >> val;
	return val;
}


 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}

struct uni_find
{
	vector<int> par;
	vector<int> cnt;
	int sz;
	uni_find(){} 
	uni_find(int n) {init(n);}
	void init(int n) {
		par.resize(n);
		cnt.resize(n);
		rep(i, n) par[i] = i, cnt[i] = 1;
		sz = n;
	}
	int root(int x) {return par[x] == x ? x : root(par[x]);}
	bool same(int x, int y) {return root(x) == root(y);}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (cnt[x] < cnt[y]) {
			par[x] = y;
			cnt[y] += cnt[x];
		}
		else {
			par[y] = x;
			cnt[x] += cnt[y];
		}
	}
	int size(int x) {
		return cnt[root(x)];
	}
};

uni_find a, b;
int N;

void init()
{
	int K, L;
	cin >> N >> K >> L;
	a.init(N);
	b.init(N);
	rep(i, K) {
		a.unite(GET<int>()-1, GET<int>()-1);
	}
	rep(i, L) {
		b.unite(GET<int>()-1, GET<int>()-1);
	}
}


void solve()
{
	map<pair<int,int> , int> m;
	rep(i, N) {
		m[MP(a.root(i), b.root(i))]++;
	}
	rep(i, N) {
		cout << m[MP(a.root(i), b.root(i))] << " \n"[i==N-1];
	}
}



Measured memory_bytes: 15104
import itertools

import numpy as np


def main():
    H, W, M = map(int, input().split())
    HW = [list(map(int, input().split())) for _ in range(M)]

    A = np.zeros(H, dtype=np.int64)
    B = np.zeros(W, dtype=np.int64)

    for h, w in HW:
        A[h - 1] += 1
        B[w - 1] += 1

    maxA = np.max(A)
    maxB = np.max(B)

    # 最大値を取るindex
    ind_A = np.arange(H)[A == maxA]
    ind_B = np.arange(W)[B == maxB]

    # 解の候補の数
    nn = len(ind_A) * len(ind_B)

    # Mより候補の数のほうが多いとok
    # 少ないときはM以下なので可算
    ans = maxA + maxB

    if nn <= M:
        for h, w in HW:
            if A[h - 1] == maxA and B[w - 1] == maxB:
                nn -= 1

    print(ans if nn else ans - 1)


main()


Measured memory_bytes: 93332
import java.util.*;
 
class Main {
    public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    while(true) {
        int l = s.nextInt();
        if(l==0) break;
        int a = 0;
        boolean f = true;
        for(int i=1 ; i<13 ; i++) {
        int m = s.nextInt();
        int n = s.nextInt();
        a += m;
        a -= n;
        if(a>=l && f) {
            System.out.println(i);
            f = false;
        }
        }
        if(f) System.out.println("NA");
    }
    }
}

Measured memory_bytes: 42724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			BigDecimal a = new BigDecimal(chr[0]);
			BigDecimal b = new BigDecimal(chr[1]);
			BigDecimal di = new BigDecimal("2");
			BigDecimal ans = (a.add(b)).divide(di);
			System.out.println(ans.setScale(0,RoundingMode.UP));

		}
	}
}

Measured memory_bytes: 25720