akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static final int MOD = (int) 1e9 + 7;

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt(), k = sc.nextInt();
		ArrayList<Long> pos = new ArrayList<>();
		ArrayList<Long> neg = new ArrayList<>();
		
		for(int i = 0; i < n; i++) {
			long x = sc.nextInt();
			if(x < 0) neg.add(-x);
			else pos.add(x);
		}
		
		int rem = k - pos.size();
		if((rem > 0 && rem % 2 != 0 && neg.size() <= rem) || (pos.size() == 0 && k % 2 == 1)) { //minimize
			Collections.sort(pos);
			Collections.sort(neg);
			
			long ans = 1;
			for(int i = 0, j = 0; k > 0; k--) {
				long po = i < pos.size() ? pos.get(i) : Integer.MAX_VALUE;
				long ne = j < neg.size() ? neg.get(j) : Integer.MAX_VALUE;
				
				if(po <= ne) {
					i++;
					ans *= po;
					ans %= MOD;
				}else {
					j++;
					ans *= ne;
					ans %= MOD;
				}
			}
			
			ans = (-ans + MOD) % MOD;
			out.println(ans);
			
		}else {
			
			Collections.sort(pos, Collections.reverseOrder());
			Collections.sort(neg, Collections.reverseOrder());
			
			int i = Math.min(k - 1, pos.size() - 1);
			if((k - i - 1) % 2 != 0) i--;
			int j = k - i - 2;
			
			while(i > 0 && j < neg.size() - 2) {
				long ne = neg.get(j + 1) * neg.get(j + 2);
				long po = pos.get(i) * pos.get(i - 1);
				
				if(ne > po) {
					j += 2;
					i -= 2;
				}else {
					break;
				}
			}
			
			long ans = 1;
			for(int idx = 0; idx <= i; idx++) {
				ans *= pos.get(idx);
				ans %= MOD;
			}
			
			for(int idx = 0; idx <= j; idx++) {
				ans *= neg.get(idx);
				ans %= MOD;
			}
			
			out.println((ans + MOD) % MOD);
		}
		
		out.close();
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

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

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

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}

Measured memory_bytes: 58580
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int a, b, k; cin >> a >> b >> k;
  int n = max(a, b);
  int cnt = 0;
  int i;
  for (i = n; i > 0; i--)
    if (a % i == 0 && b % i == 0)
    {
      cnt++;
      if (cnt == k) break;
    }
  cout << i << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>

constexpr int INF = 1145141919;

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

    int N;
    std::cin >> N;

    double X_min = (double)N/1.08;
    double X_max = (double)(N+1)/1.08;
    bool flag=false;
    for(int i=X_min; i<=X_max; i++){
        if( N == (int)(i*1.08) ){
            flag=true;
            std::cout << i;
        }
    }

    if(flag==false){
        std::cout << ":(";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;

	int a[n];

	rep(i,n)
	{
		cin>>a[i];
	}
	int ans = 0;
	rep(i,n)
	{
		REP(j,i+1,n-1)
		{
			ans+=a[i]*a[j];
		}
	}
	cout<<ans;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    vector<bool> a(n+1,0);
    for ( int i=0; i<k; i++ ) {
        int d;
        cin >> d;
        for ( int j=0; j<d; j++ ) {
            int b;
            cin >> b;
            a[b]=1;
        }
    }
    int ans=0;
    REP1(i,1,n) {
        if ( a[i] ) ans++;
    }
    cout << n-ans << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
string s;
int ans = 0;
signed main() {
	cin >> s;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'A')cnt++;
		else if (i != s.size() - 1 && s[i] == 'B' && s[i + 1] == 'C') {
			ans += cnt;
			i++;
		}
		else cnt = 0;
	}
	cout << ans << endl;
	return 0;
}

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

int n;
string s;

