akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

struct edge {
  int src, dst;
  edge(int s, int d) :src(s), dst(d) { }
};
typedef vector<edge> edges;
typedef vector<edges> graph;

int C[100050][11], T[100050][11], P[100050];

int main() {
  int N = in();
  int M = in();
  graph G(N);

  for (int i = 0; i < M; ++i) {
    int a = in() - 1;
    int b = in() - 1;
    G[a].emplace_back(a, b);
    G[b].emplace_back(b, a);
  }

  int Q = in();
  for (int i = 1; i <= Q; ++i) {
    int v = in() - 1;
    int d = in();
    int c = in();
    C[v][d] = c;
    T[v][d] = i;
    P[i] = c;
  }

  for (int d = 10; d > 0; --d) {
    for (int u = 0; u < N; ++u) {
      for (const edge& e : G[u]) {
        const int v = e.dst;
        if (T[u][d] > T[v][d - 1]) {
          T[v][d - 1] = T[u][d];
          C[v][d - 1] = C[u][d];
        }
      }
    }
  }

  for (int u = 0; u < N; ++u) {
    int col = 0, mt = 0;
    for (int d = 0; d <= 10; ++d) {
      if (mt < T[u][d]) {
        mt = T[u][d];
        col = P[T[u][d]];
      }
    }
    printf("%d\n", col);
  }

  return 0;
}


Measured memory_bytes: 15860
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
typedef long long ll;
typedef long double ld;
const ll oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
//ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }
using namespace std;
 
void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}
 
int n,a[300005];
ll f[300005],g[300005],ans=-oo*oo,s[300005];
 
void bat1(){
    priority_queue <int> Q,P;
    ll sum=0;
    for (int i=1; i<=n; i++) P.push(-a[i]);
    f[n]=0;
    for (int i=n+1; i<=2*n; i++){
        Q.push(a[i]);
        Q.push(-P.top());
        sum+=a[i]-P.top();
        P.pop();
        sum-=Q.top();
        P.push(-Q.top());
        Q.pop();
        f[i]=sum;
    }
}
 
void bat2(){
    priority_queue <int> Q,P;
    ll sum=0;
    for (int i=3*n; i>=2*n+1; i--) P.push(a[i]);
    g[2*n]=0;
    for (int i=2*n-1; i>=n; i--){
        Q.push(-a[i+1]);
        Q.push(-P.top());
        sum+=a[i+1]+P.top();
        P.pop();
        sum-=-Q.top();
        P.push(-Q.top());
        Q.pop();
        g[i]=sum;
    }
}
 
int main() {
    //file_put();
 
    scanf("%d",&n);
    for (int i=1; i<=3*n; i++) {
        scanf("%d",&a[i]);
        s[i]=s[i-1]+a[i];
    }
    bat1();
    bat2();
    for (int i=n; i<=2*n; i++) ans=max(ans,s[i]-(s[3*n]-s[i])-f[i]+g[i]);
    cout<<ans<<endl;
    
    /*cout<<endl;
    for (int i=n; i<=2*n; i++) printf("f[%d]=%d \n",i,f[i]);
	for (int i=n; i<=2*n; i++) printf("g[%d]=%d \n",i,g[i]);*/
 
    return 0;
}


Measured memory_bytes: 9720
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {
  ll x; cin >> x;
  bool f = false;
  Rep(a, -1000, 1000){
    Rep(b, -1000, 1000){
      if(pow(a, 5)-pow(b, 5) == x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  ll a = 100;


  return 0;
}


Measured memory_bytes: 4100
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        Arrays.setAll(a, i -> scanner.nextInt());
        Arrays.setAll(b, i -> scanner.nextInt());

        int ans = 0;
        for (int i = 1 << 28; i > 0; i >>= 1) {
            int count = 0;
            for (int j = 0; j < n; j++) {
                a[j] &= 2 * i - 1;
                b[j] &= 2 * i - 1;
            }
            Arrays.sort(a);
            Arrays.sort(b);

            int p1 = 0, p2 = 0, p3 = 0;
            for (int j = n - 1; j >= 0; j--) {
                while (p1 < n && a[j] + b[p1] < i) p1++;
                while (p2 < n && a[j] + b[p2] < 2 * i) p2++;
                while (p3 < n && a[j] + b[p3] < 3 * i) p3++;
                count += n + p2 - p1 - p3;
                count &= 1;
            }
            if (count % 2 == 1) {
                ans |= i;
            }
        }
        System.out.println(ans);
    }
}

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

int main(){
  vector<tuple<string, int, int>>a;
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++){
    string S;
    int P;
    cin >> S >> P;
    a.push_back(make_tuple(S, -1*P, i));
  }
  sort(a.begin(), a.end());
  for (tuple<string, int, int> t:a){
    string s;
    int p, num;
    tie(s, p, num) = t;
    cout << num << endl;
  }
}

