akhauriyash/Code-Regression huggingface dataset:
# 一点更新区間min(1-indexed, 非再帰)
class RangeMinimumQuery:
    def __init__(self, n, inf=2 ** 31 - 1):
        self.n = 1 << (n - 1).bit_length()
        self.INF = inf
        self.segtree = [self.INF] * (2 * self.n)

    # i番目の値(0-indexed)をxに変更
    def update(self, i, x):
        i += self.n
        self.segtree[i] = x
        while i > 0:
            i //= 2
            self.segtree[i] = min(self.segtree[2 * i], self.segtree[2 * i + 1])

    # [l, r)のmin
    def query(self, l, r):
        L, R = l + self.n, r + self.n
        s = self.INF
        while L < R:
            if L & 1:
                s = min(s, self.segtree[L])
                L += 1

            if R & 1:
                s = min(s, self.segtree[R - 1])
                R -= 1

            L >>= 1
            R >>= 1

        return s


N, Q = map(int, input().split())
RMQ = RangeMinimumQuery(N)
for q in range(Q):
    cmd, x, y = map(int, input().split())
    if cmd == 0:
        RMQ.update(x, y)

    if cmd == 1:
        print(RMQ.query(x, y + 1))



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

using namespace std;

using ll=long long;

const ll p=1000000007;

const ll maxn=300000;

vector<ll>fact(maxn);
vector<ll>factorialNumInverse(maxn);
vector<ll>naturalNumInverse(maxn);

void InverseofNumber(ll p)
{
    naturalNumInverse[0] = naturalNumInverse[1] = 1;
    for (int i = 2; i <= maxn; i++)
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
}
void InverseofFactorial(ll p)
{
    factorialNumInverse[0] = factorialNumInverse[1] = 1;
    for (int i = 2; i <= maxn; i++)
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
}
void factorial(ll p)
{
    fact[0]=1;
    for (ll i =1;i<maxn;i++) {
        fact[i]=(fact[i - 1]*i)% p;
    }
}
ll Binomial(ll N, ll R, ll p)
{
    ll ans = ((fact[N] * factorialNumInverse[R])
              % p * factorialNumInverse[N - R])
             % p;
    return ans;
}
int main() {
   InverseofNumber(p);
   InverseofFactorial(p);
   factorial(p);
   ll n,k;
   cin>>n>>k;
   ll ans=1;
   if(k>=n)k=n-1;
   for(ll i=1;i<=k;i++){
    ans+=(Binomial(n,i,p)*Binomial(n-1,i,p))%p;
   }
   cout<<ans%p<<endl;
}


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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int n,a,b,ans=1;

signed main() {
    cin >> n >> a >> b;
    int tmpn=n, now=2;
    while(tmpn) {
        if (tmpn%2) ans = (ans*now)%MOD;
        tmpn >>= 1;
        now = (now*now)%MOD;
    }
    int kuso = 1, kasu = 1;
    for(int i=n;i>n-a;i--) kuso = (kuso*i)%MOD;
    for(int i=2;i<=a;i++) kuso = (kuso*modinv(i, MOD))%MOD;
    for(int i=n;i>n-b;i--) kasu = (kasu*i)%MOD;
    for(int i=2;i<=b;i++) kasu = (kasu*modinv(i, MOD))%MOD;
    cout << (ans-kuso-kasu+MOD+MOD-1)%MOD << endl;
}



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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int SUM;
    if (a >= k) {
        SUM = k;
    }
    else if (b>=k-a) {
        SUM = a;
    }
    else{
        SUM = a - (k - a - b);
    }
    cout << SUM << endl;

    return 0;
}

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int n,m;
		scanf("%d %d",&n,&m);
		vector<int> adj[n+1];
		for(int i=0;i<m;i++){
			int u,v;
			scanf("%d %d",&u,&v);
			adj[u].push_back(v);
			adj[v].push_back(u);
		}		
		queue<int> q;
		q.push(1);
		static int dis[500005];
		static bool vis[500005];
		dis[1] = 0;
		dis[n] = 1e8;
		while(!q.empty()){
			int tmp = q.front();
			q.pop();
			for(int i=0;i<adj[tmp].size();i++){
				if(vis[adj[tmp][i]] == false){
					q.push(adj[tmp][i]);
					vis[adj[tmp][i]] = true;
					dis[adj[tmp][i]] = dis[tmp]+1;
				}
			}
		}
		puts(dis[n]==2?"POSSIBLE":"IMPOSSIBLE");
	}
	return 0;	
}