int main() {
  cin >> n;
  cin >> s;
  int num = 0;
  int ans = 0;
  rep (i, n) {
    if (s.at(i) == 'I') {
      num++;
    }else{
      num--;
    }
    ans = max(ans, num);
  }
  cout << ans << endl;
  return 0;
}


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


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}



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

	vector<vector<int>> s(m);

	for (int i = 0; i < m; i++){
		int k;
		cin >> k;
		s[i].resize(k);
		for (int j = 0; j < k; j++){
			cin >> s[i][j];
			s[i][j]--;
		}
	}

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

	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++){
		vector<int> on;
		for (int i = 0; i < n; i++){
			if (bit & (1 << i)){
				on.push_back(i);
			}
		}

		int ok = true;
		for (int i = 0; i < m; i++){
			int oncnt = 0;
			for (int j = 0; j < s[i].size(); j++){
				for (int k = 0; k < on.size(); k++){
					if (s[i][j] == on[k]){
						oncnt++;
					}
				}
			}
			if (oncnt % 2 != p[i]){
				ok = false;
				break;
			}
		}
		if (ok){
			ans++;
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
L = list(map(int, input().split()))
if L[0]%2 == 1 or L[1]%2 == 1 or L[2]%2 == 1:
    print(0)
    exit()

if (L[0]//2)%2 == 1 and (L[1]//2)%2 == 1 and (L[2]//2)%2 == 1:
    print(-1)
    exit()

i = 0
while True:
    i += 1
    L = [L[1]//2+L[2]//2, L[0]//2+L[2]//2, L[0]//2+L[1]//2]
    if L[0]%2 == 1 or L[1]%2 == 1 or L[2]%2 == 1:
        print(i)
        exit()
    if i >= 10**6:
        print(-1)
        exit()


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

ll N;
vector<ll> a, b, c;

int main() {
    cin >> N;
    a.resize(N), b.resize(N), c.resize(N);
    rep(i,N) scanf("%Ld", &a[i]);
    rep(i,N) scanf("%Ld", &b[i]);
    rep(i,N) scanf("%Ld", &c[i]);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll acnt = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll ccnt = N - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
        ans += acnt*ccnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define inf (int)1e18+7
#define mod 1000000007
const int nmax = (int) 1e5 + 10;

int n;
vector<int > graph[nmax];
vector<int > tree[nmax];

bool vis[nmax];

void dfs(int u) {
    vis[u] = true;
    for (auto v: graph[u]) {
        if (vis[v]) continue;
        tree[u].push_back(v);
        dfs(v);
    }   
}

int dp[nmax][2];

void dfs1(int u) {
    
    dp[u][0] = 1;
    dp[u][1] = 1;
    for (auto v : tree[u]) {
        dfs1(v);
        dp[u][0] *= (dp[v][0] + dp[v][1]) % mod;
        dp[u][0] %= mod;
        dp[u][1] *= dp[v][0];
        dp[u][1] %= mod;     
    }
       
}            
                     
signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    int m = n - 1;
    while(m -- ) {
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    dfs(1);
    dfs1(1);

    cout << (dp[1][0] + dp[1][1]) % mod << endl;

    return 0;
}


Measured memory_bytes: 17024
#include<iostream>
#include<map>
#include<string>
#include<utility>
#include<vector>
#include<cctype>
#include<cmath>
#include<algorithm>
#define rep(i, a) for(int i=0; i<a; i++)
#define all(a)  a.begin(), a.end()
using namespace std;

int main(void){
  int n;  cin >> n;
  int a=0, b=0;
  int m=0;
  vector<int> vc;
  rep(i, n){
    int t;  cin >> t;
    vc.emplace_back(t);
  }
  sort(all(vc));
  if(vc.size()%2==0)  m++;
  rep(i, n){
    if(m%2==0)  a+=vc[i];
    else  b+=vc[i];
    m++;
  }
  cout << a-b << endl;
  return 0;
}


Measured memory_bytes: 256
import Data.Bool

main = print . solve =<< getLine

solve :: String -> Int
solve s = min (ob+ew) (ow+eb)
    where
        (ob, ow) = cnt s
        (eb, ew) = cnt $ drop 1 s

cnt ('0':ss) = incblack . cnt $ drop 1 ss
cnt ('1':ss) = incwhite . cnt $ drop 1 ss
cnt [] = (0, 0)

incblack (b, w) = (b+1, w)
incwhite (b, w) = (b, w+1)


Measured memory_bytes: 9852
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   int a,b,c;
   cin>>a>>b>>c;
   if(c>=a && c<=b)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans = 700;
    if(s.at(0) == 'o') ans += 100;
    if(s.at(1) == 'o') ans += 100;
    if(s.at(2) == 'o') ans += 100;

    cout << ans << endl;
 }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


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

	int n, k;
	cin >> n >> k;
	if (n % k == 0)cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int a, b, c, d, e, k;
    scan(a);scan(b);scan(c);scan(d);scan(e);scan(k);
    bool ok = e - a <= k;
    writeln(ok ? "Yay!" : ":(");
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main()
{
	string s;
	cin >> s;
	if (s.at(0) != s.at(1) && s.at(1) != s.at(2) && s.at(0) != s.at(2)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
def main():
    N = int(input())
    ans = ''
    keta = 1
    tmp = 0
    while N > 0:
        cnt = N % 26
        if cnt == 0:
            cnt = 26
            N -= 1
        ans = chr(96+cnt) + ans
        N //= 26
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 61780
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/
int main(){
     int n;
     cin>>n;
     bool adj[n][n];
     for(int i=0;i<n;i++){
          for(int j=0;j<n;j++){
               char x;cin>>x;
               if(x=='0')adj[i][j]=0;
               else adj[i][j]=1;
          }
     }
     queue<int> q;
     q.push(0);
     int s[n];memset(s,-1,sizeof(s));s[0]=0;
     while(!q.empty()){
          int x=q.front();q.pop();
          for(int i=0;i<n;i++){
               if(adj[x][i]){
                    if(s[i]==-1){s[i]=(s[x]+1)%2;q.push(i);}
                    if(s[i]%2==s[x]%2){
                         cout<<-1;return 0;
                    }
               }
          }
     }
     int dp[n][n];
     for(int i=0;i<n;i++)for(int j=0;j<n;j++){
          if(adj[i][j])dp[i][j]=1;
          else if(i==j)dp[i][j]=0;
          else dp[i][j]=1e8;
     }
     for(int k=0;k<n;k++){
          for(int i=0;i<n;i++){
               for(int j=0;j<n;j++){
                    dp[i][j]=min(dp[i][k]+dp[k][j],dp[i][j]);
               }
          }
     }
     int res=0;
     for(int i=0;i<n;i++){
          for(int j=0;j<n;j++){
               res=max(dp[i][j],res);
          }
     }
     cout<<res+1;
}
 
 
 
 

























Measured memory_bytes: 3788
n,k=map(int,input().split())
dlist=[]
alist=[i+1 for i in range(n)]

for j in range(k):
    dlist.append(int(input()))
    tmplist=list(map(int,input().split()))
    for tmp in tmplist:
        if tmp in alist:
            alist.remove(tmp)

print(len(alist))

Measured memory_bytes: 9208
#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=1e9+7;

#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;}

int N;
int M;
set<int> es[114514];
bool used[114514];
int prv[114514];
int depth[114514];

void Erase(int u, int v) {
  rep(i, 2) {
    assert(es[u].count(v));
    es[u].erase(v);
    swap(u, v);
  }
}

bool check() {
  fill(used, used+N, false);
  fill(prv, prv+N, -1);

  queue<int> que;
  int root = -1;
  rep(v, N) {
    if (!es[v].empty()) {
      root = v;
      used[v] = 1;
      que.push(v);
      break;
    }
  }
  if (root == -1) return false;

  using Ans = pair<int, pii>;
  Ans ans(MOD, pii(-1, -1));
  while (!que.empty()) {
    int v = que.front(); que.pop();
    for (int u : es[v]) {
      if (!used[u]) {
        prv[u] = v;
        used[u] = true;
        depth[u] = depth[v]+1;
        que.push(u);
      } else if (prv[v] != u) {
        MN(ans, Ans(1+depth[v]+depth[u], pii(v, u)));
      }
    }
  }
  if (ans.X == MOD) return false;

  int p, q;
  tie(p, q) = ans.Y;
  assert(p != -1);
  Erase(p, q);
  if (depth[p] < depth[q]) swap(p, q);
  while (depth[p] > depth[q]) {
    int np = prv[p];
    Erase(p, np);
    p = np;
  }

  while (p != q) {
    int np = prv[p];
    Erase(p, np);
    p = np;
    int nq = prv[q];
    Erase(q, nq);
    q = nq;
  }
  return true;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N >> M;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    es[a].insert(b);
    es[b].insert(a);
  }

  rep(v, N) {
    if (es[v].size()%2) {
      puts("No");
      return 0;
    }
  }

  rep(i, 3) {
    //cout << i << endl;
    if (!check()) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 15872
#include<iostream>

using namespace std;

int main(){
	int x,y,s;
	while(cin>>x>>y>>s &&x){
		int ans=0;
		for(int i=1;i<s;i++){
			for(int j=1;j<s;j++){
				if((i*(100+x)/100+j*(100+x)/100)==s){
					ans=max((i*(100+y)/100+j*(100+y)/100),ans);
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  string s;
  LL n;
  Solver(string s) : s(s), n(s.size()){};

  void solve() {
    LL ans = 0;
    deque<LL> a;
    LL cnt = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] == 'W') cnt++;
    }
    for (int i = 0; i < cnt; ++i) {
      a.push_back(i);
    }
    for (LL i = 0; i < n; ++i) {
      if (s[i] == 'W') {
        ans += i - a[0];
        a.pop_front();
      }
    }
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  std::string s;
  std::cin >> s;

  Problem::Solver sol(s);
  sol.solve();
  return 0;
}


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

using namespace std;

typedef long long ll;

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

	ll n;
	cin >> n;

	ll sm = 0;
	for(int i = 1; i <= n; i++){
		if(i % 3 == 0 || i % 5 == 0) continue;
		sm += i;
	}

	cout << sm << endl;
}


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

int moved = 0;
int w, h;
char myMap[20][20];

bool safe(int x, int y){
    return (x < h && y < w) && (x >= 0 && y >= 0);
}

void move(int x, int y){
    myMap[x][y] = '#';
    moved++;
    if (myMap[x+1][y] == '.' && safe(x+1, y)) move(x+1, y);
    if (myMap[x-1][y] == '.' && safe(x-1, y)) move(x-1, y);
    if (myMap[x][y+1] == '.' && safe(x, y+1)) move(x, y+1);
    if (myMap[x][y-1] == '.' && safe(x, y-1)) move(x, y-1);
    return;
}

int main(){
    while (1){
	cin >> w >> h;
	if (w == 0 && h == 0) break;

	moved = 0;
	int initX, initY;

	for (int i = 0; i < h; i++){
	    for (int j = 0; j < w; j++){
		cin >> myMap[i][j];
		if (myMap[i][j] == '@'){
		    initX = i;
		    initY = j;
		}
	    }
	}
	
	move(initX, initY);
	
	cout << moved << endl;
    }
}

Measured memory_bytes: 0
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_3_D
//p116.cpp

#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	stack<int> S1;
	stack<pair<int, int> > S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++) {
		if (ch == '\\') S1.push(i);
		else if (ch == '/' && S1.size() > 0) {
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j) {
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}

	vector<int> ans;
	while (S2.size() > 0) { ans.push_back(S2.top().second); S2.pop(); }
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size(); i++) {
		cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;
}




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

int main()
{

  int n;
  cin >> n;
  long double a[n];
  rep(i,n) cin >> a[i];
  long double ans = 1, sum = 0;
  rep(i,n) sum += 1 / a[i];
  cout << setprecision(10) << ans / sum << endl;
  return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int k;
	cin >> k;
	queue<ll> q;
	rep2(i, 1, 10){
		q.push(i);
	}
	ll ans = -1;
	while(k > 0){
		ll now = q.front(); q.pop();
		int bt = now % 10;
		if(bt != 0) q.push(now*10 + bt - 1);
		q.push(now*10 + bt);
		if(bt != 9) q.push(now*10 + bt + 1);
		ans = now;
		k--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
program slimes
    implicit none
    integer :: n, i, cnt = 0
    character(100000) s
    read *, n
    read *, s
    do i = 1, n
        if(s(i:i) .ne. s(i+1:i+1))then
            cnt = cnt + 1
        end if
    end do
    print *, cnt
end program

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

bool chara(char a){
  return ( a>='a' && a<='z')||(a>='A' && a<='Z');
}

int main(){
  char str[1025];
  int pos,len;

  while(fgets(str,1025,stdin)!=NULL){
    len = 0;
    pos = 0;
    while(str[pos] != '\n'){
      pos++;
      len++;
    }
 
    for(pos=0;pos<len-4;pos++){
      if(str[pos] == 'a'){
	if(str[pos+1] == 'p'){
	  if(str[pos+2] == 'p'){
	    if(str[pos+3] == 'l'){
	      if(str[pos+4] == 'e'){
		//	if( (pos==0 || !chara(str[pos-1])) && (pos+5 == len || !chara(str[pos+5])) ){
		  str[pos] = 'p';
		  str[pos+1] = 'e';
		  str[pos+2] = 'a';
		  str[pos+3] = 'c';
		  str[pos+4] = 'h';
		  //}
	      }
	    }
	  }
	}
      }
      else if(str[pos] == 'p'){
	if(str[pos+1] == 'e'){
	  if(str[pos+2] == 'a'){
	    if(str[pos+3] == 'c'){
	      if(str[pos+4] == 'h'){
		//if( (pos==0 || !chara(str[pos-1])) && (pos+5 == len || !chara(str[pos+5])) ){
		  str[pos] = 'a';
		  str[pos+1] = 'p';
		  str[pos+2] = 'p';
		  str[pos+3] = 'l';
		  str[pos+4] = 'e';
		  //	}
	      }
	    }
	  }
	}
      }
    }
    cout << str;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int,int> > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < n && m > 0; i++) {
    int buy = min(m, v[i].second);
    ans += buy * v[i].first;
    m -= buy;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  int a[10];
  int i;
  int m1,m2,m3;

    m1=m2=m3=-1;

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

  for(i=0;i<10;i++){
    if(m1<=a[i]){
      m3=m2;
      m2=m1;
      m1=a[i];
    }

    else if(m1>a[i]&&m2<=a[i]){
      m3=m2;
      m2=a[i];
    }

    else if(m2>a[i]&&m3<=a[i]){
      m3=a[i];
    }
  }

  printf("%d\n%d\n%d\n",m1,m2,m3);

  return 0;
}

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

using namespace std;

long long int n,k,x,y;

int main()
{
	//freopen("input14.txt","r",stdin);freopen("output14.txt","w",stdout);
	cin>>n>>k>>x>>y;
	if (n>=k){
		cout<<x*k+(n-k)*y;
	}
	else {
		cout<<x*n;
	}
    return 0;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
count=0
flag=False
for i in range(len(p)):
  if (i+1)==p[i]:
    count+=1
    if flag==True:
      count-=1
      flag=False
    else:
      flag=True
  else:
    flag=False
print(count)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
    FIO;
    int n; cin >> n;
    map <string , int > m;
    for(int i = 0; i < n; ++i)
    {
        string s; cin >> s;
        m[s]++;
    }

    cout << "AC x" << ' ' << m["AC"] << '\n';
    cout << "WA x" << ' ' << m["WA"] << '\n';
    cout << "TLE x" << ' ' << m["TLE"] << '\n';

    cout << "RE x" << ' ' << m["RE"] <<  '\n';
    return 0;
}

Measured memory_bytes: 3668
import java.io.*;

class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
                String line = reader.readLine();
                String[] strAry = line.split(" ");
                int[] a = new int[strAry.length]; 

                for(int i = 0; i <strAry.length; i++){
                    a[i] = Integer.parseInt(strAry[i]);
                }

                System.out.print(menseki(a[0], a[1]) + " ");
                System.out.println(shu(a[0], a[1]));

        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }catch(NumberFormatException e){
            System.out.println("??´??¢?????£????????????????????????");
        }
    }

    public static int menseki(int n, int m){
        int r;
        r = n * m;

        return r;
    }

    public static int shu(int n, int m){
        int r;
        r = 2 * (m + n);
        
        return r;
    }
}

Measured memory_bytes: 24116
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<queue>
#include<set>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll maxn=1e9;


int main()
{
	char s[1000];
	int w;
	while(cin>>s>>w)
	{
		for(int i=0;s[i]!='\0';i++)
		{
			if(i%w==0)cout<<s[i];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ac_count, wa_count, tle_count, re_count = 0, 0, 0, 0
for i in range(n):
  s = input()
  if s == "AC":
    ac_count += 1
  elif s == "WA":
    wa_count += 1
  elif s == "TLE":
    tle_count += 1
  else:
    re_count += 1
print("AC x ",ac_count)
print("WA x ",wa_count)
print("TLE x ",tle_count)
print("RE x ",re_count)

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define LOG(...) printf(__VA_ARGS__)
using namespace std;

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

    if (K <= N * M) {
        if (K % N == 0 || K % M == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < M; ++j) {
                if (i * j + (N - i) * (M - j) == K) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


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

using namespace std;

constexpr int INF = INT_MAX;

class RMQ {
  public:
    int n;
    vector<int> dat;
  
    RMQ(int n_)
    {
        n = 1;
        while (n < n_) {
            n *= 2;
        }
        dat.assign(2 * n - 1, INF);
    }
  
    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]);
        }
    }

    int query(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l) {
            return INF;
        }
        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);
        }
    }
    
    /* min [l, r] */
    int query(int l, int r)
    {
        return query(l, r + 1, 0, 0, n);
    }
};

int main()
{
    int N, Q;
    cin >> N >> Q;
    RMQ rmq(N);
    for (int i = 0; i < Q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            rmq.update(x, y);
        } else {
            cout << rmq.query(x, y) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
    #define ll long long int
    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #define all(a) (a).begin(), (a).end()
    #define sz size
    #define f first
    #define s second
    #define pb push_back
    #define er erase
    #define in insert
    #define mp make_pair
    #define pi pair
    #define rc(s) return cout<<s,0
    #define mod 1000000007
    #define PI 3.14159265359
    #define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
    using namespace std;
    ll a,b;
    int32_t main(){
    CODE_START;
    cin>>a>>b;
if(a>=10||b>=10){
    cout<<"-1";
}else cout<<a*b;
}

Measured memory_bytes: 256
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()
    A, B = il()
    for n in range(A, B + 1):
        if n % K == 0:
            print('OK')
            exit()
    else:
        print('NG')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9484
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int a,b,c;
  
  cin >> a >> b >> c;
  
  if (a+b+c>=22) cout << "bust" << endl;
  else cout << "win" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
int n, m, k, x, y, sum, ans;
char s[1000005];
int main () {
	scanf("%s", s);
	n=strlen(s);
	for (int i=0; i<n; i++) {
		while (s[i+1]==s[i]) i++;
		ans++;
	}
	printf("%d\n", ans-1);
	return 0;
}

Measured memory_bytes: 892
use std::collections::HashMap;

fn main() {
  let _: usize = read();
  let vecd: Vec<i64> = read_vec();
  let _: usize = read();
  let vect: Vec<i64> = read_vec();

  let mut hashd: HashMap<i64, usize> = HashMap::new();
  let mut hasht: HashMap<i64, usize> = HashMap::new();
  for d in vecd {
    let counter = hashd.entry(d).or_insert(0);
    *counter += 1;
  }
  for t in vect {
    let counter = hasht.entry(t).or_insert(0);
    *counter += 1;
  }

  for (kt,vt) in hasht {
    let vd = hashd.get(&kt);
    if vd == None {
      println!{"NO"};
      return;
    }
    if vd.unwrap() < &vt {
      println!{"NO"};
      return;
    }
  }

  println!("YES");
}

fn read<T: std::str::FromStr>() -> T {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().parse::<T>().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}

Measured memory_bytes: 23740
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

ll cnt[int(1e5 + 5)];

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % inf, N / 2) % inf;
  else return A * Pow(A * A % inf, N / 2) % inf;
}

ll Calc(ll num, ll now){
  for (ll i = 1; i * i <= num; i++){
    if (num % i == 0){
      if (i * i == num){
        cnt[i] += now;
        cnt[i] %= inf;
      }else{
        cnt[i] += now;
        cnt[i] %= inf;
        cnt[num / i] += now;
        cnt[num / i] %= inf;
      }
    }
  }
  return 0;
}

int main(){
  ll N, K; cin >> K >> N;

  ll ans = 0;
  for (ll i = N; i >= 1; i--){
    ll num = N / i;
    ll now = Pow(N / i, K) - cnt[i]; now %= inf;
    ans += i * now; ans %= inf;
    if (ans < 0) ans += inf;
    Calc(i, now);
  }

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


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    string s; cin >> s;
    ll k; cin >> k;

    int n = s.size();
    bool flag = true;
    ll sum = 0;
    ll cnt = 1, fcnt = 0;
    for(int i = 0; i < n - 1; i++){
        if(s[i] == s[i + 1]) cnt++;
        else{
            if(flag){
                fcnt = cnt;
                flag = false;
            }else{
                sum += cnt / 2;
            }
            cnt = 1;
        }
    }

    ll sum2 = 0;
    ll ecnt = 0;
    ll bcnt = 0;
    if(s[0] == s[n - 1]){
        sum2 = (fcnt + cnt) / 2;
        bcnt = fcnt / 2;
        ecnt = cnt / 2;
    }else{
        sum += fcnt / 2;
        sum += cnt / 2;
    }

    if(n == cnt) cout << cnt * k / 2 << endl;
    else cout << sum * k + sum2 * (k - 1) + bcnt + ecnt << endl;


    return 0;
}


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

int main()
{
  	map<int,int> cnt;
  	int n;
  	for(int i=0 ; i<3 ; ++i)
    {
    	cin>>n;
      	++cnt[n];
    }
  	for(auto &i:cnt)
    {
    	if(i.second==1)
        cout<<i.first<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define maxn 200050
#define add(u,v) (to[++top]=head[u],head[u]=top,w[top]=v)
#define For(x) for(int h=head[x],o=w[h];h;o=w[h=to[h]])
using namespace std;
int n,m,to[maxn],head[maxn],w[maxn],u,v,top;
int a[maxn],b[maxn],c[maxn],co[maxn],r[maxn],q,i;
void dfs(int x,int rg,int col)
{
	if (rg<=r[x]||rg<=0) return;
	r[x]=rg; 
	if (co[x]==0) co[x]=col;
	For(x) dfs(o,rg-1,col);
}
int main()
{
	scanf("%d%d",&n,&m);
	while (m--)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
    }
    scanf("%d",&q);
    for (i=1;i<=q;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]);
    memset(co,0,sizeof(co)); memset(r,0,sizeof(r));
    for (i=q;i>=1;i--) dfs(a[i],b[i]+1,c[i]);
    for (i=1;i<=n;i++) printf("%d\n",co[i]);
    return 0;
}

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



void dfs(vector<bool>& used, vector<vector<int> >& graph, int c){
    
    if(used[c]) return;  //すでに訪問済みなら戻る
    used[c] = true;      //訪問済みにする
    for(int i = 0; i < graph[c].size(); i++){
        dfs(used, graph, graph[c][i]);
    }
}

int main(void){

    int n, m; cin >> n >> m;
    vector<vector<int> > graph(n + m + 1);  //隣接リスト
    for(int i = 1; i <= n; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int l; cin >> l;
            graph[i].push_back(l + n);
            graph[l + n].push_back(i);
        }
    }

    /*for(int i = 1; i <= n + m; i++){
        cout << i << ": ";
        for(int j = 0; j < graph[i].size(); j++){
            cout << graph[i][j] << " ";
        }
        cout << endl;
    }*/

    
    vector<bool> used(n + m + 1, false);
    dfs(used, graph, 1);      //深さ優先探索

    bool flag = true;
    for(int i = 1; i <= n; i++){
        if(used[i] == false){
            flag = false;
            break;
        }
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 8440
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
using namespace std;
const int maxn=10+10;
int n,a[maxn][maxn];
int aa[maxn],bb[maxn];
int main(){
	REP(i,1,3)REP(j,1,3)
		scanf("%d",&a[i][j]);
	REP(i,0,a[1][1]){
		bool ee=0;
		aa[1]=i;
		bb[1]=a[1][1]-aa[1];
		bb[2]=a[1][2]-aa[1];
		bb[3]=a[1][3]-aa[1];
		aa[2]=a[2][1]-bb[1];
		aa[3]=a[3][1]-bb[1];
		REP(j,1,3)REP(k,1,3)
			if(a[j][k]!=aa[j]+bb[k]){
				ee=1;
				break;
			}
		if(ee==0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>
#include<iomanip>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define INF 1e9
#define min_3(a, b, c) min(a, min(b, c));
typedef long long ll;

int main()
{
  int n; cin >> n;
  int ans = n;

  //全探索
  for (int i = 0; i <= n; i++)
  {
    int count = 0;
    int t = i;
    
    //階乗はそれぞれ何回か，割り切れなかった分は1結果に足す
    while(t > 0) count += t % 6, t /= 6;
    t = n - i;
    while(t > 0) count += t % 9, t /= 9;
    if (ans > count) ans = count;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();

    match std::io::stdin().read_line(&mut line) {
        Ok(0) => return Err("eof".to_string()),
        Ok(_) => (),
        Err(err) => return Err(format!("{:?}", err)),
    }

    line.trim()
        .split_whitespace()
        .map(|x| x.parse::<T>())
        .collect::<Result<Vec<T>, _>>()
        .map_err(|_| format!("{}", "parse error"))
}

use std::cmp::Ordering;

fn main() {
    let nv = read_parameters::<usize>().unwrap();
    let n = nv[0];

    let mut taro = 0;
    let mut hanako = 0;
    for _ in 0..n {
        let sv = read_parameters::<String>().unwrap();
        let (t, h) = (&sv[0], &sv[1]);

        match t.cmp(h) {
            Ordering::Greater => taro += 3,
            Ordering::Less => hanako += 3,
            Ordering::Equal => {
                taro += 1;
                hanako += 1;
            }
        }
    }
    println!("{} {}", taro, hanako);
}



Measured memory_bytes: 5044
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
ull t[100];

ull gcd(ull a, ull b)
{
    if(a < b) swap(a, b);
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

inline ull lcm(ull a, ull b)
{
    //return (a * b) / gcd(a, b);
    return a / gcd(a, b) * b;
}

void init()
{
}

void solve()
{
    //sort(t, t+N, greater<ull>());
    //ull ans = t[0];
    ull ans = 1ull;
    //FOR(i, 1, N){
    REP(i, N){
        if(ans % t[i] != 0) ans = lcm(ans, t[i]);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N){
        cin >> t[i];
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>

using namespace std;

struct SecondDescComp {
  bool operator()(const pair<int64_t, int64_t> &a, const pair<int64_t, int64_t> &b) const {
    return a.second >= b.second;
  }
};

int main(int argc, char *argv[]) {
  int64_t N, M;
  cin >> N >> M;
  priority_queue<int64_t, std::vector<int64_t>, std::greater<int64_t>> nums;
  for(int i = 0; i < N; i++){
    int64_t tmp;
    cin >> tmp;
    nums.push(tmp);
  }
  multiset<pair<int64_t, int64_t>, SecondDescComp> replaces;
  for(int i = 0; i < M; i++){
    int64_t b, c;
    cin >> b >> c;
    replaces.insert({b, c});
  }
  for(auto &p : replaces) {
    for(int i = 0; i < p.first; i++){
      if(p.second <= nums.top()) break;
      //cerr << nums.top() << "->" << p.second << endl;
      nums.pop();
      nums.push(p.second);
    }
  }
  int64_t sum = 0;
  while(!nums.empty()) {
    sum += nums.top();
    nums.pop();
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 7284
#coding: utf-8
N = input()
N_list = list(map(int,N))
N_str = str(N)

if   (N_list[0] + N_list[1] + N_list[2] + N_list[3]) ==7:
    print(N_str[0] +"+"+ N_str[1] +"+"+  N_str[2] + "+" + N_str[3]+"=7")

elif (N_list[0] - N_list[1] + N_list[2] + N_list[3]) ==7:
    print(N_str[0] +"-"+ N_str[1] +"+"+  N_str[2] + "+" + N_str[3]+"=7")

elif (N_list[0] - N_list[1] - N_list[2] + N_list[3]) ==7:
    print(N_str[0] +"-"+ N_str[1] +"-"+  N_str[2] + "+" + N_str[3]+"=7")

elif (N_list[0] - N_list[1] - N_list[2] - N_list[3]) ==7:
    print(N_str[0] +"-"+ N_str[1] +"-"+  N_str[2] + "-" + N_str[3]+"=7")

elif (N_list[0] + N_list[1] - N_list[2] + N_list[3]) ==7:
    print(N_str[0] +"+"+ N_str[1] +"-"+  N_str[2] + "+" + N_str[3]+"=7")

elif (N_list[0] + N_list[1] - N_list[2] - N_list[3]) ==7:
    print(N_str[0] +"+"+ N_str[1] +"-"+  N_str[2] + "-" + N_str[3]+"=7")

elif (N_list[0] + N_list[1] + N_list[2] - N_list[3]) ==7:
    print(N_str[0] +"+"+ N_str[1] +"+"+  N_str[2] + "-" + N_str[3]+"=7")

elif (N_list[0] - N_list[1] + N_list[2] - N_list[3]) ==7:
    print(N_str[0] +"-"+ N_str[1] +"+"+  N_str[2] + "-" + N_str[3]+"=7")

Measured memory_bytes: 3064