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

int main() {
  int n, m, pena = 0, correct = 0;
  cin >> n >> m;
  vector<bool> ac(n+1, 0);
  vector<int> tpena(n+1, 0);
  for (int i = 0; i < m; ++i) {
    int p;
    string s;
    cin >> p >> s;
    if (ac[p] == 1) continue;
    if (s == "AC") {
      ac[p] = 1;
      ++correct;
      pena += tpena[p];
    }
    else
      ++tpena[p];
  }
  printf("%d %d\n", correct, pena);
}

Measured memory_bytes: 640
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	vector<int> x(n), y(n), a(n);
	vector<vector<bool>> field(h, vector<bool>(w, true));

	FOR(i, 0, n) {
		int x, y, a;
		cin >> x >> y >> a;

		int wl = 0, wu = w;
		int hl = 0, hu = h;
		switch (a) {
		case 1:
			wu = x;
			break;
		case 2:
			wl = x;
			break;
		case 3:
			hu = y;
			break;
		case 4:
			hl = y;
			break;
		}
		FOR(i, hl, hu) {
			FOR(j, wl, wu) {
				field[i][j] = false;
			}
		}

	}

	int cnt = 0;
	FOR(i, 0, h) {
		FOR(j, 0, w) {
			if (field[i][j])
				cnt++;
		}
	
	}
	cout << cnt << endl;
	return 0;
	
}

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

bool isThree(int num);

int main(){
    int n,i;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3==0)cout<<" "<<i;
        else if(isThree(i)==true)cout<<" "<<i;
    }
    cout<<"\n";
    return 0;
}

bool isThree(int num){
    bool flag=false;
    int i;
    while(true){
        i=num;
        if(i/10==0){
            if(num==3){
                flag=true;
            }
            break;
        }
        else{
            if(num%10==3){
                flag=true;
                break;
            }
            num=num/10;
        }
    }

    return flag;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    char str[100005];
    cin>>str;
    int N=strlen(str);
    for(int i=0;i<N;i++){
       if(str[i]==str[i+2]&&i<N-2){cout<<i+1<<' '<<i+3; break;}
       else if(str[i]==str[i+1]&&i<N-1){cout<<i+1<<' '<<i+2; break;}
       if(i==N-1){cout<<-1<<' '<<-1;}
    }
    return 0;
}


Measured memory_bytes: 384
n , a , b = map(int, input().split())
x = list(map(int,input().split()))
c = 0

for i in range(n-1):
    if (x[i+1]-x[i])*a<b:
        c+=(x[i+1]-x[i])*a
    else:
        c+=b
print(c)


Measured memory_bytes: 14224
# -*- coding: utf-8 -*-
import re

S = input()
flag = 0
if(S[0] == 'A'):
  if(len(re.findall('C', S[2:-1])) == 1):
    index = S[2:-1].find('C') + 2
    ss = 'a' + S[1:index] + 'c' + S[index+1:]
    if(S.lower() == ss):
      flag = 1

if(flag == 1):
  print('AC')
else:
  print('WA')


Measured memory_bytes: 3188
import java.util.*;
import java.util.Collections;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int ans = 0;
		int A = 0;
		List<Integer> list = new ArrayList<>();
		for(int i = 0;i < H; i++){
			list.add(sc.nextInt());
		}
		for(int j:list){
			ans += j;
		}
		if(ans % 10 != 0){
			System.out.println(ans);
		}else{
			for(int k = 0;k < list.size(); k++){
				if(list.get(k) % 10 != 0){
					A += 1;
				}
			}
			if(A == 0){
				System.out.println(0);
			}else{
				for(int l = 0;l < list.size(); l++){
					Collections.sort(list);
					ans = 0;
					int Z = list.get(l);
					list.remove(l);
					for(int m:list){
						ans += m;
					}
					if(ans % 10 != 0){
							System.out.println(ans);
							break;
						}else{
							list.add(Z);
						}
				}
			}
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    int r = 0, d = 0;
    for (int i = 0; i < n; i++) {
      int p, d1, d2;
      cin >> p >> d1 >> d2;
      if (d < d1 + d2) {
        d = d1 + d2;
        r = p;
      }
    }
    cout << r << ' ' << d << endl;
  }
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var num_X = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int counter = 1;

            foreach(var c in num_X)
            {
                if (c == 0)
                {
                    break;
                }
                counter++;
            }

            Console.WriteLine(counter);

            Console.Out.Flush();
        }
    }
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};

