akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

long gcd(long a, long b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main(){
    long n,x;
    cin >> n >> x;
    vector <long> place(n),dec(n);
    rep(i,n){
        cin >> place[i];
        dec[i] = abs(place[i] - x);
    } 

    if(n==1){
        cout << dec[0] << endl;
        return 0;
    }

    long ans=gcd(dec[0],dec[1]);
    for(int i=0; i<n; i++){
        ans = gcd(ans,dec[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
a = int(input())
cnt = 1
if a == 1 or a == 2:
  print('4')
else:
  while a >=3:
    if a % 2 == 0 and a != 4:
      a = a//2 
      cnt += 1
    elif a % 2 != 0:
      a = 3*a + 1
      cnt += 1
    elif a == 4:
      break
  print(cnt+3)

Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();

    if(a*b %2 == 0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N;
  cin>>N;
  vector<double> x(N);
  
  for(int i=0; i<N; i++){
    cin>>x.at(i);
  }
  
  sort(x.begin(), x.end());
    
  double q,w,e;
  
  w=x.at(0)/2;
  e=x.at(1)/2;
    
  q=w+e;  
    
  for(int i=2; i<N; i++){
    
    w=x.at(i)/2;
    e=q/2;
    
    
    q=w+e;
  }
  
  cout<<q<<endl;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <set>
using namespace std;

typedef pair<int,int> P;

int main(int argc, char const *argv[]) {
  int n;cin>>n;
  vector<long long> a(3*n);
  for(int i=0;i<3*n;++i)cin>>a[i];
  sort(a.begin(),a.end());
  long long res=0;
  for(int i=0;i<n;++i){
    res+=a[3*n-2-2*i];
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 2560
n = int(input())
s = "abcdefghijklmnopqrstuvwxyz"
for i in range(n):
    inp = input()
    for j in range(26):
        for k in range(26):
            out = ""
            for c_inp in inp:
                if c_inp in s:
                    out += s[(s.index(c_inp)*j+k)%26]
                else:
                    out += c_inp
            if ("that" in out) or ("this" in out):
                print(out)




Measured memory_bytes: 5596
#include <stdio.h>
#include <math.h>

int main(void) {
    //code goes 
	int a,b,mul,root,bdig;
	scanf("%d %d",&a,&b);
	if(b<10)    bdig=10;
	else if(b<100)  bdig=100;
	else bdig=1000; 
	mul=a*bdig+b; 
	root = (int) sqrt(mul);
	if(root*root==mul) 
	    printf("Yes");
	else       
	    printf("No");
	return 0;
}



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

using namespace std;

int main(int argc, char const *argv[]) {
	int a,b;
	std::cin >> a >> b;
	if ((a*b)%2 == 1) {
		std::cout << "Odd" << '\n';
	}
	else {
		std::cout << "Even" << '\n';
	}
	return 0;
}


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

int main(){
	int N,M,p;
	cin>>N>>M>>p;
	
	int d[100001];
	d[0]=p;

	for(int i=1;i<=M;i++)
		cin>>d[i];

	sort(d,d+M+1);

	int c_min=N-1;

	for(int i=0;i<M+1;i++){
		int q=d[i];
		int r1=d[(i-1+M+1)%(M+1)];
		int r2=d[(i+1)%(M+1)];

		int c1=((p-q+N)%N)*2+(r1-p+N)%N;
		int c2=((q-p+N)%N)*2+(p-r2+N)%N;

		c_min=min(c_min,min(c1,c2));
	}

	cout<<c_min*100<<endl;

	return 0;
}
	
	

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

int main(){
    long long n, d = 1;
    string s = "";
    cin >> n;
    if(n == 0){
        cout << 0;
    }else{
        while(n != 0){
            if(n%abs(d*2) != 0){
                s = "1" + s;
                n -= d;
            }else{
                s = "0" + s;
            }
            d *= -2;
        }
        cout << s;
    }
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for(int 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++)
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    ll a,b,c,x,y, ans=0, more_pizza,buy_pizza,cost;
    scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&x,&y);
    if(c*2<=a+b){
        buy_pizza = min(x,y);
        ans += c * buy_pizza * 2;
        more_pizza = max(x,y) - buy_pizza;
        if(max(x,y) == x){// aの方がたくさん買いたい
            cost = min(a,2*c);
            if(cost == a) ans += a*more_pizza;
            else ans += c* 2* more_pizza;
        }
        else{
            cost = min(b,2*c);
            if(cost == b) ans += b*more_pizza;
            else ans += c* 2* more_pizza;
        }
    }
    else{
        ans = a*x+b*y;
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 3824
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int arr[n];
    int parity=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]%2==0)
            parity++;
    }
    if(parity==n)
        cout<<"second";
    else
        cout<<"first";

}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K ,Q;
    int res=0,a;
    cin >> N >> K >> Q;
    vector<int> A(N);

    for (int i = 0; i < N; i++) {
        A.at(i) = K-Q;
    }

    for (int i = 0; i < Q; i++) {
        cin >> a;
        A.at(a-1)++;
    }

    for (int i = 0; i < N; i++) {
        if(A.at(i)>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

int main(){
    long long int N;
    cin >> N;
    //cerr << (double)4/3485 << endl;
    long long int ansh=0,ansn=0,answ=0;
    for(long long int h= 1;h<=3500;h++){
        bool flag = false;
        for(long long int n = 1;n<=3500;n++){
            if((4*h*n-N*n-h*N) == 0LL) continue;
            if((N * h * n) % (4 * h * n - N * (n + h)) ) continue;
            long long int w = N*h*n/(4*h*n-N*n-h*N);
            if(w > 0){
                ansh = h;
                ansn = n;
                answ = w;
                flag = true;
                break;
            }
        }
        if(flag) break;
    }


    cout << ansh << " " << ansn << " " << answ<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " ";
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    map<string, int> m;
    while(t--)
    {
        string s;
        cin >> s;
        m[s]++;
    }    
    out("AC x")
    outline(m["AC"])
    out("WA x")
    outline(m["WA"])
    out("TLE x")
    outline(m["TLE"])
    out("RE x")
    outline(m["RE"])
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int N;
	cin >> N;
	
	int a;
	int v_odd = 0;
	int v_four = 0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a % 2 == 1) {
			v_odd += 1;
		}
		else if (a % 4 == 0) {
			v_four += 1;
		}
	}

	if ((v_four + N % 2) >= v_odd) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>


using namespace std;

int main(){

	/*Q1*/
	int ret = 0;
	int in = 0;

	cin >> in;

	for (int i = 0; i < 4; ++i){
		if (in % 10 == 2){
			ret++;
		}
		in /= 10;
	}

	cout << ret;

	/*Q2*/
	
	/*Q3*/
	
	/*Q4*/

	return 0;
	
}


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

int main() {
  int N, K; cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  int answer = 0;
  for (auto&& x : h) {
    if (x >= K) answer++;
  }
  cout << answer;
}

Measured memory_bytes: 640
#include <iostream>

int main(){
  std::string S,T;
  std::cin>>S>>T;
  int max = 0;
  for (int i = 0; i < S.size()-T.size()+1; i++){
    int counter = 0;
    for (int j = 0; j < T.size(); j++)
      if (S[i+j]==T[j]) counter++;
    if (max<counter) max = counter;
  }
  std::cout<<T.size()-max<<std::endl;
}

Measured memory_bytes: 3580
import sys


def main() -> None:
    n = int(sys.stdin.readline())
    a = [0] * n
    b = [0] * n
    ans = 0

    for i in range(n):
        a[i], b[i] = map(int, sys.stdin.readline().split())

    for i in range(n - 1, -1, -1):
        a[i] += ans
        if a[i] % b[i] != 0:
            ans += abs(a[i] % b[i] - b[i])

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14836
fun main(args: Array<String>) = abc160c()

fun abc160c() {
    val (k, n) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val diff = LongArray(n)
    diff[0] = k - aList.last() + aList.first()

    for (i in 0 until n - 1) {
        diff[i + 1] = aList[i + 1] - aList[i]
    }

    val answer = diff.sum() - diff.max()!!

    println(answer)
}


Measured memory_bytes: 82920
#include<iostream>

using namespace std;

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

const int INF = 1000000000;
int n;
string a[10], b[10], c, d;

bool hit(string c, int k) {
  rep (i, c.size() - a[k].size() + 1) if (c.substr(i, a[k].size()) == a[k]) return true;
  return false;
}

string sed(string c, int k) {
  string res;
  rep (i, c.size()) {
    if (i + a[k].size() <= c.size() && c.substr(i, a[k].size()) == a[k]) {
      res += b[k];
      i += a[k].size() - 1;
    } else {
      res += c[i];
    }
  }
  return res;
}

int solve(string c) {
  if (c == d) return 0;
  if (c.size() >= d.size()) return INF;
  int res = INF;
  rep (i, n) if (hit(c, i)) res = min(res, solve(sed(c, i)) + 1);
  return res;
}

int main() {
  while (cin >> n, n) {
    rep (i, n) cin >> a[i] >> b[i];
    cin >> c >> d;
    int s = solve(c);
    if (s == INF) s = -1;
    cout << s << endl;
  }
  return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

/*
class Compare
{
  public:
    bool operator()(pi a,pi b)
    {
      if(a.first<b.first || (a.first==b.first && a.second>b.second))
        return true;
      return false;
    }
};
*/

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll cur = n / 1000;
	if (n % 1000 == 0) {
		cout << 0 << endl;
	}
	else {
		ll ans = (cur + 1) * 1000 - n;
		cout << ans << endl;

	}
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/





























Measured memory_bytes: 3648
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back

using namespace std;
using ll=long long;
// using ll=int;

const ll mod = (ll)(1e9+7);

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

int main(){

    /*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("myoutput.txt", "w", stdout);
    #endif
    */

    fast;
    ll t = 1;
    // cin >> t;
    while(t--){
        ll n; cin >> n;
        ll _max = INT_MIN;
        map<string, ll> vote_paper;
        for(ll i = 0; i < n; i++){
            string s; cin >> s;
            vote_paper[s]++;
        }
        for(auto i : vote_paper) {
            if(i.second >= _max){
                _max = i.second;
            }
        }

        for(auto i : vote_paper) {
            // cerr << i.first << ' ' << i.second << endl;
            if(i.second >= _max){
                cout << i.first << endl;
            }
        }
    }
    // cerr << (double)clock()/CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 23808
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define MP_ make_pair
#define PB_ push_back
#define UB_ upper_bound
#define LB_ lower_bound
#define PQ_ priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/









int main()
{
  //IOS; /* making cin faster */
  lli N,K;

  SCANLLD2(N,K);
  
  if( K % 2 )
    {
      
      printf("%lld\n" ,(N/K) * (N/K) * (N/K) );
      
    }
  else
    {
      printf("%lld\n", (N/K) * (N/K) * (N/K) + ((N + (K/2))/K) *  ((N + (K/2))/K) *  ((N + (K/2))/K));
    }
  
  

}


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

int main()
{
  int K, x, y; 
  cin>>K;
  long long int sum=0;
  for(int i=1; i<=K; i++)
  {
    for(int j=1; j<=K; j++)
    {
      x=__gcd(i,j);
      for(int k=1; k<=K; k++)
      { 
        y=__gcd(x,k);
        sum+=y;
      }
    }
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int N = 505;
char a[N][N];
char b[N][N];
char c[N][N];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf(" %s",a[i]+1);
        for(int j=1;j<=m;j++)   b[i][j]=a[i][j],c[i][j]=a[i][j];
        if(i==1||i==n)  continue;
        b[i][1]='#',c[i][m]='#';
        if(i%2) for(int j=2;j<=m-1;j++) b[i][j]='#';
        else    for(int j=2;j<=m-1;j++) c[i][j]='#';
    }
    for(int i=1;i<=n;i++)   printf("%s\n",b[i]+1);
    printf("\n");
    for(int i=1;i<=n;i++)   printf("%s\n",c[i]+1);
    return 0;
}
/*
5 5
.....
..#..
.#.#.
..#..
.....
*/


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <bitset>
#include <fstream>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair <int, int>
#define pll pair <long long, long long>
#define vi vector <int>
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

const int n = 50;

ll a[n], k, rest, t;

void make_op()
{
	int id = -1;
	int mx = -100;
	for(int i = 0; i < n; i++)
		if(a[i] > mx)
		{
			mx = a[i];
			id = i;
		}
	a[id] -= (n + 1);
	for(int i = 0; i < n; i++)
		a[i]++;
}

int main()
{
	ios:: sync_with_stdio(false);
	cin >> k;
	t = (k + n - 1) / n;
	for(int i = 0; i < n; i++)
		a[i] = t + i;
	rest = n * t - k;
	for(int i = 0; i < rest; i++)
		make_op();
	cout << n << endl;
	for(int i = 0; i < n; i++)
		cout << a[i] << " ";
	return 0;
}


Measured memory_bytes: 256
// unihernandez22
// https://atcoder.jp/contests/abc150/tasks/abc150_a
// implementation

import std.stdio;

void main() {
	int k, x;
	"%s %s\n".readf(&k, &x);
	if (500 * k >= x)
		writeln("Yes");
	else
		writeln("No");
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
int dp[305][305],cost[305][305];//dp[i][j]:xをi、yをj沈めるのにかかる最小コスト　cost[i][j]:xがi、yがj沈んでる時の摩擦
int H,W,ans;
std::vector<string> s(300);
void init_(){
  for(int i=0;i<305;i++)for(int j=0;j<305;j++)dp[i][j]=LINF;
  dp[0][0]=0;
}
int f(int right){
  int x=right-1,y=right;
  init_();
  for(int i=0;i<H;i++){//cost[0][i]とcost[i][0]を求める
    int res=0,res2=0;
    for(int j=0;j<H-i;j++)res+=(s[H-1-j][x]==s[H-1-j-i][y]);cost[0][i]=res;
    for(int j=0;j<H-i;j++)res2+=(s[H-1-j-i][x]==s[H-1-j][y]);cost[i][0]=res2;
  }
  for(int i=0;i<H;i++){
    for(int k=1;k+i<=H;k++){//cost[k][k+i]とcost[k+i][i]を求める
      cost[k][k+i]=cost[k-1][k+i-1]-(s[H-k][x]==s[H-(k+i)][y]);
      cost[k+i][k]=cost[k+i-1][k-1]-(s[H-(k+i)][x]==s[H-k][y]);
    }
  }
  for(int i=0;i<=H;i++){
    for(int j=0;j<=H;j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]+cost[i][j]);
      dp[i][j+1]=min(dp[i][j+1],dp[i][j]+cost[i][j]);
    }
  }
  return dp[H][H];
}
//main
signed main(){
  cin>>H>>W;
  for(int i=0;i<H;i++)cin>>s[i];
  for(int j=1;j<W;j++)ans+=f(j);
  cout<<ans<<endl;
}


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

int main()
{
	int S,h,m,s;//S:秒単位、h:時間、m:分、s:秒
	cin >> S;
	h = S / 3600;//3600秒で一時間
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;

	cout << h << ":" << m << ":" << s<<endl;
    return 0;
}


Measured memory_bytes: 3076
#include <cctype>
#include <functional>
#include <iostream>
#include <string>

using namespace std;

struct Node {
    int value = 0;
    Node* left = nullptr;
    Node* right = nullptr;
    Node(int v, Node* l, Node* r)
        : value{v}
        , left{l}
        , right{r}
    {
    }
};

int main()
{
    string a;
    cin >> a;
    string b;
    cin >> b;

    auto parse = [](const string& str) {
        int i = 0;
        auto value = [&i, &str]() {
            auto begin = i;
            while (isdigit(str[i])) {
                ++i;
            }
            auto end = i - 1;
            return stoi(str.substr(begin, end - begin + 1));
        };

        function<Node*()> p = [&p, &i, &str, &value]() -> Node* {
            if (str[i] == ')') {
                return nullptr;
            }
            ++i; // (
            auto l = p();
            ++i; // )
            ++i; // [
            auto v = value();
            ++i; // ]
            ++i; // (
            auto r = p();
            ++i; // )
            return new Node{v, l, r};
        };
        return p();
    };

    function<void(Node*)> pp = [&pp](Node* n) {
        if (n) {
            cout << "(";
            pp(n->left);
            cout << ")";
            cout << '[' << n->value << ']';
            cout << "(";
            pp(n->right);
            cout << ")";
        }
    };

    function<Node*(Node*, Node*)> f = [&f](Node* l, Node* r) {
        auto ll = l->left && r->left ? f(l->left, r->left) : nullptr;
        auto rr = l->right && r->right ? f(l->right, r->right) : nullptr;
        return new Node{l->value + r->value, ll, rr};
    };

    auto t1 = parse(a);
    auto t2 = parse(b);
    auto r = f(t1, t2);
    pp(r);
    cout << endl;
}

Measured memory_bytes: 3240
import math

n, h = map(int, input().split())
A = []
B = []
c = 0
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

amax = max(A)
B = list(filter(lambda x: x > amax, B))
B.sort()

while h > 0:
    if B:
        tmp = B.pop()
        h -= tmp
        # print("威力", tmp, "の刀を投げました")
        c += 1
    else :
        c += math.ceil(h / amax)
        # print("威力", amax, "の刀で", math.ceil(h / amax), "回斬りました")
        break
print(c)


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

int main() {
	ios_base::sync_with_stdio( false );

	string S;
	cin >> S;

	int result = 0;
	for( int i = 0; i < S.size(); ++i ) {
		result += (S[i] == '+') ? 1 : -1;
	}

	cout << result << endl;
	return 0;
}


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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=2e5+5;
int h[N];
ll tree[4*N],a[N];
ll mx;

void update(int v,int tl,int tr,int pos){
	if(tl==tr){
		tree[v]=mx;
		return;
	}
	int tm=(tl+tr)/2;
	if(tm>=pos){
		update(v*2,tl,tm,pos);
	}
	else{
		update(v*2 +1,tm+1,tr,pos);
	}
	tree[v]=max(tree[v*2],tree[v*2 +1]);
}

ll getmax(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return 0;
    if (l <= tl && tr <= r){
        return tree[v];
    }
    int tm = (tl + tr) / 2;
    return max(getmax(v*2, tl, tm, l, min(r, tm)), getmax(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void solve(){
	int n;
	cin>>n;
	fr(i,0,n){
		cin>>h[i];
	}
	fr(i,0,n){
		cin>>a[i];
	}
	ll ans=0;
	fr(i,0,n){
		mx=getmax(1,1,n,1,h[i])+a[i];
		update(1,1,n,h[i]);
		ans=max(mx,ans);
	}
	cout<<ans<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 10084
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,sum=0;
    cin>>n;
    int arr[n];
    for (i=0;i<n;i++)
        cin>>arr[i];
    for (i=0;i<n;i++)
    {
        for (j=i+1;j<n;j++)
            sum+=arr[i]*arr[j];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 100005;
const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;

int n;
int a[maxn];

int solve(int num)
{
    int cnt=0;
    while(num%2==0)
    {
        cnt++;
        num/=2;
        if(cnt>=2) break;
    }
    return cnt;
}

int main()
{
    while(~scanf("%d",&n))
    {
        int ans0=0,ans1=0,ans2=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            int xx=solve(a[i]);
            if(xx==0) ans0++;
            else if(xx==1) ans1++;
            else ans2++;
        }
        /*if(ans2==0&&ans0==0)
        {
            puts("Yes");
            continue;
        }*/
        if(ans0==0)
        {
            puts("Yes");
            continue;
        }
        if(ans1)
        {
            if(ans0<=ans2)
            {
                puts("Yes");
            }
            else puts("No");
        }
        else 
        {
            if(ans0<=ans2+1)
            {
                puts("Yes");
            }
            else puts("No");
        }
    }
    return 0;
}


Measured memory_bytes: 512
i = list(map(int, input().split()))

if i[0] == i[1] and i[0] != i[2] and i[1] != i[2]:
	print('Yes')
elif i[0] != i[1] and i[0] == i[2] and i[1] != i[2]:
	print('Yes')
elif i[0] != i[1] and i[0] != i[2] and i[1] == i[2]:
	print('Yes')
elif i[0] != i[1] and i[0] != i[2] and i[1] != i[2]:
	print('No')
elif i[0] == i[1]  == i[2]:
	print('No')
	

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

using namespace std;

long long a, v1, b, v2, t, v;

int main() {
    cin >> a >> v1 >> b >> v2 >> t;
    v = v1 - v2;
    long long d = abs(a - b);
    if (v > 0 && (d + v - 1) / v <= t) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
def resolve():
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

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

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

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

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

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

    n, m = map(int, input().split())
    s = [j for j in range(n)]
    uf=UnionFind(n)
    for _ in range(m):
        a,b  = map(int, input().split())
        a-=1
        b-=1
        uf.union(a,b)

    ans=0
    for i in range(n):
        ans=max(uf.size(i),ans)
    print(ans)
resolve()

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

int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
}

// BFS のためのデータ構造
vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
queue<int> que;

vector<int> answer(N, 0);
  
// 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            answer.at(nv) = v + 1;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    bool error = false;
    for (int v = 1; v < N; ++v){
        if(answer.at(v) == 0) error = true;
    }
    if(error == true) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        for (int v = 1; v < N; ++v){
            cout << answer[v] << endl;
        }
    }
    
}

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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<ll int,ll int>
#define pb push_back
#define ppb pop_back
#define vi vector<ll int>


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		int ans = ceil((float)n/2);
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 256
/* Name of the class has to be "Main" only if the class is public. */
import java.util.Scanner;
import java.util.Arrays;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int [] x = new int[10];
		
		Scanner cin = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
     		x[i] = cin.nextInt();
		}
		
		Arrays.sort(x);
		
		for (int i = 9; i >= 7; i--) {
			 System.out.println(String.valueOf(x[i]));
		}
	}
}

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

    int n,w;
    cin>>n>>w;
    int wt[n],val[n];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    long long int dp[w+1][n+1];
    for(int i=0;i<=w;i++)
     fill(dp[i],dp[i]+n+1,0);
     for(int i=0;i<=w;i++)
     {
         for(int j=1;j<=n;j++)
         {
             if(i-wt[j-1]>=0)
             {
                 dp[i][j]=max(dp[i][j],dp[i-wt[j-1]][j-1]+val[j-1]);
                
                
             }
            dp[i][j]= max(dp[i][j],dp[i][j-1]);
         }
     }
      
    
    cout<<dp[w][n]<<endl;

}

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

int shape(int h, int w);

int shape(int h, int w)
{
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << "#";
        }
        cout << endl;
    }
    cout << endl;
}

int main()
{
    int n = 10000;
    int array[n][2];
    int cnt;
    for (int i = 0; i < n; i++)
    {
        cin >> array[i][0] >> array[i][1];
        if (array[i][0] == 0 && array[i][1] == 0)
        {
            cnt = i;
            break;
        }
    }
    for (int i = 0; i < cnt; i++)
    {
        shape(array[i][0],array[i][1]);
    }
}


Measured memory_bytes: 3124
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Collections;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC081D solver = new ABC081D();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC081D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int[] targetPos = new int[2];
            targetPos[0] = in.nextInt();
            targetPos[1] = in.nextInt();
            LinkedList<Integer> xList = new LinkedList<Integer>();
            LinkedList<Integer> yList = new LinkedList<Integer>();

            int count = 0;
            boolean turnX = true;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'F') count++;
                else if (turnX) {
                    xList.add(count);
                    count = 0;
                    turnX = false;
                } else {
                    yList.add(count);
                    count = 0;
                    turnX = true;
                }
            }
            if (turnX) {
                xList.add(count);
            } else {
                yList.add(count);
            }

            int[] pos = {xList.get(0), 0};
            xList.remove(0);
            Collections.sort(xList);
            Collections.sort(yList);

            for (int i = xList.size() - 1; i >= 0; i--) {
                int cn = xList.get(i);
                if (pos[0] < targetPos[0]) pos[0] += cn;
                else pos[0] -= cn;
            }
            for (int i = yList.size() - 1; i >= 0; i--) {
                int cn = yList.get(i);
                if (pos[1] < targetPos[1]) pos[1] += cn;
                else pos[1] -= cn;
            }

            String ans = (pos[0] == targetPos[0] && pos[1] == targetPos[1]) ? "Yes" : "No";
            out.println(ans);
        }

    }
}



