akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
  	for(int i = 1;i <= x; i++){
  		if(i%3 == 0){
  			System.out.print(" "+i);
  		}else if(Integer.toString(i).contains("3")){
  			System.out.print(" "+i);
  		}
  	}
  	System.out.println("");
  }
}


Measured memory_bytes: 28968
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

#define ECHO(v) cout << v << endl;

int main(void){
    ll n, s;
    cin >> n;
    cout << (n * (n+1)/2) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int dat[401];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 200; i++) {
		for (int j = 1; i * j <= 200; j++) {
			dat[i * j]++;
		}
	}
	int count = 0;
	for (int i = 1; i <= n; i+=2)if (dat[i] == 8)count++;
	cout << count << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string answer;
  for(int i = 0;i < s.size();i++){
    if(s[i] == '0'){
      answer += "0";
    }else if(s[i] == '1'){
      answer += "1";
    }else if(s[i] == 'B'){
      int a = answer.size();
      if(a == 0) a = 1;
      answer.erase(a-1);
    }
  }
  cout << answer << endl;
}


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

int main(){
	int n;
	cin >> n;
	
	map<string, long long> m;
	for(int i = 0;i < n;++i){
		string str;
		cin >> str;
		sort(str.begin(), str.end());
		m[str]++;
	}
	
	long long ans = 0;
	for(pair<string, long long> e : m)
		ans += ((e.second * (e.second-1)) / 2);
	cout << ans;
}


Measured memory_bytes: 11380
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        int a = -1;
        int b = -1;
        int c = -1;
        for (int i = 0; i <= n; i++) {
            for (int j = 0; i + j <= n; j++) {
                int k = n - i - j;
                if (y == (10000*i + 5000*j + 1000*k)) {
                    a = i;
                    b = j;
                    c = k;
                }
            }
        }
        System.out.println(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)
typedef long long ll;
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string a,b,c;
	int vis=0;
	cin>>a>>b;
	int len=a.length(),len1=b.length(),maxx=0,cnt=0,start=-1,end=-1;
	for(int i=0;i<=len;i++){
		if(a[i]=='?')
			cnt++;
		else {
			if(cnt>=len){
				start=i-len1;
				end=i-1;
				vis=1;
			}
			cnt=0;
		}
	}
	if(cnt>=len){
		end=len-1;
		start=len-len1-2;
	}
	if(start==-1){
		for(int i=0;i<len;i++){
			vis=0;
			if(len1+i>len)break;
			for(int j=i;j<len1+i;j++){
				if(a[j]!='?'&&a[j]!=b[j-i]){
					vis=1;
					break;
				}
			}
			if(vis==0){
				start=i;
				end=len1+i-1;
			}
		}
		if(start==-1)
			cout<<"UNRESTORABLE";
		else {
			for(int i=0;i<start;i++){
				if(a[i]=='?')c[i]='a';
				else c[i]=a[i];
			}
			for(int i=start;i<=end;i++){
				c[i]=b[i-start];
			}
			for(int i=end+1;i<len;i++){
				if(a[i]=='?')
					c[i]='a';
				else c[i]=a[i];
			}
			for(int i=0;i<len;i++){
				cout<<c[i];
			}
		}
	}
	else {
		for(int i=0;i<start;i++){
			if(a[i]=='?')
				c[i]='a';
			else c[i]=a[i];
		}
		for(int i=start;i<=end;i++){
			c[i]=b[i-start];
		}
		for(int i=end+1;i<len;i++){
			if(a[i]=='?')c[i]='a';
			else c[i]=a[i];
		}
		c[len]='\0';
		for(int i=0;i<len;i++)
			cout<<c[i];
	}
	return 0;
}

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

