akhauriyash/Code-Regression huggingface dataset:
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> x(N), y(N);
	vector<vector<int>> dist_x(N, vector<int>(N)), dist_y(N, vector<int>(N));

	REP(i, N) {
		cin >> x[i] >> y[i];
	}

	for(int i = 0; i < N; i++) {
		for(int j = i + 1; j < N; j++) {
			dist_x[i][j] = x[i] - x[j];
			dist_y[i][j] = y[i] - y[j];
		}
	}

	int max_equal_dist = 0;
	for(int i1 = 0; i1 < N; i1++) {
		for(int j1 = i1 + 1; j1 < N; j1++) {
			int equal_dist = 1;
			for (int i2 = 0; i2 < N; i2++) {
				for (int j2 = i2 + 1; j2 < N; j2++) {
					if (!((i1 == i2) && (j1 == j2))) {
						if (((dist_x[i1][j1] == dist_x[i2][j2]) && (dist_y[i1][j1] == dist_y[i2][j2]))
							|| ((dist_x[i1][j1] == - dist_x[i2][j2]) && (dist_y[i1][j1] == - dist_y[i2][j2]))) {
							equal_dist++;
						}
					}
				}
			}
			max_equal_dist = max(max_equal_dist, equal_dist);
		}
	}

	cout << N - max_equal_dist << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

type unionFind struct {
	count   int
	parents []int
}

func NewUnionFind(n int) *unionFind {
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = i
	}
	return &unionFind{
		count:   n,
		parents: p,
	}
}

func (u *unionFind) Root(x int) int {
	if u.parents[x] == x {
		return x
	}
	u.parents[x] = u.Root(u.parents[x])
	return u.parents[x]
}

func (u *unionFind) Unite(x, y int) {
	rx, ry := u.Root(x), u.Root(y)
	if rx == ry {
		return
	}
	if rx < ry {
		u.parents[rx] = ry
	} else {
		u.parents[ry] = rx
	}
}

func (u *unionFind) Same(x, y int) bool {
	return u.Root(x) == u.Root(y)
}

func main() {
	var n, m, a, b int
	fmt.Scan(&n, &m)
	var cnt = n
	u := NewUnionFind(n)
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		if u.Same(a-1, b-1) {
			continue
		} else {
			u.Unite(a-1, b-1)
			cnt--
		}
	}
	if cnt > 0 {
		fmt.Println(cnt - 1)
	} else {
		fmt.Println(cnt)
	}
}


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

using ll = long long;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> prices(m);
    vector<vector<int>> boxes_by_keys(n);
    vector<vector<int>> keys_by_boxes(m);
    for (int i = 0; i < m; i++) {
        int b;
        cin >> prices[i] >> b;
        for (int k = 0; k < b; k++) {
            int c;
            cin >> c;
            c--;
            boxes_by_keys[c].emplace_back(i);
            keys_by_boxes[i].emplace_back(c);
        }
    }
    map<string, int> mp;
    string s(n, '0');
    mp[s] = 0;
    for (int i = 0; i < m; i++) {
        vector<int> keys = keys_by_boxes[i];
        for (auto &e: mp) {
            string key = e.first;
            bool changed = false;
            for (auto k: keys) {
                if (key[k] == '0') {
                    key[k] = '1';
                    changed = true;
                }
            }
            if (changed) {
                int new_val = e.second + prices[i];
                if (mp.count(key)) {
                    mp[key] = min(mp[key], new_val);
                } else {
                    mp[key] = new_val;
                }
            }
        }
    }
    string a(n, '1');
    cout << (mp.count(a) ? mp[a] : -1) << endl;
    return 0;
}


Measured memory_bytes: 896
n = int(input())
a = [int(x) for x in input().split()]
ans = 2**60

if a[0] == 0:
  s = 1
  cnt = 1
  for i in range(1,n):
    ns = s + a[i]
    if s * ns < 0:
      s = ns
      continue
    else:
      cnt += abs(ns)+1
      s = -1 if ns > 0 else 1
  ans = min(ans, cnt)

  s = -1
  cnt = 1
  for i in range(1,n):
    ns = s + a[i]
    if s * ns < 0:
      s = ns
      continue
    else:
      cnt += abs(ns)+1
      s = -1 if ns > 0 else 1
  ans = min(ans, cnt)
  
else:
  s = a[0]
  cnt = 0
  for i in range(1,n):
    ns = s + a[i]
    if s * ns < 0:
      s = ns
      continue
    else:
      cnt += abs(ns)+1
      s = -1 if ns > 0 else 1
  ans = min(ans, cnt)
  
  s = -1 if a[0] > 0 else 1
  cnt = abs(a[0])+1
  for i in range(1,n):
    ns = s + a[i]
    if s * ns < 0:
      s = ns
      continue
    else:
      cnt += abs(ns)+1
      s = -1 if ns > 0 else 1
  ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 14332
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<fstream>
#include<math.h>
using namespace std;

