akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <deque>
using namespace std;

typedef deque<int> DI;

int main(void){
  int n, qn;
  vector<DI> vs;
  
  cin >> n >> qn;
  vs = vector<DI>(n);
  for (int i=0; i<qn; i++){
    int q, t;
    cin >> q >> t;
    if (q==0){
      int x;
      cin >> x;
      vs[t].push_back(x);
    } else if (q==1){
      if (!vs[t].empty()) cout << vs[t].back() << endl;
    } else { // q==2
      if (!vs[t].empty()) vs[t].pop_back();
    }
  }
  
  return 0;
}


Measured memory_bytes: 4384
#include<iostream>
using namespace std;
int main(){
	int n,u1,u2,s1,s2,U1,U2,S1,S2
	,c,a,b,r,d,e,f,g,h,k,x,y,ren,temp;
	while(cin>>n,n){
		u1=100000000;
		u2=100000000;
		s1=0;
		s2=0;
		for(int i=0;i<n;i++){
			cin>>r>>a>>b>>c>>d>>e>>f>>g>>h;
			x=(a+c+e+g)*60+b+d+f+h;
			y=x;
			k=r;
			if(u1>x){
				ren=U1;
				U1=r;
				r=ren;
				temp=u1;
				u1=x;
				x=temp;
			}
			if(u2>x){
				U2=r;
				u2=x;
			}
			if(s1<y){
				ren=S1;
				S1=k;
				k=ren;
				temp=s1;
				s1=y;
				y=temp;
			}
			if(s2<y){
				S2=k;
				s2=y;
			}
		}
		
		cout<<U1<<endl<<U2<<endl<<S2<<endl;
		
		
	}
	return 0;
}

Measured memory_bytes: 0
import numpy as np
N = int(input())
H = [int(i) for i in input().split()]
if N == 1:
  print('Yes')
else:
  for i in range(N-1):
    if H[i] < H[i+1]:
      H[i+1] = H[i+1] - 1
  A = np.zeros(N-1)
  B = np.zeros(N-1)
  for i in range(N-1):
    A[i] = H[i+1] - H[i]
  B = sorted(A)
  if B[0] >= 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 23120
from collections import defaultdict
dic = defaultdict(int)

N = int(input())
for _ in range(N):
    v = int(input())
    dic[v] += 1

count = 0
for k, v in dic.items():
    if v%2:
        # push
        count += 1
    else:
        # push & pop
        pass
print(count)

Measured memory_bytes: 15448
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S , T;
    cin >> S >> T;
    int A , B;
    cin >> A >> B;
    string U;
    cin >> U;

    if(U == S){
        cout << A - 1 << ' ' << B << endl;
    }

    else {
        cout << A << ' ' << B - 1 << endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int h, n;
	cin >> h >> n;

	int sum = 0;
	while(n--){
		int x;
		cin >> x;
		sum += x;
	}

	puts(h <= sum ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int field[109][109];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int W,B;
    cin>>W>>B;
    
    rep(i,50)rep(j,100) field[i+50][j]=1;
    rep(k,B-1){
        int i=k/50,j=k%50;
        field[i*2][j*2]=1;
    }
    rep(k,W-1){
        int i=k/50,j=k%50;
        field[i*2+51][j*2]=0;
    }
    
    cout2(100,100)
    rep(i,100){
        rep(j,100){
            cout<<(field[i][j]?'#':'.');
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int H,W,i,N,a[10000],zenbu[10000],x=0,ki,w,c[100][100];
  scanf("%d %d",&H,&W);
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    while(a[i]>0){
      a[i]--;
      zenbu[x]=i+1;
      x++;
    
    }
    
   }
   x=0;
   if(H%2==0){
for(ki=0;ki<H;ki++){
   for(w=0;w<W;w++){
     c[w][ki]=zenbu[x];
     x++;
   }
   ki++;
   for(w=W-1;w>=0;w--){
     c[w][ki]=zenbu[x];
     x++;
   }}
   }
   else{
     for(ki=0;ki<H-2;ki++){
   for(w=0;w<W;w++){
     c[w][ki]=zenbu[x];
     x++;
   }
   ki++;
   for(w=W-1;w>=0;w--){
     c[w][ki]=zenbu[x];
     x++;
   }}
    for(w=0;w<W;w++){
     c[w][H-1]=zenbu[x];
     x++;
   }
   }
   //出力
   for(i=0;i<H;i++){
   for(w=0;w<W;w++){
     printf("%d ",c[w][i]);
   }
   printf("\n");}



  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=in.nextInt(),m=in.nextInt(),A[][]=new int[n][m],b[]=new int[m];
		
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++)A[i][j]=in.nextInt();
		}
		
		for(int i=0;i<m;i++)b[i]=in.nextInt();
		
		for(int i=0;i<n;i++) {
			int c=0;
			for(int j=0;j<m;j++) {
				c+=A[i][j]*b[j];
			}
			out.println(c);
		}
		
		out.flush();
	}

}



