akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	int k;
	cin >> s >> k;

	set<string> se;

	rep(i, s.size())rep1(j, 5) {
		string t = s.substr(i, j);
		se.insert(t);
	}
	
	auto itr = se.begin();
	rep(i, k - 1)itr++;
	cout << *itr << endl;

}

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

using namespace std;


int main(){

    string s;

    int left, right, sz;

    cin >> s;

    sz = s.size();
    //cout << sz << " sz\n";
    for(int i = 0;i < sz;i++)
        if(s[i] == 'A') {
            left = i;
            break;
        }

    for(int i = sz-1;i >= 0; i--)
        if(s[i] == 'Z') {
            right = i;
            break;
        }
    ///cout << left << " left\n" << right << " right \n";
    cout << abs(left - right) + 1 << endl;

    return 0;
}


Measured memory_bytes: 644
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int n; cin >> n;
    ll a[n]; rep(i,n) cin >> a[i];
    ll sum = 0; rep(i,n) sum += a[i];
    ll l = 0; ll r = sum;
    ll ans = INF;
    rep(i,n) {
        l += a[i];
        r -= a[i];
        ans = min(ans, abs(l - r));
    }
    out(ans);



    

    
    return 0;
}






Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    for i in range(int(N/4)+1):
        for j in range(int(N/7)+1):
            if i*4+j*7 == N:
                print("Yes")
                exit()
    print("No")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

#define mod 1000000007

int n,m,cnt,flag1,flag2,s1,s2;
long long k;
char s[2001][2001];

long long quickpow(long long base,long long to)
{
    if(to<=0)return 1;
    if(to==1)return base;
    long long mid=quickpow(base,to>>1);
    if(to&1)return mid*mid%mod*base%mod;
    else return mid*mid%mod;
}

struct Matrix{
    long long a[3][3];
    Matrix(){memset(a,0,sizeof(a));}
    Matrix operator*(Matrix &m)
    {
        Matrix ans;
        for(int i=1;i<=2;++i)
            for(int j=1;j<=2;++j)
                for(int k=1;k<=2;++k)
                    ans.a[i][j]=(ans.a[i][j]+a[i][k]*m.a[k][j]%mod)%mod;
        return ans;
    }
};

int main()
{
    scanf("%d%d%lld",&n,&m,&k);
    for(int i=1; i<=n; ++i)
        scanf("%s",s[i]+1);
    for(int i=1; i<=n; ++i)
    {
        for(int j=1; j<=m; ++j)
            if(s[i][j]=='#')
            {
                ++cnt;
                s1+=s[i][j-1]=='#';
                s2+=s[i-1][j]=='#';
            }
        if(s[i][1]=='#' && s[i][m]=='#')++flag1;
    }
    for(int i=1;i<=m;++i)if(s[1][i]=='#' && s[n][i]=='#')++flag2;
    if(flag1 && flag2)
    {
        puts("1");
        return 0;
    }
    if(!flag1 && !flag2)
    {
        printf("%lld\n",quickpow(cnt,k-1));
        return 0;
    }
    if(!flag1)swap(flag1,flag2),swap(s1,s2);
    Matrix A;
    A.a[1][1]=cnt;
    A.a[2][1]=s1;
    A.a[2][2]=flag1;
    --k;
    Matrix ANS;
    ANS.a[1][1]=ANS.a[2][2]=1;
    while(k)
    {
        if(k&1)ANS=ANS*A;
        A=A*A;
        k>>=1;
    }
    printf("%lld\n",(ANS.a[1][1]-ANS.a[2][1]+mod)%mod);
}

Measured memory_bytes: 2176
n,k = map(int,input().split())
a_L = list(map(int,input().split()))

mod = 10**9+7
ans = 0
for i in range(n):
    x,y = 0,0
    for j in range(i):
        if a_L[i] > a_L[j]:
            x += 1
    for j in range(n):
        if a_L[i] > a_L[j]:
            y+=1
    ans += y*((1+k)*k//2) - x*k
    ans = ans%mod

print(ans)

Measured memory_bytes: 73944
use std::cmp::min;
fn main() {
    let s = rl();
    let s = s.trim_right().as_bytes();
    let n = s.len();
    let mut dp = vec![[0;2];n+1];
    dp[0][1]=2;
    for i in 0..n {
        let k=(s[i]-b'0')as i32;
        dp[i+1][0]=min(dp[i][0],dp[i][1])+k;
        dp[i+1][1]=min(dp[i][0]+1,dp[i][1]-1)+10-k;
    }
    println!("{}",min(dp[n][0],dp[n][1]));
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}

Measured memory_bytes: 12540
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for m in range(M)]
for i in range(10**N):
    if len(str(i))==N and all(str(i)[s-1]==str(c) for s,c in sc):
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 38256
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