Measured memory_bytes: 256
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)




int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<long long> l1 = {a*c, a*d, b*c, b*d, 0};
    vector<long long> l2 = {a*c, a*d, b*c, b*d};
    if((a<0 && b>0) || (c<0 && d>0)){//0 possible
        cout << *max_element(l1.begin(), l1.end());
    }
    else{
        cout << *max_element(l2.begin(), l2.end());
    }
}

Measured memory_bytes: 3504
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long Int;
#define catlower(a, b) (lower_bound(a.begin(), a.end(), b) - a.begin())
#define catupper(a, b) (upper_bound(a.begin(), a.end(), b) - a.begin())
#define MOD 1000000007
Int n, a, b;
Int s[108000];
Int dp[108000];
Int dps[108000];
bool must[108000];
vector<Int> ng;
int main(){
  cin >> n >> a >> b;n++;
  if(a > b)swap(a, b);
  s[0] = -b;
  for(Int i = 1;i < n;i++)cin >> s[i];
  for(Int i = 1;i < n;i++){
    if(s[i] - s[i-1] < a){
      ng.push_back(i-1);
      ng.push_back(i);
      must[i] = true;
      must[i-1] = true;
    }
    if(i > 1 && s[i] - s[i-2] < a){
      cout << 0 << endl;
      return 0;
    }
  }
  ng.erase(unique(ng.begin(), ng.end()), ng.end());
  dps[0] = 1;
  dps[1] = -1;
  Int to = 0;
  vector<Int> nga = ng;
  nga.push_back(n);
  for(Int i = 0;i < n;i++){
    if(i)dps[i] += dps[i-1];
    dps[i] %= MOD;
    dp[i] = dps[i];
    //cout << i << " " << dp[i] << " " << dps[i] <<endl;
    while(to < n && s[to] - s[i] < b)to++;
    int r = nga[catupper(ng, i)];
    //cout << r << endl;
    if(r + 1 < n && s[r+1] - s[r] >= a){
      r = nga[catupper(ng, r)];
    }
    //    cout << to << " " << r << endl;
    if(to > r+2)continue;
    dps[to] += dp[i];dps[to] %= MOD;
    dps[r+2] -= dp[i];dps[r+2] %= MOD;
    
  } 
  dps[n] += dps[n-1];
  cout << dps[n] % MOD << endl;
  return 0;
}


Measured memory_bytes: 6000
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  map<char, char> m;
  m['A'] = 'T';
  m['T'] = 'A';
  m['C'] = 'G';
  m['G'] = 'C';
  
  char a;
  cin >> a;
  cout << m[a] << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    cout << p+q+r-max({p, q, r}) << "\n";
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N+1);
  vector<long long> B(N+1);
  rep(i, N+1){
    cin >> A[i];
  }
  rep(i, N){
    cin >> B[i];
  }
  // ここから本題
  // ansは倒したモンスターの数
  // yoryokuは勇者が次の街で余分に倒せるモンスターの数（余力）
  long long ans=0, yoryoku, toubatu, gamusyara;
  // 最初は例外処理
  toubatu = min(A[0], B[0]);
  ans += toubatu;
  yoryoku = B[0] - toubatu;
  // 最初と最後を除いたN-1回同じ処理をする
  rep(i, N-1){
    // 討伐するモンスター
    gamusyara = min(A[i+1], yoryoku);
    ans += gamusyara;
    A[i+1] -= gamusyara;
    toubatu = min(A[i+1], B[i+1]);
    ans += toubatu;
    // 毎回余力を更新していく
    yoryoku = B[i+1] - toubatu;
  }
  // 最後も例外処理
  gamusyara = min(A[N], yoryoku);
  ans += gamusyara;
  cout << ans << endl;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
using namespace std;
 
