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

int main() {
  int N, M, Q, l, r, p, q;
  cin >> N >> M >> Q;
  vector< vector<int> > s(N+1, vector<int>(N+1));
  for (int i=0; i<=N; i++) {
    for (int j=0; j<=N; j++) {
      s[i][j] = 0;
    }
  }
  for (int i=0; i<M; i++) {
    scanf("%d %d", &l, &r);
    s[l][r]++;
  }
  for (int i=1; i<=N; i++) {
    for (int j=1; j<=N; j++) {
      s[i][j] = s[i][j-1] + s[i-1][j] - s[i-1][j-1] + s[i][j];
    }
  }
  for(int i=0; i<Q; i++) {
    scanf("%d %d", &p, &q);
    cout << s[q][q] - s[q][p-1] - s[p-1][q] + s[p-1][p-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    int ans = 1000 - n%1000;
    ans %= 1000;
    cout << ans << endl;
}

Measured memory_bytes: 3612
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int N,K;

	scanf("%d%d", &N,&K);



	printf("%d\n", !!(N%K));

	return 0;
}

Measured memory_bytes: 256
#E re
H, N = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
DP = [float('inf')] * (H+1)
DP[0] = 0

for i in range(N):
    for j in range(H):
        nj = min(j+A[i], H)
        DP[nj] = min(DP[nj], DP[j]+B[i])

print(int(DP[H]))


Measured memory_bytes: 51932
class WUnionFind:
    MAX_N = 0
    PAR  = [] 
    RANK = []
    DIFF_WEIGHT=[]

    def __init__(self,n):
        self.MAX_N = n
        self.PAR = [ i for i in range(n)]
        self.RANK= [ 0 ] * n
        self.DIFF_WEIGHT=[ 0 ] * n

    def root(self,x):
        if self.PAR[x] == x:
            return x
        else:
            r = self.root(self.PAR[x])
            self.DIFF_WEIGHT[x] += self.DIFF_WEIGHT[self.PAR[x]]
            self.PAR[x] = r
            return r
    
    def weight(self,x):
        self.root(x)
        return self.DIFF_WEIGHT[x]

    def issame(self,x,y):
        return self.root(x) == self.root(y)

    def diff(self,x,y):
        return self.weight(y)-self.weight(x)

    def merge(self,x,y,w):
        w += self.weight(x)
        w -= self.weight(y)
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.RANK[x] < self.RANK[y]:
            x,y = y,x
            w = -w
        if self.RANK[x] == self.RANK[y]:
            self.RANK[x] += 1

        self.PAR[y] = x
        self.DIFF_WEIGHT[y] = w
        return True


N,Q  = map(int,input().split())
Ans = []
tree = WUnionFind(N+1)

for _ in range(Q):
    s = list(map(int,input().split()))
    if s[0] == 0:
        x = s[1]
        y = s[2]
        w = s[3]
        tree.merge(x,y,w)
    else:
        x = s[1]
        y = s[2]
        if tree.issame(x,y):
            a = tree.diff(x,y)
        else:
            a = '?'
        Ans.append(a)

for a in Ans:
    print(a)



Measured memory_bytes: 15264
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	int a[100];
	int k, s;
	int n, m;
	int w, x, y, z;
	int ans = 0;

	scanf("%d", &n);
	m = 0;
		w = n % 10;
		n = n / 10;
		x = n % 10;
		n = n / 10;
		y = n % 10;
		n = n / 10;
		z = n % 10;
		if (w == x&&x == y)m = 1;
		if (z == x&&x == y)m = 1;
	if (m==1)printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, T; 
  cin >> N >> T;

  vector<pair<int, int>> vec(N);
  REP(i, N) cin >> vec[i].first >> vec[i].second;

  sort(ALL(vec));
  
  vector<vector<int>> dp(N+1, vector<int>(6010, -INF));
  dp[0][0] = 0;

  REP(i, N) REP(j, T+1){
    chmax(dp[i+1][j], dp[i][j]);
    if(j < T) chmax(dp[i+1][j+vec[i].first], dp[i][j]+vec[i].second);
  }

  int ans = 0;
  REP(i, N+1) REP(j, 6010) chmax(ans, dp[i][j]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;
const int mod = 1e9+9;
/*ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }
*ll lcm(ll x, ll y){return x*(y/gcd(x,y));}
*void exEuclid(int a, int b){
	if(b==0){x = 1; y=0; d=a; return ;}
	exEuclid(b, a%b);
	int x1=y;
	int y1=x-(a/b)*y;
	x=x1;
	y=y1;
} 
* */
//===========================================================//
const int nax = 1e5+3;
int n;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));
	return dp[i]=ans;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll tmp;
