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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

// Description: ????????????
// Verifyed: various problem 
const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
const P O=0.0L;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P p;R c;};

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline int sdot(P o,P a,P b){return sgn(dot(o,a,b));}
inline int sdet(P o,P a,P b){return sgn(det(o,a,b));}

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/(l.t-l.s)); return (1-u)*l.s+u*l.t;}

//reflection verify AOJ CGL_1_B
P refl(L l,P p){return 2.0L*proj(l,p)-p;}

// CCW verify AOJ CGL_1_C
enum CCW{ LEFT = 1,RIGHT = 2,BACK = 4,FRONT = 8,ON = 16};
inline int ccw(P o,P a, P b) {
	a-=o,b-=o,o-=o;
	if(sdet(o,a,b) > 0) return LEFT;    // counter clockwise
	if(sdet(o,a,b) < 0) return RIGHT;   // clockwise
	if(sdot(o,a,b) < 0) return BACK;    // b--base--a on line
	if(sgn(norm(a)-norm(b)) < 0) return FRONT;   // base--a--b on line
	return ON; // base--b--a on line  semnet determination betwenn a and b 
}

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

int main(void){
	P a,b,p;
	int n;
	cin >> a >> b >> n;
	L l={a,b};
	cout.precision(20);
	rep(i,n){
		cin >> p;
		P ans=refl(l,p);
		cout << fixed << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>
 
int main() {
  int n,m,i,j,cnt=0;
  scanf("%d",&n);
  int a[n];
  for(i=0; i<n; i++) scanf("%d",&a[i]);
  scanf("%d",&m);
  for(i=0; i<m; i++) {
    int x;
    scanf("%d",&x);
    int l=-1,r=n+1;
    while(l+1!=r) {
      int m=(l+r)/2;
      if(a[m]==x) {
    cnt++;
    break;
      }
      if(a[m]<x) l=m;
      else r=m;
    } 
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 2148
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int p = n-m;
        if(m==1){
            System.out.println("0");
        }
        else
            System.out.println(p);
        
    }
    
}


Measured memory_bytes: 21972
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char sr[1<<21],z[20];int K=-1,Z=0;
inline void Ot(){fwrite(sr,1,K+1,stdout),K=-1;}
void print(R int x){
    if(K>1<<20)Ot();if(x<0)sr[++K]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++K]=z[Z],--Z);sr[++K]='\n';
}
const int N=2e5+5,P=1e9+7,inv2=500000004;
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
int fac[N],ifac[N],bin[N],pw[N],pb[N],b,w;
inline int C(R int n,R int m){return m>n?0:1ll*fac[n]*ifac[m]%P*ifac[n-m]%P;}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&b,&w);
	fac[0]=ifac[0]=1;fp(i,1,b+w)fac[i]=mul(fac[i-1],i);
	ifac[b+w]=ksm(fac[b+w],P-2);fd(i,b+w-1,1)ifac[i]=mul(ifac[i+1],i+1);
	bin[0]=1;fp(i,1,b+w)bin[i]=mul(bin[i-1],inv2);
	fp(i,1,b+w){
		pw[i]=add(pw[i-1],mul(C(i-1,w-1),bin[i]));
		pb[i]=add(pb[i-1],mul(C(i-1,b-1),bin[i]));
		print(add(1ll*(1+P-pw[i-1]+P-pb[i-1])*inv2%P,pw[i-1]));
	}
	return Ot(),0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

int W, a, b;

void _main() {
  cin >> W >> a >> b;
  cout << max(0, abs(b-a) - W) << "\n";
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    string s;
    while(getline(cin, s))
    {
        if(s == "END OF INPUT") break;
        int cnt = 0, l = s.size();
        REP(l)
        {
            if(s[i] == ' ') { cout << cnt; cnt = 0;}
            else cnt++;
        }
        cout << cnt << endl;


    }
    return 0;
}

Measured memory_bytes: 0
N = int(input())
S = list(input())
r = S.count('R')
g = S.count('G')
b = S.count('B')
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        if(j+(j-i) >= N):
            break
        if((S[j+(j-i)] != S[i]) and (S[j+(j-i)] != S[j]) and (S[i] != S[j])):
            cnt += 1
