akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a) {
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    int size(int a){
        return -uni[root(a)];
    }
};


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    UnionFind g(n);
    for (int i = 0; i < m; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        g.unite(x-1, y-1);
    }
    map<int, vector<int>> map1;
    for (int i = 0; i < n; ++i) {
        map1[g.root(v[i]-1)].emplace_back(i+1);
        map1[g.root(v[i]-1)].emplace_back(v[i]);
    }
    int ans = 0;
    for (auto &&j : map1) {
        sort(j.second.begin(), j.second.end());
        for (int i = 0; i < j.second.size()-1; ++i) {
            if(j.second[i] == j.second[i+1]) ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 11904
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <map>

using namespace std;

int a[100000] = {};
map<int, int> b;

int main(int argc, char *argv[])
{
    int n;
    scanf("%d", &n);
    for (int in = 0; in < n; ++in)
    {
        scanf("%d", &a[in]);
    }

    for (int in = 0; in < n; ++in)
    {
        std::map<int, int>::iterator it = b.find(a[in]);
        if (it == b.end())
        {
            b[a[in]] = 1;
        }
        else
        {
            ++it->second;
        }
    }

    int need = 0;
    for (map<int, int>::const_iterator it = b.begin(); it != b.end(); ++it)
    {
        if (it->first > it->second) need += it->second;
        else need += it->second - it->first;
    }
    printf("%d\n", need);

    return 0;
}


Measured memory_bytes: 5120
using System;
using System.Linq;

class Procon
{
  public Procon() {}
  static void Main(string[] agrs)
  {
    new Procon().Do();
  }

  Scanner cin;

  public void Do()
  {
    cin = new Scanner();
    int A = cin.nextInt();
    int B = cin.nextInt();

    if (B % A == 0) {
      Console.WriteLine(A+B);
      return;
    }

    Console.WriteLine(B-A);
    return;
  }
}


class Scanner
{
  string[] s;
  int i;
  int max_i;

  public Scanner()
  {
    s = new string[0];
    max_i = 0;
    i = 0;
  }

  public string nextString()
  {
    if (i >= s.Length) 
    {
      s = Console.ReadLine().Split(' ');
      max_i = s.Length;
      i = 0;
      if (max_i == 0) 
      {
        return "";
      }
      return s[i++];
    } else 
    {
      return s[i++];
    }
  }

  public int nextInt()
  {
    return int.Parse(nextString());
  }


  public long nextLong()
  {
    return long.Parse(nextString());
  }

  public double nextDouble()
  {
    return double.Parse(nextString());
  }

  public string[] arrayString()
  {
    return Console.ReadLine().Split(' ');
  }

  public int[] arrayInt()
  {
    string[] str = Console.ReadLine().Split(' ');
    int[] array = new int[str.Length];
    for (int i=0; i<str.Length; i++) 
    {
      array[i] = int.Parse(str[i]);
    }
    return array;
  }

  public long[] arrayLong()
  {
    string[] str = Console.ReadLine().Split(' ');
    long[] array = new long[str.Length];
    for (int i=0; i<str.Length; i++) 
    {
      array[i] = long.Parse(str[i]);
    }
    return array;
  }

  public double[] arrayDouble()
  {
    string[] str = Console.ReadLine().Split(' ');
    double[] array = new double[str.Length];
    for (int i=0; i<str.Length; i++) 
    {
      array[i] = double.Parse(str[i]);
    }
    return array;
  }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<ll, ll>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (ll i = begin; i < n; i++)
#define repe(i, begin, n) for (ll i = begin; i <= n; i++)
#define repr(i, begin, n) for (ll i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (ll i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const ll inf = 1000000007;
const ll MOD = 1000000007;
const long long INF = 1000000000000000007;

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

string L;
ll dp0[101010], dp1[101010];

int main() {
  cin >> L;

  dp0[0] = 1;
  dp1[0] = 2;
  int len = L.size();
  rep(i, 1, len) {
    if (L[i] == '0') {
      dp0[i] = dp0[i - 1] * 3 % MOD;
      dp1[i] = dp1[i - 1];
    } else {
      dp0[i] = (dp0[i - 1] * 3) % MOD + dp1[i - 1];
      dp0[i] %= MOD;
      dp1[i] = dp1[i - 1] * 2 % MOD;
    }
  }

  cout << (dp0[len - 1] + dp1[len - 1]) % MOD;
}


Measured memory_bytes: 5316
#include <bits/stdc++.h>
using namespace std;
#define N 50
#define INF 99999999
typedef pair<int,int>P;
int n;
int good[3]={3,5,7};
int cnt=0;
void dfs(long long,long long);
int main(){
    cin>>n;
    //printf("n=%d\n",n);
    dfs(0,0);
    cout<<cnt<<endl;
}


void dfs(long long sum,long long d){
    //printf("cnt=%d\n",cnt);
    if(sum>n){
        //printf("cnt=%d\n",cnt);
        return;}
    //printf("sum=%d\n",sum);
    long long crr=sum;
    int flag1=0;
    int flag2=0;
    int flag3=0;
    while(crr>0){
        long long temp=crr%10;
        //printf("temp=%d\n",temp);
        if(temp==5)flag1=1;
        if(temp==7)flag2=1;
        if(temp==3)flag3=1;
        crr/=10;
    }
    if(flag1==1&&flag2==1&&flag3==1)cnt++;
    for(int i=0;i<3;i++){
        int neww=good[i];
        if(sum*10+neww<=n){
            dfs(sum*10+neww,d+1);
        }
    }
}


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

void dfs(int i, vector<int>& V, unordered_map<int, unordered_map<int, long long>>& E){
    for(auto itr = E[i].begin(); itr != E[i].end(); ++itr){
        int k = itr->first;
        long long w = itr->second;
        if (V[k] >= 0) continue;
        if (w % 2 == 1) V[k] = 1 - V[i];
        else V[k] = V[i];
        dfs(k, V, E);
    }
}

int main(){
    int n;
    cin >> n;
    int u, v;
    long long w;
    unordered_map<int, unordered_map<int, long long>> E;
    vector<int> V;
    for(int i = 0; i < n - 1; i++){
        cin >> u >> v >> w;
        E[u][v] = w;
        E[v][u] = w;
    }
    V.assign(n + 1, -1);
    V[1] = 0;
    dfs(1, V, E);
    for (int i = 1; i <= n; i++) cout << V[i] << endl;
}


Measured memory_bytes: 22308
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

int n;
int a;
int mi = INF, ma = -INF;
int mi_i, ma_i;
vector
 vec;

int main(){
  scanf("%d",&n);
  REP(i,n){
    scanf("%d",&a);
    if(ma < a){
      ma = a;
      ma_i = i;
    }
    if(mi > a){
      mi = a;
      mi_i = i;
    }
  }
  if(ma > 0 && mi < 0){
    if(ma > abs(mi)){
      REP(i,n){
        vec.push_back(s(ma_i+1,i+1));
      }
      mi = 0;
    }else{
      REP(i,n){
        vec.push_back(s(mi_i+1,i+1));
      }
    }
  }
  if(mi >= 0){
    REP(i,n-1){
      vec.push_back(s(i+1,i+2));
    }
  }else{
    REP(i,n-1){
      vec.push_back(s(n-i,n-i-1));
    }
  }
  printf("%d\n",vec.size());
  REP(i,vec.size()){
    printf("%d %d\n", vec[i].first, vec[i].second);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int x[n];
	for (int i = 0; i < n; i ++) {
		cin >> x[i];
	}
	int res = 0;
	for (int i = 1; i < n - 1; i ++) {
		int a = x[i - 1];
		int b = x[i];
		int c = x[i + 1];
		if ((a >= b && b >= c) || (c >= b && b >= a)) {
			res ++;
		}
	}
	cout << res << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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


int main() {
    int x;
    cin >> x;
    if(x >= 400 and x <= 599) {
        cout << 8 << endl;
    } else if(x >= 600 and x <= 799) {
        cout << 7 << endl;
    } else if(x >= 800 and x<= 999) {
        cout << 6 << endl;
    } else if(x >= 1000 and x <= 1199) {
        cout << 5 << endl;
    } else if(x >= 1200 and x<= 1399) {
        cout << 4 << endl;
    } else if(x >= 1400 and x<= 1599) {
        cout << 3 << endl;
    } else if(x >= 1600 and x <= 1799) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
}


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

using namespace std;

using ll = long long;

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

    string a, b;
    cin >> a >> b;
    if (a == b) cout << "EQUAL\n";
    else if (a.size() > b.size() || (a.size() == b.size() && a > b)) cout << "GREATER\n";
    else cout << "LESS\n";

    return 0;
}


Measured memory_bytes: 256
w, h, n = map(int, input().split())
l = 0
r = w
u = h
d = 0
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        l = max(l, x)
    elif a == 2:
        r = min(r, x)
    elif a == 3:
        d = max(d, y)
    else:
        u = min(u, y)
print((r - l) * (u - d) if r - l > 0 and u - d > 0 else 0)

Measured memory_bytes: 3064
# AOJ 0611: Silk Road
# Python3 2018.7.4 bal4u
 
import sys
from sys import stdin
input = stdin.readline
 
INF = 0x7fffffff
n, m = map(int, input().split())
d = [int(input()) for i in range(n)]
c = [int(input()) for i in range(m)]
dp = [[INF for j in range(n+1)] for i in range(m+1)]
dp[0][0] = 0
for i in range(m):
    dp[i+1] = dp[i][0:n+1]
    for j in range(n):
        if dp[i][j] != INF:
            dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]+c[i]*d[j])
print(dp[m][n])


Measured memory_bytes: 19128
import java.io.*;
import java.util.*;
public class Main{
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
            int k = sc.nextInt();
            int a = sc.nextInt();
            int b = sc.nextInt();
            for(int i=a;i<=b;i++){
                if(i%k==0) {
                    out.println("OK");
                    return;
                }
            }
            out.println("NG");


    }
    private static int gcd(int a, int b){
        if(b==0)
            return a;
        return gcd(b, a%b);
    }
    public static void main(String[] args) throws Exception {
        // long start =  System.nanoTime();
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();


    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    int x;
    int y;
    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}


Measured memory_bytes: 32756
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s;
    cin >> s;
    int w;
    cin >> w;
    for(int i=0;i<s.size();i += w){
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
#define mp(a,b) make_pair((a),(b))
ll ans=0;
void Main(){
    ll n;cin>>n;
    ll k;cin>>k;
    if((n-1)*(n-2)/2<k) {
        cout<<-1<<endl;
        return;
    }
    k=(n-1)*(n-2)/2-k;
    vector<pair<ll,ll>> edge;
    For(i,2,n+1){
        edge.push_back(mp(1,i));
    }
    if(k==0) goto end;
    For(i,2,n){
        For(j,i+1,n+1){
            edge.push_back(mp(i,j));
            k--;
            if(k==0) goto end;
        }
    }
    end:;
    cout<<edge.size()<<endl;
    for(auto p:edge){
        cout<<p.first<<" "<<p.second<<endl;
    }
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 512
N = int(input())
flag = 0


for i in reversed(range(1,10)):
    if N % i == 0:
        j = N / i

        if j >= 10:
            print("No")
            flag = 1
            break

        else:
            print("Yes")
            flag = 1
            break

    else:
        continue

if flag == 0:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  N = pow(2,N);
  /*vector<int> vec(N*2);
  for(int i=0; i<N; i++){
    vec.at(i) = i;
    vec.at(N+i) = i;
  }
  sort(vec.begin(),vec.end());
  do{
    bool flag = true;
    for(int i=0; i<N; i++){
      bool seen = false;
      int x = i;
      for(int j=0; j<N*2; j++){
        if(!seen && vec.at(j) == i){
          seen = true;
          continue;
        }
        if(seen){
          x ^= vec.at(j);
          if(vec.at(j) == i){
            if(x != K){
              flag = false;
            }
          }
        }
      }
    }
    if(flag){
      for(int i=0; i<2*N; i++){
        cout << vec.at(i) << " ";
      }
      cout << endl;
    }
  }while(next_permutation(vec.begin(),vec.end()));*/
  if(K == 0){
    for(int i=0; i<N; i++){
      cout << i << endl;
      cout << i << endl;
    }
  }
  else if(K >= N || (K == 1 && N == 2)){
    cout << -1 << endl;
  }
  else{
    vector<int> vec(0);
    for(int i=1; i<N; i++){
      if(i == K){
        continue;
      }
      else{
        vec.push_back(i);
      }
    }
    cout << 0 << endl;
    cout << K << endl;
    cout << 0 << endl;
    for(int i=0; i<N-2; i++){
      cout << vec.at(i) << endl;
    }
    cout << K << endl;
    reverse(vec.begin(),vec.end());
    for(int i=0; i<N-2; i++){
      cout << vec.at(i) << endl;
    }
  }
}

Measured memory_bytes: 2424
#include <stdio.h>
int main(void)
{
	int H, W, h, w;
	int all, retu, gyou,cross,an;
	scanf("%d", &H); scanf("%d", &W); scanf("%d", &h); scanf("%d", &w);
	all = H * W;
	gyou = h * W;
	retu = w * H;
	cross = h * w;
	an = all - gyou - retu + cross;
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 5000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N;
	cin >> N ;

	ll cnt = 0;
	vector<ll> A(N);
	vector<pair<ll,ll>> B(N);
	rep(i,N){
		cin >> A[i];
		A[i]--;
		if(i != A[i]){
			B[cnt].first = i;
			B[cnt].second = A[i];
			cnt++; 
		}
	}

	if(cnt > 2) cout << "NO" << endl;
	else{
		if(B[0].first == B[1].second && B[1].first == B[0].second){
			 cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int n;
int c[200005];

int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int a;
    scanf("%d", &a);
    ++c[a];
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", c[i]);
  }
}


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

typedef long long LL;
multiset<pair<LL, LL> >s;
int main()
{
    LL n, k, a, b;
    scanf("%lld%lld",&n,&k);
    while(n--)
    {
        scanf("%lld%lld",&a,&b);
        s.insert(make_pair(a, b));
    }
    LL sum = 0;
    for(auto it = s.begin(); it!=s.end(); ++it)
    {
        sum += it->second;
        if(sum >= k)
            return 0*printf("%d\n",it->first);
    }
    return 0;
}


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

string N,out_moji;
double x,H[1100],T,A;        

int main() {
    cin >> N;
    x = N.size();

        for (int i = 0; i < x; i = i +2) {
        
           out_moji = out_moji + N[i];
        
        }

    // cout << max << endl;
   //  cout << min << endl;
   // max = max - min;
    cout << out_moji << endl;
}

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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eps 1e-9

const int MOD = 1e9+7;

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

ll POWER[65];
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll inv(ll x) {return power(x,MOD-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}
const int MAXN = 205;
int ar[MAXN];
int main() {
//	freopen("TASK.in","r",stdin);	
//	freopen("TASK.out","w",stdout);
	precompute();
	int n;
	cin>>n;
	for(int i=1;i<=2*n;i++) cin>>ar[i];
	sort(ar+1,ar+1+2*n);
	int ans=0;
	for(int i=1;i<=2*n;i+=2) ans+=ar[i];
	cout<<ans<<endl;
	return 0;
}


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

int main(){
 int a , b ;

 cin >> a >> b;
 
 if (( a + b ) % 2 >> 0) {

cout << ( a + b ) / 2 + 1  ;
}
 if (( a + b ) % 2 == 0 ){
     cout << ( a + b ) / 2 << endl;
 }
}

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

int main()
{
  int n;
  cin>>n;
  vector<int> e(n+1,0);
  char s;
  for(int i=1;i<=n;i++)
  {
    cin>>s;
    if(s=='E') e.at(i)=e.at(i-1)+1;
    else e.at(i)=e.at(i-1);
  }

  int cnt=1000000;
  for(int i=1;i<=n;i++)
  {
    int left=(i-1)-e.at(i-1);
    int right=e.at(n)-e.at(i);
    int turn=left+right;
    if(turn<cnt) cnt=turn;
  }
  cout<<cnt<<endl;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    int N;
    cin >> N;
    int ans=0;

    REP(i, N+1){
        int tmp = i;
        int keta = 0;
        while(tmp > 0){
            keta++;
            tmp /= 10;
        }
        if(keta % 2 == 1)ans++;
    }

    cout << ans << endl;




}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
n = int(input())
w = tuple(map(int, input().split()))
av_min = 100000
for i in range(n-1):
    av = abs(sum(w[:i+1]) - sum(w[i+1:]))
    if av < av_min:
        av_min = av
    else:
        break
print(av_min)

Measured memory_bytes: 9104
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

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

const i64 MAX = 510000;

i64 fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
i64 COM(i64 n, i64 k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

i64 s(i64 x) {
    return (x * (x + 1) / 2) % MOD;
}

i64 extGCD(i64 a, i64 b, i64& x, i64& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    i64 d = extGCD(b, a % b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline i64 mod(i64 a, i64 m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
i64 modinv(i64 a, i64 m) {
    i64 x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

int main() {
    i64 n, m, k;
    cin >> n >> m >> k;
    COMinit();
    i64 ans = 0, cnt = 1;
    for (i64 i = 0; i < n; ++i) {
        for (i64 j = 0; j < m; ++j) {
            i64 x = (((s(m - j - 1) + s(j)) % MOD * n) % MOD);
            i64 y = (((s(n - i - 1) + s(i)) % MOD * m) % MOD);
            i64 z = (COM(n * m - 2, k - 2) * (x + y)) % MOD;
            ans = (ans + z) % MOD;
        }
    }
    cout << (ans * modinv(2, MOD)) % MOD << endl;
}

// (1, 1) (1 + 2 + .. m - 1) * n + (1 + 2 ... + n - 1) * m * (n * m - 1)C(k - 1)
// (0 + 1 + 1 + 2


Measured memory_bytes: 12160
from bisect import bisect_left
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]

LIS = deque()  # LISの中身は、LISの最小の数字を保持する
LIS.append(a[0])
for i in range(1, n):
    idx = bisect_left(LIS, a[i])
    if idx == 0:
        LIS.appendleft(a[i])
    else:
        LIS[idx-1] = a[i]
print(len(LIS))

Measured memory_bytes: 81836
import java.io.*;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		StringTokenizer s = new StringTokenizer(in.readLine(), " ");
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) a[i] = Integer.parseInt(s.nextToken());
		
		int c = 0;
		int e = 0;
		for (int i = 0; i < a.length - 1; i++) {
			if(a[i] > a[i + 1]){
				if(e == -1){
					c++;
					e = 0;
				}
				else if(e == 0) e = 1;
			}
			else if(a[i] < a[i + 1]){
				if(e == 1){
					c++;
					e = 0;
				}
				else if(e == 0) e = -1;
			}
		}
		
		c++;
		
		System.out.println(c);
				
	}
}


Measured memory_bytes: 35852
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>

using namespace std;
int main(){

        string ring;
        cin >> ring;

        int n;
        int ans = 0;
        scanf("%d",&n);
        for(int i = 0; i < n; i++){
                string tmp;
                cin >> tmp;
                tmp += tmp;
                int len = tmp.size();
                for(int j = 0; j < len-ring.size(); j++){
                        bool f = false;
                        for(int k = 0; k < ring.size(); k++){
                                if(ring[k] != tmp[j+k]){
                                        f = true;
                                        break;
                                }
                        }
                        if(!f){
                                ans++;
                                break;
                        }
                }
        }

        printf("%d\n",ans);
        return 0;
}

Measured memory_bytes: 1228
// Solution of Problem : https://www.hackerrank.com/contests/hourrank-21/challenges/sams-numbers
// Change value of mod

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000009// Change mod value
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define space printf(" ")
#define endl printf("\n")
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{
	ST_Node()
	{

	}
	void assign_value_()
	{

	}
	void merge_nodes_()
	{

	}
};

const int N = (2e5) + 9;
const int M = (1e5) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;

int a[N];

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int n, i, sum = 0, ans = 0;
	cin >> n;
	fo(i,1,n+1)
	{
		cin >> a[i];
		sum += a[i];
	}
	if(sum % 10)
		ans = max(ans, sum);
	else
		ans = max(ans, 0);
	fo(i,1,n+1)
	{
		if((sum-a[i]) % 10)
			ans = max(ans, (sum-a[i]));
		else
			ans = max(ans, 0);
	}
	cout << ans;
	// Code ends here

	// clk = clock() - clk;
	// cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
jobs = []
for _ in range(n):
    jobs.append(list(map(int, input().split())))
    
jobs.sort(key=lambda x:x[1]) #Bをkeyにソート
time = 0
result = 'Yes'

for job in jobs:
    time += job[0]
    if(time > job[1]):
        result = 'No'
        break
print(result)

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

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld %lld",&n,&k);
        cin>>str;

        for(i=1;i<n;i++)
        {
            if(str[i]!=str[i-1])x++;
        }
        x++; fr=k<<1; y=max(1LL,x-fr);  printf("%lld\n",n-y);







    return 0;
}




Measured memory_bytes: 3888
#include <stdio.h>

int main(void)
{
	int card[4][13]={0};
	int i,j,n;
	char marks[4]={'S','H','C','D'};
	char mark;
	int num;
	
	scanf("%d",&n);
	for(i=0;i<n*2;i++){
		scanf("%c %d",&mark,&num);
		switch(mark){
			case 'S':
				card[0][num-1]=1;
				break;
			case 'H':
				card[1][num-1]=1;
				break;
			case 'C':
				card[2][num-1]=1;
				break;
			case 'D':
				card[3][num-1]=1;
				break;
		}
	}
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(card[i][j]==0) printf("%c %d\n",marks[i],j+1);
		}
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll x,k,d;
    cin>>x>>k>>d;

    x=abs(x);
    if(x/d>k){
        cout<<abs(x-d*k)<<endl;
    }
    else{
        ll now=x-(x/d)*d;
        k-=x/d;
        if(k%2==1) cout<<min(abs(now-d),now+d)<<endl;
        else cout<<now<<endl;
    }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// 辺（方向と重み）
struct edge{ ll to, cost; };

// 幅優先探索
void bfs(vector<vector<edge>> &g, ll n, ll node, vi &color, vi &dst, bool &ans, ll cost){
    if(color[node] == 1){
        if(dst[node] != cost) ans = false;
    }
    else{
        color[node] = 1;
        dst[node] = cost;
        rep(i, g[node].size()){
            bfs(g, n, g[node][i].to, color, dst, ans, cost + g[node][i].cost);
        }
    }
}

int main(){
    Init();
    ll n, m; cin >> n >> m;
    vector<vector<edge>> g(n, vector<edge>(0));

    // グラフの生成
    rep(i, m){
        ll l, r, d; cin >> l >> r >> d;
        l--; r--; // 0-based
        // 双方向に辺を張る（逆向きはコストもマイナスにする）
        g[l].push_back((edge){r, d});
        g[r].push_back((edge){l, -d});
    }

    // 回答出力用
    bool ans = true;

    // グラフ巡回確認
    vi color(n, 0);
    vi dst(n, -INFLL);
    dst[0] = 0;

    // 矛盾がないか確認
    rep(i, n){
        if(color[i] == 0){
            dst[i] = 0;
            bfs(g, n, i, color, dst, ans, 0LL);
        }
    }

    // 結果出力
    (ans) ? Yes() : No();
}

Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int S, T, D;
  cin >> S >> T >> D;
  vector<int> w(D);
  for (int i = 0; i < D; i++){
    cin >> w[i];
  }
  long long min_d = 0;
  long long curr_d = 0;
  bool ok = false;
  for (int i = 0; i < D; i++){
    curr_d += w[i];
    min_d = min(min_d, curr_d);
    if (S + curr_d <= T){
      cout << i + 1 << endl;
      ok = true;
      break;
    }
  }
  if (!ok){
    long long sum = 0;
    for (int i = 0; i < D; i++){
      sum += w[i];
    }
    if (sum >= 0){
      cout << -1 << endl;
    } else {
      long long C = (S - T + min_d - 1 - sum) / (- sum);
      long long ans = C * D;
      S += sum * C;
      if (S <= T){
        cout << ans << endl;
      } else {
        for (int i = 0; i < D; i++){
          S += w[i];
          if (S <= T){
            cout << ans + i + 1 << endl;
            break;
          }
        }
      }
    }
  }
}


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

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		long n = in.nextLong();
		long minDiff = (long)(1e11);
		long maxterm = 0;
		for(long i = 1;i*i<=n;i++){
			if(n%i==0){
				minDiff = Math.min(minDiff,n/i-i);
				maxterm = n/i;
			}

		}
		int length = 0;
		while(maxterm>0){
			length++;
			maxterm/=10;
		}	
		out.println(length);
		out.flush();
		out.close();  
	}

}





Measured memory_bytes: 21204
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;



int main() {
	int N, Q; cin >> N >> Q;
	vector<ll> a(N + 1), xs(Q);
	ll ma = 0;
	for (int i = 1; i <= N; i++) cin >> a[i], a[i] *= 4, ma = max(ma, a[i]);
	for (int i = 0; i < Q; i++) cin >> xs[i], xs[i] = 4*xs[i] - 1, ma = max(ma, xs[i]);
	vector<ll> sum(N + 2), jmp(N + 2);
	for (int i = 1; i <= N; i++) sum[i] = sum[i - 1] + a[i];
	jmp[1] = a[1];
	for (int i = 2; i <= N; i++) jmp[i] = jmp[i - 2] + a[i];
	for (ll x : xs) {
		ll blo = 0, bhi = ma + 1;
		int llo, lhi, hlo, hhi;
		while (bhi - blo > 1) {
			ll bmid = blo + (bhi - blo) / 2;

			hlo = 0, hhi = N + 1;
			while (hhi - hlo > 1) {
				int mid = hlo + (hhi - hlo) / 2;
				if (a[mid] > x + bmid) hhi = mid;
				else hlo = mid;
			}

			llo = 0, lhi = N + 1;
			while (lhi - llo > 1) {
				int mid = llo + (lhi - llo) / 2;
				if (a[mid] >= x - bmid) lhi = mid;
				else llo = mid;
			}

			if (N - hlo >= hlo - llo) blo = bmid;
			else bhi = bmid;
		}

		hlo = 0, hhi = N + 1;
		while (hhi - hlo > 1) {
			int mid = hlo + (hhi - hlo) / 2;
			if (a[mid] > x + blo) hhi = mid;
			else hlo = mid;
		}

		llo = 0, lhi = N + 1;
		while (lhi - llo > 1) {
			int mid = llo + (lhi - llo) / 2;
			if (a[mid] >= x - blo) lhi = mid;
			else llo = mid;
		}

		ll ans = sum[N] - sum[hlo];
		if (N - hlo > hlo - llo && llo > 0) ans += jmp[llo - 1];
		else ans += jmp[llo];
		ans /= 4;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i, n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)
#define all(x) (x).begin(), (x).end()
#define szz(x) (int)(x).size()
#define Fi first
#define Se second
typedef long double ldouble;

int N, S;
int X[200020], P[200020];

void solve() {
	scanf("%d%d", &N, &S);
	for(int i=1;i<=N;i++) scanf("%d%d", X+i, P+i);
	vector <pll> L, R;
	for(int i=1;i<=N;i++) {
		if(X[i] > S) R.emplace_back(X[i], P[i]);
		else L.emplace_back(X[i], P[i]);
	}
	sort(all(L)); reverse(all(L));
	sort(all(R));
	ll ans = 0;
	int p = -1;
	while(szz(L) || szz(R)) {
		if(szz(L) == 0) ans += R.back().Fi - S, R.clear();
		else if(szz(R) == 0) ans += S - L.back().Fi, L.clear();
		else {
			if(L.back().Se >= R.back().Se) {
				if(p != 0) ans += R.back().Fi - L.back().Fi;
				L.back().Se += R.back().Se;
				p = 0; R.pop_back();
			}
			else {
				if(p != 1) ans += R.back().Fi - L.back().Fi;
				R.back().Se += L.back().Se;
				p = 1; L.pop_back();
			}
		}
	}
	printf("%lld\n", ans);
}

int main() {
	//DM(); return 0;
	int tc = 1; // scanf("%d", &tc);
	for(int t=1;t<=tc;t++) {
	//	printf("Case #%d: ", t);
		solve();
	}
	return 0;
}


Measured memory_bytes: 3572
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

C.sort(reverse=True)

tmp = []
for x in range(X):
    for y in range(Y):
        tmp.append(A[x] + B[y])
        
tmp.sort(reverse=True)

res = []
for i in range(min(K, X*Y)):
    for z in range(Z):
        res.append(tmp[i] + C[z])
 
res.sort(reverse=True)
for i in range(K):
    print(res[i])

Measured memory_bytes: 147776
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)(s1[0]-'a'+'A') << (char)(s2[0]-'a'+'A') << (char)(s3[0]-'a'+'A') << endl;
}

Measured memory_bytes: 256
import collections
n=int(input())
A=[]
AA=[]
B=[]
C=[]
X=[]
mod=10**9+7
p=137053438808121949
for i in range(n):
  a,b=map(int,input().split())
  if a<0:
    a=a*-1
    b=b*-1
  if a*b>0:
    A.append(b*pow(a,p-2,p)%p)
  elif a*b<0:
    AA.append(a*pow((-b),p-2,p)%p)
  else:
    if a==0 and b==0:
      X.append(i)
    elif a==0:
      B.append(i)
    else:
      C.append(i)
D=collections.Counter(A)
DD=collections.Counter(AA)
E=set(list(D)+list(DD))
a=1
for i in E:
  a=(a*(2**D[i]+2**DD[i]-1))%mod
a=(a*(2**len(B)+2**len(C)-1)-1)%mod
print((a+len(X))%mod)

Measured memory_bytes: 169444
using System;

class Program {

    /// <summary>
    /// スートの定義
    /// </summary>
    enum Suit {
        /// <summary>
        /// Spade
        /// </summary>
        S,
        /// <summary>
        /// Heart
        /// </summary>
        H,
        /// <summary>
        /// Crab
        /// </summary>
        C,
        /// <summary>
        /// Dia
        /// </summary>
        D,
    }

    private static int Main() {
        // 不足分の判定用フラグ
        bool[] flags = new bool[ 52 ];
        // 所持トランプ数
        int count = 0;

        {
            // 所持トランプ数を読み込み
            var input = Console.ReadLine();
            count = int.Parse( input );
        }

        // 所持トランプ数の分だけ判定用フラグを立てていく
        for( int i = 0; i < count; ++i ) {
            var input = Console.ReadLine();
            var values = input.Split( ' ' );

            var suitChar = char.Parse( values[ 0 ] );
            var rank = int.Parse( values[ 1 ] );
            
            // スート文字から列挙値を取得
            Suit suit = GetSuit( suitChar );

            // rank は 1?13 なので 0?12 にして Index に適用
            var index = (int)suit * 13 + ( rank - 1 );

            flags[ index ] = true;
        }

        // 所持してないトランプを検索して出力
        for( int i = 0; i < flags.Length; ++i ) {
            if( !flags[ i ] ) {
                var output = string.Format( "{0} {1}", (Suit)( i / 13 ), ( i % 13 ) + 1 );
                Console.WriteLine( output );
            }
        }

        return 0;
    }

    /// <summary>
    /// スート文字から列挙値を取得
    /// </summary>
    /// <param name="suitChar">スート文字</param>
    /// <returns>Suit列挙値</returns>
    private static Suit GetSuit( char suitChar ) {
        switch( suitChar ) {
            case 'S':
                return  Suit.S;
            case 'H':
                return Suit.H;
            case 'C':
                return Suit.C;
            case 'D':
                return Suit.D;
            default:
                throw new Exception( "Invalid Suit Char: " + suitChar );
        }
    }
}

Measured memory_bytes: 5932
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int sum = 0;
        int count = n;
        int[] m = new int[n];
        for (int i = 0; i < n; i++) {
            m[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            sum += m[i];
        }
        x -= sum;
        Arrays.sort(m);
        while (true) {
            if (x >= m[0]) {
                x -= m[0];
                count++;
            } else {
                break;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
import sys
from collections import deque
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N = int(input())
    q = deque()
    for _ in range(N):
        a = int(input())
        pos = bisect_left(q, a)
        if pos == 0:
            q.appendleft(a)
        else:
            q[pos-1] = a

    return len(q)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 7284
#include<stdio.h>
long long gcd(long long a,long long b)
{
    return b?gcd(b,a%b):a;
}
long long lcm(long long a,long long b)
{
	return a*b/gcd(a,b);
}
int main()
{
	long long a,b,c,d,e,x,y,z;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	x=b/c-a/c;
	if(a%c==0)x++;
	y=b/d-a/d;
	if(a%d==0)y++;
	e=lcm(c,d);
	z=b/e-a/e;
	if(a%e==0)z++;
	printf("%lld\n",(b-a+1)-(x+y-z));
}

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

int main() {
 	int n;cin>>n;
  int e = n%10;
  if(e==2 || e==4 || e==5 || e==7 || e==9)
    cout<<"hon";
  else if(e==3)
    cout<<"bon";
  else
    cout<<"pon";
  return 0;
}

Measured memory_bytes: 3620
s=input()
t=input()
letters=[]
count=[]
for i in range(len(s)):
  if s[i] in letters:
    count[letters.index(s[i])].append(i)
  else:
    count.append([i])
    letters.append(s[i])
failflag=0
for i in count:
  r=t[i[0]]
  for j in i:
    if t[j]!=r:
      failflag=1
letters=[]
count=[]
for i in range(len(s)):
  if t[i] in letters:
    count[letters.index(t[i])].append(i)
  else:
    count.append([i])
    letters.append(t[i])
for i in count:
  r=s[i[0]]
  for j in i:
    if s[j]!=r:
      failflag=1
if failflag==0:
  print('Yes')
else:
  print('No')

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

#define forn(i,n) for(int i=0;i<int(n);i++)
#define forsn(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define dforsn(i,s,n) for(int i=(int)((n)-1);i>=int(s);i--)
#define si(a) int((a).size())
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define endl '\n'
#ifdef LOCAL
    #define DBG(a) cerr << #a << "=" << a << endl
#else
    #define DBG(a)
#endif
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long int tint;

const int MAXN = 100+10;
pii r[MAXN], b[MAXN];
bool taken[MAXN];

int main() {
    fastio;

    int n;
    cin >> n;
    forn(i, n) cin >> r[i].first >> r[i].second;
    forn(i, n) cin >> b[i].first >> b[i].second;
    sort(r, r+n, [](pii &a, pii &b) {
                return a.second > b.second; 
            });
    sort(b, b+n);

    int cnt = 0;
    forn(i, n) {
        forn(j, n) {
            if (!taken[j] && r[j].first < b[i].first && r[j].second < b[i].second) {
                taken[j] = true;
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
#include <cstdio>
using namespace std;
stack <int> st;
int solve(string);
int main(){
  string str;
  while(cin>>str){
    if(str=="+"||str=="-"||str=="*"||str=="/")
      st.push(solve(str));
    else st.push(atoi(str.c_str()));
    if(getchar()=='\n'){
      cout << st.top() << endl;
      return 0;
    }
  }
}
int solve(string str){
  int b = st.top(); st.pop();
  int a = st.top(); st.pop();
  if(str=="+")return a+b;
  else if(str=="-")return a-b;
  else if(str=="*")return a*b;
  else if(str=="/")return a/b;
}

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

using namespace std;

vector<int> num;

int main(){
	int n, k, tmp;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> tmp, num.push_back(tmp);
	for (int i = k; i < n; i++){
		if (num[i] > num[i - k]) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 4296