akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int i,n,y,m,d,fp[1024] = {0},dd;
	for(i = 1;i <= 999;i++){
		if(i % 3 == 0){
			fp[i + 1] = fp[i] + 200;
		}
		else{
			fp[i + 1] = fp[i] + 195;
		}
	}
	scanf("%d",&n);
	for(i = 1;i <= n;i++){
		scanf("%d%d%d",&y,&m,&d);
		dd = fp[y];
		if(y % 3 == 0){
			dd+=(20*(m-1));
		}
		else{
			if(m == 2){dd+=20;}
			if(m == 3){dd+=39;}
			if(m == 4){dd+=59;}
			if(m == 5){dd+=78;}
			if(m == 6){dd+=98;}
			if(m == 7){dd+=117;}
			if(m == 8){dd+=137;}
			if(m == 9){dd+=156;}
			if(m == 10){dd+=176;}
		}
		dd+=d;
		printf("%d\n",196471-dd);
	}
	return 0;
}

Measured memory_bytes: 600
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut c: Vec<Vec<char>> = vec![];
    for i in 0..2{
        c.push(read_as_string().chars().collect::<Vec<char>>());
    }

    if c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]{
        println!("YES");
    }else{
        println!("NO");
    }
}


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

int main(void){
    int N, M, sum;
    sum = 0;
    cin >> N >> M;
    int A[N];

    for(int i = 0; i < M; ++i){
        cin >> A[i];
        sum += A[i];
    }

    if(sum > N)cout << -1 << endl;
    else cout << N - sum << endl;

}

Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int N; cin >> N;
	string s; cin >> s;
	int ans = 1;
	for (int i = 0;i < N - 1;++i) {
		if (s[i] != s[i + 1])++ans;
	}
	cout << ans << "\n";

	return 0;
}

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

