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

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    if (count(A.begin(), A.end(), X) == 0) {
        cout << X << endl;
        return 0;
    }
    for (int i = 0; i < 1000; i++) {
        if (count(A.begin(), A.end(), X-i) == 0) {
            cout << X-i << endl;
            return 0;
        }
        if (count(A.begin(), A.end(), X+i) == 0) {
            cout << X+i << endl;
            return 0;
        }
    }
    return 0;
}

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

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

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



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

void main() {
    auto tmp = readln.split.to!(int[]);
    auto H = tmp[0], W = tmp[1];
    string[] A;
    foreach (i; 0..H) {
        auto as = readln.chomp;
        if (as.all!(a => a == '.')) continue;
        A ~= as;
    }
    bool[] flags = new bool[W];
    foreach (i; 0..W) {
        flags[i] = A.all!(as => as[i] == '.');
    }
    foreach (i; 0..A.length) {
        foreach (j; 0..W) {
            if (flags[j]) continue;
            write(A[i][j]);
        }
        writeln;
    }
}



Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

int A, B;

int main() {
    cin >> A >> B;
    cout << A * B << endl;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+') cout << a + b << endl;
    else if(op == '-') cout << a - b << endl; 
    return 0;
}

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

signed main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  string S;
  cin >> S;
  
  string T = S;
  if( C < D ){
    //Bについて
    bool fg = true;
    bool mae = false;
    for( int i = B-1; i < N; i++ ){
      if( mae == true && S.at(i) == '#' ){
        fg = false;
        break;
      }else if( mae == false && S.at(i) == '#' ){
        mae = true;
      }
      if( S.at(i) == '.' ) mae = false;
      if( i == D-1 ){
        break;
      }
    }
    mae = false;
    for( int i = A-1; i < N; i++ ){
      if( mae == true && S.at(i) == '#' ){
        fg = false;
        break;
      }else if( mae == false && S.at(i) == '#' ){
        mae = true;
      }
      if( S.at(i) == '.' ) mae = false;
      if( i == C-1 ){
        break;
      }
    }
    if( fg == true ){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else if( C > D ){
    bool san = false; //追い抜くための3マスの空きがあるか
    bool fg = true;
    bool mae = false;
    for( int i = A-1; i < N; i++ ){
      if( B-1 <= i && i < D ){
        if( S.at(i-1) == '.' && S.at(i) == '.' && S.at(i+1) == '.' ) san = true;
      }
      if( mae == true && S.at(i) == '#' ){
        fg = false;
        break;
      }else if( mae == false && S.at(i) == '#' ){
        mae = true;
      }
      if( S.at(i) == '.' ) mae = false;
      if( i == C-1 ){
        break;
      }
    }
    if( fg == true && san == true ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 772
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using ll = long long int;
using namespace std;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    if (N & 1)
    {
        cout << "No" << endl;
        return 0;
    }
    string x, y;
    x = S.substr(0, N / 2);
    y = S.substr(N / 2, N);
    if (x == y)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        int n = Integer.parseInt(br.readLine());
        String[] str = br.readLine().split(" ");

        for (int i = n - 1; i >= 0; i--) {
            sb.append(str[i] + " ");
        }
        int a = sb.length();
        sb.deleteCharAt(a-1);
        System.out.println(sb);
    }
}

Measured memory_bytes: 24268
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#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 pi              pair<int,int>
#define pll             pair<ll,ll>
#define pb              push_back
#define F               first
#define S               second
#define vi              vector<int>
#define vll             vector<ll>
#define endl            '\n'
#define all(v)          (v).begin(),(v).end()
#define FOR(i,a,b)      for(int i=a;i<b;i++)
#define MP(a,b)         make_pair(a,b)
#define debug(x)        cerr<< #x << " : " << x << endl;
#define debugp(p)       cerr<< #p << " : " << "(" << (p).first << "," << (p).second << ")\n";
#define debugv(v)       cerr<< #v << " : " << "["; for(int i = 0; i < (v).size(); i++) cerr << v[i] << " "; cerr<<"]\n";
#define debugs(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<*itr << " "; cerr << "]\n";
#define debugm(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<"(" << itr->first << "," << itr->second << ") "; cerr << "]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
    int h , w;
    cin >> h >> w;
    vector<string> s (h + 1);
    for (int i = 1; i <= h; i++){
        cin >> s[i];
        s[i] = "$" + s[i];
    }
    const ll mod = 1e9 + 7;
    vector<vector<long long>> dp (h + 1, vector<long long> (w + 1 , inf));
    if (s[1][1] == '.')
        dp[1][1] = 1;
    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            if (i + 1 <= h && s[i + 1][j] != '#'){
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= mod;
            }
            if (j + 1 <= w && s[i][j + 1] != '#'){
                dp[i][j + 1] += dp[i][j];
                dp[i][j + 1] %= mod;
            }
        }
    }
    cout << dp[h][w] << endl;
}
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    #ifdef LOCAL
    cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
    #endif
}



