akhauriyash/Code-Regression huggingface dataset:
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine();
        var values = input.Split(' ');
        int a = int.Parse(values[0]);
        int b = int.Parse(values[1]);
        int c = int.Parse(values[2]);
        int answer = 0;
        for (int i = a; i <= b; i++)
        {
            if (c % i == 0) answer++;
        }
        Console.WriteLine("{0}", answer);
    }
}

Measured memory_bytes: 5628
H, W, D = map(int,input().split())

A = [[]]*(H*W+1)
for i in range(H):
  a = list(map(int,input().split()))
  for j in range(W):
    A[a[j]] = [i, j]

Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]

def magic(LR):
  magic = 0
  x = LR[0]
  y = LR[1]
  magicx = abs(A[x][0] - A[y][0]) 
  magicy = abs(A[x][1] - A[y][1]) 
  return magicx + magicy

magiclist = [0]*(H*W+1)
for i in range(D+1,H*W+1):
  magiclist[i] = magiclist[i-D] + magic([i-D,i])

for i in range(Q):
  x = LR[i][0]
  y = LR[i][1]
  if (x == y):
    print(0)
  else:
    print(magiclist[y]- magiclist[x])


Measured memory_bytes: 41468
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //ifstream cin("input.in");
   // ofstream cout("output2.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long X,A,B;
    cin>>X>>A>>B;
    A=X-A;
    A+=B;
    if(A<=X)
        cout<<"delicious";
    else if(A<=2*X)
        cout<<"safe";
    else
        cout<<"dangerous";
}

Measured memory_bytes: 256
from collections import deque
def solve():
    H, W = map(int, input().split())
    field = [list(input()) for i in range(H)]

    sy = 0
    sx = 0
    blk_cnt = 0

    for i in range(H):
        for j in range(W):
            if field[i][j] == '#':
                blk_cnt += 1

    
    shortest_step = bfs(H,W,field,sy,sx,H-1,W-1)
    if shortest_step == -1:
        print(-1)
    else: 
        print(H*W - blk_cnt - shortest_step)

def bfs(H,W,field,sy,sx,ty,tx):
    n_step = [[-1]*W for i in range(H)]
    n_step[sy][sx] = 1
    deq = deque()
    deq.appendleft((sy,sx))
    
    d_x_y = ((1,0),(-1,0),(0,1),(0,-1))
    while len(deq) > 0:
        cy, cx = deq.pop()
        if cy == ty and cx == tx:
            return n_step[cy][cx]

        for dy, dx in d_x_y:
            ny = cy + dy
            nx = cx + dx
            if 0 <= ny < H and 0 <= nx < W and field[ny][nx] != '#' and n_step[ny][nx] == -1:
                n_step[ny][nx] = n_step[cy][cx] + 1
                deq.appendleft((ny,nx)) 
    
    return -1

if __name__ == '__main__':
    solve()

Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod  1000000007
#define pb push_back
#define mk make_pair
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ld long double
#define fi first
#define se second
#define setbits __builtin_popcount
#define inf 1e18
bool prime[1000000];
void seive()
{
    memset(prime,true,sizeof(prime));
    for(ll i=2;i*i<=1000000;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<1000000;j+=i)
            {
                prime[j]=false;
            }
        }
    }
}
int main()
{
    fastIO;
    ll x;
    cin>>x;
    seive();
    ll ans;
    for(ll i=2;i<1000000;i++)
    {
        if(i>=x && prime[i]==true)
        {
            ans=i;
            break;
        }
    }
    cout<<ans<<'\n';
}

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

class Program
{
	static void Main(string[] args)
	{
		string[] input_1 = Console.ReadLine().Split(' ');
		int num_K = int.Parse(input_1[1]);

		string[] input_2 = Console.ReadLine().Split(' ');

		List<int> priceList = new List<int>();

		foreach(string s in input_2)
        {
			priceList.Add( int.Parse(s));
		}

		priceList.Sort();

		int sum = 0;
		int addCount = 0;
		foreach(int i in priceList) {
			sum += i;
			addCount++;
			if (addCount == num_K) break;
		}

		Console.WriteLine(sum);
	}
}