int main(){
    int N,a;
    cin >> N;
    vector<int> vec(N);
    for(int i=1;i<N;i++){
        cin >> a;
        vec[a-1]++;
    }
    for(int j=0;j<N;j++){
        cout << vec[j] << endl;
    }
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
typedef pair<P1,int> Pli;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 802

bool dp[MAX_N][MAX_N]={};
vector<int> G[MAX_N];
vector<int> v;
bool d[MAX_N][MAX_N]={};
queue<int> que;

int main() {

	int h,w,k;

	cin>>h>>w>>k;
	int s1,s2;
	rep(i,h){
		rep(j,w){
			char chr;
			cin>>chr;
			if(chr=='S'){
				s1=i;
				s2=j;
				d[i][j]=true;
			}
			if(chr=='.')d[i][j]=true;
		}
	}
	int t=1000000000;
	queue<P2> que;
	que.push(P2(k,P1(s1,s2)));
	while(!que.empty()){
		P2 pp2=que.front();que.pop();
		int cost=pp2.first;
		int x1=pp2.second.first;
		int y1=pp2.second.second;
		if(dp[x1][y1]||!d[x1][y1])continue;
		dp[x1][y1]=true;
		int t2=min(min(x1,y1),min(h-x1-1,w-y1-1));
		t2=t2/k+(t2%k!=0)+1;
		t=min(t,t2);
//		cout<<t<<endl;
		if(cost==0)continue;
		if(x1>0)que.push(P2(cost-1,P1(x1-1,y1)));
		if(x1<h-1)que.push(P2(cost-1,P1(x1+1,y1)));
		if(y1>0)que.push(P2(cost-1,P1(x1,y1-1)));
		if(y1<w-1)que.push(P2(cost-1,P1(x1,y1+1)));
	}
	cout<<t<<endl;

	return 0;
}


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

wa=[0]*n
sa=[0]*n
cntwa=[0]*(n+1)
cntsa=[0]*(n+1)
for i in range(n):
    wa[i]=i+1+a[i]
    sa[i] =i+1-a[i]
    if 0<wa[i]<n:
        cntwa[wa[i]]+=1
    if 0<sa[i]<n:
        cntsa[sa[i]]+=1
ans = 0
for i in range(n):
    ans += cntwa[i] * cntsa[i]
print(ans)


Measured memory_bytes: 95464
#include <stdio.h>

int main()
{
	int S, h, m, s;
	scanf("%d", &S);
	h = S / 60 / 60;
	m = (S / 60) % 60;
	s = S % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

int now_time = -1, time_stamp_d[101]{}, time_stamp_f[101]{};
int vertices_num;
std::vector<int> dest[101];
void search(int);

int main()
{
	int vertex_tmp, dest_num, dest_tmp;

	std::cin >> vertices_num;
	for (int i = 1; i <= vertices_num; ++i)
	{
		std::cin >> vertex_tmp >> dest_num;
		for (int j = 0; j < dest_num; ++j)
		{
			std::cin >> dest_tmp;
			dest[vertex_tmp].push_back(dest_tmp);
		}
		dest[0].push_back(i);
	}
	
	search(0);

	for (int i = 1; i <= vertices_num; ++i)
	{
		std::cout << i << " " << time_stamp_d[i] << " " << time_stamp_f[i] << std::endl;
	}

	return 0;
}

void search(int now_place)
{
	time_stamp_d[now_place] = ++now_time;
	for (auto e : dest[now_place])
	{
		if (time_stamp_d[e]) continue;
		search(e);
	}
	time_stamp_f[now_place] = ++now_time;
	return;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

 if (A + B < C + D ) {
   cout << "Right" << endl;
 }
 if (A + B > C + D ) {
   cout << "Left" << endl;
 } 
 if (A + B == C + D ) {
   cout << "Balanced" << endl;
 }  
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

// U - Grouping
int n;
ll a[16][16],dp[1<<16],c[1<<16];

int main(){
	cin>>n;
	FOR(i,0,n) FOR(j,0,n) cin>>a[i][j];
	FOR(b,0,1<<n){
		FOR(i,0,n) FOR(j,i+1,n) if(1&(b>>i)) if(1&(b>>j)) c[b]+=a[i][j];
	}
	FOR(i,1,1<<n){
		for(int isub=i; isub>0; isub=(isub-1)&i){
			ll now=dp[i-isub]+c[isub];
			dp[i]=max(dp[i],now);
		}
	}
	co(dp[(1<<n)-1]);
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll cash=1000;
void Main(){
    int n;
    cin >> n;
    vector<int> a(n);
    For(i,0,n) cin >> a[i];
    For(i,0,n-1){
        if(a[i]<a[i+1]){
            ll stock=cash/a[i];
            cash+=stock*(a[i+1]-a[i]);
        }
    }
    cout<<cash<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
  char s[12] = "\0";
  int i, nf = 0;
  
  scanf("%s", s);
  
  for(i=0; s[i]!='\0'; i+=2){
    if(s[i] != 'h' || s[i+1] != 'i'){
      nf = 1;
      break;
    }
  }
  
  if(nf == 0){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define overload4(_1, _2, _3, _4, name, ...) name
#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int iINF = 1e9;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

const int max_h = 10;
const int max_w = 10;

int H, W;
int CH, CW;
int DH, DW;
int cnt = 0;
P step[4] = {
    P(1, 0),
    P(0, 1),
    P(-1, 0),
    P(0, -1),
};
vector<vector<ll>> note;

int bfs(vector<vector<char>> map, P start, P goal) {
  deque<P> q;
  // スタート地点登録
  q.push_back(start);
  note[start.first][start.second] = 0;
  while (!q.empty()) {
    P p = q.front();
    q.pop_front();
    int y = p.first;
    int x = p.second;
    rep(4) {
      int nx, ny;
      ny = y + step[i].first;
      nx = x + step[i].second;
      if (nx <= 0 || ny <= 0 || nx > W || ny > H) continue;
      // 壁の場合
      if (map[ny][nx] == '#') continue;
      if (chmin(note[ny][nx], note[y][x])) {
        q.push_front(P(ny, nx));
      }
    }
    rep(xx, -2, 3) rep(yy, -2, 3) {
      int nx2, ny2;
      ny2 = y + yy;
      nx2 = x + xx;
      if (nx2 <= 0 || ny2 <= 0 || nx2 > W || ny2 > H) continue;
      // 壁の場合
      if (map[ny2][nx2] == '#') continue;
      if (chmin(note[ny2][nx2], note[y][x] + 1)) {
        q.push_back(P(ny2, nx2));
      }
    }
  }
  return 0;
}

int main() {  // TODO
  cin >> H >> W;
  cin >> CH >> CW;
  cin >> DH >> DW;
  P c = P(CH, CW);
  P d = P(DH, DW);

  vector<vector<char>> map(H + 1, vector<char>(W + 1));
  note.assign(H + 1, vector<ll>(W + 1, INF));
  // vector<vector<ll>> note(H + 1, vector<ll>(W + 1, INF));
  rep2(i, H) rep2(j, W) cin >> map[i + 1][j + 1];

  if (map[c.first][c.second] == '#' || map[d.first][d.second] == '#') {
    cout << -1 << endl;
  }
  int res = bfs(map, c, d);
  ll ans = note[DH][DW];
  if (ans == INF) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 13584
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int a,b,c,a1,b1,c1,ans=inf;
int main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>a>>b>>c;
    a1=a+b;
    b1=a+c;
    c1=b+c;
    ans=min(a1,min(b1,c1));
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  long long sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  long long sa=INT_MAX;
  long long sum2=0;
  for(int i=0;i<n;i++){
    sum2+=a[i];
    sa=min(sa,abs(abs(sum-sum2)-sum2));
  }
  cout<<sa<<endl;
  return 0;
}
    

Measured memory_bytes: 1024
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($($args),*), ($($args),*));
    };
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

fn neighs(xs: &Vec<i64>, x: i64) -> Vec<i64> {
    let mut left = 0;
    let mut right = xs.len();
    for _ in 0..900 {
        let mid = (left + right) / 2;
        if xs[mid] < x {
            left = mid;
        } else {
            right = mid;
        }
    }
    left = if left > 3 { left - 3 } else { 0 };
    right = if right + 3 < xs.len() { right + 3 } else { xs.len() };

    (left..right).map(|i| xs[i]).collect()
}

fn main() {
    let mut sc = Scanner::new();
    let n = sc.cin();
    let m = sc.cin();
    let q = sc.cin();

    let xs: Vec<i64> = (0..n).map(|_| sc.cin()).collect();
    let ys: Vec<i64> = (0..m).map(|_| sc.cin()).collect();

    for _ in 0..q {
        let t: i64 = sc.cin();
        let neighs_xs = neighs(&xs, t);
        let neighs_ys = neighs(&ys, t);
        // trace!(t);
        // trace!(&neighs_xs); trace!(&neighs_ys);
        let mut ans = ( xs[n-1] + ys[m-1] ) * 3;
        for &x in neighs_xs.iter() {
            for &y in neighs_ys.iter() {
                ans = min(ans, (t - x).abs() + (x - y).abs());
                ans = min(ans, (t - y).abs() + (x - y).abs());
            }}
        put!(ans);
    }
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


Measured memory_bytes: 7420
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int N, K; cin >> N >> K;
    vector<int> A(N); for (auto &a : A) cin >> a, a--;
    vector<int> visited(N, -1);
    vector<int> history;
    int curr = 0;
    int cnt = 0;
    while (visited[curr] == -1) {
        if (cnt == K) {
            cout << curr + 1 << '\n';
            return 0;
        }
        visited[curr] = cnt++;
        history.push_back(curr);
        curr = A[curr];
    }
    int t = visited[curr];
    cout << history[t + (K - t) % (cnt - t)] + 1 << endl;
    return 0;
}


Measured memory_bytes: 5812
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author rn-sshawish
 */
public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int t = 0, x = 0, y = 0;
        boolean state = true;
        for (int i = 0; i < n; i++) {
            int t1 = input.nextInt();
            int x1 = input.nextInt();
            int y1 = input.nextInt();
            int distanceDiff;

                int fiffY = Math.abs(x - x1);
//                if (fiffY != 0 && x != 0&& x1 != 0) {
//                    fiffY ++;
//                }
                int fiffX = Math.abs(y - y1);
//                if (fiffX != 0 && y != 0&& y1 != 0) {
//                    fiffX ++;
//                }
                distanceDiff = fiffX + fiffY;
            
            int timeDiff = t1 - t;
            if (distanceDiff == timeDiff) {
                t = t1;
                x = x1;
                y = y1;
            }else if (distanceDiff < timeDiff && (timeDiff - distanceDiff) % 2 == 0) {
                t = t1;
                x = x1;
                y = y1;
            }else {
                state = false;
                break;
            }
        }
        if (state) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}



Measured memory_bytes: 85356
from collections import Counter

n = int(input()) 
S = input()

# n = 6
# S = "aabbca"
count = [0 for x in range(n)]

for i in range(n):
    S1 = S[0:i]
    S1c = Counter(S1)
    # print(S1c)
    # print(S1c.keys())

    S2 = S[i:n]
    S2c = Counter(S2)
    # print(S2c)

    for alphabet in S1c.keys():
        if alphabet in S2c.keys():
            count[i] += 1

# print(count)
print(max(count))

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
         
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
#define vll vector<ll>
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define F first
#define S second
#define pll pair<ll,ll> 
#define G(a,b) get<a>(b)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)    
#define endl "\n"
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define sz(x) (ll)x.size() 
#define ara cout<<"ara-ara\n"; 
const ld pi=3.141592653589793238;

const ll N=5e5+10;
ll arr[N],lastOcc[N],n,q,x[N],BIT[N],ans[N];
vector<pll>qq[N];

void upd(ll idx,ll del)
{
  while(idx<=n+2) 
  {
    BIT[idx]+=del;
    idx+=(idx&(-idx));
  }
}

ll pre(ll idx)
{
  ll res=0;
  while(idx)
  {
    res+=BIT[idx];
    idx-=(idx&(-idx));
  }
  return res;
}

void func()
{
  cin>>n>>q;
  f(i,1,N) lastOcc[i]=-1;
  f(i,1,n+1)
  {
    cin>>arr[i];
    x[i]=lastOcc[arr[i]];
    lastOcc[arr[i]]=i;
  }
 
  f(i,1,q+1)
  {
    ll l,r;
    cin>>l>>r;
    qq[r].pb(MP(l,i));
  }
  
  // Shift everything 2 units right
  f(i,1,n+1)
  {
    upd(x[i]+2,1);
    for(auto &j:qq[i]) 
    {
      ll l=j.F,idx=j.S;
      ll x=pre(l+1),y=i-x,res=i-l+1-y;
      ans[idx]=res;
    }
  }
  
  f(i,1,q+1) cout<<ans[i]<<"\n";
}   
     
     
     
int main() 
{
    fast
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif // ONLINE_JUDGE
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
       //cout<<"Case #"<<i<<": ";
       //cout<<"\n";
       func();
    }
     
    return 0;
}


Measured memory_bytes: 47836
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <array>
#define ll long long
#define ar array
using namespace std;
const int N = 1e5;
string a, b;
int dp[N];
vector<int> adj[N];

int solve(int v){
    if(dp[v]!=-1)
        return dp[v];
    int res = 0;
    for(int u : adj[v]){
        res = max(res, solve(u)+1);
    }
    return dp[v]=res;
}

int main(){
    ios_base::sync_with_stdio(0);
    int n, m;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int u, v;
        cin>>u>>v;
        adj[v-1].push_back(u-1);
    }

    int res = 0;
    for(int i=0; i<n; i++){
        dp[i] = -1;
    }

    for(int i=0; i<n; i++){
        res = max(res, solve(i));
    }
    cout<<res<<endl;
}

Measured memory_bytes: 13560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair

const int maxn = 1e5 + 100 , maxc = 115, mod = 1e9 + 7, inf = 1e9+10;

ll n, a[maxn], t;
ll sum;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	if (sum % (n * (n+1) / 2))
		return cout << "NO" << endl, 0;
	ll k = sum / (n * (n+1) / 2);
	a[n] = a[0];
	for (int i = 0; i < n; i++)
	{
		ll d = a[i+1] - a[i];
		d -= k;
		if (d > 0)
			return cout << "NO" << endl, 0;
		d = -d;
		if (d % n)
			return cout << "NO" << endl, 0;
	}
	cout << "YES" << endl;



	return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		char arr[] = sc.nextLine().toCharArray(); 
		if(arr[0] == arr[1] && arr[1] == arr[2])
			System.out.println("Yes"); 
		else if(arr[1] == arr[2] && arr[2] == arr[3])
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<stack>
#include<string>

using namespace std;

int main(void){
    string X;
    stack<char> s;
    cin >> X;
    s.push('X');    //sentinel
    for(auto itr = X.begin(); itr != X.end(); itr++){
        // cout << *itr << endl;
        if(*itr == 'S') s.push('S');
        else{
            if(s.top() == 'S') s.pop();
            else s.push('T');
        }
    }
    cout << s.size() - 1 << endl;
}

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

int main(void) {
    long N;
    cin >> N;
    for(long h=1; h<=3500; h++)
        for(long n=1; n<=3500; n++) {
            long w = roundl(1.0/(4.0/N - 1.0/h - 1.0/n));

            if(0 < w && w <= 3500 && abs(4.0/N - 1.0/h - 1.0/n - 1.0/w) < 1e-15) {
                cout << h << ' ' << n << ' ' << w << endl;
                return 0;
            }
        }

}


Measured memory_bytes: 256
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var v = Console.ReadLine().Split();
            var p = new double[6];
            for(int i=0; i < 4; p[i] = double.Parse(v[i++])) ;
            Console.WriteLine("{0:f5}", Math.Sqrt((p[4] = p[0] - p[2]) * p[4] + (p[5] = p[1] - p[3]) * p[5]));
        }
    }
}