Measured memory_bytes: 12184
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		boolean isAns = false;
		if (n % 10 == 9 || n / 10 == 9)
			isAns = true;
		
		System.out.println(isAns ? "Yes" : "No");
	}
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll dp[2020][2020];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    dp[0][0] = 1;

    ll N, M;
    cin >> N >> M;
    vector<ll> S(N), T(M);
    REP(i, N) cin >> S[i];
    REP(i, M) cin >> T[i];

    REP(i, N+1){
    	REP(j, M+1){
    		if(i<N){
    			dp[i+1][j] += dp[i][j];
    			dp[i+1][j] %= mod;
    		}
    		if(j<M){
    			dp[i][j+1] += dp[i][j];
    			dp[i][j+1] %= mod;
    		}
    		if(i<N && j<M && S[i]!=T[j]){
    			dp[i+1][j+1] -= dp[i][j];
    			dp[i+1][j+1] += mod;
    			dp[i+1][j+1] %= mod;
    		}
    	}
    }

    /*
    REP(i, N+1){
    	REP(j, M+1){
    		cout << dp[i][j] << " ";
    	}
    	cout << endl;
    }
    */
    
    cout << dp[N][M] << endl;
    return 0;
}

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

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

    int p, q, r;
    cin >> p >> q >> r;
    int a = p + q;
    int b = q + r;
    int c = r + p;

    cout << min(a, min(b, c)) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		while(true)
		{
			int m = stdIn.nextInt();
			int f = stdIn.nextInt();
			int r = stdIn.nextInt();
			
			if(m==-1 && f==-1 && r==-1)
			{
				break;
			}
			
			if(m==-1 || f==-1)
			{
				System.out.println('F');
			}
			else if((m+f)>=80)
			{
				System.out.println('A');
			}
			else if((m+f)>= 65)
			{
				System.out.println('B');
			}
			else if((m+f)>=50)
			{
				System.out.println('C');
			}
			else if((m+f)>=30)
			{
				if(r>=50)
				{
					System.out.println('C');
				}
				else
				{
					System.out.println('D');
				}
			}
			else
			{
				System.out.println('F');
			}
			
		}
	}

}

Measured memory_bytes: 19108
#include<bits/stdc++.h>
using namespace std;
int main(){
long n,m;
cin >> n >> m;
vector<int> l(m);
vector<int> r(m);
  for(long i=0;i<m;i++){
  cin >>l[i]>>r[i];}
sort(l.begin(),l.end());
sort(r.begin(),r.end());
  cout << max(0,r.at(0)-l.at(m-1)+1) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i, 4) {
    if(n % 10 == 2) ans++;
    n /= 10;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int a,b;
  while(cin>>a>>b){
  int cnt = 1;
  a += b;
  
  while(a/=10)cnt++;
  cout<<cnt<<endl;
}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, m, n) for(ll i = (ll)m; i < (ll)n; i++)
#define PER(i, m, n) for(ll i = (ll)m; i > (ll)n; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main() {
    int A, B, C, D, E, F, G, H, I;
    cin >> A >> B >> C >> D >> E >> F >> G >> H >> I;
    if (A - D == B - E &&
    B - E == C - F &&
    D - G == E - H &&
    E - H == F - I &&
    A - B == D - E &&
    D - E == G - H &&
    B - C == E - F &&
    E - F == H - I) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


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

