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

using namespace std;
typedef long long ll;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
bool isPar(string s)
{
    ll n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return 0;
        }
    }
    return 1;
}

ll nOfD(ll n)
{
    ll d=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) d+=2;
        i++;
    }
    if(i * i == n)d++;
    return d;
}
ll sOfD(ll n)
{
    ll sum=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) sum+=i,sum+=n/i;
        i++;
    }
    if(i * i == n)sum+=i;
    return sum;
}
bool isP(ll x)
{
    if(x==2)return 1;
    if(x<2 || x%2==0)return 0;
    for(ll i=3;i * i <= x;i+=2)
    {
        if(x%i==0)return 0;
    }
    return 1;
}
ll lcm(ll a, ll b)
{
    return (a / __gcd(a, b) * b);
}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("op.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,ans=0,x;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>x;
            if(i%2 && x%2)ans++;
        }
        cout<<ans;
    }
    return 0;
}


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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
int n,m;
vector <int> a[100001];
int dp[100001];
int dfs(int u)
{
    if(dp[u]!=-1)
        return dp[u];
    int res=0;
    for(auto v:a[u])
        res=max(res,dfs(v));
    res++;
    return dp[u]=res;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        a[u].push_back(v);
    }
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++)
        if(dp[i]==-1)
            dfs(i);
    int kq=0;
    for(int i=1;i<=n;i++)
        kq=max(kq,dp[i]);
    cout<<kq-1;
    return 0;
}


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


int main(){
  int N;
  cin >> N  ;
 vector<int> K(N);
  for(int i =0; i<N; i++){
    cin>> K.at(i);
  }
    
 int count1 =0;
  
  int count3=10000000;
  for (int q=1;q<101;q++){
    int count2=0;
    for (int r=0;r<N;r++){
      count1=(q-K.at(r))*(q-K.at(r));
     if (count1<0){
        count1=count1*(-1);
       }
      count2+=count1;
    }
    if (count2<count3){
      count3=count2;
    }
  }
  
  cout<< count3 <<endl;
      
   
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <list>

int main()
{
	int n;
	while(1){
		std::cin >> n;
		if(n == 0) break;
		int sum=0, cnt=0;
		for(int i = 1; i <= n/2; i++){
			sum = i;
			for(int j = i+1; j < n; j++){
				sum += j;
				if(sum > n) break;
				if(sum == n){
					cnt++;
					break;
				}
			}
		}
		std::cout << cnt << std::endl;
	}
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int n, k; cin >> n >> k;
    double res;
    for (int i = 1; i <= n; i++) {
        int curr = i;
        double tmp = 1.0;
        while (curr < k) {
            tmp *= 0.5;
            curr *= 2;
        }
        res += tmp;
    }
    
    res /= (double)n;
    
    cout.precision(12);
    cout << fixed;
    cout << res << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)(1e18)
#define mod 1000000007

int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        int n,k;
        cin>>n>>k;

        bool snuke[n+1]={0};
        for( int i=0 ; i<k ; i++ )
        {
            int d;
            cin>>d;

            for( int j=0 ; j<d ; j++ )
            {
                int a;
                cin>>a;
                snuke[a]=1;
            }
        }

        int ans=0;
        for( int i=1 ; i<=n ; i++ )
        {
            if(!snuke[i])
                ans++;
        }

        cout<<ans;
    }
    return 0;
}












Measured memory_bytes: 3568
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

#define INF 1LL << 50

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