Measured memory_bytes: 40564
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    const long long INF =1LL << 60;
    int n;
    cin>>n;
    vector<int>h(n);
    vector<int64_t>cost(n);
    rep(i,n){
        cin>>h.at(i);
        cost.at(i) = INF;
    }
    cost.at(0)=0;
    chmin(cost.at(1),cost.at(0)+abs(h.at(1)-h.at(0)));
    for(int i=2;i<n;i++){
        chmin(cost.at(i),cost.at(i-1)+abs(h.at(i)-h.at(i-1)));
        chmin(cost.at(i),cost.at(i-2)+abs(h.at(i)-h.at(i-2)));
    }
    cout<<cost.at(n-1)<<endl;
    return 0; 
}




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

using namespace std;

int main() {
    int X, Y;
    int A, B, C;
    cin >> A >> B >> C;
    cin >> X >> Y;
    C = min(A + B, 2 * C);
    A = min(A, C);
    B = min(B, C);
    int R = min(X, Y);
    cout << (X - R) * A + (Y - R) * B + R * C << endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    if (n == 1)
        cout << "Hello World";
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
int main(){
	ll n,k,h[100001],min[100001],q;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		if(i==1) min[i]=0;
		if(i==2) min[i]=abs(h[2]-h[1]);
		if(i>=3){
			q=min[i-1]+abs(h[i]-h[i-1]);
			for(int i2=2;i2<=k;i2++){
				if(i-i2<1) break;
				if(min[i-i2]+abs(h[i]-h[i-i2])<q) q=min[i-i2]+abs(h[i]-h[i-i2]);
			}
			min[i]=q;
		}
	}
	cout<<min[n];
}

Measured memory_bytes: 1792
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

void saiki(vector<bool> plus, vector<int> &x, ll &ans){
    if(plus.size() == x.size()-1){
        ll sumx = 0;
        ll now = x[0];
        FOR(i, 1, x.size()){
            if(!plus[i-1]){
                now = 10 * now + x[i];
            }
            else{
                sumx += now;
                now = x[i];
            }
        }
        sumx += now;
        ans += sumx;
        // calculation
    }
    else{
        vector<bool> plus2 = plus;
        plus2.push_back(true);
        saiki(plus2, x, ans);
        plus2.back() = false;
        saiki(plus2, x, ans);
    }
}

int main() {
    string s;
    cin >> s;
    vector<int> x;
    for(auto c: s)
        x.push_back(c - '0');

    ll ans = 0;
    vector<bool> plus;
    saiki(plus, x, ans);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, M = mi()
Ss = list(mi())
Ts = list(mi())
slen = len(Ss)
tlen = len(Ts)

#DPを2つ作る
#1スタートにしておく。0は、for分でindexエラーを出さないために使う
DP_pairs = [[0] * (len(Ts)+1) for _ in range(len(Ss)+1)] #末尾がS[i]==T[j]である共通部分列の数
DP_cumsum = [[0] * (len(Ts)+1) for _ in range(len(Ss)+1)] #二次元累積和


for i, s in enumerate(Ss):
  i += 1 #1スタート
  for j, t in enumerate(Ts):
    j += 1 #1スタート
    if s==t:
      DP_pairs[i][j] = DP_cumsum[i-1][j-1] + 1
    #s!=tの場合はほっといてもDP_pairsが0なので何もする必要なし
    DP_cumsum[i][j] = (DP_cumsum[i][j-1]+DP_cumsum[i-1][j]-DP_cumsum[i-1][j-1]+DP_pairs[i][j])%(10**9+7)

print(DP_cumsum[len(Ss)][len(Ts)]+1)


Measured memory_bytes: 104668
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ABC070D();

int main()
{
	ABC070D();
	fflush(stdout);
	return 0;
}

class edge {
public:
	int to = 0;
	LLONG cost = 0;
};

static void dijkstra(int st, std::vector<LLONG>& costs, std::vector<std::vector<edge>>& graph)
{
	std::priority_queue<
		std::pair<LLONG, LLONG>,
		std::vector<std::pair<LLONG, LLONG>>,
		std::greater<std::pair<LLONG, LLONG>>> que;

	costs[st] = 0;
	que.push(std::pair<LLONG, LLONG>(0, st));

	while (!que.empty()) {
		std::pair<LLONG, LLONG> p = que.top(); que.pop();
		int v = (int)p.second;

		if ((costs[v] != -1LL) && (costs[v] < p.first)) continue;

		int eCount = graph[v].size();
		for (int e = 0; e < eCount; e++) {
			edge ed = graph[v][e];
			if ((costs[ed.to] == -1LL) ||
				(costs[ed.to] > costs[v] + ed.cost)) {
				costs[ed.to] = costs[v] + ed.cost;
				que.push(std::pair<LLONG, LLONG>(costs[ed.to], ed.to));
			}
		}
	}
}

static void ABC070D()
{
	int N;
	getint(N);

	std::vector<std::vector<edge>> graph(N);
	for (int i = 0; i < N - 1; i++) {
		int from, to, cost;
		getint(from, to, cost); from--; to--;

		edge e;
		e.to = to;
		e.cost = cost;
		graph[from].push_back(e);
		
		e.to = from;
		graph[to].push_back(e);
	}

	int Q, K;
	getint(Q, K); K--;

	std::vector<LLONG> costs(N, -1LL);
	dijkstra(K, costs, graph);

	std::vector<LLONG> ans(Q, 0);
	for (int i = 0; i < Q; i++) {
		int from, to;
		getint(from, to); from--; to--;
		ans[i] = costs[from] + costs[to];
	}
	for (int i = 0; i < Q; i++) {
		printf("%lld\n", ans[i]);
	}
}


Measured memory_bytes: 14076
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,a;
  cin>>n;
  cin>>a;
  cout<<n*n-a<<endl;


}