ll ret = 0;
string s;

void input() {
  IN(s);
}

void solve() {
  ll ans1 = 0; //101010..
  ll ans2 = 0; //010101..
  char c, d;

  REP(i, s.size()) {
    c = s[i];
    d = ((i&1) == 0)?'1':'0';
    if (c != d) ans1 += 1;
    else ans2 += 1;
  }
  ret = min(ans1, ans2);
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 512
#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 int long long
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define _ ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define mod 1000000007
#define deb(x) cerr << "\n" \
					<< #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
						<< #x << "=" << x << "\n" \
						<< #y << "=" << y << "\n";
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
 
int32_t main()
{
 
	int n;
	cin >> n;
	int sum = 0;
 
	for (int i = 1; i <= n; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)
			sum += i;
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define inf    0x3f3f3f3f
#define ll long long
#define pb push_back
#define upperlimit 1000100
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]

int main(){

 ll h,w;
 cin>>h>>w;

 ll total = h*w;

 if(h>w) swap(h,w);
 
 if(h == 1)
      cout<<"1"<<endl;
 else 
      cout<<(h*w+1)/2<<endl;


return 0;
}

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

int main()
{
    int n,k;
    for(;;){
        cin >> n >> k;
        if(n==0&&k==0) break;
        int s=0;
        int a[n];
        for(int i=0;i<n;i++)
            cin >> a[i];
        int m=0;
            for(int j=0;j<k;j++)
                m+=a[j];
            s=m;
        for(int q=0;q<n-k;q++){
            m-=a[q];
            m+=a[q+k];
            s=max(s,m);
        }
        cout << s << endl;
    }
    return 0;
}



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

using namespace std;

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

  int a,b; cin>>a>>b;
  if (a > b)
    swap(a,b);
  for (int i = 0; i < b; i++) {
    cout << a;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
//ProblemC.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemC.cpp

#define MAXL 11

bool p[MAXL];
s64 num[MAXL];
s64 sum;
int l;

void getsum(int i)
{
	if (i == l - 1) {
		s64 mul = 1;
		for (int j = 0; j < l; ++j) {
			sum += mul * num[j];
			
			if (p[j]) mul = 1;
			else mul *= 10;
		}
		return;
	}

	getsum(i + 1);
	p[i] = true;
	getsum(i + 1);
	p[i] = false;
}

int main(int argc, char* argv[])
{
	OPENOJIO;

	string s;
	ip >> s;

	l = s.size();
	for (int i = 0; i < l; ++i) {
		num[i] = s[l - 1 - i] - '0';
	}

	sum = 0;
	FillZero(p);

	getsum(0);
	op << sum << endl;

	return 0;
}
/***************************************************************/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

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

int main(int argc, char **argv)
{
	ll n, x; cin >> n >> x;
	ll res{0};
	for (ll i = 0; i < n; ++i)
	{
		ll a; cin >> a;
		res = gcd(abs(a-x), res);
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 256
S = input().split()
K = int(S[0])
N = int(S[1])
A = []
B = []
a = input().split()
for o in range(N):
    A.append(int(a[o]))
A.sort()
for j in range(N-1):
    B.append(A[j+1] - A[j])
B.append(A[0] + K-A[N-1])
B.sort()
ans = 0
ans = K - B[N-1]

print(int(ans))

Measured memory_bytes: 27980
#include <stdio.h>

class Dice4{
public:
	int number[6];

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

};

int main(){
	int n,k,j;
	scanf("%d",&n);
	Dice4 array[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
				&array[i].number[3],&array[i].number[4],&array[i].number[5]);
	}
	for(k = 0; k < n-1; k++){
		for(j = k+1; j < n; j++){
			if(array[k].isSameDice(array[j].number))
				break;
		}
		if(j < n) break;
	}
	if(k == n-1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}



Measured memory_bytes: 2696
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <set>
#include <map>
#include <math.h>
#include <bitset>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

typedef long long ll;

const ll INF = 1e18, MOD = 1e9 + 7;
const int INT_MAX = 1e9;

ll n;

ll a[100000], st1[100000], ptr1, st2[100000], ptr2;



int main () 
{
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		scanf ("%lld", &a[i]);
	}

	for (int i = 0; i < n; i++)
	{
		if (a[i] > ptr1 + 1)
		{
			cout << - 1;
			return 0;
		}
		else
		{
			while (ptr1 + 1 != a[i])
			{
				st2[ptr2] = st1[ptr1-1];
				ptr2++;
				ptr1--;
			}

			st1[ptr1] = a[i];
			ptr1++;

			while (ptr2)
			{
				st1[ptr1] = st2[ptr2-1];
				ptr1++;
				ptr2--;
			}
		}
	}

	for (int i = 0; i < ptr1; i++)
		cout << st1[i] << endl;
}

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


int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  while(n--){
    s = s[s.size()-1] + s;
    s.pop_back();
    if(s == t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))

ans = (a[0] * a[1]) % MOD
s = a[0]
for i in range(2, n):
    s = (s + a[i-1]) % MOD
    ans += (s * a[i]) % MOD
    ans %= MOD

print(ans)

Measured memory_bytes: 31532
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////

int main() {
    ll n; cin >> n;
    string s; cin >> s;
    ll cntw = 0;
    rep(i, 0, n) if(s[i] == 'W') cntw++;
    reverse(ALL(s));
    ll ans = 0;
    rep(i, 0, cntw){
        if(s[i] != 'W') ans++;
    }
    co(ans);

    return 0;
}




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

int main() {
    int n,k,x,a=0;
    cin >> n >> k;
    for(int i = 0;i < n;i ++){
        cin >> x;
        if(x < k-x){
            a += x;
        }else{
            a += k-x;
        }
    }
    cout << a*2 << endl;
}



Measured memory_bytes: 256
input = gets

N = input.split(" ")[0].to_i

i = 1
arry = []

9.times do
  j = 1
  
  9.times do
    ans = i*j
    
    arry.push(ans)
    j += 1
  end
  
  i += 1
end



if arry.include?(N)
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

int n, S;
pair <int, int> a[101];
int d[N], ans[N];

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> S;
	for (int i = 0; i < n; i++){
		cin >> a[i].f >> a[i].s;
	}
	sort(a, a + n);
	d[0] = 1;
	for (int i = 0; i < n; i++){
		for (int j = 1e5; j >= 0; j--){
			if (d[j]){
				if (!d[j + a[i].s]){
					ans[j + a[i].s] = ans[j] + a[i].f;
				}
				else{
					ans[j + a[i].s] = min(ans[j] + a[i].f, ans[j + a[i].s]);
				}
				d[j + a[i].s] = 1;
			}
		}
	}
	int mx = 0;
	for (int i = 0; i <= 1e5; i++){
		if (d[i]){
			//cout << i << " " << ans[i] << "  ";
			if (ans[i] <= S)mx = max(mx, i);
		}
	}
	//cout << endl;
	cout << mx;
	return 0;
}












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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string str;
	cin >> str;
	if (str == "AAA" || str == "BBB") {
		cout << "No";
	} else {
		cout << "Yes";
	}
	return 0;
}



Measured memory_bytes: 3620
S = input()
K = int(input())
count = 0
for i in range(K):
    if i >= len(S):
        break
    if S[i] == "1":
        count += 1
if count == K:
    print("1")
    exit()

for i in range(len(S)):
    if S[i] != "1":
        ans = S[i]
        break

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		int first=0,second=0,third=0;
		int set;
		
		Scanner sc = new Scanner(System.in);
		
		for(int i=0;i<10;i++){
			
			set = sc.nextInt();
			
			if(first<set){
				third = second;
				second = first;
				first = set;
			}else if(second<set){
				third = second;
				second = set;
			}else if(third<set){
				third = set;
			}
			
		}
		
		System.out.println(first);
		System.out.println(second);
		System.out.println(third);
	}

}