// BellmanFord
void solve(long long N, long long M, vector<long long> a, vector<long long> b,
           vector<long long> c) {

  ll dist[N];
  fill(dist, dist + N, INF);
  dist[0] = 0;

  REP(n, N - 1)
  REP(i, M) {
    if (dist[a[i]] == INF)
      continue;
    if (dist[b[i]] > dist[a[i]] + c[i]) {
      dist[b[i]] = dist[a[i]] + c[i];
    }
  }

  ll ans = dist[N - 1];
  bool nega[N] = {};

  REP(n, N)
  REP(i, M) {
    if (dist[a[i]] == INF)
      continue;
    if (dist[b[i]] > dist[a[i]] + c[i]) {
      dist[b[i]] = dist[a[i]] + c[i];
      nega[b[i]] = true;
    }
    if (nega[a[i]]) {
      nega[b[i]] = true;
    }
  }

  cout << ((nega[N - 1]) ? "inf" : to_s(-ans)) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  long long M;
  cin >> N;
  cin >> M;
  vector<long long> c(M - 1 + 1);
  vector<long long> b(M - 1 + 1);
  vector<long long> a(M - 1 + 1);
  for (int i = 0; i <= M - 1; i++) {
    cin >> a[i];
    a[i]--;
    cin >> b[i];
    b[i]--;
    cin >> c[i];
    c[i] = -c[i];
  }
  solve(N, M, a, b, c);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;
}

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

#define QQ 9
int main() {
	for (int i = 1; i <= QQ; i++) {
		for (int j = 1; j <= QQ; j++) {
			cout << i << "x" << j << "=" << i * j << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1112
from itertools import product


def find_center(n, xyh):
    for cx, cy in product(range(101), repeat=2):
        for i in range(n):
            x, y, h = xyh[i]
            if i == 0:
                H_ans = h + abs(x - cx) + abs(y - cy)
                continue

            dist = abs(x - cx) + abs(y - cy)
            H_estimate = h + dist

            if H_ans == H_estimate:
                continue

            if H_estimate != H_ans:
                if h > 0:
                    break
                if dist <= H_ans:
                    break
        else:
            return cx, cy, H_ans


if __name__ == "__main__":
    n = int(input())
    xyh = [tuple(map(int, input().split())) for _ in range(n)]
    xyh.sort(reverse=True, key=lambda x: x[-1])
    ans = find_center(n, xyh)
    print(*ans)


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;
  int si = s.size();

  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < si; ++i) {
    if (i % 2 == 0) {
      if (s[i] == '0') {
        ++cnt1;
      } else {
        ++cnt2;
      }
    } else {
      if (s[i] == '1') {
        ++cnt1;
      } else {
        ++cnt2;
      }
    }
  }

  cout << min(cnt1, cnt2) << '\n';

  return 0;
}


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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> Pair;
typedef vector<Pair> VP;

#define MOD 1000000007
#define times(n) rep(_idx, n)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mk make_pair
#define OUT(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;

template<typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}

int main() {
    int N, A, B, C, D;
    string S;

    cin >> N >> A >> B >> C >> D >> S;

    S = "#" + S + "##";
    REP(i, A, C) if (S[i] == '#' && S[i + 1] == '#') { OUT("No"); return 0; }
    REP(i, B, D) if (S[i] == '#' && S[i + 1] == '#') { OUT("No"); return 0; }
    if (C < D) { OUT("Yes"); return 0; }
    REP(i, B - 1, D) if(S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
        OUT("Yes"); return 0;
    }
    OUT("No");
    return 0;
}

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