Measured memory_bytes: 256
#include "bits/stdc++.h"
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

double dp[310][310][310];
bool used[310][310][310];
int N;
double dfs(int a, int b, int c) {
    if (used[a][b][c]) return dp[a][b][c];
    used[a][b][c] = true;
    double tmp = 0.0;
    if (a > 0) tmp += a * dfs(a - 1, b, c);
    if (b > 0) tmp += b * dfs(a + 1, b - 1, c);
    if (c > 0) tmp += c * dfs(a, b + 1, c - 1);
    tmp += N;
    tmp /= (double)(a + b + c);
    return dp[a][b][c] = tmp;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    int cnt[3] = {};
    used[0][0][0] = true;
    rep(i, N) {
        int x; cin >> x;
        cnt[x - 1]++;
    }
    printf("%.12f\n", dfs(cnt[0], cnt[1], cnt[2]));




    return 0;
}


Measured memory_bytes: 256256
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

int N;
int A[100000];
int main() {
  scanf("%d",&N);
  for(int i=0;i<N;++i) {
    scanf("%d", &A[i]);
  }
  sort(A, A+N, greater<int>());
  int prev=A[0];
  int b1=0,b2=0;
  for(int i=1;i<N;++i) {
    if (A[i]==prev) {
      if (b1==0) {
        b1 = A[i];
        prev=0;
        continue;
      } else {
        b2 = A[i];
        break;
      }
    }
    prev=A[i];
  }

  printf("%lld\n", 1ll * b1 * b2);

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int maxN = 3e3+3;
int N;
double p[maxN];
double f[maxN][maxN];
int main() {
    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin >> p[i];
    f[1][0] = 1 - p[1]; f[1][1] = p[1];
    for(int i = 2; i <= N; ++i) {
        f[i][0] = f[i-1][0]*(1-p[i]);
        for(int j = 1; j <= i; ++j)
            f[i][j] = f[i-1][j-1]*p[i]+f[i-1][j]*(1-p[i]);
    }
    double ans = 0;
    for(int i = N/2+1; i <= N; ++i)
        ans += f[N][i];
    cout << fixed << setprecision(12) << ans << endl;

}


Measured memory_bytes: 68992
require 'scanf'
hash = Hash.new
while str=STDIN.gets
    str=str.chomp
    name,page=str.scanf("%s %d")
    hash[name] = [] if not hash.has_key?name
    hash[name].push(page)
end

keys = hash.keys.sort
for k in keys do
    print k,"\n"
    l = hash[k].sort
    for i in 0..l.length-1 do
        print l[i]
        print " " if i<l.length-1
    end
    print "\n"
end

Measured memory_bytes: 6484
def main():
    import sys
    readline = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read
    N = int(readline())
    R = [[int(i) for i in r.split()] for r in read().rstrip().split(b'\n')]
    G = [[] for _ in range(N)]
    edge = {}
    ans_key = []
    for a, b in R:
        G[a-1].append(b-1)
        G[b-1].append(a-1)
        edge[(a-1, b-1)] = -1
        ans_key.append((a-1, b-1))
    max_g = max(len(g) for g in G)

    def dfs(max_g):
        todo = [0]
        seen = [False]*N
        seen[0] = True
        par = [-1]*N
        while todo:
            u = todo.pop()
            k = 0
            c = edge[(par[u], u)] if u != 0 else 0
            for v in G[u]:
                if seen[v]:
                    continue
                seen[v] = True
                todo.append(v)
                par[v] = u
                k += 1
                if k == c:
                    k += 1
                    if max_g < k:
                        k = 1
                if u < v:
                    edge[(u, v)] = k
                else:
                    edge[(v, u)] = k

    dfs(max_g)
    print(max_g)
    for k in ans_key:
        print(edge[k])


if __name__ == '__main__':
    main()


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

int main() {
    string S;
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2]){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int t, x, y; cin >> t >> x >> y;
    if(x+y>t){
        cout << "No" << endl;
        return 0;
    }
    bool flg = 0;
    for(int i=0; i<n-1; i++){
        int a, b, c; cin >> a >> b >> c;
        if(a-t>=abs(x-b)+abs(y-c)&&(a-t)%2==(abs(x-b)+abs(y-c))%2){
        }else{
            flg = 1;
        }
        t=a; x=b; y=c;
    }
    if(flg) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std; 
  
int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
    multiset<int> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (int i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 
  
// Driver program 
int main() 
{   
    int n;
    cin >> n;
    int arr[100200]; 
    for (int i = 0; i < n; i++) cin >> arr[i];
    cout << MinimumNumIncreasingSubsequences(arr, n) << endl;; 
    return 0; 
} 

Measured memory_bytes: 5376
import collections
N = int(input())
L = list(map(int, input().split()))

C = collections.Counter(L)
ans = 0
for i in C.items():
    ans += int((i[1]*(i[1]-1))/2)
        
for i in range(N):
    del_target = L[i]
    print(ans - (C[del_target]-1))

Measured memory_bytes: 26780
//In The Name Of GOD

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 8*1001+1;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);

int main(){
  IO;
  ll n;
  cin>>n;
  ll a[n],ans=0,all=0;
  cin>>a[0];
  for(ll i=1;i<n;i++){
    cin>>a[i];
    if(a[i]>a[i-1]){
      all=0;
    }else{
      all++;
      ans=max(ans,all);
    }
  }
  cout<<ans;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<map>
using namespace std;

int n, m;
string s;

int main(){
    map<string, int> mp;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s;
        mp[s]++;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> s;
        mp[s]--;
    };
    int max = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr -> second > max){
            max = itr -> second;
        }
    }
    cout << max << endl;
    return 0;
}

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