Measured memory_bytes: 5748
<?php
$input = trim(fgets(STDIN));
$list = explode(" ", $input);
$a = $list[0];
$b = $list[1];
$c = $list[2];

$cnt = 0;
for($i=$a; $i<=$b; $i++){
      if($c % $i == 0){
        $cnt++;
     }
}
echo $cnt;

?>

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

int main() {
  int N;
  cin >> N;
  string ans;
  if (!N) cout << 0 << endl;
  else {
    while (N) {
      if (N % -2) {
        N--;
        ans.push_back('1');
      } else ans.push_back('0');

      N /= -2;
    }

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

    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fname "C"
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << '\n'
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<float, float> ff;
typedef pair<double, double> dd;

int main()
{
	if (fopen(fname".INP", "r")) {
		freopen(fname".INP", "r", stdin);
		freopen(fname".OUT", "w", stdout);
	}
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, ans = INT_MAX, sum;
	scanf("%d", &n);
	vector<int> arr(n);
	REP0(i, n) scanf("%d", &arr[i]);
	FOR(x, -100, 100) {
		sum = 0;
		REP0(i, n) sum += (x - arr[i])*(x - arr[i]);
		ans = min(ans, sum);
	}
	cout << ans;
	return 0;
}

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

int main(){
	int k,a,b;
	cin >> k >> a >> b;
	
	for(int i =1;i<1001;i++)
	{
		if(i*k<=b && i*k>=a)
		{
			cout << "OK" <<endl;
			return 0;
		}
		
	}
	cout << "NG" << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll ib = b*100+0.1;
    ll ans = (a*ib)/100;
    cout << ans << endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

ll func(ll n){
    if(n&1){
        if((n / 2) & 1)n = 0;
        else n = 1;
    }
    else {
        n = (((n / 2) & 1) ^ n);
    }

    return n;
}

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

    if(a == 0)cout << b << endl;
    else cout << (func(a-1) ^ func(b)) << endl;
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int a[100005];
int main(int argc, char** argv) {
	int n,mn=1e9,mx=0,cnt=0;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]==mn)
			++cnt;
		if(a[i]<mn)
		{
			mn=a[i];
			cnt=1;
		}
		if(a[i]>mx)
			mx=a[i];
	}
	if(mx==mn)
	{
		if(a[1]==n-1)
			puts("Yes");
		else if(a[1]<=n/2)
			puts("Yes");
		else puts("No");
		return 0;
	}
	if(mx-mn>=2)
		puts("No");
	else if((n-cnt)/2+cnt<mx||cnt+1>mx)
		puts("No");
	else puts("Yes");
	return 0;
}
//dlstxdy!