int main(){
    
    char s[100];
    int N,Rc,Bc;
    Rc = 0;
    Bc = 0;

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

    for(int i=0;i<N;i++){
        if(s[i]=='R'){
            Rc+=1;
        }else{
            Bc+=1;
        }
    }

    if(Rc>Bc){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

      int HP = sc.nextInt();//モンスターHP
      int N = sc.nextInt();//必殺技の種類
      int sum = 0;//必殺技の和
           
      //各必殺技を足す
      for(int i = 1; i<=N; i++){
        int hit = sc.nextInt();
        sum += hit;       
      }  
      //必殺技の和でモンスターを倒せるか
       System.out.print( sum>=HP ? "Yes":"No");
    }
}

Measured memory_bytes: 46968
// D - 3N Numbers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);++i)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

void pq_print(priority_queue<int> q){
	printf("[");
	while(!q.empty()){
		printf("%d,",q.top());q.pop();
	// }puts("]\n--");
	}puts("]");
}

void v_print(vector<ll> v){
	for(auto e:v) printf("%d,",e);puts("");
}

int main(){
	int N; cin>>N;
	vector<ll> A(3*N);
	rp(i, 3*N) cin>>A[i];

	// v_print(A);//

	vector<ll> F(3*N);
	F[0] = A[0];
	priority_queue<int> fque;
	fque.push(-A[0]);
	for(int i=1; i<3*N; ++i){
		fque.push(-A[i]);
		ll minA = 0;
		if(fque.size() > N){
			minA = -fque.top();
			fque.pop();
		}
		F[i] += F[i-1] + A[i] - minA;

		// pq_print(fque);//
		// v_print(F);//

	}

	reverse(all(A));

	// puts("--");//
	// v_print(A);//

	vector<ll> B(3*N);
	B[0] = A[0];
	priority_queue<int> bque;
	bque.push(A[0]);
	for(int i=1; i<3*N; ++i){
		bque.push(A[i]);
		ll minA = 0;
		if(bque.size() > N){
			minA = bque.top();
			bque.pop();
		}
		B[i] += B[i-1] + A[i] - minA;

		// pq_print(bque);//
		// v_print(B);//

	}

	B.pop_back();
	reverse(all(B));

	// v_print(F);//
	// v_print(B);//

	ll maxfb = LLONG_MIN;
	rp(i, N+1){
		int j = N - 1 + i;
		maxfb = max(maxfb, F[j]-B[j]);
	}
	cout<< maxfb <<endl;

}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  ll G = A[0];
  int maxa = A[0];
  REP(i, N){
    G = gcd(G, A[i]);
    maxa = max(maxa, A[i]);
  }
  if(G <= K && K <= maxa && K % G == 0){
    cout << "POSSIBLE" << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3696
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b<a)
		if(c<a)
		cout<<a*10+b+c;
		else
		cout<<c*10+a+b;
	else if(c<b)
		cout<<b*10+a+c;
	else
		cout<<c*10+a+b;
	return 0;
 } 

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();  // Scanner has functions to read ints, longs, strings, chars, etc.
        int k = in.nextInt();
        int answer = n-k;
        if (k==1)
        {
            answer = 0;
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 23632
#include <iostream>
#include <map>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long a[n];
    map<long long, long long> mp;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    long long sum = 0;
    for (auto itr=mp.begin(); itr!=mp.end(); itr++) {
        sum += (itr->second*(itr->second-1))/2;
    }
    for (int k=0; k<n; k++) {
        cout << sum - mp[a[k]] + 1 << endl;
    }
}

Measured memory_bytes: 13044
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define MAXV 100007
using namespace std;

int a[MAXV], b[MAXV];
vector<int> tree[MAXV];
int n;

vector<int> bfs(int s){
    vector<int> dist(n+1, -1);
    queue<int> q;
    q.push(s);
    dist[s] = 0;

    while(!q.empty()){
       int t = q.front(); q.pop();
       for(int i: tree[t]){
           if(dist[i] == -1){
               dist[i] = dist[t]+1;
               q.push(i);
           }
       } 
    }
    return dist;
}


int main(){
    cin >> n;
    int black, white;
    for(int i=1; i<n; i++){
        cin >> black >> white;
        tree[black].push_back(white);
        tree[white].push_back(black);
    }
    
    vector<int> d1 = bfs(1);
    vector<int> d2 = bfs(n);

    int l = 0, r = 0;
    for(int i=1; i<=n; i++){
        if(d1[i] <= d2[i]) l++;
        else r++;
    }

    if(l > r) cout << "Fennec" << endl;
    else if(r >= l) cout << "Snuke" << endl;

    return 0;
}

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