int
main ()
{
  int len;
  string str;
  cin >> len;
  if (len % 2)
    {
      cout << "No" << endl;
      return 0;
    }
  cin >> str;
  int half = len / 2;
  if (str.substr(0, half) != str.substr(half, half))
    {
      cout << "No" << endl;
      return 0;
    }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=Counter(a)
c=len(([i[0] for i in b.items() if i[1] == 2]))
if n%2==0:
    if n//2==c:
        print(2**(len(set(a)))%1000000007)
    else:
        print(0)
else:
    if (n-1)//2==c and a.count(0)==1:
        print(2**(len(set(a))-1)%1000000007)
    else:
        print(0)


Measured memory_bytes: 15328
from sys import stdin
n = int(input())
a = list(map(int, stdin.readline().split()))
a.sort()
amax = max(a)+1
e = [0]*amax
ans = 0

for i in range(n):
    e[a[i]] += 1
    if e[a[i]] == 1:
        for j in range(2*a[i], amax, a[i]):
            e[j] += 2

print(e.count(1))

Measured memory_bytes: 31308
A, B = map(int, input().split())
ans = 0
minprice = 1010
for i in range(1, 1010): #B<=100よりmax1009円+1
    if int(i*0.08)==A and int(i*0.10)==B:
        minprice = min(minprice,i)
        ans = 1
print(minprice if ans == 1 else -1)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            var n = int.Parse(Console.ReadLine());

            // 整数配列の入力
            var x = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var minSum = int.MaxValue;

            for(int i = 1; i <= 100; i++) {
                var sum = 0;
                for(int j = 0; j < x.Length; j++) {
                    sum += (int)Math.Pow(x[j] - i, 2);
                }

                if(sum < minSum) {
                    minSum = sum;
                }
            }

            Console.WriteLine(minSum);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> nums = new ArrayList<Integer>();
		for(int i = 0; i < 3; i++) {
			nums.add(sc.nextInt());
		}
		Collections.sort(nums);
		int k = sc.nextInt();

		int sum = 0;
		for(int i = 0; i < 3; i++) {
			if(i == 2) {
				int tmp = nums.get(i);
				for(int j = 0; j < k; j++) {
					tmp *= 2;
				}
				sum += tmp;
			} else {
				sum += nums.get(i);
			}
		}
		System.out.println(sum);
	}
}


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

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    A[] a = new A[N];
    B[] b = new B[N];
    for (int i = 0; i < N; i++) {
      a[i] = new A(Integer.parseInt(scanner.next()), Integer.parseInt(scanner.next()));
    }
    for (int i = 0; i < N; i++) {
      b[i] = new B(Integer.parseInt(scanner.next()), Integer.parseInt(scanner.next()));
    }
    Arrays.sort(a);
    Arrays.sort(b);
    boolean[] isUsedA = new boolean[N];
    Arrays.fill(isUsedA, false);
    int ans = 0;
    for (int idxB = 0; idxB < N; idxB++) {
      for (int idxA = N - 1; idxA >= 0; idxA--) {
        if (a[idxA].getX() < b[idxB].getX() && a[idxA].getY() < b[idxB].getY() && isUsedA[idxA] == false) {
          ans++;
          isUsedA[idxA] = true;
          break;
        }
      }
    }
    System.out.println(ans);
  }

  public static class B implements Comparable<B> {
    private int X;
    private int Y;

    public B(int X, int Y) {
      this.setX(X);
      this.setY(Y);
    }

    public int getX() {
      return this.X;
    }

    public void setX(int x) {
      this.X = x;
    }

    public int getY() {
      return this.Y;
    }

    public void setY(int y) {
      this.Y = y;
    }

    @Override
    public int compareTo(B b) {
      return this.getX() - b.getX();
    }
  }

  public static class A implements Comparable<A> {
    private int X;
    private int Y;

    public A(int X, int Y) {
      this.setX(X);
      this.setY(Y);
    }

    public int getX() {
      return this.X;
    }

    public void setX(int x) {
      this.X = x;
    }

    public int getY() {
      return this.Y;
    }

    public void setY(int y) {
      this.Y = y;
    }

    @Override
    public int compareTo(A a) {
      return this.getY() - a.getY();
    }
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
int main(void){
   int i = 0;
   char str[8];
   char fu = '+';
   scanf("%s",str);
for(int b=0;b<4;b++){
    
   if(str[b]==fu){
     i++;   
}else{
   i--;
   }
}
 printf("%d\n",i);
return 0;
}

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

const int INF = 1001001001;
vector<int> to[100005];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b; //頂点を0からにするためにディクリメント
    //a  ⇄  b の辺 (これは無向グラフのため両方向にいける)
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  //頂点までの各点からの距離をINFで初期化
  vector<int> dist(n, INF);
  //最短経路における一つ前の点をメモ
  vector<int> pre(n, -1);
  dist[0] = 0; //頂点の距離は0
  q.push(0);   //頂点をqueueにいれる
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (int u : to[v]) {     //uにto[v]の中身をto[v]の配列の先頭から代入 
      if (dist[u] != INF) continue;
      dist[u] = dist[v]+1;   //距離の更新 
      pre[u] = v;            //前の点をメモ
      q.push(u);
    }
  }
  
  cout << "Yes" << endl;
  rep(i,n) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 10656
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const ll mod = 7*17*(1<<23) + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll s;
	cin >> s;
	cout << "0 0 " << ((s+999999999)/1000000000) << " 1 ";
	cout << (s%1000000000?(1000000000-(s%1000000000)):0) << " 1000000000";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a;
  cin >> n >> a;
  /**/
  if(n<=a||n%500==0||(n%500)<=a){
    cout << "Yes" << endl;
  }else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
