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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

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

    string ans = "";
    REP(i,N) ans += "-";

    REP(i,M){
        int s;
        char c;
        cin >> s >> c;
        if(ans[s-1]!='-'&&ans[s-1]!=c){
            cout << "-1" << endl;
            return 0;
        }
        ans[s-1] = c;
    }


    REP(i,N){
        if(N!=1&&i==0&&ans[i]=='-') ans[i]='1';
        if(ans[i]=='-')ans[i]='0';
    }

    if(ans.size()!=1&&ans[0]=='0') ans = "-1";
    cout << ans << endl;
    return 0;

}



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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int k, a, b;
    cin>>k>>a>>b;
    ll ans = (b/k)*k;
    if(ans <= b && ans >= a)
        cout<<"OK\n";
    else
        cout<<"NG\n";
    return 0;
}

Measured memory_bytes: 3644
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if (c-b==b-a) printf("YES");
	    else printf("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int num = 1;
    for (int i = 0; i < n; ++i) {
        int v1 = num * 2;
        int v2 = num + k;
        if (v1 < v2)
            num = v1;
        else
            num = v2;
    }
    cout << num << '\n';
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
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())
struct bity
{
	#define d 63
	vector<ll> wek;
	bity(){}
	bity(int v)
	{
		wek.resize((v/d)+2, 0);
	}
	void upper(int v)
	{
	    while(wek.size() < (v/d)+2) wek.pb(0);
	}
	void upp(int v){
	    while(wek.size() < v) wek.pb(0);
	}
	void ustaw(int v)
	{
		wek[v/d]|=(1LL<<(v%d));
	}
	void zeruj()
	{
		fill(wek.begin(), wek.end(), 0);
	}
	int licz()
	{
		int ret=0;
		for (const ll &i : wek)
			ret+=__builtin_popcountll(i);
		return ret;
	}
};
 
void oruj(bity &a, const bity &b)
{
	int r=min(a.wek.size(), b.wek.size());
	for (int i=0; i<r; i++)
		a.wek[i]|=b.wek[i];
}