class UnionFind{
  public:
  vector<ll> par;
  UnionFind(int size) : par(size,-1) {}
  bool unite(ll x,ll y){
    x = root(x),y = root(y);
    if(x == y)return false;
    if(par[y] < par[x])swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool find(ll x,ll y){
    return root(x) == root(y);
  }
  ll root(ll x){
    return par[x] < 0 ? x : par[x] = root(par[x]);
  }
  ll size(ll x){
    return -par[root(x)];
  }
};

int main(){

  ll n,m;
  cin >> n >> m;
  vector<P> v;
  REP(i,m){
    ll x,y;cin >> x >> y;
    x--,y--;
    v.push_back(make_pair(x,y));
  }
  reverse(ALL(v));
  UnionFind uf(n);
  vector<ll> res;
  const ll max = n*(n-1)/2;
  ll pre = 0;
  res.push_back(max);

  REP(i,m-1){
    ll fs = uf.size(v[i].first),ss = uf.size(v[i].second);
    bool flag = uf.find(v[i].first,v[i].second);
    uf.unite(v[i].first,v[i].second);
    if(fs == 1 && ss == 1){
      pre++;
      res.push_back(max-pre);
    }else if(fs > 1 && ss == 1){
      pre += fs;
      res.push_back(max-pre);
      
    }else if(fs == 1 && ss > 1){
      pre += ss;
      res.push_back(max-pre);
      
    }else{
      if(flag){
        res.push_back(max-pre);

      }else{
        pre = pre-1ll*fs*(fs-1)/2-1ll*ss*(ss-1)/2+1ll*(fs+ss)*(fs+ss-1)/2;
        res.push_back(max-pre);
        
      }
    }
    
  }
  reverse(ALL(res));
  REP(i,m){
    cout << res[i] << endl;
  }





  return 0;
}

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

#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++)

int main() {
    string str;
    cin >> str;
    cout << ( (str == "AAA" || str == "BBB") ? "No" :"Yes") << endl;
    return 0;    
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t N;
  cin >> N;
  int64_t res = 0;
  int64_t M = N;
  for (int64_t i = 2; i * i < M + 1; i++) {
    int cnt = 0;
    while (N % i == 0) {
      N /= i;
      cnt++;
    }
    int k = 1;
    while (k * (k + 1) / 2 <= cnt) {
      k++;
    }
    res += k - 1;
  }
  if (N != 1) res++;
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3652
MOD = 10**9 + 7

class ModInt:
    def __init__(self, x):
        if isinstance(x, ModInt):
            self.x = x.x
        else:
            self.x = x % MOD
            if self.x < 0:
                self.x += MOD
    
    def get_mod(self):
        return MOD
    
    def inv(self, other):
        return ModInt(pow(ModInt(other).x, MOD - 2, MOD))
    
    # str関数を使用したとき
    def __str__(self):
        return str(self.x)
    
    def __int__(self):
        return self.x
    
    __index__ = __int__
    
    # print関数を使用したとき
    __repr__ = __str__

    ## 四則演算
    def __add__(self, other):
        return ModInt(self.x + ModInt(other).x)
    
    def __sub__(self, other):
        return ModInt(self.x - ModInt(other).x)

    def __mul__(self, other):
        return ModInt(self.x * ModInt(other).x)
    
    # /
    def __truediv__(self, other):
        # a * a^(p - 2) ≡ 1 (mod p) 逆元から求める
        return ModInt(self.x * pow(ModInt(other).x, MOD - 2, MOD))

    # //
    def __floordiv__(self, other):
        return self.x // ModInt(other).x

    # 累乗
    def __pow__(self, other):
        return ModInt(pow(self.x, ModInt(other).x, MOD))

    ## 四則演算の順序
    __radd__ = __add__

    def __rsub__(self, other):
        return ModInt(other - self.x)
    
    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rfloordiv__(self, other):
        return ModInt(other // self.x)
    
    # 累乗の順序
    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))
    
    ## 不等号
    def __lt__(self, other):
        return self.x < ModInt(other).x
    
    def __gt__(self, other):
        return self.x > ModInt(other).x

    def __le__(self, other):
        return self.x <= ModInt(other).x
    
    def __ge__(self, other):
        return self.x >= ModInt(other).x
    
    def __eq__(self, other):
        return self.x == ModInt(other).x
    
    def __ne__(self, other):
        return self.x != ModInt(other).x
    
    ## in-place 演算子(+=, -=, *=, /=)
    def __iadd__(self, other):
        self.x += ModInt(other).x
        if self.x >= MOD:
            self.x -= MOD
        return self.x
    
