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

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

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

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

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

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

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

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

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M; cin >> N >> M;
    unordered_map<lint, lint> num_occurances;
    range(i, 0, M) {
        lint a, b; cin >> a >> b;
        a--; b--;
        num_occurances[a] += 1;
        num_occurances[b] += 1;
    }
    for (const auto& p : num_occurances) {
        // cout << p << "\n";
        if (p.second % 2) {
            cout << "NO" << "\n";
            return 0;
        }
    }
    cout << "YES" << "\n";
}

Measured memory_bytes: 4004
N,K=map(int,raw_input().split())
D=map(int,raw_input().split())

U=[i for i in range(10) if i not in D]

Keta=1
while True:
    if N>U[-1]*(sum(10**(i) for i in range(Keta))):
        Keta+=1
    else:
        break

N_copy=N

Result=[]
for k in range(Keta):

    for u in U:
        if u*(10**(Keta-k-1))+U[-1]*(sum(10**(i) for i in range(Keta-k-1)))>=N_copy:
            Result.append(u)
            N_copy-=u*(10**(Keta-k-1))
            break
#    print u
#    print N_copy
#    print Keta
    if N_copy<=0:
        while len(Result)<Keta:
            Result.append(U[0])
        break

Ans=sum(Result[i]*(10**(Keta-i-1)) for i in range(len(Result)))
print Ans 

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

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


int main(){

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(), a.end(), less<ll>());
  
  vector<ll> l;
  vector<ll> r;

  l.push_back(a[0]);
  r.push_back(a[n-1]);

  rep(i,n-2){
    if(a[i+1]>0){
      r.push_back(a[i+1]);
    }else{
      l.push_back(a[i+1]);
    }
  }
  vector<P> ans;
  ll x = l[l.size()-1];
  ll y;
  rep(i,r.size()-1){
    y = r[i];
    P p = {x,y};
    ans.push_back(p);
    x = x-y;
  }

  y = x;
  x = r[r.size()-1];
  P p = {x,y};
  ans.push_back(p);
  x = x-y;

  rep(i,l.size()-1){
    y = l[i];
    P p = {x,y};
    ans.push_back(p);
    x = x-y;
  }

  cout << x << endl;
  rep(i,n-1){
    cout << ans[i].first << " " << ans[i].second << endl;
  }

  return 0;
} 

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin >> a >> b;

    ll ab=__gcd(a,b);

    ll abc=ab;
//    cout << ab << "\n";
    ll div=2;
    map<int,int> mpab;
    mpab[1]=1;
    while(abc>=div*div) {
        if(abc%div==0){
            abc/=div;
            mpab[div]++;
        }
        else div++;
    }
    mpab[abc]++;
//    for(auto itr = mpab.begin(); itr != mpab.end(); itr++) {
//        cout << itr->first << " " << itr->second << "\n";
//    }
    cout << mpab.size() << "\n";
    return 0;
}

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

