akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int main(){
  int k,x;
  cin >> k >> x;
  int bottom = x-k+1;
  int upper = k+x-1;
  for(int i=bottom;i<=upper;i++){
    cout << i <<' ';
  }
  cout << endl;
  return 0;
}


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

int main()
{
    int c[3][3];
    for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) cin >> c[i][j];

    int a[3][2] = {};
    int b[3][2] = {};
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 2; j++) {
            a[i][j] = c[i][j] - c[i][j + 1];
            b[i][j] = c[j][i] - c[j + 1][i];
        }
    }
        
    bool f = true;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (a[j][i] != a[j + 1][i]) f = false;
        }
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,a;
  vector<int> vec;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    vec.push_back(a);
  }
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  for(int i=0;i<vec.size()-1;i++) cout << vec[i] << " ";
  cout << vec[vec.size()-1] << endl;
  return(0);
}



Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    int a,b;
    cin >> a >> b;
    print(a/b)
    print(a%b)
    double c = (double)a/b;
    printf("%.16f\n",c);
    //cout << c << endl;
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



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

int main(){
  string S; cin >> S;
  int ans;
  
  for(int i = 0; i < 8; i++){
    int sum = S.at(0) - '0';
    
    for(int j = 0; j < 3; j++){
      if((1 << j) & i){
        sum += S.at(j + 1) - '0';
      }else{
        sum -= S.at(j + 1) - '0';
      }
    }
    if(sum == 7){
      ans = i;
      break;
    }
  }
 
  for(int i = 0; i < 3; i++){
    cout << S.at(i);
    if((1 << i) & ans){
      cout << "+";
    }else{
      cout << "-";
    }
  }
  cout << S.at(3) << "=7" << endl;
}



Measured memory_bytes: 256
# -*- Coding: utf-8 -*-

x = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

print(len(str(make_divisors(x)[-1])))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;


ll num[sz];