a,b,c = readInts()
ans=0

if a==b and b==c and a%2==0:
	print(-1)
	exit()

while not a%2+b%2+c%2:
	ta = a
	tb = b
	tc = c
	a = (b+c)//2
	b = (ta+tc)//2
	c = (ta+tb)//2
	#print(a,b,c)
	ans+=1

print(ans)

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;


/*Please dont change namespace, Dcoder 
and class must not be public*/

//Compiler version 4.0, .NET Framework 4.5


namespace Dcoder
{
public class Program
{
public static void Main(string[] args)
{
Method(args);
}

public static void Method(string[] args)
{
int n=int.Parse(Console.ReadLine());
int allPat=0;
for(int i=1;i<=n;i+=2){
	int cnt=0;
	for(int j=1;j<=i;j++){
		if(i%j==0)cnt++;
	}
	if(cnt==8)allPat++;
}
Console.WriteLine(allPat);
}
}
}

Measured memory_bytes: 11092
# C - Forbidden List

x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

    
if x not in p:
    print(x)
else:
    for i in range(1, 100):
        a = x-i
        if a not in p:
            print(a)
            break
        b = x+i
        if b not in p:
            print(b)
            break

Measured memory_bytes: 9212
#include <iostream>
using namespace std;
typedef long long ll;

int main(void){
    string s;
    cin >> s;
    
    int ans = 0, g = 0, p = 0;
    for (int i = 0; i < s.size(); i++) {
        if (char(s[i]) == 'g') {
            if (p < g) {
                ans++;  p++;
            }
            else g++;
        }
        else {
            if (p < g) {
                p++;
            }
            else {
                ans--;  g++;
            }
        }
        //cout << g << " " << p << " " << ans << endl;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 512
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define LLINF (1<<30)
#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
    int n, m, Q, map[505][505] = {};
    cin >> n >> m >> Q;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        map[l][r]++;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            map[i][j] += map[i][j - 1];
        }
    }
    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        int ans = 0;
        for (int j = p; j <= q; j++) {
            ans += map[j][q] - map[j][p - 1];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;

// https://atcoder.jp/contests/abc161/tasks/abc161_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		sc.close();


		System.out.println(z+" "+x+" "+y);


	}
}


Measured memory_bytes: 23124
<?php
list($x, $n) = explode(" ", trim(fgets(STDIN)));
if($n==0){
	echo $x . "\n";
	exit();
}
$nums = explode(" ", trim(fgets(STDIN)));
rsort($nums);
$array = [];
for($i=0; $i<=$nums[0]+1; $i++){
    if(!in_array($i, $nums)){
    	$array[] =  $i;
    }
}
foreach ($array as $key => $value) {
	if($value>=$x){
		$check_key = $key;
		break;
	}
}
if(!isset($check_key)){
	$ans = end($array);
}elseif($key == 0){
	$ans =  $array[0];
}else{
	if(abs($x - $array[$check_key]) < abs($x - $array[$check_key-1])){
		$ans =  $array[$check_key];
	}else{
		$ans = $array[$check_key-1];
	}
}
echo $ans . "\n";

Measured memory_bytes: 16104
import java.util.Scanner;