int n;
char f[505][505];
bity B[10][505];
ll ans;
int C[10];
int cur[10];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",&f[i]);
	rep(i,n)rep(j,n)if(f[i][j]!='#')C[f[i][j]-'0']++;
	repn(x,9) rep(i,n) B[x][i] = bity(0);
	for(int i=0;i<2*n-1;i++){
		for(int j=min(i,n-1);j>=max(0,i-n+1);j--){
			int x = j, y = i-j;
			if(f[x][y] != '#'){
			    B[f[x][y]-'0'][x].upper(cur[f[x][y]-'0']+1);
			    repn(w,9) B[w][x].upp(B[w][x-1].wek.size());
				if(x){
				    repn(w,9) oruj(B[w][x],B[w][x-1]);
				}
				repn(w,9) ans += 1LL*w*(f[x][y]-'0')*(B[w][x].licz());
				B[f[x][y]-'0'][x].ustaw(cur[f[x][y]-'0']++);
			}
			else{
			    repn(w,9) B[w][x].upp(B[w][x-1].wek.size());
				repn(w,9) B[w][x].zeruj();
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 19712
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

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

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

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

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

    lint n, k;
    cin >> n >> k;

    lint ans = (n / k) * (n / k) * (n / k);
    if(k % 2LL == 0LL){
        if(n % k >= k / 2LL){
            ans += (n / k + 1LL) * (n / k + 1LL) * (n / k + 1LL);
        }else{
            ans += (n / k) * (n / k) * (n / k);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(){
  int i;
  char S[50], T[50], ans = 'y';
  scanf("%s %s", S, T);
  for (i = 0; S[i] != '\0'; i++) {
    if (S[i] != T[i]) {
      ans = 'n';
      break;
    }
  }
  if (T[i + 1] != '\0') ans = 'n';
  if (ans == 'y') printf("Yes");
  else            printf("No");
  return 0;
}


Measured memory_bytes: 1728
N,M,K = map(int,input().split())
MOD = 998244353

class Combination:
  def __init__(self, n_max, mod=998244353):
    self.mod = mod
    self.modinv = self.make_modinv_list(n_max)
    self.fac, self.facinv = self.make_factorial_list(n_max)

  def __call__(self, n, r):
    return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

  def make_factorial_list(self, n):
    # 階乗のリストと階乗のmod逆元のリストを返す O(n)
    # self.make_modinv_list()が先に実行されている必要がある
    fac = [1]
    facinv = [1]
    for i in range(1, n+1):
      fac.append(fac[i-1] * i % self.mod)
      facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
    return fac, facinv

  def make_modinv_list(self, n):
    # 0からnまでのmod逆元のリストを返す O(n)
    modinv = [0] * (n+1)
    modinv[1] = 1
    for i in range(2, n+1):
      modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
    return modinv

comb = Combination(2*10**5)

res = 0
for x in range(K+1):
  res += (M * pow(M-1, N-x-1, MOD)%MOD * comb(N-1, x)%MOD)%MOD
  res %= MOD

print(res % MOD)

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

int main(){
	int n;
	cin >> n;
	vector<string> data1, data2;
	vector<string> strSameValuePair;
	string s;
	for (int i=0; i<n; i++){
		cin >> s;
		data1.push_back(s);
		data2.push_back(s);
	}
	for (int i=0; i<n; i++){
		for (int j=i; j<n; j++){
			if (data1[j].substr(1,1) == data1[i].substr(1,1)){
				strSameValuePair.push_back(data1[i]);
				strSameValuePair.push_back(data1[j]);
			}
		}
	}
	
	// Bubble Sort
	for (int i=0; i<n; i++) {
		for (int j=n-1; j>i; j--){
			if (data1[j].substr(1,1) < data1[j-1].substr(1,1)){
				swap(data1[j], data1[j-1]);
			}
		}
	}
	int mini;	
	// Selection Sort
	for (int i=0; i<n; i++){
		mini = i;
		for (int j=i+1; j<n; j++) {
			if (data2[j].substr(1,1) < data2[mini].substr(1,1)) {
				swap(j, mini);
			}
		}
		if (mini != i){
			swap(data2[i], data2[mini]);
		}
	}
	
	for (int i=0; i<n-1; i++){
		cout << data1[i] << " ";
	}
	cout << data1[n-1] << endl;
	int pairCount = strSameValuePair.size();
	int foundCount;
	int i1, i2;
	int stable = 1;
	for (int i=0; i<pairCount; i+=2){
		foundCount = 0;
		for (int j=0; j<n; j++){
			if (foundCount == 2){
				break;
			}
			if (data1[j] == strSameValuePair[i]){
				foundCount++;
				i1 = j;
			}
			else if (data1[j] == strSameValuePair[i+1]){
				foundCount++;
				i2 = j;
			}
		}
		if (foundCount == 2){
			if (i1 > i2){
				stable = 0;
				break;
			}
		}
	}
	if (stable){
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
	
	for (int i=0; i<n-1; i++){
		cout << data2[i] << " ";
	}
	cout << data2[n-1] << endl;

	stable = 1;
	for (int i=0; i<pairCount; i+=2){
		foundCount = 0;
		for (int j=0; j<n; j++){
			if (foundCount == 2){
				break;
			}
			if (data2[j] == strSameValuePair[i]){
				foundCount++;
				i1 = j;
			}
			else if (data2[j] == strSameValuePair[i+1]){
				foundCount++;
				i2 = j;
			}
		}
		if (foundCount == 2){
			if (i1 > i2){
				stable = 0;
				break;
			}
		}
	}
	if (stable){
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
	return 0;
}


Measured memory_bytes: 3152
import java.util.*;
public class Main {
    public static void call(int n){
        int i = 1;
        do {
            int x = i;
            if ( x % 3 != 0 ){
                while( x != 0 ){
                    if ( x % 10 == 3 ){
                        System.out.printf(" %d", i);
                        break;
                    }
                    x /= 10;
                }
            } else {
                System.out.printf(" %d", i);
            }
        } while(++i <= n);
        System.out.println();
    }
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        call(n);
    }
}


Measured memory_bytes: 38268
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n")
  tmp0 = input[0].split(" ")
  N = Number(input[0])
  S = input[1]
  K = Number(input[2])

  c = S[K-1]
  ans = []
  for(var i=0; i < N; i++)
  {
    if(S[i] !== c)
    {
      ans.push('*')
    }else{
      ans.push(S[i])
    }
  }
  console.log(ans.join(""))
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("5\nerror\n2")

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int ret;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>x;
		ret+=min(x,K-x)*2;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){ 
  int n;
  std::cin >> n;
  string a,b,c;
  std::cin >> a>>b;
  rep(i,a.size()){
    c.pb(a[i]);
    c.pb(b[i]);
  }
  std::cout << c << std::endl;
}

Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline())
a = list(int(sys.stdin.readline()) for i in range(N))
count = 0
index = 1
while count <= N:
    lump = a[index - 1]
    count += 1
    if lump == 2:
        print(count)
        exit()
    else:
        index = lump
print(-1)

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

template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);

struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator << (pair<c, d> e) {
	return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator << (c a) {
	cerr << boolalpha << a;
	return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator << (c a) {
	*this << "[";
	for (auto it = a.begin(); it != a.end(); ++it)
		*this << ","[1 - (it != a.begin())] << *it;
	return *this << "]";
}
#else
template<class c> debug& operator << (c) {
	return *this;
}
#endif
};

#define aty(x) " [" << #x ": " << x << "] "

using ll = long long;






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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int INF = (1 << 30);
const int N = 100005;
struct Card
{
	char suit;
	int value;
} card[N], t[N];
Card L[N / 2 + 1], R[N / 2 + 1];

void _merge(Card a[], int l, int m, int r)	//[l, r)
{
	int i, j, k;
	int n1 = m - l;
	int n2 = r - m;
	for (i = 0; i < n1; ++i)
		L[i] = a[l + i];
	for (i = 0; i < n2; ++i)
		R[i] = a[m + i];
	L[n1].value = R[n2].value = INF;
	i = j = 0;
	for (k = l; k < r; ++k)
	{
		if (L[i].value <= R[j].value)
			a[k] = L[i++];
		else
			a[k] = R[j++];
	}
}

void _merge_sort(Card arr[], int l, int r)
{
	if (l + 1 >= r)
		return;
	int m = (l + r) / 2;
	_merge_sort(arr, l, m);
	_merge_sort(arr, m, r);
	_merge(arr, l, m, r);
}

int partition(Card arr[], int p, int r)	//[p, r)????????????,????????????pivot??????
{
	int pivot = arr[r - 1].value;
	int i = p;
	for (int j = p; j < r - 1; ++j)
	{
		if (arr[j].value <= pivot)
		{
			swap(arr[i++], arr[j]);
		}
	}
	swap(arr[i], arr[r - 1]);
	return i;
}

void q_sort(Card arr[], int l, int r)
{
	if (l + 1 < r)
	{
		int t = partition(arr, l, r);
		q_sort(arr, l, t);
		q_sort(arr, t, r);
	}
}

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> card[i].suit >> card[i].value;
		t[i] = card[i];
	}
	q_sort(card, 0, n);
	_merge_sort(t, 0, n);
	bool flag = true;
	for (int i = 0; i < n; ++i)
	{
		if (card[i].suit != t[i].suit)
		{
			flag = false;
			break;
		}
	}
	if (flag)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;

	for (int i = 0; i < n; ++i)
		cout << card[i].suit << ' ' << card[i].value << endl;

	return 0;
}

Measured memory_bytes: 5432
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

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

int main(void) {
    int A, B; cin >> A >> B;
    int ans = A*B;
    if (A < 1 || 9 < A) {
        ans = -1;
    }
    if (B < 1 || 9 < B) {
        ans = -1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
a=[list(map(int,input().split())) for _ in range(3)]
c=[[False]*3 for _ in range(3)]

n=int(input())
for i in range(n):
    b=int(input())
    for g in range(3):
        for l in range(3):
            if b==a[g][l]:
                c[g][l]=True

if c[0][0] is True and c[1][1] is True and c[2][2] is True:
    print("Yes")
    exit()

if c[0][2] is True and c[1][1] is True and c[2][0] is True:
    print("Yes")
    exit()

for i in range(3):
    if c[i]==[True]*3:
        print("Yes")
        exit()

for i in range(3):
    if c[0][i] is True and c[1][i] is True and c[2][i] is True:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string S;
    ll K;
    cin >> S >> K;
    int firstover1 = -1;
    for (int i = 1; i <= S.size(); i++) {
        if (S[i-1] > '1') {
            firstover1 = i;
            break;
        }
    }
    if (K < firstover1 || firstover1 == -1) {
        cout << 1 << endl;
    } else {
        cout << S[firstover1-1] << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<double> x(N);
  vector<double> y(N);
  vector<vector<double>> dist(N, vector<double>(N));
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      dist[i][j] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
    }
  }
  
  double d = 0;
  for(int i = 0; i < N; i++){
    for(int j = i; j < N; j++){
      d += dist[i][j];
    }
  }
  
  cout << setprecision(16) << d * 2 / (double)N << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    string s;
    cin>>k;
    cin>>s;
    if(s.size() <= k) cout<<s<<endl;
    else{
        for(int i = 0; i<k; i++) cout<<s[i];
        cout<<"..."<<endl;
    }
}



Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10 ** 7)

n, a, b, c = map(int, input().split())
s = [input() for _ in range(n)]

ans = []

d = {"A": a, "B": b, "C": c}


def dfs(i):
    if min(d.values()) < 0:
        return

    if i == n:
        print("Yes")
        print(*ans, sep="\n")
        exit()

    for j in range(2):
        add = s[i][j]
        sub = s[i][1-j]
        d[add] += 1
        d[sub] -= 1
        ans.append(add)
        dfs(i + 1)
        d[add] -= 1
        d[sub] += 1
        ans.pop()


dfs(0)

print("No")


Measured memory_bytes: 110900
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int maxn = 1e5 + 3;
int n,m,dp[maxn];
vector<int> graph[maxn];
bool visited[maxn];

int solve(int node)
{
    //No base case as all calls are surely from 1 to n so no invalid calls.
    if(dp[node] != -1)
        return dp[node];
    int ans = 0;
    for(auto elem : graph[node])
    {
        ans = max(ans, 1 + solve(elem));
    }
    return dp[node] = ans;
}
int main()
{
    IO;
    cin >> n >> m;
    memset(visited, false, sizeof maxn);
    memset(dp, -1, sizeof dp);
    for(int i = 0; i < m; i++)
    {
        int x,y;
        cin >> x >> y;
        graph[x].push_back(y);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        if(dp[i] == -1)
            ans = max(ans,solve(i));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8192
import math
import itertools

N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i] and L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]:
                ans += 1
print(ans)


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

using namespace std;

int n;
int a[15], ans;
pair <int, int> x[15][15];

bool check(int a[]) {
	for (int i = 0; i < n; ++i) 
		for (int j = 0; j < ::a[i]; ++j)
			if (a[i] == 1 && (x[i][j].second != a[x[i][j].first - 1]))
				return false;

	return true;
}

void iterate(int a[], int c) {
	if (c == n) {
		if (check(a)) {
			int t = 0;

			for (int i = 0; i < n; ++i)
				if (a[i] == 1)
					++t;

			ans = max(ans, t);
		}

		return;
	}

	int b[c + 1];
	for (int i = 0; i < c; ++i)
		b[i] = a[i];

	b[c] = 0;
	iterate(b, c + 1);
	b[c] = 1;
	iterate(b, c + 1);
}

int main() {
	cin >> n;

	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		for (int j = 0; j < a[i]; ++j)
			cin >> x[i][j].first >> x[i][j].second;
	}

	int arr[0];
	iterate(arr, 0);

	cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    cout << n*n*n << endl;
}

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