int main()
{

    ll i,n;
    double a,x,p,d,t,aa,ans;

    cin>>n>>t>>a;

    for(i=1; i<=n; i++)
    {
        cin>>aa;

        x=t-aa*(0.006);

        d=(x-a);
        if(d<0)d=-d;


        if(i==1)
        {
            p=d;
            ans=1;
        }

        else if(d<p)
        {
            p=d;
            ans=i;
        }
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
import sys

def solve(sx, sy, tx, ty):
    # sA -> tA -> tB -> sB -> sC -> tC -> tD -> sD
    # ..+-------D.
    # ..|+---->AtC
    #   vA......B^
    #   DsB<----+|
    #    C-------+

    dx = tx - sx
    dy = ty - sy
    A = ((sx, sy+1), (tx-1, ty))
    B = ((tx, ty-1), (sx+1, sy))
    C = ((sx, sy-1), (tx+1, ty))
    D = ((tx, ty-1), (sx-1, sy))

    path = ''
    # A
    path += 'U' * dy
    path += 'R' * dx
    # B
    path += 'D' * dy
    path += 'L' * dx
    # C
    path += 'D'
    path += 'R' * (dx + 1)
    path += 'U' * (dy + 1)
    path += 'L'
    # D
    path += 'U'
    path += 'L' * (dx + 1)
    path += 'D' * (dy + 1)
    path += 'R'

    print(path)

def main():
    sx, sy, tx, ty = map(int, input().split())
    solve(sx, sy, tx, ty)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <stdio.h>

int main() {
  long long int a, b, x, y, t, gcd, lcm;


  while(scanf("%lld%lld", &x, &y)!=EOF){

   a=x;
   b=y;
  while (b != 0) {
    t = b;
    b = a % b;
    a = t;
  }

  gcd = a;
  lcm = (x*y)/gcd;

  printf("%lld %lld\n",gcd,lcm);

  }
  return 0;
}



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

int main(){
  int ans=0;
  string s;
  cin >> s;
  int a = (s[0]-'0')*10 + (s[1]-'0'), b = (s[2]-'0')*10+(s[3]-'0');
  if(a>=1&&a<=12) ans+=2;
  if(b>=1&&b<=12) ans+=1;
  
  if(ans==0){
    cout << "NA" << endl;
  } else if(ans==1){
    cout << "YYMM" << endl;
  } else if(ans==2){
    cout << "MMYY" << endl;
  } else {
    cout << "AMBIGUOUS" << endl;
  }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(a.rbegin(),a.rend());
  
  ll ans=0;
  
  priority_queue<pair<int,int>> q;
  q.emplace(a[0],1);
  
  irep(i,1,n){
    ans+=q.top().first;
    
    if(q.top().second==1) q.pop();
    else{
      auto p=q.top(); q.pop();
      q.emplace(p.first,p.second-1);
    }
    q.emplace(a[i],2);
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 6872
N = input()
n_len = len(N)
N = int(N)
A = [[0 for i in range(10)] for _ in range(10)]

ans = 0
for n in range(1, N+1):
    l = int(str(n)[0])
    r = n % 10

    if r == 0:
        continue
    A[l][r] += 1

for l in range(1, 10):
    for r in range(1, 10):
        ans += A[l][r] * A[r][l]

print(ans)


Measured memory_bytes: 3064
from collections import Counter


def main():
    N = int(input())
    counter = Counter(
        int(input())
        for _ in range(N)
    )
    answer = sum(
        1
        for v in counter.values()
        if v % 2 != 0
    )
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15452
S = int(input())

a = set([])

a1 = S
i = 0
while not(a1 in a):
    a.add(a1)
    i = i + 1
    if (a1 % 2 == 0):
        a1 = int(a1 / 2)
    else:
        a1 = a1 * 3 + 1

print(i+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<double> a(n);
	rep(i,n)cin >> a[i];
	sort(a.begin(),a.end());
	double ret = a[0];
	rep(i,n){
		if(i){
			ret = (ret+a[i])/2;
		}
	}
	printf("%.12lf",ret);
	return 0;
}

Measured memory_bytes: 3776
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Queue;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
 
 
 
public class Main{
	
	static int posx;
	static int posy;
	static int type;
	static int diff;
	static int INF = Integer.MAX_VALUE;
	static int[][] d;
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 long X=sc.nextLong();
	 long Y=sc.nextLong();
	 long Z=0;
     long result = 0;
     while(true) {
    	 
    	 Z=(long) (X*Math.pow(2, result));
    	if(Z>Y) {
    		
    		break;    	}
    	result++;
    	 
     }
     System.out.println(result);
     
	 
	 
 }
	
 
 
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;
  
public class Main {
  public static void main(String[] args) throws Exception{
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      int value;
      value = Integer.parseInt(in.readLine());
      System.out.println(value*value*value);
      in.close();
  }
}

Measured memory_bytes: 24180
/**
 * Contest : AtCoder Beginner Contest 159
 * Contest URL : https://atcoder.jp/contests/abc159/
 * Problem : E - Dividing Chocolate
 * Problem URL : https://atcoder.jp/contests/abc159/tasks/abc159_e
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

const int inf = 1000000;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector < string > bar (h);
	for (int i = 0; i < h; i++) {
		cin >> bar[i];
	}
	int answer = INT_MAX;
	//vector < bool > cut (h - 1);
	for (int state = 0; state < (1 << (h - 1)); state++) {
		vector < int > cuts;
		for (int i = 0; i < h - 1; i++) {
			if ((state >> i) & 1) {
				cuts.push_back (i);
			}
		}
		cuts.push_back (h - 1);
		vector < vector < int > > white_bars (cuts.size(), vector < int > (w));
		int start = 0;
		int index = 0;
		for (int end : cuts) {
			for (int j = 0; j < w; j++) {
				int s = 0;
				for (int i = start; i <= end; i++) {
					s += (bar[i][j] == '1');
				}
				white_bars[index][j] = s;
			}
			index++;
			start = end + 1;
		}
		vector < int > sums (white_bars.size());
		int count = 0;
		for (int j = 0; j < w; j++) {
			bool valid = true;
			for (int i = 0; i < sums.size(); i++) {
				sums[i] += white_bars[i][j];
				if (sums[i] > k) { valid = false; break; }
			}
			if (!valid) {
				count++;
				//sums.assign (sums.size(), 0);
				for (int i = 0; i < sums.size(); i++) {
					sums[i] = white_bars[i][j];
					if (sums[i] > k) {
						count = inf;
						break;
					}
				}
			}
		}
		answer = min (answer, count + (int) cuts.size() - 1);
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())
for i in range(K):
  if i%2==0:
    if A%2==1:
      A = A-1
    A //= 2
    B += A
  elif i%2==1:
    if B%2==1:
      B = B-1
    B //= 2
    A += B
print(A, B)

Measured memory_bytes: 3060
import math


def compute_triangle_area(a: float, b: float, c: float) -> float:
    s = (a + b + c) / 2.0
    return math.sqrt(s * (s - a) * (s - b) * (s - c))


def compute_triable_height(a: float, area: float) -> float:
    return 2 * area / a


if __name__ == "__main__":
    a, b, angle = map(lambda x: float(x), input().split())
    c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle)))
    area = compute_triangle_area(a, b, c)
    length = a + b + c
    height = compute_triable_height(a, area)
    print(f"{area}")
    print(f"{length}")
    print(f"{height}")



Measured memory_bytes: 5704
#include <iostream>

using namespace std;

int main(void){
  int n,k,x,y;
  int sum = 0;
  
  cin >> n >> k >> x >> y;
  
  if(n > k){
    sum += x * k + y * (n-k);
  }else{
    sum += x * n;
  }
  
  cout << sum;
  
  return 0;
  
}
      

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int SIZE=500000;
int A[SIZE+1], H;
void maxheap(int v){
	int l=v*2,r=v*2+1,lar;
	int sto;
	if(l<=H&&A[l]>A[v])lar=l;
	else lar=v;
	if(r<=H&&A[r]>A[lar])lar=r;
	if(lar!=v){
		sto=A[v];A[v]=A[lar];
		A[lar]=sto;maxheap(lar);
	}
	return;
}
void buildmaxh(){
	for(int i=H/2;i>=1;i--)maxheap(i);
	return;
}
int main() {
	cin>>H;
	for(int i=1;i<=H;i++)cin>>A[i];
	buildmaxh();
	for(int i=1;i<=H;i++)cout<<" "<<A[i];
	cout<<endl;
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

vector<ll> inv,fact,invfact;

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


void mod_build(int n=101010){  
  fact.resize(n+1);
  inv.resize(n+1);
  invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1;
  inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
  k%=mod-1;
  if(k<0)k+=mod-1;
  ll ret=1;
  while(k){
    if(k&1)ret=ret*n%mod;
    n=n*n%mod;
    k>>=1;
  }
  return ret;
}

int main(){  
  mod_build();
  int n,k;
  cin >> n >> k;
  vector<ll> a(n,0);  
  rep(i,n){
    cin>>a[i];
  }

  sort(a.rbegin(),a.rend());
  ll ans=0;
  for(ll i=0; i<n-k+1; i++){
    ans += ((ll)(a[i]*comb(n-i-1,k-1)))%mod;
    ans %= mod;
  }

  sort(a.begin(),a.end());
  ll ansb=0;
  for(ll i=0; i<n-k+1; i++){
    ansb += ((ll)(a[i]*comb(n-i-1,k-1)))%mod;
    ansb %= mod;
  }

  ans = ans-ansb;
  while(ans<mod){ ans += mod;}
  ans %= mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();    
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = stdIn.nextInt();
        }   
        stdIn.close();

        int count = 1;
        int min = P[0];
        for (int i = 1; i < N; i++) {
            if (P[i] < min) {
                min = P[i];
                count++;
            }
        }
        System.out.println(count);

    }
}

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

bool solve() {
	int edges[3];
	for(auto &e : edges) cin >> e;
	sort(edges, edges + 3);
	return edges[0] * edges[0] + edges[1] * edges[1] == edges[2] * edges[2];
}

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

	int t;
	cin >> t;
	while(t--) cout << (solve() ? "YES" : "NO") << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main(){

    input!{
        s: chars,
    }

    println!("{}{}{}", s[0], s.len() - 2, s[s.len() - 1]);


}

Measured memory_bytes: 4352
k,n = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

def from_the_first(house)
  house[-1] - house[0]
end

def from_the_other(house, point, end_point)
  house[(point - 1)] + end_point - house[point]
end 

distance = []
(a.length - 1).times{|s| distance << a[(s+1)] - a[s] }
departure_point = distance.index(distance.max) +1

puts  [from_the_other(a, departure_point, k), from_the_first(a)].min

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

int main() {
  int n,k; cin >> n >> k;
  vector<ll> posi, nega;
  rep(i,n){
    ll s; cin >> s;
    if(s<0) nega.push_back(-s);
    if(s>=0) posi.push_back(s);
  }

  reverse(nega.begin() , nega.end());

  /*for(auto p : posi) cout << p <<" ";
  cout << endl;
  for(auto p : nega) cout << p <<" ";*/

  //min(k-1,posi.size()-1)
  ll ans = 1e12;
  ll nowans;
  int size=posi.size();
  ll s = min(k-1,size-1);
  if(size == 0){
    cout << nega[k-1] << endl;
    return 0;
  }
  rep(i,k){
    if(s+1-k >= 0){
      nowans = posi[s];
      //cout << "upcase: nowans= " << nowans << endl;
      ans = min(nowans , ans);
    }
    if(s+1-k < 0){
      nowans = min(posi[s],nega[k-s-2])*2 + max(posi[s],nega[k-s-2]);
      //cout << "downcase: nowans= " << nowans << endl;
      ans = min(nowans , ans);
    }
    s--;
    if(s<0 || k-s-2>= nega.size()) break; //break判定
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="AAA" || s=="BBB"){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
#print(a, b)
ans = -1
i = 0
for i in range(10 ** 6):
    if int(i * 0.08) == a:
        if int(i*0.1) == b:
            ans = i
            break
        #print(i)

# print(int(25 * 0.08))
# print(int(25 * 0.1))
print(ans)

Measured memory_bytes: 40172
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int mod=10000,MAX=203,INF=1<<30;

using namespace std;

int main(){
    int N; cin >> N;
    string S; cin >> S;

    int need_left = 0;
    int pointer = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == '(') ++pointer;
        else {
            if (pointer == 0) ++need_left;
            else --pointer;
        }
    }

    int need_right = pointer;
    string res = "";
    for (int i = 0; i < need_left; ++i) res += '(';
    res += S;
    for (int i = 0; i < need_right; ++i) res += ')';
    cout << res << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

ll n, m, x, x2, y, y2, cntx, cnty, ans;

int main() {
	cin >> n >> m;
	cntx = cnty = 0;
	cin >> x;
	lp(n - 1) {
		cin >> x2;
		cntx += (x2 - x) * (i + 1)*(n - 1 - i);
		x = x2;
	}
	cin >> y;
	lp(m-1) {
		cin >> y2;
		cnty += (y2 - y)*(i + 1)*(m - 1 - i);
		y = y2;
	}
	cout << (cntx%mod)*(cnty%mod) % mod << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N,M;
  cin>>N>>M;
  cout<<N*M<<endl;

  return 0;
}



Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static System.Console;

namespace AGC033A
{
    class MainClass
    {

        static int[] s;
        static long[] n;
        static int[,] his;

        static List<char[]>fld= new List<char[]>();
        static LinkedList<int[]>dstlst = new LinkedList<int[]>();
        public static void Main(string[] args)
        {

            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            for(int i= 0;i<s[0];i++){
                fld.Add(ReadLine().ToCharArray());
            }

            his = new int[s[0],s[1]];

            for(int i=0;i<s[0];i++){
                for(int j=0;j<s[1];j++){
                    if(fld[i][j]=='#'){
                        his[i,j]=0;
                        int[] dst = new int[2]{i,j};
                        dstlst.AddLast(dst);
                    }else{
                        his[i,j]=-1;
                    }
                }
            }

            int ans = 0;
            for(int i=0;i<int.MaxValue;i++){
                int dstcnt = dstlst.Count();
                for(int j=0;j<dstcnt;j++){
                    int x = dstlst.First()[0];
                    int y = dstlst.First()[1];
                    Visit(x,y);
                }
                if(!dstlst.Any()){
                    ans = i;
                    break;
                }

            }
            WriteLine(ans);
        }

        public static void Visit(int x, int y){

            his[x,y]=0;
            dstlst.RemoveFirst();

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


            for(int i = 0;i<4;i++){
                int nx = x+dx[i];
                int ny = y+dy[i];
                if(0<=nx&&nx<s[0]&&0<=ny&&ny<s[1]&&his[nx,ny]==-1){
                    his[nx,ny]=0;
                    int[]dst = new int[2]{nx,ny};
                    dstlst.AddLast(dst);
                }
            }
        }
    }
}


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

int main(void){
    unsigned long long int A;
    double B;   //double型　－＞有効数字15,16桁
    //最低18桁以上の有効数字がほしい
    cin >> A >> B;
    long long int  B100 = (long long)(B*100 + 0.001);
    cout << A*B100 / 100 << endl;
    return 0;
}

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

int main(){
	int a,b;
	cin>>a>>b;
	int count=0;
	for (int i = a; i <= b; i++){
		if(i/10000==i%10&&i/1000%10==i/10%10){
			count++;
		}
	}
	cout<<count<<endl;
} 

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

// @author: pashka

int BUBEN = (1 << 9) - 1;
int MAX = 100001;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> v(n), w(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i] >> w[i];
    }
    int nn = min(n, BUBEN);
    vector<vector<int>> d(nn, vector<int>(MAX));
    for (int j = w[0]; j < MAX; j++) {
        d[0][j] = v[0];
    }
    for (int i = 1; i < nn; i++) {
        int p = (i - 1) / 2;
        for (int j = 0; j < MAX; j++) {
            d[i][j] = d[p][j];
            if (j >= w[i]) {
                d[i][j] = max(d[i][j], d[p][j - w[i]] + v[i]);
            }
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int t, l;
        cin >> t >> l;
        t--;
        vector<int> c;
        while (t >= BUBEN) {
            c.push_back(t);
            t = (t - 1) / 2;
        }
        int m = c.size();
        int res = 0;
        for (int x = 0; x < (1 << m); x++) {
            int sv = 0;
            int sw = 0;
            for (int i = 0; i < m; i++) {
                if (x & (1 << i)) {
                    sv += v[c[i]];
                    sw += w[c[i]];
                }
            }
            if (sw <= l) {
                res = max(res, sv + d[t][l - sw]);
            }
        }
        cout << res << "\n";
    }

    return 0;
}

Measured memory_bytes: 206008
object Main extends App {

  for (i <- 1 to 9; j <- 1 to 9) yield Param(i, j).print

  case class Param(x: Int, y: Int) {
    val ans = x * y

    private def format: String = {
      s"${x}x${y}=${ans}"
    }

    def print = println(format)
  }

}

Measured memory_bytes: 43904
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // input
    int quantity = Integer.parseInt(br.readLine());
    String[] str = br.readLine().split(" ");
    long min = 1000000;
    long max = -1000000;
    long sum = 0;

    for(int i = 0; i < quantity; i++){

      long value = Integer.parseInt(str[i]);

      //check
      if(min > value)
        min = value;
      if(max < value)
        max = value;
      sum += value;
    }
    // output
    System.out.println(min + " " + max + " " + sum);
  }
}

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

int f(int x, int y, int z){
    return x * x + y * y + z * z + x * y + y * z + z * x;
}



int main() {
    int n;
    cin >> n;
    int tmp_count = 0;


    for (int i = 1; i < n+1; i++){
        int limit = sqrt(i);
        int count = 0;
        
        for (int x = 1; x < limit + 1; x++){
            if(f(x, x, x) == i){
                count += 1;
            }
        }

        tmp_count = 0;
        for (int x = 1; x < limit + 1; x++){
            for (int z = 1; z < limit + 1; z++){
                if(x != z && f(x, x, z) == i){
                    tmp_count += 1;
                }
            }
        }

        count += tmp_count * 3;
        tmp_count = 0;
        for (int x = 1; x < limit + 1; x++){
            for (int y = 1; y < x; y++){
                for (int z = 1; z < y; z++){
                    if(f(x, y, z) == i){
                        tmp_count += 1;
                    }
                }
            }
        }
        count += tmp_count * 6;
        cout << count << endl;
    }
}





Measured memory_bytes: 3588
#pragma region template
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

typedef tuple<ll, ll, ll> e;

int main()
{
    ll n, m, s, t;
    cin >> n >> m >> s >> t;
    vi u(m), v(m), a(m), b(m);
    REP(i, m)
    {
        cin >> u[i] >> v[i] >> a[i] >> b[i];
    }

    vector<vector<e>> G(n + 1);
    REP(i, m)
    {
        G[u[i]].push_back(e(v[i], a[i], b[i]));
        G[v[i]].push_back(e(u[i], a[i], b[i]));
    }
    priority_queue<ii, vector<ii>, greater<ii>> q;
    vi dp(n + 1, INF);
    q.push(ii(0, s));
    dp[s] = 0;
    while (!q.empty())
    {
        ii x = q.top();
        q.pop();
        ll c = x.first;
        ll i = x.second;

        REP(k, G[i].size())
        {
            ll j = get<0>(G[i][k]);
            ll w = c + get<1>(G[i][k]);
            if (w < dp[j])
            {
                dp[j] = w;
                q.push(ii(w, j));
            }
        }
    }
    priority_queue<ii, vector<ii>, greater<ii>> q2;
    vi dp2(n + 1, INF);
    q2.push(ii(0, t));
    dp2[t] = 0;
    while (!q2.empty())
    {
        ii x = q2.top();
        q2.pop();
        ll c = x.first;
        ll i = x.second;

        REP(k, G[i].size())
        {
            ll j = get<0>(G[i][k]);
            ll w = c + get<2>(G[i][k]);
            if (w < dp2[j])
            {
                dp2[j] = w;
                q2.push(ii(w, j));
            }
        }
    }
    priority_queue<ii, vector<ii>, greater<ii>> r;
    REP1(i, n)
    {
        r.push(ii(dp[i] + dp2[i], i));
    }
    REP(i, n)
    {
        while (r.top().second <= i)
        {
            r.pop();
        }
        ll ans = 1e15 - r.top().first;
        OUT(ans);
    }
}
#pragma endregion template

Measured memory_bytes: 18036
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  rep(i, n - 2)
  {
    if (s.substr(i, 3) == "ABC")
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
/**
*  vote
*/

#include<bits/stdc++.h>
using namespace std;

/** define */

/** global */
int n = 0;
int m = 0;
int _list[1020] = {0};
int standard[1020] = {0};
int eval[1020] = {0};

void solve()
{
  for (int i = 0; i < m; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (standard[i] >= _list[j])
      {
        eval[j]++;
        break;
      }
    }
  }
}

int getAns()
{
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    ans = max(ans, eval[i]);
  }
  for (int i = 0; i < n; i++)
  {
    if (eval[i] == ans)
    {
      return i+1;
    }
  }
  return -1;
}