Measured memory_bytes: 17168
#include <stdio.h>
#include <string.h>
int main(void)
{
  char a[101];
  char b[101];
  int c=0,l;
  while(scanf("%s",a)!=EOF){
    l=strlen(a);
    int i,j;
    for(i=0,j=l-1;i<l;i++,j--){
      b[i]=a[j];
    }
    b[l]='\0';
    if(strcmp(a,b)==0)
      c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 548
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char ret[100][100];

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    // white . A
    // black # B
    for(int i = 0; i < 100; i++) {
        for(int j = 0; j < 100; j++) {
            if(j >= 50) ret[i][j] = '#';
            else ret[i][j] = '.';
        }
    }
    for(int i = 0; i < 100; i += 2) {
        for(int j = 0; j < 50; j += 2) {
            if(b-- > 1) {
                ret[i][j] = '#';
            }
        }
    }
    for(int i = 0; i < 100; i += 2) {
        for(int j = 51; j < 100; j += 2) {
            if(a-- > 1) {
                ret[i][j] = '.';
            }
        }
    }
    printf("100 100\n");
    for(int i = 0; i < 100; i++) {
        for(int j = 0; j < 100; j++) {
            printf("%c", ret[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 256
n, k = map(int, input().split())

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

C = zip(A, B)
C = sorted(C)
A, B = zip(*C)
for i in range(n):
    a = A[i]
    b = B[i]
    k -= b
    if k <= 0:
        print(a)
        break

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

int n,now=1,len=0;
int a[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	for (int i=1;i<=n;i++)
	{
		if (a[i]==now)
		{
			now++;
			len++;
		}
	}
	if (len==0)  cout<<-1<<endl;
	else cout<<n-len<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] a = new long[N];
		long[] b = new long[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
		}
		for(int i = 0; i < N; i++) {
			b[i] = sc.nextLong();
		}
		sc.close();
		long t1 = 0;
		long t2 = 0;
		for(int i = 0; i < N; i++) {
			if(a[i] >= b[i]) {
				t1 += (a[i] - b[i]);
			}else {
				long t = b[i] - a[i];
				t2 += t / 2;
			}
		}
		if(t1 <= t2) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 42432
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,t,n,a[26]={0},b[26]={0},c,s=0,ans=0,j;
	string p;
	cin>>n>>p;
	for (i=0;i<p.size();i++){
		t=p[i]-'0';
		t-=49;
		a[t]++;
	}
	for (i=0;i<26;i++){
		if (a[i]>0){
			s++;
		}
	}
	for (i=0;i<p.size()-1;i++){
		t=p[i]-'0';
		t-=49;
		b[t]++;
		a[t]--;
		c=0;
		for (j=0;j<26;j++){
			if (a[j]>0&&b[j]>0){
				c++;
			}
		}
		ans=max(ans,c);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_L = 80;
const int MAX_E = MAX_L * 4;

/* typedef */

/* global variables */

int l;
int es[MAX_L], dp[MAX_L][MAX_E + 1];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;

  while (n--) {
    cin >> l;
    for (int i = 0; i < l; i++) cin >> es[i];

    if (l == 1) {
      cout << es[0] << endl;
      continue;
    }

    memset(dp, -1, sizeof(dp));
    dp[1][es[0]] = es[1];

    for (int i = 1; i < l - 1; i++)
      for (int e = 0; e <= MAX_E; e++) {
	int dp0 = dp[i][e];
	if (dp0 < 0) continue;

	if (dp[i + 1][dp0] < es[i + 1]) dp[i + 1][dp0] = es[i + 1];

	int e1 = es[i + 1] + e;
	if (dp0 > 0 && dp[i + 1][dp0 - 1] < e1) dp[i + 1][dp0 - 1] = e1;
      }

    int max_e = 0;
    for (int e = 0; e <= MAX_E; e++)
      if (max_e < dp[l - 1][e]) max_e = dp[l - 1][e];

    cout << max_e << endl;
  }

  return 0;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  std::string S, T;
  std::cin >> S >> T;

  rep(i, S.length()) {
    if(S[i] != T[i]) {
      std::cout << "No" << '\n';
      return 0;
    }
  }
  std::cout << "Yes" << '\n';
}


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

int gcd(int a, int b){
  
  if(a < b){
    if(a==0){return b;}
    return gcd(b%a, a);
  }else{
    if(b==0){return a;}
    return gcd(a%b, b);
  }
}

int main() {
  
  int N;
  cin >> N;
  
  long long sum = 0;
  for(int i=1; i<=N; i++){
    for(int j=1; j<=N; j++){
      for(int k=1; k<=N; k++){
        sum += gcd(gcd(i, j), k);
      }
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int NR= 2e5 + 5 ;
ifstream in("viitor.in");
ofstream out("viitor.out");
vector < char > st;
vector < vector < char > > sol ;
int n;
void rec ( int poz , int high ) {
    int i , maxim = 0 ;
    if( poz == n + 1 )  {
        sol.pb( st ) ;
        return ;
    }
    for ( i = 0 ; i <= min ( high , 25 ) ; ++ i )   {
        st.pb( 'a' + i ) ;
        maxim = max ( maxim , i ) ;
        rec( poz + 1 , max ( maxim + 1 , high ) ) ;
        st.pop_back();
    }

}

int main()  {
    cin >> n ;
    if ( n == 1 )
        return cout << 'a' , 0 ;
    st.pb('a');
    rec( 2 , 1 ) ;
    sort ( sol.begin() , sol.end() ) ;
    for ( int i = 0 ; i < sol.size() ; ++ i , cout << '\n' )
        for ( int j = 0 ; j < sol [ i ].size() ; ++ j )
        cout << sol [ i ][ j ] ;
    return 0;
}


Measured memory_bytes: 7856
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int debt = 100000;
		int n = scanner.nextInt();
		for (int i = 0; i < n; i++) {
			debt = (int)(debt * 1.05);
			if (debt % 1000 != 0) {
				debt = debt - (debt % 1000) + 1000;
			}
		}
		System.out.println(debt);
	}
}

Measured memory_bytes: 25912
A,B,K = map(int,input().split())

if B-A+1 <= K * 2:
    for i in range(A,B+1):
            print(i)

else:
    for i in range(A,A+K): #AからB
        print(i)

    for i in range(B-K+1,B+1):
        print(i)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define push_back pb
#define make_pair mp
using ll =  long long;
const int INF = 0x3f3f3f3f;

const int MAX_N = 1e5+29;
int N, M;
int par[MAX_N],ran[MAX_N];

void init()
{
	for(int i=1;i<MAX_N;++i){
		par[i]=i;
		ran[i]=1;
	}
}

int look(int x)
{
	if(par[x]==x) return x;
	return par[x]=look(par[x]);
}

void comb(int x, int y)
{
	int a = look(x),b=look(y);
	if(a!=b){
		if(ran[a]<ran[b]){
			par[a]=b;
		}else{
			par[b]=a;
			if(ran[a]==ran[b])ran[a]++;
		}
	}
}


void solve()
{
	int ans = 0;
	for(int i=1;i<=N;++i)if(par[i]==i)ans++;
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	init();
	cin >> N >> M;
	int x,y,z;
	for(int i=0;i<M;++i){
		cin >> x >> y >> z;
		comb(x,y);
	}
	solve();
	return 0;
}

Measured memory_bytes: 1024
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N = int(input())
    A, B = [0] * N, [0] * N
    S = []
    for i in range(N):
        A[i], B[i] = map(int, input().split())
        S.append((A[i]+B[i], i))

    S.sort(reverse=True)

    t = a = 0
    for i in range(N):
        idx = S[i][1]
        if not i % 2:
            t += A[idx]
        else:
            a += B[idx]

    print(t-a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 57432
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var array = new int[N];
            var A = ReadInts();

            for (int i = 0; i < N - 1; i++)
            {
                array[A[i] - 1]++;
            }
            foreach (var item in array)
            {
                WriteLine(item);
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 43100
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int sum = 1000000000;
int main() {
	int h, w,k=0,m=0;
	int a[26][26];
	cin >> h >> w;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			k = 0;
			for (int l = 0;l < h;l++) {
				for (int t = 0;t < w;t++) {
					if (l == i || t == j)continue;
					k+= min(abs(i - l), abs(j - t))*a[l][t];
				}
			}
			sum = min(sum, k);
		}
	}cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        for (int k = 0; k <= 1000000000; k++) {
            if (Math.abs(A - k) == Math.abs(B - k)) {
                System.out.println(k);
                break;
            }
            if (A > B && k >= A) {
                System.out.println("IMPOSSIBLE");
                break;
            }
            if (B > A && k >= B) {
                System.out.println("IMPOSSIBLE");
                break;
            }
        }
        
    }
}


Measured memory_bytes: 24276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=3e3;
int n,m;
int temp=1;
int a[N];
int dp[N][N];
ll ans=0;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
	{
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
	{
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
bool check(int a,int b,int c){return a<b+c&&b<c+a&&c<a+b;}
int main()
{
//    freopen("input.in","r",stdin);
//    freopen("output.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for(int i=3;i<=n;i++)
	{
		for(int j=1;j<=i-2;j++)
		{
			int x=upper_bound(a+1,a+n+1,a[i]-a[j])-a;
			if(x>=i) continue;
			if(x<=j) x=j+1;
			ans+=(i-x);
		}
	}
	printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
'use strict'

const Main = (input) => {
  const tmp = input.trim().split('\n')
  const K = parseInt(tmp[0])
  const S = tmp[1]

  let result = ''

  if (S.length <= K) {
    result = S
  } else {
    result=S.substr(0, K) + "..."
  }

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int main(){
	int n,x;
	cin >> n >> x;
	
	vector<int> l(n);
	for(int i = 0; i < n; ++i){
		cin >> l.at(i);
	}
	
	int c = 0;
	int r = 0;
	
	for(int i = 0; i < n;++i){
		r += l.at(i);
		if(r <= x) ++c;
	}
	
	cout << c+1 << endl;
	
	return 0;
}
		

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import combinations

N = int(input().rstrip())
score = [int(input().rstrip()) for _ in range(N)]
score.sort(reverse=1)

s_multiple_of_10 = [s for s in score if s % 10 == 0]
if len(s_multiple_of_10) == N: print(0)
s_not_multiple_of_10 = [s for s in score if s % 10 != 0]

# combinationsでも、先に１０の倍数を除外してから処理したらどうだろう
for i in range(len(s_not_multiple_of_10), 0, -1):
    for c in combinations(s_not_multiple_of_10, i):
        if sum(c) % 10 == 0:
            continue
        else:
            print(sum(c) + sum(s_multiple_of_10))
            exit()
        


Measured memory_bytes: 3316
#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()

ll mpow(ll a, ll b){
	if(b==0){
		return a;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

int main(void){
	ll n;
	cin>>n;
	vector<pair<ll, ll>> job;
	ll a,b;
	rep(i,n){
		cin>>a>>b;
		job.push_back(pair<ll,ll>{b,a});
	}
	sort(all(job));
	ll time = 0;
	rep(i,n){
		time += job[i].second;
		if(time > job[i].first){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 6512
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b, c, x, ans, i, j, k;
	cin >> a >> b >> c >> x;
	ans = 0;
	for (i = 0; i <= a; i++) {
		for (j =0; j <= b; j++) 
			for (k = 0; k <= c; k++) {
				if (i * 500 + j * 100 + k * 50 == x)ans++;
			}
	}
	cout << ans << "\n";



	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n,W;
    cin>>n>>W;
    ll w[n], v[n];
    for(ll i=0; i<n; i++)
    {
        cin>>w[i]>>v[i];
    }
    vector< vector<ll> >  dp(n, vector<ll>(W + 1, 0));
    if(w[0]<=W)
        dp[0][w[0]] = v[0];
    // for(ll i=0; i<=W; i++)
    // {
    //     if(i<=w[0])
    //     {
    //         dp[0][i] = v[0];
    //     }
    //     else
    //     {
    //         dp[0][0] = 0;
    //     }       
    // }
    ll ans = 0;
    for(ll i=1; i<n; i++)
    {
        for(ll j=1; j<=W; j++)
        {
            if(j>=w[i])
                dp[i][j] = max(dp[(i-1)][j], dp[i-1][j - w[i]] + v[i]);
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    for(ll i=0; i<=W; i++)
    {
        ans = max(ans, dp[n-1][i]);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 82356
n, m = list(map(int, input().split()))
ac = set()
wa = {}
for i in range(m):
  p, s = input().split()
  p = int(p)
  if p in ac:
    continue
  if s == 'WA':
    wa[p] = wa.get(p, 0) + 1
  else:
    ac.add(p)
pe = 0
for p in set(ac) & set(wa.keys()):
    pe += wa[p]
print("%d %d" % (len(ac), pe))

Measured memory_bytes: 54232
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const int INF=1e7;
const LL LINF= 1LL << 62;

int main(){
    LL x,y;
    cin >> x >> y;
    LL ans=0;
    if(abs(y)-abs(x)>0){
        ans+=abs(y)-abs(x);
        if(y<0) ans++;
        if(x<0) ans++;
    }
    else if(abs(y)-abs(x)<0){
        ans+=abs(x)-abs(y);
        if(y>0) ans++;
        if(x>0) ans++;
    }
    else{
        if(y*x<0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    int h, n;
    cin >> h >> n;
    int power = 0;
    for(int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        power += tmp;
    }
    
    if(h <= power) cout << "Yes";
    else cout << "No";
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
//  Created by 中川阿津志 on 2018/12/05.
//
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

//#include "atcoder.hpp"

long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}
int main() {
    int N, K;
    int abcd[4] = {0};
    
    
    
    REP(i,3){
        int a, b;
        cin >> a >> b;
        abcd[a]++;
        abcd[b]++;
    }
    
    int numst = 0;
    
    for (int i : abcd)
        if (i % 2 == 1)
            numst++;
    
    cout << (numst <= 2 ? "YES" : "NO") << endl;
    
    return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int m,d,ans=0;
  cin>>m>>d;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=d;j++){
      if(i==(j/10)*(j%10) && (j/10)>=2 && (j%10)>=2){
        ans++;
      }
    }
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;

#define forsn(i,s,n) for(int i=(s); i<(int)(n); i++)
#define forn(i,n) forsn(i,0,n)

typedef long long int tint;

int main() {	
	int n; cin >> n;

	int left = 1, right = 1000;
	while (left + 1 < right) {
		int middle = (left + right) / 2;
		if ((middle * (middle - 1)) / 2 <= n) left = middle;
		else right = middle;
	}
	
	if ((left * (left - 1)) / 2 != n) cout << "No\n";
	else {
		cout << "Yes\n";
		vector<vector<int>> res(left, vector<int>());
		
		cout << left << '\n';
		int cur = 1;
		forn(i, left) forsn(j, i + 1, left) {
			res[i].push_back(cur);
			res[j].push_back(cur++);
		}
		
		forn(i, left) {
			cout << res[i].size();
			for (int r : res[i]) cout << " " << r;
			cout << '\n';
		}
	}
}



Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int N, L,hkk=9999999,sum=0;
	cin >> N >> L;
	for (int i = 0; i < N; i++){
		hkk = min(abs(hkk), L + i);
		sum += L + i;
	}
	cout << sum - hkk << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int c[][] = new int[3][3];

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				c[i][j] = scanner.nextInt();
			}
		}

		for (int i = 0; i <= 100; i++) {
			if (judge(i)) {
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");

	}

	private static boolean judge(int i) {
		int b1 = c[0][0] - i;
		int b2 = c[0][1] - i;
		int b3 = c[0][2] - i;
		boolean jua2 = false;
		boolean jua3 = false;
		for (int j = 0; j <= 100; j++) {
			if (c[1][0] - b1 == j && c[1][1] - b2 == j && c[1][2] - b3 == j)
				jua2 = true;
		}
		for (int j = 0; j <= 100; j++) {
			if (c[2][0] - b1 == j && c[2][1] - b2 == j && c[2][2] - b3 == j)
				jua3 = true;
		}

		if (0 <= b1 && b1 <= 100 && 0 <= b2 && b2 <= 100 && 0 <= b3 && b3 <= 100 && jua2 && jua3)
			return true;
		else
			return false;

	}

}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll m, d;
  cin >> m >> d;

  
  ll cnt = 0;
  rep1(mx, m){
    rep1(dx, d){
      if(dx%10 < 2) continue;
      if(dx/10 < 2) continue;
      if((dx%10)*(dx/10) == mx) cnt++;
    }
  }


  cout << cnt << endl;



  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
broken = []
for i in range(0, N+1):
	broken.append(False)
for i in range(0, M):
	broken[int(input())] = True
dp = [1, 1]
if broken[1]: dp[1] = 0
for i in range(2, N+1):
	if broken[i]: dp.append(0)
	else:
		dp.append(dp[-1]+dp[-2])
print(dp[N]%1000000007)

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a,b;
    cin >> a >> b;
    if(a + b == 15){
        cout << "+\n";
    }else if(a * b == 15){
        cout << "*\n";
    }else{
        cout << "x\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
struct edge{
	int to,next;
}e[N*2];
int head[N],f[N];
int n,tot;
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
void dfs(int x,int fa){
	for (int i=head[x];i;i=e[i].next)
		if (fa!=e[i].to){
			dfs(e[i].to,x);
			f[x]^=f[e[i].to]+1;
		}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	dfs(1,0);
	puts(f[1]?"Alice":"Bob");
}

Measured memory_bytes: 7296
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;
using Graph = vector<vector<int>>;

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; }

vector<bool> seen;

void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int abs_B(long long num, long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

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

bool permutation(vector<int>& vec, vector<int>& P) {
    bool ok = true;
    for (int i = 0; i < vec.size(); i++) {
        //cout << vec.at(i);
        if (vec.at(i) != P.at(i)) {
            ok = false;
        }
    }
    return ok;
}

/*bool nibu(vector<int>& retu,int key) {

}*/

const long long MOD = 1000000007;
const int INF = 1001001001;

int main() {
    int N;
    cin >> N;
    vector<int> retu(N - 1);
    for (int i = 0; i < N - 1; i++) {
        cin >> retu.at(i);
    }
    int ans = 0;
    if (N == 2) {
        cout << retu.at(0) * 2 << endl;
        return 0;
    }
    else {
        ans = retu.at(0);
        for (int i = 0; i < N - 2; i++) {
            ans = ans + min(retu.at(i), retu.at(i + 1));
        }
        ans = ans + retu.back();
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=rdsp;foreach(ref j;v.tupleof)pick(r,j);}}

void main()
{
  int n, t; readV(n, t);
  struct R { int c, t; }
  R[] r; readS(n, r);

  auto cf = r.filter!(ri => ri.t <= t).map!(ri => ri.c);
  if (cf.empty)
    writeln("TLE");
  else
    writeln(cf.reduce!min);
}


Measured memory_bytes: 256
#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.rbegin(),a.rend());

    int A=0,B=0;    
    int flg = 0;

    for(auto p:a){
        if(flg == 0){
            A += p;
            flg = 1;
        }else{
            B += p;
            flg =0;
        }
    }

    cout << A-B << endl;

}

Measured memory_bytes: 3616
#include<cstdio>
#include<algorithm>
using namespace std;
int dp[1001][1001],a[1001],b[1001],mi,t=1000000000;
int main(void)
{
	int n,m,i,j,k,w;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<=m;i++){
		for(j=0;j<n+1;j++){
			dp[i][j]=t;
		}
	}
	dp[0][0]=0;
	for(i=0;i<m;i++){
		for(j=0;j<n+1;j++){
			if(dp[i][j]!=t){
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			}
			if(j!=m+1){
				w=a[j]*b[i];
				dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+w);
			}
		}
	}
	mi=t;
	for(i=0;i<n+1;i++){
		mi=min(t,dp[m][i]);
	}
	printf("%d\n",mi);
	return 0;
}


Measured memory_bytes: 6620
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>
 
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
 
const int INF = 1e9;
 
using namespace std;
 
int main() {
    int t = 0;
    int h = 0;
    int n;
    string taro, hanako;
    cin >> n;
    REP(i, n){
        cin >> taro >> hanako;
        (taro == hanako) ? ( {t++; h++;} ) : ((hanako > taro) ? ({h += 3;}) : ({t += 3;}));
    }
    cout << t << " " << h << endl;
    return 0;
}

Measured memory_bytes: 1212