public class Main {
    public static void main(String[] args){
        final Scanner sc = new Scanner(System.in);
        final String s = sc.next();
        if (s.startsWith("YAKI")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main() {
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = []
for i in range(N):
    Ai, Bi = map(int, input().split())
    AB.append([Ai, Bi])

# # Bubble Sort
# start = 0
# for i in range(N-1):
#     for index in range(start, N-1):
#         if AB[index][0] > AB[index+1][0]:
#             AB[index], AB[index+1] = AB[index+1], AB[index]
#         else:
#             pass
#         start += 1

AB = sorted(AB, key=lambda x: x[0])

final = 0
sum_bottles = 0
while(M > sum_bottles):
    final += 1
    sum_bottles += AB[final-1][1]

cost = 0
sum_bottles = 0
for i in range(final):
    if i == final - 1:
        cost += AB[i][0] * (M - sum_bottles)
    else:
        cost += AB[i][0] * AB[i][1]
        sum_bottles += AB[i][1]

print(cost)


Measured memory_bytes: 22020
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

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

    }

    private void solve() {
        int N = sc.nextInt();
        int[] bars = new int[N];

        for (int i = 0; i < N; i++) {
            bars[i] = sc.nextInt();

        }

        Arrays.sort(bars);
        HashMap<Integer, Integer> dic = new HashMap<Integer, Integer>();
        long a = 0;
        long b = 0;
        for (int i = N - 1; i >= 0; i--) {
            int num = bars[i];
            if (dic.containsKey(num)) {
                dic.put(num, dic.get(num) + 1);
                if (dic.get(num) >= 2) {
                    if (a == 0) {
                        a = num;
                    } else {
                        b = num;
                    }
                    dic.put(num, 0);
                }
                if (a != 0 && b != 0) {
                    break;
                }
            } else {
                dic.put(num, 1);
            }
        }
        System.out.println(a * b);
    }
}



Measured memory_bytes: 54140
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    vi x(n),y(n);
    rp(i,n){
        cin >> x.at(i);
        y.at(i)=x.at(i);
    }
    sort(all(y));
    int s=y[n/2-1],l=y[n/2];
    rp(i,n){
        if(x.at(i)<=s) print(l);
        else print(s);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3840
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
         int n=sc.nextInt();
        Integer h[]=new Integer[n];
        Map<Integer,Integer>map=new TreeMap<>();
        for(int i=0;i<n;i++){
            map.put(sc.nextInt(),i);
        }
        for(Integer value:map.values()){
            System.out.println(value+1);
        }
    }
}

Measured memory_bytes: 76608
import java.util.Scanner;

public class Main {
	public static boolean isIn(double r, double wx, double wy, double x, double y) {
		double len = Math.hypot(wx - x, wy - y);
		return len <= r ? true : false;
	}

	public static boolean isVisible(double r, double wx, double wy, double tx, double ty, double sx, double sy) {
		double a1, b1, a2, b2;
		double xx, yy;

		if (tx == sx) {
			a1 = Double.POSITIVE_INFINITY;
			b1 = Double.NaN;
		} else {
			a1 = (ty - sy) / (tx - sx);
			b1 = ty - a1 * tx;
		}

		if (a1 == Double.POSITIVE_INFINITY) {
			xx = tx;
			yy = wy;
		} else if (a1 == 0) {
			xx = wx;
			yy = ty;
		} else {
			a2 = -1.0 / a1;
			b2 = wy - a2 * wx;

			yy = (a2 * b1 - a1 * b2) / (a2 - a1);
			xx = (yy - b1) / a1;
		}

		if ((tx * sy - sx * ty) != 0) {
			if (0 < (tx * yy - xx * ty) * (sx * yy - xx * sy)) {
				return true;
			}
		} else {
			double ntx = tx - 1;
			double nty = ty;
			double nsx = sx - 1;
			double nsy = sy;
			double nxx = xx - 1;
			double nyy = yy;
			if (0 < (ntx * nyy - nxx * nty) * (nsx * nyy - nxx * nsy)) {
				return true;
			}
		}

		return !isIn(r, wx, wy, xx, yy);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		double wx[], wy[], r[];
		double tx, ty;
		double sx, sy;
		boolean flag;

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			wx = new double[n];
			wy = new double[n];
			r = new double[n];
			for (int i = 0; i < n; i++) {
				wx[i] = sc.nextInt();
				wy[i] = sc.nextInt();
				r[i] = sc.nextInt();
			}
			m = sc.nextInt();
			while (m-- != 0) {
				tx = sc.nextInt();
				ty = sc.nextInt();
				sx = sc.nextInt();
				sy = sc.nextInt();
				flag = true;
				for (int i = 0; i < n; i++) {
					if (isIn(r[i], wx[i], wy[i], tx, ty) != isIn(r[i], wx[i], wy[i], sx, sy)) {
						flag = false;
					} else if (!isIn(r[i], wx[i], wy[i], tx, ty)) {
						if (!isVisible(r[i], wx[i], wy[i], tx, ty, sx, sy)) {
							flag = false;
						}
					}
				}
				System.out.println(!flag ? "Safe" : "Danger");
			}
		}
	}
}