int main()
{
  cin >> n >> m;
  for (int i = 0; i < n; i++)
  {
    cin >> _list[i];
  }
  for (int i = 0; i < m; i++)
  {
    cin >> standard[i];
  }
  solve();
  printf("%d\n", getAns());
  return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end(), greater<ll>());
    ll sum = A[0];
    queue<pll> Q;
    Q.push(pll(A[0], A[1])); Q.push(pll(A[0], A[1]));

    for (int i = 2; i < N; i++) {
        pll p = Q.front(); Q.pop();
        sum += p.second;
        Q.push(pll(p.first, A[i]));
        Q.push(pll(p.second, A[i]));
    }
    cout << sum << '\n';
}


Measured memory_bytes: 8196
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdlib>
#define x first
#define y second
#define lch 2*x
#define rch 2*x+1
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=3e5+5,T=2e6+5;
const ll mod=1e9+7;
struct node{
    int maxv,add;
}tree[T];
void Pushdown(int x){
    if(tree[x].add){
        tree[lch].add+=tree[x].add;
        tree[lch].maxv+=tree[x].add;
        tree[rch].add+=tree[x].add;
        tree[rch].maxv+=tree[x].add;
        tree[x].add=0;
    }
}
void Pushup(int x){
    tree[x].maxv=max(tree[lch].maxv,tree[rch].maxv);
}
void Add(int x,int l,int r,int pl,int pr,int add){
    if(pl<=l&&r<=pr){
        tree[x].maxv+=add;
        tree[x].add+=add;
        return ;
    }
    int mid=(l+r)>>1;
    if(pl<=mid)
        Add(x*2,l,mid,pl,pr,add);
    if(pr>mid)
        Add(x*2+1,mid+1,r,pl,pr,add);
    Pushdown(x);
    Pushup(x);
}
int w,h,n;
pii p[N],sta[N],stb[N];
int topa,topb;
int ans;
void work(){
    sort(p+1,p+n+1);
    memset(tree,0,sizeof tree);
    topa=topb=0;
    for(int i=1;i<n;i++){
        if(p[i].y<=h/2){
            int nxt=i-1;
            while(topa&&p[i].y>sta[topa].y){
                Add(1,1,n,sta[topa].x,nxt,sta[topa].y-p[i].y);
                nxt=sta[topa--].x-1;
            }
            if(nxt!=i-1)
                sta[++topa]=pii(nxt+1,p[i].y);
        }
        else{
            int nxt=i-1;
            while(topb&&p[i].y<stb[topb].y){
                Add(1,1,n,stb[topb].x,nxt,p[i].y-stb[topb].y);
                nxt=stb[topb--].x-1;
            }
            if(nxt!=i-1)
                stb[++topb]=pii(nxt+1,p[i].y);
        }
        sta[++topa]=pii(i,0);
        stb[++topb]=pii(i,h);
        Add(1,1,n,i,i,h-p[i].x);
        Pushdown(1);
        Pushup(1);
        ans=max(ans,tree[1].maxv+p[i+1].x);
    }
}
int main()
{
    scanf("%d%d%d",&w,&h,&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&p[i].x,&p[i].y);
    }
    p[++n]=pii(0,0);
    p[++n]=pii(w,h);
    work();
    for(int i=1;i<=n;i++)
        swap(p[i].x,p[i].y);
    swap(w,h);
    work();
    printf("%d\n",ans*2);
}