//------------------------------------------------------------

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean buyability = false;

		for (int i=0 ; 4*i<=n ; ++i) {
			for (int j =0 ; 7*j<=n-4*i ; ++j) {
				int total = 4*i+7*j ;
				if (total == n) {
					buyability =true;
				}
			}
		}
		if (buyability) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
//------------------------------------------------------------
	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int n;
	cin>>n;
	vector<int> H;
	int h;
	rep(i,n){
		cin>>h;
		H.push_back(h);
	}
	int ans = 0;
	int i=0;
	while(i<n){
		if(H[i] > 0){
			ans++;
			for(int j=i; j<n; j++){
				if(H[j] > 0){
					H[j]--;
				}else{
					break;
				}
			}
		}else{
			i++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import collections
import string
import heapq
s=input()
n = len(s)
k = int(input())

m = ['zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz']
subs = []
for i in range(n):
    for j in range(i+1, min(i+6, n+1)):
        sub = s[i:j]
        if sub not in subs:
            subs.append(sub)
            subs.sort()
            subs = subs[:5]
print(subs[k-1])


Measured memory_bytes: 3960
#include <bits/stdc++.h>
    using namespace std;
        int main() {
        	int N, M;
    		cin >> N >> M;

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

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

			int result = -1;
			if(sum <= N)	result = N - sum;
			
			cout << result << endl;

        }

Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
typedef pair<P, long long> P2;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
#define MOD 1000000007

int N, Q;
long long A[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> Q;
  set<P2> S;
  S.insert(P2(P(0, N-1), 0));
  rep(i, Q) {
    int a;
    long long b;
    cin >> a >> b;
    a--;
    auto it = --S.upper_bound(P2(P(a+1, -1), -1));
    P2 p = *it;
    if (p._1._2 > a) {
      S.erase(it);
      S.insert(P2(P(a+1, p._1._2), p._2));
      it = S.insert(P2(P(p._1._1, a), p._2))._1;
    }
    while (true) {
      P2 cur = *it;
      long long w = cur._1._2-cur._1._1+1;
      long long lim = INF;
      if (it != S.begin()) {
        lim = (--it)->_2 - cur._2;
        it++;
      }
      long long up = min(lim, b/w);
      cur._2 += up;
      b -= 1LL*up*w;
      if (it != S.begin() && up == lim) {
        it = S.erase(it);
        int left = (--it)->_1._1;
        S.erase(it);
        it = S.insert(P2(P(left, a), cur._2))._1;
      }
      else {
        S.erase(it);
        it = S.insert(cur)._1;
        break;
      }
    }
    if (b > 0) {
      P2 cur = *it;
      int left = it->_1._1, border = left+b;
      S.erase(it);
      S.insert(P2(P(left, border-1), cur._2+1));
      S.insert(P2(P(border, a), cur._2));
    }
  }
  for (P2 p : S) {
    int l = p._1._1, r = p._1._2;
    long long val = p._2;
    for (int i=l; i<=r; i++) A[i] = val;
  }
  rep(i, N) cout << A[i] << "\n";
  return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c[3];
	int i;
	for(i=0;i<3;i++)
	{
		scanf("%c",&c[i]);
	}
	if(c[0]==c[1]&&c[1]==c[2])
	printf("No");
	else
	printf("Yes");
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000
#define NMAX 102

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A[NMAX],B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
vector<int > v;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	sort(v.begin(), v.end());
	ans = v[N-1]-v[0];
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		v.push_back(A[i]);
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
from collections import deque
 
H,W = map(int,readline().split())
H += 2; W += 2
grid = '#' * W
for _ in range(H-2):
    grid += '#' + readline().rstrip().decode() + '#'
grid += '#' * W
 
def bfs(start):
    INF = 10 ** 9
    dist = [INF] * (H*W)
    dist[start] = 0
    q = deque([start])
    while q:
        v = q.popleft()
        dv = dist[v]
        for move in (-1,1,W,-W):
            w = v + move
            if grid[w] == '#':
                continue
            dw = dv + 1
            if dw >= dist[w]:
                continue
            dist[w] = dw
            q.append(w)
    return max(x for x in dist if x < INF)
 
answer = max(bfs(v) for v in range(H*W) if grid[v] != '#')
print(answer)

Measured memory_bytes: 3316
N=int(input())
restaulant=[]
for i in range(N):
    restaulant.append(input().split())
    restaulant[i][1]=-1*int(restaulant[i][1])
sorted_rest=sorted(restaulant)
for i in sorted_rest:
    for j in range(N):
        if i==restaulant[j]:
            print(j+1)

Measured memory_bytes: 3060
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    i64 n, k;
    std::cin >> n >> k;
    std::vector<i64> a(n);
    std::vector<i64> f(n);
    rep(i, n) std::cin >> a[i];
    rep(i, n) std::cin >> f[i];
    std::sort(a.begin(), a.end());
    std::reverse(a.begin(), a.end());
    std::sort(f.begin(), f.end());
    // 二分探索
    i64 ng = -1,
        ok = 1e18 + 10;
    while(std::abs(ok - ng) > 1) {
        i64 mid = ng + (ok - ng) / 2;
        i64 cnt = 0;
        rep(i, n) {
            cnt += std::max<i64>(a[i] - mid / f[i], 0LL);
        }
        if(cnt <= k) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    std::cout << ok << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3328
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int N = ri();
		Console.WriteLine(N * 800 - (N / 15) * 200);
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
inp = input()


lst = list(inp)
stk = []
stk2 = []

for i in range(len(lst)):
    if lst[i] == '\\':
        stk.append(i)
    if lst[i] == '/' and len(stk)>0:
        idx = stk.pop()
        a = i - idx
        if len(stk2) > 0:
            while(len(stk2) > 0):
                tmp = stk2.pop()
                if idx < tmp[0]:
                    a += tmp[1]
                else:
                    stk2.append(tmp)
                    break
        stk2.append([idx, a])

s = 0
l = []

for i in stk2:
    l.append((i[1]))
    s += i[1]
print(s)
if(len(stk2) > 0):
    print(len(stk2), end=' ')
    print(*l)
else:
    print("0")



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

using namespace std;

typedef long long ll;
typedef long double ld;
const ld INF = 1e10;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  ll N;
  cin >> N;
  vector<ll> a(N);
  ll big = -INF;
  ll bigi = 0;
  ll sma = INF;
  ll smai = 0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(a[i] > big){
      big = a[i];
      bigi = i;
    }
    if(a[i] < sma){
      sma = a[i];
      smai = i;
    }
  }
  cout << N*2 - 1 << endl;
  if(big >= 0 && abs(big) >= abs(sma)){
    for(int i=0;i<N;i++)
      cout << bigi+1 << " " << i+1 << endl;
    for(int i=1;i<N;i++)
      cout << i-1+1 << " " << i+1 << endl;
  }else{
    for(int i=0;i<N;i++)
      cout << smai+1 << " " << i+1 << endl;
    for(int i=1;i<N;i++)
      cout << N-i+1 << " " << N-i-1+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import itertools
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        D, G = map(int, input().split())

        p = {}
        c = {}
        for i in range(1, D + 1):
            p[i], c[i] = map(int, input().split())

        ans = 10 * 100
        for i in range(D + 1):
            for comb in itertools.combinations(range(1, D + 1), i):
                score = 0
                ac = 0

                for index in comb:
                    score += c[index] + p[index] * index * 100
                    ac += p[index]

                if score >= G:
                    ans = min(ans, ac)
                    continue

                for j in range(1, D + 1)[::-1]:
                    if j in comb:
                        continue

                    if score >= G:
                        break

                    for _ in range(1, p[j]):
                        score += (j * 100)
                        ac += 1

                        if score >= G:
                            ans = min(ans, ac)

                            break
        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 42972
N = int(input())

#モンスター
A = list(map(int,input().split()))
#勇者
B = list(map(int,input().split()))

#モンスターを倒した数
count = 0

for i in range(N):
    #勇者の数が多い
    if B[i] > A[i]:
        #モンスターを全部倒す
        count += A[i]
        #倒した分だけ勇者をへらす
        B[i] -= A[i]
        #次の街に倒しにいく
        #勇者は次の街のモンスターを全部倒せる
        if B[i] > A[i+1]:
            #モンスターを全部倒す
            count += A[i+1]
            A[i+1] = 0
        #勇者の数が足らないのでできるだけ倒す
        else:
            count += B[i]
            A[i+1]-=B[i]
    #勇者の数がモンスターと一緒か足らない
    else:
        #勇者の数だけモンスターを倒す
        count += B[i]
        #倒した分だけモンスターを減らす
        A[i] -= B[i]

print(count)


Measured memory_bytes: 82020
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;
    
    namespace ConsoleApp2
    {
    class Program
    {
        static long H;
        static long W;
        static String[] map;
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();


            var dic = new Dictionary<long,long>();
            for (int i = 0; i < N; i++)
            {
                if (dic.ContainsKey(A[i]))
                {
                    dic[A[i]]++;
                }
                else
                {
                    dic.Add(A[i], 1);
                }
            }

            var over2 = new List<long>();
            var over4 = new List<long>();
            over2.Add(0);
            over4.Add(0);
            foreach (var item in dic)
            {
                if (item.Value >= 2)
                {
                    over2.Add(item.Key);
                }

                if (item.Value >= 4)
                {
                    over4.Add(item.Key);
                }
            }

            var tmp2 = over2.OrderByDescending(x => x).ToArray();
            var tmp4 = over4.OrderByDescending(x => x).ToArray();

            if(tmp4[0] >= tmp2[0])
            {
                Console.WriteLine(tmp4[0]* tmp4[0]);
            }
            else
            {
                Console.WriteLine(tmp2[0] * Max(tmp4[0],tmp2[1]));
            }
            
        }
    }

}


Measured memory_bytes: 30304
C=[list(map(int,input().split())) for i in range(3)]
for a in range(101):
    for b in range(101):
        for c in range(101):
            d=C[0][0]-a
            e=C[1][1]-b
            f=C[2][2]-c
            if all([b+d==C[0][1],c+d==C[0][2],a+e==C[1][0],c+e==C[1][2],a+f==C[2][0],b+f==C[2][1]]):
                print('Yes')
                exit()
print('No')

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

int n;

int main()
{
    cin >> n;
    set<string> st;
    rep(i, n)
    {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    
    return 0;
}

Measured memory_bytes: 19256
N,M = (int(i) for i in input().split()) 
a = set(int(input()) for i in range(M))

mod=10**9+7

dp=[0]*(N+1)

dp[0]=1
if 1 in a:
	dp[1]=0
else:
	dp[1]=1

for i in range(0, N-1):
	if i+2 in a:
		dp[i+2]=0
	else:
		dp[i+2]+=dp[i+1]+dp[i]
	
print(dp[N]%mod)

Measured memory_bytes: 462708
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll k, a, b;
  cin >> k >> a >> b;
  ll val = (a + k - 1)/k;
  val*=k;
  if(val <= b) cout << "OK";
  else cout << "NG";
  return 0;
} //good night.

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    ll n, k;
    cin >> n >> k;
    cout << min(n % k, abs(n % k - k)) << '\n';
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  int X;
  cin>>X;
  int i=1,sum=1;
  while(sum<X){
    i++;
    sum+=i;
  }
  cout<<i<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,k;
  char S[500];
  int N;
  scanf("%d %d",&N,&j);
  for(i=0;i<N;i++){
    scanf("%s",S);
    printf("%s\n",S);
    printf("%s\n",S);
  }
  return 0;
}

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

N, K = map(int, input().split())
H = []
for i in range(N):
    H.append(int(input()))

H.sort()

ans = H[-1] - H[0]
for i in range(len(H) - K + 1):
    ans = min(ans, H[i + K - 1] - H[i])

print(ans)


Measured memory_bytes: 7384
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
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/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,Pll> a,pair<ll,Pll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se.fi>b.se.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    ll n;cin>>n;
    V<ll>p(n);
    for(ll i=0;i<n;i++)cin>>p[i];
    ll longe=0;
    map<ll,ll>m;
    for(ll i=0;i<n;i++){
        if(p[i]==1){
            m[1]=1;
        }
        else{
            if(m[p[i]-1]>0){
                m[p[i]]=m[p[i]-1]+1;
            }
            else{
                m[p[i]]=1;
            }
        }
        chmax(longe,m[p[i]]);
    }
    cout<<n-longe<<endl;
    //-------------------------------  
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------






















































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

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i) >> C.at(i);
  // dp[i][j] := i 日終了時点の幸福度の総和の最大値。j は i 日目に行った活動
  vector<vector<int>> dp(N+1, vector<int>(3, 0));
  for (int i = 0; i < N; i++) {
    dp.at(i+1).at(0) = max(dp.at(i+1).at(0), dp.at(i).at(1) + A.at(i));
    dp.at(i+1).at(0) = max(dp.at(i+1).at(0), dp.at(i).at(2) + A.at(i));
    dp.at(i+1).at(1) = max(dp.at(i+1).at(1), dp.at(i).at(0) + B.at(i));
    dp.at(i+1).at(1) = max(dp.at(i+1).at(1), dp.at(i).at(2) + B.at(i));
    dp.at(i+1).at(2) = max(dp.at(i+1).at(2), dp.at(i).at(0) + C.at(i));
    dp.at(i+1).at(2) = max(dp.at(i+1).at(2), dp.at(i).at(1) + C.at(i));
  }
  int ans = 0;
  for (int j = 0; j < 3; j++) ans = max(ans, dp.at(N).at(j));
  cout << ans << endl;
}