class Dice{
public:
    int Now[7], Will[7];
    
    Dice(int N[]){
        for(int i=1; i<7; i++){
            Now[i]=N[i];
            Will[i]=N[i];
        }
    }
    
    void move_S(){
        Will[1] = Now[5];
        Will[2] = Now[1];
        Will[6] = Now[2];
        Will[5] = Now[6];
        
        for(int i=1; i<7; i++){
            Now[i] = Will[i];
        }
    }
    
    void move_E(){
        Will[1] = Now[4];
        Will[3] = Now[1];
        Will[6] = Now[3];
        Will[4] = Now[6];
        
        for(int i=1; i<7; i++){
            Now[i] = Will[i];
        }
    }
    
    void move_N(){
        Will[1] = Now[2];
        Will[5] = Now[1];
        Will[6] = Now[5];
        Will[2] = Now[6];
        
        for(int i=1; i<7; i++){
            Now[i] = Will[i];
        }
    }
    
    void move_W(){

        Will[1] = Now[3];
        Will[4] = Now[1];
        Will[6] = Now[4];
        Will[3] = Now[6];
        
        for(int i=1; i<7; i++){
            Now[i] = Will[i];
        }
    }
    
    void top(){
        cout << Now[1] <<endl;
    }
};
//
//

int main(){
    int Face[7];
    for(int i=1; i<7; i++){
        cin >> Face[i];
    }
    string direct;
    cin >> direct;

    Dice dice(Face);

    for(int j=0; j<direct.length(); j++){
        if(direct[j] == 'S') dice.move_S();
        else if(direct[j] == 'E') dice.move_E();
        else if(direct[j] == 'N') dice.move_N();
        else if(direct[j] == 'W') dice.move_W();
    }

    dice.top();
    
return 0;
}


Measured memory_bytes: 3224
use std::io::stdin;

fn gcd(a: isize, b: isize) -> isize {
    if a == 0 {
        b
    } else {
        gcd(b % a, a)
    }
}

fn lcm(a: isize, b: isize) -> isize {
    a * b / gcd(a, b)
}

fn calc(l: isize, vals: &Vec<isize>) -> isize {
    let mut ret = 0;
    for (i, &v1) in vals.iter().enumerate() {
        ret += l / v1;
        for &v2 in vals.iter().skip(i + 1) {
            ret -= l / lcm(v1, v2);
        }
    }
    return ret;
}

fn main() {
    let mut x = String::new();
    stdin().read_line(&mut x).unwrap();
    let x: Vec<isize> = x.trim().split_whitespace().flat_map(str::parse).collect();
    let (a, b, c, d) = (x[0], x[1], x[2], x[3]);

    let vals = vec![c, d];
    println!("{}", (b - calc(b, &vals)) - (a - 1 - calc(a - 1, &vals)));
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

int main()
{
	int N;
	std::cin >> N;
	std::vector<double> As(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> As[i];
	}

	std::sort(As.begin(), As.end(), std::less<double>());

	double avg = (As[0] + As[1]) * 0.5;
	for (int i = 2; i < N; ++i) {
		avg = (avg + As[i]) * 0.5;
	}

	std::cout << avg << "\n";
	return 0;
}

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

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

  int p[n], q[n];

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

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

  int s[n];
  int p_pos, q_pos;

  for (int i=0; i<n; i++) s[i] = i+1;

  int pos = 0;

  do {
    if (equal(s, s+n, p)) p_pos = pos;
    if (equal(s, s+n, q)) q_pos = pos;
    pos += 1;
  } while (next_permutation(s, s+n));

  cout << abs(p_pos - q_pos) << endl;
}


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

const int INF = 1001001001;

template<typename T> inline void chmin(T &a, T b){
	if(a > b) a = b;
}