    def __isub__(self, other):
        self.x -= ModInt(other).x
        if self.x < 0:
            self.x += MOD
        return self.x
    
    def __imul__(self, other):
        self.x = ModInt(self.x * ModInt(other).x)
        return self.x

    def __itruediv__(self, other):
        self.x = ModInt(self.x * pow(ModInt(other).x, MOD - 2, MOD))
        return self.x
    
    def __ifloordiv__(self, other):
        self.x = self.x // ModInt(other).x

def comb(n, r):
    res = ModInt(1)
    for i in range(n-r+1, n+1):
        res *= i
    for i in range(2, r+1):
        res /= i
    return res

n, a, b = map(ModInt, map(int, input().split()))

ans = 2 ** n

ans = ans - comb(n, a)
ans = ans - comb(n, b)
ans = ans - 1

print(ans)

Measured memory_bytes: 87004
/**
 *     author: qodjf
 *     created: 04.17.2020 13:05:16
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

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

int H, W;
vector<string> m;

int dp[110][110];

int main() {
  cin >> H >> W;
  m.resize(H);
  for (int i = 0; i < H; i++) {
    cin >> m[i];
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i == 0 && j == 0) {
        dp[i][j] = m[i][j] == '#';
        continue;
      }
      dp[i][j] = INF;
      if (i) {
        dp[i][j] =
            min(dp[i][j],
                dp[i - 1][j] + (m[i][j] == '.' ? 0 : (m[i - 1][j] == '.')));
      }
      if (j) {
        dp[i][j] =
            min(dp[i][j],
                dp[i][j - 1] + (m[i][j] == '.' ? 0 : (m[i][j - 1] == '.')));
      }
    }
  }

  cout << dp[H - 1][W - 1] << endl;
}


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

using namespace std;

int main()
{
    int l;
    cin >> l;
    double v = pow(l/3.0,3);
    cout << setiosflags(ios::fixed|ios::left);
    cout << setprecision(6);
    cout << v << endl;
    return 0;
}

Measured memory_bytes: 256
N, H = map(int, input().split())
ab = [[int(i) for i in input().split()] for _ in range(N)]
amax = max(ab)[0]

def solve(H) :
    ret = 0
    ab.sort(key=lambda x: x[1], reverse=True)
    for a, b in ab :
        if b > amax :
            H -= b
            ret += 1
        else :
            break
            
        if H <= 0 :
            return ret
            
    ret += (H + amax - 1) // amax
    return ret

print(solve(H))

Measured memory_bytes: 64344
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;
  long long sum = 0, a;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    sum += a;
  }
  cout << (sum % 2 ? "NO" : "YES") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define Sort(a, n) sort(a, a+n);
#define reverse(a, n) 
using ll = long long;
using P = pair<int, int> ;
int a[10];
int main(){
  int n; cin >> n;
  int ans=0;
  vector<ll> vec(n);
  rep(i, n){
    cin >> vec[i];
  }
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      for(int q=j+1; q<n; q++){
        if ((vec[i] + vec[j] > vec[q]) && 
          (vec[q] + vec[i] > vec[j]) &&
          (vec[q] + vec[j] > vec[i])&&
           vec[i] != vec[j]&&
           vec[i] != vec[q]&&
           vec[j] != vec[q]){
            ans++;
          }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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 ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 10;
const int MAX_V = 110;

bool graph[MAX_N][MAX_N];

int dfs(int v, int N, bool visited[MAX_N]) {
	bool all_visited = true;
	rep(i, N) {
		if (!visited[i]) all_visited = false;
	}
	if (all_visited)return 1;
	int ret = 0;
	rep(i, N) {
		if (!graph[v][i])continue;
		if (visited[i])continue;
		visited[i] = true;
		ret += dfs(i, N, visited);
		visited[i] = false;
	}
	return ret;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int N, M;
	cin >> N >> M;
	rep(i, M) {
		int A, B; cin >> A >> B;
		graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
	}
	bool visited[MAX_N];
	rep(i, N)visited[i] = false;
	visited[0] = true;
	cout << dfs(0, N, visited) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,A,B;
	while(cin>>N>>A>>B) {
		ll ans=0;
		RANGE(i, 1, N+1) {
			string s=to_string(i);
			ll sum=0;
			REP(j, s.size())sum+=s[j]-'0';
			if(A<=sum&&sum<=B) ans+=i;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
/*
// シンプルな構文解析用
typedef string::const_iterator State;
class ParseError {};
//*/
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;



int main(void) {
	int N;
	cin >> N;
	string s, t;
	cin >> s >> t;
	ll ans = 1;
	int start = 0;
	if (s[0] == t[0]) {
		ans = 3;
		start = 1;
	}
	else {
		ans = 6;
		start = 2;
	}
	repl(i, start, N) {
		if (s[i] == t[i]) {
			if (s[i - 1] == t[i - 1]) {
				ans *= 2;
				ans %= MOD;
			}

		}
		else {
			if (s[i - 1] == t[i - 1]) {
				ans *= 2;
				ans %= MOD;
			}
			else {
				ans *= 3;
				ans %= MOD;
			}
			i++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

bool G[32][32];
bool visit[32];
bool dfs(int node){
  if(visit[node]) return false;
  visit[node] = true;

  for(int to=0;to<32;++to){
	if(!G[node][to]) continue;
	if(!dfs(to)) return false;
  }
  
  visit[node] = false;
  return true;
}

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

  int Q; cin >> Q;
  while(Q--){
	int H, W; cin >> H >> W;
	vector<string> line(H);
	REP(i,H) cin >> line[i];

	vector< pair<PII,PII> > sz(32, MP(MP(128,128),MP(-1,-1)));
	REP(y,H) REP(x,W){
	  if(line[y][x] == '.') continue;
	  PII& tl = sz[line[y][x]-'A'].first;
	  PII& br = sz[line[y][x]-'A'].second;
	  tl.first = min(tl.first, x);
	  br.first = max(br.first, x);
	  tl.second = min(tl.second, y);
	  br.second = max(br.second, y);
	}
	
	fill((bool*)G, (bool*)G+32*32, false); 
	bool isSafe = true;
	REP(i,32){
	  if(sz[i].second.second < 0) continue;
	  PII& tl = sz[i].first;
	  PII& br = sz[i].second;
	  for(int y=tl.second;y<=br.second;++y){
		for(int x=tl.first;x<=br.first;++x){
		  if(line[y][x] == '.'){
			isSafe = false;
			break;
		  }
		  char over = line[y][x]-'A';
		  if(over != i) G[over][i] = true;
		}
	  }
	}

	for(int i=0;i<32;++i){
	  fill(visit, visit+32, false);
	  if(!dfs(i)){
		isSafe = false;
		break;
	  }
	}
	
	cout << (isSafe? "SAFE": "SUSPICIOUS") << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

/*
acp
ae
a*c*p*
a**e**

abcdef
abc
abcdef
a*b*c*

*/

int main(){

    ll N, M;
    string s, t;
    cin >> N >> M >> s >> t;
    ll L = lcm(N, M);
    for(ll i = 0; i < N; i++){
        ll idx = i * L / N * M;
        if(idx % L == 0){
            idx /= L;
            if(s[i] != t[idx]){
                cout << "-1" << endl;
                return 0;
            }
        }        
    }
    cout << L << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

class strong_components{
private:
    vector<vector<int>> v,rv,nv;
    vector<int> rs,visited,cmp,cmp_size;
    void dfs(int n){
        visited[n] = 1;
        for(auto x:v[n]) if(!visited[x]) dfs(x);
        rs.push_back(n);
    }
    void rdfs(int n,int cnt){
        visited[n] = 1;
        cmp[n] = cnt;
        for(auto x:rv[n]) if(!visited[x]) rdfs(x,cnt);
    }
public:
    strong_components(int N,vector<vector<int>>& graph){
        v = graph;
        rv = vector<vector<int>>(N);
        visited = cmp = cmp_size = vector<int>(N,0);
        for(int i=0;i<N;i++) for(auto x:v[i]) rv[x].push_back(i);
        for(int i=0;i<N;i++) if(!visited[i]) dfs(i);
        for(int i=0;i<N;i++) visited[i] = 0;
        int now = 0;
        for(int i=(int) rs.size()-1;i>=0;i--) if(!visited[rs[i]]) rdfs(rs[i],now++);
        nv = vector<vector<int>>(now);
        for(int i=0;i<N;i++){
            for(auto x:v[i]){
                if(cmp[i]!=cmp[x]){
                    nv[cmp[i]].push_back(cmp[x]);
                    cmp_size[cmp[x]]++;
                }
            }
        }
    }
    int find(int n){return cmp[n];}
    bool is_same_group(int a,int b){return cmp[a]==cmp[b];}
};

class SAT{
private:
    int N;
    vector<vector<int>> v;
public:
    SAT(int N):N(N){
        v = vector<vector<int>>(2*N);
    }
    void add_closure(int x, bool bx, int y, bool by){
        v[x+(!bx)*N].push_back(y+by*N);
        v[y+(!by)*N].push_back(x+bx*N);
    }
    vector<int> solve(){
        strong_components scc(2*N,v);
        //不可能か判定
        vector<int> res(N);
        for(int i=0;i<N;i++){
            //同じ強連結成分にあったらだめ
            if(scc.is_same_group(i,i+N)) return vector<int> {};
            res[i] = (scc.find(i)<scc.find(i+N));
        }
        return res;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,D;
    cin >> N >> D;
    vec<int> X(N),Y(N);
    for(int i=0;i<N;i++) cin >> X[i] >> Y[i];
    SAT sat(N);
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
        if(abs(X[i]-X[j])<D) sat.add_closure(i,false,j,false);
        if(abs(X[i]-Y[j])<D) sat.add_closure(i,false,j,true);
        if(abs(Y[i]-X[j])<D) sat.add_closure(i,true,j,false);
        if(abs(Y[i]-Y[j])<D) sat.add_closure(i,true,j,true);
    }
    auto res = sat.solve();
    if(res.empty()){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for(int i=0;i<N;i++) cout << (res[i]? X[i]:Y[i]) << "\n";
}

Measured memory_bytes: 4056
package main

import "fmt"

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	var s string
	fmt.Scan(&s)
	values := []string{"dream", "dreamer", "erase", "eraser"}

	// 文字列反転させるといいらしい
	s = Reverse(s)
	for i := 0; i < len(values); i++ {
		values[i] = Reverse(values[i])
	}

	res := true
	for i := 0; i < len(s); {
		match := false
		for j := 0; j < len(values); j++ {
			vlen := len(values[j])
			if i+vlen > len(s) {
				continue
			}

			str := s[i : i+vlen]
			if values[j] == str {
				match = true
				i += vlen
				break
			}
		}
		if !match {
			res = false
			break
		}
	}

	if res {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(){
    int a,b,c,t;
    scanf("%d %d %d",&a,&b,&c); 
    if(a > b){
       t = a;
       a = b;
       b = t;
}
    if(c < a){
       t = c;
       c = b;
       b = a;
       a = t;
}
    else if(c >= a && b > c){
       t = c;
       c = b;
       b = t;
}
    printf("%d %d %d\n",a,b,c);
    return 0;
}


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

template <typename T>
class BIT {
  public:
    int N;
    vector<T> data;
    BIT(T _N) : N(_N) {
        data.assign(2 * N + 10, 0);
    };

    void add(int a, T w) {
        for (int x = a; x <= N; x += x & -x)
            data[x] += w;
    }
    T sum(int a) {
        T res = 0;
        for (int x = a; x > 0; x -= x & -x)
            res += data[x];
        return res;
    }
    T sum(int l, int r) { return sum(r) - sum(l - 1); }

    void add0(int a, T w) { add(a + 1, w); }
    T sum0(int a) { return sum(a + 1); }
    T sum0(int l, int r) { return sum0(r) - sum0(l - 1); }
};

int main() {
    int n, Q;
    cin >> n >> Q;

    vector<int> a(n + 1);
    rep(i, n) cin >> a[i + 1];

    vector<pair<int, int>> p(Q), query(Q);
    rep(i, Q) {
        cin >> p[i].second >> p[i].first;
        query[i] = p[i];
    }

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

    vector<int> la(500005);
    BIT bit(n + 1);

    int mr = 1;

    map<pair<int, int>, int> mp;
    rep(i, Q) {
        for (int j = mr; j <= p[i].first; ++j) {
            //初
            if (la[a[j]] != 0)
                bit.add(la[a[j]], -1);
            la[a[j]] = j;
            bit.add(j, 1);
        }
        mr = p[i].first;

        mp[p[i]] = bit.sum0(p[i].second - 1, p[i].first);
    }

    rep(i, Q) {
        cout << mp[query[i]] << "\n";
    }

    return 0;
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll inf=100000000000000000,mod=1000000007,m;
ll dist(pair<ll,ll> a,pair<ll,ll> b)
{
    ll res;
    res=(a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
    return res;
}
int main(){
   
   ll n,k,sum=0;
   cin>>n>>k;
   ll arr[n];
   for(ll i=0;i<n;i++)cin>>arr[i];sort(arr,arr+n);
   if(k>=n)
   cout<<"0"<<endl;
   else
   {
      for(ll i=0;i<n-k;i++)
      sum+=arr[i];
      cout<<sum<<endl;
   }
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
#define Rep(i,n) for(int i = 0;i < (n);i++)	
typedef long long ll;

int gcd(int a, int b) { if (b == 0)  return a;  else  return gcd(b, a % b);  }
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; }
int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; }
int mod(int a, int b) { return a % b; }

class Human {
public:
	ll number;
	ll tall;
	ll R, L;
	Human(int _i, ll _a) :
		tall(_a),
		number(_i)
	{
		R = number - tall;
		L = number + tall;
	}
};


int main() {
	ll n;
	ll ans = 0;
	std::vector<Human> A;
	std::cin >> n;
	Rep(i, n) {
		ll a;
		std::cin >> a;
		
		A.emplace_back(i + 1, a);
	}
	std::vector<ll> boxR(250000,0);
	std::vector<ll> boxL(250000,0);
	for (auto iter = A.begin(); iter != A.end(); iter++) {
		if (iter->R >= 0) {
			boxR[iter->R]++;
		}
		if (iter->L <= 200000) {
			boxL[iter->L]++;
		}
	}
	Rep(i, 250000) {
		ans += boxR[i] * boxL[i];
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 13424
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  int n;
  cin >> n;
  vi data(n);
  rep(i,n) cin >> data[i];
  int ans = 0;
  rep(i,n) {
    rep(j,n) {
      if(i == j) continue;
      else ans += data[i] * data[j];
    }
  }
  cout << ans/2;
  hinata;
}

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

int main(void)
{
    using namespace std;
    int N, M;
    cin >> N >> M;

    int total = 0;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        total += A[i];
    }
    double sikii = (double)total / (4 * M);

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] >= sikii) {
            cnt++;
        }
    }
    
    if (cnt >= M) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

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

int main()
{
    int n;
    cin>>n;
    
    int a[n], sum=0;
    
    for(int i=0;i<n;i++)
    { cin>>a[i];
    sum+=a[i];
    }
    
    if(sum%2==0)
    { cout<<"YES";}
    else cout<<"NO";
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int main()
{
	int n, k, q;
	cin >> n >> k >> q;
	for(int i = 1; i <= q; i++){
		int x;
		scanf("%d", &x);
		a[x]++;
	}
	for(int i = 1; i <= n; i++){
		if(a[i] - q + k <= 0){
			printf("No\n");
		}else{
			printf("Yes\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t H, W;
    std::cin >> H >> W;

    boost::multi_array<char, 2> mat(boost::extents[H][W]);
    for (auto p = mat.data(); p < (mat.origin() + mat.num_elements()); ++p) {
        std::cin >> *p;
    }

    for (int64_t h = 0; h < H; ++h) {
        for (int64_t w = 0; w < W; ++w) {
            bool isOk = false;

            if (mat[h][w] == '.') {
                continue;
            }

            constexpr std::pair<int, int> dir[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
            for (auto d: dir) {
                const int xx = w + d.first;
                const int yy = h + d.second;
                if (0 <= xx && xx < W && 0 <= yy && yy < H) {
                    if (mat[yy][xx] == '#') {
                        isOk = true;
                        break;
                    }
                }
            }

            if (!isOk) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
def BellmanFord(edges,num_v,s):
  #グラフの初期化
  inf=float("inf")
  dist=[inf]*num_v
  dist[s]=0
  
  #辺の緩和
  for i in range(num_v-1):
    for edge in edges: #edges[頂点][頂点][重み]
      if dist[edge[0]] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
  ans=-dist[n-1]
  neg=[False]*num_v
  for i in range(num_v):
    for edge in edges: #edges[頂点][頂点][重み]
      if dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        neg[edge[1]]=True
      if neg[edge[0]]:
        neg[edge[1]]=True
  if neg[n-1]:
    ans='inf'
  return ans
edges=[]
for i in range(m):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  c*=-1
  edges.append((a,b,c))
print(BellmanFord(edges,n,0))

Measured memory_bytes: 3344
from math import sqrt

MOD = 10 ** 9 + 7


def primes(N):
    p = [True] * (N + 1)
    p[0] = p[1] = False
    for i in range(2, int(sqrt(N)) + 1):
        if p[i]:
            for j in range(i * 2, N + 1, i):
                p[j] = False
    return [i for i, x in enumerate(p) if x]


# --------------------
N = int(input())
P = primes(N)

factors = []

for p in P:
    i = p
    f = 0
    while i <= N:
        f += N // i
        i *= p
    factors.append(f)

ans = 1

for f in factors:
    ans *= f + 1
    ans %= MOD

print(ans)

Measured memory_bytes: 38384
x = int(input())
if x == 2:
  print(2)
  
else:
  var = x
  while True:
    for _ in range(2,var):
      if var%_ != 0:
        ind = True
      else:
        ind = False
        break
    if ind == True:
      break  
    else:
      var+=1  
  print(var)
      

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

int main(){
  long long n,wt,sum=0;
  cin>>n>>wt;
  vector<long long> v(n+1),w(n+1);
 
  for(long long i=1;i<=n;i++){
      cin>>w[i]>>v[i];
      sum+=v[i];
  }
  vector<long long> dp(sum+1,INT_MAX);
  dp[0]=0;
  for(long long i=1;i<=n;i++){
      for(long long j=sum;j>=v[i];j--){
          dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
      }
  }
  int ans=0;
  for(int i=sum;i>=1;i--)
        if(dp[i]<=wt)
        {
            ans=i;
            break;
        }
  cout<<ans;

}

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

import fractions

A, B, K = (int(i) for i in input().split())

gcd_num = fractions.gcd(A, B)

if K==1:
    print(gcd_num)
    exit()

yakusuu_array = []
for i in range(1,gcd_num):
    if gcd_num % i == 0:
        yakusuu_array.append(i)
        yakusuu_array.sort(reverse=True)

print(yakusuu_array[K-2])

Measured memory_bytes: 5344
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,i,x,y,zz[100005],zhan1[100005],zhan2[100005],head,tail,p;
set<int> s[100005],t[100005];
set<int> :: iterator it;
map<pair<int,int>,int> mp;
int zzz(int z){
	if(zz[z]==z) return z;
	return zz[z]=zzz(zz[z]);
}
int main(){
	n=read();
	for(i=1;i<=n;i++)
		zz[i]=i;
	for(i=1;i<n;i++){
		x=read();y=read();
		s[x].insert(y);
		s[y].insert(x);
		mp[make_pair(x,y)]++;
		mp[make_pair(y,x)]++;
	}
	head=1;
	for(i=1;i<n;i++){
		x=read();y=read();
		t[x].insert(y);
		t[y].insert(x);
		mp[make_pair(x,y)]++;
		mp[make_pair(y,x)]++;
		if(mp[make_pair(x,y)]==2){
			tail++;
			zhan1[tail]=x;
			zhan2[tail]=y;
			mp[make_pair(x,y)]=0;
			mp[make_pair(y,x)]=0;
			s[x].erase(y);
			s[y].erase(x);
			t[x].erase(y);
			t[y].erase(x);
		}
	}
	while(head<=tail){
		x=zzz(zhan1[head]);
		y=zzz(zhan2[head]);
		if(s[x].size()+t[x].size()>s[y].size()+t[y].size())
			swap(x,y);
		zz[x]=y;
		for(it=s[x].begin();it!=s[x].end();it++){
			s[y].insert(*it);
			s[*it].insert(y);
			s[*it].erase(x);
			mp[make_pair(y,*it)]++;
			mp[make_pair(*it,y)]++;
		}
		for(it=t[x].begin();it!=t[x].end();it++){
			t[y].insert(*it);
			t[*it].insert(y);
			t[*it].erase(x);
			mp[make_pair(y,*it)]++;
			mp[make_pair(*it,y)]++;
		}
		for(it=s[x].begin();it!=s[x].end();it++){
			if(mp[make_pair(y,*it)]==2){
				tail++;
				zhan1[tail]=y;
				zhan2[tail]=(*it);
				mp[make_pair(y,*it)]=0;
				mp[make_pair(*it,y)]=0;
				s[y].erase(*it);
				s[*it].erase(y);
				t[y].erase(*it);
				t[*it].erase(y);
			}
		}
		for(it=t[x].begin();it!=t[x].end();it++){
			if(mp[make_pair(y,*it)]==2){
				tail++;
				zhan1[tail]=y;
				zhan2[tail]=(*it);
				mp[make_pair(y,*it)]=0;
				mp[make_pair(*it,y)]=0;
				s[y].erase(*it);
				s[*it].erase(y);
				t[y].erase(*it);
				t[*it].erase(y);
			}
		}
		s[x].clear();
		t[x].clear();
		head++;
	}
	if(tail==n-1)
		printf("YES\n");
	else
		printf("NO\n");
   	return 0;
}

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

#define ll long long
#define mx  300005
#define mod 1000000009
#define lim 10000000
#define N 18
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;cin>>n;
	int a[n+5];

	for(int i=1;i<=n;i++)cin>>a[i];

	int i,j,bit;
	ll ans=0;
	i=j=1,bit=0;

	while(i<=j)
	{
		while(j<=n && !(bit & a[j]))
		{
			bit |=a[j];
			j++;
		}
		ans+=(j-i);
		bit^=a[i];
		i++;
	}

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


Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{int x=1,i=0;
 char s[3];
 scanf("%s",s);
 for(i;i<=2;i++)
 {if(s[i]=='a'){x*=1;}
  else if(s[i]=='b'){x*=2;}
  else{x*=3;}
 }
 if(x==6){printf("Yes");}
 else{printf("No");}
  return 0;
 }

Measured memory_bytes: 128
move = [[1,4],[0,2,5],[1,3,6],[2,7],[0,5],[4,1,6],[5,2,7],[6,3]]

ans = {"01234567":0}
que = [["01234567",0]]
while que:
    pzl,count = que.pop(0)
    p = pzl.find("0")
    for q in move[p]:
        a,b = min(p,q),max(p,q)
        tmp = pzl[:a]+pzl[b]+pzl[a+1:b]+pzl[a]+pzl[b+1:]
        if tmp not in ans:
            ans[tmp] = count+1
            que.append([tmp,count+1])

while 1:
    try:
        print ans[raw_input().replace(" ","")]
    except:
        break

Measured memory_bytes: 6160
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll n;
    cin >> n;
    ll a[n], b[n];
    rep(i, n) {
        cin >> a[i]; b[i]  = a[i];
    }

    sort(a, a+n);
    ll k1 = a[n/2], k2 = a[n/2-1];
    rep(i, n)
    {
        if(b[i] <= k2) cout << k1 << " ";
        else cout << k2 << " ";
    }

}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main(){
  int r, D;
  vector<int> x(11);
  
  cin >> r >> D >> x.at(0);
  
  for(int i=0;i<10;i++){
    x.at(i+1) = r*x.at(i)-D;
    cout << x.at(i+1) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fun(long long int n)
{
    if(n<0)
        return -n;
    else
        return n;
}
int main()
{
    long long int n;
    while(scanf("%lld",&n)==1)
    {
        if(n%2==0)
            printf("%lld\n",n);
        else
            printf("%lld\n",2*n);
    }
    return 0;
}


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


int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll i=0;i<N;i++){
        ll sub1;
        cin >> sub1;
        A[i]=sub1;
        
        
    }
    ll count=0;
    for(ll i=0;i<N-2;i++){
        for(ll j=i+1;j<N-1;j++){
            
            for(ll k=j+1;k<N;k++){
                
                if(A[i]==A[j])continue;
                if(A[i]==A[k])continue;
                if(A[j]==A[k])continue;
                if(A[i]+A[j]>A[k]&&A[j]+A[k]>A[i]&&A[k]+A[i]>A[j])count++;
                
            }
            
        }
        
        
    }
    cout << count << endl;
    
    //for(ll i:B)cout << i << endl;
    
}

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

int main(){
  int stu[5];
  int ava;
  for(int i=0;i<5;i++){
    cin >> stu[i];
    if(stu[i] < 40){
      stu[i] = 40;
    }
    ava += stu[i];
  }
  ava = ava / 5;
  cout << ava << endl;
}

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

typedef long long ll;
using namespace std;

int main() {
  int K, S;
  cin >> K >> S;
  ll ans = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      if (S - X - Y >= 0 && S - X - Y <= K) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())

if a<=b<=c:
  print(a,b,c)
elif b<=c<=a:
  print(b,c,a)
elif c<=a<=b:
  print(c,a,b)
elif a<=c<=b:
  print(a,c,b)
elif c<=b<=a:
  print(c,b,a)
elif b<=a<=c:
  print(b,a,c)


Measured memory_bytes: 5592
package main

import (
	"fmt"
)

const (
	mod = 1000000007
)

var comb [][]int


func main() {
	var n int
	var k int

	fmt.Scan(&n)
	fmt.Scan(&k)

	buildComb(2000)

	for i := 0; i < k; i++ {
		fmt.Println(solve(n, k, i))
	}
}

func solve(n int, k int, i int) int {
	if i > n - k {
		return 0
	}

	a := comb[k - 1][i]
	b := comb[n - k + 1][i + 1]

	return (a * b) % mod
}


func buildComb(m int) {
	comb = make([][]int, m + 1)

	for i := 0; i <= m; i++ {
		comb[i] = make([]int, i + 1)

		for j := 0; j <= i; j++ {
			if j == 0 || j == i {
				comb[i][j] = 1
			} else {
				comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % mod
			}
		}
	}
}

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

Measured memory_bytes: 18304