long long int sum(long long int n){
  long long int p=0;
  while(n>0){
    p+=n%10;
    n/=10;
  }
  return p;
}

int main() {
  long long int n;
  cin>>n;
  if(n%sum(n)==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
          string[] line = Console.ReadLine().Split(' ');
          float A = float.Parse(line[0]);
          float B = float.Parse(line[1]);
		  for(int i = 1; i < (int)(100 / 0.08); i++)
          {
            if(((int)(i * 0.08) == A) && ((int)(i * 0.1) == B))
            {
            Console.WriteLine(i);
              return;
            }
          }
          
          Console.WriteLine("-1");
          
        }
    }
}


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

int main() {
	int n, m; cin >> n >> m;
	vector<int>a(m); for (auto&& x : a)cin >> x;
	sort(a.begin(), a.end());

	long long sum = 0; 
	if (n >= m);
	else {
		vector<int>dist;
		for (int i = 1; i < m; i++)dist.push_back(abs(a[i] - a[i - 1]));
		sort(dist.begin(), dist.end());
		for (int i = 0; i < m - n; i++) {
			sum += dist[i];
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1276
import java.util.Scanner;

/**
 * Go to School
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }

            int[] order = new int[N];
            for (int i = 0; i < N; i++) {
                order[A[i] - 1] = i + 1;
            }

            StringBuilder sb = new StringBuilder();
            sb.append(order[0]);
            for (int i = 1; i < N; i++) {
                sb.append(" ").append(order[i]);
            }
            System.out.println(sb.toString());
        }
    }

}


Measured memory_bytes: 51072
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    string S,T; cin >> S >> T;
    int t = 0;
    for(int k = N; k > 0;k--) {
        bool ok = true;
        for (int j = 0; j < k; j++) {
            if (S[N-k+j] != T[j]) ok = false;
        }
        if (ok) {
            t = k;
            break;
        }
    }
    


    cout << 2*N-t << endl;
}

Measured memory_bytes: 256
result=[]

while True:
	chk_list = input()

	if chk_list == "-":
		break

	num = int(input())
	for i in range(num):
		n = int(input())
		chk_list = chk_list[n:] + chk_list[0:n]

	result.append(chk_list)

[print(res) for res in result]




Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef tuple<int,int,int> TP;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    ll N;
    cin >> N;
    ll cnt = N;
    ll ret = 0;
    for(ll i = 2;i * i <= N;i++) {
        if(cnt % i == 0) {
            ll cnt2 = 0;
            while(cnt % i == 0) {
                cnt /= i;
                cnt2++;
            }
            ll cnt3 = 0;
            ll cnt4 = 1;
            while(true) {
                if(cnt2 < cnt3) {
                    ret += cnt4 - 2;
                    break;
                }
                cnt3 += cnt4;
                cnt4++;
            }
        }
    }
    if(cnt != 1) {
        ret++;
    }
    cout << ret << endl;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string a, b;
    ll d;
    cin >> a >> b;
    d = stoi(a + b);
    for(ll i = 1;i <= 1000;i++) {
        if(i * i == d) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;

// #define DEBUG

class Unionfind
{
    vector<int> p;

public:
    Unionfind(int n);
    int find(int x);
    void unite(int x, int y);
    bool match(int x, int y);
};

Unionfind::Unionfind(int n)
{
    for (int i = 0; i < n; i++)
    {
        p.push_back(i);
    }
}

int Unionfind::find(int x)
{
    while (p[x] != x)
    {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

bool Unionfind::match(int x, int y)
{
    return (find(x) == find(y)) ? true : false;
}

void Unionfind::unite(int x, int y)
{
    x = Unionfind::find(x);
    y = Unionfind::find(y);
    if (x != y)
    {
        p[x] = y;
    }
}

void printsubset(int x)
{
    int t;
    cout << x << ":";
    t = 0;
    while (x > 0)
    {
        if (x % 2 == 1)
            cout << " " << t;
        x /= 2;
        t++;
    }
    cout << endl;
}

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, q, t, x, op;
    cin >> n >> q;
    priority_queue<int> a[n];
    for (int i = 0; i < q; i++)
    {
        cin >> op;
        if (op == 0)
        {
            cin >> t >> x;
            a[t].push(x);
        }
        else if (op == 1)
        {
            cin >> t;
            if (!a[t].empty())
                cout << a[t].top() << endl;
        }
        else if (op == 2)
        {
            cin >> t;
            if (!a[t].empty())
                a[t].pop();
        }
    }

    return 0;
}



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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

//---------------------------

int main(){
    double t,x;
    cin >> t >> x;
    cout << setprecision(12) << t/x << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadLong;
            WriteLine(N / 11 * 2 + (N % 11 > 6 ? 2 : (N % 11 == 0 ? 0 : 1)));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(3 * n);
  rep(i, 3 * n) cin >> a[i];

  sort(a.rbegin(), a.rend());
  ll ans = 0;
  rep(i, n){
    ans += a[2*i+1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b&&b<c){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

   
    
    
    
    
        
}


Measured memory_bytes: 3084
def main():
	n = int(input())
	said = set()
	first = input()
	said.add(first)
	last = first[-1]
	is_shiritori = True
	for _ in range(n-1):
		word = input()
		if word in said or word[0] != last:
			is_shiritori = False
		said.add(word)
		last = word[-1]

	if is_shiritori:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;
int n;
long long a,b,h[100001],p[100001];
bool ok(long long x){
  long long sum=0;
  for(int i=0;i<n;i++){
    p[i]=h[i]-b*x;
    if(p[i]>0)
      sum+=(p[i]-1)/(a-b)+1;
    }
  if(sum<=x)
    return true;
  else
    return false;
  }
int main(){
  cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    cin>>h[i];
    }
  long long l=0,r=1<<30,mid;
  while(r-l>1){
    mid=(l+r)/2;
    if(ok(mid))
      r=mid;
    else
      l=mid;
    }
  cout<<r<<endl;
  return 0;
  } 

Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
S = sum(A)
dp = 1
for a in A:
    dp |= dp<<a
dp ^= dp&((1<<(-(-S//2))) - 1)
print((-dp&dp).bit_length() - 1)

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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

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

bool cmp(pair<int, int> a, pair<int, int> b){
  return a.second < b.second;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  vector<pair<int, int>> task(N);
  REP(i, N){
    cin >> A[i] >> B[i];
    task[i] = make_pair(A[i], B[i]);
  }
  sort(task.begin(), task.end(), cmp);
  int time = 0;
  bool flag = true;
  REP(i, N){
    time += task[i].first;
    if(time > task[i].second){
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>

int main(){
	int i,x,y;
	for(i=0;i<=1000000;i++){
		scanf("%d %d",&x,&y);
		if((x==0)&&(y==0)){
			break;
		}
		if(x==y){
			printf("%d %d\n",x,y );
		}
		else if(x<y){
			printf("%d %d\n",x,y );
		}
		else if(y<x){
			printf("%d %d\n",y,x );
		}
		}
	return 0;
}

Measured memory_bytes: 1028
import java.util.Arrays;
import java.util.Scanner;

public class Main 
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int N=1299709;
		boolean a[] = new boolean[N+1];
		Arrays.fill(a, true);
		a[0]=a[1]=false;
		for(int i=2; i*i<=N; i++)
		{
			if(!a[i])
				continue;
			for(int j=i*2; j<=N; j+=i)
			{
				a[j]=false;
			}
		}
	
		while(sc.hasNext())
		{
			int n=sc.nextInt();
			if(n==0)
				return;
			if(a[n]||n==1)
			{
			System.out.println(0);	
				continue;
			}
			int ans=0;
			
			for(int i=n+1; i<=N; i++)
			{
				if(!a[i])
					ans++;
				else
				{
					ans++;
					break;
				}
			}
			for(int i=n-1; i>=0; i--)
			{
				if(!a[i])
					ans++;
				else
				{
					ans++;
					break;
				}
			}
			System.out.println(ans);
		}
	}
}

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

using namespace std;

struct SegTree {
    vector<int> node;
    int n;
    SegTree(int sz) {
        n = 1;
        while (sz > n) n *= 2;
        node.resize(2 * n - 1, 0);
    }
    void add(int p, int x) {
        p += n-1;
        node[p] += x;
        while (p) {
            p = (p-1) / 2;
            node[p] += x;
        }
    }
    int get(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) {
            return node[k];
        }
        return get(a, b, k * 2 + 1, l, (l + r) / 2) + get(a, b, k * 2 + 2, (r + l) / 2, r);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    SegTree s(n);
    while (q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            s.add(x-1, y);
        } else {
            cout << s.get(x-1, y) << endl;
        }
    }
}


Measured memory_bytes: 3884
import sys
from operator import itemgetter

inf = 1<<30

def solve():
    while 1:
        N, M = map(int, sys.stdin.readline().split())

        if N == M == 0:
            return

        sect = [tuple(list(map(int, sys.stdin.readline().split()))) for i in range(N)]
        sect.sort(key=itemgetter(1), reverse=True)

        ans = 0

        for di, pi in sect:
            if di <= M:
                M -= di
            else:
                ans += (di - M) * pi
                M = 0

        print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 8900
#include<cstdio>

using namespace std;

int main(){
	int n, x;
	scanf("%d%d", &n, &x);
	if(x == 1 || x == 2 * n - 1){
		printf("No\n");
	}else{
		printf("Yes\n");
		for(int i = 0; i < 2 * n - 1; i++){
			printf("%d\n", (x - n + i + 2 * n - 1) % (2 * n - 1) + 1);
		}
	}
	return 0;
}

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

using namespace std;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    set<char> ss;
    for (auto el : s)
    {
        ss.insert(el);
    }
    if (ss.size() == 1)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> Graph(N);
  for(int i=0;i<M;i++){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    X--;
    Y--;
    Graph[X].push_back(Y);
    Graph[Y].push_back(X);
  }
  vector<bool> seen(N,false);
  stack<int> stack;
  vector<bool> complete(N,true);
  int ans=0;
  for(int j=0;j<N;j++){
    if(seen[j]==true){
      continue;
    }
    stack.push(j);
    while(!stack.empty()){
      int state=stack.top();
      seen[state]=true;
      stack.pop();
      for(int i:Graph[state]){
        if(seen[i]==true){
          continue;
        }
        seen[i]=true;
        stack.push(i);
      }
    }
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9528
#include <iostream>
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b==c||b+c==a||c+a==b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CppTest
//
//  Created by M_Sugawara on 2019/12/22.
//  Copyright © 2019 Sugawar. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a;
    int b;

    cin >> a >> b;

    if ((a == 1 && b == 2) || (a == 2 && b == 1)) {
        cout << 3;
    } else if ((a == 1 && b == 3) || (a == 3 && b == 1)) {
        cout << 2;
    } else {
        cout << 1;
    }

    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
using namespace std;
#define  LL long long

LL n,ans=0;
void dfs(LL x,int a,int b,int c)
{
	if(x>n) return;
	if(a+b+c==3) ans++;
	dfs(x*10+3,1,b,c);
	dfs(x*10+7,a,1,c);
	dfs(x*10+5,a,b,1);
}


int main()
{
	scanf("%lld",&n);
	dfs(0,0,0,0);
	printf("%lld\n",ans);


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
/**
 *    author:  dattrinh
 *    created:    Codeforces Round #635
**/
#define pb push_back
#define fi first
#define ss second
#define tp(x) fixed<<setprecision(x)
using namespace std;
using ll = int64_t;
const int N = 1000003;
ll t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n,k;
    cin>>n>>k;
    if(n<k)cout<<min(n,abs(n-k));
    else{
        n%=k;
        cout<<min(n,abs(n-k));
    }
    return 0;
}






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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  std::cin >> a;
  std::sort(a.begin(), a.end());
  int64_t count = 0;
  bool flag = false;

  for (int64_t i = 0; i < n; i++) {
    count++;
    int64_t j = 1;
    while (i + 1 < n && a[i] == a[i + 1]) {
      i++;
      j++;
    }
    if (j % 2 == 0) {
      flag = !flag;
    }
  }
  if (flag) {
    std::cout << count - 1 << std::endl;
  } else {
    std::cout << count << std::endl;
  }
  return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ++v[a];
  }
  sort(v.begin(), v.end(), greater<>());
  int temp = 0;
  for (int i = 0; i < k; ++i) {
    temp += v[i];
  }
  int ans = n - temp;
  cout << ans << endl;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main(void) {

  int n;
	scanf("%d", &n);
	int f[n][10];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			scanf("%d", &f[i][j]);
		}
	}
	long p[n][11];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 11; j++) {
			scanf("%ld", &p[i][j]);
		}
	}
	int bit[10];
	bit[0] = 1;
	for (int i = 0; i < 10; i++) {
		bit[i] = 0;
	}
	long max = 0;
	for (int i = 0; i < n; i++) {
		if (f[i][0] == 1) {
			max += p[i][1];
		} else {
			max += p[i][0];
		}
	}
	long profit;
	int common;
	while (1) {
		bit[0]++;
		for (int i = 1; i < 10; i++) {
			bit[i] += bit[i-1]/2;
			bit[i-1] %= 2;
		}
		if (bit[9] > 1) {
			break;
		}
		profit = 0;
		for (int i = 0; i < n; i++) {
			common = 0;
			for (int j = 0; j < 10; j++) {
				if (bit[j] == 1 && f[i][j] == 1) {
					common++;
				}
			}
			profit += p[i][common];
		}
		if (profit > max) {
			max = profit;
		}
	}
	printf("%ld\n", max);

  return 0;
}

