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

using namespace std;


#define MAX 200002

int n;
int k;
int l;
#define SQ 330

struct UF{
	vector<int> belong;
	vector<int> size;
	void resize(int n){
		belong.assign(n + 1, -1);
		size.assign(n + 1, 1);
	}
	inline int root(int b){
		if (belong[b] == -1){
			return b;
		}
		belong[b] = root(belong[b]);
		return belong[b];
	}
	void merge(int a, int b){
		a = root(a);
		b = root(b);
		if (a == b)return;
		belong[a] = b;
		size[b] += size[a];
	}
	set<int> r;
	vector<vector<int> > child;
	vector<set<int> > child2;
	map<int, bitset<MAX>> mp;
	void solve(){
		child2.assign(n, set<int>());
		child.assign(n, vector<int>());
		for (int i = 0; i < n; i++){
			r.insert(root(i));
			child[root(i)].push_back(i);
			child2[root(i)].insert(i);
		}
		for (auto it = r.begin(); it != r.end(); it++){
			if (size[(*it)] < SQ){

			}
			else{
				mp[(*it)] = bitset< MAX >() ;
				auto &f = mp[(*it)];
				for (int j = 0; j < child[(*it)].size(); j++){
					f.set(child[(*it)][j], 1);
				}
			}
		}
	}
};
 
UF uf1;
UF uf2;