int main()
{
    int n; scanf("%d", &n);
    std::vector<int> a(n+1), b(n);
    long long count = 0;

    for (int i=0; i<n+1; i++) scanf("%d", &a.at(i));
    for (int i=0; i<n; i++)   scanf("%d", &b.at(i));

    for (int i=n-1; i>=0; i--)
    {
        if (a.at(i+1) <= b.at(i))
        {
            count += a.at(i+1);
            b.at(i) -= a.at(i+1);
            a.at(i+1) = 0;
        }
        else
        {
            count += b.at(i);
            a.at(i+1) -= b.at(i);
            b.at(i) = 0;
        }
        
        if (a.at(i) <= b.at(i))
        {
            count += a.at(i);
            b.at(i) -=  a.at(i);
            a.at(i) = 0;
        }
        else 
        {
            count += b.at(i);
            a.at(i) -= b.at(i);
            b.at(i) = 0;
        }
        //std::cout << count << std::endl;
    }

    std::cout << count << std::endl;
}

Measured memory_bytes: 4068
#include <stdio.h>
 
int main(){
  long long int A, B, r, p, tmp;
  scanf("%lld %lld", &A, &B);
 
  p = A * B;
 
  if(A < B){
    tmp = A;
    A = B;
    B = tmp;
  }
 
  r = A % B;
  while(r != 0){
    A = B;
    B = r;
    r = A % B;
  }
 
  printf("%lld", p/B);
 
  return 0;
}