Measured memory_bytes: 22784
h, w, k = map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0
for patH in range(0, 2**h):
    for patW in range(0, 2**w):
        cnt = 0
        for y in range(h):
            for x in range(w):
                if patH & 2 ** y or patW & 2 ** x:
                    continue
                elif c[y][x] == '#':
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

int main(){
  char c;
  string s = "aeiou", flg = "consonant";
  
  cin >> c;
  for(int i = 0;i < s.size();i++){
    if(c == s.at(i)){
      flg = "vowel";
      break;
    }
  }
  cout << flg << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}


const int MAX = 210;
const int MAXW = 10100;
const ll MOD = 1000000007;

int N, W;
int w[MAX];
int s[MAX];

ll ndp[MAX][MAXW];
ll udp[MAX][MAXW];

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    while (cin >> N >> W) {
        memset(w, 0, sizeof(w));
        memset(s, 0, sizeof(s));
        for (int i = 0; i < N; ++i) {scanf("%d", &w[i]);}
        sort(w, w+N, greater<int>());
        for (int i = 0; i < N; ++i) s[i] = w[i];
        for (int i = N-1; i >= 1; --i) {
            s[i-1] += s[i];
        }
        
        memset(ndp, 0, sizeof(ndp));
        memset(udp, 0, sizeof(udp));
        
        ndp[0][0] = 1;
        udp[0][0] = 0;
        
        ll res = 0;
        if (s[0] <= W) res = 1;
        for (int i = 0; i <= N; ++i) {
            for (int j = 0; j <= W; ++j) {
                //cout << i << ", " << j  << " : " << ndp[i][j] << " ; " << udp[i][j] <<endl;
                
                ndp[i+1][j] += ndp[i][j] + udp[i][j];
                if (j >= w[i]) udp[i+1][j] += ndp[i][j-w[i]] + udp[i][j-w[i]];
                ndp[i+1][j] %= MOD; udp[i+1][j] %= MOD;
                
                if (i <= N-1) {
                    ll S = W - s[i+1];
                    if (j >= S - w[i] + 1 && j <= S) res += ndp[i+1][j];
                    res %= MOD;
                }
            }
        }
        
        cout << res << endl;
    }
    
    return 0;
}


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