Measured memory_bytes: 256
def func(len_a):
    ans = ""
    for i in range(1, len_a):
        if i & 1 == 0:
            ans += "0"
        elif i & 1 == 1:
            ans += "9"
    return ans

def main():
    a = input()
    len_a = len(a)
    if len_a & 1 == 0:
        ans = func(len_a)
        print(ans)
    else:
        if len_a == 1:
            print(a)
        else:
            ans = int(func(len_a-1))
            ans = ans + ( int(a) - 10 ** (len_a-1) ) + 1
            print(ans)


main()


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

int main(){

  string s;
  string t;

  cin >> s;
  cin >> t;

  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());

  if(s < t){
    cout << "Yes";
  }else{
    cout << "No";
  }

}

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

int n,k;
int a[200000];
int num[200000];
int balltype=0;

int main(){

    cin>>n>>k;

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

sort(a,a+n);

for(int i=0;i<n;i++){
    num[a[i]]+=1;
}

sort(num,num+n);

for(int i=n-1;i>=n-k;i--){
    balltype+=num[i];
}

cout<<(n-balltype)<<endl;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
        long n, k;
        cin >> n >> k;
        if( (n - 1) * (n-2) < k * 2){
                cout << -1 << endl;
                return 0;
        }
        int count = ( n - 1 ) * ( n-2 ) / 2 - k;
        cout << n - 1 + count << endl;

        // base
        for(int i=1;i<n;i++){
                cout << i << " " << n << endl;
        }

        // add
        for(int i=1;i< n;i++){
                for(int j=i+1;j<n;j++){
                        if(count <= 0 ){
                                goto LBL_LAST;
                        }
                        count--;
                        cout << i << " " << j << endl;
                }
        }

LBL_LAST:
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
               
using namespace std; 
#define MAX 2000001 
#define VMAX 10000 
               
int main() {   
  int C[VMAX + 1]; 
  int n; cin >> n; 
               
  int A[n + 1], B[n + 1]; 
  for (int i = 0; i <= VMAX; i++) C[i] = 0; 
  for (int i = 1; i <= n; i++) { // ここでi = 0からではなく1から入れるのがポイント 
    cin >> A[i]; 
    C[A[i]]++; 
  }            
  for (int i = 0; i < VMAX; i++) { 
    C[i + 1] += C[i]; 
  }            
  for (int i = 1; i <= n; i++) { 
    B[C[A[i]]] = A[i]; 
    C[A[i]]--; 
  }            
  for (int i = 1; i <= n; i++) { 
    if (i != 1) cout << " "; 
    cout << B[i]; 
  }            
  cout << endl;
               
  return 0;    
}   


Measured memory_bytes: 18748
#include<bits/stdc++.h>
#include<stdio.h>
#define PI acos(-1)
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define mem(a,b) memset(a,b,sizeof(a))
#define MX 1000005
#define MXX 2000005
//#define  s second
//#define f first
#define mod 1000000007
#define inf 1e9
#define err 1e9
//int ex[]={1,-1,0,0};
//int wye[]={0,0,1,-1};
using namespace std;
ll n,an[55],k,tmp;
int main()
{
    fast();
    scanf("%lld",&k);
    if(k==0){
        printf("2\n0 0\n");
        return 0;
    }
    if(k==1){
        printf("2\n0 2\n");
        return 0;
    }
    if(k<50){
        printf("%lld\n",k);
        for(ll i=1;i<=k;i++) printf("%lld ",i);
        return 0;
    }
    printf("50\n");
    tmp=k/50;
    for(ll i=1;i<=50;i++,tmp++) an[i]=tmp;
    tmp=k%50;
    for(ll i=50;tmp;i--,tmp--) an[i]++;
    for(ll i=1;i<=50;i++) printf("%lld ",an[i]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,e;
  static int n[26];
  char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  do{
    e = scanf("%c", &st);

    for(i=0;i<52;i++)
      if(al[i] == st){
        n[ i%26 ]++;
      }

  }while(e != EOF);

  for(i=0;i<26;i++)
    printf("%c : %d\n", al[i] , n[i]);

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
}

Measured memory_bytes: 3596
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    #define see(x) cout<<#x<<" = "<<x<<endl
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (ll x,ll n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x)%MOD,n/2)%MOD;
        else
        return (x%MOD*power((x*x)%MOD,(n-1)/2))%MOD; 
    }
         ll ans=0;
         ll z[64];
         ll o[64];
    int main()
    {   
         IOS;
         ll n,m,i,j,k;
         cin>>n;
         
         


         for(i=0;i<n;i++)
         {
           ll num;
           cin>>num;
           ll id=0;
           while(num!=0)
            {
              // ar[i][id]=num%2;
              if(num%2) o[id]++;
              else z[id]++;
              id++;
              num/=2;
            }
            for(j=id;j<64;j++)
              z[j]++;
         }
         // k+=2;
                
     
       
         for(j=0;j<64;j++)
         {
           // cout<<z[j]<<" "<<o[j]<<endl;
           ans= (ans+((z[j]*o[j])%MOD*power(2LL,j))%MOD)%MOD;
         }
         cout<<ans;
         
         cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
    }

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=n;i>=c;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