Measured memory_bytes: 128
from collections import deque
import sys
readline = sys.stdin.readline

N = int(readline())
G = [[] for i in range(N)]
for i in range(N-1):
    a, b, c = map(int, readline().split())
    G[a-1].append((b-1, c))
    G[b-1].append((a-1, c))

used = [0]*N
que = deque([0])
used[0] = 1
ans = [0]*N
while que:
    v = que.popleft()
    l = ans[v]
    for w, c in G[v]:
        if used[w]:
            continue
        if c % 2:
            ans[w] = l^1
        else:
            ans[w] = l
        que.append(w)
        used[w] = 1
print(*ans, sep='\n')

Measured memory_bytes: 41484
#include<iostream>
#include<algorithm>
using namespace std;
int n,s[100000],t[300000+1];
int main()
{
    cin>>n;
    int now=0;
    for(int i=0;i<n;i++)
        {
        cin>>s[i];
           for(int k=-1;k<=1;k++)
                t[s[i]+k]++;
        }
    int d = 0;
	for (int i = 0; i <= 300001; i++)
        {
		d = max(d, t[i]);
        }
    cout<<d;
}

Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

A_cnt = Counter(A)
tmp = sum([x-1 for x in A_cnt.values()])

print(len(A_cnt) if tmp%2 == 0 else len(A_cnt)-1)