print(r*g*b-cnt)

Measured memory_bytes: 9204
n,h=map(int, input().split())
ab=[list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x:(-x[0],x[1]))
a=ab.pop(0)
am=a[0]
a1=a[1]
ab.sort(key=lambda x:x[1])
ans=0
while(h>a1):
    if(len(ab)==0):
        h-=a[1]
        ans+=1
        if(h>0):
            ans+=-(-h//am)
            h=0
        break
    t=ab.pop(-1)
    if(am>t[1]):
        h-=a[1]
        ans+=1
        if(h>0):
            ans+=-(-h//am)
            h=0
        break
    h-=t[1]
    ans+=1
if(h>0):
    ans+=1
print(ans)

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

int factorial(int a)
{
    int ans = 1;
    for (int i = 2; i <= a; i++)
    {
        ans *= i;
    }
    return ans;
}

int main()
{
    int N, M, R;
    cin >> N >> M >> R;

    vector<int> r(R);
    for (int i = 0; i < R; i++)
    {
        cin >> r[i];
        r[i]--;
    }

    vector<vector<int>> matrix(N, vector<int>(N, 99999999));
    int A, B, C;
    for (int i = 0; i < M; i++)
    {
        cin >> A >> B >> C;
        A--;
        B--;
        matrix[A][B] = C;
        matrix[B][A] = C;
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            for (int k = 0; k < N; k++)
            {
                matrix[j][k] = min(matrix[j][k], matrix[j][i] + matrix[i][k]);
            }
        }
    }

    int ans = INT_MAX;
    for (int i = 0; i < factorial(R); i++)
    {
        int tmp = 0;
        for (int j = 0; j < R - 1; j++)
        {
            tmp += matrix[r[j]][r[j + 1]];
        }
        ans = min(ans, tmp);
        next_permutation(r.begin(), r.end());
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	ll n,k;
	cin>>n>>k;
	vector<ll> h(n);
	for(int i=0;i<n;++i) cin>>h[i];
	sort(h.begin(), h.end());
	ll ans=0;
	for(int i=0;i<n-k;++i) ans+=h[i];
	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (s, t) = [e for e in lines[0].split(" ")]
    (a, b) = [int(e) for e in lines[1].split(" ")]
    u = lines[2]

    return (s, t, a, b, u)


def solve(s, t, a, b, u):
    
    a2 = a
    b2 = b
    if s == u:
        a2 = a2 - 1
    elif t == u:
        b2 = b2 - 1
    
    result = ' '.join([str(a2), str(b2)])

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	while (1) {
		cin >> n >> k;
		if (n == 0 && k == 0) {
			return 0;
		} else {
			vi v(n);
			fill(ALL(v), 0LL);
			ll q = k;
			ll i = 0;
			while (1) {
				if (q != 0) {
					v[i]++;
					q--;
					if (q == 0 && k == v[i]) {
						cout << i << endl;
						break;
					}
				} else {
					q += v[i];
					v[i] = 0;
				}
				i++;
				if (i == n) i = 0;
			}
		}
	}
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;




int main(){
    int n;cin >> n;
    vector<LL> a(n);
    for (int i = 0; i < n-1; i++) {
        cin >> a[i];
    }
    LL ans = 0;
    for (int i = 0; i < n-2; i++) {
        ans += min(a[i],a[i+1]);
    }
    ans += a[0] + a[n-2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import fractions

A, B, C, D = map(int, input().split())
G = (C * D) // fractions.gcd(C, D)
print(B - A + 1- (B // C - (A - 1) // C) - (B // D - (A - 1) // D) + (B // G - (A - 1) // G))

Measured memory_bytes: 5048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());

		int a=Integer.parseInt(st.nextToken());
		int b=Integer.parseInt(st.nextToken());
		if(a<b) {
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else {
			System.out.println("a == b");
		}
	}

}



Measured memory_bytes: 24284
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 20 20:53:37 2019

@author: ctiuser
"""

N = int(input())
A = [int(input()) for i in range(N)]

first = 0
second = 0
for c in A:
    if c > first:
        first, second = c, first
    elif c > second:
        second = c

for c in A:
    if c == first:
        print(second)
    else:
        print(first)

Measured memory_bytes: 12560
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int N) : par(N), rank(N) {
        rep(i, N) par[i] = i, rank[i] = 0;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
        }
        else {
            par[ry] = rx;
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int N, Q;
    cin >> N >> Q;
    UnionFind tree(N);

    rep(i, Q) {
        int ct, x, y;
        cin >> ct >> x >> y;
        if (ct) {
            if (tree.same(x, y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
        else {
            tree.unite(x, y);
        }
    }
    return 0;
}


Measured memory_bytes: 3188
A, B, C = map(int, input().split())

rem = []
flg = 0
ct = 1
while True:
    tmp = ct*A
    if tmp % B == C:
        flg = 1
        break
    else:
        if tmp % B not in rem:
            rem.append(tmp % B)
        else:
            break
    ct += 1

print('YES' if flg else 'NO')


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    vector<ll> A(5);
    vector<ll> B(5);

    REP(i, 5){
        cin >> A[i];
    }

    ll ans = 0;
    REP(i, 5){
        B[i] = A[i] % 10;
        ans += int((A[i]+9)/10) * 10;
    }
    sort(B.begin(), B.end());

    bool T = true;
    REP(i, 5){
        if(T){
            if(B[i] > 0){
                ans += B[i] - 10;
                T = false;
            }
        }
    }

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

Measured memory_bytes: 256
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
#入力
#解答
#出力
#Priority-queue
class PriorityQueue:

    def __init__(self,heap):
        self.heap = heap
        heapify(self.heap)
    
    def push(self,item):
        heappush(self.heap,item)
    
    def pop(self):
        return heappop(self.heap)
    
    def pushpop(self,item):
        return heappushpop(self.heap,item)
    
    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)

n,m = map(int,input().split())
A = sorted(list(map(int,input().split())))
heap = []
q = PriorityQueue(heap)
for i in range(n):
    q.push(-A[i])

for i in range(m):
    a = q.pop()
    a *= -1
    a //=2
    a *= -1
    q.push(a)
print(-1*sum(heap))

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

 int main(void)
 {
     int a,b,c,k;
     cin>>a>>b>>c>>k;

     if(k<=a)
        cout<<k<<endl;
     else if(k > a && k <= (a+b))
        cout<<a<<endl;
     else if(k > (a+b))
        cout<<(2*a+b-k)<<endl;
     return 0;
 }


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

// time complexity: O(n)
// space complexity: O(1)
int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int min_num_changes = (1 << 29) - 1;

    int num_changes_starting_at_white = 0;
    int num_changes_starting_at_black = 0;
    for (int i = 0; i < S.size(); i++) {
        char color = S.at(i);
        if ((i % 2 == 0 && color == '1') || 
            (i % 2 == 1 && color == '0')) {
            num_changes_starting_at_black += 1;
        }
        if ((i % 2 == 0 && color == '0') ||
            (i % 2 == 1 && color == '1')) {
                num_changes_starting_at_white += 1;
        }
    }
    min_num_changes = min(min_num_changes, num_changes_starting_at_black);
    min_num_changes = min(min_num_changes, num_changes_starting_at_white);
    cout << min_num_changes << "\n";
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string S;
ll T[201010];
map<ll, ll> m;

int main()
{
    cin >> S;
    ll n = S.length();

    ll r = 1;
    m[0]++;
    for (int i = n - 1; i >= 0; i--)
    {
        int c = S[i] - '0';
        T[i] = ((r * c) % 2019 + T[i + 1]) % 2019;
        r *= 10;
        r %= 2019;
        m[T[i]]++;
    }

    ll ans = 0;
    for (auto e : m)
    {
        ll k = e.first;
        ll v = e.second;
        ans += v * (v - 1) / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 5288
#!/usr/bin/env python3
H, W, N = map(int, input().split())
sr, sc = map(lambda x: int(x) - 1, input().split())
S = input()
T = input()
l, r = 0, W
u, d = 0, H
for i in range(N)[::-1]:
    if T[i] == 'L': r = min(W, r + 1)
    if T[i] == 'R': l = max(0, l - 1)
    if T[i] == 'U': d = min(H, d + 1)
    if T[i] == 'D': u = max(0, u - 1)
    if S[i] == 'L': l += 1
    if S[i] == 'R': r -= 1
    if S[i] == 'U': u += 1
    if S[i] == 'D': d -= 1
    if l == r or u == d: 
        print("NO")
        exit()

print(("NO", "YES")[l <= sc < r and u <= sr < d])



Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

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

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

  queue<string> q;
  q.push("0");
  string ans = "";
  int count = 0;
  int keta = 1;

  while (count < k)
  {
    string tmp = q.front();
    ans = tmp;
    q.pop();

    if (tmp != "0")
      count++;

    if (keta == 1)
    {
      q.push("1");
      q.push("2");
      q.push("3");
      q.push("4");
      q.push("5");
      q.push("6");
      q.push("7");
      q.push("8");
      q.push("9");
      keta++;
      continue;
    }

    if (tmp[tmp.size() - 1] == '0')
    {
      q.push(tmp + '0');
      q.push(tmp + '1');
      continue;
    }

    if (tmp[tmp.size() - 1] == '9')
    {
      q.push(tmp + '8');
      q.push(tmp + '9');
      continue;
    }

    char last = tmp[tmp.size() - 1];
    int lasti = last - '0';

    for (int i = -1; i <= 1; i++)
    {
      char nextc = '0' + (lasti + i);
      q.push(tmp + nextc);
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  int sum = 0;
  int a[n], b[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    int val = a[i] - b[i];
    if(val > 0)
      sum += val;
  }
  cout << sum;
}

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

using namespace std;
using ll = long long;

int main(){
	string s;
	cin>>s;
	for(int i = 0; i < s.length() - 1; i++){
		if(s[i] == s[i+1]){
			
				cout<<i + 1<<" "<<i + 2<<endl;
			
			return 0;
            
		}if(i < s.length() - 1){
			if(s[i] == s[i + 2]){
				cout<<i + 1<<" "<<i + 3<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1"<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define N 36

//bool isStable(char*,char*,int);
int main(){
  int i,j,a,k,minj;
  char A[N][N],tmp[N],A2[N][N];

  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%s",&A[i]);
  }
 
  memcpy(A2,A,sizeof(A));
  for(i=0;i<a-1;i++){   
    for(j=a-1;i+1<=j;j--){
      //printf("%s %s\n",A[j],A[j-1]);
      if (A[j][1]<A[j-1][1]){
	strcpy(tmp,A[j]);
	strcpy(A[j],A[j-1]);
	strcpy(A[j-1],tmp); 
        //printf("change %s %s\n",A[j],A[j-1]);
      }
    }
  }
 
  for(k=0;k<a-1;k++)
  printf("%s ",A[k]);
  printf("%s\n",A[k]);
  printf("Stable\n");
    
  for(i=0;i<a-1;i++){
    minj=i;
    for(j=i;j<a;j++){
      if(A2[j][1]<A2[minj][1])
	minj = j;
    }
    if (i!=minj){
      strcpy(tmp,A2[i]);
      strcpy(A2[i],A2[minj]);
      strcpy(A2[minj],tmp); 
	
    }
  }

  for(k=0;k<a-1;k++)
    printf("%s ",A2[k]);
  printf("%s\n",A2[k]);
    

  for(k=0;k<a;k++){
    if(A[k][1]!=A2[k][1] || A[k][0]!=A2[k][0])
      break;
  }
  if(k==a) printf("Stable\n");
  else printf("Not stable\n");
    
   
  return 0;

}  





Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,flag=0;cin>>a>>b;
	int na=ceil(double(a)*100/8.0);double nb=double(a+1)*100/8.0;
	for(int i=na;i<nb;++i)
	if(floor(i*0.1)==b) 
	{cout<<i;flag=1;break;
	}
	if(flag==0) cout<<"-1";
}

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

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int v[n],ans=0;
  for(int i=0;i<n;i++){
    scanf("%d",&v[i]);
    if(v[i]>=k)ans ++;
  }
  printf("%d",ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int main() {
    int n;
    int a[202020];
    int b[202020];
    cin>>n;
    REP(i, 1, n+1) cin>>a[i];
    REP(i, 1, n+1) b[i]=0;

    vector<int> ball; // ボールを入れるべき箱のindex
    int idx=n;
    while(idx>0){
        int cnt=0;
        for(int i=idx; i<n+1; i+=idx){
            cnt+=b[i];
        }

        if(cnt%2 != a[idx]){
            b[idx]=1;
            ball.push_back(idx);
        }

        idx--;
    }
    cout<<ball.size()<<endl;
    if(ball.size()>0){
        REP(i, 0, ball.size()-1){
            cout<<ball[i]<<" ";
        }
        cout<<ball[ball.size()-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3064
import math
#数値ひとつ
#I = int(input())
#数値欲しいとき
N, M = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#listA = list(N)
#受け取る数が未定かつリストにしたいとき
list = list(map(int, input().split()))

sum = 0
for syukudai in list:
    sum += syukudai

if N-sum < 0:
    print('-1')
else:
    print(N-sum)


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s;cin>>s;
    int k;cin>>k;
    int n=SIZE(s);

    REP(i,n){
        if(s[i]=='a'){
            continue;
        }
        int d='z'+1-s[i];
        if(k>=d){
            s[i]='a';
            k-=d;
        }
    }
    k%=26;
    s[n-1]+=k;
    if(s[n-1]>'z'){
        s[n-1]-=26;
    }
    cout<<s<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 50;
int a[mxN+3];
llong stax[(1<<18)+3],stay[(1<<18)+3];
llong comb[mxN+3][mxN+3],f[mxN+3];
int bitcnt[(1<<25)+3];
int n,m,A,B,mx;

llong Bitcnt(llong x) {return bitcnt[x>>25]+bitcnt[x&((1ll<<25)-1)];}

int main()
{
	comb[0][0] = 1ll; for(int i=1; i<=mxN; i++) {comb[i][0] = comb[i][i] = 1ll; for(int j=1; j<i; j++) comb[i][j] = comb[i-1][j]+comb[i-1][j-1];}
	for(int i=1; i<(1<<25); i++) bitcnt[i] = bitcnt[i>>1]+(i&1);
	n = read(),m = read(),A = read(),B = read();
	for(int i=0; i<=n; i++) for(int j=1; j<=m; j++) {f[i] += comb[i][j];}
	for(int i=0; i<n; i++) a[i] = read();
	mx = (1<<18)-1;
	if((A&B)!=A) {puts("0"); return 0;}
	for(int i=0; i<=mx; i++)
	{
		for(int j=0; j<n; j++) {if((a[j]&i)==i) {stax[i] |= (1ll<<j);} if((a[j]|i)==i) {stay[i] |= (1ll<<j);}}
	}
	llong ans = 0ll;
	for(int i=A; i<=mx; i=(i+1)|A)
	{
		if((B&i)!=i) continue;
		for(int j=B^i; j>=0; j=(j==0?-1:(j-1)&(B^i)))
		{
			llong coe = (bitcnt[A]-bitcnt[i]+bitcnt[j|i]-bitcnt[B])&1,tmp = f[Bitcnt(stax[i]&stay[j|i])];
			coe?ans-=tmp:ans+=tmp;
		}
	}
	printf("%lld\n",ans);
	return 0;
}
/*
19 17 12296 14429
98556 131974 245670 63659 206158 29342 236386 8051 718 178812 253316 41592 210524 106503 146207 192609 81118 92232 133769 
*/

Measured memory_bytes: 138884
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define pi 3.14159265358979323846
int i;
int main(){
    string s;cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String s = a + b;
        int c = Integer.parseInt(s);
        double r = Math.sqrt(c);
        if (r == (int) r)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 21844
import java.util.*;
import java.io.*;

public class Main {
	static int n, H[];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		n=Integer.parseInt(in.next()); H=new int[n+1];
		for(int i=1;i<=n;i++) {
			H[i]=Integer.parseInt(in.next());
		}
		buildMaxHeap();
		
		PrintWriter out=new PrintWriter(System.out);
		for(int i=1;i<=n;i++)out.print(" "+H[i]);
		out.println();
		out.flush();
	}
	
	static void maxheapify(int i) {
		if(i*2>n) return;
		
		int max=H[i], u=-1;
		if(H[i*2]>max) {
			max=H[i*2];
			u=i*2;
		}
		if(i*2+1<=n && H[i*2+1]>max) {
			max=H[i*2+1];
			u=i*2+1;
		}
		
		if(u>0) {
			int t=H[i];
			H[i]=H[u];
			H[u]=t;
			maxheapify(u);
		}
	}
	
	static void buildMaxHeap() {
		for(int i=n/2;i>0;i--)maxheapify(i);
	}
}




Measured memory_bytes: 109524
#include <stdio.h>
int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	int ans=0;
	//何回投げるかを計算する
	int i;
	int try = 1;
	for(i=0;i<m;i++){
		try *=2;
	}
	ans = try*( (n-m)*100 + (1900)*m);
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int a,b;
    while(1){
        scanf("%d %d",&a,&b);
        if(a + b == 0)break;
        if(a < b){
            printf("%d %d\n",a,b);
        }else printf("%d %d\n",b,a);
    }
    return 0;
}


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


int main ()
{
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> t(N);
  for (int i = 0; i < N; i++)
  {
    cin >> S[i] >> t[i];
  }
  string X;
  cin >> X;
  
  int count = 0;
  for (int i = 0; i < N; i++)
  {
    
    if (S.at(N-1-i) == X) break;
    count += t.at(N-1-i);
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
int k,a,b;
  cin>>k>>a>>b;
  int fg=0;
for(int i=a;i<=b;i++)
    if(i%k==0)
        {cout<<"OK";
        fg=1;break;}
        
  if(fg==0)
      cout<<"NG\n";
  
 return 0; 
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll    long long
#define pb          push_back
#define F first
#define S second
#define    endl        '\n'
#define all(v) (v).begin(), (v).end()
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    string sep;
    for (const auto &x : v) os << sep << x, sep = ", ";
    return os << '}';
}
template<typename T, size_t size> ostream &operator<<(ostream &os, const array<T, size> &arr)
{
    os << '{';
    string sep;
    for (const auto &x : arr) os << sep << x, sep = ", ";
    return os << '}';
}
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    return os   << '(' << p.first << ", " << p.second << ')';
}
void dbg_out()
{
    cerr << endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}

#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
const int N = 1000 + 5;
void solve()
{
    ll n, m = 1e9 + 7, s = 0, ans = 0;
    cin >> n;
    std::vector<ll> v(n);
    for(ll &i : v) cin >> i, s += i;
    for(ll i : v)
    {
        s-=i;
        ans+=s%m*i%m;
        ans%=m;
    }
    cout<<ans;



}
int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    ll TESTS = 1;
    // cin >> TESTS;
    for(int t = 1; t <= TESTS; t++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL c[200005];

LL M = 1e9 + 7;

LL fact[200005];
LL p2[200005];

void init() {
    fact[0] = 1;
    for (LL i = 1; i < 200005; i++) {
        fact[i] = i * fact[i - 1];
        fact[i] %= M;
    }
    p2[0] = 1;
    for (LL i = 1; i < 200005; i++) {
        p2[i] = p2[i - 1] * 2;
        p2[i] %= M;
    }
}

int main() {
    init();
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c, c + n, [](LL x, LL y) { return x > y; });
    LL ag = 1;
    LL ans = 2 * c[0];
    ans %= M;
    for (int i = 1; i < n; i++) {
        ans *= 4;
        ans %= M;
        ag = ag * 2 + p2[i - 1];
        ag %= M;
        ans += ((ag * p2[i + 1]) % M) * c[i];
        ans %= M;
        // printf("ag = %lld\n", ag);
    }
    cout << ans << endl;
}


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


def val_arg_tpls_sort(lis):
    val_arg_tpls = (
        (val, i) for i, val in enumerate(lis)
    )
    return list(sorted(val_arg_tpls))


def count_odd_in_even(val_arg_tpls):
    cnt = 0
    for _, arg in val_arg_tpls[::2]:
        cnt += arg % 2
    return cnt


def solve(N: int, A: "List[int]"):
    sorted_tpls = val_arg_tpls_sort(A)
    cnt = count_odd_in_even(sorted_tpls)
    print(cnt)
    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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int gcd(int a,int b) {
  if(b > a) swap(a,b);
  if(a % b == 0) {
    return b;
  } else {
    return gcd(b, a%b);
  }
}

int main(void) {
  int a,b,k;
  cin >> a >> b >> k;
  int g = gcd(a,b);
  vector< int > cd;
  for(int i = g;i >= 1;--i){
    if(g % i == 0){
      cd.push_back(i);
    }
  }
  cout << cd[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

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

using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    
    string S;
    cin >> S;
    
    int a=0;
    int b=(int)S.length()-1;
    int count=0;
    
    while(a<b){
        if(S[a]!=S[b]){
            S[a]=S[b];
            count++;
        }
        a++;
        b--;
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3196
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int[] a, b;
    int i, j, hi, bl;

    a = new int[4];
    b = new int[4];

    for(;sc.hasNext();){
      hi = 0; bl = 0;
      for(i = 0;i < 4;i++)a[i] = sc.nextInt();
      for(i = 0;i < 4;i++)b[i] = sc.nextInt();
      for(i = 0;i < 4;i++)if(a[i] == b[i])hi++;
      for(i = 0;i < 4;i++)for(j = 0;j < 4;j++)if(a[i] == b[j])bl++;
      out.println(hi + " " + (bl - hi));
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 18084
n, m = list(map(int,input().split()))
# print(n,m)
l = {}
ok = True
for i in range(m):
  x, y = list(map(int,input().split()))
  if (x in l):
    if l[x] != y:
      ok = False
      break
  else:
    l[x] = y
ret = ""
for i in range(n):
  keta = i + 1    
  if keta in l:
    if keta == 1:
      if l[keta] == 0:
        ret = ret + str(l.pop(keta))
        ok = False
        break
      else:
        ret = ret + str(l.pop(keta))
    else:
      ret = ret + str(l.pop(keta))
  else:
    ret = ret + "0"
if len(l) > 0:
  ok = False

ret = int(ret)
if ok:
  if (ret < 10**(n-1)) and n > 1:
    print(ret + 10**(n-1))
  else:
    print(ret)
else:
  if n == 1 and ret == 0:
    print(0)
  else:
    print(-1)


Measured memory_bytes: 38256
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

// x文字目の時に，あまりiである数をカウント
var dp = [13]int{}

func main() {
	input := bufio.NewReader(os.Stdin)
	var S string
	fmt.Fscanf(input, "%s\n", &S)

	// 1234 % mod = ((1000%mod) + (200%mod) + (30%mod) + (4%mod))%mod

	dp[0] = 1
	for i := 0; i < len(S); i++ {
		var nextdp = [13]int{}
		num, _ := strconv.Atoi(string(S[i]))

		for j := 0; j < 13; j++ {
			for k := 0; k < 10; k++ {
				if string(S[i]) == "?" || num == k {
					nextdp[((j*10)+k)%13] += dp[j]
					nextdp[((j*10)+k)%13] %= mod
				}
			}
		}
		dp = nextdp
	}
	fmt.Println(dp[5])
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i][0] < a[j][0] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
char laz[maxn];
int pi[12*maxn];
int prefix_function(const string &s,const string &t) {
    ///search t on s
    int m=(int)t.length();
    int n =(int)t.length()+(int)s.length()+1;
    auto ss=[&](int idx){
        if(idx==m)return '#';
        if(idx<m)return t[idx];
        return s[idx-m-1];
    };
    pi[0]=0;
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && ss(i) != ss(j))
            j = pi[j-1];
        if (ss(i) == ss(j))
            j++;
        pi[i] = j;
    }
    int ma=-1;
    for(int i=n-1;i>m;i--){
        pi[i]=(pi[i]==m?1:0);
        if(i+m<n&&pi[i]==1){
            pi[i]+=pi[i+m];
        }
        ma=max(ma,pi[i]);
    }
    return ma;
}
string s,t,a,ss,tt;
/**
There exists a non-negative integer j
such that the concatenation of i copies of t
is a substring of the concatenation of j copies of s.
*/


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>ss>>t;
    s=ss;
    while((int)s.length()<=(int)t.length()+(int)ss.length()){
        s+=ss;
    }
    s+=ss;
    int c=prefix_function(s,t);
    if(c==-1){
       return cout<<"0",0;
    }
    s+=s;
    int cc=prefix_function(s,t);
    if(cc==c){
        return cout<<cc,0;
    }
    else{
        return cout<<-1,0;
    }
}
/*
    Good Luck
        -Lci70121
*/


Measured memory_bytes: 25916
n,m = map(int, input().split())
s = input()
num = '0123456789'
flg = 0
for i in range(len(s)):
  if i < n-1:
    if s[i] not in num:
      flg = 1
  elif i == n:
    if s[i] != '-':
      flg = 1
  else:
    if s[i] not in num:
      flg = 1
if flg == 0:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
import sys
stdin = sys.stdin
from collections import deque

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
a = na()
b = set(a)
if len(a)==len(b):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 25944
N = gets.to_i

num =gets.split.map(&:to_i)
cnt =0

N.times.each do |i|
minj = i

(i..N-1).each do |j|
if num[j] < num[minj]
minj = j

end
end

if minj != i
work = num[i]
num[i] = num[minj]
num[minj] = work
cnt +=1

end

end

puts num.join(" ")
puts cnt

Measured memory_bytes: 8672
#include <stdio.h>
int main(void){
    int n,m,q;
    scanf("%d%d%d",&n,&m,&q);
    int a[n][n];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)a[i][j]=0;
    int e,f;
    for(int i=0;i<m;i++){
        scanf("%d%d",&e,&f);
        a[e-1][f-1]++;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            a[i][j+1]+=a[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=n-1;j>0;j--){
            a[j-1][i]+=a[j][i];
        }
    }
    for(int i=0;i<q;i++){
        scanf("%d%d",&e,&f);
        printf("%d\n",a[e-1][f-1]);
    }
}

Measured memory_bytes: 1792
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        String s=in.nextLine();
        String p=in.nextLine();
        s=s+s;
        if(s.indexOf(p)!=-1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26220
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

class KMP {
  int m;
  string pattern;
  vector<int> fail;

public:
  KMP(const string &pattern) : m(pattern.size()), pattern(pattern), fail(m + 1) {
    int j = fail[0] = -1;
    for (int i = 1; i <= m; ++i) {
      while (j >= 0 && pattern[j] != pattern[i - 1]) j = fail[j];
      fail[i] = ++j;
    }
  }

  vector<int> findAll(const string &target) { // matched substrs positions (0-indexed)
    int n = target.size();
    vector<int> indices;
    for (int i = 0, j = 0; i < n;) {
      if (target[i] == pattern[j]) {
        i++, j++;
      } else if (j == 0) {
        i++;
      } else {
        j = fail[j];
      }
      if (j == m) {
        indices.emplace_back(i - m);
        j = fail[j];
      }
    }
    return indices;
  }
};

main {
  string t, p;
  cin >> t >> p;
  KMP kmp(p);
  for (auto i : kmp.findAll(t)) cout << i << endl;
}



Measured memory_bytes: 12748
def foods_loved_by_everyone(N: int, M: int, KA: list) -> int:
    loved = [0] * M

    for ka in KA:
        for a in ka[1:]:
            loved[a-1] += 1

    return sum([1 for l in loved if l == N])


if __name__ == "__main__":
    N = 0
    N, M = [int(s) for s in input().split()]
    KA = [[int(s) for s in input().split()] for _ in range(N)]
    ans = foods_loved_by_everyone(N, M, KA)
    print(ans)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
A = []
for i in range(N):
    A.append(z())

pos = 0
for i in range(N):
    pos = A[pos] - 1
    if (pos == 1):
        print(i+1)
        exit()
print(-1)


Measured memory_bytes: 46432
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int A[] = new int[100];
    int i,N;

    N = scanner.nextInt();

    for(i=0;i<N;i++){
      A[i] = scanner.nextInt();
    }

    for(i=N-1;i>=0;i--){
      System.out.print(A[i]);
      if(i!=0)System.out.print(" ");
    }

    System.out.print("\n");

  }
}



Measured memory_bytes: 26332