Measured memory_bytes: 13296
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e18L+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
ll dp[N]; // dp[k] = minimum weight required to get value k. 
lll vals[101];

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,w; cin>>n>>w; ll totalval = 0;
    FOR(i, 0, n) {
    	cin>>vals[i].ff>>vals[i].ss;
    	totalval += vals[i].ss;
    }
    fill(dp, dp+N, INF);
    dp[0] = 0;
    FOR(i, 0, n) {
    	RFOR(j, totalval, vals[i].ss) {
    		dp[j] = min(dp[j], vals[i].ff + dp[j - vals[i].ss]);
    	}
    }
    ll ans = 0;
    FOR(i, 0, N) {
    	if (dp[i] <= w)
    	{
    		ans = i;
    	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(x,y) (x+y-1)/y

using namespace std;
typedef pair<int, int> PII;

int main() {
	FAST;

	int n, k;
	cin >> n >> k;
	int x[n];
	int sum=INT_MAX;
	rep(i,n) {
		cin >> x[i];
		if (i >= k-1) {
			if (x[i-k+1]<0 && x[i]>0) {
				if (x[i-k+1]+x[i]>=0) sum = min(sum, x[i]-2*x[i-k+1]);
				else sum = min(sum, 2*x[i]-x[i-k+1]);
			}
			else if (0<=x[i-k+1]) sum = min(sum,x[i]);
			else if (x[i]<=0) sum = min(sum, -x[i-k+1]);
		}
	}

	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 640
unittest
{
	assert( [ "3", "1 5", "3 9", "7 8" ].parse.expand.solve == 3 );
	assert( [ "6", "8 3", "4 9", "12 19", "18 1", "13 5", "7 6" ].parse.expand.solve == 8 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto xyis = new long[ 3 ][ n ];
	foreach( i, ref xyi; xyis )
	{
		input.popFront;
		xyi = input.front.split.to!( long[] ) ~ i;
	}
	return tuple( xyis );
}

auto solve( long[ 3 ][] xyis )
{
	// xでソートして隣同士の頂点を結ぶ辺配列を作成
	// （コストはΔxとΔyのminを取るので、xとyは別々の辺と考えてよい。大きいほうのΔの辺は作るけど使われない）
	auto es = new long[ 3 ][ ( xyis.length - 1 ) * 2 ];
	xyis.sort();
	for( auto i = 0L; i + 1 < xyis.length; i++ )
	{
		es[ i ] = [ xyis[ i ][ 2 ], xyis[ i + 1 ][ 2 ], ( xyis[ i ][ 0 ] - xyis[ i + 1 ][ 0 ] ).abs ];
	}
	
	// yでソートして隣同士の頂点を結ぶ辺配列を作成
	xyis.sort!( ( a, b ) => a[ 1 ] < b[ 1 ] );
	for( auto i = 0L; i + 1 < xyis.length; i++ )
	{
		es[ xyis.length - 1 + i ] = [ xyis[ i ][ 2 ], xyis[ i + 1 ][ 2 ], ( xyis[ i ][ 1 ] - xyis[ i + 1 ][ 1 ] ).abs ];
	}
	
	// 全頂点が木構造になるように、辺をコストが小さい順で使う
	es.sort!( ( a, b ) => a[ 2 ] < b[ 2 ] );
	auto ans = 0L;
	auto uft = UnionFindTree( xyis.length );
	foreach( e; es )
	{
		if( uft.same( e[ 0 ], e[ 1 ] ) ) continue;		// もう行き来できるので辺の追加は不要
		uft.unite( e[ 0 ], e[ 1 ] );
		ans += e[ 2 ];
	}
	return ans;
}

// UnionFind木
struct UnionFindTree
{
	private long[] ps;
	
	// 重み無し初期化
	public this( long n )
	{
		ps.length = n;
		ps[] = -1;		// マイナスは根であり、その木に属するノードの数でもある。
	}
	
	public long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	public bool same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	public void unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( ps[ i ] <= ps[ j ] ){ ps[ i ] += ps[ j ]; ps[ j ] = i; }
		else                    { ps[ j ] += ps[ i ]; ps[ i ] = j; }
	}
}


Measured memory_bytes: 12540
/*
Nahid Hossain
Jahangirnagar University
Roll:54
*/
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 1000005

ll a[ma],b[ma];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,x,k;
    while(cin>>n)
    {
        ll ans=0;
       for(i=1;i<=n;i++)cin>>a[i];


       for(i=1;i<=n;i++)
       {
           ll s=0;
           for(j=i;j<=n;j++)
           {
               if(a[j]==0)break;
               s+=a[j];
           }
           ans+=(s/2);
           i=j;
       }
       cout<<ans<<endl;


    }
    return 0;
}


Measured memory_bytes: 4352
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    a = i_list()
    a = [k-(i+1) for i,k in enumerate(a)]

    a.sort()
    import statistics

    ans = int(statistics.median(a))
    trial = 0
    for i in a:
        trial += abs(i - ans)
    print(trial)


if __name__=="__main__":
    main()


Measured memory_bytes: 113580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int main()
{
    char s[200010],t[200010];
    bool done[3000];

    scanf("%s",s);
    scanf("%s",t);

    for( int i=0;i<strlen(s);i++ ){
        if( done[t[i]] == false ){
            done[t[i]] = true;
            for( int j=i+1;j<strlen(s);j++){
                if( s[i] == s[j] && t[i] != t[j] ){
                    printf("No\n");
                    return 0;
                }
                if( s[i] != s[j] && t[i] == t[j] ){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 512
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n){
  ll res=1;
  while(n>=0){
    res*=n;
    n--;
  }
  return res;
}
    
ll pow(ll i, ll n){
  ll res=1;
  while(n>=0){
    res*=i;
    n--;
  }
  return res;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(K); readl(A); readl(B);

  if(A + 2 >= B){
    cout << K + 1 << endl;
    return 0;
  }

  ll b = 1;
  ll m = 0;

  rep(i, K){
    // dump(b);
    // dump(m);
    if(m >= 1){
      // dump(m2b);
      m--;
      b += B;
      continue;
    }

    if(b >= A && K - i >= 2){
      // dump(b2m);
      b -= A;
      m++;
      continue;
    }
    
    {
      // dump("else b++");
      b++;
    }
  }

  cout << b << endl;
}
#endif


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

using namespace std;

typedef long long ll;

int n, k, s;

int main(){
    scanf("%d %d %d", &n, &k, &s);
    if(s==1000000000){
        for(int i=1; i<=k; i++) printf("1000000000 ");
        for(int i=k+1; i<=n; i++) printf("1 ");
    }
    else{
        for(int i=1; i<=k; i++) printf("%d ", s);
        for(int i=k+1; i<=n; i++) printf("1000000000 ");
    }
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int sz = 80*160+5;
int a[81][81];
bitset<sz*2> dp[81][81];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    rep(i,h)rep(j,w) cin >> a[i][j];
    rep(i,h)rep(j,w){
        int b;
        cin >> b;
        a[i][j] = abs(b - a[i][j]);
    }
    dp[0][0][sz-a[0][0]] = 1;
    dp[0][0][sz+a[0][0]] = 1;
    rep(i,h)rep(j,w){
        if(i > 0){
            dp[i][j] |= dp[i-1][j] << a[i][j];
            dp[i][j] |= dp[i-1][j] >> a[i][j];
        }
        if(j > 0){
            dp[i][j] |= dp[i][j-1] >> a[i][j];
            dp[i][j] |= dp[i][j-1] << a[i][j];
        }
    }
    int ans = INF;
    rep(i,sz*2){
        if(dp[h-1][w-1][i]) chmin(ans, abs(i-sz));
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23980
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
A = LI()
mod = 10**9 + 7
sm = sum(A) - A[0]
ans = 0

for i in range(N - 1):
    ans += A[i] * sm
    ans %= mod
    sm -= A[i + 1]
    
print(ans)

Measured memory_bytes: 105364
main :: IO ()
main = interact $ solve . map (read :: String -> Int). words

solve = unlines . map (\(x, y) -> show x ++ " " ++ show y) . reverse . tail . reverse . map myReplace . myZip

myZip :: [Int] -> [(Int, Int)]
myZip [] = []
myZip (a:b:xs) = (a, b) : myZip xs

myReplace :: Ord a => (a, a) -> (a, a)
myReplace (x, y)
	| x < y     = (x, y)
	| otherwise = (y, x)


Measured memory_bytes: 5508
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

int main() {
	ll X, D = 100, C = 0;
	cin >> X;
	while (D < X) {
		D += D / 100;
		C++;
	}
	cout << C << endl;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main()
{
    int n, p;

    while (cin >> n >> p, n || p) {
        int pl[50];

        for (int i = 0; i < n; i++)
            pl[i] = 0;

        int idx, res;
        
        idx = 0;
        res = p;
        while (true) {
            if (pl[idx] == p) {
                cout << idx << endl;
                break;
            }

            if (res == 0) {
                res += pl[idx];
                pl[idx] = 0;
            }
            else {
                pl[idx]++;
                res--;
            }
            idx = (idx + 1) % n;
        }
    }

    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#define ll long long
using namespace std;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> rgb(3, 0);
    ll sum = 1;
    ll minus = 0;

    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') rgb[0]++;
        if (S[i] == 'G') rgb[1]++;
        if (S[i] == 'B') rgb[2]++;
    }
    for (int i = 0; i < 3; i++) sum *= rgb[i];

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (2 * j - i < N && 2*j - i > j) {
                if (S[i] != S[j] && S[j] != S[2 * j - i] && S[i] != S[2 * j - i]) sum--;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3652
N=int(input())
C,S,F=[0]*(N-1),[0]*(N-1),[0]*(N-1)
for i in range(N-1):
    C[i],S[i],F[i]=map(int,input().split())

for i in range(N-1):
    time=0
    for j in range(i,N-1):
        if time%F[j]==0:
            if time>=S[j]:
                time+=C[j]
            else:
                time=S[j]
                time+=C[j]
        else:
            if time>=S[j]:
                time+=F[j]-time%F[j]
                time+=C[j]
            else:
                time=S[j]
                time+=C[j]
    print(time)
print(0)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<tuple>


int main(void){
	long long x,y;
	long long lx;
	std::cin>>x>>y;
	//for(lx=x;lx<=1000000000000000000;lx+=x){
		if(x%y!=0){
			std::cout<<x<<std::endl;
			return 0;
		}else std::cout<<-1<<std::endl;
	//}


	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
    int paSize = printArray.size();
    for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
    if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int INF = 1e8;

int N, W;
int v[111], w[111];
int dp[11111];

int main() {
    cin >> N >> W;
    rep (i, N) {
        cin >> v[i] >> w[i];
    }

    for (int i = 0; i <= W; i++) {
        rep (j, N) {
            if (i >= w[j]) {
                dp[i] = max(dp[i], dp[i-w[j]]+v[j]);
            }
        }
    }
    cout << dp[W] << endl;

    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
using namespace std;
#define INF 1e9
vector<int> c;
int dp[100001];

int main(){
   int N;
   cin>>N;
   c.push_back(1);
   for(int i=6;i<=N;i*=6){c.push_back(i);}
   for(int i=9;i<=N;i*=9){c.push_back(i);}
   fill(dp,dp+N+1,INF);
   dp[0]=0;
   for(int i=0;i<=N;i++){
       for(int j=0;j<c.size();j++){
           if(i>=c[j]){
               dp[i]=min(dp[i],dp[i-c[j]]+1);
            }
        }
    }
    cout<<dp[N]<<endl;
    return 0;
}


Measured memory_bytes: 640
using System;

namespace ALDS1
{
    class Program
    {
        static void Main()
        {
            int l = int.Parse(Console.ReadLine()) - 1;
            int min = int.Parse(Console.ReadLine());
            int max = -999999999;
            for (int i = 0; i < l; i++)
            {
                int a = int.Parse(Console.ReadLine());
                int b = a - min;
                if (b > max) max = b;
                if (a < min) min = a;
            }
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1<<29;
using Graph = vector<vector<int>>;
int main() {
    int A,B,C,D; cin >> A >> B >> C >> D;
    bool turn = true;
    while(true){    
        if (turn) C -= B;
        else A -= D;
        if (A<=0 || C<=0) break;
        turn = !turn;
    }
    if (turn) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll a,b;
  cin >> a >> b;
  if(a+b==15) pr("+");
  else if(a*b==15) pr("*");
  else pr("x");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
  long n,k,x,y;
  scanf("%ld %ld %ld %ld",&n,&k,&x,&y);
  if(n>k)
    printf("%ld\n",k*x+(n-k)*y);
  else
    printf("%ld\n",x*n);
}

Measured memory_bytes: 128
alphabet = ('a'..'z')
table = Hash.new(0)
alphabet.each{|m| table[m] = 0}

while str = gets
  str.chomp!

  str.downcase.scan(/./)do |m|
    if alphabet.cover? m
      table[m] += 1
    end
  end
end

table.each do |key, num|
  printf "%s : %d\n", key , num
end



Measured memory_bytes: 6876
#include <cstdio>
#include <algorithm>
#define maxn 55
using namespace std;
int n,m,q,st=maxn,ed=0,sum;
int a[maxn],b[maxn],c[maxn],d[maxn],p[15];
void dfs(int step){//step当前处理到的步数
	int i,j;
	if(step==ed+1){//已找到a sequence A
		int t=0;
		for(j=1;j<=q;j++)//尝试测试数据
			if(p[b[j]]-p[a[j]]==c[j])t+=d[j];
		sum=max(sum,t);//找最大值
		return;
	}
	for(i=p[step-1];i<=m;i++){//注意，元素值非递减
		p[step]=i;//设置数组元素值
		dfs(step+1);
	}
}
int main(){
	int i;
	scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=q;i++)scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]),st=min(st,a[i]),ed=max(ed,b[i]);
	ed=ed-st+1,st=1,p[0]=1;//st,ed找数组脚标的边界，目标，脚标起始位置从1开始。
	dfs(1);
	printf("%d\n",sum);
	return 0;
}

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

typedef long long ll;

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

int main() { 
    ll S;
    cin >> S;
    ll d[S+1], mod = 1000000007;
    d[0] = 1;
    for (int i = 1; i <= S; ++i) {
        d[i] = 0;
        for (int j = 0; j <= i-3; ++j) {
            d[i] += d[j];
            d[i] %= mod;
        }
    }

    cout << d[S] % mod << "\n";
    return 0;
}

Measured memory_bytes: 3624
//ITP1_1_B
#include <iostream>
#include <cmath>

class ITP1_1_B
{
public:
    static void cubeNumber()
    {
        int num;
        std::cin >> num;
        std::cout << num * num * num << std::endl;
    }
};

class ITP1_1_C
{
public:
    int length;
    int breadth;
    int area;
    int perimeter;

    ITP1_1_C(int l, int b)
    {
        this->length = l;
        this->breadth = b;
        this->area = length * breadth;
        this->perimeter = 2 * (length + breadth);
    }
};

class ITP1_1_D
{
public:
    int originSecond;
    int hour;
    int minute;
    int second;

    explicit ITP1_1_D(int s)
    {
        originSecond = s;
        hour = (originSecond / 60) / 60;
        minute = (originSecond - 60 * 60 * hour) / 60;
        second = originSecond - 60 * 60 * hour - 60 * minute;
    }
};

class ITP1_2_A
{
public:
    static void judge(int a,int b)
    {
        if(a<b)
            std::cout<<"a < b"<<std::endl;
        else if(a == b)
            std::cout<<"a == b"<<std::endl;
        else
            std::cout<<"a > b"<<std::endl;
    }
};

int main()
{
    int a,b;
    std::cin>>a>>b;
    ITP1_2_A::judge(a,b);
}



Measured memory_bytes: 3056
#include<stdio.h>

#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest,t;
  l = 2*i;
  r = 2*i+1;

  if(l<=H&&A[l] > A[i]) largest = l;
  else largest = i;
  if(r<=H&&A[r] > A[largest]) largest = r;

  if(largest!=i){
    t=A[i];
    A[i]=A[largest];
    A[largest] = t;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d",&H);

  for(i = 1; i<=H;i++) scanf("%d",&A[i]);
      
  for(i = H/2; i>=1;i--) maxHeapify(i);

  for(i = 1; i<=H; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}



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

using namespace std;

ll n, m, d, k, br0;
ll neg[200010];
ll pos[200010];

int manjiNP(ll br, ll a)
{
    int l=0;
    int r=m-1;
    if(pos[m-1]*a>br) return 0;
    while(l<r)
    {
        int sr=(l+r)/2;
        if(a*pos[sr]>br)
            l=sr+1;
        else
            r=sr;
    }
    return m-l;
}

int manjiP(ll br, ll a)
{
    int l=0;
    int r=m-1;
    if(a*pos[0]>br)
        return 0;
    while(l<r)
    {
        int sr=(l+r+1)/2;
        if(a*pos[sr]>br)
            r=sr-1;
        else
            l=sr;
    }
    if(a*a<=br) return l;
    return l+1;
}

int manjiN(ll br, ll a)
{
    int l=0;
    int r=n-1;
    if(a*neg[0]>br)
        return 0;
    while(l<r)
    {
        int sr=(l+r+1)/2;
        if(a*neg[sr]>br)
            r=sr-1;
        else
            l=sr;
    }
    if(a*a<=br) return l;
    return l+1;
}

ll odredi(ll br)
{
    ll tk=0;
    if(br<0)
    {
        for(int i=0;i<n;i++)
            tk+=manjiNP(br,-neg[i]);
    }
    else
    {
        tk+=n*m;
        //if(br==0) tk-=br0*n;
        ll pp=0;
        for(int i=0;i<m;i++)
            pp+=manjiP(br,pos[i]);
        pp/=2;
        ll pn=0;
        for(int i=0;i<n;i++)
            pn+=manjiN(br,neg[i]);
        pn/=2;
        tk+=pp;
        tk+=pn;
    }
    return tk;
}

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

	cin>>d>>k;
	ll t;
	br0=0;
	while(d--)
    {
        cin>>t;
        if(t<0) neg[n++]=abs(t);
        else pos[m++]=t;

        if(t==0) br0++;
    }

    sort(neg,neg+n);
    sort(pos,pos+m);

	ll l=-1e18;
	ll r=1e18;
    //cout<<odredi(-6);
	//return 0;
	//cout<<odredi(7);
	ll sr;
	while(l<r)
    {
        //cout<<l<<" "<<r<<endl;
        sr=(l+r)/2;
        if(l+r<0) sr=(l+r-1)/2;
        ll tk=odredi(sr);
        if(tk<k)
            l=sr+1;
        else
            r=sr;
    }
    cout<<l;

    //cout<<"*"<<odredi(6);

	return 0;
}


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


int main(){
 string s;
 int n;
 cin>>s>>n;
 vector<string> ss(n);
 for(ll i=0;i<n;i++){
  string t;
  cin>>t;
  ss[i] = t+t;
 }

 ll cnt = 0;
 for(ll i=0;i<n;i++){
  bool f = false;

  for(ll j=0;j+s.size()<ss[i].size();j++){
   bool ff = true;
   for(ll k =0;k<s.size();k++){
    if( ss[i][j+k] == s[k] ){
    }else{
     ff = false;
     break;
    }
   }
   if( ff ){
    cnt++;
    break;
   }

  }

 }

 cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3168
n, m = gets.chomp.split(" ").map(&:to_i)
xs = gets.chomp.split(" ").map(&:to_i).sort
diffs = []
i = 0
while i < (xs.size - 1) do
  diffs.push xs[i+1] - xs[i]
  i += 1
end

puts diffs.sort.reverse.drop(n-1).reduce(&:+) || 0


Measured memory_bytes: 11888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, q, s;

    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    cin >> q;
    vector<int> m(q);
    for(int i = 0;i < q;i++){
        cin >> m[i];
    }

    vector<string> ans(q, "no");
    for(int i = 0;i < pow(2, n);i++){
        s = 0;
        for(int j = 0;j < n;j++){
            s += (i >> j & 1) * a[j];
        }
        for(int j = 0;j < q;j++){
            if(m[j] == s){
                ans[j] = "yes";
            }
        }
    }
    for(int i = 0;i < q;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3372
#include <cstdio>
#include <cstdint>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <vector>

const int inf=0x3f3f3f3f;

int main() {
	int N;
	std::cin>>N;
	uint64_t W;
	std::cin>>W;
	std::vector<int> weight(N);
	std::vector<int> value(N);
	int total_value = 0;
	for (int i = 0; i < N * 2; ++i) {
		int h;
		std::cin >> h;
		if (i % 2 == 0) {
			weight[i/2] = h;
		} else {
			value[i/2] = h;
			total_value += h;
		}
	}

	int dp[total_value+1];
	dp[0] = 0;
	for (int i = 1; i <= total_value; ++i) {
		dp[i] = inf;
	}
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		for (int j = total_value; j >= value[i-1]; j--) {
			dp[j] = std::min(dp[j], dp[j - value[i-1]] + weight[i-1]);
			if (dp[j] <= W) {
				ans = std::max(ans, j);
			}
			//printf("i[%d] j[%d] dp[%d]\n", i, j, dp[j]);
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long long H,W;
    cin >> H >> W;
    if (H !=1 && W != 1)
    {
        cout << (H*W)/2+(H*W)%2;
    }else{
        cout << 1;
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

var N, A, B, C int
var l []int

func main() {
	fmt.Scan(&N, &A, &B, &C)

	l = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&l[i])
	}

	fmt.Println(dfs(0, 0, 0, 0))
}

func dfs(n int, a int, b int, c int) int {
	if n == N {
		if Min(a,b,c) > 0 {
			return abs(A-a) + abs(B-b) + abs(C-c) - 30
		} else {
			return  100000
		}
	}

	nv := dfs(n+1, a, b, c)
	av := dfs(n+1, a+l[n], b, c) + 10
	bv := dfs(n+1, a, b+l[n], c) + 10
	cv := dfs(n+1, a, b, c+l[n]) + 10

	return Min(nv, av, bv, cv)
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

func Min(a ...int) int {
	min := int(^uint(0) >> 1)
	for _, i := range a {
		if i < min {
			min = i
		}
	}
	return min
}


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

using namespace std;

int main(){

  string s1,s2,s3;

  cin >> s1 >> s2 >> s3;
  cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef struct Dice{
	int	f1;
	int	f2;
	int	f3;
	int	f4;
	int	f5;
	int	f6;
}Dice;

int main(void)
{
	char roll;
	Dice D0;
	Dice Dw;
	scanf("%d%d%d%d%d%d", &D0.f1, &D0.f2, &D0.f3, &D0.f4, &D0.f5, &D0.f6);
	while(scanf("%c", &roll) != EOF){
		Dw.f1 = D0.f1;
		Dw.f2 = D0.f2;
		Dw.f3 = D0.f3;
		Dw.f4 = D0.f4;
		Dw.f5 = D0.f5;
		Dw.f6 = D0.f6;
		switch(roll){
			case 'E':
				D0.f1 = Dw.f4;
				D0.f3 = Dw.f1;
				D0.f4 = Dw.f6;
				D0.f6 = Dw.f3;
				break;
			case 'N':
				D0.f1 = Dw.f2;
				D0.f2 = Dw.f6;
				D0.f5 = Dw.f1;
				D0.f6 = Dw.f5;
				break;
			case 'S':
				D0.f1 = Dw.f5;
				D0.f2 = Dw.f1;
				D0.f5 = Dw.f6;
				D0.f6 = Dw.f2;
				break;
			case 'W':
				D0.f1 = Dw.f3;
				D0.f3 = Dw.f6;
				D0.f4 = Dw.f1;
				D0.f6 = Dw.f4;
				break;
			default:
				break;
		}
	}
	printf("%d\n", D0.f1);
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		String[] s = sc.next().split("");
		String[] t = sc.next().split("");
		
		StringBuilder sb = new StringBuilder();
		for(int i= 0; i < count;i++) {
			sb.append(s[i]);
			sb.append(t[i]);
		}
		System.out.println(sb);
	}

}

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

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using ll = long long int;
using ld = long double;
using vi = vector<int>;
using mii = map<int, int>;
using pii = pair<int, int>;

const int inf = 1e9;
const int N = 100005;
const ll mod = (ll) 1e9 + 7;

int32_t main(){
	fio;

	int x;
	cin >> x;
	cout << 1 - x << '\n';
	return 0;
}

/*

 */


Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n=0;
  string w,t;
  cin >>w;
  //小文字へ
  for(int i=0;i<(int)w.size(); i++){
    if((65<=w[i])&&(w[i]<=90)){
      w[i]+=32;
    }
  }
  
  while(cin>>t,t!="END_OF_TEXT"){

    for(int i=0;i<(int)t.size(); i++){
      if((65<=t[i])&&(t[i]<=90)){
	t[i]+=32;
      }
    }
    
    if(w==t){
      n+=1;
    }
  }
  cout <<n<<endl;

  return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int data[200000];
int olddata[200000];
int main(){
     int n;
     cin >> n;
     REP(i,n) {
      cin >> data[i];
      olddata[i] = data[i];
    }
     sort(data, data+n);
     int n1 = data[n-1];
     int n2 = data[n-2];
     REP(i,n){
      if(olddata[i] == n1) cout << n2 << endl;
      else cout << n1 << endl;
     }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int n,m;
const int INF = 1001001001;
int main(){
    cin >> n >> m;
    Graph G(n);
    rep(i,m){
        int a,b;cin >> a >> b;
        a--,b--;
        G[b].push_back(a);
        G[a].push_back(b);
    }
    queue<int> q;
    vector<int> dist(n,INF);
    vector<int> pre(n,-1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int u:G[v]){
            if(dist[u]!=INF) continue;
            dist[u] = dist[v]+1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    rep(i,n){
        if(i==0) continue;
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10680
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
const long long MaxN = 1e5;
 
struct xxx
{
	long long v;
	long long z;
	long long f;
}x[MaxN + 5];
 
bool cmp(struct xxx a1,struct xxx b1)
{
	return a1.f < b1.f;
}
 
struct yyy
{
	long long sum;
	long long mAx;
	long long hf;
}a[MaxN + 5],b[MaxN + 5];
 
int main()
{
	long long c,n,ans,piu,biu;
	while(~scanf("%lld %lld",&n,&c))
	{
		memset(x,0,sizeof(x));
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		ans = 0;
		for(long long i = 1;i <= n;i++)
		{
			scanf("%lld %lld",&x[i].z,&x[i].v);
			a[i].sum = a[i - 1].sum + x[i].v - x[i].z + x[i - 1].z;
			ans = max(ans,a[i].sum);
			if(a[i - 1].mAx < a[i].sum)
			{
				a[i].hf = x[i].z;
				a[i].mAx = a[i].sum;
			}
			else
			{
				a[i].hf = a[i - 1].hf;
				a[i].mAx = a[i - 1].mAx;
			}
			x[i].f = c - x[i].z;
		}
		sort(x + 1, x + 1 + n,cmp);
		for(long long i = 1;i <= n;i++)
		{
			b[i].sum = b[i - 1].sum + x[i].v - x[i].f + x[i - 1].f;
			ans = max(ans,b[i].sum);
			if(b[i - 1].mAx < b[i].sum)
			{
				b[i].hf = x[i].f;
				b[i].mAx = b[i].sum;
			}
			else
			{
				b[i].hf = b[i - 1].hf;
				b[i].mAx = b[i - 1].mAx;
			}
		}
		piu = 0;
		for(long long i = 1;i < n;i++)
		{
			piu = a[i].mAx - a[i].hf + b[n - i].mAx;
			ans = max(ans,piu);
			piu += a[i].hf - b[n - i].hf;
			ans = max(ans,piu);
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 7168
A = [None] * 9

A[0], A[1], A[2] = map(int, input().split(' '))
A[3], A[4], A[5] = map(int, input().split(' '))
A[6], A[7], A[8] = map(int, input().split(' '))

# print(A)

N = int(input())
# print(N)

ANS = [None] * 9
# print(ANS)


def main():

    for i in range(N):
        # print('i', i)
        choice = int(input())
        # print('choice:', choice)

        if choice in A:
            ANS[A.index(choice)] = 1


    # print('hitted ans:', ANS)

    if (ANS[0] == 1 and ANS[1] == 1 and ANS[2] == 1) or (ANS[3] == 1 and ANS[4] == 1 and ANS[5] == 1) or (
            ANS[6] == 1 and ANS[7] == 1 and ANS[8] == 1) or (ANS[0] == 1 and ANS[3] == 1 and ANS[6] == 1) or (
            ANS[1] == 1 and ANS[4] == 1 and ANS[7] == 1) or (ANS[2] == 1 and ANS[5] == 1 and ANS[8] == 1) or (
            ANS[0] == 1 and ANS[4] == 1 and ANS[8] == 1) or (ANS[2] == 1 and ANS[4] == 1 and ANS[6] == 1):
        return 'Yes'
    else:
        return 'No'


print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define io  ios_base::sync_with_stdio(false);    cin.tie(NULL);
#define vec  vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define MOD 1000000007
using namespace std;
 
 void solve()
 {
          ll i,z,c,d,y=0,x,l=0,A[1000],B[5004],a,b,s,j,m,n,num,p,q,k,r;
         string S="";
        // vec v(n),v1; 
          cin>>n;
          while(n>0)
          {
              n-=1;
              char ch;
              p=n%26;
              ch=(char)(97+p);
              S+=ch;
              n/=26;
          }
          for(i=S.length()-1;i>=0;i--)
         {
             cout<<S[i];
         }
          
          
 }
 
int main() 
{  io
    ll num;
num=1;
//cin>>num;
while(num--)
{ 
solve();

cout<<"\n";
}
return 0;
}

Measured memory_bytes: 3636
import sys
s = input()
for op1 in '+-':
    for op2 in '+-':
        for op3 in '+-':
            e = s[0]+op1+s[1]+op2+s[2]+op3+s[3]
            tmp = eval(e)
            if tmp == 7:
                print('%s=7'%e)
                sys.exit(0)




Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		int z=0;
		boolean fin=false;
		boolean we=false;
		while(z<S.length()){
			char a=S.charAt(z);
			if(z%2==0)
				if(a=='R'||a=='U'||a=='D')
					we=true;
				else
					fin=true;
			if(z%2==1)
				if(a=='L'||a=='U'||a=='D')
					we=true;
				else
					fin=true;
			z++;
		}
		if(fin)
			System.out.println("No");
		else
			System.out.println("Yes");
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &arr[i]);
        flag = arr[i] > max ? 1 : flag;
        prod *= arr[i];
        arr[i] ? max /= arr[i] : zero = 1;
    }
    if (zero) {
        printf("0\n");
    }
    else {
        flag ? printf("-1\n") : printf("%lld\n", prod);
    }
    return 0;
}


Measured memory_bytes: 2480
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int n;
    cin >> n;

    vector<int> a(n, 1000000);
    for(int i = 0; i < n - 1; i++){
        int b;
        cin >> b;

        a[i] = min(a[i], b);
        a[i + 1] = b;
    }

    int ans = 0;
    for(int i = 0; i < n; i++) ans += a[i];

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 251

int Parent(int i){
  return i/2;
}

int Left(int i){
  return 2*i;
}

int Right(int i){
  return (2*i)+1;
}

main(){
  int heap[MAX],id,size,left,right;
  
  scanf("%d",&size);
  for(id=1 ; id<=size ; id++){
    scanf("%d",&heap[id]);
  }

  for(id=1 ; id<=size ; id++){
    printf("node %d: key = %d, ",id,heap[id]);
    if(id>=2) printf("parent key = %d, ",heap[Parent(id)]);

    left = Left(id);
    right = Right(id);
    if(left<=size) printf("left key = %d, ",heap[left]);
    if(right<=size) printf("right key = %d, ",heap[right]);

    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
N, K = map(int, input().split())
A = [int(s) for s in input().split()]


def cntbit(bit):
    cnt = 0
    for a in A:
        if a & bit:
            cnt += 1
    return cnt


def getans(bink):
    if len(bink) == 1:
        if bink == "0":
            return cntbit(1)
        else:
            return N - cntbit(1)

    ans = 0
    bit = 1 << (len(bink) - 1)
    if bink[0] == "0":
        return bit * cntbit(bit) + getans(bink[1:])
    else:
        ans1 = bit * (N - cntbit(bit)) + getans(bink[1:])
        ans2 = 0
        ans2 += bit * cntbit(bit)
        for i in range(len(bink) - 1):
            bit = 1 << i
            cnt = cntbit(bit)
            ans2 += bit * max(cnt, N - cnt)
        return max(ans1, ans2)


bink = bin(K)[2:]
bink = "0" * (40 - len(bink)) + bink
print(getans(bink))


Measured memory_bytes: 68880
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>





using namespace std;

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MOD = 1000000007;
const int INF = INT_MAX;
const double PI = 3.14159265358979323846;



int main(int argc, char const *argv[])
{

    string s;
    cin >> s;

    s[3] = '8';

    cout << s << endl;





    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
#include <stdio.h>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int H, W;
    while(true){
    scanf("%d %d", &H, &W);
    if(H == 0) break;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++)
            printf("#");
        printf("\n");
    }
    printf("\n");
    }
    return 0;
}

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



int main(){
	int N;
	cin >> N;
	int tmp = N %10;
	if(tmp == 3) cout << "bon" << endl;
	else if (tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8) cout << "pon" << endl;
	else cout << "hon" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main() {
    int n;
    int a, b;
    scanf("%d", &n);
    scanf("%d %d", &a, &b);
    int uuu = 0;
    for(int i = a; i < b+1; ++i){
        if (i%n == 0){
            uuu = 1;
            break;
        }
    }
    
    if (uuu == 1)
        printf("OK\n");
    else
        printf("NG\n");
    return 0;
}


Measured memory_bytes: 1664