Measured memory_bytes: 28032
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))
#define PI 3.14159265358979

int main()
{
	int n;
	int i,j,k;
	char str[11];
	int count = 0;
	scanf("%s",str);
	scanf("%d",&n);
	for(i = 0;i < n;i++)
	{
		char data[11];
		scanf("%s",data);
		for(j = 0;j < 10;j++)
		{
			for (k = 0; k < 10; k += 1)
			{
				if(str[k] == '\0')
				{
					count++;
					goto hell;
				}
				else if(str[k] != data[(k+j)%10])
				{
					break;
				}
			}
			if(k == 10)
			{
				count++;
				break;
			}
		}
		hell:;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 0
import collections

#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s

#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a

def main():
    s = inputStrOnebyOne()
    ret = []
    for i in range(len(s)):
        if s[i] == "0":
            ret.append(s[i])
        elif s[i] == "1":
            ret.append(s[i])
        else:
            if 1<=len(ret):
                ret.pop()
    print(''.join(ret))

if __name__=='__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    x -= a;
    while (x >= b)
    {
        x -= b;
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int cnt, h;
    string s, ts;
    while (true)
    {
        cin >> s;
        if (s == "-")
            break;

        cin >> cnt;
        for (int i = 0; i < cnt; i++)
        {
            cin >> h;
            ts = s.substr(0, h);
            s = s.substr(h) + ts;
        }

        cout << s << endl;
    }
}


Measured memory_bytes: 3136
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>

using namespace std;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int sum = 0;

	for (int i = 0; i < K; ++i) {
		if (A != 0) {
			sum++;
			A--;
		}
		else if (B != 0) {
			//何もしない
			B--;
		}
		else if (C != 0) {
			sum--;
			C--;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){ll A, P;
    cin>>A>>P;
    cout<<(3*A+P)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp

#define MAX 500000
int N;
int A[MAX];
int L[MAX/2+2];
int R[MAX/2+2];
int cnt;

static void merge(int l, int m, int r) {
    int N1 = m-l;
    int N2 = r-m;
    REP(i, N1) L[i] = A[l+i];
    REP(i, N2) R[i] = A[m+i];
    L[N1] = R[N2] = INF;

    int i = 0, j = 0;
    for (int k = l; k < r; k++) {
        cnt++;
        if (L[i] < R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

static void mergeSort(int l, int r) {
    if (l + 1 < r) {
        int mid = (l+r)/2;
        mergeSort(l, mid);
        mergeSort(mid, r);
        merge(l, mid, r);
    }
}

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    mergeSort(0, N);
    arrdump(N, A);
    cout << cnt << "\n";
    return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 13;
const lli INF = 1ll << 62;

lli n,m;
lli ans;

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

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	var lis []int
	for i := 100; i >= 1; i-- {
		if a%i == 0 && b%i == 0 {
			lis = append(lis, i)
		}
	}
	//fmt.Println(lis)
	fmt.Println(lis[k-1])
}


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

int fac(int n){
  if(n==0)return 1;
  else return n * fac(n-1);
}


int main(){
  int N;
  cin >> N;
  string ss;
  vector<string> S(N);
  //rep(i,N)cin >> S[i];

  char march[5] = {'M','A','R','C','H'};
  int march_num[10]={0};
  // M,A,R,C,H = 1,2,3,4,5
  rep(i,N){
    cin >> ss;
    rep(j,5){
      if(ss[0] == march[j])march_num[j]++;
    }
  }

  long long int ans = 0;
  long long int plus = 0;
  for(int a=0;a<3;a++){
    for(int b=a+1;b<4;b++){
      for(int c=b+1;c<5;c++){
        plus = ll(march_num[a]) * ll(march_num[b]) * ll(march_num[c]);
        //cout << plus << endl;
        ans += plus;
      }
    }
  }

  cout << ans << endl;
}

/*

  // 多分含まれる文字種でnC3して文字の選択肢倍すればいいはず…
  long long int ans = 0;
  if(count>=3) ans = fac(count) / (fac(count-3)*fac(3));
  rep(i,5){
    if(march_num[i]!=0)ans *= march_num[i];
  }

  → だめでした(複数文字あるやつを使う時だけ倍にならないとだめ)

  解説読んだ
  → 五文字から3文字作るのは全探索可能←たしかに～～～～～


  なんかだめだった
  → 計算途中もintだとだめなのか～～～～
  普通にlonglongintでmarch格納も宣言しておくべきだった
*/

Measured memory_bytes: 1024
temp=list(map(int, input().split()))
N=temp[0]
M=temp[1]
f=[0]*N
cnt=0
ac=0
wa=[0]*N
for i in range(M):
  temp=input().split()
  if f[int(temp[0])-1]==0:
    if temp[1]=='WA':
      wa[int(temp[0])-1]+=1
    else:
      f[int(temp[0])-1]=1
      ac+=1
cnt=sum([wa[i] if f[i]==1 else 0 for i in range(N)])
print(str(ac)+' '+str(cnt))
  


Measured memory_bytes: 5528
import math

n = int(input())
if n == 1:
    print(1)
    exit(0)
dp = [0] * (n+1)
mod = 10**9+7

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

prime = sieve_of_erastosthenes(1000)
prime = [i for i, t in enumerate(prime) if t]

for i in range(2, n+1):
    v = i
    while v < n+1:
        dp[i] += 1
        v += i

dp2 = [0] * (n+1)
for p in prime:
    v = p
    k = 1
    while v < n+1:
        dp2[p] += dp[v]
        v *= p
        k += 1

ans = 1
for i in range(n+1):
    ans = (ans * (dp2[i]+1)) % mod
print(ans)
        

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

const int MAXV=(int) 1e5+1;

struct edge{
    int to;
};

vector <edge> G[MAXV];
int visited[MAXV];

int find_chain( int i, int count ){
    if( visited[i]<0 ){
        visited[i]=count;
        //cout << "i visited[i] " << i << " " << visited[i] << endl;
    }else{
        return 0;
    }
    for( auto& e:G[i] ){
        if( visited[e.to]<0 ){
            find_chain( e.to, count );
        }
    }
    return 1;
}

int main(){
    int N,M;
    cin >> N >> M;
    int X[M],Y[M],Z[M];
    int ans,count;
    for(int i=0; i<M; i++){
        cin >> X[i] >> Y[i] >> Z[i];
    }

    for(int i=0; i<M; i++){
        edge e = { Y[i] };
        G[X[i]].push_back(e);
        e = { X[i] };
        G[Y[i]].push_back(e);
    }

    for(int i=0; i<MAXV; i++) visited[i]=-1;

    ans=0;
    count=0;
    for(int i=1; i<=N; i++){
        if( G[i].size()==0 ){
            ans++;
            continue;
        }else{
            int a=find_chain(i,count);
            //cout << "a= " << a << endl;
            //cout << "i count " << i << " " << count << endl;
            count=count+a;
        }
    }

    cout << ans+count << endl;

    return 0;
}

Measured memory_bytes: 10368
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
#define mod 998244353

ll inv[10000099]; // ith index will store (1/i)%mod
ll finv[10000099]; // ith index will store (1/i!)%mod
ll fact[10000099]; // ith index will store (i!)%mod
ll pow2[10000099];
int N;
ll Npow3 = 1;

void populate(int n) {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    pow2[0] = 1;
    pow2[1] = 2;
    Npow3 = 3;

    for(int i = 2;i <= n;i++) {
        fact[i] = (i*fact[i-1])%mod;
        inv[i] = mod-((inv[mod%i]*(mod/i))%mod);
        finv[i] = (finv[i-1]*inv[i])%mod;
        pow2[i] = (2*pow2[i-1])%mod;
        Npow3 = (3*Npow3)%mod;
    }
}

ll prod(ll x, ll y) {
  return (x*y)%mod;
}

ll add(ll x, ll y) {
  return (x+y)%mod;
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> N;
  populate(N);

  N /= 2;

  ll ans = 0;
  for(int i = 1;i <= N;i++) {
      ans = add(ans, prod(prod(fact[2*N], finv[N+i]), prod(finv[N-i], pow2[N-i])));
  }

  ans = (Npow3-2*ans)%mod;
  ans = add(ans, mod);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 312704
/* ファイル名：ITP1_2_B.c	*/
/* 内容：３つの整数a, b, cを読み込み、それらが a < b < cの条件を満たすならば"Yes"を、	*/
/*		 満たさないならば"No"を出力する													*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:３つの整数a, b, cを読み込み、それらが a < b < cの条件を満たすならば"Yes"を、	*/
/*		 	満たさないならば"No"を出力する													*/
int main( void )
{
	/* 内部変数定義	*/
	int a;	/* 読み込む整数a*/
	int b;	/* 読み込む整数b*/
	int c;	/* 読み込む整数c*/
	
	scanf("%d %d %d",&a,&b,&c);	/* 整数を読み込む	*/
	
	/* a < b < cが成立するかどうか*/
	if(( a < b )
	&& ( b < c )){
		printf("Yes\n");		/* 成立		*/
	}
	else{
		printf("No\n");			/* 不成立	*/
	}
	
	return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct UnionFind
{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    for(int i=0;i<n;i++) par[i] = i;
  }

  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]); 
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};
int main(){
  int n,k,l;
  cin >> n >> k >> l;
  UnionFind road(n),train(n);
  for(int i=0;i<k;i++){
    int p,q;
    cin >> p >> q;
    road.unite(--p,--q);
  }
  for(int i=0;i<l;i++){
    int p,q;
    cin >> p >> q;
    train.unite(--p,--q);
  }
  map<pair<int,int>,int> mp;
  for(int i=0;i<n;i++) mp[{train.find(i),road.find(i)}]++;
  for(int i=0;i<n;i++) cout << mp[{train.find(i),road.find(i)}] << " \n"[i==n-1];
}

Measured memory_bytes: 17592
let _ =
  let rec p () =
    match read_line() with
     "0 0" -> ()
    | x -> Scanf.sscanf x "%d %d" (fun a b ->
      match a with
      | a when a < b -> Printf.printf "%d %d\n" a b
      | _ -> Printf.printf "%d %d\n" b a
    ); p ()
  in p ()



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

int main(){
  int X, Y;
  cin >> X;
  cin >> Y;
  if(2*X <= Y && Y <= 4*X && Y % 2 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  cin>>a;
  for(auto& ai:a)ai--;

  vector<ll> visited(n,-1);
  ll kk = k;
  ll now = 0;
  ll ord = 0;
  while(kk--){
    if(visited[now]!=-1){
      break;
    }
    visited[now] = ord++;
    dump(now,a[now]);
    now = a[now];
  }
  k -= visited[now];
  k %= (ord-visited[now]);
  dump(ord-visited[now],visited[now]);
  while(k--){
    now = a[now];
  }
  cout<<(now+1)<<endl;

}

Measured memory_bytes: 6424
#[allow(unused_macros)]
macro_rules! debug {
	($($a:expr),*) => {
		println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
	}
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(dead_code)]
const MOD: usize = 1e9 as usize + 7;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let sx: i64 = sc.read();
    let sy: i64 = sc.read();
    let tx: i64 = sc.read();
    let ty: i64 = sc.read();

    let mut ans = "".to_string();
    for _ in sx..tx {
        ans += "R";
    }
    for _ in sy..ty {
        ans += "U";
    }
    for _ in sx..tx {
        ans += "L";
    }
    for _ in sy..ty {
        ans += "D";
    }

    ans += "D";
    for _ in sx..tx + 1 {
        ans += "R";
    }
    for _ in sy - 1..ty {
        ans += "U";
    }
    ans += "LU";
    for _ in sx..tx + 1 {
        ans += "L";
    }
    for _ in sy - 1..ty {
        ans += "D";
    }
    ans += "R";
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}

#[allow(dead_code)]
fn yn(flag: bool) {
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
# mod = 998244353
# mod = 10 ** 9 + 9
mod = 10 ** 9 + 7
PI = Math::PI
dx = [ 1,  0, -1,  0,  1,  1, -1, -1]
dy = [ 0,  1,  0, -1,  1, -1,  1, -1]
eight = [0, 1, 1, 0, -1, -1, 1, -1, 0]
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end
def gi;             gets.to_s.to_i                             end
def gf;             gets.to_s.to_f                             end
def gs;             gets.to_s.chomp                            end
def gmi(n=nil); n.nil? ? gets.to_s.split.map{|t|t.to_i} : n.times.map{ gets.to_s.to_i } end
def gmf(n=nil); n.nil? ? gets.to_s.split.map{|t|t.to_f} : n.times.map{ gets.to_s.to_f } end
def gms(n=nil); n.nil? ? gets.to_s.split : n.times.map{ gets.to_s.chomp } end
def ga2i(h);        h.times.map{ gets.to_s.split.map{|t|t.to_i} }      end
def gm(h);        Array.new(h){ gets.to_s.split.map{|t|t.to_i} }      end
def yn(f); puts f ? "Yes" : "No" end
#def YN(f); puts f ? "YES" : "NO" end
def yes(f=nil); f.nil? ? (puts "Yes"; exit) : (puts f ? "Yes" : "No") end
def no(f=nil); f.nil? ? (puts "No"; exit) : (puts f ? "Yes" : "No") end
def yay(f=nil); f.nil? ? (puts "Yay!"; exit) : (puts f ? "Yay!" : ":(") end

#n = gets.to_s.to_i
# s = gets.to_s.chomp
# t = gets.to_s.chomp
n, k = gets.to_s.split.map{|e|e.to_i}
a = [0] + gets.to_s.split.map{|e|e.to_i}

t = Array.new(n+1){ 0 } 
used = Array.new(n+1){ false }

s = 1
t[1] = 1
i = 1
used[1] = true
loop do
  
  s = a[s]
  
  if i == k
    puts s
    exit
  end
  
  
  used[s] ? break : used[s] = true
  
  i +=1
  t[s] = i
end
# p s
# p t
# p i

dist = (t[s] - 1)
cycle = i - dist

if dist >= k
  puts s
else
  idx = (k - dist) % cycle + dist + 1
  puts t.index(idx)
end

# p (727202214173249351 - 2) % 3



Measured memory_bytes: 32104
<?php

fscanf(STDIN, "%d %d %d %d", $x, $y, $z, $k);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
$B = array_map('intval', explode(' ', trim(fgets(STDIN))));
$C = array_map('intval', explode(' ', trim(fgets(STDIN))));
rsort($A);
rsort($B);
rsort($C);

$ABC = [];
for ($a = 0; $a < $x; ++$a) {
    for ($b = 0; $b < $y; ++$b) {
        if (($a + 1) * ($b + 1) > $k) break;
        for ($c = 0; $c < $z; ++$c) {
            if (($a + 1) * ($b + 1) * ($c + 1) > $k) break;
            $ABC[] = $A[$a] + $B[$b] + $C[$c];
        }
    }
}

rsort($ABC);
for ($i = 0; $i < $k; ++$i) {
    echo $ABC[$i], PHP_EOL;
}


Measured memory_bytes: 10744
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M, Q;
int A[202020], B[202020], C[202020];
int uf[202020];

int root(int p)
{
	return uf[p] < 0 ? p : (uf[p] = root(uf[p]));
}
bool join(int p, int q)
{
	p = root(p);
	q = root(q);
	if (p == q) return false;
	uf[p] += uf[q];
	uf[q] = p;
	return true;
}
int main()
{
	scanf("%d%d%d", &N, &M, &Q);
	for (int i = 0; i < N; ++i) uf[i] = -1;
	int rem = M;
	for (int i = 0; i < Q; ++i) {
		scanf("%d%d%d", A + i, B + i, C + i);
		if (C[i] == 0) {
			if (join(A[i], B[i])) --rem;
		}
	}
	for (int i = 0; i < Q; ++i) {
		if (C[i] == 1 && root(A[i]) == root(B[i])) {
			puts("No");
			return 0;
		}
	}
	int n_root = 0;
	set<int> con;
	for (int i = 0; i < N; ++i) {
		if (root(i) == i) ++n_root;
	}
	for (int i = 0; i < Q; ++i) {
		if (C[i] == 0) continue;
		int u = root(A[i]), v = root(B[i]);
		if (u > v) swap(u, v);
		con.insert(u);
		con.insert(v);
	}
	if (con.size() == 2 && n_root == 2) {
		puts("No");
		return 0;
	}
	//printf("%d %d %d\n", con.size(), n_root, rem);
	i64 req;
	if (con.size() == 2) req = 3;
	else req = con.size();
	req = max(req, (i64)n_root - 1);
	if (con.size() != 0) req = max(req, (i64)n_root);
	i64 rmax = (i64)n_root * (n_root - 1) / 2;

	if (req <= rem && rem <= rmax) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>

int main(){
    int N,cnt=0;
    int i,a[101];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<N;i++){
        if(i%2==0 && a[i]%2!=0) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 1736
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 998244353;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
int main(){
  ll n; cin >> n; ll cnt = 0; ll pow = 1;
  
  while(n != 0){
    n /= 2; 
    cnt += pow;
    pow *= 2;
  }
  
  cout << cnt << endl;
  
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;

int N;

double dp[310][310][310];
double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if (i > 0) res += rec(i - 1, j, k) * i;
    if (j > 0) res += rec(i + 1, j - 1, k) * j;
    if (k > 0) res += rec(i, j + 1, k - 1) * k;
    res += N;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;
}

int main() {
    cin >> N;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a == 1) ++one;
        else if (a == 2) ++two;
        else ++three;
    }

    memset(dp, -1, sizeof(dp));

    cout << rec(one, two, three) << endl;
}

Measured memory_bytes: 233088
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

long long int func(long long n, long long x){
	if(n == -1) return -1;
	return (n/x);

}


int main(void){


	long long a, b, x; cin >> a >> b >> x;

	long long int ans = func(b,x) - func(a-1,x);
	cout << ans << endl;



	return 0;

}


Measured memory_bytes: 384
X, Y = map(int, input().split())
get = 0

if X == 1:
    get += 300000
if X == 2:
    get += 200000
if X == 3:
    get += 100000
if Y == 1:
    get += 300000
if Y == 2:
    get += 200000
if Y == 3:
    get += 100000
if X == 1 and Y == 1:
    get += 400000

print(get)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> mv(n);
    for(int i=0;i<n;i++)cin>>mv[i];
    int finans=1e9;
    for(int ans=1;ans<=100;ans++){
        int tmp=0;
        for(int i=0;i<n;i++){
            tmp+=(mv[i]-ans)*(mv[i]-ans);
        }
        finans=min(finans,tmp);
    }
    cout<<finans<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  double a,t,closest=100000000.0;
  int i,n,palace=-1;
  cin>>n;
  cin>>t>>a;
  double h[n];
  for(i=0;i<n;i++)
  {
  	cin>>h[i];
  	double temp= t- (h[i]*0.006);
  	if(fabs(a-temp)<closest)
  	{
  		closest=fabs(a-temp);
  		palace=i;
  	}
  }
  cout<<palace+1;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"container/list"
	"fmt"
	"strings"
)

type input struct {
	q  int
	f1 int
	f2 string
}

func main() {
	var s string
	var qn int
	fmt.Scan(&s, &qn)

	var q, f1 int
	var f2 string
	var reverseCnt int
	// top := make([]byte, 0, qn)
	// bottom := make([]byte, 0, qn)
	dq := list.New()
	dq.PushFront(s)

	for i := 0; i < qn; i++ {
		fmt.Scan(&q)
		if q == 1 {
			reverseCnt++
		} else {
			fmt.Scan(&f1, &f2)
			if (reverseCnt%2 == 0 && f1 == 1) || (reverseCnt%2 == 1 && f1 == 2) {
				dq.PushFront(f2)
			} else {
				dq.PushBack(f2)
			}
		}
	}

	ss := make([]string, dq.Len())
	i := 0
	for e := dq.Front(); e != nil; e = e.Next() {
		ss[i] = e.Value.(string)
		i++
	}
	ans := strings.Join(ss, "")
	if reverseCnt%2 == 1 {
		ans = reverse(ans)
	}
	fmt.Println(ans)
}

func reverse(str string) string {
	rs := []rune(str)
	for i, j := 0, len(str)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}


Measured memory_bytes: 24704
N = int(input())
S = list(input())

r = 0
g = 0
b = 0
for s in S:
    if s == 'R':
        r += 1
    elif s == 'G':
        g += 1
    else:
        b += 1
ans = r * b * g

d = 1
while True:
    if 2 * d >= N:
        break
    i = 0
    while True:
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
        i += 1
    d += 1

print(ans)


Measured memory_bytes: 67912
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
char m[510][510];
int main(){
	int h,w;
	cin>>h>>w;
	lol(i,h)lol(j,w)cin>>m[i][j];
	lol(i,h){
		lol(j,w){
			bool to=false;
			if(j==0)to=true;
			if(i%2==0)to=true;
			if(m[i][j]=='#')to=true;
			if(j==w-1)to=false;
			if(to)cout<<"#";
			else cout<<".";
		}
		cout<<endl;
	}
	cout<<endl;
	lol(i,h){
		lol(j,w){
			bool to=false;
			if(j==w-1)to=true;
			if(i%2==1)to=true;
			if(m[i][j]=='#')to=true;
			if(j==0)to=false;
			if(to)cout<<"#";
			else cout<<".";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N,K;
vector<ll> vec;


//解法
void solve() {

	ll ans = LONG_MAX;

	rep(i,N - K+1) {

		ll len = vec[i + K - 1] - vec[i] + min(abs(vec[i+K-1]),abs(vec[i]));
	
		ans = min(ans, len);

	}

	cout << ans;

	return;
}

int main() {
	//入力

	cin >> N>>K;
	vec.resize(N);
	rep(i, N) cin >> vec[i];

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<assert.h>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const int N=200010;
pii a[N];
int cmp(pii a,pii b)
{
	if(a.first+a.second!=b.first+b.second)
		return a.first+a.second<b.first+b.second;
	return a.first>b.first;
}
int c[2*N];
int main()
{
//	open("d");
	int w,h,n;
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].first,&a[i].second);
	sort(a+1,a+n+1,cmp);
	int ans=h;
	for(int i=1;i<=n;i++)
	{
		if(a[i].first>a[i].second&&!c[a[i].first-a[i].second+200000])
			ans=min(ans,a[i].first-1);
		c[a[i].first-a[i].second+200000]=1;
		c[a[i].first-a[i].second+200000+1]=1;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
typedef long long LL;

int main()
{
	int N;
	cin >> N;
	int t1 = 0, x1 = 0, y1 = 0;
	for (int i = 0; i < N; i++) {
		int t2, x2, y2;
		cin >> t2 >> x2 >> y2;
		int t = t2-t1, x = abs(x2-x1), y = abs(y2-y1);
		if (x+y > t) {
			cout << "No" << endl;
			exit(0);
		}
		if (x+y < t) {
			int d = t-(x+y);
			if (d%2 != 0) {
				cout << "No" << endl;
				exit(0);
			}
		}
	}
	cout << "Yes" << endl;
	exit(0);
}



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

int main() {
  int n;
  cin >> n;
  
  vector<float> a(n);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  
  vector<float> b(n);
  float bSum = 0.0f;
  for(int i = 0; i < n; ++i){
    b[i] = 1 / a[i];
    bSum += b[i];
  }
  
  float r = 1 / bSum;
  
  cout << r << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{   int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2104
N, M, X = map(int, input().split())
C = []
A = []
for i in range(N):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

MY_INF = 1000000007
    
ans = MY_INF
for case in range(1 << N):
    ans_tmp = 0
    A_tmp = [0] * M
    case_tmp = case
    for i in range(N):
        if case_tmp % 2:
            ans_tmp += C[i]
            for j, Aij in enumerate(A[i]):
                A_tmp[j] += Aij
        #
        case_tmp >>= 1
    #
    for j in range(M):
        if A_tmp[j] < X:
            break
        else:
            continue
    else:
        ans = min(ans, ans_tmp)
else:
    if ans == MY_INF: ans = -1

print(ans)
    

Measured memory_bytes: 9224
# include "iostream"
# include "cstdio"
# include "cstring" 

using namespace std;

const int maxm=1000+10; 

char s1[maxm],s2[maxm]; 
int len1,len2,Next[maxm]; 

void Calculate_Next(){
	register int i,j;
	for(i=2,j=0;i<=len2;i++){
		while(j>0 && s2[i]!=s2[j+1]) j=Next[j];
		if(s2[i]==s2[j+1]) j++;
		Next[i]=j; 
	} 
	return; 
} 

void Calculate_Fail(){
	register int i,j;
	for(i=1,j=0;i<=len1;i++){
		while(j>0 && (j==len2 || s1[i]!=s2[j+1])) j=Next[j];
		if(s1[i]==s2[j+1]) j++;
		if(j==len2){
			printf("Yes");
			return; 
		} 
	}
	printf("No");
	return; 
} 

int main(){
	register int i; 
	scanf("%s%s",s1+1,s2+1);
	len1=len2=strlen(s1+1); 
	for(i=1;i<=len1;i++){
		s1[i+len1]=s1[i]; 
	}
	len1<<=1;
	Calculate_Next();
	Calculate_Fail(); 
	return 0; 
} 

Measured memory_bytes: 256
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;

inline int ceiling(int n, int d) {
	return n % d == 0 ? n / d : n / d + 1;
}

inline int dis(pair<int, int> a, pair<int, int> b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}

int main() {
	int N, M; cin >> N >> M;
	using pos = pair<int, int>;
	auto people = vector<pos>(N);
	auto points = vector<pos>(M);
	for (size_t i = 0; i < N; i++) cin >> people[i].first >> people[i].second;
	for (size_t i = 0; i < M; i++) cin >> points[i].first >> points[i].second;
	for (size_t i = 0; i < N; i++) {
		int min_dis = 1000000000; int number = -1;
		for (size_t j = 0; j < M; j++) {
			auto d = dis(people[i], points[j]);
			if (d < min_dis) {
				number = j + 1;
				min_dis = d;
			}
		}
		cout << number << endl;
	}
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

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

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
// vll x(n); x[i]=a;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;
typedef vector<vector<ll>> vvll;
// vvll x(m,vi(n)); x[i][j]=a;

#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll n, ans = 0, tmp = 0;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	S := sc.next()
	T := sc.next()

	Sarr := strings.Split(S, "")
	Tarr := strings.Split(T, "")
	var cnt int
	for i := 0; i < 3; i++ {
		if Sarr[i] == Tarr[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <algorithm>

#define lo long long
using namespace std;

lo a,b;
lo fak[100100];
const lo MODD=1e9 +7;
int main()
{
    fak[0]=1;
    for (int i=1;i<100100;i++) fak[i]=(fak[i-1]*i)%MODD;
    cin>>a>>b;
    if (abs(a-b)>1)
    {
        cout<<0<<endl;
        return 0;
    }

    lo aa=max(a,b);
    lo bb=min(a,b);

    if (aa==bb)
    {
        lo ans=fak[aa];
        ans=(ans*fak[bb])%MODD;
        ans=(ans*2)%MODD;
        cout<<ans<<endl;
        return 0;
    }
    else
    {
        lo ans=fak[aa];
        ans=(ans*fak[bb])%MODD;
        cout<<ans<<endl;
        return 0;
    }
    return 0;
}


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

int main(){
    string nums;
    int sum;
    while (1){
        sum = 0;
        cin >> nums;
        if (nums[0] == '0') break;
        for (int i=0; i<nums.size(); i++) 
            sum += nums[i] - '0';
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
// ABC087_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

ll N;

ll dfs(vector< vector<ll> > &vec, ll x, ll y, ll score) {
    // stop
    if (x == 1 && y == N-1) return score + vec[x][y];
    
    ll ret1 = -1, ret2 = -1;
    if (x != 1) ret1 = dfs(vec, x+1, y, score + vec[x][y]);
    if (y != N-1) ret2 = dfs(vec, x, y+1, score + vec[x][y]);
    return max(ret1, ret2);
}

int main() {
    // input(sunippets: inpv, inpn, inps)
    
    cin >> N;
    vector< vector<ll> > vec(2, vector<ll>(N));
    REP(i, 2) {
        REP(j, N) cin >> vec[i][j];
    }
    
    // calculation
    
    cout << dfs(vec, 0, 0, 0) << "\n";
    
    return 0;
}

Measured memory_bytes: 256