Measured memory_bytes: 6912
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int A[100010], B[100010];
    rep(i, n + 1) cin >> A[i];
    rep(i, n) cin >> B[i];
    ll ans = 0;
    rep(i, n) {
        int tmp = min(A[i], B[i]);
        ans += tmp;
        B[i] -= tmp;
        tmp = min(A[i + 1], B[i]);
        ans += tmp;
        A[i + 1] -= tmp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define N (100)

int main(void){
    int M[N][N];
    int n,u,k,v;
    
    cin>>n;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j)cout<<" ";
            cout<<M[i][j];
        }
        cout<<endl;
    }
    return 0;
}



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

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        int n = input.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) S[i] = input.nextInt();
        
        int q = input.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) T[i] = input.nextInt();
        
        Arrays.sort(S);
        Arrays.sort(T);
        
        int i = 0, j = 0, count = 0;
        while (j < q && i < n) {
            if (S[i] < T[j]) {
                i++;
            } else if (S[i] == T[j]) {
                count++;
                while (i < n && S[i] == T[j]) i++;
            } else {
                j++;
            }
        }
        
        System.out.println(count);
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
    
    private static class Scanner {
        BufferedReader r;
        StreamTokenizer st;
        
        public Scanner(InputStream in) {
            r = new BufferedReader(new InputStreamReader(in));
            st = new StreamTokenizer(r);
        }
        
        public String next() {
            nextToken();
            return st.sval;
        }
        
        public Integer nextInt() {
            nextToken();
            return (int)st.nval;
        }
        
        private int nextToken() {
            int token = st.TT_EOF;
            try {
                token = st.nextToken();
            } catch (IOException e) {
            }
            return token;
        }
    }
}