Measured memory_bytes: 26348
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
1 3 4
---+/
/+---test
3 2 3
---+/

void main(string[] args) {
  long P, Q, R;
  readf(" %d %d %d ", &P, &Q, &R);
  (P+Q+R - max(P, Q, R)).writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

int main(){
	char S[100];
	int  i,j,len,count=0;

	cin>>S;

	len=strlen(S);
	len--;

	for(i=0;i<=len/2;i++){
		if(S[i]!=S[len-i]) count++;
	}

	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int n;
    long long h, w, a, b, cnt = 0;
    std::cin >> n >> h >> w;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a >> b;
        if (h <= a && w <= b) { cnt++; }
    }
    std::cout << cnt << std::endl;
    return 0;
}

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


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

    int n = s.length();

    rep(i,n){
        if(i%2==0 && (s[i]=='R' || s[i]=='U' || s[i]=='D'))continue;
        else if(i%2==1 && (s[i]=='L' || s[i]=='U' || s[i]=='D'))continue;
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}


int main() {
    int i,j;
    long long int n;
    long long int k;

    scanf("%lld %lld", &n, &k);

    n = n - (n/k) * k;


    if(-(n-k) < n){
        printf("%lld", -(n-k));
    }else{
        printf("%lld", n);
    }
    return 0;
}

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