Measured memory_bytes: 22932
import itertools

N = int(input())
P = ''.join(list(input().split()))
Q = ''.join(list(input().split()))

perms = [''.join(per) for per in itertools.permutations([str(n) for n in range(1, N + 1)], N)]
perms = sorted(perms)

l = perms.index(P)
r = perms.index(Q)
ma = max(l, r)
mi = min(l, r)
print(ma - mi)


Measured memory_bytes: 6296
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  double d, s, t;
  cin >> d >> s >> t;
  if (d / s <= t) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3736
#include<stdio.h>
#include<math.h>
int main(void){
    double x1,y1,x2,y2;
    double answer;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    answer=sqrt(fabs(x1-x2)*fabs(x1-x2)+fabs(y1-y2)*fabs(y1-y2));
    printf("%lf\n",answer);
    return 0;
}


Measured memory_bytes: 2028
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      
      int n = sc.nextInt();
      int k = sc.nextInt();
      
      int count = 0;
      for(int i = 0; i < n; i++) {
         if(k <= sc.nextInt()) {
            count++;
         }
      }
      System.out.println(count);
   }
}

Measured memory_bytes: 46428
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);

	if(x>0 && x/d>=k)
	{
		x=x-k*d;
		cout<<x;
		return 0;
	}
	else
	{
		ll temp=x/d;
		x=x-temp*d;
		k=k-temp;
		if(k%2==0)
			cout<<abs(x);
		else
			cout<<abs(min(x-d,x+d));
		return 0;
	}
	
	
}

Measured memory_bytes: 3648
import sys
N, X, M = map(int, input().split())
if N == 1:
  print(X)
  sys.exit()

ans = 0
ans += X - (X%M)
X %= M

def fun(x):
  return (x * x) % M

appear_list = [X]
appear_set = {X}

x = X
i_0 = 1
sum_0 = x