Measured memory_bytes: 24820
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
int main()
{
	string s;
	cin>>s;
	if(s=="ABC")
	cout<<"ARC"<<endl;
	else
	cout<<"ABC"<<endl;
} 

Measured memory_bytes: 3620
#include<iostream>

using namespace std;

int count( int i, int n )
{
  if ( i == 4 )
    if ( n == 0 )
      return 1;
    else
      return 0;
  else
    {
      if ( n < 0 ) return 0;
      
      int ret = 0;
      for ( int j = 0; j < 10; j++ )
        {
          ret += count( i+1, n - j );
        }
      return ret;
    }
}

int main()
{
  int n;
  
  while ( cin >> n )
    cout << count(0, n) << endl;

  return 0;
}

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

int main(void) {
    int N;
    cin >> N;
    
    vector<int>d(N);
    for (int i = 0; i < N; i++) {
        cin >> d.at(i);
    }
    
    sort(d.begin(), d.end());
    
    vector<int> dan;
    int j = 0;
    dan.push_back(d.at(0));
    for (int i = 1; i < N; i++) {
        if (d.at(i) != dan.at(j)) {
            dan.push_back(d.at(i));
            j++;
        }
    }
    



    cout << dan.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000000000000LL
using namespace std;
typedef long long int ll;

ll A,B,C,D;
map <ll,ll> dp;

ll dfs(ll n)
{
	if(n==0) return 0;
	if(dp.find(n)!=dp.end()) return dp[n];
	ll ret=INF;
	if(n<=INF/D) ret=n*D;
	for(int t=-4;t<=4;t++)
	{
		ll x=n+t;
		if(x%2==0&&abs(t)<2&&x/2<n&&x>=0) ret=min(ret,dfs(x/2)+A+D*abs(t));
		if(x%3==0&&abs(t)<3&&x/3<n&&x>=0) ret=min(ret,dfs(x/3)+B+D*abs(t));
		if(x%5==0&&abs(t)<5&&x/5<n&&x>=0) ret=min(ret,dfs(x/5)+C+D*abs(t));
	}
	return dp[n]=ret;
}
	
void solve()
{
	ll N;
	scanf("%lld %lld %lld %lld %lld",&N,&A,&B,&C,&D);
	dp.clear();
	printf("%lld\n",dfs(N));
}
int main()
{
	int T;
	scanf("%d",&T);
	while(T--) solve();
	return 0;
}

Measured memory_bytes: 4628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll H,W,K;cin>>H>>W>>K;
    vector<vector<mint>> dp(H+1);
    dp[0]=vector<mint>(W,0);
    dp[0][0]=1;
    for(int i=0; i<H; i++){
        dp[i+1]=vector<mint>(W,0);
        for(int j=0; j<1<<(W-1); j++){
            bool b = false;
            for(int k=0; k<W-2; k++){
                b |= (j>>k)&(j>>(k+1))&1;
            }
            if(b)continue;
            for(int k=0; k<W; k++){
                if(k>0&&j>>(k-1)&1==1)dp[i+1][k]+=dp[i][k-1];
                else if(k<W-1&&j>>k&1==1)dp[i+1][k]+=dp[i][k+1];
                else dp[i+1][k]+=dp[i][k];
            }
        }
    }
    cout<<dp[H][K-1].x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,k,p;
    cin >> n ;
    
    
    for(int i=0 ; i<n ; i++){ cin >> k>>p;
       { if (k>p && k%p==0)  cout << p <<endl;
         else if (k>p) cout << k%p <<endl;
         else  cout << k <<endl;}
    }
    
    
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
 
int main(){
  int count=0;
  int A[210];
  int N;
  cin >> N;
  for(int i=0;i<N;i++) cin>>A[i];
  
  while(true){
    bool exist_odd=false;
    for(int i=0;i<N;i++) {
      if(A[i]%2!=0) exist_odd=true;
    }
    
    if(exist_odd==true) break;
    
    for(int i=0;i<N;i++){
      A[i] /= 2;
    }
    
    count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256