int main() {
   double pi = 3.14159265358979;
   double a, b, h, m;
   cin >> a >> b >> h >> m;
   double tansin = 2 * pi * (60 * h + m) / (12*60);
   double chousin = 2 * pi * m / 60;
   double kakudo = min(abs(chousin - tansin), abs(tansin - chousin));
   cout << fixed << setprecision(12) << sqrt(a*a + b*b - 2*a*b*cos(kakudo)) << endl;
   return 0;
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        long res = 0;
        for (var i = 1; n >= i; i++)
        {
            if (i % 3 == 0 || i % 5 == 0)
            {
                continue;
            }
            res += i;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 27528
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

template<class T> void swap(T &a, T &b ){
    T temp;
    temp = a;
    a = b;
    b = temp;   
}

int main(){
    int N;
    int *A;
    int *B;
    ULL ans;
    int i;

    cin >> N;
    A = new int[N];
    B = new int[N-1];
    for(i=0;i<N-1;i++){
        cin >> B[i];
    }
    A[0] = B[0];
    A[1] = B[0];
    for(i=1;i<N-1;i++){
        if( A[i] > B[i]){
            A[i] = B[i];
        }
        A[i+1] = B[i];
    }
    ans = 0;
    for(i=0;i<N;i++){
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll h = in(), w = in();
	cout << string(w + 2, '#') << endl;
	REP(i, h) cout << '#' << in<string>() << '#' << endl;
	cout << string(w + 2, '#') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	string s;
	cin >> s;
	int n = s.length();
	if (s[n - 1] == 's') {
		s += "es";
	}
	else s += "s";
	cout << s;

}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3636
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
ll a,b,c,d,n;
int main()
{
	cin>>a>>b>>c>>d>>n;
	n=n*4;
	b=min(b,a*2);
	c=min(c,b*2);
	d=min(d,c*2);
//	cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	ll ans=0;
	ans+=(n/8)*d;
	n%=8;
	ans+=(n/4)*c;
	n%=4;
	ans+=(n/2)*b;
	n%=2;
	ans+=n*a;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

const int MAXN = 1e5 + 5;
int n,m;
int a,b,c;
int d,e,f;
vector <int> A;
vector <int> B;
vector <int> C;
vector <int> dp[MAXN];

int main()
{
	scanf("%d",&n);
	for(int i = 0; i < n; i++)
	{
		scanf(" %d %d %d",&a,&b,&c);
		A.push_back(a);//第一天的a现在是a[0]
		B.push_back(b);
		C.push_back(c);
	}
	dp[0].push_back(A[0]);
	dp[0].push_back(B[0]);
	dp[0].push_back(C[0]);
	for(int i = 1; i < n; i++)
	{
		d = max(dp[i - 1][1],dp[i - 1][2]);
		e = max(dp[i - 1][0],dp[i - 1][2]);
		f = max(dp[i - 1][0],dp[i - 1][1]);
		dp[i].push_back(d + A[i]);
		dp[i].push_back(e + B[i]);
		dp[i].push_back(f + C[i]);
		//dp[i][1] = max(dp[i - 1][2],dp[i - 1][3]) + a[i];
		//dp[i][2] = max(dp[i - 1][1],dp[i - 1][3]) + b[i];
		//dp[i][3] = max(dp[i - 1][1],dp[i - 1][2]) + c[i];
	}
	m = max(max(dp[n - 1][1],dp[n - 1][2]),dp[n - 1][0]);
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 6892
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 1010;
const ll P = 1000000007;

int a[MAX_N];

int main() {
	int N;
	cin >> N;
	for (int i = 2; i <= N; i++) {
		int x = i;
		for (int d = 2; d * d <= x; d++) {
			while (x % d == 0) {
				a[d] += 1;
				x /= d;
			}
		}
		if (x != 1) a[x] += 1;
	}
	ll ans = 1;
	for (int p = 2; p <= N; p++) {
		if (a[p] != 0) ans = (ans * (a[p] + 1)) % P;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0, a;
    for(int i = 0; i < m; i++){
        cin >> a;
        sum += a;
    }

    if(n - sum >= 0) cout << n - sum << endl;
    else cout << -1 << endl;

}

Measured memory_bytes: 3624
if __name__ == '__main__':
    n = int(input())

    a = [int(i) for i in input().split()]
    for i in range(n):
        a[i] -= i;

    a.sort()

    m = n // 2

    ans = 0
    for i in a:
        ans += abs(i - a[m])

    print(ans)

Measured memory_bytes: 26020
MOD = 10**9 + 7

N = int(input())
As = [int(input().replace(' ', ''), 2) for _ in range(N)]

patWsList = [[] for _ in range(N+1)]
for patW in range(2**N):
    num1 = sum([(patW >> i) & 1 for i in range(N)])
    patWsList[num1].append(patW)

dp = [0] * (2**N)
dp[-1] = 1
for iM, (A, patWs) in enumerate(zip(As, reversed(patWsList))):
    for patW in patWs:
        A2 = A & patW
        dpNow = dp[patW]
        for iW in range(N):
            if A2 & (1 << iW):
                dp[patW ^ (1 << iW)] += dpNow
                dp[patW ^ (1 << iW)] %= MOD

print(dp[0])


Measured memory_bytes: 117852
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;

void main()
{
	auto tokens = split(chomp(readln()));
	auto n = to!int(tokens[0]);
	auto m = to!int(tokens[1]);
	auto x = to!int(tokens[2]);
	auto y = to!int(tokens[3]);

	int[] a, b;
	a ~= x;
	foreach (token; split(chomp(readln())))
	{
		a ~= to!int(token);
	}
	a.sort();
	b ~= y;
	foreach (token; split(chomp(readln())))
	{
		b ~= to!int(token);
	}
	b.sort();

	//bool isWar = !(a[$-1] < y && b[0] > x && a[$-1] < b[0]);
	bool isWar = !(a[$-1] < b[0]);
	
	writeln(isWar ? "War" : "No War");
	stdout.flush();
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAXNM 20
int main(){

int n,m,c;
int fvalue=0;
int ans=0;
int a[MAXNM][MAXNM]={};
int b[MAXNM]={};
cin>>n>>m>>c;
for(int i=0;i<m;i++){
cin>>b[i];
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>a[i][j];
}
}
for(int i=0;i<n;i++){
fvalue=0;
for(int j=0;j<m;j++){
fvalue+=a[i][j]*b[j];
}
if(fvalue+c>0)ans++;
}
cout<<ans<<endl;
}



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

int a[100005];
main()
{
    int n, x;
    cin >> n >> x;
    long long ans = 0;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        int dif = a[i] + a[i + 1] - x;
        if (dif > 0)
        {
            ans += dif;
            a[i + 1] -= dif;
        }
    }
    cout << ans << endl;
    return 0;
}

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

signed main(void)
{
	int n, cnt;
	cin >> n;
	int a[n];
	map<int, int> mp;
	rep(i, n)
	{
		cin >> a[i];
		a[i]--;
		mp[i] = a[i];
	}
	cnt = 0;
	rep(i, n)
	if (mp[mp[i]] == i)
		cnt++;
	cout << cnt / 2 << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll h, w, n;
  cin >> h >> w >> n;
  vector<ll> x(n), y(n);
  REP(i, n) cin >> y[i] >> x[i], y[i]--, x[i]--;

  vector<set<ll>> v(h);
  REP(i, n) {
    v[y[i]].insert(x[i]);
  }

  ll tx = 0;
  FOR(i, 1, h) {
    // v[i]にtx以下の要素が含まれているか
    if(v[i].upper_bound(tx) != v[i].begin()) {
      cout << i << endl;
      return 0;
    }

    if(v[i].find(tx+1) != v[i].end()) {

    } else {
      tx++;
    }
  }

  cout << h << endl;

  return 0;
}

Measured memory_bytes: 22144
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
#define ll long long int

using namespace std;

ll my_pow(ll a,ll b){
  ll res;
  if(b==1) return a;
  if(b % 2 == 0){
    res = my_pow(a,b/2);
    return res * res;
  } else {
    res = my_pow(a,b/2);
    return res * res * a;
  }
}

signed main(){
  
  int N; cin>>N;
  vector <int> b;b.resize(N+1,0);
  vector <int> ans;ans.resize(N,0);
  for(int i=0;i<N;i++) cin>>b[i+1];

  bool flag = true;
  int now = N-1;

  while(b.size() > 1){

    int last = -1;

    for(int i=0;i<b.size();i++){
      if(b[i] == i) last = i;
    }

    if(last==0){
      flag = false;
      //cout<<now<<endl;
      break;
    }

    ans[now] = last; now--;
    b.erase(b.begin() + last);

  }
  if(flag == false) {cout<<-1<<endl;return 0;}

  for(int &re : ans){
    cout<<re<<endl;
    re = -1;
  }

  

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

ll a,b,n;

main(){
  scanf("%lld%lld%lld",&a,&b,&n);
  printf("%lld\n",a*min(b-1,n)/b);
  return 0;
}

Measured memory_bytes: 1732
/*input
3 2
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}

fn main() {
    let v: Vec<u32> = read_line()
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect(""))
        .collect();
    println!(
        "{} {} {:.5}",
        v[0] / v[1],
        v[0] % v[1],
        v[0] as f64 / v[1] as f64
    );
}



Measured memory_bytes: 5048
#include <iostream>
using namespace std;
int main(void){
    long long int A, B;
    cin >> A >> B;
    long long int ab_m = min(A, B);
    A -= ab_m;
    B -= ab_m;
    if (max(A, B) % 2 == 0)
        cout << max(A, B) / 2 + ab_m << endl;
    else
        cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC058_B
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string o = Console.ReadLine();
			string e = Console.ReadLine();

			string resultStr = "";
			int count = 0;
			for (int i = 0; i < e.Length;)
			{
				if (count % 2 == 0)
				{
					resultStr += o.Substring(i, 1);
				}
				else
				{
					resultStr += e.Substring(i, 1);
					i++;
				}

				count++;
			}

			if (o.Length - e.Length == 1) 
				resultStr += o.Substring(o.Length - 1, 1);
			
			Console.WriteLine(resultStr);
		}
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<int> ans;

void solve(int N, int M) {
    int r; cin >> r;
    vector<vector<int>> imos(M+1, vector<int>(1261));
    for (int i = 0; i < r; i++) {
        int t, n, m, s; cin >> t >> n >> m >> s;
        if (s) imos[m][t]++;
        else imos[m][t]--; 
    }
    for (int i = 1; i <= M; i++) {
        for (int j = 1; j < 1261; j++) {
            imos[i][j] += imos[i][j-1];
        }
    }
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int s, e, m; cin >> s >> e >> m;
        int cnt = 0;
        for (int j = s; j < e; j++) {
            if (imos[m][j]) cnt++;
        }
        ans.push_back(cnt);
    }
}

int main(void) {
    int N, M;
    while (1) {
        cin >> N >> M;
        if (!N && !M) break;
        solve(N, M);
    }
    for (auto i : ans) {
        cout << i << endl;
    }
}   


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

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

using namespace std;

int main() {
    int N, D;
    cin >> N >> D;
    int count = 0;
    while(N > 0) {
        N -= 2 * D + 1;
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    static long mod = 1000000007;
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int N= sc.nextInt();
        int[][] ball = new int[N][2];
        for(int i=0;i<N;i++){
            ball[i][0] = sc.nextInt();
            ball[i][1] = sc.nextInt();
        }
        Arrays.sort(ball, (a,b)->a[0]-b[0]);
        int result = N;
        int p = 0;
        int q = 0;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                p = ball[j][0] - ball[i][0];
                q = ball[j][1] - ball[i][1];
                int cost = cost_calc(ball, p, q);
                if(cost < result)result=cost;
            }
        }
        System.out.println(result);
    }

    public static int cost_calc(final int[][] a, int p, int q) {
        int cost = 0;
        int N = a.length;
        final int[][] ball = a;
        int[] check = new int[N];
        for(int i=0;i<N;i++){
            check[i] = 1;
        }
        for(int i=0;i<N;i++){
            int s = ball[i][0];
            int t = ball[i][1];
            for(int j=0;j<N;j++){
                int x = ball[j][0];
                int y = ball[j][1];
                if((x-p) == s && (y-q) == t){
                    check[j] = 0;
                }
            }
        }
        for(int i=0;i<N;i++)cost+=check[i];
        return cost;
    }
}

Measured memory_bytes: 29140
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int preT = 0;
        int preX = 0;
        int preY = 0;

        for (int i=0; i<n; i++) {
            int postT = sc.nextInt();
            int postX = sc.nextInt();
            int postY = sc.nextInt();

            int dt = postT-preT;
            int dist = Math.abs(postX-preX) + Math.abs(postY-preY);
            if ((dt<dist) || ((dist-dt)%2 !=0)) {
                System.out.println("No");
                return;
            }
            preT=postT;
            preX=postX;
            preY=postY;
        }

        System.out.println("Yes");
        sc.close();
    }
}

Measured memory_bytes: 58800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    vector<ll> dp(202020);
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        cin >> z[i];
        if (i != 0) {
            if (z[i] == z[i - 1])continue;
        }
        ll c = dp[z[i]];

        dp[z[i]] += ans;
        dp[z[i]] %= 1000000007;
        ans += c;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}


int main(void){
 
  ll n, m;
  cin>>n>>m;

  vector<ll> h(n);
  REP(i, n){
    ll x;
    cin>>x;
    h[i] = x;
  }

  vector<ll> v(n, 0);

  REP(i, m){
    ll x, y;
    cin>>x>>y;
    if(h[x-1]==h[y-1]) {
      v[x-1]++;
      v[y-1]++;
    }else if(h[x-1] > h[y-1]){
      v[y-1]++;
    }else{
      v[x-1]++;
    }
  }

ll sum = 0;
  REP(i, n){
    if(v[i]==0) sum++;
  }
  
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 4840
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  int h, a;
  cin >> h >> a;
  cout << (h + (a - 1)) / a << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

Console.ReadLine()
|> ParseIntN
|> Array.sort
|> fun vs -> if vs.[2] = (vs.[1] + vs.[0]) then "Yes" else "No"
|> Console.WriteLine


Measured memory_bytes: 14048
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
#define INF 1e9;
#define LINF 1e18;
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;}
const string YES = "Yes";
const string NO = "No";
// clang-format on

void solve(long long K, long long X) {
  ANS(((K * 500 >= X) ? YES : NO));
}

// clang-format off
int main() {
  long long K;
  scanf("%lld",&K);
  long long X;
  scanf("%lld",&X);
  solve(K, X);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n , m;
const int maxn = 1e5 + 5;
ll a[maxn];
inline ll gcd(ll a , ll b) {
	return b == 0 ? a : gcd(b , a % b);
}
inline ll lcm(ll a , ll b) {
	return a / gcd(a , b) * b;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m;
	ll minx;
	bool valid = 1;
	for(register int i = 1; i <= n; ++i) {
		cin >> a[i]; a[i] >>= 1; 
		if(i == 1) minx = a[1];
		minx = lcm(minx , a[i]);
		if(minx > m) valid = 0;
	}
	for(register int i = 1; i <= n; ++i)
		if(!(minx / a[i] & 1)) {
			valid = 0;
			break;
		}
	if(!valid)
		cout << 0 << endl;
	else {
		ll ans = m / minx;
		if(ans & 1) ans++;
		ans /= 2;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
# 141a https://atcoder.jp/contests/abc141/tasks/abc141_a

# 入力
S = input()
# 処理
if S == 'Sunny':
    answer = 'Cloudy'
elif S == 'Cloudy':
    answer = 'Rainy'
elif S == 'Rainy':
    answer = 'Sunny'
else:
    answer = '入力値エラー'
# 出力
print(answer)

Measured memory_bytes: 8888