Measured memory_bytes: 640
'use strict'

const main = input => {
	const args = input.trim().split('\n').map(t1 => t1.split(' ').map(t2 => parseInt(t2, 10)))
	const N = args[0][0]
	let X = args[0][1]
	const m = []
	let cnt = 0
	let minM = 1000

	for (let i = 1; i < args.length; i++) {
		m.push(args[i][0])
	}

	for (let i = 0; i < m.length; i++) {
		minM = Math.min(minM, m[i])
		X -= m[i]
		cnt++
	}

	cnt += Math.floor(X / minM)
	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 11468
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
char s[1010],t[1010];
const char st[8]={0,'k','e','y','e','n','c','e'};
bool cmp(char s[]) {
	for (int i=1;i<=7;i++) if (s[i]!=st[i]) return 0;
	return 1;
}
int main() {
	gets(s+1); n=strlen(s+1);
	if (n==7&&cmp(s)) {
		puts("YES"); return 0;
	} 
	for (int i=1;i<=8;i++) {
		for (int j=1;j<i;j++) t[j]=s[j];
		for (int j=7;j>=i;j--) t[j]=s[n-7+j];
		//for (int j=1;j<=7;j++) putchar(t[j]); puts("");
		if (cmp(t)) {
			puts("YES"); return 0;
		}
	}
	puts("NO");
	return 0;
}

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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, n)