while fun(x) not in appear_set:
  x = fun(x)
  appear_list.append(x)
  appear_set.add(x)
  sum_0 += x
  i_0 += 1
  #print(appear_list, x, fun(x))
  #print(i_0, N, appear_set)
  if i_0 == N:
    print(ans + sum_0)
    sys.exit()

ans += sum_0
N -= i_0

x = fun(x)
appear_set_2 = {x}
sum_1 = x
sum_list = [0,x]
i_1 = 1
while fun(x) not in appear_set_2:
  x = fun(x)
  appear_set_2.add(x)
  sum_1 += x
  sum_list.append(sum_1)
  i_1 += 1
  
sum_0 -= sum_1
i_0 -= i_1

#print(N % i_1)
ans += sum_1 * (N // i_1) + sum_list[(N % i_1)]

print(ans)



  
  
  


Measured memory_bytes: 86940
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;
    static final int mod1 = 1073741824;

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static boolean prime[] = new boolean[1000001];

    public static void sieve() {
        int n = 1000000;

        Arrays.fill(prime, true);
        for (int j = 2; j * j <= n; j++) {
            if (prime[j] == true) {
                for (int i = j * j; i <= n; i += j) {
                    prime[i] = false;
                }
            }
        }
        /*for(int j=2;j<=n;j++)
        {
            if(prime[j]==true)
                System.out.println(j);
        }*/

    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        //Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        HashMap<Integer,Integer>hm=new HashMap<>();
        for(int j=0;j<n;j++) {
            a[j] = sc.nextInt();

        }
        Arrays.sort(a);
        long ans=0;
        for(int j=0;j<k;j++)
            ans+=a[j];
        System.out.println(ans);



    }
}




















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

const int mod=1000000007;

int main(){
    
    int N;cin>>N;
    vector<char> A(N),B(N);
    vector<long long int> S(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    int i=1;
    if(A[0]==B[0]) S[0]=3;
    else{
        S[0]=6;
        S[1]=6;
        i++;
    }
    for(;i<N;i++){
        if(A[i]==B[i]){
            if(A[i-1]==B[i-1]) S[i]=(S[i-1]*2)%mod;
            else S[i]=S[i-1];
        }else{
            if(A[i-1]==B[i-1]){
                S[i]=(S[i-1]*2)%mod;
                S[i+1]=S[i];
                i++;
            }else{
                S[i]=(S[i-1]*3)%mod;
                S[i+1]=S[i];
                i++;
            }
        }
    }
    cout<<S[N-1]<<endl;
}



Measured memory_bytes: 256
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
T = []
for q in range(Q):
    T.append(list(map(int, input().split())))

A = list(combinations_with_replacement(list(range(1, M+1)), N))
Alist = [list(a) for a in A]

#print(Alist)

Max = 0

for a in Alist:
    cost = 0
    for t in T:
        if a[t[1]-1] - a[t[0]-1] == t[2]:
            cost += t[3]
    if cost > Max:
        Max = cost
print(Max)

Measured memory_bytes: 35580
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int a[100050];
int n;
/*
inline bool all_same()
{
	for(int i=1;i<n;++i)
		if(a[i]!=a[i+1])
			return false;
	return true;
}
*/
inline void work()
{
	cin>>n;
	reg int mini=0x3f3f3f3f,maxi=0;
	for(int i=1;i<=n;++i)
		read(a[i]),mini=min(mini,a[i]),maxi=max(maxi,a[i]);
	if(mini>n-1)
	{
		puts("Yes");
		return;
	}
	// if(all_same())
	if(maxi==mini)
	{
		if(a[1]==1||a[1]==n-1)
		{
			puts("Yes");
			return;
		}
		if(a[1]<=n/2)
			puts("Yes");
		else
			puts("No");
		return;
	}
	if(maxi-mini>=2)
	{
		puts("No");
		return;
	}
	reg int cntmax=0,cntmin=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]==mini)
			++cntmin;
		if(a[i]==maxi)
			++cntmax;
	}
	if(mini<cntmin)
	{
		puts("No");
		return;
	}
	if(2*mini<n+cntmin-1)
	{
		puts("Yes");
		return;
	}
	puts("No");
	return;
}
signed main(void)
{
	// int t;cin>>t;
	// while(t--)
		work();
	return 0;
}