class dice
{
    int F[6];
public:
    dice();
    int get(const int) const;
    void roll_a();
    void roll_b();
    bool check(const dice& d);
};

dice::dice()
{
    for(int i = 0; i < 6; i++) cin >> F[i];
}

int dice::get(const int k) const{ return F[k]; }

void dice::roll_a()
{
    static int i, j;
    i = F[0]; F[0] = F[2]; F[2] = F[1]; F[1] = i;
    j = F[3]; F[3] = F[4]; F[4] = F[5]; F[5] = j;
}

void dice::roll_b()
{
    static int k;
    k = F[0]; F[0] = F[5]; F[5] = k;
    k = F[1]; F[1] = F[3]; F[3] = k;
    k = F[2]; F[2] = F[4]; F[4] = k;
}

bool dice::check(const dice& d)
{
    if((d.get(0) != F[0]) || (d.get(5) != F[5])) return false;
    if((d.get(1) == F[1]) && (d.get(2) == F[2]) && (d.get(3) == F[3]) && (d.get(4) == F[4])) return true;
    if((d.get(1) == F[3]) && (d.get(2) == F[1]) && (d.get(3) == F[4]) && (d.get(4) == F[2])) return true;
    if((d.get(1) == F[4]) && (d.get(2) == F[3]) && (d.get(3) == F[2]) && (d.get(4) == F[1])) return true;
    if((d.get(1) == F[2]) && (d.get(2) == F[4]) && (d.get(3) == F[1]) && (d.get(4) == F[3])) return true;

    return false;
}

int main()
{
    dice d1 = dice();
    dice d2 = dice();
    bool eq = false;

    eq = d1.check(d2);
    if(!eq){ d1.roll_a(); eq = d1.check(d2); }
    if(!eq){ d1.roll_a(); eq = d1.check(d2); }

    if(!eq) d1.roll_b();

    eq = d1.check(d2);
    if(!eq){ d1.roll_a(); eq = d1.check(d2); }
    if(!eq){ d1.roll_a(); eq = d1.check(d2); }

    if(eq){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

vector<int>calc(string s) {
	s += "+";
	vector<int>res(51);
	string t;
	for (char c : s) {
		if (c == '+') {
			if (t.back() == 'x')t += "^1";
			if (t.front() == 'x')t = "1" + t;
			if (count(t.begin(), t.end(), 'x') == 0)res[50] = stoi(t);
			int a = 0, b = 0;
			bool flag = true;
			for (char c : t) {
				if (c == 'x')flag = false;
				else if (c == '^')continue;
				else if (flag)a = a * 10 + c - '0';
				else b = b * 10 + c - '0';
			}
			res[50 - b] = a;
			t = "";
		}
		else t += c;
	}
	return res;
}
void add(vector<int>&a, vector<int>b) {
	rep(i, a.size())a[i] += b[i];
}
void sub(vector<int>&a, vector<int>b) {
	rep(i, a.size())a[i] -= b[i];
}
struct edge { int to; vector<int>cap; int rev; };
bool used[50];
vector<edge>E[50];

void add_edge(int from, int to, vector<int>cap) {
	E[from].push_back({ to,cap,(int)E[to].size() });
	E[to].push_back({ from,cap,(int)E[from].size() - 1 });
}
vector<int>dfs(int v, int t, vector<int>f) {
	used[v] = true;
	if (v == t)return f;
	for (edge&e : E[v]) {
		if (used[e.to] || e.cap == vector<int>(51))continue;
		vector<int>d = dfs(e.to, t, min(f, e.cap));
		if (d != vector<int>(51)) {
			sub(e.cap, d); add(E[e.to][e.rev].cap, d);
			return d;
		}
	}
	return vector<int>(51);
}
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)E[i].clear();
		rep(i, m) {
			int a, b; string s; cin >> a >> b >> s; a--; b--;
			add_edge(a, b, calc(s));
		}
		vector<int>INF(51, INT_MAX);
		vector<int>res(51);
		while (1) {
			memset(used, 0, sizeof(used));
			vector<int>f = dfs(0, n - 1, INF);
			if (f == vector<int>(51))break;
			add(res, f);
		}
		bool flag = false;
		rep(i, 51) {
			if (res[i] == 0)continue;
			if (flag)printf("+");
			if (i == 50)printf("%d", res[i]);
			else if (i == 49) {
				if (res[i] == 1)printf("x");
				else printf("%dx", res[i]);
			}
			else if (res[i] == 1)printf("x^%d", 50 - i);
			else printf("%dx^%d", res[i], 50 - i);
			flag = true;
		}
		if (!flag)printf("0");
		puts("");
	}
}

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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector<int>
#define vvi         vector<vi>
#define pii         pair<int,int>
#define vii         vector<pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define pb          emplace_back
#define mkpr        make_pair
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         998244353

