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

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

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

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

using namespace std;

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

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

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  int sum = 0;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  double ave = (double)sum / (double)n;
  double near = abs((double)a[0] - ave);
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(abs((double)a[i] - ave) < near ) {
      near = abs((double)a[i] - ave);
      ans = i;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
 cin>>N;
 vector<int>V(N);
 vector<int>C(N);
 long long answer=0;
for(int i=0; i<N; i++){
cin>>V.at(i);
}
  for(int i=0; i<N; i++){
    cin>>C.at(i);
  }
  for(int i=0; i<N; i++){
    if(V.at(i)-C.at(i)>0){
      answer+=V.at(i)-C.at(i);
    }
  }
cout<<answer<<endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    vector<P> v(n);
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        v[i] = P(a, i+1);
    }
    sort(v.begin(), v.end());
    set<int> s;
    s.insert(v[0].second);
    s.insert(n+1);
    ll ans = v[0].second * (n-v[0].second+1);

    for(int i = 1; i < n; i++)
    {
        P p = v[i];
        ll num = p.first;
        ll pos = p.second;
        s.insert(pos);
        auto itr = s.find(pos);
        if(itr == s.begin())
        {
            itr++;
            ll l = *itr; 
            ans += num * pos * (l-pos);
        }
        else
        {
            itr--;
            ll l = *itr;
            auto it = s.lower_bound(pos);
            it++;
            ll r = *it;
            ans += num * (pos-l) * (r-pos);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 12800
import java.util.*;
class Main{
 public static void main(String[] args){
 	Scanner sc=new Scanner(System.in);
   	int n=sc.nextInt();
   	String S=sc.next();
   	if(S.length()<=n){
      System.out.println(S);
    }
   	else{
     System.out.println(S.substring(0,n)+"..."); 
    }
 }
}

Measured memory_bytes: 38648
#include <iostream>
#include <vector>
#include <numeric>  // accumulate
using namespace std;

#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
typedef long long ll;

int main() {
    // input
    ll N;
    cin >> N;
    vector<ll> height(N);
    for (ll i = 0; i < N; ++i) cin >> height[i];

    // calculation
    if (N == 1) {
        cout << height[0] << "\n";
    } else {
        ll idx = 0, left, right, min_interval;
        ll sum_height = SUM(height), res = 0;

        while (sum_height > 0) {
            // 区間を定める
            left = -1, right = -1;
            min_interval = 101;

            // 左端を定める
            for (ll i = 0; i < N; ++i) {
                if (height[i] != 0) {
                    left = i;
                    break;
                }
            }

            if (left == -1) {
                // 全てが 0 の場合
                break;
            } else {
                // 右端を定める
                for (ll i = left; i < N; ++i) {
                    if (height[i] != 0) {
                        // 0 ではない区間の右端，区間の最小値を求める．
                        min_interval = min(min_interval, height[i]);
                        right = i;
                    } else {
                        break;
                    }
                }

                // 区間の要素から区間の最小値を引く
                for (ll i = left; i <= right; ++i) {
                    height[i] -= min_interval;
                    sum_height -= min_interval;
                }
                res += min_interval;  // 水やりは一回
            }
        }
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
$N = <STDIN>+0;
@P=split " ",<STDIN>;
$m=1000000007;
unshift @P,-1;
for($i=1;$i<=$N;$i++) {
	push @{$IP[$P[$i]]},$i;
}
$lv{0}=0;
for($i=0;$i<=$N;$i++) {
	$lv=$lv{$i};
	$lvsum{$lv}+=1;
	for($j=0;$j<=$#{$IP[$i]};$j++) {
		$lv{$IP[$i][$j]}=$lv+1;
	}
}


for($i=$N;$i>=0;$i--) {
	$l=$IP[$i];
	$mj=$#{$l};
	if ($mj<0) {
		$A[$i][0]=1;
		$B[$i][0]=1;
		next;
	}
	if ($mj==0) {
		$di=${$l}[0];
		$A[$i]=$A[$di];
		$B[$i]=$B[$di];
	} else {
		$md=-1;
		for($j=0;$j<=$mj;$j++) {
			$pdi=${$l}[$j];
			if ($md < $#{$A[$pdi]}) { $di=$pdi; $md=$#{$A[$di]}; }
		}
		$A[$i]=$A[$di];
		$B[$i]=$B[$di];
		for($d=0;$d<=$md;$d++) {
			$A=$A[$i][$d];
			$B=$B[$i][$d];
			$D=0;
			for($j=0;$j<=$mj;$j++) {
				$ij=${$l}[$j];
				next if ($di==$ij);
				next if ($A[$ij][$d]==0);
				$D=($A*$A[$ij][$d]+$D*($A[$ij][$d]+$B[$ij][$d]))%$m;
				$A=($A*$B[$ij][$d]+$B*$A[$ij][$d]              )%$m;
				$B=($B*$B[$ij][$d]                             )%$m;
			}
			$A[$i][$d]=$A;
			$B[$i][$d]=($B+$D) % $m;
		}
	}
	unshift @{$A[$i]},1;
	unshift @{$B[$i]},1;
}
$pow[0]=1;for($p=0;$p<$N;$p++){ $pow[$p+1]=($pow[$p]*2) % $m; }
$sum=0;
for($d=0;$A[0][$d]>0;$d++) {
	$sum=($sum + $A[0][$d]*$pow[$N+1-$lvsum{$d}]) % $m;
}
print $sum,"\n";


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

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

#define Endl endl

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

int main(){
    cin>>n>>m;
    while(1){
        if(n>m){
            break;
        }
        n*=2;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if((C >= min(A, B)) && (C <= max(A, B)))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair
#define int long long

using namespace std;

int dp[1000000][2];
int mod = 1e9 + 7;

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	string s;
	cin >> s;
	if (s[0] == '0') {
		dp[0][0] = 0;
		dp[0][1] = 1;
	} else {
		dp[0][0] = 1;
		dp[0][1] = 2;
	}
	for (int i = 1; i < s.size(); ++i) {
		dp[i][1] = (dp[i - 1][1] * (s[i] == '1' ? 2 : 1)) % mod;
		dp[i][0] = (dp[i - 1][0] * 3 + (s[i] == '1' ? dp[i - 1][1] : 0)) % mod;
	}
	cout << (dp[s.size() - 1][0] + dp[s.size() - 1][1]) % mod; 
}

Measured memory_bytes: 2000
N = int(input())
A = [int(i) for i in input().split()]
Ans_list = [[] for i in range(N-1)]
A.sort(reverse = True)
count = 0

for i in A[1:-1]:
    if i >= 0:
        Ans_list[count] = [A[-1],i]
        A[-1] -= i
    else:
        Ans_list[count] = [A[0],i]
        A[0] -= i
    count += 1

Ans_list[-1] = [A[0],A[-1]]
print(A[0]-A[-1])
for i,j in Ans_list:
    print(i,j)

Measured memory_bytes: 23236
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(list[K-1])

Measured memory_bytes: 3060
// b.cpp : 定义控制台应用程序的入口点。
//


#include<iostream>
using namespace std;

int main()
{
	int K, S;
	cin >> K >> S;
	int res = 0;
	for (int left = 0; left <= K; left++)
	{
		int right = K;
		for (; right >= left; right--)
		{
			int mid = S - left - right;
			if (mid < left || mid > right)
				continue;

			if (left == right && mid == left)
				res += 1;
			else if (left != mid && left != right && mid != right)
				res += 6;
			else
				res += 3;
			
		}
	}
	cout << res << endl;
    return 0;
}


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

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt1=0,cnt2=0;
  if(s[0] == s[1]){
    if(s[0] != s[2] && s[2] == s[3]){
      cout << "Yes";
      return 0;
    } else {
      cout << "No";
      return 0;
    }
  } else { 
    if(s[0] == s[2]){
      if(s[1] == s[3] && s[0] != s[1]){
        cout << "Yes";
        return 0;
      } else {
        cout << "No";
        return 0;
      }
    }
  }
  if(s[0] == s[3]){
    if(s[1] == s[2] && s[0] != s[1]){
      cout << "Yes";
      return 0;
    } else {
      cout << "No";
      return 0;
    }
  } else {
    cout << "No";
  }
 
 return 0;
}

Measured memory_bytes: 256
#include <iostream>

 int main() {


	 int ans = 0;

	 for (int i = 0; i < 9; ++i) {
		 
		 for (int n = 0; n < 9; ++n) {
			 ans = (n + 1) * (i + 1);

			 std::cout << i + 1 << "x" << n + 1 << "=" << ans << std::endl;

		 }

	 }

 }

Measured memory_bytes: 2892
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, res = 0;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        int a = i / 10000 % 10, b = i / 1000 % 10;
        int c = i / 10 % 10, d = i % 10;
        if (a == d && b == c) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int ans[321][321]; char test[321][321];
int main() {
	long long n, k, o, atai = 1; char a; cin >> n >> k>> o;
    long long c = 0, d = 0, e = 0;
	for(int h=0;h<n;h++){
      for(int i=0;i<k;i++){
        cin>>a;test[h][i]=a; 
      }
    }
    for(int h=0;h<n;h++){
       int b = 0, x = 0, y = 0;
       for(int i=0;i<k;i++){
          if(test[h][i]=='#'){
            b++; y = i;
            for(int j=d; j<=e + 1; j++){
              for(int l=x;l<=y;l++){
                 ans[j][l]=atai;
              }
            }
            atai++; x = i+1;
          }
          else if(i==k-1){
             atai--;
             for(int j=d; j<=e + 1; j++){
               for(int l=x;l<k;l++){
                 ans[j][l]=atai;
               }
             }
             atai++;
          }
       }
       if(b==0){
         if(c==0){ d=h; c++;}
         if(h==n-1){
            for(int j=d; j<=e + 1; j++){
               for(int l=0;l<k;l++){
                 ans[j][l]=ans[d-1][l];
               }
             }
         }
         e=h;
       }
       else{
         c=0;d=h+1;e=h+1;
       }
    }
    for(int h=0;h<n;h++){
      for(int i=0;i<k;i++){
        if(i==k-1){
       cout<<ans[h][i];
        }
        else{
       cout<<ans[h][i]<<' '; 
        }
      }
      cout<<endl;
    }
  cout<<endl;
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        S += T.charAt(T.length()-1);
        if (S.equals(T)) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 38884
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    REP(i, 0, n) cin >> a[i];
    REP(i, 0, m) cin >> b[i];
    for (int i = 0; i < n - m + 1; i++) {
        for (int j = 0; j < n - m + 1; j++) {
            bool ans = true;
            for (int x = 0; x < m; x++) {
                for (int y = 0; y < m; y++) {
                    if (a[y+j][x+i] != b[y][x]) {
                        ans = false;
                        break;
                    }
                }
                if (!ans) break;
            }
            if (ans) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      string B;
      
      // ここにプログラムを追記
      for(int i=0;i<N;i++){
        cin >> B;
        if(B=="Y"){
          cout << "Four" << endl;
          break;
        }
        if(i==N-1){
          cout << "Three" << endl;
        }
      }
    }

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int a = NextInt();
        int b = NextInt();
        int[] memo = new int[1000];
        memo[0] = 0;
        for (int i = 1; i <= 999; i++)
            memo[i] = memo[i - 1] + i;
        int ans = 0;
        for (int i = 1; i <= 999; i++)
            if (memo[i] - b == memo[i - 1] - a) ans = memo[i] - b;

        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N, M;
    cin >> N >> M;
    if(N==M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    static int s[1 << 20];
    int n;
    fi>>n;
    int cnt = 0;
    for (int i = 1;i <= n;++i)
        fi>>s[i],cnt ^= s[i],s[i] ^= (s[i] - 1);
    sort(s + 1,s + 1 + n,greater < int > ());
    auto lg = [&](int x)
    {
        int ans = 0;
        while ((++ans) && (x /= 2));
        return ans;
    };
    int ans = 0;
    for (int i = 1;cnt && i <= n;++i)
        if (lg(cnt) == lg(s[i]))
            cnt ^= s[i],++ans;
    if (cnt)
        ans = -1;
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    set<int> st;
    for(int i=1;i<10;i++){
	for(int j=1;j<10;j++){
	    st.insert(i*j);
	}
    }
    int n;
    cin>>n;
    if( st.find( n ) != st.end()){
	cout<<"Yes"<<endl;
    }else{
	cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int n, m, q; 
int a[50], b[50], c[50], d[50];

int ans = 0;

vector<int> vect;

void calc(){
    int val = 0;
    for(int i=0; i<q; i++){
        if(vect[b[i]-1]-vect[a[i]-1]==c[i]){
            val += d[i];
        }
    }
    ans = max(ans, val);
}

void recur(int i){
    if(i==n){
        calc();
        return;
    }
    int cur = vect.back();
    for(int j=cur; j<=m; j++){
        vect.pb(j);
        recur(i+1);
        vect.pop_back();
    }
}


void solve(){
    cin>>n>>m>>q;
    For(i, 0, q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    for(int i=1; i<=m; i++){
        vect.pb(i);
        recur(1);
        vect.pop_back();
    }
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}





Measured memory_bytes: 3644
class Main{
	public static void main(String[] args){
    	java.util.Scanner scan = new java.util.Scanner(System.in);
      int a = scan.nextInt();
      int b = scan.nextInt();
      int c = scan.nextInt();
      
      if(a == b){
      	System.out.println(c);
      }
      else if(a == c){
      	System.out.println(b);
      }
      else{
      	System.out.println(a);
      }
    }
}


Measured memory_bytes: 23892
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    auto A = readln.chomp.split(" ").map!(to!int).array;
    auto B = readln.chomp.split(" ").map!(to!int).array;
    assert(N == A.size);
    assert(M == B.size);

    int calc(int a, int b, int p, int q) {
        int a_score = 0, b_score = 0;
        for (int i = p; i < a; i++) {
            if (A[i] < 0) continue;
            a_score += A[i];
        }
        for (int i = q; i < b; i++) {
            if (B[i] < 0) continue;
            b_score += B[i];
        }
        //log([a, b, p, q], [a_score, b_score]);
        return a_score - b_score;
    }

    int[Tuple!(int, int, int, int, int, int)] cache;
    int dfs(int w, int a, int b, int p, int q, int pass_count) {
        if (pass_count == 2) return 0;
        auto key = tuple(w, a, b, p, q, pass_count);
        if (key in cache) return cache[key];
        int ret = (w == 0 ? int.min / 4 : int.max / 4);
        if (w == 0) {
            ret = max(ret, dfs( (w + 1) % 2, a, b, a, b, pass_count + (a == p && b == q) ) + calc(a, b, p, q));
            if (a < A.size)
                ret = max(ret, dfs( (w + 1) % 2, a + 1, b, p, A[a] == -1 ? b : q, 0 ));
        } else {
            ret = min(ret, dfs( (w + 1) % 2, a, b, a, b, pass_count + (a == p && b == q) ) + calc(a, b, p, q));
            if (b < B.size) 
                ret = min(ret, dfs( (w + 1) % 2, a, b + 1, B[b] == -1 ? a : p, q, 0 ));
        }
        return cache[key] = ret;
    }

    writeln(dfs(0, 0, 0, 0, 0, false));

    /*
    foreach (k, v; cache) {
        writeln(k, " -> ", v);
    }
    */


}

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


int main(){
    int a,b,c,n;
    string s,p;
    char ch;
    vector<int>v;
    
    cin >> s;
    
    if(s[0]=='7' || s[1]=='7' || s[2]=='7')cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
    
    
    
    return 0;
}




Measured memory_bytes: 3596
S = input()
n = len(S)
s = int(S, 2)
b = ''.join(map(str, [i % 2 for i in range(n)]))
p = int(b, 2)
q = int(b[1:] + str(int(b[-1]) ^ 1), 2)
print(min(bin(s ^ n).count('1') for n in [p, q]))

Measured memory_bytes: 55796
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif (m + f) >= 80:
        print('A')
    elif 65 <= (m + f) < 80:
        print('B')
    elif 50 <= (m + f) < 65:
        print('C')
    elif 30 <= (m + f) < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')




Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    string S; cin >> S;
    ll N = S.size();
    vel cnt(26,0); rep(i,N) cnt[S[i] - 'a']++;
    ll sum = N * (N - 1LL) / 2LL;
    ll sub = 0LL;
    rep(i,26) sub += cnt[i] * (cnt[i] - 1LL) / 2LL;
    cout << sum - sub + 1LL << endl;
    return 0;
}

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(true){
        int n,x;
        cin>>n>>x;
        if(n==0&&x==0)return 0;
        int cnt=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x)cnt++;
                }
            }
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define INF 1e18

using namespace std;
typedef long long ll;

ll V[200005], dp[200005][20], dp2[200005][20], P[50];
int n;

int main() {
    ios_base::sync_with_stdio(false);
    P[0]=1;
    for (int i=1; i<=30; i++)
        P[i]=P[i-1]*4;
    scanf("%d", &n);
    for (int i=1; i<=n; i++)
        scanf("%d", &V[i]);

    for (int j=0; j<=15; j++)
    {
        dp[n][j] = 2*j;
    }

    for (int i=n-1; i>=1; i--)
    {
        for (int j=0; j<=15; j++)
        {
            ll x = V[i] * P[j];
            ll put = 0;
            while (P[put]*V[i+1]<x)
                put++;
            if (put<=15)
                dp[i][j] = dp[i + 1][put] + j * 2;
            else
            {
                dp[i][j] = dp[i+1][15] + (put-15)*(n-i)*2 + j*2;
            }
        }
    }


    for (int j=0; j<=15; j++)
    {
        dp2[1][j] = 2*j+1;
    }

    for (int i=1; i<=n; i++)
        V[i]*=2;

    for (int i=2; i<=n; i++)
    {
        for (int j=0; j<=15; j++)
        {
            ll x = V[i] * P[j];
            ll put = 0;
            while (P[put]*V[i-1]<x)
                put++;
            if (put<=15)
                dp2[i][j] = dp2[i - 1][put] + j * 2 + 1;
            else
            {
                dp2[i][j] = dp2[i-1][15] + (put-15)*(i-1)*2 + j*2 + 1;
            }
        }
    }

//    for (int i=1; i<=n; i++)
//    {
//        for (int j=0; j<=15; j++)
//            cout<<dp[i][j]<<" ";
//        cout<<'\n';
//    }

    ll minim=INF;
    for (int i=1; i<=n+1; i++)
        for (int j=0; j<=15; j++)
            if (dp2[i-1][j]+dp[i][j]<minim)
                minim=dp2[i-1][j]+dp[i][j];
    printf("%lld", minim);
    return 0;
}

Measured memory_bytes: 64384
import scala.io.StdIn.{readInt, readLine}

final case class Card(suit: String, value: Int)

object Main extends App {
  import QuickSort.quickSort
  import MergeSort.mergeSort

  val n     = readInt()
  val lines = Iterator.fill(n)(readLine())

  val cardsA = lines
    .map { _.split(" ") }
    .map {
      case Array(suit, v) => Card(suit, v.toInt)
    }
    .toArray

  val cardsB = cardsA.clone

  quickSort(cardsA)
  mergeSort(cardsB)

  println(if (cardsA sameElements cardsB) "Stable" else "Not stable")
  cardsA.foreach {
    case Card(suit, value) => println(s"$suit $value")
  }
}

object QuickSort {
  def quickSort(xs: Array[Card]): Unit = {

    def run(p: Int, r: Int): Unit = {
      if (p < r) {
        val q = partition(xs, p, r)
        run(p, q - 1)
        run(q + 1, r)
      }
    }

    run(0, xs.length - 1)
  }

  private def partition(xs: Array[Card], p: Int, r: Int): Int = {
    val x = xs(r).value
    var i = p - 1
    var j = p
    while (j < r) {
      if (xs(j).value <= x) {
        i += 1
        swap(xs, i, j)
      }
      j += 1
    }

    val q = i + 1
    swap(xs, q, r)
    q
  }

  private def swap[A](xs: Array[A], a: Int, b: Int): Unit = {
    val temp = xs(a)
    xs(a) = xs(b)
    xs(b) = temp
  }
}

object MergeSort {
  private val Max: Int       = 100000
  private val Sentinel: Card = Card("", 2000000000)

  def mergeSort(xs: Array[Card]): Int = {

    val ls = new Array[Card](Max / 2 + 2)
    val rs = new Array[Card](Max / 2 + 2)

    def run(left: Int, right: Int): Int = {
      val m = right - left
      if (m <= 1) 0
      else {
        val mid  = (left + right) / 2
        val cnt1 = run(left, mid)
        val cnt2 = run(mid, right)
        merge(left, mid, right)
        cnt1 + cnt2 + m
      }
    }

    def merge(left: Int, mid: Int, right: Int): Unit = {
      val n1 = mid - left
      val n2 = right - mid
      Array.copy(xs, left, ls, 0, n1)
      Array.copy(xs, mid, rs, 0, n2)
      ls(n1) = Sentinel
      rs(n2) = Sentinel
      var i  = 0
      var j  = 0
      var k  = left
      while (k < right) {
        if (ls(i).value <= rs(j).value) {
          xs(k) = ls(i)
          i += 1
        } else {
          xs(k) = rs(j)
          j += 1
        }
        k += 1
      }
    }

    run(0, xs.length)
  }
}



Measured memory_bytes: 164112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	string s;
	cin >> s;
	ll n = s.size();
	vector<ll> a(s.size());
	a[0] = s[0]-'0';

	ll io = 1;
	reverse(s.begin(),s.end());
	for(ll i = 0;i<s.size();i++)
	{
		a[i] = ((s[i]-'0')*io)%2019;
		(io*=10)%=2019;
	}
	//for(auto i:a)cout<<i<<' ';cout<<endl;
	vector<ll> b(n+1);
	for(ll i = 0;i<n;i++)
	{
		b[i+1] = b[i]+a[i];
		b[i+1]%=2019;
	}
	sort(b.begin(),b.end());
	//for(auto i:b)cout<<i<<' ';cout<<endl;
	//b.push_back(-1);
	vector<int> cnt(2019);
	for(int i = 0;i<n+1;i++)cnt[b[i]]++;
	ll ans =0;
	for(int i =0;i<2019;i++)ans += cnt[i]*(cnt[i]-1)/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 6780
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, H, W = map(int, input().split())
    ans = 0
    for _ in range(N):
        a, b = map(int, input().split())
        if a >= H and b >= W:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);

  int a, b, k;
  cin >> a >> b >> k;
  if (b - a < 2 * k) {
    for (int i = a; i <= b; ++i) {
      cout << i << "\n";
    }
  } else {
    for (int i = a; i < a + k; ++i) {
      cout << i << "\n";
    }
    for (int i = b - k + 1; i <= b; ++i) {
      cout << i << "\n";
    }
  }
}


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

int main() {
  ll n, k, a[200001] = {0};
  cin >> n >> k;
  for (ll i = 1; i <= n; ++i) cin >> a[i];
  ll w2, w3, w2Town;
  vector<ll> counter(n + 1);
  for (ll i = 1; i <= n; ++i) counter[i] = 0;
  ll nPos = a[1];
  ll w;
  for (w = 1;; ++w) {
    counter[nPos]++;
    if (counter[nPos] > 1) {
      w2 = w;
      w2Town = nPos;
      nPos = a[nPos];
      w++;
      break;
    }
    nPos = a[nPos];
  }
  for (;; ++w) {
    counter[nPos]++;
    if (counter[nPos] > 2) {
      w3 = w;
      break;
    }
    nPos = a[nPos];
  }
  ll loopTownNum = w3 - w2;
  nPos = a[1];
  ll ans = 0;
  vector<ll> tPos(n);
  if (k < w2) {
    for (ll i = 2; i <= k; ++i) nPos = a[nPos];
    ans = nPos;
  } else if (k >= w2) {
    nPos = w2Town;
    for (ll i = 0; i < loopTownNum; ++i) {
      tPos[i] = nPos;
      nPos = a[nPos];
    }
    ans = tPos[(k - w2) % loopTownNum];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8016
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int dfs(double ans,int div,double sum,int a,int n){
	if(ans-EPS <= sum && sum <= ans+EPS){
		return 1;
	}
	else if(ans-EPS <= sum || a == 0 || n == 0){
		return 0;
	}

	int res = 0;
	for(int i=div;i<=a;i++){
		res += dfs(ans,i,sum+(1.0/i),a/i,n-1);
	}

	return res;
}

int main()
{
	int p,q,a,n;
	while(~scanf("%d %d %d %d",&p,&q,&a,&n)){
		if(p==q && q==a && a==n && n==0) break;
		int res = dfs((double)p/(double)q,1,0,a,n);
		printf("%d\n",res);
	}
}

Measured memory_bytes: 876
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=0
n=int(input())
print(*d(list(map(int,input().split()))))
print(c-n)


Measured memory_bytes: 63696
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  scanf("%d%d",&n,&k);
  if(n == 1)
  {
    if(k == 0) puts("0 0 1 1");
    else puts("-1");
    return 0;
  }
  if((1<<n) <= k) {puts("-1"); return 0;}
  for(int i = 0 ; i < (1<<n) ; i++)
  {
    if(i != k) printf("%d ",i);
  }
  printf("%d ",k);
  for(int i = (1<<n) - 1 ; i >= 0 ; i--)
  {
    if(i != k) printf("%d ",i);
  }
  printf("%d ",k);
}

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

int main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	if(A*B>C*D){
		cout<<A*B<<endl;
	}else if(A*B<C*D){
		cout<<C*D<<endl;
	}else{
		cout<<A*B<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);

#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long

int n;
int ans[2000][2000];

int generate(){
    ans[0][0]=1;
    ans[0][1]=2;
    ans[1][0]=2;
    ans[1][1]=3;
    ans[2][0]=1;
    ans[2][1]=3;
    for(int i=3;i<=1000;i++){
        for(int k=(i-1)*i/2+1;k<=i*(i+1)/2;k++){
            ans[k-((i-1)*i/2+1)][i-1]=k;
            ans[i][k-((i-1)*i/2+1)]=k;
        }
    }
    return 0;
}

signed main(){
    generate();
    cin>>n;
    if(n==1){
        cout<<"Yes"<<endl;
        cout<<"2"<<endl;
        cout<<"1 1"<<endl;
        cout<<"1 1"<<endl;
        return 0;
    }
    for(int i=1;i<=1000;i++){
        if(i*(i+1)/2>n){
            cout<<"No"<<endl;
            return 0;
        }
        if(i*(i+1)/2==n){
            cout<<"Yes"<<endl;
            i++;
            cout<<i<<endl;
            for(int k=0;k<i;k++){
                cout<<i-1<<" ";
                for(int m=0;m<i-1;m++){
                    if(m==i-2)cout<<ans[k][m]<<endl;
                    else cout<<ans[k][m]<<" ";
                }
            }
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 17280
#include<cstdio>
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const static int MOD = 1000000007;

int main(){
	string T;
	cin >> T;
	for (int i = 0; i < T.size(); ++i){
		if(T[i] == '?') T[i] = 'D';
	}
	for (int i = 0; i < T.size(); ++i){
		printf("%c", T[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    vector< vector<int> > A(3, vector<int>(3, 0));
    vector< vector<bool> > is_called(3, vector<bool>(3, false));
    REP(i, 3) {
        REP(j, 3) {
            int tmp;
            cin >> tmp;
            A[i][j] = tmp;
        }
    }
    int N;
    cin >> N;
    vector<int> b(N);
    REP(i, N) {
        int tmp;
        cin >> tmp;
        REP(i, 3) REP(j, 3) if(A[i][j] == tmp) is_called[i][j] = true;
    }

    REP(i, 3)
        if(is_called[i][0] && is_called[i][1] && is_called[i][2]) {
            cout << "Yes" << endl;
            return 0;
        }
    REP(i, 3)
        if(is_called[0][i] && is_called[1][i] && is_called[2][i]) {
            cout << "Yes" << endl;
            return 0;
        }

    if(is_called[0][0] && is_called[1][1] && is_called[2][2]) {
        cout << "Yes" << endl;
        return 0;
    }
    if(is_called[0][2] && is_called[1][1] && is_called[2][0]) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };


int main() {
	int n, i;
	cin >> n;
	vi num(100001, 0);
	int a;
	for (i = 0; i < n; i++) {
		cin >> a;
		if (a == 0) {
			num[0]++;
			num[1]++;
		}
		else if (a == 100000) {
			num[100000]++;
			num[99999]++;
		}
		else {
			num[a - 1]++;
			num[a]++;
			num[a + 1]++;
		}
	}
	int max = 0;
	for (i = 0; i < 100001; i++) {
		if (max < num[i]) {
			max = num[i];
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 640
import sys
import math
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())

    D = []
    for i in range(N):
        a, b = map(int, input().split())
        heapq.heappush(D, (a, b))
    ans = 0
    while M > 0:
        a, b = heapq.heappop(D)
        if M > b:
            ans += a * b
            M -= b
        else:
            ans += M * a
            print(ans)
            exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 22616
#include <stdio.h>
#include<string.h>

int main()
{
 	int n;
	char cs[4][3][10];
	memset(cs,'0',sizeof(cs));
	scanf("%d",&n);
	while(n--){
 		int b,f,r,v;
		scanf("%d %d %d %d",&b,&f,&r,&v);
		cs[b-1][f-1][r-1]+=v;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				printf(" %c",cs[i][j][k]);
			}
			printf("\n");
		}
		if(i<3)printf("####################\n");
	}
}



Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    cout << (n %1000 == 0 ? 0 : 1000 - n % 1000) << endl;
}

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

using namespace std;

typedef long long ll;

const int N = 100;

char m[N][N];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    for (int i = 0; i < N / 2; ++i) {
        for (int j = 0; j < N; ++j) {
            m[i][j] = '#';
        }
    }
    for (int i = N / 2; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            m[i][j] = '.';
        }
    }
    for (int i = 1; i < N / 2; i += 2) {
        for (int j = 1; j < N; j += 2) {
            if (a) {
                m[i][j] = '.';
                --a;
            }
        }
    }
    for (int i = N / 2 + 1; i < N; i += 2) {
        for (int j = 1; j < N; j += 2) {
            if (b) {
                m[i][j] = '#';
                --b;
            }
        }
    }
    cout << "100 100\n";
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cout << m[i][j];
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, M) = Scanner.Scan<int, int>();
            var G = new List<int>[N].Select(x => new List<int>()).ToArray();
            for (var i = 0; i < M; i++)
            {
                var (a, b) = Scanner.Scan<int, int>();
                a--;
                b--;
                G[a].Add(b);
                G[b].Add(a);
            }

            var queue = new Queue<int>();
            queue.Enqueue(0);
            var depths = Enumerable.Repeat(-1, N).ToArray();
            depths[0] = 0;
            var from = new int[N];
            while (queue.Any())
            {
                var current = queue.Dequeue();
                foreach (var next in G[current])
                {
                    if (depths[next] != -1) continue;
                    depths[next] = depths[current] + 1;
                    from[next] = current + 1;
                    queue.Enqueue(next);
                }
            }

            if (depths.Contains(-1))
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
                Console.WriteLine(string.Join("\n", from.Skip(1)));
            }
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 58348
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    ll a, b; cin>>a>>b;
    if(b%a==0){
        cout<<-1<<endl;
        return 0;
    }
    for(ll i=1; i<a; i++){
        ll r=i*b%a, q=i*b/a+1;
        if(r==0) continue;
        r=a-r;
        if(q<i+r){
            cout<<i*b+r<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


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

int main() {
  int x;
  cin >> x;
  
  for (int i = x; i <= 100003; i ++) {
    bool isprime = true;
    for (int j = 2; j <= sqrt((float)i); j++) {
      if (i % j == 0) {
        isprime = false;
        break;
      }
    }
    if (isprime) {
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}


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

int main(){
 int K, a;
  cin >> K;
  a = 0;
  for(int i = 1; i <= K; i++){
  a = (10*a + 7)%K;
  if(a == 0){
    cout << i <<endl;
  break;
  }
  if(i == K)
    cout << -1 <<endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

vec x(1), y(1), r(1);
ll X, Y, sx, sy;
long double range(ll u, ll v){
    if(u != -1) {
        ll dx = abs(x[u] - x[v]), dy = abs(y[u] - y[v]);
        if (dx * dx + dy * dy <= (r[u] + r[v]) * (r[u] + r[v])) return 0;
        return sqrt(dx * dx + dy * dy) - r[u] - r[v];
    }else{
        ll dx = abs(sx - x[v]), dy = abs(sy - y[v]);
        //cout<<v<<' '<<sqrt(dx * dx + dy * dy)<<' '<<dx * dx + dy * dy<<endl;
        if(dx * dx + dy * dy <= r[v] * r[v]) return 0;
        return  sqrt(dx * dx + dy * dy) - r[v];
    }
}

vector<long double> dist(1010, INF);
vector<bool> used(1010, false);
ll mini_id(){
    ll ans = -1;
    long double mini = INF;
    rep(i,1010){
        if(mini > dist[i] && !used[i]) ans = i, mini = dist[i];
    }
    used[ans] = true;
    return ans;
}

int main() {
    r[0] = 0;
    cin >> sx >> sy >>X >> Y;
    x[0] = X, y[0] = Y;
    cin>>N;
    rep(i,N) cin>>X>>Y>>R, x.push_back(X), y.push_back(Y), r.push_back(R);
    rep(i,N+1) dist[i] = range(-1, i);
    rep(i, N + 1){
        ll id = mini_id();
        rep(j, N + 1){
            if(!used[j]){
                dist[j] = min(dist[j], dist[id] + range(j, id));
            }
        }
    }
    //rep(i,N+1) cout<<dist[i]<<endl;
    cout<<fixed<<setprecision(10)<<dist[0]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct mat {
    ll num[66];
    mat()
    {
        memset(num, 0, sizeof(num));
    }
    void add(ll a)
    {
        for (int i = 63; i >= 0; i--)
        {
            if (!((a >> i) & 1))
                continue;
            if (!num[i])
            {
                num[i] = a;
                break;
            }
            a ^= num[i];
        }
    }
}m;
#define MAXNUM 111111
#define rep(i,s,t) for(int i=s;i<t;i++)
ll num[MAXNUM];
int main()
{
    int n;scanf("%d",&n);
    ll sum=0;
    rep(i,1,n+1)scanf("%lld",&num[i]),sum^=num[i];
    rep(i,1,n+1)
    {
        rep(j,0,62)if(((sum>>j)&1)&&((num[i]>>j)&1))num[i]-=1ll<<j;
        m.add(num[i]);
    }
    ll res=sum,numnow=0;
    for(int i=62;i>=0;i--)
    {
        if(m.num[i])
        {
            if(!((numnow>>i)&1))numnow^=m.num[i];
        }
        if((numnow>>i)&1)res+=(1ll<<i)*2;
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (((a*b) > (c*d)) ? a*b : c*d) << endl;
    return 0;
}


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

#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define MOD 1000000007
#define INF 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y) 
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,k;
	cin>>n>>k;

	int ct=0;
	while(n){
		ct++;
		n/=k;
	}

	cout<<ct;

	return 0;
}

Measured memory_bytes: 256