akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

 
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<vector<ll>> S(N+1, vector<ll>(62));
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        rep(j,62){
            if((A[i] >> j)&1LL){
                S[i+1][j] += S[i][j] + 1; 
            }else{
                S[i+1][j] = S[i][j];
            } 
        }
    }
    mint ans = 0;
    rep(i,62){
        mint t = S[N][i]*(N-S[N][i]);
        t *= mint(1LL << i);
        ans += t; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 162608
#include<iostream>
using namespace std;
int main(){
    int sub[30];
    for(int i = 0;i < 30;i++){
        sub[i] = 0;
    }
    int a;
    for(int i = 0;i < 28;i++){
        cin >> a;
        sub[a-1] = 1;
    }
    for(int i = 0;i < 30 ;i++){
        if(sub[i] == 0){
            cout << i+1 <<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<queue>
#include<stack>
#define N (1000000000+7)
typedef long long ll;
using namespace std;

int main(void){
    string s;
    stack<char>p,emptyp;
    while(true){
        getline(cin,s);
        if(s==".")break;
        while(!p.empty())p.pop();
        bool flag=true;
        //if(p.empty())cout<<"progin"<<" ";
        string t;
        for(int i=0;i<s.length();i++)if((s[i]=='(')||(s[i]==')')||(s[i]=='[')||(s[i]==']'))t+=s[i];
        for(int i=0;i<t.length();i++){
            if((t[i]=='(')||(t[i]=='[')){
                p.push(t[i]);
            }
            else{
                 if(t[i]==')'){
                    if(p.empty()){
                        cout<<"no"<<endl;
                        flag=false;
                        break;
                    }
                    else{
                        char a=p.top();
                        p.pop();
                        if(a=='['){
                            cout<<"no"<<endl;
                            flag=false;
                            break;
                        }
                    }
                }
                else if(t[i]==']'){
                    if(p.empty()){
                        cout<<"no"<<endl;
                        flag=false;
                        break;
                    }
                    else{
                        char a=p.top();
                        p.pop();
                        if(a=='('){
                            cout<<"no"<<endl;
                            flag=false;
                            break;
                        }
                    }
                }
            }
        }
        if(flag){
            if(p.empty())cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=0
s=a[0]
q=1
f=[1,a[0]]
d=set(f)
for _ in range(n):
  s=a[s-1]
  if s in d:
    break
  else:
    f.append(s)
    d.add(s)
g=f.index(s)
t=len(f[g:])
if k<(len(f)-t):
  print(f[k])
else:
  u=(k+t-len(f))%t
  print(f[g:][u])

Measured memory_bytes: 125172
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    ll n;cin>>n;
    vector<P> ans;
    for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
      if(n%2==0)if(not(n+1==i+j))ans.push_back(make_pair(i,j));
      if(n%2==1)if(not(n+0==i+j))ans.push_back(make_pair(i,j));
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
      cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
    return 0;
}



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

int main(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec.at(i);

    int count=0;
    while (1){
        //奇数判定
        bool odd = false;
        for (int i = 0; i < n; i++){
            if (vec.at(i)%2==1){
                odd = true;
            }
        }

        if(odd==true) break;

        //2で割ってカウント
        for (int i = 0; i < n; i++){
            vec.at(i)/=2;
        }

        count++;
    }

    cout << count << endl;
    
}

Measured memory_bytes: 256
import math

N = int(input())

*X,  = map(int, input().split())
total = sum(X)

c = math.ceil(total/N)
f = math.floor(total/N)

min_c = c
min_f = f
total_c = 0
total_f = 0


for x in X:
    total_c = total_c + (x-min_c)**2

for x in X:
    total_f = total_f + (x-min_f)**2

print(total_c if total_c <= total_f else total_f)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int main() {
    int N, L;
    int num = 0;
    int min = 0;
    int sum = 0;
    
    cin >> N >> L;

    vector<int> data(N);
    vector<int> data2(N);

    for (int i = 0; i < N; i++) {
        num = i + 1;
        data.at(i) = abs(L + num - 1);
        data2.at(i) = L + num - 1;
    }

    for (int i = 0; i < N; i++) {
        if (i == 0) {
            min = data.at(0);
        }

        if (min > data.at(i)) {
            min = data.at(i);
        }
    }

    for (int i = 0; i < N; i++) {
        if (abs(data2.at(i)) != min) {
            sum += data2.at(i);
        } 
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n,a;
  cin>>n;
  map<int,int> ma;
  for(int i=0;i<n;i++){
    cin>>a;
    ma[a]++;
    if(n%2==0){
      if(a>=n||a%2==0||ma[a]>2){
        cout<<0;
        return 0;
      }
    }else{
      if(a>=n||a%2==1||ma[a]>2||ma[0]>1){
        cout<<0;
        return 0;
      }
    }
  }
  if(n%2==0){
    for(int i=1;i<n;i+=2){
      if(ma[i]!=2){
        cout<<0;
        return 0;
      }
    }
    ll cnt=1;
    for(int i=0;i<n/2;i++){
      cnt*=2;
      cnt%=1000000007;
    }
    cout<<cnt;
  }else{
    if(ma[0]!=1){
      cout<<0;
      return 0;
    }
    for(int i=2;i<n;i+=2){
      if(ma[i]!=2){
        cout<<0;
        return 0;
      }
    }
    ll cnt=1;
    for(int i=0;i<n/2;i++){
      cnt*=2;
      cnt%=1000000007;
    }
    cout<<cnt;
  }
}

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

const int64_t mod = 1000000007;

int main() {
  int64_t n, m;
  cin >> n >> m;

  vector<bool> broken(n + 1);
  rep(i, m) { 
    int a;
    cin >> a;
    broken.at(a) = true;
  }

  vector<int64_t> dp(n + 2);
  dp.at(n) = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (broken.at(i)) {
      dp.at(i) = 0;
      continue;
    } else {
      dp.at(i) = (dp.at(i + 1) + dp.at(i + 2)) % mod;
    }
  }

  cout << dp.at(0) << endl;
  return 0;
}

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

int main() {
  int N;
  string S;
  cin >>N>>S;
  
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
int count=N;
  for(int i=0;i<N;i++){
    if(i+1<N){
    if(S.at(i)==S.at(i+1)){
      count--;
    }
    }
   }
  cout<<count<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define fi first
#define se second
 
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int maxm = 3e5 + 10;
const double PI = acos(-1.0);
const int inf = 1e9;
const double eps = 1e-6;



int main()
{
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    double a,b,x;
    cin >> a >> b >> x;
    double h = 2.0 * x / a / a - b;
    if(h >= eps) {
        //cout << h << endl;
        double ans = 180.0000000 *atan((b - h) / a) / PI;
        printf("%.6f",ans);
    }
    else {
        double ans =  a * b * b / 2.0 / x ;
        ans = 180.0000000 * atan(ans) / PI;
        printf("%.6f",ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        for (int i = 0; 1+i*a <= D; i++) {
            X++;
        }
    }

    cout << X << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

bool binarySearch(vector<int> vec, int target)
{
	int l = 0;
	int r = vec.size();
	while (l < r)
	{
		int mid = (l + r) / 2;
		if (vec[mid] == target)
		{
			return(true);
		}
		else if (vec[mid] < target)
		{
			l = mid + 1;
		}
		else
		{
			r = mid;
		}
	}
	return(false);
}

void solve()
{
	int n;
	cin >> n;
	vector<int> S(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> S[i];
	}
	int q;
	cin >> q;
	int ans = 0;
	for (int i = 0; i < q; ++i)
	{
		int t;
		cin >> t;
		if (binarySearch(S, t))
		{
			++ans;
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 1796
N, A, B, C = map(int, input().split())
l = []
for i in range(N):
    l.append(int(input()))
ans = 100000000


def rec(a, b, c, d):
    if d == N:
        if a[1] > 0 and b[1] > 0 and c[1] > 0:
            global ans
            ans = min(
                ans,
                abs(
                    a[0] - A) + abs(b[0] - B) + abs(c[0] - C)
                + 10 * (a[1] + b[1] + c[1] - 3)
            )
        return
    rec((a[0] + l[d], a[1] + 1), b, c, d + 1)
    rec(a, (b[0] + l[d], b[1] + 1), c, d + 1)
    rec(a, b, (c[0] + l[d], c[1] + 1), d + 1)
    rec(a, b, c, d + 1)


rec((0, 0), (0, 0), (0, 0), 0)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for(int i = 0; i<3;i++){
    for(int j = 0; j<3;j++){
      cin >> c.at(i).at(j);
    }
  }
   if(c.at(0).at(0)-c.at(1).at(0) ==
      c.at(0).at(1)-c.at(1).at(1) &&
      c.at(0).at(1)-c.at(1).at(1) ==
      c.at(0).at(2)-c.at(1).at(2) &&
      c.at(1).at(0)-c.at(2).at(0) ==
      c.at(1).at(1)-c.at(2).at(1) &&
      c.at(1).at(2)-c.at(2).at(2) ==
      c.at(1).at(1)-c.at(2).at(1)){
     cout << "Yes" << endl;
   } else {
     cout << "No" << endl;
   }
                        
      
      
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
  int N, L;
  cin >> N >> L;
  int res = (L - 1) * N + N * (N + 1) / 2;
  if (L + N - 1 < 0) {
    res -= L + N - 1;
  } else if (L > 0) {
    res -= L;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int H = GetInt();
		int W = GetInt();
		int numStone = 0;
		for(int i = 0; i < H; i++)
		{
			string S = GetString();
			for(int j = 0; j < W; j++)
				if(S[j] == '#')
					numStone++;
		}
		
		Console.WriteLine((numStone == (H + W - 1)) ? "Possible" : "Impossible");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
N=int(input())
D=[]
i=1
while(i*i<=N):
    if N%i==0:
        D.append(i)
        D.append(N//i)
    i+=1
ans=N-1
for i in D:
    j=N//i
    ans=min(ans,i+j-2)
print(ans)


Measured memory_bytes: 3264
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

//Range Minimum Query????????°???????????¨??§

const int MAXN = 1145140;

//?????°???????????¨???????????°??????????????????
int n, dat[2*MAXN-1];

//?????????
void init(int n_){
    //?°????????????????????´???°???2???????????????
    n = 1;
    while(n<n_) n *= 2;

    //??¨????????????INT_MAX???
    REP(i,2*n-1) dat[i] = INF;
}

//k????????????(0-indexed)???a????????´
void update(int k, int a){
    //????????????
    k += n-1;
    dat[k] = a;
    //?????????????????´??°
    while(k>0){
        k = (k-1) / 2;
        dat[k] = min(dat[k*2+1],dat[k*2+2]);
    }
}

//[a,b)???????°????????±???????
//????????????query(a,b,0,0,n)??¨???????????¶
int query(int a, int b, int k, int l, int r){
    //[a,b)??¨[l,r)?????????????????????????????°INF?????????
    if(r<=a || b<=l) return INF;

    //[a,b)???[l,r)????????¨???????????§????????°?????????????????????
    if(a<=l && r<=b) return dat[k];
    else {
        //????????§???????????°??????????????????????°????
        int vl = query(a,b,k*2+1,l,(l+r)/2);
        int vr = query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}

signed main(){
    int q;
    scanf("%d%d",&n,&q);
    init(n);

    REP(i,q){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        if(a) printf("%d\n",query(b,c+1,0,0,n));
        else update(b,c);
    }
    return 0;
}

Measured memory_bytes: 4236
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		a = scanner.nextInt();
		b = scanner.nextInt();
		str = new char[a][b];
		for (int i = 0; i < a; i++)
			str[i] = scanner.next().toCharArray();
		pat = new char[2][2];
		for (int i = 0; i < 2; i++)
			pat[i] = scanner.next().toCharArray();
		int ret = 0;
		ans = 0;
		map = new boolean[a][b];
		for (int i = 0; i < a - 1; i++) {
			loop: for (int j = 0; j < b - 1; j++) {
				for (int k = 0; k < 2; k++) {
					for (int l = 0; l < 2; l++) {
						if (str[i + k][j + l] != pat[k][l])
							continue loop;
					}

				}
				map[i][j] = true;
				ans++;

			}
		}
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				for (int k = 0; k < 3; k++) {
					if (str[i][j] == cs[k])
						continue;
					char tmp = str[i][j];
					str[i][j] = cs[k];
					ret = Math.max(ret, slove(i, j));
					str[i][j] = tmp;
				}
			}
		}
		System.out.println(ret + ans);
	}

	private int slove(int p, int q) {
		int ret = 0;
		for (int i = p - 1; i <= p; i++) {
			loo: for (int j = q - 1; j <= q; j++) {
				if (i < 0 || a - 1 <= i || j < 0 || b - 1 <= j)
					continue;
				for (int k = 0; k < 2; k++) {
					for (int l = 0; l < 2; l++) {
						if (str[i + k][j + l] != pat[k][l]) {
							if (map[i][j])
								ret--;
							continue loo;
						}
					}

				}
				if (!map[i][j])
					ret++;
			}
		}
		return ret;
	}

	int a, b, ans;
	boolean[][] map;
	char[][] str, pat;
	char[] cs = { 'J', 'O', 'I' };
}

Measured memory_bytes: 33924
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  string s;
  cin >> s;
  int sz=s.size();
  cout << s[0] << sz-2 << s[sz-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  int p = 0, g = 0;
  int win = 0, lose = 0;
  rep(i,n){
    if(p < g){
      if(s[i] == 'g') win++;
      p++;
    }else{
      if(s[i] == 'p') lose++;
      g++;
    }
  }
  cout << win-lose;
  cout << "\n";
  return 0;
}


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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
auto id = [](T b) { return b; };

const int MAX_H = 2000, MAX_W = 2000;
int h,w;
string s[MAX_H];
int hist[MAX_H-1][MAX_W-1] = {};
int l[MAX_H], r[MAX_H];

int main()
{
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }

  for (int i = 0; i < h-1; i++) {
    for (int j = 0; j < w-1; j++) {
      int bc = 0;
      if (s[i][j] == '#') bc++;
      if (s[i][j+1] == '#') bc++;
      if (s[i+1][j] == '#') bc++;
      if (s[i+1][j+1] == '#') bc++;
      hist[i][j] = bc % 2 == 0 ? 1 : 0;
      //cout << hist[i][j];
    }
    //cout << endl;
    int cons = 0;
    for (int j = w-2; j >= 0; j--) {
      cons = hist[i][j] = hist[i][j] * (cons + 1);
      //printf("hist[%d][%d]=%d\n",i,j,hist[i][j]);
    }
  }

  int m = 0;
  for (int j = 0; j < w-1; j++) {
    stack<int> st1, st2;
    for (int i = 0; i < h-1; i++) {
      while (!st1.empty() && hist[st1.top()][j] >= hist[i][j])
        st1.pop();
      l[i] = st1.empty() ? -1 : st1.top();
      st1.push(i);
    }

    for (int i = h-2; i >= 0; i--) {
      while (!st2.empty() && hist[st2.top()][j] >= hist[i][j])
        st2.pop();
      r[i] = st2.empty() ? h-1 : st2.top();
      st2.push(i);
    }

    for (int i = 0; i < h-1; i++) {
      m = max(m, (r[i]-l[i])*(hist[i][j]+1));
    }
  }

  cout << max(m,max(h,w)) << endl;

  return 0;
}


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

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char grid[][] = new char[w][h];
        for (int y = 0;y < h;++y){
            String s = sc.next();
            for (int x = 0;x < w;++x){
                grid[x][y] = s.charAt(x);
            }
        }

        for (int y = 0;y < h;++y){
            for (int x = 0;x < w;++x){
                if(grid[x][y] == '#'){
                    int c = 0;
                    if(x > 0){
                        if(grid[x - 1][y] == '#')++c;
                    }
                    if(y > 0){
                        if(grid[x][y - 1] == '#')++c;
                    }
                    if(x < w - 1){
                        if(grid[x + 1][y] == '#')++c;
                    }
                    if(y < h - 1){
                        if(grid[x][y + 1] == '#')++c;
                    }
                    if(c == 0){
                        System.out.println("No");
                        return;
                    }
                }
            }
        }
        System.out.println("Yes");
        //sout
    }



}

Measured memory_bytes: 21460
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

while True:
    N, W, D = map(int, input().split())
    if N == 0 and W == 0 and D == 0:
        break    
    cakes = [(W * D, W, D)]
    for i in range(N):
        p, s = map(int, input().split())
        _, w, d = cakes.pop(p - 1)
        s %= (2 * w + 2 * d)
        A = 0
        B = 0
        if s <= w:
            A = (s * d, s, d)
            B = ((w - s) * d, w - s, d)
        elif s <= w + d:
            y = s - w
            A = (w * y, w, y)
            B = (w * (d - y), w, (d - y))
        elif s <= 2 * w + d:
            x = 2 * w + d - s
            A = (x * d, x, d)
            B = ((w - x) * d, w - x, d)
        else:
            y = (2 * w + 2 * d) - s
            A = (w * y, w, y)
            B = (w * (d - y), w, (d - y))
        
        if A[0] > B[0]:
            A, B = B, A
        cakes.append(A)
        cakes.append(B)
    print(" ".join(map(lambda cake: str(cake[0]), sorted(cakes))))


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

int main(){
    int n, d[100][2], i, j, flag = 1;

    scanf("%d", &n);

    for(i = 0;i < n;i++){
        for(j = 0;j < 2;j++){
            scanf("%d", &d[i][j]);
        }
    }

    for(i = 0;i < n - 2;i++){
        if(d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]){
            flag = 0;
        }
    }
    if(flag) puts("No");
    else puts("Yes");

    return 0;
}


Measured memory_bytes: 2092
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <functional>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <climits>

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long N;
	cin >> N;

	ans = LLONG_MAX;
	for (i = 1; i < N; i++) {
		j = N - i;
		long long sum;
		sum = (i / 100000) + (i / 10000 % 10) + (i / 1000 % 10) + (i / 100 % 10) + (i / 10 % 10) + (i % 10);
		sum += (j / 100000) + (j / 10000 % 10) + (j / 1000 % 10) + (j / 100 % 10) + (j / 10 % 10) + (j % 10);
		
		ans = min(ans, sum);
	}

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

Measured memory_bytes: 256
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>

using namespace std;

#define sz(X) ((int)(X).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define all(X) (X).begin(),(X).end()
#define FOR(i, a, n) for(int i=(a), __ ## i=(n); i<__ ## i; i++)
#define REP(I,N) FOR(I,0,N)
#define PR(X) cout<<#X<<" = "<<(X)<<" "
#define PRL cout<<endl
#define PRV(X) {cout<<#X<<" = {";REP(__prv,sz(X)-1)cout<<(X)[__prv]<<",";if(sz(X))cout<<*(X).end();cout<<"}"<<endl;}

template<class T> ostream &operator<<(ostream &os, const vector<T> &vec)
{
	os << '{';
	REP(i, sz(vec))
	{
		os << vec[i];
		if (i + 1 != sz(vec))
			os << ',';
	}
	os << '}';
	return os;
}

template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &par)
{
	os << '(' << par.X << ',' << par.Y << ')';
	return os;
}

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<bool> VB;
typedef vector<unsigned long long> VULL;
typedef vector<vector<int>> VVI;
typedef queue<int> QI;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : abs(x);
}

template<class T> T sqr(T x)
{
	return x * x;
}

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	VI result(26, 1000000);
	REP(i, n)
	{
		string s;
		cin >> s;

		VI cur(26);
		REP(j, s.length())
		{
			cur[s[j] - 97]++;
		}

		REP(j, 26)
			result[j] = min(result[j], cur[j]);
	}

	REP(i, 26)
	{
		while (result[i] > 0)
		{
			cout << (char)(97 + i);
			result[i]--;
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), z = in.nextInt(), w = in.nextInt();
			int[] a = in.nextIntArray(n);

			if (n == 1) {
				out.println(abs(a[0]-w));
			} else {
				out.println(max(abs(a[n-1]-a[n-2]), abs(a[n-1]-w)));
			}
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23124
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int W,H,i,j;
    
    while(1){
        scanf("%d %d",&H ,&W);
        if(W==0 && H==0){
            break;
        }
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                if((i+j)%2 ==0){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

// 繰り返し二乗法を用いて a の n 乗を算出する(ただし mod m の空間内)
long long modpow(long long a, long long n, long long mod)
{
    long long ret = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            ret *= a;
            ret = ret % mod;
        }
        a *= a;
        a = a % mod;
        n = (n >> 1);
    }
    return ret;
}

long long modnCk(long long n, long long k, long long mod)
{
    long long ret = 1, x = 1, y = 1;
    for (long long i = 0; i < k; ++i)
    {
        x *= (n - i);
        x = x % mod;

        y *= (k - i);
        y = y % mod;
    }
    ret = modpow(y, mod - 2, mod) % mod;
    ret = (ret * x) % mod;
    return ret;
}

int main()
{
    long long mod = 1000000007;
    long long n, a, b;
    cin >> n >> a >> b;
    long long x = modpow(2, n, mod) - 1;
    x = x % mod;
    long long y = modnCk(n, a, mod) + modnCk(n, b, mod);
    y = y % mod;
    long long ans = (x - y + mod) % mod; // C++ だと余りが負になる場合があるのでmodを足して余りがゼロ以上になるようにする
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    vector <int> p(n);
    double m=0.0;
    double mx=0.0;
    vector <double> exp(n);
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    for(int i=0;i<n;i++)
    {
        exp[i]=(double) (p[i]+1)/2;
    }
    
    queue <double> q;

    for(int i=0;i<n;i++)
    {
        m+=exp[i];
        q.push(exp[i]);
        if(q.size()>k)
        {
            m -= q.front();
            q.pop();
        }
        if(q.size()==k)
        {
            mx = max(mx,m);
        }
    }
    
    printf("%.8f", mx);
    return 0;
}

Measured memory_bytes: 4224
import sys
import math
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()

N=ni()
m=[0]*5
for i in range(N):
    tmp = input()
    if(tmp[0]=="M"):
        m[0]+=1
    elif(tmp[0]=="A"):
        m[1]+=1
    elif(tmp[0]=="R"):
        m[2]+=1
    elif(tmp[0]=="C"):
        m[3]+=1
    elif(tmp[0]=="H"):
        m[4]+=1
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += m[i]*m[j]*m[k]
#print(m)
print(ans)




Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int r,i;
    scanf("%d%d",&r,&i);
    if((r==1&&i==2)||(r==2&&i==1)){
        printf("3\n");
    }
    else if((r==1&&i==3)||(r==3&&i==1)){
        printf("2\n");
    }
    else if((r==2&&i==3)||(r==3&&i==2)){
        printf("1\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k,r,p,s,points=0;
cin>>n>>k>>r>>s>>p;
string st,a="";
cin>>st;
for(int i=0;i<st.size();i++)
{
    if(st.at(i)=='r')
    {
        if(i<k||(i>=k&&a.at(i-k)!='p'))
        {
            a+="p";
            points+=p;
        }
        else
        a+=" ";
        
    }

    else if(st.at(i)=='p')
    {
        if(i<k||(i>=k&&a.at(i-k)!='s'))
        {
            a+="s";
            points+=s;
        }
        else
        a+=" ";
        
        
    }
    
    else if(st.at(i)=='s')
    {
    if(i<k||(i>=k&&a.at(i-k)!='r'))
        {
            a+="r";
            points+=r;
        }
        
    else
        a+=" ";
    
    }
}
    cout<<points;
    
    

return 0;
}


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

struct tree{
  int ki;
  struct tree *right,*left,*parent;
};

struct tree *root,*nil;

void insert(int);
void inwalk(struct tree *);
void prwalk(struct tree *);
struct tree * find(struct tree*,int);

void insert(int k)
{
  struct tree *a=root,*b=nil,*c;

  c = (struct tree *)malloc(sizeof(struct tree));
  c->ki = k;
  c->left = nil;
  c->right = nil;

  while(a!=nil) {
    b = a;
    if(c->ki < a->ki) {
      a = a->left;
    }else{
      a = a->right;
    }
  }

  c->parent = b;
  if(b == nil) {
    root = c;
  }else{
    if(c->ki < b->ki) {
      b->left = c;
    }else{
      b->right = c;
    }
  }
}

void inwalk(struct tree *x)
{
  if(x == nil)
    return;
  inwalk(x->left);
  printf(" %d",x->ki);
  inwalk(x->right);
}

void prwalk(struct tree *y)
{
  if(y == nil)
    return;
  printf(" %d",y->ki);
  prwalk(y->left);
  prwalk(y->right);
}

struct tree * find(struct tree *z,int k)
{
  while(z != nil && k != z->ki) {
    if(k < z->ki) {
      z = z->left;
    }else{
      z = z->right;
    }
  }
    return z;
}

int main()
{
  int m,k,i;
  char ins[10];

  scanf("%d",&m);

  for(i=0;i<m;i++) {
    scanf("%s",ins);
    if(ins[0] == 'f') { /*f = find*/
      scanf("%d",&k);
      struct tree *t = find(root,k);
      if(t != nil) {
	printf("yes\n");
      }else{
	printf("no\n");
      }
    }else if(ins[0] == 'i') { /*i = insert*/
      scanf("%d",&k);
      insert(k);
    }else if(ins[0] == 'p') { /*p = print*/
      inwalk(root);
      printf("\n");
      prwalk(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20488
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	vector<int> A;
	char group = S[0];//'0'のグループか '1'のグループかを格納
	int cnt = 0;
	for(int i=0; i<N; i++){
		if(S[i] == group) cnt++;
		else{
			A.push_back(cnt);
			group = S[i];
			cnt = 1;
		}
	}
	A.push_back(cnt);

	// if(A.size() == 1){ 
		// ここ入れないと 入力が 1 1 0　のとき，2K回ループするところで範囲外参照起こす
		// もう A.size()を intにキャストすることで解決したので　ここはコメントアウト
	// 	cout << N << endl;
	// 	return 0;
	// }
	vector<int> wa;
	wa.push_back(0);
	for(int i=0; i<A.size(); i++) wa.push_back(wa.back()+A[i]);
	// cout << " A: "; print_vec(A);

	int ans = 0;
	if(S[0] == '0'){//左端が0のグループの場合
		int tmp = 0;
		for(int i=0; i<2*K; i++){
			if(i<A.size()) tmp += A[i];
		}
		ans = max(ans, tmp);	
	}
	if(S.back() == '0'){//右端が0のグループの場合
		int tmp = 0;
		for(int i=0; i<2*K; i++){
			if(int(A.size())-1 - i >= 0) tmp += A[A.size()-1 - i];// A.size()をintにキャストしないと， A.size()-1が範囲外参照的な感じで壊れた値になる
			// cout << " i : " << i << "     A.size(): " << A.size() <<  "   index: " << (int)A.size() - 1 - i <<  "    tmp: " << tmp << endl;
		}
		ans = max(ans, tmp);
	}
	// cout << "1 A.size() = " << A.size() << "    wa.size() = " << wa.size() << endl;
	if(S[0] == '0'){
		reverse(wa.begin(), wa.end());
		wa.pop_back();
		reverse(wa.begin(), wa.end());
	}
	// cout << "2 A.size() = " << A.size() << "    wa.size() = " << wa.size() << endl;
	if(S.back() == '0') wa.pop_back();
	// cout << "3 A.size() = " << A.size() << "    wa.size() = " << wa.size()<< endl;

	int range = 2*K + 1;
	for(int left = 0; left<wa.size(); left +=2){//0のグループから選ぶ意味はないのでleft+=2
		int right = left + range;
		if(right > wa.size()-1) right = wa.size() - 1;
		if(right < left) continue;
		ans = max(ans, wa[right]-wa[left]);
	}

	cout << ans << endl;
	
	


}



Measured memory_bytes: 4456
using System;
using System.Linq;
using System.Collections.Generic;

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
         
        var primeFactors = PrimeFactors(n);
         
        string output = primeFactors.Count() == 0 
                        ? n.ToString() 
                        : string.Join(" ", primeFactors.Select (f => f.ToString()).ToArray()); //AOJ??¨
                        //:string.Join(" ", primeFactors);
        Console.WriteLine("{0}: {1}", n, output);
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i * i <= n)
        {
            if(tmp % i == 0){
                tmp /= i;
                yield return i;
            }else{
                i++;
            }
        }
		if(tmp != 1) yield return tmp;
    }
}

Measured memory_bytes: 20292
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int main(){
  string ans;
  char S;
  cin>>S;
  if (S>='a' && S<= 'z')ans="a";
  else ans="A";
  cout<<ans<<endl;
}


Measured memory_bytes: 3624
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;



public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	   int n = sc.nextInt();
	   int k = sc.nextInt();
	   int[] v = new int[n];
	   for(int i = 0; i < n; i++) {
		   v[i] = sc.nextInt();
	   }
	   ArrayList<Integer> list = new ArrayList<>();
	   int tim = Math.min(n, k);
	   int ans = 0;
	   for(int a = 0; a <= tim; a++) {
		   for(int b = 0; b <= tim-a; b++) {
			   if (a == b && b == 0)
					continue;
			   list.clear();
			   for(int i = 0; i < a; i++) {
				   list.add(v[i]);
			   }
			   for(int i = 0; i < b; i++) {
				   list.add(v[n-i-1]);
			   }
			   Collections.sort(list);
			   int i = 0;
			   while(i<k-(a+b)&&i<a+b&&list.get(i)<0) {
				   i++;
			   }
			   int sum = 0;
			   for(;i < a+b; i++) {
				   sum+=list.get(i);
			   }
			   if(ans<sum)ans = sum;
		   }
	   }
	   System.out.println(ans);
	}
}

Measured memory_bytes: 24276
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
using namespace std;

int main()
{
	#ifdef DEBUG
	freopen("text.in", "r", stdin);
	#endif
	int x;
	scanf("%d", &x);
	puts(x >= 30 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3664
A, B, C, D, E, F = map(int, input().split())
X = [1] + [0] * F
Y = [1] + [0] * F
for i in range(1, F+1):
    if i >= A*100 and X[i-A*100]: X[i] = 1
    if i >= B*100 and X[i-B*100]: X[i] = 1
    if i >= C and Y[i-C]: Y[i] = 1
    if i >= D and Y[i-D]: Y[i] = 1

ans = (0, 0)
ratio = -1
for i in range(100, F+1, 100):
    for j in range(F+1):
        if X[i] and Y[j]:
            if j <= i // 100 * E and i + j <= F:
                if j / i > ratio:
                    ans = (i+j, j)
                    ratio = j / i
print(*ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

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

dic= defaultdict(int)
for idx, a in enumerate(A):
    dic[a] = idx + 1

for i in range(1,N+1):
    print(dic[i], end=' ')
print()


Measured memory_bytes: 63524
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n,m;cin>>n>>m;

	bool res = true;
	Graph G(n);

	rep(i,m) {
		int a,b;
		cin >> a >> b;
		G[a-1].pb(b-1);
		G[b-1].pb(a-1);
	}

    vector<int> dist(n, -1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);


	vector<int> ans(n, -1);
    while (!que.empty()) {
        int v = que.front();
        que.pop();


        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
			ans[nv] = v+1;
			
            que.push(nv);
        }
    }

    rep(i,n) {
		if (dist[i]==-1) {
			ct("No");
			return 0;
		}
	}
	cout << "Yes" << "\n";
	for(int v=1; v<n; ++v) {
		cout << ans[v] << "\n";
	}
}


Measured memory_bytes: 10592
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int D, G;
int p[13];
int c[13];


int minimum = INF10;


int dfs(int idx, int max_id, int init_score, int cnt) {
	if (idx == D) {
		int score = init_score;
		int num_max_id = p[max_id] - 1;
		while (score < G) {
			if (num_max_id == 0)break;
			score += (max_id + 1) * 100;
			num_max_id -= 1;
			cnt++;
		}
		if (score < G)return 0;
		else {
			minimum = min(minimum, cnt);
		}
		return 0;
	}
	dfs(idx + 1, idx, init_score, cnt);
	dfs(idx + 1, max_id, init_score + (idx + 1) * 100 * p[idx] + c[idx], cnt+p[idx]);
	return 0;
}

void solve() {
	dfs(0, 0, 0, 0);
	print(minimum);
	return;
}



int main() {
	cin >> D >> G;
	for (int i = 0; i < D; i++) {
		cin >> p[i] >> c[i];
	}

	solve();

	return 0;
}

Measured memory_bytes: 256
N = int(input())
list_a  = list(map(int, input().split()))

list_a.sort()

sum_of_diff = 0

while list_a:
	tmp_a = list_a.pop()
	try:
		tmp_b = list_a.pop()
	except:
		tmp_b = 0
	sum_of_diff += tmp_a - tmp_b

print(sum_of_diff)



Measured memory_bytes: 2940
# Digital Gifts

N = int(input())
x = []
u = []
for i in range(N) :
    x1, u1 = [i for i in input().split()]
    x.append(float(x1))
    u.append(u1)

def calc(wkX, wkU, Num) :
    total = 0
    for i in range(Num) :
        if wkU[i] == "JPY" :
            total += wkX[i]
        else :
            total = total + (wkX[i] * 380000.0)
    return total

print(calc(x, u, N))

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n - 1; ++i)
    {
        ans += (n / i) - (n % i == 0);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3672
n,q = map(int,input().split())
s = input()
count = [0]*n
for i in range(1,n):
    count[i] += count[i-1]
    if s[i-1:i+1] == "AC":count[i] += 1
for i in range(q):
    l,r = map(int,input().split())
    print(count[r-1]-count[l-1])

Measured memory_bytes: 7700
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n,a[200005];
	cin>>n;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	rep(i,n-1) if (a[i]==a[i+1]) {cout<<"NO";return 0;}
	cout<<"YES";
	return 0;
}


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

int N,M;
int FS[310][310];
vector<int>K;
  
int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>FS[i][j];
    }
  }
  for(int i=1;i<=M;i++){
    K.push_back(i);
  }
  int eachmaxcnt=0;
  int maxcnt=300;
  int C[310];
  int temp=0;
  
  //ゲームの種類分回す
  while(K.size() !=0){
  //for(int l=0;l<M;M++){
    
    //各ゲームの参加者数を初期化
    for(int i=1;i<=M;i++){
      C[i]=0;
    }
    //for(auto it=K.begin();it != K.end();it++){
      for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
          //最初にでてくるゲームの参加者を加算
          if(FS[i][j] != -1){
            C[FS[i][j]]++;
            break;
          }
        }
      //}
    }
    
    //最大参加者数を求める
    eachmaxcnt=0;
    for(int i=1;i<=M;i++){
      if(eachmaxcnt<C[i]){
        eachmaxcnt=C[i];
        temp=i;
      }
    }

    //最大参加者数の更新
    maxcnt=min(maxcnt,eachmaxcnt);
    //cout<<temp<<" "<<maxcnt<<endl;
    
    //最大参加者のゲームを削除
    K.erase(remove(K.begin(),K.end(),temp),K.end());
    
    //最大参加者のゲームを-1にする
    for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
        if(FS[i][j]==temp){
          FS[i][j]=-1;
        }    
      }
    }
  }    

  cout<<maxcnt<<endl;
  return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