int main(){
	int N,x;
	cin >> N;
	int arr[N];
	int count=0;
	for(int i=0;i<N;++i){
		cin >> x;
		arr[i] = x;
	}
	int curr=arr[0];
	for(int i=0;i<N;++i){
		if(arr[i]<=curr){
			count++;
			curr = arr[i];
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 1024
// ワーシャルフロイドからの全探索でオあり
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  int N, M, R;
  long long ans = 100100100100100100;
  cin >> N >> M >> R;
  vector<int> r(R);
  for(int i=0;i<R;i++) {
    cin >> r[i];
    r[i]--;
  }
  vector<vector<long long>> d(N, vector<long long>(N));
  for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
    if(i == j) d[i][j] = 0;
    else d[i][j] = 100100100100100100;
  }
  for(int i=0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
    if(d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
  }
  sort(r.begin(), r.end());
  do {
    long long total = 0;
    for(int i=0;i<R-1;i++) {
      total += d[r[i]][r[i+1]];
    }
    if(total < ans) ans = total;
  } while(next_permutation(r.begin(), r.end()));

  cout << ans << endl;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st, st2;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    public static void main(String[] args) throws Exception {
        int N = Integer.parseInt(br.readLine());
        TreeMap<Integer, TreeSet<Integer>> d = new TreeMap<Integer, TreeSet<Integer>>();
        ArrayList<Pair> A = new ArrayList<Pair>();

        ArrayList<Integer> a2 = new ArrayList<Integer>();
        ArrayList<Integer> b2 = new ArrayList<Integer>();

        st = new StringTokenizer(br.readLine());
        st2 = new StringTokenizer(br.readLine());
        for (int i = 0; i < N; i++) {
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st2.nextToken());
            if (!d.containsKey(a)) {
                d.put(a, new TreeSet<Integer>());
            }
            A.add(new Pair(a, b));
            a2.add(a);
            b2.add(b);
        }

        Collections.sort(A);
        Collections.sort(a2);
        Collections.sort(b2);

        for (int i = 0; i < N; i++) {
            d.get(A.get(i).a).add(i);
            if (a2.get(i) > b2.get(i)) {
                N = -1;
            }
        }

        boolean f = false;
        for (int i = 0; i < N-1; i++) {
            // System.out.println(d);
            Pair p = A.get(i);
            if (p.a <= p.b) {
                f = true;
                break;
            }
            int fn = d.firstKey();
            if (fn > p.b) {
                break;
            }
            if (d.get(fn).size() >= 2) {
                f = true;
                break;
            }
            int toSwap = d.get(fn).first();
            d.remove(fn);
            if (d.firstKey() <= p.b) {
                f = true;
                break;
            }
            A.get(toSwap).a = p.a;
            d.get(p.a).remove(i);
            d.get(p.a).add(toSwap);
        }

        pw.println(f ? "Yes" : "No");

        pw.close();
        br.close();
    }
}

class Pair implements Comparable<Pair>{
    public int a, b;

    Pair(int _a, int _b){
        a = _a;
        b = _b;
    }
 
    public String toString(){
        return a + " " + b;
    }

    public int compareTo(Pair p){
        if (b != p.b) return b < p.b ? -1 : 1;
        if (a != p.a) return a < p.a ? -1 : 1;
        return 0;
    }
}

Measured memory_bytes: 85720
def resolve():
    k = int(input())
    from collections import deque
    a = [1,2,3,4,5,6,7,8,9]
    b = [1,2,3,4,5,6,7,8,9]
    if k < 10:
        print(a[k-1])
    else:
        a = deque(a)
        b = deque(b)
        while len(b) <= k:
            test = a.popleft()
            mtest = test % 10
            if mtest == 0:
                a.append (test*10)
                a.append (test*10+mtest+1)
                b.append (test*10)
                b.append (test*10+mtest+1)
            elif mtest == 9:
                a.append (test*10 + mtest-1)
                a.append (test*10 + mtest)
                b.append (test*10 + mtest-1)
                b.append (test*10 + mtest)
            else:
                a.append (test*10 + mtest-1)
                a.append (test*10 + mtest)
                a.append (test*10 + mtest+1)
                b.append (test*10 + mtest-1)
                b.append (test*10 + mtest)
                b.append (test*10 + mtest+1)
        print(b[k-1])
resolve()

Measured memory_bytes: 10196
using System;
using System.Linq;

public class MainClass {
    public static void Main(string[] args) {
        string[] input = Console.ReadLine().Split(' ');
        int[] nums = input.Select(i => int.Parse(i)).ToArray();
        int max = Math.Max(nums[0], nums[1]);
        if (nums[0] != nums[1]) {
            Console.WriteLine(2 * max - 1);
        } else {
            Console.WriteLine(2 * max);
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

int min(int x,int y){return x>y?y:x;}
int max(int x,int y){return x>y?x:y;}

int main(){

  int n,x=(int)1e9,y,ans=-(int)1e9,i;

  scanf("%d%d",&n,&y);

  for(i=1;i<n;i++){

    x=min(x,y);
    scanf("%d",&y);
    ans=max(ans,y-x);

  }

  printf("%d\n",ans);

  return 0;

}



Measured memory_bytes: 2140
def main():
    from sys import stdin
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    res = ""
    for i in r:
        if i == '1':
            res += '9'
        else:
            res += '1'
    print(res)
   
if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
#include<stdio.h>
#define MAX 3000000

int x,T[MAX+1];

void A(int a){
  int l,r,z,b;
  l=2*a;
  r=2*a+1;

  if(l<=x&&T[l]>T[a]){
    z=l;
  }else {
    z=a;
  }

  if(r<=x&&T[r]>T[z]){
    z=r;
  }

  if(z != a){
    b=T[a];
    T[a]=T[z];
    T[z]=b;
    A(z);
  }
}

int main(){
  int i;
  
  scanf("%d",&x);

  for(i=1;i<=x;i++){
    scanf("%d",&T[i]);
  }

  for(i=x/2;i>=1;i--){
    A(i);
  }

  printf(" ");
  for(i=1;i<=x;i++){
    printf("%d",T[i]);
    if(i!=x){
      printf(" ");
    }else{
      printf("\n");
    }
  }
  
  return 0;
}



Measured memory_bytes: 3656
n = gets.chomp.to_i
v_arr = gets.chomp.split(' ').map(&:to_i)

v_arr = v_arr.sort
answer = 0
v_arr.each_with_index do |v, index|
  if index == 0 or index == 1
    answer += 1.0 * v / 2 ** (n - 1)
  else
    answer += 1.0 * v / 2 ** (n - index)
  end
end
puts answer


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN 
#if !testing
	#define cerr if(0)cout
#endif

int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	vector <vector<int> > v;
	int n; cin >> n;
	vector <int> a, b;
	FOR(i,1,n) {
		int x; cin >> x;
		a.pb(x);
	}
	FOR(i,1,n) {
		int x; cin >> x;
		b.pb(x);
	}
	vector <int> ov;
	FOR(i,1,n) ov.pb(i);
	int sz = 0;
	do {
		++sz;
		v.pb(ov);
		dbv(ov);
	} while (next_permutation(all(ov)));
	int id1, id2;
	FOR(i,0,sz-1) {
		if (v[i] == a) id1 = i;
		if (v[i] == b) id2 = i;
	}
	cout << abs(id1-id2);
}


Measured memory_bytes: 3384
#include<bits/stdc++.h>
using namespace std;
long long  n;
#define nn 65
long long  x[nn],y[nn],id[nn];
#define pii pair<long long ,long long >
#define mp make_pair
map<pii,long long > ump;long long  used[nn];long long  p,q;
long long  solve(){
	long long  ans=n;
	for(long long  i=1;i<=n;i++) {
		ans-=ump[mp(x[i]-p,y[i]-q)];
	}
	return ans;
	
}
signed main()
{
	cin>>n;for(long long  i=1;i<=n;i++) cin>>x[i]>>y[i],ump[mp(x[i],y[i])]=1;long long  ans=n;
	for(long long  i=1;i<=n;i++){
		for(long long  j=1;j<=n;j++) if(i!=j){
			p=x[j]-x[i],q=y[j]-y[i];
			ans=min(ans,solve());
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
  long long n,a[100010]={};
  cin>>n;

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

  long long sum=0,ans1=0,ans2=0;
  for(int i=0;i<n;++i){
    sum+=a[i];

    if(i%2==0){

        if(sum>0){
            continue;
        }else{
            ans1+=1-sum;
            sum=1;
        }

    }else{

        if(sum<0){
            continue;
        }else{
            ans1+=sum+1;
            sum=-1;
        }

    }

  }

  sum=0;
  for(int i=0;i<n;++i){
    sum+=a[i];

    if(i%2==0){

        if(sum<0){
            continue;
        }else{
            ans2+=sum+1;
            sum=-1;
        }

    }else{

        if(sum>0){
            continue;
        }else{
            ans2+=1-sum;
            sum=1;
        }

    }

  }

  cout << min(ans1,ans2) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;

	string x = a + b;
	int ix = atoi(x.c_str());

	for (int i = 1; i < 320; i++) {
		if (ix == i * i) {
			cout << "Yes" << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 888
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <limits>
#include <numeric>

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = 3.1415926;
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));
using vlll = vector<tuple<l,l,l>>;

const l MOD = e9 + 7; // end of template
const l MAX = 20;

void connect(l a, l n, vlll& edges) {
  if (n <= 3) {
    F(i, 0, n) edges.emplace_back(a, MAX, i);
    return;
  }
  if (n % 2) {
    edges.emplace_back(a, MAX, n - 1);
  }
  edges.emplace_back(a, a + 1, 0);
  edges.emplace_back(a, a + 1, n / 2);
  connect(a + 1, n / 2, edges);
}

void solve(istream& in, ostream& out) {
  l n; in >> n;
  vlll edges;
  connect(1, n, edges);
  out << MAX << ' ' << edges.size() << lf;
  for (auto e : edges)
    out << get<0>(e) << ' ' << get<1>(e) << ' ' << get<2>(e) << lf;
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


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

int main(){
    int N, WMAX, V[105], W[105], DP[105][10005]={0};
    cin >> N >> WMAX;

    for(int i=0;i<N;i++) cin >> V[i] >> W[i];
    for(int i=0;i<N;i++) {
        for(int w=0;w<=WMAX;w++) {
            if(w-W[i]>=0) DP[i+1][w] = max(DP[i][w], DP[i][w-W[i]]+V[i]);
            else DP[i+1][w] = DP[i][w];
        }
    }
    cout << DP[N][WMAX] << endl;
    return 0;
}


Measured memory_bytes: 7224
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ll arr[60];
ll n; 
bool isInvalid(ll k){
	ll sum_required_k = 0;
	for (ll i = 0; i < n; ++i)
	{
		sum_required_k += ceil((arr[i] - n + 1 + (ld)k)/((ld)n + 1));
	}
	// cout<<k<<" "<<sum_required_k<<endl;
	return sum_required_k > k;
}
int main(int argc, char const *argv[])
{
	cin>>n;
	ll t;
	for (ll i = 0; i < n; ++i)
	{
		cin>>t;
		arr[i] = t;
	}
	ll min_k = 0;
	ll low = min_k, high = 1e18;
	while(high - low > 1){
		// cout<<low<<" "<<high<<".."<<endl;
		ll mid = (low + high)/2;
		if(isInvalid(mid)){
			// cout<<"right\n";
			low = mid;
		}
		else{
			// cout<<"left\n";
			high = mid;
		}
	}
	ll mini = high;
	for (ll i = max(low - 10000, (ll)0); i <= high; ++i)
	{
		// cout<<i<<" "<<isInvalid(i)<<endl;
		if(isInvalid(i) == false){
			mini = i;
			break;
		}
	}
	cout<<mini<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
ll mod=1e9+7;
int a[300];
ll dp[2][2][90001];
void add(ll &x,ll y){
	x+=y;
	x%=mod;
}
ll ex(ll x,ll p){
	ll a=1;
	while(p){
		if(p%2) a=a*x%mod;
		x=x*x%mod;
		p/=2;
	}
	return a;
}
int main(){
	int d,s;
	cin>>d;
	rep(i,d) cin>>a[i];
	cin>>s;
	dp[0][0][0]=1;
	rep(i,d){
		rep(j,2) rep(k,s+1) dp[1-i%2][j][k]=0;
		rep(j,2) rep(k,s+1) if(dp[i%2][j][k]){
			add(dp[1-i%2][j][k],dp[i%2][j][k]);
			add(dp[1-i%2][1-j][k+a[i]],dp[i%2][j][k]);
		}
	}
	ll ans=0;
	rep(i,s){
		add(ans,ex(s-i,d)*(dp[d%2][0][i]-dp[d%2][1][i]));
	}
	cout<<(ans+mod)%mod<<endl;
}

Measured memory_bytes: 3968
import java.util.*;

public class Main {
    static int N;
    static int[][]dp = new int[100000][3];
    static int[][]plans = new int[100000][3];
    static int res;
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        for(int i = 0 ; i < N ; ++i){
            for(int j = 0 ; j < 3 ; ++j){
                plans[i][j] = in.nextInt();
            }
        }
        solve();
        System.out.println(res);
    }

    private static void solve() {
        dp[0] = plans[0];  
        for(int i = 1 ; i < N ; ++i){
            for(int j = 0 ; j < 3 ; ++j){
                dp[i][j] = Math.max(dp[i-1][ (j+1) % 3] , dp[i-1][(j+2) % 3])+plans[i][j];
            }
        }
        for(int j = 0 ; j < 3 ; ++j){
            res = Math.max(res, dp[N-1][j]);
        }
    }
}

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

int main (){
    int N,K,Q = 0;
    cin >> N >> K >> Q;
    vector<int> A(Q,0);
    vector<int> P(N, K-Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> A[i];
        P[A[i]-1]++;
    }
    for (int i = 0; i < N;i++)
    {
        if(P[i] <= 0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D,E;
    cin >> A >> B;
    C = A + B;
    D = A - B;
    E = A * B;
   vector<int> answer(3);
   answer.at(0) = C;
   answer.at(1) = D;
   answer.at(2) = E;
   sort(answer.begin(), answer.end());
   cout << answer.at(2) << endl;
}

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

#define ll long long
#define db double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ino freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

#define fr(i,n) for(i=0;i<n;i++)
#define frs(i,a,n) for(i=a;i<n;i++)
#define frv(i,n) for(i=n-1;i>=0;i--)

#define ne cout<<"\n";
#define cas(i) cout<<"Case #"<<i<<": "

#define vi vector <int>
#define vpi vector <pair <int,int> >
#define vpin(v,a,b) v.push_back(make_pair(a,b))
#define vsort(v) sort(v.begin(),v.end());
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))

#define todegree(rad) rad*(180.0/pi)
#define isnttriangle(a,b,c) (a+b<c||a+c<b||b+c<a)
#define pi acos(-1)
#define siz 100019

int cn[6]={0};

int main()
{
    int i,N;
    string s;
    cin>>N;
    while(N--)
    {
        cin>>s;

        if(s[0]=='A') cn[0]++;
        else if(s[0]=='W') cn[1]++;
        else if(s[0]=='T') cn[2]++;
        else if(s[0]=='R') cn[3]++;

    }

         cout<<"AC x "<<cn[0]<<"\n";
         cout<<"WA x "<<cn[1]<<"\n";
         cout<<"TLE x "<<cn[2]<<"\n";
         cout<<"RE x "<<cn[3]<<"\n";



    return 0;
}




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

#define mp make_pair
typedef pair<int,int>pii;
const int N = 2e5;
const int mod = 998244353;
int tree[4*N+100],dp[N+100];
pii xd[N+100];

void update(int v,int tl,int tr,int idx,int val)
{
	if(tl==tr){
		tree[v] = val;
		return;
	}
	int tm = (tl+tr)/2;
	if(tm>=idx){
		update(v*2,tl,tm,idx,val);
	}
	else{
		update(v*2+1,tm+1,tr,idx,val);
	}
	tree[v] = max(tree[v*2],tree[v*2+1]);
}
int get(int v,int tl,int tr,int l,int r)
{
	if(l>r){
		return 0;
	}
	if(tl==l&&tr==r){
		return tree[v];
	}
	int tm = (tl+tr)/2;
	return max(get(v*2,tl,tm,l,min(r,tm)),get(v*2+1,tm+1,tr,max(tm+1,l),r));
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&xd[i].first,&xd[i].second);
	}
	sort(xd+1,xd+n+1);
	dp[n+1] = 1;
	for(int i=n;i>0;i--){
		auto idx = lower_bound(xd+1,xd+n+1,mp(xd[i].first+xd[i].second,-1))-xd;
		idx--;
		int nxt;
		if(idx==i){
			nxt = i+1;
			update(1,1,n,i,i+1);
		}
		else{
			nxt = get(1,1,n,i+1,idx);
			update(1,1,n,i,nxt);
		}
		dp[i] = (dp[i+1]+dp[nxt])%mod;
	}
	printf("%d\n",dp[1]);
}


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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n;
  cin >> n;

  vt<int> dp(n + 1);
  dp[0] = 0;
  rep(i, 1, n + 1) {
    dp[i] = dp[i - 1] + 1;

    int six = 6;
    while(i >= six) {
      dp[i] = min(dp[i], dp[i - six] + 1);
      six *= 6;
    }

    int nine = 9;
    while(i >= nine) {
      dp[i] = min(dp[i], dp[i - nine] + 1);
      nine *= 9;
    }
  }
  cout << dp[n] << endl;
}

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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

ll medianDoubleInEven(vec<ll>& A){
    assert(A.size() % 2 == 0);
    return A.at(A.size()/2) + A.at(A.size()/2-1);
}

void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if(N % 2 == 0){
        ll smaller = medianDoubleInEven(A);
        ll bigger = medianDoubleInEven(B);
        cout << bigger - smaller + 1 << endl;
    }else{
        ll smaller = A.at(A.size()/2);
        ll bigger = B.at(B.size()/2);
        cout << bigger - smaller + 1 << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 6428
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;


void Main(){
    string s; cin >> s;
    string data = "ATCG";

    int ans = 0;
    int cnt = 0;
    
    rep(i, s.size()){
        bool ok = false;
        rep(j, 4) {
            if(s[i] == data[j]) ok = true;
        }
        if(ok) cnt++;
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3636
card = []
3.times do
	card << gets.split(" ").map(&:to_i)
end
signed = [[0,0,0],[0,0,0],[0,0,0]]
N = gets.to_i
nums = []
N.times do
	nums << gets.to_i
end

N.times do |t|
	for i in 0...3
		for j in 0...3
			if nums[t] == card[i][j]
				signed[i][j] = 1
			end
		end
	end
end

for i in 0...3
	if (signed[i][0] & signed[i][1] & signed[i][2]) == 1
		puts "Yes"
		exit
	end
end

for i in 0...3
	if (signed[0][i] & signed[1][i] & signed[2][i]) == 1
		puts "Yes"
		exit
	end
end

if (signed[0][0] & signed[1][1] & signed[2][2]) | (signed[0][2] & signed[1][1] & signed[2][0]) == 1
	puts "Yes"
	exit
end

puts "No"

Measured memory_bytes: 1788
mod = 10 ** 9 + 7

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

ctr = [0] * (n + 1)
ctr[-1] = 3

ret = 1
for x in a:
    ctr[x] += 1
    ret = ret * ctr[x - 1] % mod  # ctr[x - 1]: 同じ色の帽子の候補者数
    ctr[x - 1] -= 1

print(ret)


Measured memory_bytes: 14396
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize,
        m: usize,
        h: [usize; n],
        ab: [(Usize1, Usize1); m],
    };
    let mut ans = vec![true; n];

    for (a, b) in ab {
        if h[a] <= h[b] {
            ans[a] = false;
        }
        if h[a] >= h[b] {
            ans[b] = false;
        }
    }

    println!("{}", ans.into_iter().filter(|&x| x).count());
}



Measured memory_bytes: 6596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a,b,c;cin >>a>>b;
  if(a=='H'&&b=='H')c='H';
  if(a=='H'&&b=='D')c='D';
  if(a=='D'&&b=='H')c='D';
  if(a=='D'&&b=='D')c='H';
  cout << c<< endl;
}

Measured memory_bytes: 256
n = list(input())
for i in range(len(n)):
    if n[i] == "1":
        n[i] = "9"
    elif n[i] == "9":
        n[i] = "1"
    if i == 0:
        s = str(n[i])
    else:
        s = s+ str(n[i])
print(int(s))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <list>
using namespace std;

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

  for(int i=0; i<2; ++i){
    int over;
    if(i==2){
      over=-1;
    }else{
      over=i;
    }
    if(c[0][i] - c[0][over+1] != c[1][i] - c[1][over+1] || c[0][i] - c[0][over+1] != c[2][i] - c[2][over+1]){
      can=false;
    }
  }
  
  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3404
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

int main() 
{
    string s; cin >> s;
    vector<string> ans;
    int K; cin >> K;
    
    rep(i,s.size()) {
        string t = s.substr(i, s.size()-i); 
        rep(j, t.size()+1) {
            string sub = t.substr(0, j);
            if(sub.size() > K) { break; }
            if(sub != "") { 
                auto s = find(ans.begin(), ans.end(), sub);
                if(s == ans.end()) { ans.push_back(sub); }
            }
        }
    }

    sort(ans.begin(), ans.end());
    //for(auto v : ans) { cout << v << endl; }
    cout << ans[K-1] << endl;

    return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, k;
	cin >> n >> k;

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

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

	ll sum = 0;
	for(int i = 0; i < n - k; ++i)
	{
		sum += h[i];
	}
	cout << sum;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 1024
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,K;
  cin>>N>>K;
  double ans=0;
  for(int i=1;i<=N;i++){
    int X=i;
    double cnt=1.0/N;
    while(X<K){
      X*=2;
      cnt/=2;
    }
    ans+=cnt;
  }
  printf("%.12lf",ans);
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    if(abs(b-a) <= t*(v-w)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }



    return 0;
}


Measured memory_bytes: 3640
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n, x, t;
	cin>>n>>x>>t;
	cout<<(t*(n/x) + (n%x == 0? 0 : t))<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3588
S = list(input())
N = len(S)
ans = 'AC'
a = 0 #Cの数
for i in range(N):
    if i == 0:
        if S[i] != 'A':
            ans = 'WA'
            break
    elif i == 1:
        if S[i].islower() == False:
            ans = 'WA'
            break
    elif i == N - 1:
        if a != 1:
            ans = 'WA'
            break
        if S[i].islower() == False:
            ans = 'WA'
    else:
        if S[i] == 'C':
            a += 1
            if a > 1:
                ans = 'WA'
                break
        elif S[i].islower() == False:
            ans = 'WA'
            break
print(ans)
        
        

Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
  lli A,B=1,C=0,D=0,F=0;
  cin >> A;
  rep(i,1,A+1){
    B=B*i%mod;
  }
  Out(B);
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(), m = s.nextInt();
        Integer[] arr = new Integer[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
            sum += arr[i];
        }
        double div = (double) sum / (4*m);
        for(int i = 0; i < n && m > 0; i++) {
            if(arr[i] >= div) {
                m--;
            }
        }
        if(m <= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 25300
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 = [10**9]*(h+1)
dp[0] = 0
for i in range(h):
    for j in range(n):
        dp[min(i+a[j],h)] = min(dp[min(i+a[j],h)],dp[i]+b[j])
print(dp[h])

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

using namespace std;

int comb(int n, int r){
	int res = 1;
	for(int i=0; i<r; i++){
		res = res*(n-i)/(i+1);
	}
	return res;
}


int main(){
	
	int n;
	cin >> n ;
	
	vector<int> vec(n);
	for(int i=0; i<n; i++){
		cin >> vec.at(i);
	}
	std::sort(vec.begin(), vec.end());
	
	
	int resa = 0;
	int resb = 0;
	
	resa = n-1;
	
	int inst = vec.at(n-1);
	for(int i=0; i<n; i++){
		if(inst >= std::abs(vec.at(n-1)/2 - vec.at(i))) {
			inst=std::abs(vec.at(n-1)/2 - vec.at(i));
			if(i != resa)resb=i;
		}
	}
	
	cout << vec.at(resa) << " " <<  vec.at(resb) << endl;
	
}



Measured memory_bytes: 640
#include <stdio.h>
int ten(int x){
  int y = x % 10;
  if (y == 0) {
    return x;
  } else {
  return x + (10 - y);
  }
}

int main() {
  int A,B,C,D,E;
  scanf("%d %d %d %d %d",&A,&B,&C,&D,&E);
  int ans[5];
  ans[0] = ten(A) + ten(B) + ten(C) + ten(D) + E;
  ans[1] = ten(A) + ten(B) + ten(C) + ten(E) + D;
  ans[2] = ten(A) + ten(B) + ten(E) + ten(D) + C;
  ans[3] = ten(A) + ten(E) + ten(C) + ten(D) + B;
  ans[4] = ten(E) + ten(B) + ten(C) + ten(D) + A;
  int i;
  int answer = ans[0];
  for (i = 0;i < 5;++i) {
    if (answer > ans[i]) {
      answer = ans[i];
    }
  }
  printf("%d\n",answer );
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int A,B,C,K;
	cin >> A >> B >> C >> K;
	
	for(int i = 0; i < K; i++){
		if(C > B && B > A) break;
		else if(C <= B) C *= 2;
		else if(B <= A) B *= 2;
		else C *= 2;
	}
	
	if(B > A && C > B){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    X[i] = x-1;
  }
  
  vector<int> power(100);
  for (int i = 0; i < 100; i++) {
    int p = 0;
    for (int j = 0; j < N; j++) {
      p += (X[j] - i)*(X[j] - i);
    }
    power.at(i) = p;
  }
  
  sort(power.begin(), power.end());
  cout << power[0] << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Rcnt=0;
    int c[] = new int[N];
    int min=1;
    int max=0;
    int tmp=0;
    
    for(int i=0;i<N;i++){
      tmp=sc.nextInt();
      if(tmp>=3200){
        Rcnt++;
      }
      c[i]=tmp/400;
    }
    Arrays.sort(c);
    if(N==Rcnt){
      System.out.print(1);
      System.out.print(" ");
      System.out.println(Rcnt);
      return;
    }
    for(int i=0;i<N-Rcnt-1;i++){
      if(c[i]!=c[i+1]){
        min++;
      }
    }
    System.out.print(min);
    System.out.print(" ");
    System.out.println(min+Rcnt);
  }
  

  
}

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

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int n;
bool U, D, L, R;
long long uU = -0x3f3f3f3f, uD = 0x3f3f3f3f, uL = 0x3f3f3f3f, uR = -0x3f3f3f3f;
long long dU = -0x3f3f3f3f, dD = 0x3f3f3f3f, dL = 0x3f3f3f3f, dR = -0x3f3f3f3f;
long long lU = -0x3f3f3f3f, lD = 0x3f3f3f3f, lL = 0x3f3f3f3f, lR = -0x3f3f3f3f;
long long rU = -0x3f3f3f3f, rD = 0x3f3f3f3f, rL = 0x3f3f3f3f, rR = -0x3f3f3f3f;
vector<double>tt;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		long long x, y;
		char opt;
		cin >> x >> y >> opt;
		if (opt == 'U')
		{
			U = 1;
			uU = max(uU, y);
			uD = min(uD, y);
			uL = min(uL, x);
			uR = max(uR, x);
		}
		if (opt == 'D')
		{
			D = 1;
			dU = max(dU, y);
			dD = min(dD, y);
			dL = min(dL, x);
			dR = max(dR, x);
		}
		if (opt == 'L')
		{
			L = 1;
			lU = max(lU, y);
			lD = min(lD, y);
			lL = min(lL, x);
			lR = max(lR, x);
		}
		if (opt == 'R')
		{
			R = 1;
			rU = max(rU, y);
			rD = min(rD, y);
			rL = min(rL, x);
			rR = max(rR, x);
		}
	}
	tt.push_back(0);
	if (L&&R)
	{
		tt.push_back(0.5*abs(rR - lR));
		tt.push_back(0.5*abs(rR - lL));
		tt.push_back(0.5*abs(rL - lR));
		tt.push_back(0.5*abs(rL - lL));
	}
	if (U&&D)
	{
		tt.push_back(0.5*abs(uU - dU));
		tt.push_back(0.5*abs(uU - dD));
		tt.push_back(0.5*abs(uD - dU));
		tt.push_back(0.5*abs(uD - dD));
	}
	if (R && (U || D))
	{
		if (U)//rL,rR, (uR,uL)(dR,dL)
		{
			tt.push_back(abs(rL - uR));
			tt.push_back(abs(rL - uL));
			tt.push_back(abs(rR - uR));
			tt.push_back(abs(rR - uL));
		}
		if (D)
		{
			tt.push_back(abs(rL - dR));
			tt.push_back(abs(rL - dL));
			tt.push_back(abs(rR - dR));
			tt.push_back(abs(rR - dL));
		}
	}
	if (L && (U || D))
	{
		if (U)//rL,rR, (uR,uL)(dR,dL)
		{
			tt.push_back(abs(lL - uR));
			tt.push_back(abs(lL - uL));
			tt.push_back(abs(lR - uR));
			tt.push_back(abs(lR - uL));
		}
		if (D)
		{
			tt.push_back(abs(lL - dR));
			tt.push_back(abs(lL - dL));
			tt.push_back(abs(lR - dR));
			tt.push_back(abs(lR - dL));
		}
	}
	if (U && (L || R))
	{
		if (L)//uU,uD,(lU,lD)(rU,rD)
		{
			tt.push_back(abs(uU - lU));
			tt.push_back(abs(uU - lD));
			tt.push_back(abs(uD - lU));
			tt.push_back(abs(uD - lD));
		}
		if (R)
		{
			tt.push_back(abs(uU - rU));
			tt.push_back(abs(uU - rD));
			tt.push_back(abs(uD - rU));
			tt.push_back(abs(uD - rD));
		}
	}
	if (D && (L || R))
	{
		if (L)//dU,dD,(lU,lD)(rU,rD)
		{
			tt.push_back(abs(dU - lU));
			tt.push_back(abs(dU - lD));
			tt.push_back(abs(dD - lU));
			tt.push_back(abs(dD - lD));
		}
		if (R)
		{
			tt.push_back(abs(dU - rU));
			tt.push_back(abs(dU - rD));
			tt.push_back(abs(dD - rU));
			tt.push_back(abs(dD - rD));
		}
	}
	double ans = 0x3f3f3f3f3f3f3f3f;
	for (double x : tt)
	{
		double xmin = min({ lL - x, rL + x, (double)uL, (double)dL });
		double xmax = max({ lR - x,rR + x,(double)uR,(double)dR });
		double ymax = max({ uU + x,dU - x,(double)rU,(double)lU });
		double ymin = min({ uD + x,dD - x,(double)rD,(double)lD });
		ans = min(ans, (xmax - xmin)*(ymax - ymin));
	}
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long  int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

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

	cin >> N;
	int a, b, c;
	cin >> a >> b >> c;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	vector<int>w(N, 0);
	int ans = MOD;
	while (w[0] < 4) {
		int A, B, C;
		A = B = C = 0;
		int add = 0;
		for (int i = 0; i < N; i++) {
			if (w[i] == 0)A += v[i],add+=10;
			if (w[i] == 1)B += v[i],add+=10;
			if (w[i] == 2)C += v[i],add+=10;
		}
		if (A && B && C) {
			ans = min(ans, add + abs(A - a) + abs(B - b) + abs(C - c));
		}
		w[N - 1]++;
		for (int i = N - 1; i >= 1; i--) {
			if (w[i] == 4) {
				w[i] = 0;
				w[i - 1]++;
			}
		}
	}
	cout << ans-30 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			int k = stdIn.nextInt();
			if((n|k)==0){
				return;
			}
			int[] a = new int[n];
			for(int i=0;i<n;i++){
				a[i] = stdIn.nextInt();
			}
			int max = 0;
			
			for(int i=0;i<k;i++){
				max += a[i];
			}
			int s = max;
			for(int i=k;i<n;i++){
				s += a[i];
				s -= a[i-k];
//			TLE -------------------------
//			for(int i=0;i<=n-k;i++){
//				int s = 0;
//				for(int j=i;j<i+k;j++){
//					s+=a[j];
//				}
				max = Math.max(max, s);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int d;
	cin >> d;
	if(d==25) cout<<"Christmas";
	else if(d==24) cout <<"Christmas Eve";
	else if(d==23) cout <<"Christmas Eve Eve";
	else if(d==22) cout <<"Christmas Eve Eve Eve";
		
	 
	return 0;
}

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

int main()
{
    string s, t, r;

    cin >> s >> t >> r;

    cout << (char)(s[0] - 'a' + 'A') << (char)(t[0] - 'a' + 'A') << (char)(r[0] - 'a' + 'A') << endl;

    return (0);
}


Measured memory_bytes: 256