int main(){
	scanf("%d%d%d", &n, &k, &l);
	uf1.resize(n);
	uf2.resize(n);
	for (int i = 0; i < k; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		uf1.merge(a, b);
	}
	for (int i = 0; i < l; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		uf2.merge(a, b);
	}
	uf1.solve();
	uf2.solve();
	for (int i = 0; i < n; i++){
		int cnt2 = 0;
		int b1 = uf1.root(i);
		int b2 = uf2.root(i);
		bool search = false;
		set<int> &A = uf1.child2[b1];
		set<int> &B = uf2.child2[b2];
		bool f1 = false;
		if (A.size()>B.size()){
			swap(A, B);
			f1 = true;
		}
		if (A.size() <= SQ){
			for (auto it = A.begin(); it != A.end(); it++){
				if (B.count((*it))){
					cnt2++;
				}
			}
			if (i){
				printf(" ");
			}
			printf("%d", cnt2);
		}
		else{
			int cnt2 = (uf1.mp[b1] & uf2.mp[b2]).count();
			if (i){
				printf(" ");
			}
			printf("%d", cnt2);
		}
		if (f1){
			swap(A, B);
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 77184
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int N,a[100],M,m,f,indm,indM,count=0;
  cin >> N;
  REP(i,N)cin >> a[i];
  f = 1;
  REP(i,N){
    if(a[i] < 0)
      f = 0;
  }
  if(f){
    cout << N-1 << endl;
    REP(i,N-1){
      cout << (i+1) << " " << (i+2) << endl;
    }
    return 0;
  }
  f = 1;
  REP(i,N){
    if(a[i] > 0)
      f = 0;
  }
  if(f){
    cout << (N-1) << endl;
    for(int i=N;i>1;i--){
      cout << i << " " << (i-1) << endl;
    }
    return 0;
  }
  M = -10E6-1;
  m = 10E6+1;
  REP(i,N){
    if(a[i] > M){
      M = max(M,a[i]);
      indM = i;
    }
    if(a[i] < m){
      m = min(m,a[i]);
      indm = i;
    }
  }
  if(abs(M) >= abs(m)){
    REP(i,N){
      if(a[i] < 0)
        count++;
    }
    cout << (N-1 + count) << endl;
    REP(i,N){
      if(a[i] < 0)
        cout << (indM+1) << " " << i+1 << endl;
    }
    REP(i,N-1){
      cout << (i+1) << " " << (i+2) << endl;
    }
    return 0;
  }else{
    REP(i,N){
      if(a[i] > 0)
        count++;
    }
    cout << (N-1 + count) << endl;
    REP(i,N){
      if(a[i] > 0)
        cout << (indm+1) << " " << i+1 << endl;
    }
    for(int i=N;i>1;i--){
      cout << (i) << " " << (i-1) << endl;
    }
    return 0;
  }
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



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

def solve():
    imos=[0]*(n+1)
    for i in range(n):
        mnind=max(0,i - a[i])
        mxind=min(n,i+ a[i]+1)
        imos[mnind]+=1
        imos[mxind]-=1
    for i in range(len(imos)-1):
        imos[i+1]+=imos[i]
    return imos[:n]

if k>50:
    k=50
for i in range(k):
    a = solve()
print(*a,sep=" ")

Measured memory_bytes: 171316
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN 200005

using namespace std;

int N;
int a[MAXN], b[MAXN];
int sum;
vector<int> res;

signed main()
{
  IO;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  for (int i = N; i >= 1; i--) {
    sum = 0;
    for (int j = i + i; j <= N; j += i) {
      sum += b[j];
    }
    b[i] = (sum & 1) ^ a[i];
    if (b[i]) {
      res.emplace_back(i);
    }
  }
  cout << res.size() << endl; 
  for (auto &i : res) {
    cout << i << ' ';
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll N, H, W;
    cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); ++i)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define INF ((1 << 30) - 1)
 
int main(){
    istream_iterator<int> itr(cin);
    int n = *itr, m = *(++itr);
    vector<int> a(m), b(m), c(m);
    rep(i, m){
        a[i] = *(++itr) - 1;
        b[i] = *(++itr) - 1;
        c[i] = *(++itr);
    }
 
    vector< vector<int> > p(n);
    rep(i, n){
        p[i] = vector<int>(n, INF);
    }
    rep(i, n){
        p[i][i] = 0;
    }
    rep(i, m){
        p[a[i]][b[i]] = c[i];
        p[b[i]][a[i]] = c[i];
    }
    rep(i, n)
        rep(j, n)
            rep(k, n)
                p[j][k] = min(p[j][k], p[j][i] + p[i][k]);
 
    int sum = 0;
    rep(i, m){
        bool used = false;
        rep(j, n){
            if(p[j][a[i]] + c[i] == p[j][b[i]] || p[j][b[i]] + c[i] == p[j][a[i]]){
                used = true;
                break;
            }
        }
        if(!used){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    s=int(input())
    
    print(int((s-2)*180))

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
 
using namespace std;
 
void display(vector<int> ary) {
  for (int i = 0; i < ary.size(); i++) {
    if (i > 0) cout << " ";
    cout << ary[i];
  }
 
  cout << endl;
}
 
void selection_sort_and_display(vector<int> ary) {
  int min_idx, len, count = 0;
  len = ary.size();
  for (int i = 0; i < len; i++) {
    min_idx = i;
    for (int j = i; j < len; j++) {
      if (ary[min_idx] > ary[j]) {
        min_idx = j;
      }
    }
 
    if (min_idx != i) {
      swap(ary[i], ary[min_idx]);
      count++;
    }
  }
 
  display(ary);
  cout << count << endl;
}
 
int main(void) {
  int len;
  vector<int> ary;
  char s[200];
 
  cin >> len;
 
  for (int i = 0; i < len; i++) {
    cin >> s;
    ary.push_back(atoi(s));
  }
 
  selection_sort_and_display(ary);
 
  return 0;
}

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

int main() {
  
  int N,l,r,s;
  cin >> N;
  s=0;
  
  for(int i=0; i<N; i++){
    cin >> l >> r;
    s+=r-l+1;
  }
  
  cout << s << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, m;
    cin >> n >> m;
    vector<bool> ac(n, false);
    vector<int> wa(n, 0);
    REP(i, m){
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(s == "AC"){
            ac[p] = true;
        }else if(!ac[p]){
            wa[p]++;
        }
    }
    REP(i, n){
        wa[i] *= ac[i];
    }
    cout << SUM(ac) << " " << SUM(wa) << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(void){
  char a[200001],b[200001];
  long long int i, j, count=0;
  scanf("%s",a);
  scanf("%s",b);
  j=strlen(a);
  for(i=0; i<j; i++){
    if(a[i]!=b[i]){
      count++;
    }
  }
  printf("%lld",count);
  return 0;
}

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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }
    i64 ans = 1;
    map<i64, i64> mp;
    mp[-1] = 3;
    for(int i=0;i<n;++i){
        ans *= mp[v[i]-1];
        ans %= MOD;
        mp[v[i]-1]--;
        mp[v[i]]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,i,j,flag=0;;
	scanf("%lld",&n);
	for(i=-200;i<=200;i++)
	{
		for(j=-200;j<=200;j++)
		{
			if(pow(i,5)-pow(j,5)==n)
			{
				flag=1;
				printf("%lld %lld\n",i,j);
				break;
			}
		}
		if(flag)
		break;
	}
}

Measured memory_bytes: 4168
N = int(input())
S = input()

east_count = [0]*(N+1)
west_count = [0]*(N+1)

for i in range(N):
    east_count[i+1] += east_count[i]
    west_count[i+1] += west_count[i]
    if S[i] == 'E':
        east_count[i+1] += 1
    else:
        west_count[i+1] += 1

ans = 2**64
for i in range(N):
    s = S[i]
    count = west_count[i]
    count += east_count[N] - east_count[i+1]
    ans = min(ans, count)

print(ans)
    


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

int main(int argc, char const *argv[]) {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  int tmp;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());

  vector<int> num;
  int cnt = 1;
  int kind = 1;
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      num.push_back(cnt);
    } else if (a[i] == a[i + 1]) {
      cnt++;
    } else {
      num.push_back(cnt);
      cnt = 1;
      kind++;
    }
  }

  // cout << kind << endl;
  sort(num.begin(), num.end());
  // for (int i = 0; i < num.size(); i++) {
  // cout << num[i] << endl;
  // }

  int ans = 0;
  int i = 0;
  while (kind > k) {
    // cout << num[0] << endl;
    ans += num[i++];
    // num.erase(num.begin());
    kind--;
  }

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

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
ll dp[10005];
ll n;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 1, 150){
		REP(j, 1, 150){
			REP(k, 1, 150){
				ll x = i*i + j*j + k*k + i*j + j*k + k*i;
				if (x > n) break;
				dp[x]++;
			}
		}
	}
	REP(i, 1, n + 1){
		cout << dp[i] << endl;
	}
}

//cout.flush()

Measured memory_bytes: 3656
#include<iostream>

using namespace std;

int main(){
	int x,i;
	i=0;
	for(;;){
		cin>>x;
		i=i+1;
		if(x==0)break;
		else{
			cout<<"Case"<<" "<<i<<": "<<x<<endl;
		}
	}
	return 0;
}

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

string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){

   string a;
   int t;

   cin >> t >> a;
   for(int i = 0;i < a.size();i++){
        cout << s[(a[i]-'A'+t)%26];
   }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
void LCS(string X,string Y,int m,int n)
{
	int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout <<lcs; 
}
int main() 
{
	string a,b;
	cin>>a>>b;
	int s1 = a.length();
	int s2 = b.length();
	LCS(a,b,s1,s2);
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  string a;
  cin>>a;
  string d=a+a;
  string b;
  cin>>b;
  ll c=a.size();
  for(ll i=0;i<c;i++){
    for(ll j=0;j<c;j++){
      if(d.at(i+j)!=b.at(j)){
        break;
      }
      if(j==c-1){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
        
    
  
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <limits>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <cmath>

using namespace std;
string s;

int main() {
    cin >> s;
    if (s[s.size() - 1] == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 3636
//Code is like humor. When you have to explain it, it’s bad.
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long
using namespace std;
#define ss second
#define ff first
int32_t main()
{
    fastio;
    int T,n,m,i,j,k,a,b,c,x,y;
    T=1;
    while(T --> 0)
    {
        cin>>x>>y>>a>>b>>c;
        int A[a],B[b];
        vector<int> C(c);
        for(i=0;i<a;i++)    cin>>A[i];
        for(i=0;i<b;i++)    cin>>B[i];
        for(i=0;i<c;i++)    cin>>C[i];

        partial_sort(A,A+x,A+a,greater<int>());
        partial_sort(B,B+y,B+b,greater<int>());
        
        for(i=0;i<x;i++)    C.emplace_back(A[i]);
        for(i=0;i<y;i++)    C.emplace_back(B[i]);

        partial_sort(C.begin(),C.begin()+x+y,C.end(),greater<int>());
        int ans=0;
        for(i=0;i<x+y;i++)  
            ans+=C[i];
        
        cout<<ans;
    }
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();++i)ans+=(s.at(i)!=t.at(i));
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3804
num = gets.to_i
high = gets.split(" ").map(&:to_i)

cost = 0

(high.length - 1).times do |i| 
    if(high[i] > high[i + 1])
      diff = high[i] - high[i + 1]
      cost += diff
      high[i + 1] += diff
    end
end

puts cost

Measured memory_bytes: 28020
import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	String out = "No";
      	for(int i = 1; i<10; i++){
          if(a%i == 0 && a/i < 10){
			out = "Yes";
              break;
          }
        }
      	System.out.println(out);
    
    }




}

Measured memory_bytes: 23892
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s = readline().rstrip().decode('utf-8')

s = "0"+s

lst1 = []

for i in range(len(s)):
    lst1.append(int(s[i]))

n = len(lst1)-1

res = 0

for i in range(n,-1,-1):
    if lst1[i] <= 4: #自分で払ったほうが良い
        res += lst1[i]
    elif lst1[i] == 5: #5の場合、その上の桁によって話が変わってくる
        if lst1[i-1] >= 5: #どうせ次の桁で多くなるなら
            res += 5 #おつりでもらって
            lst1[i-1] += 1 #次の桁を1枚多く払う
        else: #そうでないなら、素直にその桁は5枚払う。
            res += 5
    else: #お釣りをもらったほうが良い
        res += 10-lst1[i]
        lst1[i-1] += 1 #一個上の桁で払う金が一枚多くなる
print(res)



Measured memory_bytes: 114148
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,n,x=1,p=0;
cin>>a>>b>>n;
	x=min(b-1,n);
	p=(floor((a*x)/b)-a*floor(x/b));
	cout<<p<<endl;
	return 0;
}

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

using namespace std;

int n;
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
pii A[205];
int main(){
//	freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i = 0; i<n; i++){
		cin >> A[i].first.first >> A[i].first.second;
		A[i].second = 0;
	}
	for(int i = n; i<2*n; i++){
		cin >> A[i].first.first >> A[i].first.second;
		A[i].second = 1;
	}
	sort(A, A+2*n);
	set<int> guys;
	int ans = 0;
	for(int i = 0; i<2*n; i++){
//		printf("%d %d %d\n", A[i].first.first, A[i].first.second, A[i].second);
		if(A[i].second == 1){
			// blue
			auto guy = guys.upper_bound(A[i].first.second);
			if(guy == guys.begin()) continue;
			guy = prev(guy);
//			printf("removing %d\n", *guy);
			guys.erase(guy);
			ans++;
//			printf("%d blue\n", A[i].first.second);
		}else{
			guys.insert(A[i].first.second);
		}
	}
	cout << ans;
}

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

    public class Main {

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

            int mod = 1_000_000_000 + 7;
            int n = in.nextInt();
            long [] a = new long[n];
            long sum = 0;
            long[] suffix = new long[n + 1];
            for (int i = 0; i < a.length; i++) {
                a[i] = in.nextLong();
            }
            for (int i = a.length - 1; i >=0; i--) {
                suffix[i] = (sum + a[i])%mod;
                sum = suffix[i];
            }
            //out.println(Arrays.toString(suffix));
            sum = 0;
            for (int i = 0; i < a.length; i++) {
                sum = sum + (a[i]%mod * suffix[i + 1]%mod)%mod;
            }
            out.println(sum%mod);
            out.flush();
        }
        private static int gcd(int a, int b) {
            return b == 0 ? a : gcd(b,a%b);
        }
        private static void shuffle(int [] a) {
            for (int i = 0; i < a.length; i++) {
                int index = (int) (Math.random() * a.length);
                int temp = a[index];
                a[index] = a[i];
                a[i] = temp;
            }
        }
    }

    class InputReader extends BufferedReader {
        StringTokenizer tokenizer;

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

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

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

        public Integer nextInt() {
            return Integer.valueOf(next());
        }
        public Long nextLong() {
            return  Long.valueOf(next());
        }
        public Double nextDouble () {
            return Double.valueOf(next());
        }


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

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

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

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

Measured memory_bytes: 58584
N, M = map(int, input().split())
NUM = 10**9 + 7


if N-1 <= M <= N+1:
    ans = 1
    if N == M:
        for _ in range(2):
            for i in range(1, N+1):
                ans = ans * i % NUM
        ans = ans * 2 % NUM
    else:
        for i in range(1, N+1):
            ans = ans * i % NUM
        for i in range(1, M+1):
            ans = ans * i % NUM
else:
    ans = 0

print(ans)

Measured memory_bytes: 63168
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = list(map(int, input().split()))
# s = input()

a, b = list(map(int, input().split()))
ans = math.ceil((a + b) / 2)
print(ans)


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

int main()
{
    ll N;
    cin >> N;
    ll res = N;
    for(ll i = 1;i * i <= N;i++)if(N % i == 0){
        res = min(res, i + N / i - 2);
    }
    cout << res << endl;
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>>p(n);
    rep(i,n){
        int a,b; cin>>a>>b;
        p[i]=make_pair(b,a);
    }
    sort(p.begin(),p.end());
    int now=0;
    rep(i,n){
        now+=p[i].second;
        if(now>p[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1792
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
#define mk make_pair
using namespace std; const int N=400010, Mod=998244353;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,Q,sum[N<<2],flag[N<<2],pw[N];
int inv9;
inline int ksc(int x,int p) { int res=1; for(;p;p>>=1, x=x*x%Mod) if(p&1ll) res=res*x%Mod; return res; }
#define lc (x<<1)
#define rc (x<<1|1)
void Build(int x,int l,int r)
{
	if(l==r) { sum[x]=1; return; }
	int mid=(l+r)/2;
	Build(lc,l,mid), Build(rc,mid+1,r);
	sum[x]=sum[lc]*pw[r-mid]%Mod+sum[rc];
	sum[x]%=Mod;
}
inline void Push_Down(int x,int l,int r)
{
	int mid=(l+r)/2;
	sum[lc]=(pw[mid-l+1]-1+Mod)%Mod*flag[x]%Mod*inv9%Mod;
	//printf("LC : %lld\n",(pw[mid-l+2]-1)*inv9%Mod);
	sum[rc]=(pw[r-mid]-1+Mod)%Mod*flag[x]%Mod*inv9%Mod;
	//printf("RC : %lld\n",(pw[r-mid+1]-1)*inv9%Mod);
	flag[lc]=flag[x], flag[rc]=flag[x];
	flag[x]=0;
}
void UpDate(int u,int v,int l,int r,int x,int k)
{
	if(l>=u&&r<=v)
	{
		sum[x]=(pw[r-l+1]-1+Mod)%Mod*k%Mod*inv9%Mod;
		flag[x]=k;
		return;
	}
	int mid=(l+r)/2;
	if(flag[x]) Push_Down(x,l,r);
	if(u<=mid) UpDate(u,v,l,mid,lc,k);
	if(v>mid) UpDate(u,v,mid+1,r,rc,k);
	sum[x]=sum[lc]*pw[r-mid]%Mod+sum[rc], sum[x]%=Mod;
	
}
signed main()
{
	n=read(), Q=read();
	pw[0]=1, inv9=ksc(9,Mod-2);
	for(ri int i=1;i<=n;i++) pw[i]=pw[i-1]*10%Mod;
	Build(1,1,n);
	for(ri int i=1;i<=Q;i++)
	{
		int L,R,D;
		L=read(), R=read(), D=read();
		UpDate(L,R,1,n,1,D);
		printf("%lld\n",sum[1]);
	}
    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, b);
    map<int, int> table;

    int p = 0;
    table[p]++;
    rep(i, n) {
        Int(tmp);
        p += tmp;
        table[p]++;
    }

     int cnt = 0;
     for (auto i : table) {
         if (i.first > b) break;
         cnt += i.second;
     }

     std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 256
# 入力を受け取る
input_line = input()

# 入力データを分割する
input_list = input_line.split()
a = int(input_list[0])
b = int(input_list[1])
c = int(input_list[2])

if a < b and b < c:
    print("Yes")
else :
    print("No")


Measured memory_bytes: 5596
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int H, W; 
	char a[100][101], b[102][102];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < H + 2; i++) {
		for (int j = 0; j < W + 2; j++) {
			b[i][j] = '#';
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			b[i + 1][j + 1] = a[i][j];
		}
	}
	for (int i = 0; i < H + 2; i++) {
		for (int j = 0; j < W + 2; j++) {
			cout << b[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3648
#include <iostream>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
const int INF = 1000000;
int d[1000][1000];
char grid[1000][1001];
int main(){
  int H,W; cin >> H >> W;

  for(int i = 0;i < H;i++)cin >> grid[i];

  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      d[i][j] = INF;
    }
  }

  queue<pair<int,int>> que;
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      if(grid[i][j] == '#'){
        que.push(make_pair(i,j));
        d[i][j] = 0;
      }
    }
  }

  while(que.size()){
    pair<int,int> now = que.front();
    que.pop();

    int now_y = now.first;
    int now_x = now.second;

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

    for(int i = 0;i < 4;i++){
      int ny = now_y + dy[i];
      int nx = now_x + dx[i];
      if(0 <= nx && nx < W && 0 <= ny && ny < H && d[ny][nx] > d[now_y][now_x] + 1 && grid[ny][nx] != '#'){
        d[ny][nx] = d[now_y][now_x] + 1;
        que.push(make_pair(ny,nx));
      }
    }
  }

  int ans = 0;

  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      ans = max(ans,d[i][j]);
    }
  }

  cout << ans << endl;
}


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

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

using ll = long long;
using namespace std;

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

    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);

    cout << (s.size() == 2 ? "Yes" : "No") << endl;
}


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

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;

  int n = 1;

  while (true) {
    int tmp = Y * n + Z * (n + 1);
    if (tmp > X) {
      break;
    }
    n++;
  }
  cout << (n - 1) << endl;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

string s;

int a[26];

int main(void){
	cin>>s;

	for (int i = 0; i < 4; i++) {
		a[s[i] - 'A']++;
	}

	int cnt = 0;
	for (int i = 0; i < 26; i++) {
		if (a[i] == 2) cnt++;
	}

	if (cnt == 2) cout<< "Yes" <<endl;
	else cout<< "No" <<endl;



	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}
template<typename T1,typename T2> inline T1 gmax(T1 &a,T2 b){return a=a<b?b:a;}
template<typename T1,typename T2> inline T1 gmin(T1 &a,T2 b){return a=a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , __ = _<<1;

int to[__],ne[__],he[_]={0},ecnt=1;
inline void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
inline void addde(int a,int b){adde(a,b),adde(b,a);}

int n,dep[_],mxdep;

void dfs(int x,int ff)
{
	dep[x]=1;
	for(int i=he[x];i;i=ne[i])
		if(to[i]!=ff)dfs(to[i],x),gmax(mxdep,dep[x]+dep[to[i]]),gmax(dep[x],dep[to[i]]+1);
	gmax(mxdep,dep[x]);
}

int main()
{
	n=ty();
	for(int i=1,a,b;i<n;i++)a=ty(),b=ty(),addde(a,b);
	mxdep=0,dfs(1,0);
	puts(mxdep%3==2?"Second":"First");

	return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define lg2 std::__lg

const int N = 200054, LN = 18;

struct range {
	int l, r, v;
	range (int l_ = 0, int r_ = 0, int v_ = 0) : l(l_), r(r_), v(v_) {}
	inline bool operator < (const range &B) const;
	inline int fulfill() const;
};

int n;
int p[N], st[LN][N];
std::priority_queue <range> pq;

inline int min(const int x, const int y) {return p[x] < p[y] ? x : y;}

void build_sparse_table() {
	int *f, *g = *st, i, j, k = n;
	for (i = 0; i < n / 2; ++i) g[i] = i * 2, g[i + n / 2] = i * 2 + 1;
	for (j = 0; 1 << (j + 1) <= n; ++j) {
		f = g, g = st[j + 1], k -= 1 << j;
		for (i = 0; i < k; ++i)
			g[i] = min(f[i], f[i + (1 << j)]);
	}
}

inline int query(int L, int R) {int c = lg2(R - L); return min(st[c][L], st[c][R - (1 << c)]);}
inline bool range::operator < (const range &B) const {return p[v] > p[B.v];}
inline int range::fulfill() const {return l & 1 ? query((v + 1) / 2, (r + 1) / 2) : query((v + n) / 2, (r + n) / 2);}

inline void insert(int l, int r) {
	if (l == r) return;
	assert(!((l ^ r) & 1)), pq.emplace(l, r, l & 1 ? query((l + n) / 2, (r + n) / 2) : query(l / 2, r / 2));
}

int main() {
	int i, u, v, remain; range r;
	scanf("%d", &n), remain = n / 2;
	for (i = 0; i < n; ++i) scanf("%d", p + i);
	build_sparse_table();
	for (insert(0, n); !pq.empty(); )
		r = pq.top(), pq.pop(), u = r.v, v = r.fulfill(),
		printf("%d %d%c", p[u], p[v], --remain ? 32 : 10),
		insert(r.l, u), insert(u + 1, v), insert(v + 1, r.r);
	return 0;
}

Measured memory_bytes: 16892
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	long long kane = 1000;
	long long kabu = 0;
	bool kai = true;
	for (int i = 0;i < n;i++) {
		if (i == n - 1) {
			kane += kabu * a[i];
			kabu = 0;
		}
		else {
			if (kai) {
				if (a[i] < a[i + 1]) {
					kabu += (kane / a[i]);
					kane -= (kane / a[i]) * a[i];
					kai = false;
				}
			}
			else {
				if (a[i] > a[i + 1]) {
					kane += kabu * a[i];
					kabu = 0;
					kai = true;
				}
			}
		}
	}
	cout << kane << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s,t;
    cin>>s>>t;
    int ans=0;
    for (int i = 0; i < 3; i++)
    {
        if(s[i]==t[i]) ans++;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    s[K-1] += 32;

    cout << s << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

map<ll,ll> cnt;

int main(void){
	int n,m;
	cin >> n >> m;
	
	rep(i, n){
		ll aval;
		cin >> aval;
		cnt[-aval]++;
	}

	rep(i, m){
		ll b, c;
		cin >> b >> c;
		cnt[-c] += b;
	}

	ll rest = n;
	ll ans = 0LL;
	for(auto &elem:cnt){
		const ll num = min(rest, elem.second);
		rest -= num;
		ans -= 1LL * elem.first * num;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main(){
  string str,cnt;
  string code[32]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
  string alph=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string code2[32]={"00000","00001","00010","00011","00100","00101","00110","00111","01000","01001","01010","01011","01100","01101","01110","01111","10000","10001","10010","10011","10100","10101","10110","10111","11000","11001","11010","11011","11100","11101","11110","11111"};
  string alph2="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
  string ans,hm;
  while(getline(cin,str)){
    cnt="",ans="";
    for(int i=0,l=str.size();i<l;i++){
      for(int j=0;;j++){
	if(str[i]==alph[j]){
	  cnt += code[j];
	  break;
	}
      }
    }
    cnt += "0000";
    for(int i=0,l=cnt.size();i+5<=l;i+=5){
      hm=cnt.substr(i,5);
      for(int j=0;;j++){
	if(hm==code2[j]){
	  ans += alph2[j];
	  break;
	}
      }
    }
    cout << ans << endl;
  }
}

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


int main()
{
	map<string,string> m;
	m["ABC"]="ARC";
	m["ARC"]="ABC";
	string s;
	cin>>s;
	cout<<m[s]<<endl;
	return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int p=scan.nextInt();
		int[] x=new int[p];
		int[] y=new int[p];
		double sum;
		for(int i=0;i<p;i++){
			x[i]=scan.nextInt();
		}
		for(int i=0;i<p;i++){
			y[i]=scan.nextInt();
		}
		sum=0;
		for(int i=0;i<p;i++){
			sum+=Math.abs(x[i]-y[i]);
		}
		System.out.printf("%.6f\n",sum);
		sum=0;
		for(int i=0;i<p;i++){
			sum+=Math.pow(Math.abs(x[i]-y[i]),2);
		}
		System.out.printf("%.6f\n",Math.sqrt(sum));
		sum=0;
		for(int i=0;i<p;i++){
			sum+=Math.pow(Math.abs(x[i]-y[i]),3);
		}
		System.out.printf("%.6f\n",Math.cbrt(sum));
		sum=Math.abs(x[0]-y[0]);
		for(int i=1;i<p;i++){
			sum=Math.max(sum,Math.abs(x[i]-y[i]));
		}
		System.out.printf("%.6f\n",sum);
		scan.close();
	}

}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int V; // ????????° TODO:initialize
const int MAX_V = 100000; // ?????§???????????° TODO:initialize

vector<int> G[MAX_V]; // ??£??\???????????¨???
vector<int> child[MAX_V]; // DFS??¨????§???????????????????
bool vis[MAX_V];
int timer, root;
int prenum[MAX_V]; // DFS????¨???????
int parent[MAX_V]; // DFS????????£????????\?????¨??????
int lowest[MAX_V]; // DFS??¨??????????????????i??\????????????min(prenum)

bool ap[MAX_V]; // ??¢??????????????????

void dfs(int u, int prev)
{
    prenum[u] = timer;
    lowest[u] = timer;
    ++timer;

    vis[u] = true;

    rep(i,G[u].size())
    {
        int v = G[u][i];
        if(!vis[v])
        {
            parent[v] = u;
            child[u].pb(v);
            dfs(v,u);
            lowest[u] = min(lowest[u],lowest[v]);
        }
        else if(u!=prev)
        {
            lowest[u] = min(lowest[u], prenum[v]);
        }
    }
}

void detect_ap(int _root)
{
    memset(vis,0,sizeof(vis));
    root = _root;
    timer = 1;
    dfs(root,-1);

    memset(ap,0,sizeof(ap));
    rep(i,V)
    {
        if(i == root) ap[i] = (child[i].size()>=2);
        else
        {
            int par = parent[i];
            if(par != root) ap[par] |= (prenum[par] <= lowest[i]);
        }
    }
}

int main()
{
    int v,e;
    scanf(" %d %d", &v ,&e);
    while(e--)
    {
        int s,t;
        scanf(" %d %d", &s, &t);
        G[s].pb(t);
        G[t].pb(s);
    }

    V=v;
    detect_ap(0);

    rep(i,v)if(ap[i]) printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 10032
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,g,x,t=0,h,k=0,f,l=0,c=0;
    string s;
    map<char,int>m;
    cin>>s;
    for(int i = 0; i < 4; i++)
    {
       m[s[i]]++;

    }

    for(int i = 0; i < 4; i++)
    {
       if(m[s[i]]!=2)
       {
           c = 1;
           break;
       }
    }
    if(c==0)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }


}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,X=MI()
    L=LI()
    C=accumulate(L)
    ans = 1
    for c in C:
        if c <= X:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 64108
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())

sorted_A = sorted(A, reverse=True)

if N % 2 == 0:
    ans = sum(sorted_A[:(N - 2) // 2]) * 2 + sorted_A[(N - 2) // 2] - sorted_A[(N - 2) // 2 + 1] - sum(sorted_A[(N - 2) // 2 + 2:] * 2)
else:
    ans_a = sum(sorted_A[:(N - 2) // 2]) * 2 + sum(sorted_A[(N - 2) // 2: (N - 2) // 2 + 2]) - sum(sorted_A[(N - 2) // 2 + 2:]) * 2
    ans_b = sum(sorted_A[:(N - 1) // 2]) * 2 - sum(sorted_A[(N - 1) // 2: (N - 1) // 2 + 2]) - sum(sorted_A[(N - 1) // 2 + 2:]) * 2
    ans = max(ans_a, ans_b)
print(ans)


Measured memory_bytes: 46808
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
        
    // }
    ll n,k;
    cin>>n>>k;
    ll p[n],c[n];
    for(int i=0;i<n;i++)
    cin>>p[i];
    for(int i=0;i<n;i++)
    cin>>c[i];
    ll ans=-1e18;
    for(int i=0;i<n;i++)
    {
        vector<ll>pref;
        ll j=p[i]-1;
        while(j!=i)
        {
            if(pref.size()==0)
            pref.push_back(c[j]);
            else
            pref.push_back(pref[pref.size()-1]+c[j]);
            j=p[j]-1;
        }
        pref.push_back(pref[pref.size()-1]+c[j]);
        for(ll t=0;t<pref.size()&&t<k;t++)
        {
            ans=max(ans,pref[t]);
        }
        if(k>pref.size())
        {
            ll temp=k/pref.size();
            for(ll t=0;t<pref.size()&&t<k%pref.size();t++)
            {
                ans=max(ans,pref[pref.size()-1]*temp+pref[t]);
            }
            temp--;
            for(ll t=0;t<pref.size();t++)
            {
                ans=max(ans,pref[pref.size()-1]*temp+pref[t]);
            }   
        }
    }
    cout<<ans;
    
}

Measured memory_bytes: 3752
#include<iostream>
#include<vector>
#include<array>
#include<string>
#include<sstream>
#define _X_ 0
#define _Y_ 1
int main()
{
	while (true)
	{
		std::vector<std::array<int, 2>>p;
		p.reserve(4);
		for (int i = 0; i < 8; i++)
		{
			std::string temp;
			std::cin >> temp;
			std::stringstream st(temp);
			for (int j = 0; j < 8; j++)
			{
				char foo;
				st >> foo;
				if (foo == '1')
				{
					p.push_back({ j, i });
				}
			}
		}
		if (std::cin.eof())
		{
			break;
		}
		if (p[0][_Y_] == p[1][_Y_])
		{
			if (p[0][_X_] == p[2][_X_])
			{
				std::cout << 'A' << std::endl;
			}
			else if (p[0][_Y_] == p[2][_Y_])
			{
				std::cout << 'C' << std::endl;
			}
			else if (p[1][_X_] == p[2][_X_])
			{
				std::cout << 'E' << std::endl;
			}
			else if (p[0][_X_] == p[3][_X_])
			{
				std::cout << 'G' << std::endl;
			}
		}
		else
		{
			if (p[0][_X_] == p[3][_X_])
			{
				std::cout << 'B' << std::endl;
			}
			else if (p[0][_X_] > p[3][_X_])
			{
				std::cout << 'D' << std::endl;
			}
			else
			{
				std::cout << 'F' << std::endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    string str = "";

    while(n != 0) {
        int r = n % 2;
        if (r < 0) r += 2;

        n = (n - r) / (-2);

        str += (char)('0' + r);
    }

    reverse(str.begin(), str.end());
    if (str == "") str = "0";
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = set([int(input()) for i in range(m)])

mod = 10**9 + 7
dp = [0] * (n + 3)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
if 2 not in a:
    dp[2] = dp[0] + dp[1]
for i in range(3, n + 1):
    if i not in a:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print(dp[n] % mod)


Measured memory_bytes: 13192
import queue

N, K = map(int, input().split())
P = list(map(int, input().split()))

q = queue.Queue()

#arr = [(n+1)/2 for n in P]
mx = 0
s = 0

for i in range(N):
  s += P[i]+1
  q.put(P[i]+1)
  if q.qsize() > K:
    s -= q.get()
  if q.qsize() == K:
    mx = max(mx, s)

ans = mx/2
print(ans)


Measured memory_bytes: 78408