const int M = 1000000007;

long power(long x, long n)
{
	long res;
	if (n == 0)
		return 1;

	res = power(x*x%M, n / 2);
	if ((n & 1) != 0)
	{
		res = res*x%M;
	}
	return res;
}
int main(){
	std::istream & c_in = cin;

	int m,n;
	c_in >> m >> n;
	cout << power(m,n) << endl;
}

Measured memory_bytes: 1164
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

int main(){	
	ll H, W, K;
	cin >> H >> W >> K;
	vector<string> S(H);
	rep(i, H) cin >> S[i];
	ll res = INF;
	rep(i, 1LL<<(H-1)) {
		ll now = __builtin_popcount(i);
		vector<ll> d(H);
		rep(j, W) {
			ll piv = 0;
			bool flg = false, flg2 = false;
			rep(k, H) {
				if (S[k][j] == '1') d[piv]++;
				// cout << j << piv << " " << d[piv] << endl;
				if (i&(1LL<<k)) piv++;
			}
			rep(k, H) {
				// if (d[piv] == K) flg = true;
				if (d[k] > K) flg2 = true;
			}
			// if (flg && !flg2) {
			// 	if (j != W-1) now++;
			// 	// cout << i << " " <<  j << endl;
			// 	rep(k, H) d[k] = 0;
			// }
			piv = 0;
			// if (i == 4 ) {
			// 	rep(k, H) cout << d[k];
			// 	cout << endl;
			// 	cout << flg2 << endl;
			// }
			if (flg2) {
				now++;
				// cout << i << " " << j << " " << now << endl;
				
				rep(k, H) d[k] = 0;
				rep(k, H) {
					if (S[k][j] == '1') d[piv]++;
					if (i&(1LL<<k)) piv++;
				}
				bool flg3 = false;
				rep(k, H) {
					if (d[k] > K) {
						now = INF;
						flg3 = true;
					} 
				}
				if (flg3) break;

				// rep(k, H) {
				// 	if (d[k] == K) {
				// 		now++;
				// 		flg3 = true;
				// 		break;
				// 	} 
				// }
				// if (flg3) {
				// 	rep(k, H) d[k] = 0;
				// }
			}
		}
		// cout << now << endl;
		res = min(res, now);
	}
	cout << res << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll n,k;
	ll t;
	cin >> n >> k;
	if(n%2 == 0)
	{
		t = n/2;
	}
	else
		t = n/2 + 1;
	if(k <= t)
		cout << "YES";
	else
		cout << "NO";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n,k;
	cin>>n>>k;
	
	int dp[n+1];
	int tot=0,i,d,x;
	for( i=1;i<=n;i++)
	{
		dp[i]=0;
	}
	while(k--)
	{
		
		cin>>d;
		for(i=0;i<d;i++)
		{
			cin>>x;
			dp[x]++;
		}
	}
	for( i=1;i<=n;i++)
	{
		if(!dp[i])
		{
			tot++;
		}
	}
	cout<<tot<<endl;
	
	return 0;
}

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

int main(){
    long long N;
    cin >> N;
    long long i, n, counta, answer = 0;
    for(n = 1; n <= N; n += 2){
        counta = 0;
        for(i = 1; i <= n; i++){
            if(n % i == 0) counta++;
        }
        if(counta == 8) answer++;
    }
    cout << answer << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
X, K, D = map(int, input().split())

if X==0:
  if K%2==0:
    print(X)
  else:
    print(D)
elif abs(X)-K*D>=0:
  print(abs(X)-K*D)
else:
  a = int(abs(X) / D)
  b = abs(X) % D
  if (K-a)%2==0:
    print(b)
  else:
    print(abs(b-D))
    

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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 0 && b < 0) cout << ((b-a+1)%2 ? "Negative" : "Positive");
	else if (a > 0 && b > 0) cout << "Positive";
	else cout << "Zero";
}

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