int main() {
	
	int n, m, l;
	cin >> n >> m >> l;
	vector<vector<int>> g(n, vector<int>(n, INF));
	rep(i, m){
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		g[a][b] = g[b][a] = c;
	}
	rep(i, n) g[i][i] = 0;
	rep(k, n) rep(i, n) rep(j, n){
		chmin(g[i][j], g[i][k] + g[k][j]);
	}
	
	vector<vector<int>> g2(n, vector<int>(n, INF));
	
	rep(i, n) rep(j, n){
		if(g[i][j] <= l) g2[i][j] = 1;
	}
	rep(k, n) rep(i, n) rep(j, n){
		chmin(g2[i][j], g2[i][k] + g2[k][j]);
	}
	
	int q;
	cin >> q;
	rep(i, q){
		int s, t;
		cin >> s >> t;
		s--;
		t--;
		int ans = g2[s][t] - 1;
		if(g2[s][t] == INF) ans = -1;
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

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

    while(true){
        int N,M;
        cin >> N >> M;
        if(N == 0) break;

        vector<int> Hs;
        Hs.push_back(0);
        for(int i=0;i<N;i++){
            int h;
            cin >> h;
            Hs.push_back(Hs.back()+h);
        }

        vector<int> Ws;
        Ws.push_back(0);
        for(int i=0;i<M;i++){
            int w;
            cin >> w;
            Ws.push_back(Ws.back()+w);
        }

        vector<int> HW(Hs.back()+Ws.back()+10);
        for(int i=0;i<Hs.size();i++){
            for(int j=0;j<Ws.size();j++){
                int h = Hs[i];
                int w = Ws[j];

                int hw = h + w;
                HW[hw]++;
            }
        }
        int cnt = 0;
        for(int i=0;i<HW.size();i++){
            if(HW[i] >= 2){
                cnt += HW[i]*(HW[i]-1)/2;
            }
        }
        cout << cnt << endl;

    }
    return 0;
}

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

int main(void){
  long long H;
  int N;
  cin>>H>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=A[i];
  }
  if(sum>=H) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define ten(n) ((int)1e##n)
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T> bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
ll ri(){ll l;cin>>l;return l;} string rs(){string s;cin>>s;return s;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
ostream&operator<<(ostream&o,const vb&t){forr(e,t)o<<"#."[e];return o;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";forr(e,t)o<<e<<",";o<<"}"<<endl;return o;}
#ifdef LOCAL
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return v;}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}
#else
#define out(args...)
#endif

void Main() {
  int n = ri();
  int m = ri();
  vvi E(n);
  rep(i, m) {
    int u = ri() - 1;
    int v = ri() - 1;
    E[u].push_back(v);
    E[v].push_back(u);
  }

  int a = 0;
  int b = E[a][0];

  vb used(n);
  used[a] = used[b] = 1;

  vi head, tail;
  head.emplace_back(a);
  tail.emplace_back(b);

  while (1) {
loop:
    forr(v, E[a]) {
      if (!used[v]) {
        head.emplace_back(v);
        a = v;
        used[v] = 1;
        goto loop;
      }
    }
    forr(v, E[b]) {
      if (!used[v]) {
        tail.emplace_back(v);
        b = v;
        used[v] = 1;
        goto loop;
      }
    }

    reverse(all(head));
    vi ans(head);
    forr(t, tail) ans.emplace_back(t);
    cout << sz(ans) << endl;
    rep(i, sz(ans)) {
      cout << ans[i] + 1;
      if (i+1 == sz(ans)) cout << endl;
      else cout << ' ';
    }
    return;
  }
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 7396
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin>>r;
    cout << 3*r*r<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

int64_t pow_Mod(int64_t x, int64_t n)
{
	int64_t answer = 1;
	int64_t now_pow = x;
	while(n > 0)
	{
		if((n & 1 )== 1)
		{
			answer *= now_pow;
			answer %= MODULO;
		}
		now_pow *= now_pow;
		now_pow %= MODULO;

		n >>= 1;
	}
	return answer;
}

signed main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int,int> p;
	vector<int> primes;
	bool ispr[1000] = {};
	REP(i, 2, 1000)
	{
		if(!ispr[i]){
			primes.push_back(i);
			for(int j = 2*i; j < 1000; j+=i)
			{
				ispr[j] = true;
			}
		}
	}

	int64_t ans = 1;
	n++;
	REP(i, 2, n)
	{
		for(auto t : primes)
		{

			if(i < t)
				break;

			int tmp = i;
			while(tmp % t == 0) {p[t]++;tmp /=t;};
		}
	}
	for(auto t : p)
	{
		/* cerr << t.first << ' ' << t.second << '\n'; */
		ans *= t.second + 1;
		ans %= MODULO;
	}

	cout << ans << '\n';


}



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

int main() {
    int N; cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) cin >> H[i];
    
    int res = 0;
    int current = 0;
    for (int i = 0; i < N; ++i) {
        if (H[i] >= current) ++res;
        if (current < H[i]) current = H[i];
    }
    cout << res << endl;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 998244353;
// now += mint(2).pow(s) - 1; こんな感じで、2のs乗を求められrう
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
mint dp[2010][2010];
int main()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> s(n), t(m);
	rep(i,n) cin >> s[i];
	rep(i,m) cin >> t[i];

	for(ll si = 0; si <= n; si++){
		for(ll ti = 0; ti <= m; ti++){
			if(ti == 0 || si == 0) {
				dp[si][ti] = 1;
				continue;
			}
			if(s[si-1] == t[ti-1]){
				dp[si][ti] = (dp[si-1][ti] + dp[si][ti-1]);
			} else {
				dp[si][ti] = (dp[si-1][ti] + dp[si][ti-1] - dp[si-1][ti-1]);
			}
		}
	}
	cout << dp[n][m] << endl;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int line[100001] = {};
int main() {
	int Q;
	cin >> Q;
	int d[100001] = {0};
	d[0] = 1;
	d[1] = 1;
	
	for (int i = 2; i <= 100000; i++) {
		if (d[i] == 0) {
			for (int j = i+i; j <= 100000; j = j+i) {
				d[j] = 1;
			}
		}
	}
	
	int ds[100001] = {0};
	for (int i = 1; i <= 100000; i = i+2) {
		if (d[i] == 0 && d[(i + 1) / 2] == 0) {
			ds[i] = 1;
		}
	}
	for (int i = 1; i <= 100000; i++) {
		line[i] = line[i - 1] + ds[i];
	}
	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		cout << line[r] - line[l - 1] << endl;
	}
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = 0;
        if(c<b){
            d=c; c=b; b=d;
        }
        if(b<a){
            d=b; b=a; a=d;
        }
        if(c<b){
            d=c; c=b; b=d;
        }
        System.out.println(a+" "+b+" "+c);
        sc.close();
    }
}


