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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
bool HasBit(ll x, int b) {
    return (x >> b) & 1;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    vector<ll> arr(n);
    ll xorsum = 0;
    loop(n) {
        cin >> arr[i];
        xorsum ^= arr[i];
    }
    if (xorsum == 0) {
        RET(0);
    }
    xorsum ^= arr[0] ^ arr[1];
    ll sum = arr[0] + arr[1];
    if (xorsum > sum) {
        RET(-1);
    }
    if ((sum - xorsum) & 1) {
        RET(-1);
    }
    ll andval = (sum - xorsum) >> 1;
    if (xorsum & andval) {
        RET(-1);
    }
    ll a = 0;
    vector<ll> val(51, 0);
    for (int i = 0; i <= 50; ++i) {
        if (HasBit(xorsum, i)) {
            val[i] = 1LL << i;
        }
        if (i) {
            val[i] += val[i - 1];
        }
        if (!HasBit(xorsum, i) && HasBit(andval, i)) {
            a |= 1LL << i;
        }
    }
    for (int i = 50; i >= 0; --i) {
        if (a >= arr[1]) {
            break;
        }
        if (HasBit(xorsum, i) && a + val[i] - (1LL << i) < arr[1]) {
            a |= 1LL << i;
        }
    }
    ll ans = a - arr[1];
    if (ans < 0 || ans >= arr[0]) {
        RET(-1);
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

const int INF = 0x3f3f3f3f;
const int MAX_M = 10, MAX_N = 40;

int N, A, B, asum, bsum, cmin;
int a[MAX_N], b[MAX_N], c[MAX_N];
int dp[MAX_N + 1][MAX_M * MAX_N + 1][MAX_M * MAX_N + 1];

main() {
  cin >> N >> A >> B;
  REP(i, N) cin >> a[i] >> b[i] >> c[i];

  REP(i, N) asum += a[i];
  REP(i, N) bsum += b[i];

  REP(ca, asum + 1) REP(cb, bsum + 1) {
    dp[0][ca][cb] = INF;
  }
  dp[0][0][0] = 0;
  REP(i, N) REP(ca, asum + 1) REP(cb, bsum + 1) {
    if (ca >= a[i] && cb >= b[i]) {
      dp[i + 1][ca][cb] = min(dp[i][ca][cb], dp[i][ca - a[i]][cb - b[i]] + c[i]);
    } else {
      dp[i + 1][ca][cb] = dp[i][ca][cb];
    }
  }
  cmin = INF;
  REP(ca, asum + 1) REP(cb, bsum + 1) {
    if (ca == 0 && cb == 0) continue;
    if (ca * B == cb * A && dp[N][ca][cb] < cmin) cmin = dp[N][ca][cb];
  }

  cout << (cmin < INF ? cmin : -1) << endl;
}


Measured memory_bytes: 17024
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define rep(i,n) for(int i=0;i<n;i++)
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int h,w;
set<P> st;
char a;
int dp[1010][1010];
signed main(){
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			cin>>a;
			if(a=='#')st.insert({i,j});
		}
	}
	dp[0][0]=1;
	rep(i,h){
		rep(j,w){
			if(st.find({i,j})!=st.end()){
				dp[i][j]=0;
				continue;
			}
			if(!i&&!j)continue;
			if(!i)dp[i][j]=dp[i][j-1];
			else if(!j)dp[i][j]=dp[i-1][j];
			else dp[i][j]=dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=moder;
		}
	}
	cout<<dp[h-1][w-1]<<endl;
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    bool f = false;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == '7') {
            f = true;
        }
    }
    cout << (f?"Yes":"No") << endl;

}



Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int i;
	int j;
	
	for (i = 1; i <= 9; i++){
		for (j = 1; j <= 9; j++){
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return (0);
}

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

int main() {
  string S,T;
  cin >> S;
  cin >> T;
  
  int c=0;
  int s;
  s = S.size();
  for(int i=0;i<s;++i){
    if(S[i]==T[i]) c++;
  }
  if( c==s && T.size()==s+1 ) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      int[][] ans = new int[h][w];
      int i = 0;
      int j = 0;
      for(int c= 0;c < n;c++){
      	while(a[c]>0){
          ans[i][j]=c+1;
          a[c]--;
          j+=(i%2==0)?1:-1;
          if(j<0){
            i++;
            j=0;
          }else if(j>=w){
            i++;
            j=w-1;
          }
        }
      }
      for(int l = 0;l < h;l++){
        System.out.print(ans[l][0]);
      	for(int q = 1;q < w;q++){
        	System.out.print(" "+ans[l][q]);
        }
        System.out.println("");
      }
    }
}