long long i, j, q;

int main() {
	IO;
	//ifstream cin("In.txt");
	ll n, m;
	string st;
	cin >> n;
	cin >> st;
	VEC cb(n + 1), cw(n + 1);
	f0(i,n){
		if (st[i] == '.') {
			cw[i+1] += cw[i]+1;
			cb[i + 1] += cb[i];
		}
		else {
			cb[i+1] += cb[i] + 1;
			cw[i + 1] += cw[i];
		}
	}
	ll ans = min(n - cb[n],n -cw[n]);
	f1(i, n) {
		ans = min(cb[i] + cw[n] - cw[i],ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;

const int MAX	= 1e5 + 5;
const int LIM	= 3e5 + 5;
const int MOD	= 1e9 + 7;
const LD  EPS	= 1e-10;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Assert(x)		{if(!(x)){cerr<<"Assertion failed at line "<<__LINE__<<": "<<#x<<" = "<<(x)<<"\n";exit(1);}}
#define inchar			getchar//_unlocked
#define outchar(x)		putchar(x)//_unlocked(x)

double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0;\
if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}\
while(n);i=i-1;while(i>=0)outchar(snum[i--]);outchar('\n');}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){\
str[i]=c;c=inchar();++i;}str[i]='\0';}
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){LL res=(LL)a*b;return(res>=c?res%c:res);}
LL mulmod(LL a,LL b, LL m){LL q = (LL)(((LD)a*(LD)b)/(LD)m);LL r=a*b-q*m;if(r>m)r%=m;if(r<0)r+=m;return r;}
template<typename T>T expo(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}