int main(){
  int n,k;
  cin >> n >> k;
  set<int> d;
  for(int i=0;i<k;i++){
    int dinput;
    cin >> dinput;
    d.insert(dinput);
  }
 for(int i=n;i<100000;i++){
   int m=i;
   vector<int> nn(0);
   while(m > 0){
     nn.push_back(m % 10);
     m /= 10; 
    }
    for(int j=0;j<nn.size();j++){
        if(d.count(nn.at(j))) break;
        if(j == nn.size()-1){
            cout << i << endl;
            return 0;
        }
    }
 }
 return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int t = scan.nextInt();

		int ans = (t / a) * b;

		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

int compar(const int *val1, const int *val2);

int main(void){
	int N,X,m[100];
	scanf("%d",&N);
	scanf("%d",&X);
	int i;
	for(i=0;i<N;i++){
		scanf("%d",&m[i]);
	}
	
	for(i=0;i<N;i++){
		X=X-m[i];
	}
	qsort(m, N, sizeof(int),(int (*)(const void *, const void *))compar);
	printf("%d",N+X/m[0]);
	
	return 0;}
	
int compar(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll a, n, sum = 0;
  cin >> n;
  rep(i, n) {

    cin >> a;
    sum += a - 1;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];

int check(llong P){
	int i=0;
	for(int j=0; j<k; j++){
		llong s=0;
		while(s + T[i]<=P)
		{
			s+=T[i];
			i++;
			if(i==n){return n;}
		}
	}
	return i;
}
int solve(void){
	llong left=0;
	llong right =100000*10000;
	llong mid;
	while(right-left>1){
		mid=(right+left)/2;
		int v=check(mid);
		if (v>=n) right=mid;
		else left=mid;
	}
	return right;
}
int main(void){
	int i;
	scanf("%d", &n);
	scanf("%d", &k);
	for(i=0; i<n; i++){
		scanf("%d", &T[i]);
	}
	llong ans=solve();
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2576
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

int32_t N;
int32_t x;
int64_t a[2000];
int64_t dp[2000][2000];/*
int64_t func(int32_t i, int32_t n)
{
	int64_t res = 0;
	for (int32_t ln = 1; ln < n-1; ++ln)
	{
		auto tmp = func(i, ln);
		res += tmp + x
	}
}*/
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	for (int32_t i = 0; i < 3; ++i)
	{
		in >> a[i];
	}
	if (std::any_of(a, a + 3, [](int v) {return !(v & 1); })) {
		out << 0 << std::endl; return 0;
	}
	std::sort(a, a + 3);
	out << a[0]*a[1]<< std::endl;

	/*
	in >> N>>x;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> a[i];
	}*/


	return 0;
}
#endif



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

int main()
{
    int n;
    char c;
    cin >> n;
    set<char> s;
    while(n--)
    {
        cin >> c;
        s.insert(c);
    }
    if(s.size() == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws Exception{
        int x, ans;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        x = Integer.parseInt(br.readLine());

        ans = x * x * x;
        System.out.println(ans);
    }
}

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

map<string , ll>mp ; 
int main() {
	int n ; 
	scanf("%d" , &n) ; 
	string s[N] ; 
	for (int i =0 ; i<n ; ++i) {
		cin>>s[i] ; 
		sort(s[i].begin() , s[i].end()) ; 
		mp[s[i]] ++ ; 
	
	}
	ll ans = 0 ; 
	for (auto it = mp.begin() ; it!= mp.end() ; ++it) {
		ans+=1ll * it->second * (it->second-1) / 2 ; 
	} 
	printf("%lld\n" , ans) ; 
	return 0;
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
long long A[100009],cnt1[100009],cnt2[100009];
int main()
{
  long long N,M,i,j,k,t1 = 0,t2 = 0,s1 = 0,s2 = 0,ans = 10000000000;
  cin >> N;
  for(i = 0;i < N;i++)
  {
    cin >> A[i];
    if(i & 1)
    {
      cnt1[A[i]]++;
      if(cnt1[A[i]] > cnt1[t1] && A[i] != t1)
      {
        //cout << i << " " << A[i] << " " << t1 <<  " " << s1 << endl;
        s1 = t1;
        t1 = A[i];
        //cout << i << " " << A[i] << " " << t1 << " " << s1 << endl;
      }
      else if(cnt1[A[i]] > cnt1[s1] && A[i] != t1)
      {
        s1 = A[i];
      }
    }
    else
    {
      cnt2[A[i]]++;
      if(cnt2[A[i]] > cnt2[t2] && A[i] != t2)
      {
        s2 = t2;
        t2 = A[i];
      }
      else if(cnt2[A[i]] > cnt2[s2] && A[i] != t2)
      {
        s2 = A[i];
      }
    }
  }
  //cout <<t1 << " " << t2 << endl;
  if(t1 != t2)
    cout << N - cnt1[t1] - cnt2[t2] << endl;
  else
  {
    //cout << s1 << " " << s2 << endl;
    if(s2)
    {
      ans = min(ans,N-cnt1[t1]-cnt2[s2]);
    }
    if(s1)
    {
      ans = min(ans,N-cnt2[t2]-cnt1[s1]);
    }
    if(s1 == 0 && s2 == 0)
    {
      ans = N/2;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n;
    cin>>n;

    rep(i, 1<<n) {
        cout<<i<<":"<<(i != 0 ? ' ' : '\n');
        int temp = i;
        vector<int> res;
        rep(j, n) {
            if (temp & 1) res.push_back(j);
            temp = temp >> 1;
        }
        rep(j, res.size()) cout<<res[j]<<(j != res.size() - 1 ? ' ' : '\n');
    }
}


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

int main() {
  char a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  if(c==d&&a==f&&b==e){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
a,b,m = map(int,input().split())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
a_min = min(a_list)
b_min = min(b_list)
ans = a_min + b_min

for i in range(m):
    x,y,z = map(int,input().split())
    if a_list[x-1] + b_list[y-1] - z < ans:
        ans = a_list[x-1] + b_list[y-1] - z
        
print(ans)


Measured memory_bytes: 18608
N = int(input())
now_x = 0
now_y = 0
now_t = 0
f = 0
for _ in range(N):
    t,x,y  = map(int,input().split())
    abs_xy = abs(x-now_x)+abs(y-now_y)
    abs_t = abs(t-now_t)
    if abs_xy == abs_t or (abs_t > abs_xy and (abs_t -abs_xy)%2 ==0):
        now_x = x
        now_y = y
        now_t = t
    else:
        f = 1
        break

if f:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 3064
#include<iostream>
#include<array>
#include<set>
using namespace std;
string s,t;
int ans;
main()
{
	cin>>s>>t;
	for(int i=1;i<=s.size();i++)
	{
		set<array<int,26> >S;
		array<int,26>c;
		for(int j=0;j<26;j++)c[j]=0;
		for(int j=0;j<i-1;j++)c[s[j]-'a']++;
		for(int j=i-1;j<s.size();j++)
		{
			c[s[j]-'a']++;
			S.insert(c);
			c[s[j-i+1]-'a']--;
		}
		array<int,26>d;
		for(int j=0;j<26;j++)d[j]=0;
		for(int j=0;j<i-1&&j<t.size();j++)d[t[j]-'a']++;
		for(int j=i-1;j<t.size();j++)
		{
			d[t[j]-'a']++;
			if(S.find(d)!=S.end())ans=i;
			d[t[j-i+1]-'a']--;
		}
	}
	cout<<ans<<endl;
}



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

    int a,b,c;
    cin >> a >> b >> c; 
    int i=0;
    a=a-c*2;
    if(a==b) {cout << "1" <<endl; return 0;}
    while(a>b){
        i++;
        a=a-(b+c);
        if(a==b){i++; break;}
    }
    
    cout << i;
    
           
     return 0;   
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    S = input()

    cnt = [0]*2019
    cnt[0] = 1

    # Sの右側から1ずつ左に伸ばして、cntの対応するところに加算
    rmd = 0
    num_rate = 1
    L = len(S)
    for i in range(L):
        rmd = (int(S[L-i-1])*num_rate + rmd) % 2019
        num_rate = num_rate*10%2019
        cnt[rmd] += 1

    ans = sum([i*(i-1)//2 for i in cnt])
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9364
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_s)
  end
  lc += 1
end

str = inputs[0][0]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p str
end

h = {}
for i in 0..str.length-1
  if h[str[i]] == nil
    h[str[i]] = 1
  else
    h[str[i]] += 1
  end
end

if h.size == 2 and h.to_a[0][1] == 2 and h.to_a[1][1] == 2
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
(defun d ()
  (let* ((n (read))
         (arr (make-array (1+ n) :initial-element -1))
         (res (make-array (1+ n) :initial-element -1)))
    (dotimes (i n)
      (let ((x (read)))
        (setf (aref arr (1+ i)) x)))
    (loop for i from n downto 1
       do
         (setf (aref res i)
               (if (= (aref arr i)
                      (mod (loop for j from i to n by i
                              when (> j i)
                              sum (aref res j))
                           2))
                   0
                   1)))
    (let ((sum
           (loop for i below n
              sum (aref res (1+ i)))))
      (format t "~a~%" sum)
      (when (> sum 0)
        (loop for i below n
           do
             (when (> (aref res (1+ i)) 0)
                (format t "~a " (1+ i))))))))

(d)

Measured memory_bytes: 62276
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AOJ problem = new AOJ(sc);
        problem.solve(out);

        out.flush();
    }

}

class AOJ {

    int x, y;

    AOJ(FastScanner sc) {
        x = sc.nextInt();
        y = sc.nextInt();
    }

    void solve(PrintWriter out) {
        out.println(gcd(x, y));
    }

    long gcd(long m, long n) {
        long rem;
        while ((rem = m % n) != 0) {
            m = n;
            n = rem;
        }
        return n;
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}



Measured memory_bytes: 24376
import java.io.*
import java.util.*

fun solve(n: Int, a: IntArray){
    // 1, (2,1), (3,1,2),  (4,2,1,3), (5, 3, 1, 2, 4)
    val deque = ArrayDeque<Int>()
    for (i in 0 until n){
        if (i % 2 == 0) deque.add(a[i])
        else deque.addFirst(a[i])
    }
    if (n % 2 == 0) println(deque.joinToString(separator=" "))
    else println(deque.reversed().joinToString(separator=" "))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val n = sc.next().toInt()
    val a = IntArray(n.toInt())
    for (i in 0 until n.toInt()) {
        a[i] = sc.next().toInt()
    }
    solve(n, a)
}



Measured memory_bytes: 81396
(n,s),a,b=$<.map{_1.split.map &:to_i}
b.reverse!
n.times{|i|$*[v=a[i]]||=i;v!=b[i]||(s=v;$r=i)}
s&&b=(t=[s])*(k=[$*[s],b[..$r].count(s)].min)+(b-t)+t*=b.count(s)-k
puts (0...n).any?{a[_1]==b[_1]}?:No:[:Yes,b]
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################

Measured memory_bytes: 55240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>a[1000];
	vector<ll>st;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n-1;j++){
			ll x;
			cin>>x;
			x--;
			a[i].push_back(x);
		}
		reverse(a[i].begin(),a[i].end());
		st.push_back(i);
	}
	ll cnt=0;
	while(st.size()!=0){
		cnt++;
		bool ok[1000]={false};
//		cout <<cnt<<endl;
		while(st.size()!=0){
			ll now=st.back();
			st.pop_back();
			ll next=a[now].back();
			if(ok[now]||ok[next]){
				continue;
			}
			if(a[next].back()==now){
				ok[now]=true;
				ok[next]=true;
				a[now].pop_back();
				a[next].pop_back();
			}
		}
		for(ll i=0;i<n;i++){
		//	cout << i <<ok[i]<<endl;
			if(ok[i]==true&&a[i].size()!=0){
				st.push_back(i);
			}
		}
	}
	for(ll i=0;i<n;i++){
		if(a[i].size()){
			cout <<-1;
			return 0;
		}
	}
	cout << cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 8320
private class B {
    fun solve() {
        val n = nextInt()
        val d = nextInt()
        val d2 = d * 1L * d
        var count = 0;
        for (i in 0 until n) {
            val x = nextLong()
             val y = nextLong()
            if (x * x + y * y <= d2) {
                count++
            }
        }
        println(count)
    }

    var tokenBuffer = listOf<String>()
    var bufferPosition = 0

    private fun checkBuffer() {
        if (bufferPosition == tokenBuffer.size) {
            tokenBuffer = nextLine().split(" ")
            bufferPosition = 0
        }
    }

    fun nextLine() = readLine()!!
    fun nextInt(): Int {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toInt()
    }

    fun nextLong(): Long {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toLong()
    }

    fun nextDouble(): Double {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toDouble()
    }

    fun nextToken(): String {
        checkBuffer()
        return tokenBuffer[bufferPosition++]
    }
}

fun main() {
    val reader = B().solve()

}


Measured memory_bytes: 61480
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define int long long // LEMBRAR DE TROCAR CASO PROBLEMA DE MEMORIA
#define pii pair<int,int>
#define ieps (int) 1e6
#define eps (int) 1e9
#define mp make_pair
#define pb push_back
char mat[101][101];
bool vis[101][101];

int32_t main(){
	/*ios::sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	*/
	int a , b;
	int ww , kk;
	
		for(int i = 0 ; i < 100 ; i++)
			for(int j = 0 ; j < 100 ; j++) mat[i][j] = '#';
	cin>>a>>b;
	ww = a , kk = b;
	b--;
	cout<<100<<" "<<100<<endl;
	for(int i = 99 ; i >= 0 ; i-=4){
	for(int j = 99 ; j >= 0 ; j-= 4){
			if(a != 0 && b!= 0){
				a-- , b--;
				mat[i][j] = '.';
				mat[i][j-1] = '.';
				mat[i][j-2] = '.';
				mat[i-1][j] = '.';
				mat[i-1][j-1] = '#';
				mat[i-1][j-2] = '.';
				mat[i-2][j] = '.';
				mat[i-2][j-1] = '.';
				mat[i-2][j-2] = '.';
			}
		}
	}
for(int i = 0 ; i < 100 ; i+=2){
		for(int j = 0 ; j  < 100 ; j++){
			if(a && j %2 == 0){
				a-- ; 
				mat[i][j] = '.';
			}
		}
	}
	if(b){
		for(int i = 0 ; i < 100 ; i++)
			for(int j = 0 ; j < 100 ; j++) mat[i][j] = '.';
		a = ww , b = kk;
		a--;
	for(int i = 99 ; i >= 0 ; i-=4){
	for(int j = 99 ; j >= 0 ; j-= 4){
			if(a != 0 && b!= 0){
				a-- , b--;
				mat[i][j] = '#';
				mat[i][j-1] = '#';
				mat[i][j-2] = '#';
				mat[i-1][j] = '#';
				mat[i-1][j-1] = '.';
				mat[i-1][j-2] = '#';
				mat[i-2][j] = '#';
				mat[i-2][j-1] = '#';
				mat[i-2][j-2] = '#';
			}
		}
	}
	for(int i = 0 ; i < 100 ; i+=2){
		for(int j = 0 ; j  < 100 ; j++){
			if(b && j %2 == 0){
				b-- ; 
				mat[i][j] = '#';
			}
		}
	}	
	for(int i = 0 ; i < 100 ; i++){
			for(int j = 0 ; j < 100 ; j++){
				if(mat[i][j] == '#') cout<<"#";
				else cout<<".";
			}
			cout<<endl;
	}
	return 0;
	}
	for(int i = 0 ; i < 100 ; i++){
			for(int j = 0 ; j < 100 ; j++){
				if(mat[i][j] == '.') cout<<".";
				else cout<<"#";
			}
			cout<<endl;
	}	
	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int main(){
    string s; cin >> s;
    bool ok = true;
    for(int i=0; i<6; ++i){
        if(s[2]!=s[3]){ok = false; break;}
        if(s[4]!=s[5]){ok = false; break;}
    }
    if(ok){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cout.tie(NULL);cout.tie(NULL);
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<ll>
const ll MAX=1e6;
const ll mod=1e9+7;
const ll inf=1e18+12;
set< pair<ll,ll> >ss;

ll arr[MAX];
                                                              //SAMEER KUMAR SINGH//
//================================================================================================================================//

int main(){
   FASTIO;
   ll tt=1;
   //cin>>tt;

   while(tt--){
        ll n,w;cin>>n>>w;

        ll a[2][n+1];
        for(ll i=1;i<=n;i++){
          cin>>a[0][i]>>a[1][i];
        }

        ll ans[n+1][w+1];

        for(ll i=0;i<w+1;i++)
         ans[0][i]=0;

        for(ll i=0;i<n+1;i++)
         ans[i][0]=0;

        for(ll i=1;i<n+1;i++){
          for(ll j=1;j<w+1;j++){
            if(j<a[0][i])
            ans[i][j]=ans[i-1][j];
            else{
              ans[i][j]=max(ans[i-1][j],ans[i-1][j-a[0][i]]+a[1][i]);
            }
          }
        }

       cout<<ans[n][w]<<"\n";

   }

   return 0;
}


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

int main(){
    int N;
    cin >> N;
    int X[N];
    int c[N];
    for(int i=0;i<N;i++){
        cin >> X[i];
        c[i] = X[i];
    }
    sort(c,c+N);
    for(int i=0;i<N;i++){
        int* low = lower_bound(c,c+N,X[i]);
        int l;
        if((N-1)%2==1){
            l = N/2-1;
        }else {
            l = (N-1)/2-1;
        }
        if(l<(low-c)){
            cout << c[l]<<"\n";
        }else {
            cout << c[l+1] <<"\n";
        }



        /*
        int p[N-1];
        for(int j=0;j<i;j++){
            p[j] = X[j];
        }
        for(int j=i+1;j<N;j++){
            p[j-1] = X[j];
        }
        sort(p,p+N-1);
        if((N-1)%2==1){
            cout << p[N/2-1] <<"\n";
        }else {
            cout << p[(N-1)/2-1] <<"\n";
        }
*/
    }

}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,a[N];
priority_queue<int>q;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],q.push(a[i]);
	for(int i=1;i<=n;i++){
		if(q.top()==a[i]){
			q.pop();
			cout<<q.top()<<endl;
			q.push(a[i]);
		}else cout<<q.top()<<endl;
	}

	return 0;
}

Measured memory_bytes: 3316
import re

N = int(input())
A = list(map(lambda x: bin(int(x))[2:], input().split()))
B = list(map(lambda x: bin(int(x))[2:], input().split()))
keta = max(max(map(len, A)), max(map(len, B)))


def xor(a, b):
    while keta > len(b):
        b = '0' + b
    while keta > len(a):
        a = '0' + a
    ret = ''
    for a_, b_ in zip(a, b):
        ret += '0' if a_ == b_ else '1'
    return ret


def create_table(pattern):
    table = [0 for _ in range(len(pattern)+1)]
    j = 0
    for i in range(1, len(pattern)):
        if pattern[i] == pattern[j]:
            j += 1
            table[i] = j
        else:
            table[i] = j
            j = 0
    table[i+1] = j
    return table


def kmp_search(string, pattern):
    ret = []
    table = create_table(pattern)
    i = j = 0
    while i < len(string):
        if string[i] == pattern[j]:
            i += 1
            j += 1
        elif j == 0:
            i += 1
        else:
            j = table[j]
        if j == len(pattern):
            ret.append(i - j)
            j = table[j]
    else:
        return ret

def bm_search(string, pattern):
    ret = []
    pat_len = len(pattern)
    skip = [pat_len for _ in range(256)]
    for i in range(pat_len):
        skip[ord(pattern[i])] = pat_len - i - 1
    i = pat_len - 1
    while i < len(string):
        j = pat_len - 1
        while string[i] == pattern[j]:
            if j == 0:
                ret.append(i)
            i -= 1
            j -= 1
        i = i + max(skip[ord(string[i])], pat_len-j)
    return ret


C, D = [], []
for i in range(N-1):
    C.append(xor(A[i], A[i+1]))
    D.append(xor(B[i], B[i + 1]))
C.append(xor(A[-1], A[0]))
D.append(xor(B[-1], B[0]))
for k in kmp_search(D + D, C)[::-1]:
    if k == 0:
        continue
    print(N-k, int(xor(A[N-k], B[0]), 2))


Measured memory_bytes: 219172
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

std::vector<std::vector<LL>>G;
std::vector<LL>topological_sort(LL V)
{
	std::vector<LL>h(V + 1);
	for (LL i = 1; i <= V; ++i) for (auto e : G[i]) ++h[e];

	std::stack<LL>st;
	std::vector<LL>ans;
	for (LL i = 1; i <= V; ++i) if (h[i] == 0) st.push(i);
	while (!st.empty())
	{
		LL v = st.top(); st.pop();
		ans.push_back(v);
		for (auto u : G[v])
		{
			--h[u];
			if (h[u] == 0) st.push(u);
		}
	}

	return ans;
}

int main()
{
	LL N, M;
	in >> N >> M;
	std::vector<LL>A(N - 1 + M), B(N - 1 + M);
	rep(i, N - 1 + M) in >> A[i] >> B[i];

	G.resize(N + 1);
	std::map<LL, LL>rev;
	rep(i, N - 1 + M) G[A[i]].push_back(B[i]);
	auto sortedVs = topological_sort(N);
	rep(i, N) rev[sortedVs[i]] = i;

	std::vector<LL>ans(N + 1, sortedVs[0]);
	ans[sortedVs[0]] = 0;
	rep(i, N - 1 + M) if (rev[ans[B[i]]] < rev[A[i]]) ans[B[i]] = A[i];

	for (LL i = 1; i <= N; ++i) out << ans[i] << std::endl;
}


Measured memory_bytes: 15716
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int solve(){
  int n;
  pair<int,int> counter[26] = {};
  char c[SIZE];
  scanf("%d", &n);

  if(n == 0) return false;
  
  for(int i=0;i<n;i++){
    scanf(" %c", c+i);
  }

  for(int i=0;i<26;i++) counter[i] = {0,i};
  
  for(int i=0;i<n;i++){
    for(int j=0;j<26;j++)
      if(counter[j].second == c[i]-'A') counter[j].first--;

    sort(counter, counter+26);
    if(-counter[0].first > -counter[1].first + (n-i-1)){
      printf("%c %d\n", 'A'+counter[0].second, i+1);
      return true;
    }
  }
  
  puts("TIE");
  return true;
}

int main(){
  while(solve());
  
  return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

int main(void)
{
	int n, a, b;
	cin >> a >> b;
	if (b % a == 0) {
		cout << a + b << endl;
	} else {
		cout << b - a << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
def gcd(x, y):
    r = modlog(x, y)
    while r != 0:
        x = y
        y = r
        r = modlog(x, y)
    return y

def modlog(x, y):
    r = x % y
    return r

if __name__ == '__main__' :
    N,X = map(int, input().split())
    x = list(map(int, input().split()))

    dist_list = [abs(d-X) for d in x]

    if len(dist_list) == 1:
        print (dist_list[0])
        exit()
        
    alpha = gcd(dist_list[0],dist_list[1])
    for d in dist_list:
        alpha = gcd(alpha,d)

    print(alpha)        


Measured memory_bytes: 14224
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};



int main() {
	int n, m;
	cin >> n >> m;
	int *a = new int[m];
	int *b = new int[m];
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i]; 
		a[i]--;
		b[i]--;
	}

	UnionFind bridge(n);
	long long *ans = new long long[m+1];
	ans[m] = 0;
	for (int i = m - 1; i >= 0; i--) {
		if (bridge.findSet(a[i],b[i]) == false) {
			ans[i] = ans[i + 1] + bridge.size(a[i])*bridge.size(b[i]);
			bridge.unionSet(a[i], b[i]);
		}
		else {
			ans[i] = ans[i + 1];
		}
	}
	for (int i = 1; i < m+1; i++) {
		cout << ans[0] - ans[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 3328
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    let ans = if s.chars().enumerate().any(|(i, c)| {
        if (i + 1) % 2 == 0 {
            c != 'L' && c != 'U' && c != 'D'
        } else {
            c != 'R' && c != 'U' && c != 'D'
        }
    }) {
        "No"
    } else {
        "Yes"
    };
    println!("{}", ans);
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

const long long MOD = 1000000007;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void solve(long long n, long long k, std::vector<long long> a){
    COMinit();
    // cout << COM(100000, 50000) << endl;

    int ans=0;
    sort(ALL(a));
    Vi sum=a;
    accum(sum);
    if(k==1){
        cout<<0<<endl;
        return;
    }
    REP(j,k-1,n){
//        cout<<j<<" "<<sum[n-1]<<" "<<sum[j-1]<<" "<<sum[n-j-1]<<"  "<<sum[n-1]-sum[j-1]-sum[n-j-1]<<endl;
//        cout<<COM(j-1,k-2)<<endl;
        ans = (ans+(sum[n-1]-sum[j-1]-sum[n-j-1])%MOD * COM(j-1,k-2)%MOD)%MOD;
    }
    cout<<ans<<endl;
}

// 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)
signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 13824
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var A = input[0];
        var B = input[1];
        var C = input[2];
        var K = int.Parse(Console.ReadLine());

        var count = 0;
        while (A >= B)
        {
            count++;
            B *= 2;
        }
        while (B >= C)
        {
            count++;
            C *= 2;
        }
        Console.WriteLine(count <= K ? "Yes" : "No");
    }
}


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

int main() {
    int a, b; cin >> a >> b;
    if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) {
        cout << "Possible" << endl;
    }

    else cout << "Impossible" << endl;

    return 0;
}


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

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if (a + b == c || b + c == a || c + a == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
c = [0 for _ in range(a)]
for i in range(1, a + 1):
    d = i
    for e in b:
        while d % e == 0:
            c[e - 1] += 1
            d //= e
    if d != 1:
        c[d - 1] += 1
f = 1
g = 10 ** 9 + 7
for h in c:
    f *= (h + 1)
    f %= g
print(f)

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

using namespace std;
#define ll long long
#define r(i, n) for(int i=0;i<n;i++)

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    r(i, n) cin >> v[i];
    int q, x, p;
    cin >> q;
    while (q--) {
        cin >> x;
        p = lower_bound(v.begin(), v.end(), x) - v.begin();
        cout << p << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#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 dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int n,m;cin >> n >> m;
    vector<int> G[n+1];
    vector<P> v;
    for (int i = 0; i < m; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        G[x].pb(y);
        v.pb(mp(x,y));
    }
    vector<int> ans(n+1);
    vector<int> vis(n+1,-1);
    for (int i = 0; i < m; i++) {
        int x = v[i].fs, y = v[i].sc;
        vector<int> dp(n+1,-1);
        queue<int> q;
        q.push(y);
        while(!q.empty()){
            int s = q.front();q.pop();
            if(vis[s] >= i) continue;
            vis[s] = i;
            if(s==x){
                int u = x;
                vector<int> t;
                while(u != y){
                    t.pb(u);
                    u = dp[u];
                }
                t.pb(y);
                if(t.size() < ans.size()){
                    reverse(ALL(t));
                    ans = t;
                }
                break;
            }
            for(auto g:G[s]){
                q.push(g);
                if(dp[g] == -1) dp[g] = s;
            }
        }
    }
    if(ans.size()==n+1) puts("-1");
    else{
        cout << ans.size() << endl;
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i] + 1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<=(n);i++)
#define mer(i,m,n) for(int i=(m);i>=(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;


int main() {
	int k;
	cin >>k;
	if(k%2==0||k%5==0){
		cout << -1 <<'\n';
		return 0;
	}
	ll ans = 1,now = 7;
	while(1){
		if(now%k==0)break;
		++ans;
		now = now*10+7;
		now %= k;
	}
	cout << ans <<'\n';
	return 0;
}


Measured memory_bytes: 3640