akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
template <class T> void chmax(T& a, const T b) { a = max<T>(a, b); }
template <class T> void chmin(T& a, const T b) { a = min<T>(a, b); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int N; cin >> N;
	V<ll> C(N);
	REP(i, N) cin >> C[i];
	V<int> idx(200001, -1);
	V<ll> dp(N,0);
	dp[0] = 1;
	idx[C[0]] = 0;
	for(int i = 1; i < N; ++i){
			
		if(idx[C[i]]==-1 || idx[C[i]] == i - 1){
			(dp[i] += dp[i - 1]) %= MOD;
		}
		else{
			(dp[i] += (dp[i - 1] + dp[idx[C[i]]]) %MOD ) %= MOD;
		}
		idx[C[i]] = i;
	}
	cout << dp[N - 1] << endl;

	return 0;
}



Measured memory_bytes: 4096
#include <stdio.h>

int main()
{
  int n, a[100][100], i, j, s, k, l;
  
  scanf("%d", &n);
  for( i = 0; i < n; i++ ){
    for( j = 0; j < n; j++){
      a[i][j] = 0;
    }
  }
  
  for( i = 0; i < n; i++ ){
    scanf("%d", &k);
    scanf("%d", &l);
    for( j = 0; j < l; j++ ){
      scanf("%d", &s);
      a[k - 1][s - 1] = 1;
    }
  }
  
  for( i = 0; i < n; i++){
    for( j = 0; j < n - 1; j++){
      printf("%d ", a[i][j]);
    }
    printf("%d\n", a[i][j]);
  }
  
  return 0;
}

Measured memory_bytes: 632
a = list(map(int,input().split()))
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
n = int(input())

ins = []
for i in range(n):
    b = int(input())
    if b in a:
        ins.append(a.index(b))

okp = [(0,1,2), (3,4,5), (6,7,8) ,(0,3,6), (1,4,7), (2,5 ,8), (0,4,8), (2,4,6)]
f = "No"
for x, y, z in okp:
    if x in ins and y in ins and z in ins:
        f = "Yes"
        break

print(f)



    

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

void input(std::string& str);
bool find_pattern(std::string s, std::string p);
void output(bool find);

int main()
{
	std::string shaped_text;
	std::string pattern;

	input(shaped_text);
	input(pattern);

	bool ans = find_pattern(shaped_text, pattern);
	output(ans);
}

void input(std::string& str)
{
	std::cin >> str;
}


bool find_pattern(std::string s, std::string p)
{
	bool find = false;
	size_t size = s.size();
	for (int i = 0; i < size; ++i)
	{
		if (s.find(p)!=std::string::npos)
		{
			return true;
		}
		else
		{
			s += s[i];
		}
	}
	return find;
}

void output(bool find)
{	
	std::string ans = find == true ? "Yes" : "No";
	std::cout << ans << std::endl;
}




Measured memory_bytes: 3192
import math
N = int(input())

list = []


while(N%2==0):
  list.append(2)
  N = N//2
  
f = 3

while(f*f <= N):
  if(N%f==0):
    list.append(f)
    N = N // f
  else:
    f += 2
if(N!=1):
  list.append(N)
count = 0
while(len(list)>0):
  k=0
  #mu = []
  max_num = list.count(list[0])
  num = 1
  while(num <= max_num):
    count += 1
    max_num -= num
    num += 1
  for i in range(list.count(list[k])):
    list.remove(list[k])
  
print(count)