deque<int> q;
char s[maxn];
int dp[maxn],pre[maxn],n,m,ans[maxn],cnt;
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	q.push_back(1);
	for(int i=2;i<=n+1;++i)
	{
		if(s[i]=='1') continue;
		while(!q.empty()&&q.front()<i-m) q.pop_front();
		if(q.empty())
		{
			puts("-1");
			return 0;
		}
		dp[i]=dp[q.front()]+1;pre[i]=q.front();
		while(!q.empty()&&dp[q.back()]>dp[i]) q.pop_back();
		q.push_back(i);
	}
	int tp=n+1;
	while(pre[tp]) ans[++cnt]=tp-pre[tp],tp=pre[tp];
	for(int i=cnt;i;--i) printf("%d ",ans[i]);
  	puts(" ");
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int c(const void* a,const void* b){
  int x=*(int *)a,y=*(int *)b;
  return x-y;
}
int type_count(int* a,int n);
int main(){
  int n;
  scanf("%d",&n);
  int i,flag=1,a[n];
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
  if(n%3){
    for(i=0;i<n;i++){
      if(a[i])flag=0;
    }
  }else{
    qsort(a,n,sizeof(int),c);
    int count=type_count(a,n);
    if(count==1)flag=a[0]?0:1;
    else if(count>3) flag=0;
    else if(count==2){
      int c0=0,c1=0;
      for(i=0;i<n;i++){
	if(a[i]==a[0])c0++;
	else c1++;
      }
      if(c1==c0*2 && a[0]==0)flag=1;
      else flag=0;
    }else{
      flag=(a[0]==a[n/3-1] && a[0]!=a[n/3] && a[n/3]==a[n/3*2-1] && a[n/3]!=a[n/3*2] && ((a[0]^a[n/3])==a[n/3*2]))?1:0;
      if(df)printf("%d^%d=%d?%d",a[0],a[n/3],a[n/3*2],a[0]^a[n/3]);
    }
  }

  printf("%s",flag?"Yes":"No");
  return 0;
}

int type_count(int* a,int n){
  int k=1,past=a[0],i;
  for(i=0;i<n;i++){
    if(a[i]==past)continue;
    k++;
    past=a[i];
  }
  return k;
}


/// confirm df==0 ///


Measured memory_bytes: 892