int main(){
  int n; cin >> n;
  int a[n], reg[9]={};
  
  for(int i=0; i<n; i++) {
    cin >> a[i];
    if(a[i]<400) reg[0]=1;
    else if(a[i]<800) reg[1]=1;
    else if(a[i]<1200) reg[2]=1;
    else if(a[i]<1600) reg[3]=1;
    else if(a[i]<2000) reg[4]=1;
    else if(a[i]<2400) reg[5]=1;
    else if(a[i]<2800) reg[6]=1;
    else if(a[i]<3200) reg[7]=1;
    else reg[8]++;
  }

  int min_reg, max_reg;
  min_reg = max(accumulate(reg,reg+8,0),1);
  max_reg = accumulate(reg,reg+9,0);

  cout << min_reg << " " << max_reg << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <ios>
#include <iostream>
#include <vector>

std::vector<int> tak[305] = {};
int arr[305][305] = {};
bool rej[305] = {}; //rejected
bool has[305] = {};
int pos[305] = {};
int n, m;

bool can(int k)
{
    for (int i = 0; i < n; i++)
    {
        has[i] = false;
        pos[i] = 0;
    }
    for (int i = 0; i < m; i++)
    {
        rej[i] = false;
        tak[i].clear();
    }
    bool found = false;
    bool ok = true;
    while (!found && ok)
    {
        found = true;
        for (int i = 0; i < n && ok; i++)
        {
            if (!has[i])
            {
                found = false;
                while (rej[arr[i][pos[i]]])
                {
                    pos[i]++;
                    if (pos[i] >= m)
                        return false;
                }
                has[i] = true;
                tak[arr[i][pos[i]]].push_back(i);
                if (tak[arr[i][pos[i]]].size() > k)
                {
                    int gy = arr[i][pos[i]];
                    for (std::vector<int>::iterator it = tak[gy].begin(); it != tak[gy].end(); it++)
                    {
                        pos[*it]++;
                        has[*it] = false;
                        if (pos[*it] >= m)
                            return false;
                    }
                    tak[arr[i][pos[i]-1]].clear();
                    rej[arr[i][pos[i]-1]] = true;
                }
            }
        }
    }
    return found;
}

int main()
{
    //std::ios_base::sync_with_stdio(false);
    //std::cin.tie(NULL);
    //std::cout.tie(NULL);
    std::cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            std::cin >> arr[i][j];
            arr[i][j]--;
        }
    }
    int lo = 1;
    int hi = n;
    int ans = -1;
    while (lo <= hi)
    {
        int mid = (lo+hi)/2;
        if (can(mid))
        {
            hi = mid-1;
            ans = mid;
        }
        else
            lo = mid+1;
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a;
    cin >> a;
    if (a <= 999) {
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
    return 0;
}

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

using namespace std;

int main(int argc, char** argv){
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B), c(M);
    for (int i=0; i<A; i++) cin >> a[i];
    for (int i=0; i<B; i++) cin >> b[i];
    for (int i=0; i<M; i++){
        int x, y;
        cin >> x >> y >> c[i];
        x--; y--;
        c[i] = a[x] + b[y] - c[i];
    }
    int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    ans = min(ans, *min_element(c.begin(), c.end()));
    cout << ans << "\n";

    return 0;
}


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

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

	vector<int> list(n);
	for (int i = 0; i < n; i++)
		cin >> list[i];

	sort(list.begin(), list.end());

	long int ans = 0;

	for (int i = 0; i < k; i++)
		ans += list[i];

	cout << ans;

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
	string s;
    cin >> s;

    int count = 0;
    for (char c : s)
    {
        if (c == '1')
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3584