Measured memory_bytes: 9224
#include "bits/stdc++.h"

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

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;

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

    int n;
    cin >> n;

    string s = to_string(n);
    string sn = s;

    reverse(sn.begin(), sn.end());

    if (s == sn)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main(){
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	N, C, K :=  nextInt(), nextInt(), nextInt()
	T := nextInts(N)
	sort.Ints(T)
	ans := 1
	passenger := 1
	limit := T[0]+K
	for i:=1; i<N; i++{
		if limit < T[i] || passenger == C{
			ans++
			passenger = 1
			limit = T[i]+K
		}else{
			passenger++
		}
	}
	fmt.Fprintln(out, ans)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int{
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

Measured memory_bytes: 5188
#include<iostream>
#include<string>
#include<vector>


using namespace std;

int main(void) {

	int n;//要素数

	cin >> n;

	vector<string> words(n);

	for (int i = 0; i < n; ++i) {

		cin >> words[i];
	}

	bool isCorrect = true;

	//同じ発言があるかどうか
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {

			if (words[i] == words[j]) {

				isCorrect = false;
				break;
			}

			if (!isCorrect) {
				break;
			}
		}
	}

	//言葉がつながっているかどうか
	for (int i = 0; i < n - 1; i++) {

		if (words[i].back() != words[i + 1].front()) {
			isCorrect = false;
		}

		if (!isCorrect) {
			break;
		}
	}

	if (isCorrect) {

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

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x[2]={},a;
	for(int i=0;i<2;i++){
		for(int j=0;j<4;j++){
			cin>>a;
			x[i]+=a;
		}
	}
	cout<<max(x[0],x[1])<<endl;
return 0;
}

Measured memory_bytes: 1160
def read():
    S = input().strip()
    return S, 

def solve(S):
    mid = len(S) // 2
    count = 0
    for i in range(mid):
        if S[i] != S[len(S) - i - 1]:
            count += 1
    return count


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    vi v(n);
    rep(i,n) v[--a[i]] = i;
    ll ans = 0;
    set<int> st;
    rep2(i,-1,n+1) st.insert(i);
    rrep(i,n) {
        int pos = v[i];
        st.erase(pos);
        auto r = st.lower_bound(pos);
        auto l = r;
        l--;
        ans += (ll)(i+1)*(pos-*l)*(*r-pos);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14112
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	const int MAX_N = 10;
	char s[MAX_N];
	int h=0;
	int max_h=0;
	std::cin >> s;
	for (int i = 0; i < 10; i++) {
		if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T') {
			h++;
			max_h = max(max_h, h);
		}
		else {
			h = 0;
			max_h = max(max_h, h);
		}
	}
	cout << max_h;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    char s;
    cin >> s;
    if(s=='T'){
        s = 'A';
    }else if(s == 'A'){
        s = 'T';
    }else if(s == 'G'){
        s = 'C';
    }else{
        s = 'G';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ld long double
#define input for(int i = 0; i < n; ++i) cin >> a[i]
#define output for(int i = 0; i < n; ++i) cout << a[i] << " "
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pll pair<long long ,long long >
#define ppll pair < pll , pll >
ll dp[101][100001];
ll knapsack(ll n, ll w, ll weight[], ll value[]){
    if(w == 0 || n == 0) return 0;
    if(dp[n][w] != -1) return dp[n][w];
    if(weight[n - 1] <= w){
        return dp[n][w] = max(value[n - 1] + knapsack(n - 1, w - weight[n - 1], weight, value), knapsack(n - 1, w, weight, value));
    }
    else if(weight[n - 1] > w){
        return dp[n][w] = knapsack(n - 1, w, weight, value);
    }
}     
int main(){
    SPEED;
    ll n, w;
    cin >> n >> w;
    ll wt[n], val[n];
    for(ll i = 0; i < n; ++i){
        cin >> wt[i] >> val[i];
    }
    memset(dp, -1, sizeof(dp));
    knapsack(n,w, wt, val);
    cout << dp[n][w];

}

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

int main()
{
    string n;
    cin >> n;

    if(n == "A")
    {
        cout << "T" << endl;    
    }

    if(n == "T")
    {
        cout << "A" << endl;    
    }

    if(n == "C")
    {
        cout << "G" << endl;    
    }

    if(n == "G")
    {
        cout << "C" << endl;    
    }

    return 0;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(){
    int n,k;cin>>n>>k;
    int a[200001]={0};
    vector<int>v;
    rep(i,n){int tmp;cin>>tmp;a[tmp]++;}
    rep(i,200001){
        if(a[i]!=0)v.push_back(a[i]);
    }
    sort(v.begin(),v.end(),greater<int>());
    if(v.size()<=k){co(0);return 0;}
    ll ans = 0;
    while(v.size()>k){
        ans+=v.back();
        v.pop_back();
    }
    co(ans);
}

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

int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<pair<int, int>> lines(M);
    for (int i = 0; i < M; i++) cin >> lines[i].first >> lines[i].second;
    vector<vector<int>> numlines(N+1, vector<int>(N+1, 0));
    for (int i = 0; i < M; i++) numlines[lines[i].first][lines[i].second]++;
    vector<vector<int>> ans(N+1, vector<int>(N+1, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= N-i; j++) {
            if (i == 0) ans[j][j] = numlines[j][j];
            else ans[j][j+i] = ans[j][j+i-1] + ans[j+1][j+i] + numlines[j][j+i] - ans[j+1][j+i-1];
        }
    }
    while (Q--) {
        int p, q; cin >> p >> q;
        printf("%d\n", ans[p][q]);
    }
}


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

int main() {
  vector<vector<int>> mycard(3, vector<int> (3));
  rep(i, 3) {
    rep(j, 3) cin >> mycard[i][j];
  }
  
  int n;
  cin >> n;
  
  vector<vector<bool>> myopen(3, vector<bool> (3));
  vector<int> b(n);
  
  rep(i, n) cin >> b[i];
  
  rep(i, n) {
    rep(j, 3) {
      rep(k, 3) {
        if(mycard[j][k] == b[i]) myopen[j][k] = true;
      }
    }
  }
  
  
  //たて
  rep(i, 3) {
    if(myopen[0][i] && myopen[1][i] && myopen[2][i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  //よこ
  rep(i, 3) {
    if(myopen[i][0] && myopen[i][1] && myopen[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  //ななめ
  if((myopen[0][0] && myopen[1][1] && myopen[2][2]) || 
     (myopen[2][0] && myopen[1][1] && myopen[2][0])) {
    cout << "Yes" << endl;
    return 0;
  }
  
  
  cout << "No" << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <limits.h>
using namespace std;

typedef long long ll;

//半開区間なことに注意
//L<=P<R
template <typename Monoid>
class SegmentTree{
public:
    //コンストラクタ n:サイズ pr:初期値
    SegmentTree(ll n,Monoid pr){
        size = pow(2,ceil(log2(n)));
        vec.resize(2*size-1,pr);
    }

    //値の更新　pos:位置(0-indexed) v:更新後の値
    void Update(ll pos,Monoid v){
        ll index = size-1+pos;
        vec[index] = v;
        //上方向に更新
        while(index>0){
            index = (index-1)/2;
            //更新方法
            /*RMQ*/vec[index] = min(vec[index*2+1],vec[index*2+2]);
            /*RSQvec[index] = vec[index*2+1]+vec[index*2+2]*/
        }
    }

    //クエリの処理 L:区間左端 R:区間右端 index:添字(0)
    //begin:ノード左端(0) end:ノード右端(n)
    Monoid Query(ll L,ll R,ll index,ll begin,ll end){
        if (end<=L || R<=begin) {
            //区間に重ならない
            return LONG_MAX;
        }
        if (L<=begin && end<=R){
            //完全に含む
            return vec[index];
        }
        Monoid retL = Query(L,R,index*2+1,begin,(begin+end)/2);
        Monoid retR = Query(L,R,index*2+2,(begin+end)/2,end);
        return min(retL,retR);
    }

    //L<=P<R
    Monoid Query(ll L,ll R){
        return Query(L,R,0,0,size);
    }

private:
    vector<Monoid> vec;
    ll size;
};


int main(){
    int n,q;
    cin >> n>>q;
    SegmentTree<ll> ST(n,pow(2,31)-1);
    for(int i=0;i<q;i++){
        ll com,x,y;
        cin >>com>>x>>y;
        if (com==0){
            ST.Update(x,y);
        }else {
            cout << ST.Query(x,y+1)<<endl;
        }
    }
    return 0;
}


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

public class Main {
	private static void solve(){
	//Implement solution here.
		String s = next();
		int n = s.length();
		int c0 = 0;
		int c1 = 0;
		char[] ca = s.toCharArray();
		for(char c : ca){
			if(c == '0'){
				c0++;
			}else{
				c1++;
			}
		}
		System.out.println(n - Math.abs(c0 - c1));
	}

    //Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
                scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 28232
#include<bits/stdc++.h>
#include<vector>
#include<iterator>
using namespace std;
int main()
{

  int n,q,index,value,order;
  cin>>n>>q;
  vector<int>v[n];
  while(q--){

      cin>>order>>index;

  switch(order){

  case 0:
              cin>>value;
              v[index].push_back(value);
              break;

case 1:
            if(v[index].size()==0){
              cout<<endl;
            break;}
            cout<<v[index][0];
            for(int j=1; j< v[index].size();j++){
              cout<<" "<<v[index][j];
            }
            cout<<endl;
            break;
case 2:
            v[index].clear();
            break;

}

  }
 return 0;
}



Measured memory_bytes: 5844
#include"bits/stdc++.h"
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    int max_index = max_element(A.begin(), A.end()) - A.begin();

    cout << A[max_index] + B[max_index] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int MAXN = 10 + 1e6;
const ll oo = 1 + 1e18;
const ll mod = 7 + 1e9;

int n;
int a[MAXN], b[MAXN];

int main()
{
    #define TASK "ABC"
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
    #endif ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;

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

    sort (a + 1, a + 1 + n), sort (b + 1, b + 1 + n);

    if (n % 2)
    {
        int le = a[ (n + 1) / 2 ], ri = b[ (n + 1) / 2 ];
        cout << ri - le + 1;
    }

    else
    {
        int le = (a[ n / 2 ] + a[ n / 2 + 1 ]);
        int ri = (b[ n / 2 ] + b[ n / 2 + 1 ]);
        cout << ri - le + 1;
    }

    return 0;
}




















































































Measured memory_bytes: 5192
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:dp[i]=0
print(dp[n])

Measured memory_bytes: 13192
from collections import defaultdict

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    
    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x

        return True
    
    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.parents[self.root(x)]
    
    def members(self, x):
        x_root = self.root(x)
        return [i for i in range(self.n) if self.root(i) == x_root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())

def main():
    N, K, L = map(int, input().split())
    uf_road = UnionFind(N)
    uf_railway = UnionFind(N)
    pq = [tuple(map(int, input().split())) for i in range(K)]
    for p, q in pq:
        uf_road.unite(p-1, q-1)
    rs = [tuple(map(int, input().split())) for i in range(L)]
    for r, s in rs:
        uf_railway.unite(r-1, s-1)
    
    d = defaultdict(int)
    for i in range(N):
        d[(uf_road.root(i), uf_railway.root(i))] += 1
    
    for i in range(N):
        print(d[(uf_road.root(i), uf_railway.root(i))])
    
if __name__ == "__main__":
    main()

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

int main(void){
	int n, b, f, r, v;
	int inhabitant[4][3][10] = {0};

	cin >> n;

	for (int i = 0; i < n;i++){
		cin >> b >> f >> r >> v;

		inhabitant[b-1][f-1][r-1] += v;
	}

	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				cout << " " << inhabitant[i][j][k];
			}
			cout << "\n";
		}
		if (i != 3){
			for (int m = 0; m < 20; m++){
				cout << "#";
			}
			cout << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1160
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll a,b,t;
    std::cin >> a>>b>>t;
    std::cout << (t/a)*b << std::endl;
}

Measured memory_bytes: 764
n = gets.to_i

codes = {}

def nc2(n)
  n * (n - 1) / 2
end


res = 0

n.times do
  s = gets.chomp
  code = s.chars.sort.join. to_sym
  if codes.has_key?(code)
    codes[code] += 1
  else
    codes[code] = 1
  end
end

codes.each_value { |i| res += nc2(i) }
puts res

Measured memory_bytes: 36476
# include <cstdio>
bool f [100001];
int c [100002];
int N ,L , R ;
int main ()
{
    for ( int i =2; i <=100000; i ++) if (! f [ i ]) for ( int j = i + i ;j <=100000; j += i )
                f[ j ]= true ;
    for ( int i =3; i <=100000; i +=2) if (! f [ i ]&&! f [( i +1)/2]) c [ i ]++;
    for ( int i =3; i <=100000; i ++) c [ i ]+= c [i -1];
    scanf ("%d" ,& N );
    while (N-->0)
    {
        scanf ("%d%d",&L,&R);
        printf ("%d\n",c[R]-c[L-1]);
    }
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	private static String w;
	private static void input() {
		Scanner sc = new Scanner(System.in);
		w = sc.next();
	}

	public static void main(String[] args) {
		input();
		char[] alphabet = new char[26];
		String str = "abcdefghijklmnopqrstuvwxyz";
		for(int i = 0; i < 26; i++)
			alphabet[i] = str.charAt(i);
		int[] counter = new int[26];
		for(int i = 0; i < w.length(); i++) {
			for(int j = 0; j < 26; j++) {
				if(w.charAt(i) == alphabet[j])
					counter[j]++;
			}
		}
		boolean beautiful = true;
		for(int i = 0; i < 26; i++)
			beautiful = beautiful && (counter[i]%2 == 0);
		System.out.println(beautiful ? "Yes" : "No");
	}
}

Measured memory_bytes: 25044
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    double a, b, c, d, e, f;
    double x, y;
    while( cin >> a >> b >> c >> d >> e >> f ){
        x = ( c*e - b*f )/( a*e - b*d);
        y = ( c*d - a*f )/( b*d - a*e );

        x = x + ( 0.5 - ( x < 0 ) )/1000;
        y = y + ( 0.5 - ( y < 0 ) )/1000;
        x = int( x * 1000 );
        y = int( y * 1000 );
        if(x != 0) x /= 1000;
        if(y != 0) y /= 1000;

        cout << fixed << setprecision(3)
             << x << ' ' << y
             << endl;
    }
    return 0;
}

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

int main ()
{
  int n, m, a, b; cin >> n >> m;
  
  map<int,int>mymap;
  
  for (int i=0; i<m; i++)
  {
    cin >> a >> b;
    mymap[a]++;
    mymap[b]++;
  }
  for (int i=1; i<=n; i++)
  {
    cout << mymap[i] << endl;
  }
  
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int D;
int C[26];
int S[400][26];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>D;
	FOR(i,26) cin>>C[i];
	FOR(i,D) {
		FOR(j,26) cin>>S[i][j];
		cout<<1<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3700
// #include <bits/stdc++.h>
#include <iostream>
#include <ctime>

using namespace std;
using ll = long long;

void print(char c) {
    putchar(c);
    putchar('\n');
}

void solve() {
    char b;
    cin >> b;

    b == 'A' || b == 'T' ? b == 'A' ? print('T'):print('A'):b == 'C' ? print('G'):print('C');
}

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

#ifndef ONLINE_JUDGE
    double st = clock();
#endif

    solve();

#ifndef ONLINE_JUDGE
    // cerr <<"\ntime = " <<  (clock() - st)/CLOCKS_PER_SEC << endl;
#endif 
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import fractions

gcd_ufunc = np.frompyfunc(fractions.gcd, 2, 1)

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

G = gcd_ufunc.accumulate(A, dtype=np.object).astype(np.int)[-1]
M = max(A)

if K % G == 0 and K <= M:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


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

//Range Update Query+Range Minimum Query
template<class T>
class RUQ_RMQ {
public:
	int n;
	T dat[MAX], lazy[MAX], DEFAULT;
	bool(*cmp)(T, T);
	void init(int n_,
		bool(*c)(T, T) = [](int a, int b) {return a < b; }, T d = INT_MAX) {
		cmp = c;
		DEFAULT = d;
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = lazy[i] = DEFAULT;
		}
	}
	inline void push(int k) {
		if (lazy[k] == DEFAULT)return;
		dat[k] = lazy[k];
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k];
			lazy[k * 2 + 2] = lazy[k];
		}
		lazy[k] = DEFAULT;
	}
	inline void update_node(int k) {
		if (cmp(dat[k * 2 + 1], dat[k * 2 + 2]))dat[k] = dat[k * 2 + 1];
		else dat[k] = dat[k * 2 + 2];
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = x; push(k); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return DEFAULT;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		if (cmp(lb, rb))return lb;
		return rb;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};
RUQ_RMQ<int>seg;
int main() {
	int n, q; scanf("%d%d", &n, &q);
	seg.init(n);
	rep(i, q) {
		int a, s, t; scanf("%d%d%d", &a, &s, &t); t++;
		if (a == 0) {
			int x; scanf("%d", &x);
			seg.update(s, t, x);
		}
		else {
			printf("%d\n", seg.query(s, t));
		}
	}
}

Measured memory_bytes: 5292
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int c = a - (2 * b);
  int ans = c > 0 ? c : 0;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
const int maxn=1e5+5;
int main()
{
    int n,w=0;
    scanf("%d",&n);
    string s;
    cin>>s;
    for(auto c: s)
        if(c=='.') w++;
    int m=w;
    for(auto c:s)
    {
        if(c=='#') w++;
        else w--;
        if(m>w) m=w;
    }
    printf("%d\n",m);
}


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.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 nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int H, W, N; cin >> H >> W >> N;
  int M = max(H, W);

  int ans = N / M;
  if (N % M != 0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ans =""
for i in range(len(S)):
    for j in range(len(alp)):
        if S[i] == alp[j]:
            if j+N >= 26:
                ans += alp[j+N-26]
            else:
                ans += alp[j+N]
print(ans)

Measured memory_bytes: 3060
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

const int MAX_N = 100;
int n;
string a,b;

void input() {
    RI(n);
    cin >> a >> b;
}

void solve() {
    int n = a.length(), m = b.length();
    for(int i = 0; i < n; i++) {
        int l = n-i;
        if(a.substr(i, l) == b.substr(0, l)) {
            printf("%d\n", n+m-l);
            return;
        }
    }

    printf("%d\n", n+m);
}

int main( int argc, char *argv[] ) {
    input(); 
    solve(); 
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1 << 30;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int h, n; cin >> h >> n;
    VI a(n), b(n);
    FOR(i, 0, n)cin >> a[i] >> b[i];

    VI dp(h + 1, INF);
    dp[0] = 0;
    FOR(i, 0, h)FOR(j, 0, n) {
        chmin(dp[min(i + a[j], h)], dp[i] + b[j]);
    }

    cout << dp[h] << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

import static java.lang.System.in;

public class Main {
    final static int MOD  =1000000007;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(in);
        String[] str = scanner.nextLine().split(" ");
        int n = Integer.valueOf(str[0]);
        int m = Integer.valueOf(str[1]);
        char[][] grid = new char[n][m];
        for (int i = 0; i < n; i++) {
            grid[i] = scanner.nextLine().toCharArray();
        }
        int[][] dp = new int[n+1][m+1];
        for(int i=n-1 ;i>=0 ; i--){
            for (int j=m-1;j>=0;j--) {
                if(i==n-1 && j==m-1)
                    dp[i][j] = 1;
                else if (grid[i][j] == '#')
                    dp[i][j] = 0;
                else
                    dp[i][j] = ((dp[i+1][j]%MOD) + (dp[i][j+1]%MOD))%MOD;
            }
        }
        System.out.println(dp[0][0]);
    }
}

Measured memory_bytes: 52252
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int sw[333333];
  int se[333333];
  int suw=0,sue=0;
  for(int i=0;i<s.size();i++){
    s[i]=='W'?suw++:sue++;
    sw[i]=suw;
    se[i]=sue;
  }
  int ans=333333;
  for(int i=0;i<s.size();i++){
    int t=sw[i]+sue-se[i];
    if(s[i]=='W')t--;
    ans=min(ans,t);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3204
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int now = n;
        ArrayDeque<Integer> dq = new ArrayDeque<>();
        while(now > 0){
            boolean dice = false;
            for(int i = m; i >= 1; i--){
                if(now-i < 0 || s[now-i] == '1'){
                    continue;
                }
                dq.addFirst(i);
                dice = true;
                now -= i;
                break;
            }
            if(!dice){
                System.out.println(-1);
                return;
            }
        }
        StringBuilder sb = new StringBuilder();
        while(dq.size() > 0){
            sb.append(dq.poll() + " ");
        }
        System.out.println(sb.toString().trim());
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

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

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


Measured memory_bytes: 44812
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a < 1 || a > 9 || b < 1 || b > 9) {
            System.out.println(-1);
        }
        else {
            System.out.println(a * b);
        }
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
int parent[25];
vector<int> g[25];

void preorder(int curr) {
  printf(" %d", curr);
  if (g[curr][0] != -1) preorder(g[curr][0]);
  if (g[curr][1] != -1) preorder(g[curr][1]);
}

void inorder(int curr) {
  if (g[curr][0] != -1) inorder(g[curr][0]);
  printf(" %d", curr);
  if (g[curr][1] != -1) inorder(g[curr][1]);
}

void postorder(int curr) {
  if (g[curr][0] != -1) postorder(g[curr][0]);
  if (g[curr][1] != -1) postorder(g[curr][1]);
  printf(" %d", curr);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  fill_n((int*)parent, 25, -1);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int id, l, r;
    cin >> id >> l >> r;
    g[id].emplace_back(l);
    g[id].emplace_back(r);
    if (l != -1) parent[l] = id;
    if (r != -1) parent[r] = id;
  }
  int root = 0;
  while (parent[root] != -1) root = parent[root];
  puts("Preorder");
  preorder(root);
  puts("");
  puts("Inorder");
  inorder(root);
  puts("");  
  puts("Postorder");
  postorder(root);
  puts("");  

  return 0;
}


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

int main() {
	int a[10];
	for(int i=0;i<10;i++){
		cin >> a[i];
	}
	for(int i=1;i<10;i++)
		for(int j=0;j<i;j++){
			if(a[i]<a[j]){
				swap(a[i],a[j]);
			}
		}
		for(int k=9;k>=7;k--)	
			cout << a[k] << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, a = 0, b = 0;
	string s, k = "keyence";
	cin >> s;
	rep(i, 7) {
		if (s[i] != k[i])
			break;
		a++;
	}
	rep(i, 7) {
		if (s[s.size() - 1 - i] != k[6 - i])
			break;
		b++;
	}
	if (a + b >= 7)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inrange(a, x, b) (a <= x && x <= b)
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print(T x,bool cl=1){cout<<(cl?"\x1b[36m":"")<<x<<(cl?"\x1b[39m":"")<<'\n';}
template<class T> void print1d(T x,ll n=-1,bool cl=true){if(n==-1)n=x.size();rep(i,0,n){cout<<(cl?"\x1b[36m":"")<<x[i]<<(i==n-1?'\n':' ');}cout<<(cl?"\x1b[39m":"");}
template<class T> void print2d(T x,ll r=-1,ll c=-1,bool cl=1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c,cl);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



int main()
{
        ll N;
        cin >> N;
        vll a(N), b(N);
        rep(i, 0, N) cin >> a[i] >> b[i];

        rep(i, 0, N-2) {
                bool f1 = a[i] == b[i];
                bool f2 = a[i+1] == b[i+1];
                bool f3 = a[i+2] == b[i+2];
                if (f1 and f2 and f3) {
                        cout << "Yes" << endl;
                        return 0;
                }
        }
        cout << "No" << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N =in.nextInt();
		int[] t = new int[N+1];
		int[] x = new int[N+1];
		int[] y = new int[N+1];
		t[0]=0;
		x[0]=0;
		y[0]=0;
		for(int i=1;i<=N;i++) {
			t[i]=in.nextInt();
			x[i]=in.nextInt();
			y[i]=in.nextInt();
		}
		Boolean flag = true;
		for(int i=0;i<N;i++) {
			int dif = Math.abs(x[i+1]-x[i])+Math.abs(y[i+1]-y[i]);
			int diftime=t[i+1]-t[i];
			if((dif%2)==(diftime%2)&&diftime>=dif) {
				flag = true;
			}else {
				flag =false;
			}
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");		
		}
		
	}

}


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

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

  int a[200100][30] = {};
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    for (int bit = 0; bit < 30; bit++) {
      a[i][bit] = (num % 2);
      num /= 2;
    }
  }

  long ans = 0;
  int s[30] = {};
  int count = 1;
  int index = 0;
  for (int i = 0; i < n; i++) {
    int flag = 1;
    for (int j = 0; j < 30; j++) {
      s[j] += a[i][j];
      if (s[j] > 1) flag = 0;
    }
    if (flag == 1) {
      ans += count;
      count++;
    } else {
      int Flag = 0;
      while (Flag == 0) {
        Flag = 1;
        for (int j = 0; j < 30; j++) {
          s[j] -= a[index][j];
          if (s[j] > 1) Flag = 0;
        }
        index++;
        count--;
      }
      ans += count;
      count++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 23680