Measured memory_bytes: 26128
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  vector<tuple<complex<double>, double> > nodes;
  REP(i, 2) {
    double x, y, r = 0.0;
    cin >> x >> y;
    nodes.emplace_back(complex<double>(x, y), r);
  }
  int n;
  cin >> n;
  REP(i, n) {
    double x, y, r;
    cin >> x >> y >> r;
    nodes.emplace_back(complex<double>(x, y), r);
  }
  map<int, set<tuple<int, double> >> e;
  REP(i, n+2) {
    complex<double> ci;
    double ri;
    tie(ci, ri) = nodes[i];
    REP(j, n+2) {
      complex<double> cj;
      double rj;
      tie(cj, rj) = nodes[j];
      e[i].emplace(j, max(0.0, abs(ci-cj) - (ri+rj)));
    }
  }
  set<int> already;
  priority_queue<tuple<double, int>> pq; // negc, node
  pq.emplace(0.0, 0);
  while(!pq.empty()) {
    double negc;
    int node;
    tie(negc, node) = pq.top();
    pq.pop();
    if(!already.insert(node).second) continue;
    if(node == 1) {
      cout << fixed << setprecision(9);
      cout << -negc << endl;
      return 0;
    }
    for(auto t : e[node]) {
      int to;
      double ec;
      tie(to, ec) = t;
      pq.emplace(negc - ec, to);
    }
  }
  return 0;
}


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

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

        int n = Integer.parseInt(br.readLine());

        Deque<Integer> list = new ArrayDeque<>();

        for (int i=0; i<n; i++) {
            String str = br.readLine();

            if (str.startsWith("insert")) {
                list.addFirst(Integer.parseInt(str.substring(str.indexOf(" ")+1)));
            }else if (str.equals("deleteFirst")) {
                list.pollFirst();
            }else if (str.equals("deleteLast")){
                list.pollLast();
            }else {
                list.remove((Integer)Integer.parseInt(str.substring(str.indexOf(" ")+1)));
            }
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringBuilder sb = new StringBuilder();
        sb.append(list.poll());
        for (Integer s : list) {
            sb.append(" ");
            sb.append(s);
        }
        bw.write(sb.toString());
        bw.newLine();
        bw.close();

        br.close();
    }
}



Measured memory_bytes: 125484
#include<iostream>
#include<string>