struct BIT {
    vector<int> bit;  // binary indexed tree
    int n;

    BIT (int n) {
        this->n = n + 1;
        bit.assign(n + 1, 0);
    }

    int sum(int idx) {
        int ret = 0;
        if (idx <= 0) {
            return 0;
        }
        for (++idx; idx > 0; idx -= idx & -idx)
            ret += bit[idx], ret %= mod;
        return ret;
    }

    int sum(int l, int r) {
        int x = sum(r);
        int y = sum(l - 1);
        int ans = (x - y + mod) % mod;
        return ans;
    }

    void add(int idx, int delta) {
        for (++idx; idx < n; idx += idx & -idx) {
            bit[idx] += delta;
            bit[idx] %= mod;
        }
    }
};


signed main() {
        IO;
        int n, k;
        cin >> n >> k;
        BIT b(n);
        vi dp(n + 1);
        vii segs(k);
        for (int i = 0; i < k; i++) {
            cin >> segs[i].first >> segs[i].second;
        }
        sort(all(segs));
        b.add(1, 1);
        for (int i = 2; i <= n; i++) {
            for (int j = 0; j < k; j++) {
                int l = segs[j].first, r = segs[j].second;
                int needl = max(0LL, i - r), needr = max(0LL, i - l);
                dp[i] += b.sum(needl, needr);
                dp[i] %= mod;
            }
            b.add(i, dp[i]);
        }
        cout << dp[n];
}


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

using namespace std;

int main(){
    int n;
    cin >>n;
    long long ans =0 ;
    for (int i = 1; i <= n;i++){
        ans += i;
        if(i%3 == 0){
            ans -= i;
        }
        if(i%5==0){
            ans -= i;
        }
        if(i % 3 == 0 && i % 5 == 0){
            ans += i;
        }
    }

    cout << ans <<endl;

}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>

#define MIN(X,Y) ((X)>(Y)?(Y):(X))

using namespace std;
int w[2000],sa[2000],idx[2000];
char sorted[2000];

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&w[i]), sa[i]=w[i];
    sort(sa,sa+n);
    for(int i=0; i<n; i++)
        idx[i] = lower_bound(sa,sa+n,w[i])-sa;

//    for(int i=0; i<n; i++)
//        printf("%d ", idx[i]);
//    printf("\n");

    int min = sa[0];
    int res = 0;
    for(int i=0; i<n; i++) {
        int rescur=0, j=i, localmin=30000, cnt=0;
        if(sorted[j]) continue;
        while(!sorted[j]) {
            sorted[j]=1;
            cnt++;
            if(localmin > w[j]) localmin = w[j];
            rescur+=w[j];
            j = idx[j];
        }
//        printf("%d, %d, %d\n", rescur, localmin, cnt);
//        printf("%d : %d\n",rescur+(cnt-2)*localmin, rescur+localmin+2*min+(cnt-1)*min);
        res += MIN(rescur+(cnt-2)*localmin, rescur+localmin+2*min+(cnt-1)*min);
    }
    printf("%d\n",res);


    return 0;
}

Measured memory_bytes: 2812
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    void solve(Scanner in, PrintWriter out) {
        out.println(in.nextInt() ^ 1);
    }

    public static void main(String[] args) {
        try(Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }
}


Measured memory_bytes: 35784
#include <iostream>

using namespace std;