Measured memory_bytes: 640
#[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, 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!{
        n:usize,
        m:usize,
        s: [i64;n],
        t: [i64;m]
    }
    let modulo:i64 = 1_000_000_007;
    let mut dp:Vec<Vec<i64>> = vec![vec![0;m+2];n+2];
    dp[0][0] = 1;
    for i in 0..n+1 {
        for j in 0..m+1 {
            if i as i64-1 >= 0 && j as i64-1 >=0 && s[i-1]==t[j-1] {
                dp[i][j] += dp[i-1][j-1];
                dp[i][j]%=modulo;
            }
            if i as i64-1>=0 {
                dp[i][j]+=dp[i-1][j];
                dp[i][j]%=modulo;
            }
            if j as i64-1>=0 {
                dp[i][j]+=dp[i][j-1];
                dp[i][j]%=modulo;
            }
            if i as i64-1>=0 && j as i64-1>=0 {
                dp[i][j]-=dp[i-1][j-1];
                dp[i][j]%=modulo;
            }
        }
    }
    if dp[n][m] < 0 {
        dp[n][m]+=modulo;
    }
    // println!("{:?}", dp);
    println!("{}", dp[n][m]);
}

Measured memory_bytes: 45308
#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
long long dp[100005];

int main() {
  int n,m;
  cin >> n >>m;
  int st[m+1];
  int tmp;
  
  for(int i = 0; i < m;i++){
    cin >> tmp;
    dp[tmp] = -1;
  }
  dp[0] = 1;
  if(dp[1] != -1){dp[1] = 1;}
  else{dp[1] = 0;}
  for(int i = 2; i < n+1;i++){
    if(dp[i] == -1){
      dp[i] = 0;
    }else{
      dp[i] = dp[i-1] + dp[i-2];
      dp[i] %= mod;
      //cout << dp[i] << endl;
    }
  }

  cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root,*NIL;

  void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
 z->parent=y;

  if(y==NIL){
    root=z;
  }

  else{
    if(z->key < y->key){
      y->left=z;
    }

    else{
      y->right=z;
    }
  }
}

void inorder(Node *u){
    
  if(u==NIL) return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){

  if(u==NIL) return;

  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,a;
  
  string com;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    cin >> com;

    if(com=="insert"){
      scanf("%d",&a);
      insert(a);
    }

    else if(com=="print"){

      inorder(root);
      printf("\n");
     preorder(root);
     printf("\n");
   }
  }

  return 0;
}


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