Measured memory_bytes: 34540
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int m,n;
  cin >> n >> m;
  vector<pair<int,int>> p(n);
  REP(i,n) cin >> p[i].first >> p[i].second;
  sort(ALL(p));
  ll cost=0;
  REP(i,n){
    int b = min(m,p[i].second);
    m -= b;
    cost += (ll)b * p[i].first;
    if(m<=0) break;
  }
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 1024
#(身長)ー（番号）＝ー（身長）ー（番号）はありえない、身長=0にならないから
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
AB = defaultdict(int)
_AB = defaultdict(int)
for i,a in enumerate(A):
    AB[i+1+A[i]]+=1
    _AB[-A[i]+i+1]+=1
ans = 0
for key,val in AB.items():
    ans += val*_AB[key]
print(ans)


Measured memory_bytes: 149428
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int n, N, a[100010];
char s[10];

int main(){
	scanf("%d%s", &n, s+1);
	N = (n+1)/2;
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	if (((s[1] == 'A') && (n%2 != 0)) || ((s[1] == 'B') && (n%2 == 0))){
		int ans = a[n];
		for(int i = 1; i <= n-N; i++)
			ans = min(ans,a[i+N]-a[i]);
		cout << ans << endl;
	} else {
		int l = 0, r = a[n], ans = 0;
		while (l <= r) {
			int mid = (l+r)/2, cnt = 1;
			for(int i = 1, j = 1; i <= n; i++)
				if (a[i]-a[j] > mid) cnt++, j = i;
			if (cnt > N) ans = mid, l = mid+1;
			else r = mid-1;
		}
		cout << ans+1 << endl;
	}
}

Measured memory_bytes: 1596
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;

int main(){ ; 
    int n ;
    int id;
    string s;   
    string junnbann = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
    cin >> n >> s ;
    for(int i = 0;i < s.size();i++){
        id = junnbann.find_first_of(s[i]);
        cout << junnbann[(id+n)%26];
    }
}   

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
count = 0

for i in range(n):
    minA = i
    flag = False
    for j in range(i, n):
        if A[j] < A[minA]:
            minA = j
            flag = True
    
    if flag:
        v = A[i]
        A[i] = A[minA]
        A[minA] = v
        count += 1