int main() {
    vector<int> vec(5);
    int a = 9;
    int idx = 0;
    rep(i, 5) {
        cin >> vec[i];
        int tmp = vec[i] % 10;
        if (tmp == 0) tmp = 10;
        if (tmp <= a) {
            idx = i;
            a = tmp;
        }
    }
    int ans = 0;
    rep(i, 5) {
        if (i == idx) continue;
        ans += (vec[i] + 10 - 1)/10*10;
    }
    ans += vec[idx];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;

public class Main {


  private static void solve() {
    int l = ni();
    
    
    List<int[]> edges = new ArrayList<>();
    int ptr = 1;
    int now = 0;

    for (int i = 20; i >= 1; i --) {
      if (now > 0) {
        for (int[] v : edges) {
          v[2] *= 2;
        }
        edges.add(new int[] {ptr, ptr + 1, 0});
        edges.add(new int[] {ptr, ptr + 1, 1});
        ptr ++;
        now *= 2;
      }

      if (((l >> (i - 1)) & 1) == 1) {
        if (now == 0) {
          now = 1;
        } else {
          edges.add(new int[] {1, ptr, now});
          now ++;
        }
      }
    }
    
    System.out.println(ptr + " " + edges.size());
    for (int[] e : edges) {
      System.out.println(e[0] + " " + e[1] + " " + e[2]);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	ll K,A,B;
	cin>>K>>A>>B;
	K++;
	if(A>=B){
		cout << K << endl;
		return 0;
	}
	ll ans = K;
	if(K>=A+2){
		ll dif = (K-(A+2))/2;
		ll tmp = B + dif * (B-A);
		if((K-(A+2))%2==1) tmp++;
		chmax(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;


int main(int argc, char** argv){
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i=0; i<N; i++) cin >> H[i];

    int count = 1;
    for (int i=0; i<N; i++){
        if (i == 0) continue;
        bool flag = true;
        for (int j=0; j<i; j++){
            if (H[j] > H[i]){
                flag = false;
                break;
            }
        }
        if (flag == true) count++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	ll ans = 0;
	
	for(int k = 1; k < 30; k++){
		
		int bit_k = 1 << k - 1;
		int mask_k = bit_k - 1;
		int nmask = mask_k << 1 | 1;
		
		vi v;
		rep(i, n) v.pb(b[i] & nmask);
		sort(all(v));
		
		for(int i : a){
			if(i & bit_k){
				ll lo = 0, hi = (~i & mask_k) + 1;
				if(lower_bound(all(v), hi) - lower_bound(all(v), lo) & 1) ans ^= bit_k;
				
				//if(k == 1) dbg(lo, hi);
				
				lo = hi + bit_k;
				if(v.end() - lower_bound(all(v), lo) & 1) ans ^= bit_k;
				//if(k == 1) dbg(lo, hi);
			}
			else{
				ll lo = bit_k, hi = (~i & mask_k) + 1 + bit_k;
				if(lower_bound(all(v), hi) - lower_bound(all(v), lo) & 1) ans ^= bit_k;
				
				lo = (~i & mask_k) + 1; hi = bit_k;
				if(lower_bound(all(v), hi) - lower_bound(all(v), lo) & 1) ans ^= bit_k;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3700
# -*- coding: utf-8 -*-


def solve(w):
    flag = True
    W = list(w)
    W_set = set(W)
    
    for i in range(len(W_set)):
        index = W.count(list(W_set)[i])
        if(index%2 == 1):
            flag = False
            break
            
    if(flag):
        print("Yes")
    else:
        print("No")
    
if __name__ == '__main__':
    w = input()
    
    solve(w)

Measured memory_bytes: 3064
N = int(input())
honest = []
unkind = []

for _ in range(N):
    h_state = []
    u_state = []
    for __ in range(int(input())):
        x, y = map(int, input().split())
        if y == 1:
            h_state.append(x-1)
        else:
            u_state.append(x-1)
    honest.append(h_state)
    unkind.append(u_state)

ans = 0
    
for pattern in range(1 << N):
    for person in range(N):
        is_honest = pattern & 2**person > 0
        if not is_honest:
            continue
        doubt = False
        for tar in honest[person]:
            if not pattern & 2**tar > 0:
                doubt = True
        
        for tar in unkind[person]:
            if pattern & 2**tar > 0:
                doubt = True
        
        if doubt:
            break
        
    else:
        count = 0
        for person in range(N):
            if pattern & 2**person:
                count += 1
        ans = max(ans, count)

print(ans)


Measured memory_bytes: 42864
#include<iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int h[101] = {0};
    int Min = 100;
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
        if (Min > h[i]) {
            Min = h[i];
        }
    }
    for (int i = 0; i < n; ++i) {
        h[i] -= Min;
    }
    int Sum = Min;
    int st, end;
    int flg = 0;
    while (1) {
        for (int i = 0; i < n; ++i) { //all 0 ?
            if (h[i] != 0) {
                break;
            }
            if (i == n - 1) {
                cout << Sum << endl;
                return 0;
            }
        }
        for (int i = 0; i < n; ++i) {
            if (h[i] != 0 && flg == 0) {
                flg = 1;
                st = i;
            }
            if (h[i] != 0 && h[i + 1] == 0) {
                end = i;
                flg = 0;
                Min = 100;
                for (int j = st; j <= end; ++j) {
                    if (Min > h[j]) {
                        Min = h[j];
                    }
                }
                for (int j = st; j <= end; ++j) {
                    h[j] -= Min;
                }
                Sum += Min;
                break;
            }
        }
    }
}






Measured memory_bytes: 256
#include<iostream>
#include<cstring>

using namespace std;

// http://d.hatena.ne.jp/Nekonyan/20110508 
// Nekonyanツつウツづアツづ個コツーツドツづーツ参ツ考ツづ可つオツづ慊つオツつスツ。

int table[10+1][10000];
int memo[10];

void numnum (int size, int depth, int sum )
{
	if (size + 1 == depth ) {
		table[size][sum]++;
	}else{
		for (int i = 0; i <= 9; ++i ){
			if ( memo[i] == 0 ) {
				memo[i] = 1;
				numnum (size, depth + 1, sum + i*depth );
				memo[i] = 0;
			} // end if
		} // end for
	} // end if
}

int main()
{
	memset(table, 0, sizeof (table ) );

	for (int i = 1; i <= 10; ++i ) {
		memset (memo, 0, sizeof (memo ) );
		numnum (i, 1, 0 );
	} // end for

	int n, s;
	while ( cin >> n >> s ) {
		cout << table[n][s] << endl;
	} // end while

	return 0;
}

Measured memory_bytes: 1180
def make_patterns(num_digits):
    res = []
    for i in range(2 ** num_digits):
        res.append(format(i, 'b').zfill(num_digits))
    return res


n, m, x = map(int, input().split())
books = []
for _ in range(n):
    books.append(list(map(int, input().split())))

patterns = make_patterns(n)

res = -1
for pattern in patterns:
    lst = list(pattern)
    cost = 0
    score = [0 for _ in range(m)]
    for i, binary in enumerate(lst):
        if "0" == binary:
            continue
        for j in range(m):
            score[j] += books[i][j + 1]
        cost += books[i][0]
    if all(map(lambda elm: elm >= x, score)):
        if res == -1:
            res = cost
        else:
            res = min(res, cost)
print(res)


Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


char Main(char C)
{
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    auto it = find(ALL(alphabet), C);
    return *(it+1);
}

int main(void){
    char C;
    cin >> C;
    cout << Main(C) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n,k;
	cin >> n >> k;
	ll x[n];
	REP(i,n) cin >> x[i];
	int zero = n - 1;
	REP(i,n){
		if(x[i] > 0){
			zero = i;
			break;
		}
	}
	ll ans = INF;
	for(int i = 0; i <= n - k; i++){
		if(x[i] * x[i + k - 1] > 0){
			if(x[i] > 0) ans = min(ans, x[i + k - 1]);
			else ans = min(ans, -x[i]);
		}else{
			ans = min(ans, x[i + k - 1] - x[i] + min(-x[i], x[i + k - 1]));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int n,x,t;
    cin >> n >> x >>t;
    int now = 0;
    int cnt = 0;
    while(1){
        cnt++;
        now+=x;
        if(now>=n)break;
    }
    cout << cnt*t;
    return 0;
}

Measured memory_bytes: 3644
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

void Bad(){
	cout<<"wrong"<<endl;
	exit(0);
}

const int maxn=200005;
int n;
int a[maxn],pos[maxn],st[maxn*2][30],Log2[maxn],two[maxn];
priority_queue<pair<pii,pii> >q;

pii get_ans(int l,int r){
	int base=Log2[r-l];
	int mn1;
	if(base)mn1=min(st[l][base],st[r-two[base]+1][base]);
	else mn1=st[l][base];
	int pos1=pos[mn1];
	base=Log2[r-pos1-1];
	int mn2;
	if(base)mn2=min(st[pos1+1][base],st[r-two[base]+2][base]);
	else mn2=st[pos1+1][base];
	return mk(-mn1,-mn2);
}

int main(){
//	freopen("E.in","r",stdin);
//	freopen("E.out","w",stdout); 
	scanf("%d",&n);
	REP(i,n)scanf("%d",&a[i]),pos[a[i]]=i;
	two[0]=1;
	REP(i,30)two[i]=two[i-1]*2;
	Log2[0]=0;
	REP(i,n){
		int base=Log2[i-1];
		if(two[base+1]<=i)base++;
		Log2[i]=base;
	}
	REP(i,n)st[i][0]=st[i][1]=a[i];
	int len=1,j=1;
	while(len<n){
		len*=2;
		if(len>n)break;
		j++;
		REP(i,n)st[i][j]=min(st[i][j-1],st[i+len][j-1]);
	}
	q.push(mk(get_ans(1,n),mk(1,n)));
	while(!q.empty()){
		pii c=q.top().fi,d=q.top().se;
		q.pop();
		c.fi=-c.fi;c.se=-c.se;
		printf("%d %d ",c.fi,c.se);
		c.fi=pos[c.fi];c.se=pos[c.se];
		if(c.fi-d.fi>=2)q.push(mk(get_ans(d.fi,c.fi-1),mk(d.fi,c.fi-1)));
		if(c.se-c.fi>=3)q.push(mk(get_ans(c.fi+1,c.se-1),mk(c.fi+1,c.se-1)));
		if(d.se-c.se>=2)q.push(mk(get_ans(c.se+1,d.se),mk(c.se+1,d.se)));
	}
	return 0;
}

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

using namespace std;

using int64 = long long;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
T kruskal(Edges< T > &edges, int V, int idx) {
  UnionFind tree(V);
  T ret = edges[idx].cost;
  tree.unite(edges[idx].src, edges[idx].to);
  for(auto &e : edges) {
    if(tree.unite(e.src, e.to)) ret += e.cost;
  }
  return (ret);
}

using int64 = long long;
const int mod = 1e9 + 7;

int main() {
  int N, M;
  int64 X;
  cin >> N >> M >> X;
  Edges< int64 > e;
  for(int i = 0; i < M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    e.emplace_back(--x, --y, z);
  }
  int a = 0, b = 0, c = 0;
  sort(begin(e), end(e), [](auto &a, auto &b) { return a.cost < b.cost; });
  for(int i = 0; i < M; i++) {
    auto ret = kruskal(e, N, i);
    if(ret == X) ++b;
    else if(ret < X) ++a;
    else ++c;
  }

  int64 mul[100001] = {};
  mul[0] = 1;
  for(int i = 1; i <= 100000; i++) {
    mul[i] = mul[i - 1] * 2 % mod;
  }

  int64 ret = 0;
  if(b == 0) {
    cout << 0 << endl;
    return (0);
  }

  if(a == 0) ret = (mul[b] + mod - 2) % mod;
  else ret = (mul[b] + mod - 1) * 2 % mod;
  (ret *= mul[c]) %= mod;
  cout << ret << endl;
}

Measured memory_bytes: 1152
object Main extends App{
    val Array(a,b,c) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    
    var array = Array(a,b,c)
    var count = 0
    var infinite = false
    
    while(array.forall(_ % 2 == 0) && !infinite){
        count += 1
        array = Array((array(1)/2 + array(2)/2), (array(0)/2 + array(2)/2), (array(0)/2 + array(1)/2))
        if (array sameElements Array(a,b,c)) infinite = true
    }
    
    if (infinite) println(-1) else println(count)
}

Measured memory_bytes: 27336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b)
{
    if (a > b)
        a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b)
{
    if (a < b)
        a = b;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, 0, n) cin >> d[i];
    ll ans = 0;
    rep(i, 0, n) rep(j, i + 1, n) ans += d[i] * d[j];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	makei(N);
	makei(A);
	say(N*N - A);
}

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

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

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
static const int INFTY = (1 << 21);

class Edge{
public:
	int from, to, cost;
	int backedge;
	Edge(int from = 0, int to = 0, int cost = 0) :
		from(from), to(to), cost(cost){
		backedge = -1;
	}

};

class Node{
public:
	vector<Edge> edges;
	int prenum;
	int parent;
	int lowest;
	Node(){
		prenum = -1;
		parent = -1;
	}
};

class Graph{
public:
	vector<Node> nodes;
	int prenum;

	Graph(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
		prenum = 0;
	}

	Node& operator [] (int i){
		return nodes[i];
	}

};

Graph G(0);

void dfs(Edge &e){

	Node& n = G[e.to];

	if (n.prenum != -1) {
		int parent = G[e.from].parent;
		if (e.to == parent){
			e.backedge = -1; // edge to its parent
		}
		else{
			e.backedge = 1; // backedge
		}
		return;
	}

	// set parameter
	G.prenum++;
	e.backedge = 0; // edge-of-DFStree
	n.prenum = G.prenum;
	n.parent = e.from;
	n.lowest = n.prenum;

	for (Edge &eg : n.edges){
		dfs(eg);
	}

	for (Edge &eg : n.edges){
		// edge-of-DFStree
		if (eg.backedge == 0){
			n.lowest = min(n.lowest, G[eg.to].lowest);
		}
		// backedge
		if (eg.backedge == 1){
			n.lowest = min(n.lowest, G[eg.to].prenum);
		}
	}

}


int main() {

	int V, E;
	cin >> V >> E;

	G = Graph(V);

	rep(i, E){
		int from, to;
		cin >> from >> to;
		G[from].edges.push_back(Edge(from, to, 0));
		G[to].edges.push_back(Edge(to, from, 0));
	}

	Edge e0(-1, 0, 0);
	dfs(e0);

	rep(i, V){
		// printf("%d %d %d %d\n", i, G[i].parent, G[i].prenum, G[i].lowest);
	}

	set<int> ret;

	// root
	rep(i, V){
		if (G[i].parent == -1){
			int count = 0;
			rep(j, V){
				if (G[j].parent == i) count++;
			}
			if (count > 1) ret.insert(i);
		}
	}

	// not root
	rep(i, V){
		if(G[i].parent != -1){
			Node& n = G[i];
			Node& p = G[n.parent];
			if (p.prenum <= n.lowest && p.parent != -1){
				ret.insert(n.parent);
			}
		}
	}

	for (int i : ret){
		cout << i << endl;
	}
}

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

int main()
{
   ios::sync_with_stdio(false);
   int n,x,m;
   int ans=0;
   cin>>n>>x;
   int minx=0x3f3f3f3f;
   while(n--)
   {
       cin>>m;
       ans++;
       x-=m;
       minx=min(minx,m);
   }
   ans+=(x/minx);
   cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#ifdef LOCAL
template <class T> ostream &operator<<(ostream &str, const vector<T> &vec) {
  str << '[';
  for (auto it = vec.begin(); it != vec.end(); it++) {
    if (it != vec.begin())
      str << ", ";
    str << *it;
  }
  str << ']';
  return str;
}
#define var(x) "[" << #x << ": " << x << "] "
#define dbg cerr << "  line " << __LINE__ << ": "
#else
#define var(x) 0
struct dbg_cls {
  template <class T> dbg_cls &operator<<(const T &oth) { return *this; }
} dbg;
#endif
using ll = long long;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  auto solve = [&]() {
    string s;
    cin >> s;
    int n = s.length();
    for (auto& c : s)
      if (c == '?')
        c = 'D';
    cout << s << '\n';
    /*int ans = 0;
    for (int i = 0; i < n; i++)
      ans += s[i] == 'D';
    for (int i = 1; i < n; i++)
      if (s[i] == 'D' && s[i - 1] == 'P')
        ++ans;
    cout << ans << '\n';*/
  };
  int t;
  t = 1;
  while (t--)
    solve();
  return 0;
}


Measured memory_bytes: 3780
k,n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
max = 0
a.each_cons(2) do |i,j|
  max = j-i if j-i > max
end
max = k - a[-1] + a[0] if k - a[-1] + a[0] > max
puts k - max


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

//pdf見て解答
//自力で思いつく気がしない

int main(){
    string s; cin >> s;
    
    vector<ll> cnt(s.size()+1,0);
    ll ans = 0;

    for(int i = 1; i <= s.size(); i++){
        if(s[i-1] == '<') cnt[i] = cnt[i-1] + 1;
    }
    for(int i = s.size()-1; i >= 0; i--){
        if(s[i] == '>') cnt[i] = max(cnt[i], cnt[i+1] + 1);
    }

    //for(auto x:cnt) cout << x << " "; cout << endl;

    put(accumulate(cnt.begin(),cnt.end(),0LL));
}

Measured memory_bytes: 7620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10;

void solve() {
    ll n; cin >> n;
    ll a[N]; memset(a, 0, sizeof(a));

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

    int nn; cin >> nn;
    while (nn--) {
        ll b, c; cin >> b >> c;

        sum -= b * a[b];
        sum += c * a[b];

        a[c] += a[b];
        a[b] = 0;
        cout << sum << endl;
    }
}

int main(void) {
    int t; t = 1;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 5196
def main():
    N, M = map(int, input().split())
    sAndc = []
    for _ in range(M):
        sAndc.append(tuple(input().split()))
    for n in range(10**(N-1) if N!=1 else 10**(N-1)-1, 10**N):
        isans = True
        for (s, c) in sAndc:
            if str(n)[int(s)-1] != c:
                isans = False
        if isans:
            return n
    return -1
print(main())

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

int n,d[100100];

int main(){
    cin>>n;
    for(int i=0;i<n;i++){cin>>d[i];}
    sort(d,d+n);
    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }
    cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const long INF = 123456789123456789LL;

template<typename T>
class SegTree {
public:
  int n;
  vector<T> data;
  SegTree(int m){
    n=1;
    while(n<m) n*=2;
    data.resize(2*n, -INF);
  }
  T query(int l, int r){
    T ret = -INF;
    for(l+=n, r+=n; l<r; l/=2, r/=2){
      if(l&1) ret = max(ret, data[l++]);
      if(r&1) ret = max(ret, data[--r]);
    }
    return ret;
  }
  void update(int k, T a){
    k+=n;
    data[k]=a;
    while(k>0){
      k = k/2;
      data[k] = max(data[k*2], data[k*2+1]);
    }
  }
  inline T operator[](int idx){ return data[idx+n]; }
};


int main(){
  int n;long c;
  cin>>n>>c;
  vector<long> x(n), v(n);
  rep(i,n) cin>>x[i]>>v[i];

  long ans = 0;
  rep(_,2){
    SegTree<long> st(n);
    {
      long av = 0;
      for(int i=n-1; i>=0; i--){
        av += v[i];
        st.update(i, av - (c-x[i]));
      }
    }
    long av = 0;
    rep(i,n){
      av += v[i];
      ans = max(ans, av - x[i]);//dbg(ans);
      ans = max(ans, av - 2*x[i] + st.query(i+1, n));//dbg(ans);
    }

    reverse(all(v));
    reverse(all(x));
    rep(i,n) x[i] = c - x[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



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

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

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

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

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char s;
    cin>>s;
    if(s>=65 &&s<=90) cout<<"A"<<endl;
    else cout<<"a"<<endl;
    return 0;
}


Measured memory_bytes: 3652
s = list(input().rstrip())
k = int(input())
ans_list = []

for i in range(len(s)):
    for j in range(i,len(s)+1):
        a = s[i:j]
        if len(a) > k:
            break
        a = "".join(a)
        ans_list.append(a)
        
ans_list = list(set(ans_list))
ans_list.sort()

print(ans_list[k])


Measured memory_bytes: 5084
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = (1LL << 63);

int main() {
	llint n;
	cin >> n;
	hei(ll) a(n),s(n+1,0);
	llint sum = 0;
	rep(i, 0, n) {
		cin >> a[i];
	}
	for (llint i = n - 1; i >= 0; i--) {
		s[i] = s[i + 1] + a[i];
		s[i] %= mod;
	}
	ll ans = 0;
	rep(i, 0, n) {
		ans += a[i] * s[i+1] % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int n,m,a; cin >> n >> m;
    priority_queue<int, vector<int>, less<int>> que;
    rep(i,n) {
        cin >> a;
        que.push(a);
    }
    rep(i,m) {
        a = que.top();
        que.pop();
        a /= 2;
        que.push(a);
    }
    ll ans = 0;
    rep(i,n) {
        a = que.top();
        que.pop();
        ans += a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3928
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, A, B; cin >> N >> A >> B;
    vec<lint> X_list(N);
    range(i, 0, N) cin >> X_list.at(i);
    lint sum_cost = 0;
    range(i, 0, N - 1) {
        lint dist = X_list.at(i + 1) - X_list.at(i);
        sum_cost += (dist * A < B ? dist * A : B);
    }
    cout << sum_cost << "\n";
}

Measured memory_bytes: 1024
#1
def solution(n, skewers):
  sorted_s = sorted(skewers)
  answer = 0
  for i in range(0, 2*n, 2):
    smaller = min(sorted_s[i],sorted_s[i+1])
    answer += smaller
  return answer

n = int(input())
skewers = [int(x) for x in input().split()]
print(solution(n, skewers))

Measured memory_bytes: 9184
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int N;cin>>N;
    vector<int> p(N,0);
    REP(i,N) cin>>p[i];
    sort(p.begin(),p.end());
    ll ans = 0;
    REP(i,N-1) ans += p[i];
    ans += p[N-1]/2;
    cout<<ans;
}

Measured memory_bytes: 256
io = DATA.eof? ? STDIN : DATA
n=io.gets.to_i

Amax=n
D = Array.new(Amax + 2,0)
D[1]=1
(2 .. n).each do |i|
  s = i
  while s < D.size
    if s==i
      D[s]+=2
    else
      D[s]+=1
    end
    s += i
  end
end
puts D[1..(n-1)].sum

__END__


Measured memory_bytes: 22176
#include <stdio.h>
int area(int d)
{
	int sum=0;
	for(int i=1;i<=(600/d)-1;i++){
		sum=sum+d*i*i*d*d;
	}
	return (sum);
}
int main(void)
{
	int d;
	for(int i=1;i<20;i++){
	    while((scanf("%d",&d))>0){
		    printf("%d\n",area(d));
	    }
    }
	return 0;

}


Measured memory_bytes: 1916
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;


long long int d8(long long int c, int n, int d)
{
	int r2 = n % 8;
	if (r2 > 4) r2++;
	if (r2 > 3) r2++;
	c += r2 * pow(10,d - 1);
	if (n / 8 > 0)
		c = d8(c, n / 8, d + 1);
	
	return c;
}

int main()
{
	int n;
	while (cin >> n && n != 0)
	{
		cout << d8(0, n, 1) << endl;
	}

	return 0;
}

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

int main()
{
  int n, h; cin >> h >> n ;
  int total = 0;
  int num = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> num; total += num;
  }
  cout << (h > total ? "No" : "Yes");
  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,a,m,b;
    std::deque<int> deq_a;
    std::deque<int> deq_b;
    std::deque<int> result;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a;
        deq_a.emplace_back(a);
    }
    cin >> m;
    for (int j=0;j<m;j++) {
        cin >> b;
        deq_b.emplace_back(b);
    }
    std::set_union(begin(deq_a),end(deq_a),begin(deq_b),end(deq_b),inserter(result,std::end(result)));
    
    for (int l=0;l<result.size();l++) {
        cout << result[l] << endl;
    }
}



Measured memory_bytes: 5968
n, k = map(int, input().split())
ans = []
for i in range(n): ans.append(0)

for i in range(k):
  no = int(input())
  a = list(map(int, input().split()))
  for j in a:
    #print(j-1)
    ans[j-1] = 1
tmp = 0
for i in ans:
  if(i==0):tmp+=1
print(tmp)
    

Measured memory_bytes: 67696
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  ll L, R, mod=2019;
  cin >> L >> R;
  ll m=10000;
  if (R-L>=2019) {
    cout << 0 << endl;
  }
  else {
    R=R-L/mod*mod;
    L=L-L/mod*mod;
    for (ll i=L; i<=R; i++) {
      for (ll j=i+1; j<=R; j++) {   
        ll n=i*j;
        m=min(m, n-n/mod*mod);
      }
    }
    cout << m << endl;
  }
}

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

int main(){
  int N,count=0,flag=0;

  
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){cin >> A.at(i);}

  while (flag == 0){
    for (int i = 0; i < N; i++){
      if( (A[i])%2 !=0){
        flag = 1;
        break;
      }
      A[i] /= 2;
      
    }
    if(flag!=1)count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var input = chunk.split(" ");
    var output = "";
    var num = new Array();
    
    for(var i = 0; i < input.length; i++){
        num[i] = Number(input[i]);
    }
    
    var cnt = 0;
    for(var j = num[0]; j <= num[1]; j++){
        if((num[2] % j) === 0){
            cnt ++;
        }
    }
    console.log(cnt);
});

Measured memory_bytes: 7648
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

using namespace std;
#define prev prev55

long long n, m;
long long MOD = 1e9 + 7;
long long ans = 1;
int a[5000], b[5000];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    sort(a, a + n);
    reverse(a, a + n);
    sort(b, b + m);
    reverse(b, b + m);
    int x = 0, y = 0;
    for (int i = 0; i < n; i++) if (i + 1 < n && a[i] == a[i + 1]) {cout << 0; return 0;}
    for (int i = 0; i < m; i++) if (i + 1 < m && b[i] == b[i + 1]) {cout << 0; return 0;}
    for (int i = n * m; i >= 1; i--)
    {
        while (x < n && a[x] >= i) x++;
        while (y < m && b[y] >= i) y++;
        if (x == 0 || y == 0)
        {
            cout << 0;
            return 0;
        }
        if (a[x - 1] == i && b[y - 1] == i)
        {
            continue;
        }
        if (a[x - 1] == i)
        {
            ans = ans * y % MOD;
            continue;
        }
        if (b[y - 1] == i)
        {
            ans = ans * x % MOD;
            continue;
        }
        ans = (ans * (x * y - (n * m - i))) % MOD;
        //cout << x << " " << y << endl;
        //cout << x * y - n * m + i << endl;
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int a[] = new int[n];
      	int s = 0;
      	for (int i = 0; i < n; i++){
          	a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        s = a[n/2] - a[n/2-1];
        System.out.println(s);
    }
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        
        if (n==0) {
            break;
        }
        
        map<int, int> mp;
        
        for (int i=0; i<10; i++) {
            mp[i] = 0;
        }
        
        for (int i=0; i<n; i++) {
            int ci;
            cin >> ci;
            mp[ci] += 1;
        }
        
        for (int i=0; i<10; i++) {
            if (mp[i]==0) {
                cout << '-' << endl;
            }
            else {
                for (int j=0; j<mp[i]; j++) {
                    cout << "*";
                }
                
                cout << endl;
            }
        }
    }
}


Measured memory_bytes: 3004
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long a,b,n,x,t;
    cin >> a >> b >> n;

    if(b-1<n)x=b-1;
    else x=n ;
    t = floor(a*x/b);
    
    
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3604
#include "stdio.h"

main(){

  int A[100], i=0, j, c=0, n, swap, flag = 1;

  scanf("%d", &n);

  for(j=0 ; j<n ; j++){
    scanf("%d", &A[j]);
  }

  while(flag==1){

    flag = 0;

    for(j=(n-1) ; j>=i+1 ; j--){

      if(A[j] < A[j-1]){

	swap = A[j];
	A[j] = A[j-1];
	A[j-1] = swap;

	flag = 1;
	c++;
      }

    }
    i++;
  }

  for(j=0 ; j<n ; j++){
  printf("%d", A[j]);
  if(j<(n-1)) printf(" ");
  else{printf("\n");
   }
  }
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 604
def bitcount(N):  # 立ってるbitの数
    bitcnt = [0]
    for _ in range(N):
        bitcnt += [i + 1 for i in bitcnt]
    return bitcnt


n, x = int(input()), input()

num, cnt = int(x, 2), x.count('1')
lbit = bitcount(18)
for i in range(n):
    ans = 1
    if x[i] == '0':
        ctmp = cnt + 1
        tmp = num % ctmp + pow(2, n - (i + 1), ctmp)
    elif x[i] == '1':
        ctmp = cnt - 1
        if ctmp == 0:
            print(0)
            continue
        tmp = num % ctmp - pow(2, n - (i + 1), ctmp)
    tmp %= ctmp
    ctmp = lbit[tmp]
    while tmp > 0:
        ans += 1
        tmp %= ctmp
        ctmp = lbit[tmp]
    print(ans)


Measured memory_bytes: 86888
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define all(c) (c).begin(),(c).end()
#define ss second
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >
#define Inp(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define Out(a,n,ch) for(int i=0;i<n;i++)cout<<a[i]<<ch;cout<<endl;

map <int,vi> adj;
int visited[200005],ct=1;

void dfs(int x)
{
	visited[x]=1;
	for(int i=0;i<adj[x].size();i++)
	{
		if(!visited[adj[x][i]])
		{
			ct++;
			dfs(adj[x][i]);
		}
	}
}
int32_t main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n,m,a,b;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(!visited[i])
		{
			dfs(i);
			ans = max(ans,ct);
			ct=1;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}


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

void Grade(int m, int f, int r);

int main(){
    int m[50], f[50], r[50];
    int i = 0;
    
    while(1){
        cin >> m[i] >> f[i] >> r[i];
        if(m[i] == -1 && f[i] == -1 && r[i] == -1) break;
        i++;
    }
    
    for(int j = 0; j < i; j++){
        Grade(m[j], f[j], r[j]);
    }
    return 0;
}

void Grade(int m, int f, int r){
    if(m == -1 || f == -1) cout << 'F' << endl;
    else if(m + f >= 80) cout << 'A' << endl;
    else if(m + f >= 65 && m + f < 80) cout << 'B' << endl;
    else if(m + f >= 50 && m + f < 65) cout << 'C' << endl;
    else if(m + f >= 30 && m + f < 50){
        if(r >= 50) cout << 'C' << endl;
        else cout << 'D' << endl;
    }else if(m + f < 30) cout << 'F' << endl;
}


Measured memory_bytes: 3084