int main(){
	int N,X;
	cin >> N >> X;
	vector<int> vec(N);
	for(size_t i = 0; i < vec.size(); ++i){
		cin >> vec[i];
	}
	int min = *min_element(vec.begin(), vec.end());
	int sum = accumulate(vec.begin(),vec.end(),0);
	cout << (X-sum)/min + N << endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long a, b;
    cin >> a >> b;
    
    while (b)
    {
        a %= b;
        swap(a, b);
    }
    
    set<long long> kek;
    for (long long i = 2; i * i <= a; ++i)
    {
        if (a % i == 0)
        {
            kek.insert(i);
            while (a % i == 0)
                a /= i;
        }
    }
    if (a != 1)
        kek.insert(a);
    
    cout << kek.size() + 1 << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define dbg(x) cerr << #x << ": " << x << endl
const ll INF = 1001001001;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> X(n);
  rep(i, n) cin >> X[i];
  ll ans = INF;
  rep(i, n - k + 1) {
    int xfirst = X[i], xlast = X[i + k - 1];
    ll now =
      (ll)xlast - xfirst + min(abs(xfirst), abs(xlast));
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  // �����Ƀv���O������ǋL
  int r,s;
  
  cin >> r >> s;
  // cin >> s ;

  if((r*s)%2 == 0){
	cout <<"Even"<< endl;
}else{
	cout << "Odd" <<endl;
}




  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    ll H, W, N;
    ll sr, sc;
    cin >> H >> W >> N;
    cin >> sr >> sc;
    string S, T;
    cin >> S;
    cin >> T;
    
    vector<ll> m(4);
    m[0] = sr;
    m[1] = W - sc + 1;
    m[2] = H - sr + 1;
    m[3] = sc;
    vector<ll> b(4), w(4);
    bool out = false;
    for (ll i = 0; i < N; i++) {
        if (S[i] == 'U') b[0] += 1;
        if (S[i] == 'R') b[1] += 1;
        if (S[i] == 'D') b[2] += 1;
        if (S[i] == 'L') b[3] += 1;
        
        for (int j = 0; j < 4; j++) {
            if (1 > w[j] + m[j] - b[j]) {
                out = true;
            }

            cerr << "(" << m[j] - b[j] << "," << w[j] << ") ";
        }
        cerr << endl;
        
        if (T[i] == 'D' && m[2] + b[0] - w[0] > 1) w[0] += 1;
        if (T[i] == 'L' && m[3] + b[1] - w[1] > 1) w[1] += 1;
        if (T[i] == 'U' && m[0] + b[2] - w[2] > 1) w[2] += 1;
        if (T[i] == 'R' && m[1] + b[3] - w[3] > 1) w[3] += 1;
        
        
        if (out) {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

const int MAX = 10000000;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/****** define constant end ********/
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;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
	if (n & 1)
	  res = res * a % mod;
	a = a * a % mod;
	n >>= 1;
  }
  return res;
}
/****** define variable start ******/
string s;
/******* define variable end *******/
int solve() {
	cin >> s;
	vector<ll> c(s.size()+1);
	c[s.size()] = 0;
	ll ans = 0;
	vector<ll> count(2019);
	REP(i, 2019){
		count[i] = 0;
	}
	count[0] = 1;
	for(ll i = s.size()-1; i >= 0; i--){
		ll tmp = (s.size() - i - 1);
		ll tmp2 = (modpow(10, tmp, 2019) * stol(s.substr(i, 1))) % 2019;
		c[i] = (c[i+1] + tmp2) % 2019;
		c[i] %= 2019;
		count[c[i]]++;
	}
	REP(i, 2019){
		ans += count[i] * (count[i] - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int d = 0;
    while(n > 0){
        n /= k;
        d++;
    }
    cout << d << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
	int N;
	scanf("%d",&N);
	int a[N];
	for(int i=0; i<N; i++){
		scanf("%d",&a[i]);
	}

	int min = a[0];
	int max = a[0];

	for(int i=1; i<N; i++){
		if(a[i] > max){
			max = a[i];
		}
		if(a[i] < min){
			min = a[i];
		}
	}

	printf("%d\n",max - min);

	return 0;
}

Measured memory_bytes: 128
# (1..n)
# a + b + c = x || a != b, b != c, c != a

ARGF.each do |line|
  n, x  = line.split.map(&:to_i)
  break if n == 0 && x == 0

  ary = [*1..n]

  i = 0
  ary.combination(3) do |a, b, c|
    if (a + b + c) == x
      i += 1
    end
  end
  puts i
end

Measured memory_bytes: 6096
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>

//エイリアス
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

constexpr ll MOD = 1000000007;

ll modpow(ll n, ll r, ll mod) {
    if(r == 0) return 1;
    if(n == 0) return 0;
    if(r % 2 == 0) {
        ll tmp = modpow(n, r / 2, mod);
        return tmp * tmp % mod;
    }
    else {
        return n * modpow(n, r - 1, mod) % mod;
    }
}

int main(){
    Stream io;

    string S;
    io.read(S);

    if(S.back() == 's') S += "es";
    else S += 's';

    cout << S;

    return 0;
}


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;

	public static void main(String[] args) {

		while(true) {

			int m = sc.nextInt();
			int n = sc.nextInt();

			if((m|n)==0) {
				break;
			}
			boolean[] bloom = new boolean[7368792];
//			Queue q = new ArrayDeque<Integer>();

			int idx=m;
			while(true) {
				if(! bloom[idx]) {
					if(n==0) {
						break;
					}
					for(int i = idx  ; i < 7368792 ; i+=idx) {
						bloom[i] = true;
					}
					n--;
				}
			idx++;
			}

			System.out.println(idx);

		}


	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}
}



Measured memory_bytes: 58328