Measured memory_bytes: 24148
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int n,x,i,j,k,a;
		while(true){
			n=stdIn.nextInt();
			x=stdIn.nextInt();
			if(n==0&&x==0)break;
			a=0;
			for(i=1;i<n-1;i++)for(j=i+1;j<n;j++)for(k=j+1;k<=n;k++)if(i+j+k==x)a++;
			System.out.println(a);
		}
	}
}


Measured memory_bytes: 26668
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	lint K, A, B;
	cin >> K >> A >> B;
	if (B - A <= 2) {
		cout << K + 1 << endl;
	}//OK
	else {
		if ((K - A + 1) % 2 == 0) {
			cout << A  + (K - A + 1) / 2 * (B-A) << endl;
		}

		else {
			cout << A  + (K - A + 1) / 2 * (B-A) + 1 << endl;
		}

	}
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    var a = sc.nextInt()
    val b = sc.nextInt()
    var c = sc.nextInt()
    val d = sc.nextInt()
    while (true) {
        c -= b
        if (c <= 0) {
            println("Yes")
            break
        }
        a -= d
        if (a <= 0) {
            println("No")
            break
        }
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34324
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)


signed main()
{
    FIO;
    ll n,ans=0;
    cin>>n;
    vi v(n+1,1);
    for(ll i=2;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
        {
            v[j]++;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        ans+=(i*v[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 81328
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int 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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;


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


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int MX=-999, mY=999;
	REP(i, N) {
		int x; cin >> x;
		MX = max(MX, x);
	}
	REP(i, M) {
		int y; cin >> y;
		mY = min(mY, y);
	}
	bool ok = true;
	if (MX >= mY)ok = false;
	if (MX < mY) {
		if (mY <= X)ok = false;
		if (MX >= Y)ok = false;
	}
	if (ok) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

// Union find
struct uf {
  vi d;
  uf(){}
  uf(int mx):d(mx,-1){}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y]; d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
  int operator[](int x) { return root(x);}
  int operator()(int x) { return size(x);}
};
//



int main() {
  int n;
  scanf("%d",&n);
  uf t(n);
  int m;
  scanf("%d",&m);
  rep(i,m) {
    int a,b;
    scanf("%d%d",&a,&b);
    --a; --b;
    t.unite(a,b);
  }
  int ans = 0;
  rep(i,n) if (t.root(i) == i) ++ans;
  --ans;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3808
#include <stdio.h>

int main(void) {
	int x, y;
	int i,sum = 0;

	scanf("%d%d", &x, &y);

	for(i=0;i<2;i++){
		if (x < y) {
			sum += y;
			y--;
		}else{
			sum += x;
			x--;
		}
	}

	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
if __name__ == '__main__':
    N, M = map(int, input().split())
    hopes = []
    for _ in range(M):
        a, b = map(int, input().split())
        hopes.append([b, a])
    hopes.sort()
    ans = 0
    pos = -1
    for idx, (e, s) in enumerate(hopes):
        if idx == 0 or pos <= s:
            ans += 1
            pos = e
    print(ans)


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

int main()
{
    long long int N, num, max1, max1_index, max2;
    cin >> N;
    max1 = -1;
    for(int i=0; i<N; i++){
        cin >> num;
        if(max1 <= num){
            max2 = max1;
            max1 = num;
            max1_index = i;
        }else{
            if(max2 <= num){
                max2 =num;
            }
        }
    }
    for(int i=0; i<N; i++){
        if(i == max1_index){
            cout << max2<< endl;
        }else{
            cout << max1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	char s[5];
	scanf("%s",s);

	int ans = 0;
	for(int i=0;i<4;i++){
		if(s[i]=='+') ans++;
		else if(s[i]=='-') ans--;
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , comp[N] , q , cnt[N] , big[N] , odd[N];
char al[N];
int main ( ){
   scanf("%s",al);
   n = strlen(al);
   int c = 1 , r= 1 , l = 0 ;
   comp[0] = c ;
   for ( int i = 1 ; i < n ; i++  ){
         if ( al[i] == 'L' && al[i+1] == 'R'){
                l++;
               comp[i] = c ;
               big[c] = ( r > l ? -1 : 1 );
               odd[c] = max(r,l)&1 ;
            cnt[c++] = r+l ;
            r = 0 , l = 0;
              continue;
         }
         comp[i] = c ;
         if ( al[i] == 'R') r++;
         else l ++;
   }
   cnt[c] = r+l;
   big[c] = ( r > l ? -1 : 1 );
   odd[c] = max(r,l)&1 ;

   vector < int > out (n,0);
   for ( int i = 0 ; i < n-1 ; i++ ) {
         if ( al[i] == 'R' && al[i+1] == 'L'){
             out[i] = out[i+1] =  cnt[comp[i]]/2 ;
             if ( cnt[comp[i]] & 1 ) {
                if ( big[comp[i]] == -1 ) {
                      if ( odd[comp[i]] ) out[i]++;
                      else out[i+1]++;
                }else {
                    if ( odd[comp[i]] ) out[i+1]++;
                      else out[i]++;
                }
             }
             i++;
             continue ;
         }

   }
   for ( int i = 0 ; i < n ;i++ ){
    printf("%d%c",out[i],(i==n-1?'\n':' '));
   }
return 0 ;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define ff first
#define ss second
#define dd double
#define mod 1000000007

template<class K,class other=null_type,class cmp=less<K>> using ordered_set=tree<K,other,
cmp, rb_tree_tag, tree_order_statistics_node_update>;

inline ll md(ll x){
    return x<mod?x:x%mod;
}

ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    ll x_=power(x,y/2);
    if(y & 1){
        return md(md(x_*x_)*md(x));
    }
    else{
        return md(x_*x_);
    }
}

ll mod_inverse(ll x){
    return power(x,mod-2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    ll pref[n];
    ll suff[n];
    REP(i,n){
        cin>>arr[i];
    }
    pref[0]=arr[0];
    FOR(i,1,n){
        pref[i]=(pref[i-1]+arr[i])%mod;
    }
    suff[n-1]=arr[n-1];
    for(ll i=n-2;i>=0;i--){
        suff[i]=(suff[i+1]+arr[i])%mod;
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        if(i==0){
            ll temp=suff[i+1];
            ans=(ans+(arr[i]*temp)%mod)%mod;
        }
        else if(i==n-1){
            ll temp=pref[i-1];
            ans=(ans+(arr[i]*temp)%mod)%mod;
        }
        else{
            ll temp=suff[i+1];
            ans=(ans+(arr[i]*temp)%mod)%mod;
            temp=pref[i-1];
            ans=(ans+(arr[i]*temp)%mod)%mod;
        }
    }
    cout<<(ans*mod_inverse(2))%mod<<endl;
}


Measured memory_bytes: 8296