int main(){
	std::string str;
	std::cin>>str;
	for(int i=0;i<str.size();i++){
		int a=static_cast<int>(str[i]);
		a-=3;
		if(a<65)a+=26;
		str[i]=static_cast<char>(a);
		std::cout<<str[i];
	}
	std::cout<<std::endl;
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  int N;
  cin >> N;
  ll a[1010]={0},mod=1000000007;

  for(int i=1;i<=N;i++){
    int p=i;
      for(int j=2;j<=N;j++){
        while(p%j==0){
          p/=j;
          a[j]++;
        }
      }
  }
  ll ans=1;
  for(int i=1;i<=N;i++){
    ans=(a[i]+1)*ans%mod;
  }
  cout << ans;
}

Measured memory_bytes: 256
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  A = readint()

  sort!(A, rev=true)
  #print(A)

  if N == 2
    println(A[1])
    return 
  end

  s = A[1]
  counter = 0
  p = 2
  for i in 3:N
    s += A[p]
    counter += 1
    if counter == 2
      p += 1
      counter = 0
    end
  end
  println(s) 

end

main()

Measured memory_bytes: 209760
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
using namespace std;



int main() {
	string S;
	cin >> S;
	int Y = 0;
	for (int i = 0; i < S.size()-1; i++) {
		if (S[i] != S[i + 1])Y++;
	}

	cout << Y << endl;


}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(" ").map(String::toInt)
    val mList = mutableListOf<Int>()
    for (i in (0..(n - 1))) {
        mList.add(readLine()!!.toInt())
    }
    val count = mList.size + (x - mList.sum()) / mList.min()!!

    println(count)
}

Measured memory_bytes: 36016
#include <iostream>

using namespace std;