int n, l, r;
vector<int> a;

bool init() {
  a.clear();
  cin >> n >> l >> r;
  if (n == 0) return false;
  a.resize(n);
  rep(i, n) {
    cin >> a[i];
  }
  return true;
}

int check(int x) {
  rep(i, n) {
    if (x % a[i] == 0) {
      return 1 - i % 2;
    }
  }
  return 1 - n % 2;
}


void solve() {
  int res = 0;
  reps(i, l, r+1) {
    res += check(i);
  }
  cout << res << endl;
}

int main() {
    while (init()) {
        solve();
    }
}


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

using namespace std;

int num[200001];
vector<int>pres(1000000,0);

int n;

int find(int j,int pos){
	int low=0,high=n-1,mid;
  
  	while(low <= high){
      mid =(low + high)/2;
    	if(num[mid] == j && pos!=mid){
        	return 1;
        }
      	else if( num[mid] < j){
        	low = mid+1;
        }
      	else
        {
        	high=mid -1;
        }
    }
  return 0;
}

int diva(int n,int pos) 
{  
  	if(pres[n] >1){
       return 0;}
  	else{
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
              if (n/i == i){
              	  if(find(i,pos)){
                  	return 0;
                  }
              } 
            else { 
                if(find(i,pos) == 1 || find(n/i,pos)  == 1 ) {
                	return 0;
                }
            } 
        } 
    }
    } 
  	return 1;
} 