int main() {

	string s;cin>>s;
	int result=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='+')
			result++;
		else
			result--;
	}
	cout<<result<<"\n";
	// cout<<"Execution time : "<<tick()<<"\n";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = [int(_) for _ in input().split()]

d = [h[i] - h[i+1] for i in range(n-1)]
c = 0
tmp = 0

for i in range(n-1):
  if d[i] >= 0:
    tmp += 1
  else:
    if tmp > c:
      c = tmp

    tmp = 0

print(max(tmp, c))

Measured memory_bytes: 14252
r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 1..r                                       # 変数 i を1からrまで増やして繰り返し処理する。
    
a= gets.split.map(&:to_i)
    for j in 1..c                                   # 変数 i を1からcまで増やして繰り返し処理する。
    h[i-1][j-1] = a[j-1]
    h[i-1][c] += a[j-1]
    h[r][j-1] += a[j-1]
    h[r][c] += a[j-1]
    end
end
for i in 0..r
    for j in 0..c
      print " " unless j == 0
      print h[i][j]
    end
    puts
  end



Measured memory_bytes: 7032
from fractions import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = (pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2) % MOD
print(pow(ans, ga*gb, MOD))


Measured memory_bytes: 292256
from collections import *

def bfs():
    q = deque([0])
    visited = [False]*N
    visited[0] = True
    
    while q:
        v = q.popleft()
        
        for nv in range(N):
            if G[v][nv]==1:
                if not visited[nv]:
                    visited[nv] = True
                    q.append(nv)
    
    return False in visited
    
N, M = map(int, input().split())
G = [[0]*N for _ in range(N)]
edges = []

for _ in range(M):
    a, b = map(int, input().split())
    G[a-1][b-1] = 1
    G[b-1][a-1] = 1
    edges.append((a-1, b-1))

ans = 0

for a, b in edges:
    G[a][b] = 0
    G[b][a] = 0
    
    if bfs():
        ans += 1
    
    G[a][b] = 1
    G[b][a] = 1

print(ans)

Measured memory_bytes: 39792
a = [int(s) for s in input().split()]
N = a[0]
si = a[1]
ti = a[2]
s = [int(input()) for i in range(N)]
s = sorted(s)
X = int(0)
ans = int(0)

#全員乗るまで繰り返す
while N != X:
    #まずバスを用意して先頭を乗せる
    X += 1 
    ans += 1
    #この時点で全員乗ったら終わりにする
    if N == X:
        break
    #バスの残りsi-1枠に乗れるだけ乗せる
    #そもそも乗客がsi-1人もいない場合は残りのN-X人が上限
    temp = X
    for i in range(min([si-1,N-X])):
        if s[temp + i] <= s[temp-1] + ti:
            X += 1
        else:
            break

print(ans)

Measured memory_bytes: 14080