print(" ".join(map(str, A)))
print(count)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for (int i=0;i<n;i++) cin >> s[i] >> t[i];
    string x;
    cin >> x;
    bool flag=0;
    int ans=0;
    for (int i=0;i<n;i++) {
        if (flag) ans+=t[i];
        if (s[i]==x) flag=1;

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s, t;
int main(){
    cin >> s >> t;
    for(int i = 0; i < s.length(); i++){
        string tmp;
        for(int j = 0; j <s.length(); j++){
            tmp.push_back(s[(i + j) % s.length()]);
        }
        if(tmp == t){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        int n = in.nextInt();
        int t = in.nextInt();
        int min = Integer.MAX_VALUE;
        while (n-->0) {
            int c = in.nextInt();
            int p = in.nextInt();
            if(p<=t) {
                min = Math.min(min,c);
            }
        }
        if(min == Integer.MAX_VALUE) {
            out.println("TLE");
        }
        else {
            out.println(min);
        }
        out.flush();
    }

    private boolean dfs(String [] maze,int i,int j,boolean[][] visited) {
        if(i<0 || i>=maze.length || j<0 || j>=maze[0].length() || visited[i][j] || maze[i].charAt(j) == '*') {
            return false;
        }
        if(maze[i].charAt(j) == 'T') return true;
        visited[i][j] = true;
        return dfs(maze,i+1,j,visited) || dfs(maze,i-1,j,visited) || dfs(maze,i,j+1,visited) || dfs(maze,i,j-1,visited);

    }

    private static boolean isPalindrome(char [] c, int i, int j) {
        if(i>=j) return true;
        if(c[i]!=c[j]) return false;
        return isPalindrome(c,++i,--j);
    }
    static int [] freq (char [] c) {
        int [] f = new int[26];
        for(char cc : c) {
            f[cc-'a']++;
        }
        return f;
    }
    static int check (int [] f, int k) {
        int count = 0;
        for (int i = 0; i < f.length; i++) {
            if(f[i] > 1) return 1;
            if(f[i] == 1) count++;
        }
        if(count == k) return 0;
        return -1;
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }
    public Integer nextInt() {return Integer.valueOf(next());}
    public Long nextLong() {return  Long.valueOf(next());}
    public Double nextDouble() {return Double.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

Measured memory_bytes: 21460
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = set([int(input()) for i in range(n)])
ans = [[-1]*3 for _ in range(3)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            ans[i][j] = 0

cnt = 0
for i in range(3):
    if sum(ans[i]) == 0:
        cnt = 1
        break
    elif ans[0][i] + ans[1][i] + ans[2][i] == 0:
        cnt = 1
        break
    elif ans[0][0] + ans[1][1] + ans[2][2] == 0:
        cnt = 1
        break
    elif ans[0][2] + ans[1][1] + ans[2][0] == 0:
        cnt = 1
        break

if cnt == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int a_sum=0,b_sum=0,n;
  cin >> n;
  vector<int> card(n);
  for(int i=0;i<n;i++){
    cin >> card.at(i);
  }

  sort(card.begin(),card.end());

  for(int i=n-1;i>=0;i-=2){
    a_sum+=card.at(i);
  }

  for(int i=n-2;i>=0;i-=2){
    b_sum+=card.at(i);
  }

  cout << a_sum - b_sum << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
    char ch;
    while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
    if (ch=='-'){
        int s=0;
        while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
        return -s;
    }
    int s=ch-'0';
    while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
    return s;
}

const int N = 1e5+5;

int n;
int a[N];
int pre[N];
int tree[N*2];

void add(int x){
    x+=n+1;
    for(;x<=n*2+2;x+=x&-x)tree[x]++;
}

int query(int x){
    int ret=0;
    x+=n+1;
    for(;x;x-=x&-x)ret+=tree[x];
    return ret;
}

bool check(int lim){
    fo(i,1,n){
        pre[i]=pre[i-1];
        if (a[i]<=lim)pre[i]++;
        else pre[i]--;
    }
    fo(i,0,n*2+2)tree[i]=0;
    add(0);
    LL tot=0;
    fo(i,1,n){
        tot+=query(pre[i]-1);
        add(pre[i]);
    }
    LL all=1ll*n*(n+1)/2;
    return (2*tot > all);
}

int main(){
    n=get();
    fo(i,1,n)a[i]=get();
    int l=1,r=1e9,ans=0;
    while(l<=r){
        int mid=(l+r)/2;
        if (check(mid))ans=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}
/*
in this case (<= element) > (> element) (no equality) again depends as per definition of medium
also in this case tot > all/2     strict (   " "    )       (Observation)
also we have to go right to search
e.g.  1 2 3 5 5  /// 2 -> 3..........       (Observe)
*/

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

signed main()
{
	int n, m;cin >> n >> m;
	int L, R; L = 0;R = INF;
	for(int i = 0, i_len = (int)m; i < i_len; ++i){
		int l, r; cin >> l >> r;
		L = max(L, l);
		R = min(R, r);
	}
	if(R-L+1 > 0)
	cout << R-L+1 << endl;
	else
	{
		cout << 0 << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#電球クラス
class Light:
    def __init__(self,name,switchs,whattype):
        self.name=name
        self.switchs=switchs
        self.whattype=whattype
    def reset(self):
        sumnum=0
        for switch in self.switchs:
            sumnum+=switch.onoff
        if sumnum%2==self.whattype:
            self.state="on"
        else:
            self.state="off"
            
#スイッチクラス            
class Switch:
    def __init__(self,name):
        self.name=name
        self.onoff=0
    def click(self,onoff):
        self.onoff=onoff
        
    
#整理用データ
n,m=[int(i) for i in input().split()]
allist=[]
for i in range(m+1):
    allist.append([int(j) for j in input().split()])
      

#全スイッチのリスト
switchlist=[]
for i in range(n):
    switchlist.append(Switch(i))


#全電球のリスト
lightlist=[]
for i in range(m):
    swlist=[]
    swnum=allist[i][1:]
    for j in swnum:
        swlist.append(switchlist[j-1])
    whattype=allist[-1][i]
    lightlist.append(Light(i,swlist,whattype))
    
#全部の付け方について
count=0
clicklist=[0 for i in range(n)]    
for i in range(2**n):
    onoffcheck=0
    j=0
    while i:
        clicklist[j]=i%2
        i=i//2
        j+=1
    for k in range(n):
        switchlist[k].click(clicklist[k])
    for light in lightlist:
        light.reset()
        if light.state=="off":
            onoffcheck+=1
    if onoffcheck==0:
        count+=1
print(count)

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

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

  if (N==111) {
    cout << 999 << endl;
  }
  if (N==119){
  cout << 991 << endl;
}
if (N==191){
    cout << 919 << endl;
}
  if(N==199){
    cout << 911 << endl;
}
  if(N==911){
    cout << 199 << endl;
}

if(N==919){
    cout << 191 << endl;
}
if(N==991){
    cout << 119 << endl;
}
  if(N==999){
    cout <<  111 << endl;
}
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pr pair<int,int>
#define SZ(S) int(S.size())
#define REP(i,a,b) for(int i=a;i<b;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,b,a) for(int i=b;i>=a;--i)
#define CLR(A,x) memset(A,x,sizeof(A))
#define ALL(S) S.begin(),S.end()

#define OUT(a,l,r) cout<<#a": ";FOR(i,l,r)cout<<a[i]<<" ";cout<<endl
#define PRT(a) cout<<"--> "#a" "<<a<<endl

using namespace std;
typedef long long ll;

const int N=1005,INF=0x3f3f3f3f;
const ll P=1e9+7;

template<typename T>
inline void read(T& x,int f=1,char s=getchar()) {
	for(x=0;s>'9'||s<'0';s=getchar()) if(s=='-') f=-1; 
	while(s<='9'&&s>='0') x=x*10+s-'0',s=getchar();x*=f;
}

char s[4]={'R','Y','G','B'};

int get(int x,int y,int k) {
	x+=1000*k,y+=1000*k;
	return ((((x-1)/k)&1)<<1)+(((y-1)/k)&1);
}

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	if(k&1) {
		FOR(i,1,n) FOR(j,1,m) {
			putchar(s[(i+j)&1]);
			if(j==m) putchar('\n');
		}
	}
	else {
		k/=2;
		FOR(i,1,n) {
			FOR(j,1,m) {
				if((i+j)&1)cout<<s[get((i-j+1)/2,(i+j-1)/2,k)];
				else cout<<s[get((i-j)/2,(i+j)/2,k)];
			}
			cout<<endl;
		}
	}
	return 0;
}

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

class union_find {
	vector<int> dat;
public:
	union_find(int n) : dat(n, -1) {}
	int find(int i) {
		return dat[i] < 0 ? i : dat[i] = find(dat[i]);
	}
	bool same(int u, int v) {
		return find(u) == find(v);
	}
	void unite(int u, int v) {
		u = find(u); v = find(v);
		if (u == v) return;
		if (dat[u] < dat[v]) {
			dat[u] += dat[v];
			dat[v] = u;
		}
		else {
			dat[v] += dat[u];
			dat[u] = v;
		}
	}
};

int main()
{
	int N, M;
	while (cin >> N >> M, N | M) {
		union_find uf(N * 2);
		bool ng = false;
		for (int i = 0; i < M; i++) {
			int u, v;
			cin >> u >> v; --u, --v;
			uf.unite(u, N + v);
			uf.unite(N + u, v);
			if (uf.same(u, N + u)) ng = true;
		}
		int sz = 0;
		for (int i = 0; i < N; i++) sz += uf.same(0, i);
		set<int> v;
		if (sz % 2 == 0) v.insert(sz / 2);
		sz = N - sz;
		if (sz % 2 == 0) v.insert(sz / 2);
		if (ng) v.clear();
		cout << v.size() << endl;
		for (auto x : v) {
			cout << x << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int a[5];
	int b[3] = {0};
	cin >> a[0];
	if(a[0] == 0) break;
	b[a[0]-1]++;
	REP(i,4){ 
	    cin >> a[1+i];
	    b[a[1+i]-1]++;
	}
	int c = 0;
	if(b[0] > 0) c++;
	if(b[1] > 0) c++;
	if(b[2] > 0) c++;
	if(c % 2 == 1){
	    REP(i,5) cout << 3 << endl;
	}else if(b[0] == 0){
	    REP(i,5){
		if(a[i] == 2) cout << 1 << endl;
		else cout << 2 << endl;
	    }
	}else if(b[1] == 0){
	    REP(i,5){
		if(a[i] == 3) cout << 1 << endl;
		else cout << 2 << endl;
	    }
	}else{
	    REP(i,5){
		if(a[i] == 1) cout << 1 << endl;
		else cout << 2 << endl;
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 1156
/*
    author: Salam_35
    problem name:
*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));

const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;
vec primes;
//

int main()
{
    string a;
    cin >> a;
    int ans=0;
    if(a.size()==1){cout<<0<<endl;return 0;}
    for(int i=0,j=a.size()-1;i<a.size()/2, j>=a.size()/2;i++,j--)
    {
        if( a[i]!=a[j])ans++;
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define fi first
#define se second
template <typename A, typename B> inline bool chmax(A &a, B b) {if (a < b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmin(A &a, B b) {if (a > b) {a = b; return 1;} return 0;}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const double EPS = 1e-9;
const bool debug = 0;
/****************************/

int main() {
	string s;
	while (cin >> s, s != "#") {
		
		REP(i, s.size()) s[i] -= 'a';
		
		vector<string> ans;
		REP(i, 1<<s.size()) {
			int used = 0;
			string cur = "";
			bool ng = false;
			REP(j, s.size()) {
				if (ng) break;
				
				if (i >> j & 1) {
					if (s[j] == 25) ng = true;
					else {
						if (used >> (s[j] + 1) & 1) ng = true;
						else cur += s[j] + 1 + 'a';
						used |= 1 << (s[j] + 1);
					}
				}
				else {
					if (s[j] != 0 && !(used >> s[j] & 1)) ng = true;
					else cur += s[j] + 'a';
				}
			}
			if (count(ALL(cur), 'z') != 0 && !(used >> 25 & 1)) ng = true;
			if (!ng) ans.push_back(cur);
		}
		sort(ALL(ans));
		ans.erase(unique(ALL(ans)), ans.end());
		
		if (debug) printf("@ ");
		cout << ans.size() << endl;
		if (ans.size() <= 10) {
			REP(i, ans.size()) cout << ans[i] << endl;
		}
		else {
			REP(i, 5) cout << ans[i] << endl;
			for (int i = ans.size() - 5; i < ans.size(); i++) cout << ans[i] << endl;
		}
		
	}
}



Measured memory_bytes: 4136
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
map<string,ll> mp;
map<string,ll>::iterator mpit;
//map<ll,ll> mp;
//deque<ll> deq;
vector<ll> vll;
ll num[ten52];
//priority_queue<pair<ll,ll>> pq;          //decreasing


int main(void)
{
    ll m=0,n,i=0,j,k=0;
    string s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        sort(all(s));
        mp[s]++;
    }
    for(auto &au: mp)
    {
        j=au.second;
        m+=(j)*(j-1)/2;
    }
    cout<<m;
    return 0;
}


Measured memory_bytes: 11364
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

const int N = 100101;

pair<int, int> get_pair(int number) {
	int last = number % 10;
	int cur = number % 10;
	while(number) {
		cur = number % 10;
		number /= 10;
	}
	return make_pair(cur, last);
}

int main() {
	map<pair<int, int>, int> cnt;
	int n; cin >> n;
	for(int i = 1; i <= n; ++i) {
		cnt[get_pair(i)]++;
	}
	long long ans = 0;
	for(auto it: cnt) {
		auto was = it.first;
		auto was_r = make_pair(was.second, was.first);
		ans += it.second * 1LL * cnt[was_r];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

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

  static class BPapersPlease {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      boolean f = true;
      int n = in.nextInt();
      int[] a = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = in.nextInt();
        if (a[i] % 2 == 0) {
          f = f && (a[i] % 3 == 0 || a[i] % 5 == 0);
        }
      }

      out.println(f ? "APPROVED" : "DENIED");
    }

  }
}



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

int main(){
    int a ;
    int b ;
    cin >> a >> b;

    if(a > b){
        cout <<"a > b" << endl;
    }else if(a == b){
        cout << "a == b"<< endl;
    }else{
        cout << "a < b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vp a;

int main(){
	cin>>n;
	a=vp(n);
	for(int i=0;i<n;i++){
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a.rbegin(),a.rend());
	vvl dp(n+1,vl(n+1));
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		ll x=a[i].first,id=a[i].second;
		for(int l=0;l<=i;l++){
			int r=i-l;
			dp[l+1][r]=max(dp[l+1][r],dp[l][r]+x*(id-l));
			dp[l][r+1]=max(dp[l][r+1],dp[l][r]+x*(n-r-1-id));
		}
	}
	ll res=0;
	for(int i=0;i<=n;i++) res=max(res,dp[i][n-i]);
	cout<<res<<endl;
}

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

vector<int> G[100010];
vector<int> T[100010];

void gtot(int c,int p){
  for(int i:G[c]){
    if(i==p)continue;
    gtot(i,c);
  }
  T[p].push_back(c);
}

int xortree(int x){
  int a=0;
  if(T[x].size()==0){
    return 1;
  }
  if(T[x].size()==1){
    a=xortree(T[x][0])+1;
    return a;
  }
  for(int i:T[x]){
    a^=xortree(i);
  }
  return a+1;
}

int main(){
  int N,a,b;
  cin>>N;
  for(int i=0;i<N-1;i++){
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  gtot(1,0);
  if(xortree(1)-1)cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
}

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

int main(){
  int N,a,b,minab,maxab,jouyo;
  cin>>N;
  
  vector<int> data(N,0);
  
  cin>>a;
  for(int i=0;i<N-1;i++){
    cin>>b;
    minab=min(a,b);
    maxab=max(a,b);
    //1:1で剰余の最小を計算
    for(int j=0;j<1000000000;j++){
      jouyo=maxab%minab;
      if (jouyo==0)
        break;
      maxab=minab;
      minab=jouyo;
    }
    a=minab;
  }
  
  
  
  cout<<a<<endl;
  
  return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,p;
	cin>>n>>p;
	long long int ans=1,o=0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x&1)	o++;
		else	ans<<=1;
	}
	if(o==0){
		ans*=(p==0);
	}
	else{
		for(int i=1;i<o;i++)
			ans<<=1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    H, W = map(int, readline().split())

    res = []

    for _ in range(H):
        c = input()
        res.append(c)
        res.append(c)

    for row in res:
        print(row)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63080
k, x = map(int,input().split())
lst = []
for i in range(x - k + 1, x + k):
  if (-1000000 <= i <= 1000000):
    lst.append(i)
for i in range(len(lst)):
    print(lst[i], end = '')
    if (i != len(lst) - 1):
      print(" ", end = '')
print()


Measured memory_bytes: 9184
#include<iostream>

using namespace std;
int main()

{

string s;

cin>>s;

if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
    cout<<"Yes"<<endl;
}

else  {
        cout<<"No"<<endl;

}


return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
  ll n; cin >> n;
  ll sum = 0;
  rept(i, 1, n+1){
    for(int j=i; j<=n; j+=i){
      sum += j;
    }
  }
  cout << sum << ln;
}
  


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

int main() {
	string s;
	cin >> s;
	if (s.length() <= 3) {
		cout << "No" << endl;
		return 0;
	}
	s = s.substr(0, 4);
	if (s == "YAKI")cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<stack>
using namespace std;

struct LCA{
    int n, bit; // n < 1<<bit
    vector<int> depth;
    vector<vector<int>> par, v;

    LCA(int n) : n(n){
        depth.resize(n, -1);
        bit = 0;
        while(1<<bit <= n)  bit++;
        par.resize(bit);
        for(int i = 0; i < bit; i++)    par[i].resize(n);
        v.resize(n);
    }

    void add_edge(int a, int b){
        v[a].push_back(b);
        v[b].push_back(a);
    }

    void dfs(int now, int p, int d){
        par[0][now] = p;
        depth[now] = d;
        for(int child : v[now]){
            if(child == p)  continue;
            dfs(child, now, d+1);
        }
    }

    void build(){
        for(int i = 0; i < n; i++){
            if(depth[i] == -1)    dfs(i, -1, 0);
        }
        for(int k = 0; k+1 < bit; k++){
            for(int i = 0; i < n; i++){
                if(par[k][i] < 0)   par[k+1][i] = -1;
                else                par[k+1][i] = par[k][par[k][i]];
            }
        }
    }

    int lca(int a, int b){
        // make b deeper
        if(depth[a] > depth[b]) swap(a, b);
        for(int k = 0; k < 30; k++){
            // depth(b)-depth(a) is equal to or bigger than 2^k
            if(((depth[b]-depth[a])>>k)&1){
                b = par[k][b];
            }
        }
        if(a == b)  return a;
        for(int k = bit-1; k >= 0; k--){
            if(par[k][a] != par[k][b]){
                a = par[k][a];
                b = par[k][b];
            }
        }
        return par[0][a];
    }

    int dist(int a, int b){
        int l = lca(a, b);
        return depth[a]-depth[l] + depth[b]-depth[l];
    }
};

int main(){
    int n, m;
    while(scanf("%d %d\n", &n, &m), n+m){
        vector<string> name(n);
        vector<int> depth(n);
        map<string,int> id;
        LCA l(n);
        stack<pair<int,int>> his;
        for(int i = 0; i < n; i++){
            string s;
            getline(cin, s);
            int dep;
            for(dep = 0; s[dep]==' '; dep++);
            name[i] = s.substr(dep);
            id[name[i]] = i;
            depth[i] = dep;
            while(!his.empty()&&his.top().second+1!=dep)    his.pop();
            if(!his.empty())    l.add_edge(i, his.top().first);
            his.push({i, dep});
        }
        l.build();
        while(m--){
            string a, b, c;
            cin >> a >> b >> b >> b >> c >> c;
            c.pop_back();
            int x = id[a], y = id[c];
            bool judge =    (b=="child" && l.lca(x,y)==y && depth[y]+1==depth[x]) || 
                            (b=="parent" && l.lca(x,y)==x && depth[x]+1==depth[y]) ||
                            (b=="sibling" && depth[x]==depth[y] && depth[x]==depth[l.lca(x,y)]+1) ||
                            (b=="ancestor" && l.lca(x,y)==x) || 
                            (b=="descendant" && l.lca(x,y)==y);
            cout << (judge ? "True" : "False") << endl;
        }
        cout << endl;
        cin.ignore(0);
    }
    return 0;
}


Measured memory_bytes: 3380
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll a,b;
  cin>>a>>b;
  if(a<b)swap(a,b);
  FOR(i,a){
    cout<<b;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(((b-a) == (c-b)) || ((a-b) == (b-c))) {
            System.out.println("YES"); return;
        }
        System.out.println("NO");
    }
}



Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
int n,a[N],b[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n+1;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=min(a[i],b[i]);
        b[i]-=a[i];
        b[i]=max(b[i],0);
        if(b[i])
        {
            ans+=min(a[i+1],b[i]);
            a[i+1]-=b[i];
            a[i+1]=max(a[i+1],0);
        }
    }
    printf("%lld\n",ans);
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, n) {
    if (i == 0 || s[i - 1] != s[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const readline_1 = __importDefault(require("readline"));
process.stdin.resume();
process.stdin.setEncoding('utf8');
const reader = readline_1.default.createInterface({
    input: process.stdin,
    output: process.stdout,
});
const lines = [];
reader.on('line', line => {
    lines.push(line);
});
reader.on('close', () => {
    const r = Number(lines[0]);
    console.log(Math.pow(r, 2));
});
//# sourceMappingURL=main.js.map

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

int main(void) {
  int N,X;
  cin >> N >> X;
  vector<int> D(N+1);
  D.at(0);
  rep(i,N){
    int l;
    cin >> l;
    D.at(i+1) = D.at(i) + l;
  }
  int  ans=0;
  for(int i=0; i<=N; i++) {
    if(D.at(i) <=X) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const Int M = 15;
Int dp[2][M+1][1<<M];
Int pp[1<<M];
Int dst[M];

Int ans[M*2];
Int ord[M];

Int ox[M];

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

  Int n;
  cin>>n;

  vector<Int> xs(n),ys(n),ps(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>ys[i]>>ps[i];

  const Int INF = 1e18;
  Int sz=1<<n;
  for(Int i=0;i<=n;i++)
    for(Int b=0;b<sz;b++)
      dp[0][i][b]=dp[1][i][b]=INF;

  pp[0]=0;
  for(Int i=1;i<sz;i++) pp[i]=pp[i>>1]+(i&1);


  for(Int k=0;k<2;k++){
    for(Int i=0;i<n;i++) ord[i]=i;
    sort(ord,ord+n,[&](Int i,Int j){
      return xs[i]!=xs[j]?xs[i]<xs[j]:i<j;
    });

    for(Int i=0;i<n;i++) ox[i]=xs[ord[i]];

    for(Int b=0;b<sz;b++){
      for(Int a=b;;a=(a-1)&b){
        for(Int i=0;i<n;i++) dst[i]=abs(xs[i]);
        Int lst;

        lst=-INF;
        for(Int i=0;i<n;i++){
          if((a>>ord[i])&1) lst=ox[i];
          chmin(dst[ord[i]],abs(ox[i]-lst));
        }

        lst=+INF;
        for(Int i=n-1;i>=0;i--){
          if((a>>ord[i])&1) lst=ox[i];
          chmin(dst[ord[i]],abs(ox[i]-lst));
        }

        Int res=0;
        for(Int i=0;i<n;i++)
          if((b>>i)&1) res+=dst[i]*ps[i];

        chmin(dp[k][pp[a]][b],res);
        if(a==0) break;
      }
    }
    for(Int i=0;i<n;i++) swap(xs[i],ys[i]);
  }

  for(Int i=0;i<=n;i++) ans[i]=INF;
  for(Int b=0;b<sz;b++)
    for(Int i=0;i<=n;i++)
      for(Int j=0;j<=n;j++)
        chmin(ans[i+j],dp[0][i][b]+dp[1][j][(sz-1)^b]);

  for(Int i=0;i<=n;i++) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 12104
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;
vvi G = vv(100001, 0, 0, int);
std::vector<int> p(100001, -1);
int dfs(int now){
  if(p[now]!=-1) return p[now];
  int ret = 0;
  for(int i=0;i<G[now].size();i++) ret = max(ret, dfs(G[now][i])+1);
  p[now] = ret;
  return ret;
}
int main(int argc, char const *argv[]) {
  int N, M, a, b;
  std::cin >> N >> M;
  for(int i=0;i<M;i++){
    std::cin >> a >> b;
    G[a].push_back(b);
  }
  int ans = 0;
  for(int i=1;i<=N;i++) if(p[i]==-1) ans = max(ans, dfs(i));
  //for(int i=1;i<=N;i++)std::cout << p[i] << (i==N?"\n":" ");
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  if(b<0){
    if((b-a)%2==0)cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
  }
  else if(a<=0||b==0)cout<<"Zero"<<endl;
  else cout<<"Positive"<<endl;
}

Measured memory_bytes: 256
s = input()
char_list = list(s)
alphabets = ["a", "b", "c", "d", "e", "f", "g", "h", "i" ,"j" ,"k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
             "v", "w", "x", "y", "z"]
for al in alphabets:
    if al not in char_list:
        print(al)
        exit()
print("None")


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  string s;
  cin >> s;
  int n = s.size();
  
  string s0, s1;
  s0 = "";
  s1 = "";
  for(int i = 0;i < n/2;i ++){
    s0 += "0";
    s0 += "1";
    s1 += "1";
    s1 += "0";
  }
  if(n%2 == 1){
    s0+= "0";
    s1+= "1";
  }
  // cout << s0 << endl;
  // cout << s1 << endl;
  int n0 = 0;
  int n1 = 0;
  REP(i, n){
    if(s[i] != s0[i]){n0++;}
    if(s[i] != s1[i]){n1++;}
  }
  cout << min(n0,n1)<< endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n;
    string s;
    cin >> n >> s;
    lli r = 0, g = 0, b = 0;
    rep(i, n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    }
    lli total = r * g * b;
    for(int i = 0; i<n; i++){
        for(int j = i+1; j<n; j++){
            int k = 2 * j - i;
            if(k > n-1) continue;
            if(s[i] != s[j] && s[j] != s[k] && s[i] != s[k]){
                total--;
            }
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=998244353;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

using BS = bitset<4000>;

int N;
string X;
LL pw2[4010];
BS bases[4010];
vector<BS> A;

void Add(LL &t, LL v) {
  t += v;
  while (t >= MOD) t -= MOD;
}

BS MakeBitset(string &s) {
  BS ret;
  int idx = 3999;
  rrep(i, s.size()) {
    if (s[i] == '1') ret[idx] = 1;
    else if (s[i] == '0') ret[idx] = 0;
    else assert(0);
    idx--;
  }
  return ret;
}

int RegBase(BS &v) {
  while (1) {
    int idx = v._Find_first();
    if (idx == v.size()) {
      assert(v.count() == 0);
      return -1;
    }

    if (bases[idx].count() == 0) {
      bases[idx] = v;
      return idx;
    }

    v ^= bases[idx];
    assert(v._Find_first() > idx);
  }
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  
  cin >> N >> X;
  rep(i, N) {
    string s;
    cin >> s;
    A.eb(MakeBitset(s));
  }
  sort(all(A), [](const BS &a, const BS &b) {
    return a._Find_first() < b._Find_first();
  });
  while (!A.empty() && !A.back().count()) A.pop_back();
  reverse(all(A));

  if (A.empty()) {
    cout << "1\n";
    return 0;
  }

  int idx = A[0]._Find_first();
  BS v = A[0];
  while (1) {
    int res = RegBase(v);
    assert(res == idx);
    if (res == -1) break;
    v = bases[res] >> 1;
    if (idx == 0) break;
    idx--;
  }

  reps(i, 1, N) {
    v = A[i];
    idx = A[i]._Find_first();
    while (1) {
      int res = RegBase(v);
      if (res == -1) break;
      v = bases[res] >> 1;
    }
  }

  int m = 0;
  pw2[0] = 1;
  rep(i, 4000) {
    if (bases[i].count()) m++;
    if (i > 0) {
      Add(pw2[i], pw2[i-1]);
      Add(pw2[i], pw2[i-1]);
    }
  }

  X = string(4000-X.size(), '0') + X;
  assert(X.size() == 4000);

  BS cur;
  LL ans = 1;
  rep(i, 4000) {
    if (!bases[i].count()) {
      if (cur[i] > X[i]-'0') {
        Add(ans, MOD-1);
        break;
      } else if (cur[i] < X[i] - '0') {
        Add(ans, pw2[m]);
        Add(ans, MOD-1);
        break;
      }
      continue;
    }

    if (X[i] == '1') {
      assert(m > 0);
      Add(ans, pw2[m-1]);
      if (!cur[i]) cur ^= bases[i];
    } else if (X[i] == '0') {
      if (cur[i]) cur ^= bases[i];
    }

    --m;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2432
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a==b&&b==c)System.out.println("Yes");
    else System.out.println("No");
  }
}


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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int n;
    cin >> n;

    vector<int> A(n);

    for(int i=0; i<n; i++)
        cin >> A[i];

    int ans = (int) 1e9 + 7;

    for(int i=1; i<=100; i++)
    {
        int curr = 0;

        for(int j=0; j<n; j++)
            curr += (A[j] - i) * (A[j] - i);
        
        ans = min(ans, curr);
    }

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
D = list(map(int, input().split(' ')))
M = int(input())
T = list(map(int, input().split(' ')))

import collections
d_frq_dict = collections.Counter(D)

for t in T:
    if d_frq_dict[t] == 0:
        print('NO')
        exit()
    d_frq_dict[t] -= 1

print('YES')



Measured memory_bytes: 121180