int main(){

   int ans=0;
  
  cin>>n;
  
  for(int a=0;a<n;a++){
  		cin>>num[a];
    	pres[num[a]]++;
  }
  
  sort(num,num +n);
  
  for(int a=0;a<n;a++){
  		ans=ans + diva(num[a],a);
        
  }
           cout<<ans<<endl;
           
}


Measured memory_bytes: 7988
#!/usr/bin/env python3
k, n = map(int, input().split())
a = list(map(int, input().split()))

cnt = 0
maxku = 0
for i in range(n-1):
     ku = a[i + 1] - a[i]
     maxku = max(ku, maxku)
     cnt += ku

ku = a[0] + (k - a[-1])
maxku = max(ku, maxku)
cnt += ku

print(cnt - maxku)


Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF = 1LL<<60;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k; cin>>k;
    ll n = 50; cout<<n<<endl;
    rep(i,n){
        if(i<k%n)cout<<n-1-k+(n+1)*((k/n)+1);
        else cout<<n-1-k+(n+1)*(k/n);
        cout<<" ";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;

ll bit[100002];
ll memo[100001];
int n;
ll p;

ll sum(int i) {
    ll s = 0;
    while(i > 0) {
        s += bit[i];
        s %= p;
        i -= i & -i;
    }
    return s;
}

void add(int i,ll x) {
    while(i <= n) {
        bit [i] += x;
        bit[i] %= p;
        i += i & -i;
    }
}

int main() {
    ll a,b;
    stringstream ss;
    while(cin>>a>>b>>p, a|b|p) {
//        cout<<"hoge"<<endl;
        vector<pair<string,ll> > vs;

        memset(bit, 0, sizeof(bit));
        n = b-a+1;
        for(int i=0; i<n; ++i) {
            memo[i] = 1;
//            add(i+1,1);
        }

//        cout<<"added"<<endl;
        for(ll i=a; i<=b; ++i) {
//            cout<<i<<endl;
            ss << i;
            vs.push_back(make_pair(ss.str(),i-a));
            ss.str("");
        }

        sort(vs.begin(), vs.end());
//        cout<<"sorted"<<endl;

        for(int i=0; i<vs.size(); ++i) {
            int idx = vs[i].second;
            ll hoge = sum(idx+1);
            memo[idx] += hoge;
            add(idx+1,hoge+1);
        }

        ll ans = 0;
        for(ll i=a; i<=b; ++i) {
//            cout<<i<<" "<<memo[i-a]<<endl;
            ans += memo[i-a];
            ans %= p;
        }

        cout<<ans<<endl;
    }
}

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

using namespace std;

// Function come here..

int main(int argc, char **argv)
{
    // Problem solution come here...
    int N, T;
    map<int, int> route;

    cin >> N >> T;
    int t, c;
    for (int i = 0; i < N; i++)
    {
        cin >> c >> t;

        if (t > T)
            continue;

        route.insert(pair<int, int>(c, t));
    }

    if (route.empty())
        cout << "TLE" << endl;
    else
    {
        map<int, int>::iterator it = route.begin();
        cout << it->first << endl;
    }
    return 0;
}

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


typedef long long ll;
typedef pair<int, int> P;

struct edge {int to; ll cost; };

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

ll GCD(ll a, ll b){
  if(b==0) return a;
  else return GCD(b, a%b);
}

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

int main(){
  int n;
  ll w;
  cin >> n >> w;
  vector<vector<ll>> dp(n+1, vector<ll>(100005, 1000000009));
  dp[0][0] = 0;
  for(int i=1; i<=n; i++){
    ll wi;
    int v;
    cin >> wi >> v;
    for(int j=100004; j>=0; j--){
      if(j-v>=0) dp[i][j] = min(dp[i-1][j-v]+wi, dp[i-1][j]);
      else dp[i][j] = dp[i-1][j];
    }
  }
  int ans = 0;
  for(int i=0; i<=100004; i++){
    if(dp[n][i]<=w) ans = i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 83256
#include <bits/stdc++.h>
using namespace std;
#define lmax LLONG_MAX
#define lmin LLONG_MIN
#define f(i,a,b) for(long long i=a;i<b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define tc long long test;cin>>test;while(test--)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define output(a,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define endl "\n"
#define mem(a) memset(a,-1,sizeof(a))
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast_cin;


    string s;    
    tc{
        s+="ACL";
    }

    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static class Fast {
        BufferedReader br;
        StringTokenizer st;

        public Fast() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        System.out.println((in.nextInt()-in.nextInt())%in.nextInt());
    }
}

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

using namespace std;

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

	string s;
	cin >> s;
	int count = 0;
	for(int i=1; i<s.length(); i++){
		if(s[i]=='1' and s[i-1]=='1'){
			count++;
			s[i]='0';
		}
		else if(s[i]=='0' and s[i-1]=='0'){
			count++;
			s[i]='1';
		}
	}
	cout << count;
	return 0;
}

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

int main(){
  int K,X;
  cin >> K >> X;
  if(500*K>=X){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3564
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://x...content-available-to-author-only...i.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli check(string& s, int flag){
    lli n = s.size();
    lli cnt = 0;
    loop(i, 0, n){
        if(s[i] - '0' != flag)
            cnt++;
        flag = 1 - flag;
    }
    return cnt;
}
lli solve(){
    string s;
    cin>>s;
    lli cnt = check(s, 0);
    cnt = min(cnt, check(s, 1));
    cout<<cnt<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 3760
import itertools
import math

n = int(input())
lis = [j for j in range(n)]
points = []

permutations_lis = itertools.permutations(lis)
for i in range(n):
  x,y=map(int,input().split())
  points.append([x,y])

def distance(forw, back):
  #print(points[forw][0])
  return math.sqrt((points[forw][0]-points[back][0])**2+(points[forw][1]-points[back][1])**2)

sum_,k = 0,0
for one_case in permutations_lis:
  k+=1
  for j in range(len(one_case)-1):
    dis = distance(one_case[j],one_case[j+1])
    sum_+=dis
print(sum_/k)
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    int a[3*n];
    for (int i=0;i<3*n;i++)
    {
        cin>>a[i];
    }
    sort(a, a+3*n, greater<int>());
    ll s=0;
    int k=0;
    for (int i=1;i<3*n;i=i+2)
    {
        k++;
        if (k>n)
        {
            break;
        }
        s+=a[i];
    }
    cout<<s;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, M;
	cin>>N>>M;
	vector<int> h(N+1);
	for (int i = 1; i <= N; ++i){
		cin>>h[i];
	}
	vector<int> ma(N+1);
	for (int i = 0; i < M; ++i){
		int a, b;
		cin>>a>>b;
		ma[a] = max(ma[a],h[b]);
		ma[b] = max(ma[b],h[a]);
	}
	int res = 0;
	for (int i = 1; i <= N; ++i){
		res += h[i] > ma[i];
	}
	cout<<res<<endl;
}


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

int main() {
  int n;
  cin >> n;
  long max;
  vector<long>data(n);
  cin >> data[0];
  max = data[0];
  for(int i = 1;i < n;i++){
    cin >> data[i];
    if(data[i] > max){
      max = data[i]-1;
    }
    else if(data[i] == max) continue;
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1024
from collections import defaultdict
d = defaultdict(int)

n = int(input())
s = input()
r=[]
g=[]
b=[]
for i in range(n):
  #print(s[i])
  if s[i] == 'R':
    r.append(i)
  elif s[i] == 'G':
    g.append(i)
  else:
    #b.append(i)
    d[i] = 1

#print(r)
#print(g)
#print(b)
sum = len(r)*len(g)*len(d)
for i in r:
  for j in g:
    ma = max(i,j)
    mi = min(i,j)
    df = ma - mi
    k1 = mi - df
    k2 = ma + df
    k3 = (ma + mi) / 2
    sum -= d[k1]
    sum -= d[k2]
    sum -= d[k3]
print(sum)

Measured memory_bytes: 77684
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int a,b;
	cin >> a >> b;
	cout <<  a * b << '\n';
}


Measured memory_bytes: 3652
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var N = parseInt(input[0]);
  var s = input[1];
  var wCount = 0;
  var wList = [];
  var eCount = 0;
  var eList = [];
  var output = 1000000;
  for(var i = 0; i < N; i++){
    var tmp = s.slice(i,i+1);
    if(tmp == "W"){
       wCount++;
    }else{
       eCount++; 
    }
    wList.push(wCount);
  }
  for(var i = 0; i < N; i++){
    var tmp = s.slice(i,i+1);
    if(tmp == "E"){
       eCount--;
    }
    eList.push(eCount);
  }
  for(var i = 0; i < N; i++){
    var tmp = s.slice(i,i+1);
    if(tmp == "W"){
       wList[i]--;
    }
    output = Math.min(output,wList[i] + eList[i]);
  }
  
  myout(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

int main(){
    char x;
    cin >> x;
    if(x == toupper(x)){
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }
}

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

int A,B,Q;
vector<long long> s;
vector<long long> t;
vector<long long> x;
void chmin(long long &a, long long b) { if (a > b) a = b; }
template<class T> int former(const vector<T> &v, T x){
  return upper_bound(v.begin(),v.end(),x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(),v.end(),x) - v.begin();
}
const long long INF = 1LL << 58;
int main(){
  cin >> A >> B >> Q;
  s.resize(A);
  t.resize(B);
  x.resize(Q);
  for(int i = 0;i<A;i++){
    cin >> s[i];
  }
  for(int i = 0;i<B;i++){
    cin >> t[i];
  }
  for(int i = 0;i<Q;i++){
    cin >> x[i];
  }
  s.push_back(INF);
  s.push_back(-INF);
  t.push_back(INF);
  t.push_back(-INF);
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());

  
  for(int i=0;i<Q;i++){
    long long pos = x[i];
    long long res = INF;
    for(int j = 0;j<2;j++){
      long long first = (j? s[former(s,pos)] : s[latter(s,pos)]);
      for(int k = 0;k<2;k++){
        long long second = (k? t[former(t,first)] : t[latter(t,first)]);
        chmin(res,abs(pos-first)+abs(first-second));
      }
    }

    for(int j=0;j<2;j++){
      long long first = (j? t[former(t,pos)] : t[latter(t,pos)]);
      for(int k=0;k<2;k++){
        long long second = (k? s[former(s,first)] : s[latter(s,first)]);
        chmin(res,abs(pos-first) + abs(first-second));
      }
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
using namespace std;
int main() {
    int N;
    std::vector<int> L;

    int tmp;
    std::cin >> N;
    for (size_t i = 0; i < N; i++) {
            std::cin >> tmp;
            L.push_back(tmp);
    }
    sort(L.begin(),L.end());
    tmp=L.back();
    L.pop_back();


    if(tmp<std::accumulate(L.begin(),L.end(),0)){
        std::cout << "Yes" << '\n';
    }else{
        std::cout << "No" << '\n';
    }




    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
int a[10000];
int c[9];

int main() {

    cin >> N;
    rep(i, 9) c[i] = 0;

    rep(i, N){ cin >> a[i]; }
    rep(i, N){ int r = min(a[i] / 400, 8);
               c[r]++;}

    int mn = 0;
    int mx = 0;

    rep(i, 8){ if(c[i] > 0) { mn++; mx++; } }
    mn = max(mn, 1);
    mx = mx + c[8];

	cout << mn << " " << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N;
    cin >> N;
    int h[N],dp[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<N;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[N-1] << endl;


}

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

using namespace std;

int A, B, C;
int ans = 0;

int main() {
	scanf("%d%d%d", &A, &B, &C);
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
		int nA = 0, nB = 0, nC = 0;
		nA = B/2 + C/2;
		nB = A/2 + C/2;
		nC = A/2 + B/2;
		if (nA == A && nB == B && nC == C) {
			puts("-1");
			return 0;
		}
		++ ans;
		A = nA;
		B = nB;
		C = nC;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        int ret;
        if (a[0] == a[1]) ret = a[2];
        else if (a[0] == a[2]) ret = a[1];
        else ret = a[0];
        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 13140
use std::collections::HashSet;

fn input_line() -> Vec<String> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).unwrap();
  return buf
    .split_whitespace()
    .map(|word| String::from(word))
    .collect();
}

fn main() {
  let inputs = input_line();
  let k: i64 = inputs[0].parse().unwrap();
  let mut value: i64 = 7;
  let mut i: i64 = 1;
  let mut set: HashSet<i64> = HashSet::new();
  let mut ans = -1;
  loop {
    let m = value % k;
    if m == 0 {
      ans = i;
      break;
    }
    if set.contains(&m) {
      break;
    }
    set.insert(m);
    value = (value * 10 + 7) % k;
    i += 1;
  }

  println!("{}", ans);
}

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

int main() {
  string S;
  cin >> S;
  if(S.at(0) == '7' || S.at(1) == '7' || S.at(2) == '7') {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
  
}


Measured memory_bytes: 3624