int main()
{
  int l[6];
  for (int i = 0; i < 5; i++)
    cin >> l[i];

  int k;
  cin >> k;

  for (int i = 0; i < 4; i++) {
    for (int j = i + 1; j < 5; j++) {
      if (l[j] - l[i] > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;
}

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

namespace AABC
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] kk = Console.ReadLine().Split(' ');
            int[] inp1 = new int[4];
            int k = 0;

            for (k = 0; k < 4; k++)
            {
                inp1[k] = int.Parse(kk[k]);
            }

            string[] kk2 = Console.ReadLine().Split(' ');
            int[] inp2 = new int[inp1[0]];
            for (k = 0; k < inp1[0]; k++)
            {
                inp2[k] = int.Parse(kk2[k]);
            }

            string[] kk3 = Console.ReadLine().Split(' ');
            int[] inp3 = new int[inp1[1]];
            for (k = 0; k < inp1[1]; k++)
            {
                inp3[k] = int.Parse(kk3[k]);
            }

            int X = inp1[2];
            int Y = inp1[3];
            int mid = X;
            string s = "War";

            if (X<Y)
            {
                for(int i = 1; i < (Y-X); i++)
                {
                    mid++;
                    if(inp2.Max() < mid)
                    {
                        if(inp3.Min() >= mid)
                        {
                            s = "No War";
                            break;
                        }
                    }
                    
                }
            }


            Console.WriteLine(s);

        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>

int main(void){
    int a, b, cnt, x;
    scanf("%d""%d", &a, &b);
    if(a < b){
        cnt = b;
        x = a;
    }else{
        cnt = a;
        x = b;
    }
    for(int i = 0; i < cnt; i++){
        printf("%d", x);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ab = Integer.parseInt(sc.next());
		int bc = Integer.parseInt(sc.next());
		int ca = Integer.parseInt(sc.next());
		sc.close();
		System.out.println(ab*bc/2);
	}
}


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

int main() {
  int n, m;

  cin >> n >> m;

  int ac = 0; 
  int wa = 0;
  vector <int> p_ac(100000, 0);
  vector <int> p_wa(100000, 0);
  int count = 0;
  for(int i = 0; i < m; ++i) {
    int p;
    string s;
    cin >> p >> s;

    if(p_ac[p] == 0) {
      // 見つからなかった
      if (s == "AC") {
        p_ac[p] = 1;
      } else {
        if (s == "WA") {
          p_wa[p] = p_wa[p] + 1;
        }
      }
    }
  }
  
  for (int i = 0; i < 100000; i++) {
    if (p_ac[i] != 0) {
      wa = wa + p_wa[i];
    }
    ac = ac + p_ac[i];
  }
    cout << ac;
    cout  << " ";
    cout << wa << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;


int main(){
    int N,M,sum,count;
    float temporary,reference_point;
    cin >> N >> M;
    //cout << N << M;
    long long int product[N];
    count=0;
    sum=0;
    rep(i,N){
        cin >> product[i];
        sum+=product[i];
    }
    //cout << sum << endl;
    //temporary=1/(4*(float)M);
    //cout << temporary << endl;
    reference_point=(float)sum*(1/(4*(float)M));
    //cout << reference_point << endl;
    
    rep(i,N){
        if(reference_point<=product[i]) count++;
    }
    if(count>=M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    } 

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n , x;
  cin >> n >> x;
  int sum = 0 ;
  int pre = 1<<30;
  for( int i = 0 ; i < n ; i++){
    int m;
    cin >> m ;
    sum += m;
    if( m < pre){
      pre = m;
    }
  }
  x = x - sum;
  cout << n + x/pre << endl;
}

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

int main(){
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	
	while(a>0 && c>0){
		c=c-b;
		a=a-d;
	}
	if(c<=0){
		cout<<"Yes"<<endl;
	}
	else if(a<=0){
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int p[210];

int main(int argc, char const *argv[]) {
    int n, m;
    int sum=0;
    bool flg=true;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
        sum+=a.at(i);
    }
    sort(a.rbegin(), a.rend());

    if(a.at(m-1)<(sum/(double)(4*m))){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

int n, A[30];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    int q, M, i;
    cin >> n;
    REP(i, n) cin >> A[i];
    cin >> q;
    REP(i, q) {
        cin >> M;
        if (solve(0, M))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s.substr(i, 3) == "ABC") {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t,r;
  cin >> s >> t >> r;
  if ( t.size() < 1 || t.size() > 100 ) {
    cout << "error" << endl;
    exit(0);
  }
  for ( int i = 0 ; i < s.size() ; i++ ) {
    if ( i!=2 && isupper(s.at(i)) ) {
      cout << s.at(i);
    }
  }
  for ( int i = 0 ; i < t.size() ; i++ ) {
    if ( i==0 && isupper(t.at(i)) ) {
      cout << t.at(i);
    }
  }
  for ( int i = 0 ; i < r.size() ; i++ ) {
    if ( i==0 && isupper(r.at(i)) ) {
      cout << r.at(i);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type edge struct {
	to, cost int
}

var node [][]edge

var res []int

func dfs(v, prev, cost int) {
	if prev != -1 {
		res[v] = res[prev] + cost
	}
	for _, e := range node[v] {
		if e.to == prev {
			continue
		}
		dfs(e.to, v, e.cost)
	}
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	node = make([][]edge, N)
	for i := 0; i < N-1; i++ {
		u, v, w := getInt()-1, getInt()-1, getInt()
		node[u] = append(node[u], edge{v, w})
		node[v] = append(node[v], edge{u, w})
	}

	res = make([]int, N)
	dfs(0, -1, 0)
	// out(res)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 0; i < N; i++ {
		fmt.Fprintln(w, res[i]%2)
	}
}


Measured memory_bytes: 25344
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; i++) {
        if (i != x - k + 1) {
            cout << " ";
        }
        cout << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

ll l[100001],r[100001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>> N;
    ll a[3*N];
    rep(i,0,3*N) cin>> a[i];
    priority_queue<ll, vector<ll>,greater<ll>> p;
    priority_queue<ll> q;
    
    rep(i,0,N){
        p.push(a[i]);
        l[0]+=a[i];
    }
    rep(i,1,N+1){
        p.push(a[N-1+i]);
        ll s=p.top();
        p.pop();
        l[i]=l[i-1]+a[N-1+i]-s;
    }
    rer(i,3*N,2*N){
        q.push(a[i]);
        r[N]+=a[i];
    }
    rer(i,N,0){
        q.push(a[i+N]);
        ll s=q.top();
        q.pop();
        r[i]=r[i+1]+a[i+N]-s;
    }
    ll res=-100000000000000;
    rep(i,0,N+1){
        res=max(res, l[i]-r[i]);
    }
    cout << res<<"\n";
}

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

using namespace std;

int main(void)
{
	int n,k;cin>>n>>k;
	int ans = k;
	for(int i = 1; i < n; i++){
		ans = ans*(k-1);
	}
	//ans = ans * k;
	
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	char a[9][6];
	int x,y,m,i;

	while(scanf("%s",a[0])!=EOF){
		for(i=1;i<9;i++)
			scanf("%s",a[i]);
		x=0;
		y=0;
		m=1;
		do{
			if(m==0){
				printf("L");
				x--;
				if(y==4||a[2*y+1][x]=='0'){
					if(x==0||a[2*y][x-1]=='0'){
						if(y==0||a[2*y-1][x]=='0')
							m=1;
						else
							m=2;
					}
				}else
					m=3;
			}else if(m==1){
				printf("R");
				x++;
				if(y==0||a[2*y-1][x]=='0'){
					if(x==4||a[2*y][x]=='0'){
						if(y==4||a[2*y+1][x]=='0')
							m=0;
						else
							m=3;
					}
				}else
					m=2;
			}else if(m==2){
				printf("U");
				y--;
				if(x==0||a[2*y][x-1]=='0'){
					if(y==0||a[2*y-1][x]=='0'){
						if(x==4||a[2*y][x]=='0')
							m=3;
						else
							m=1;
					}
				}else
					m=0;
			}else{
				printf("D");
				y++;
				if(x==4||a[2*y][x]=='0'){
					if(y==4||a[2*y+1][x]=='0'){
						if(x==0||a[2*y][x-1]=='0')
							m=2;
						else
							m=0;
					}
				}else
					m=1;
			}
		}while(x!=0||y!=0);
		printf("\n");
	}	
	return 0;
}

Measured memory_bytes: 524
a,b,k = map(int,input().split())
if b+2 <= a+2*k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a,a+k):
    print(i)
  for i in range(b+1-k,b+1):
    print(i)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
#define foreach(it,c) for(typeof(c.begin()) it=c.begin();it!=c.end();++it)
typedef pair<string, int> pp;
const int MAXN = 1000;
map<string, int> m;
int en[MAXN + 10] = {};
int vec[MAXN + 10][MAXN + 10] = {};
int used[MAXN + 10] = {};

int solve(int n)
{
    int ans = 0;
    if(used[n]) return 0;
    used[n] = 1;
    if(en[n] == 0) return 1;
    
    for(int i = 0; i < en[n]; i++) ans += solve(vec[n][i]);
    
    return ans;
}

int main()
{
    int n; 
    while(cin >> n && n)
    {
        m.clear();
        memset(en, 0, sizeof(en));
        memset(vec, 0, sizeof(vec));
        memset(used, 0, sizeof(used));

        string s, oya, ko;
        int nnum = 0;
        REP(n)
        {
            cin >> s;
            int f = 0, e = 0;
            for(f = 0; f < s.size();f++)if(s[f] == ':')
            {
                oya = s.substr(0, f);
                f+= 1;
                break;
            }
            if(m.find(oya) == m.end())
            {
                m.insert(pp(oya, nnum));
                nnum ++;
            }
            //cout << oya << " ";
            while(f < s.size())
                for( e = f + 1; e < s.size(); e++)if(s[e] == ',' || s[e] == '.')
            {
                ko = s.substr(f, e - f);
                if(m.find(ko) == m.end())
                {
                    m.insert(pp(ko, nnum));
                    nnum++;
                    vec[m[oya]][en[m[oya]]] = m[ko]; 
                    en[m[oya]]++;
                }
                else
                {
                    vec[m[oya]][en[m[oya]]] = m[ko];
                    en[m[oya]]++;
                }
                f = e + 1;
                //cout << ko   << " ";
            }
            //cout << endl;
        }
        cout <<  solve(0) << endl;
    }

    return 0;
}

Measured memory_bytes: 5332
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] a = new int[N][M];
		for(int i=0; i<N; i++)
			for(int j=0; j<M; j++)
				a[i][j] = sc.nextInt()-1;
		
		int min = N;
		boolean[] held = new boolean[M];
		Arrays.fill(held, true);
		int[] idx = new int[N];
		
		for(int i=0; i<M; i++) {
			int[] cnt = new int[M];
			for(int j=0; j<N; j++) {
				while(!held[a[j][idx[j]]])
					idx[j]++;
				cnt[a[j][idx[j]]]++;
			}
			int max = 0;
			for(int j=1; j<M; j++)
				if(cnt[max]<cnt[j])
					max = j;
			min = Math.min(min, cnt[max]);
			held[max] = false;
		}
		
		System.out.println(min);
		
		sc.close();
	}
}


Measured memory_bytes: 49508
x=int(input())
arr=list(map(int, input().split()))
d=dict()
for i in arr:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
coun=0
a=sorted(d.keys())
l=len(a)
for i in range(l-2):
  for j in range(i+1,l-1):
    k=j+1
    temp=a[i]+a[j]
    curr=d[a[i]]*d[a[j]]
    while k<l:
      if temp>a[k]:
        coun+=(curr*d[a[k]])
        k+=1
      else:
        break
print(coun)

Measured memory_bytes: 9220
n = int(input())
#floor = [0 for i in range(1, 11)]
my_a = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_b = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_c = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_d = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
bs = [my_a, my_b, my_c, my_d]

for i in range(n):
    num_str = input().split()
    b, f, r, v = [int(i) - 1 for i in num_str]
    bs[b][f][r] = bs[b][f][r] + v + 1

for i in range(len(bs)):
    for j in range(len(bs[0])):
        print(" ", end="")
        tmp_str = [str(i) for i in bs[i][j]]
        print(" ".join(tmp_str))
    if i != len(bs)-1:
        print("####################")



Measured memory_bytes: 5612
H,W = map(int,input().split())
s= [input() for i in range(H)]

dq = [[0 for i in range(W)] for j in range(H)]

for y in range(H):
    for x in range(W):
        cand = []
        if y > 0:
            if s[y][x] == s[y-1][x]:
                cand.append(dq[y-1][x])
            else:
                cand.append(dq[y-1][x]+1)
        if x > 0:
            if s[y][x] == s[y][x-1]:
                cand.append(dq[y][x-1])
            else:
                cand.append(dq[y][x-1]+1)
        if cand:
            dq[y][x] = min(cand)

n = dq[H-1][W-1]

if s[0][0] == ".":
    if s[H-1][W-1] == ".":
        print(n//2)
    else:
        print((n+1)//2)
else:
    if s[H-1][W-1] == ".":
        print((n+1)//2)
    else:
        print((n+2)//2)





Measured memory_bytes: 3188
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>

using namespace std;
typedef long long ll;

int main(void){
    int n, k;
    double ans=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        int score=i;
        double num=1;
        
        while(score<=k-1){
            score*=2;
            num/=2;
            
        }
        ans+=num;
    }
    
   
    ans/=n;
    cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  if(A!=1 && B!=1)
    {
      if(A>B)
	{
	  cout<<"Alice"<<endl;
	}
      if(A<B)
	{
	  cout<<"Bob"<<endl;
	}
      if(A==B)
	{
	  cout<<"Draw"<<endl;
	}
    }
  if(A==1)
    {
      if(B==1)
	{
	  cout<<"Draw"<<endl;
	}else{
	cout<<"Alice"<<endl;
      }
    }
  if(B==1)
    {
      if(A==1)
	{
	  
	}else{
	cout<<"Bob"<<endl;
      }
    }
  return 0;
}


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

bool judge( int* a, int _n, int p, int _k )
{
    int sum = 0;
    int t = 0;
    bool j = false;

    for( int i = 0; i < _n; i++ )
    {
        sum += a[i];
        if( sum > p )
        {
            sum = a[i];
            t++;
        }
        if( t == _k )                                
            return false;
 
        if( t <= _k - 1 && i == _n - 1 )        
            return true;
    }
}

int main()
{
    int n, k, p = 0;                                    //n荷物の個数、kトラックの数、p最大積載量
    int max = 0;

    cin >> n >> k;

    int w[n];

    for( int i = 0; i < n; i++ )
    {
        cin >> w[i];
        if( w[i] > p )                                  //最も重たい荷物を、pに設定する
            p = w[i];
        max += w[i];
    }

    int left = p;                                       //考えうる最小の値
    int right = max;                                    //考えうる最大の値

    while( left != right )
    {
        int mid = ( left + right ) / 2;
        if( judge( w, n , mid, k ) == true )
            right = mid;
        else
            left = mid + 1;
    }
    cout << right << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i = 0; i < N; i++){
	cin >> a.at(i);    
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Bob = 0, Alice = 0;
  for(int i = 0; i < N; i+=2){
    Alice += a.at(i);
  }
  for(int i = 1; i < N; i+=2){
    Bob += a.at(i);
  }

  cout << Alice - Bob << endl;
  
  return 0;
}

Measured memory_bytes: 256