int main() {
    long long n;
    scanf("%lld", &n);
    long long ans = 0;
    for (long long i = 0; i != n; i++)ans += (i + 1) * (n - i);
    for (int i = 0; i != n - 1; i++) {
        long long a, b;
        scanf("%lld %lld", &a, &b);
        ans -= min(a, b) * (n - max(b, a) + 1);
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 3808
/*||>>>> Praveen Ojha <<<<>>>> 01 June 2019 <<<<>>>> 17:23:37 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf 1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n;
	cin>>n;
	cout<<(n-2)*180<<"\n";
return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
ans = 0
mod = 1000000007
p = 1
for i in range(1, n):
  p *= i
  p %= mod
for i in range(n-1):
  ans += (x[n-1]-x[i])*pow(i+1, mod-2, mod)
ans *= p
ans %= 1000000007
print(ans)

Measured memory_bytes: 14224
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    while(true){
        int n, p;
        cin >> n >> p;
        if(n == 0 && p == 0){
            break;
        }
        vector<int> c(n, 0);
        int i = 0, ans, last;
        while(true){
            i = i % n;
            if(p > 0){
                p--;
                c[i]++;
                last = i;
            }else if(c[i] > 0){
                if(i == last){
                    ans = i;
                    break;
                }
                p = c[i];
                c[i] = 0;
            }
            i++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int i1 = sc.nextInt();

        int i2 = sc.nextInt();

        if ((i1 * i2) % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 23764
import os
import math
import itertools
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

def get_int_list():
    return list(map(int, input().split()))

while(True):
    try:
        s = input()
        if ('N' in s) == ('S' in s) and ('W' in s) == ('E' in s):
            print("Yes")
        else:
            print("No")
    except EOFError:
        exit()


Measured memory_bytes: 3064
import sys
from collections import defaultdict
from bisect import bisect_right as bi_r

U = 5 * 10 ** 6
def sieve_of_eratosthenes(n=U):
  if n == 1: return set()
  sieve = set(range(2, n + 1))
  for p in sieve_of_eratosthenes(int(n ** 0.5)):
    sieve -= set(range(p * 2, n + 1, p))
  return sieve

prime_numbers = sieve_of_eratosthenes(10 ** 3)
soted_prime_numbers = sorted(prime_numbers)

def is_prime(n): return n in prime_numbers

def prime_factorize(n):
  res = defaultdict(int)
  if n < 2: return res
  for p in soted_prime_numbers[:bi_r(soted_prime_numbers, int(n ** 0.5))]:
    while n % p == 0:
      res[p] += 1
      n //= p
    if n == 1:
      return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = defaultdict(int)
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items():
      res[p] += c
  return res

MOD = 10 ** 9 + 7

n = int(sys.stdin.readline().rstrip())

def main():
    res = 1
    for c in prime_factorize_factorial(n).values():
        res *= c + 1; res %= MOD
    print(res)

if __name__ ==  '__main__':
    main()

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

typedef long long LL;
typedef long double LD;
typedef string ST;


void func()
{
  ST S;
  cin >> S;
  LL N = S.length(); 
  LL cnt0 = 0;
  for (LL i = 0; i < N; ++i) {
    if (S[i] == '0') {
      cnt0++;
    }
  }
  LL cnt1 = N - cnt0;
  cout << min(cnt0*2, cnt1*2);

}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 512
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
using namespace std; 

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }
const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
const int mod=1000*1000*1000+7;  

// ----------------------------------------------------------------------------	-------------- 

void solve(){
	int n,k;  cin>>n>>k; 
	int mk=0, mk_2=0; 
	for(int i=1;i<=n;i++){
		if(i%k==0) mk++; 
		else if(i%k==k/2) mk_2++; 
	}
	ll ans=0; 
	ans+=1ll*mk*mk*mk; 
	if(k%2==0){
		ans+=1ll*mk_2*mk_2*mk_2; 
	}
	cout<<ans<<endl; 
}


int main(){
	// clock_t beg=clock(); 
	fast_io; 
    cout << fixed << setprecision(13); 
	solve(); 	
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<queue>
using namespace std;
 

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m, n;
	cin >> n>> m;
	long long a;
	priority_queue<long long> q;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		q.push(a);
	}
	for (int i = 0; i < m; ++i) {
		a = q.top(); q.pop();
		q.push(a / 2);
	}
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += q.top(); q.pop();
	}
	cout << ans << endl;
}


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

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

    string s;
    cin >> s;
    
    int n = s.size();
    int cnt = 0;
    rep(i, n){
        if(s[i] == 'o') ++cnt;
    }

    if(15-n + cnt >= 8) puts("YES");
    else puts("NO");

    return 0;
}

Measured memory_bytes: 256
lst = list(map(int, input().split()))

N = lst[0]
L = lst[1]

apple_flavours = []

for i in range(1, N+1):
    apple_flavours.append(L+i-1)


abs_apple_flavours = []

for apple in apple_flavours:
    abs_apple_flavours.append(abs(apple))

min_val = min(abs_apple_flavours)

index = abs_apple_flavours.index(min_val)

total_flavour = 0

for apple in apple_flavours:
    total_flavour += apple

print(total_flavour - apple_flavours[index])

Measured memory_bytes: 9128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

double prob[3240], p;
int n;
int main(){
  prob[0] = 1;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> p;
    for(int j = n;j >= 0;j--){
      prob[j] = prob[j] * (1-p);
      if(j)prob[j] += prob[j-1] * p;
    }
  }
  double res;
  for(int i = 0;i <= n;i++){
    if(i > n-i)res += prob[i];
  }
  printf("%.10lf\n", res);
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

 

public class Main
{
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) a[i] = nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }

        public String nextline() {
            return null;
        }
    }
 
    public static void main(String[] args) 
    {
        FastScanner sc=new FastScanner();
        String s=sc.next(),t=sc.next();
        String mah=s+t;
        int a=Integer.parseInt(mah);
        int b= (int) Math.sqrt(a);
        if(b*b==a) System.out.println("Yes");
        else System.out.println("No");
    }

    
}

Measured memory_bytes: 37140
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define For(i,k,n) for(i=k;i<=n;i++)


const  ll modo=1e9+7;

ll dp[100005][13]={0};




int main()
{
    faf;
    int n;
    cin>>n;
    int ar[n+1];
    int dp[n+1]={0};
    int i;
    for(i=1;i<=n;i++)cin>>ar[i];
    int j;
    int ss=0;
    int aa=0;
    //cout<<"SDsd";
    for(i=n;i>=1;i--)
    {
        ss=0;
        for(j=i;j<=n;j+=i)
        {
            ss+=dp[j];
        }
        if((ss%2)!=(ar[i]%2))
        {
            aa++;
            dp[i]=1;
        }
        //cout<<i<<endl;
    }
    cout<<aa<<endl;
    for(i=1;i<=n;i++)
    {
        if(dp[i])cout<<i<<" ";
    }


}

Measured memory_bytes: 2560