akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};

ll MOD = 998244353;


int main() {
    int r,g,b,n; cin >> r >> g >> b >> n;
    int cnt = 0;
    for(int i = 0; i <= n / r;i++){
        for(int j = 0; j <= n / g; j++){
            if((n - i * r -j * g) >=0&&(n - i * r -j * g) % b == 0) cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main(){
    int N, M, X; cin >> N >> M >> X;
    vector<int> A(N+1,0);
    for (int i=0;i<M;i++){
        int a_i; cin >> a_i;
        A[a_i]++;
    }
    int cost_plus=0;
    int position_plus=X;
    while (position_plus<N){
        position_plus++;
        cost_plus += A[position_plus];
    }
    
    int cost_minus=0;
    int position_minus=X;
    while (position_minus>0){
        position_minus--;
        cost_minus += A[position_minus];
    }        


    cout << min(cost_plus,cost_minus) << endl;


    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n, x; cin >> n >> x;
    vint l(n);
    rep(i, n) cin >> l[i];
    int xx = 0;
    rep(i, n) {
        xx += l[i];
        if(x < xx) {
            cout << i+1 << endl;
            exit(0);
        }
    }
    cout << n+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> height ;
vector<ll> memo;
 ll n , k ;
int solve(int i){
    if(i<=0)
        return 0;

    if(memo[i]!=-1)
        return memo[i];
    int res = solve(i-1)+abs(height[i]-height[i-1]);
    for(int j=2;j<=k&&(i-j)>=0;j++){
        int left = solve(i-j)+abs(height[i]-height[i-j]);
        res = min(left,res);
    }
    memo[i]=res;
    return memo[i];
}
int main()
{
    cin >> n >> k ;
    for(int i=0;i<n;i++){
        ll a ;
        cin >> a ;
        height.push_back(a);
        memo.push_back(-1);
    }
    solve(n-1);
    cout << memo.back();
    return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int cnt = 0;
    For(i, 0, N / R) For(j, 0, N / G) {
        int val = R * i + G * j;
        if (N - val >= 0 and (N - val) % B == 0) cnt++;
    }
    print(cnt);

    return 0;
}


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

int main()
{
  int N, A;
  cin >> N >> A;
  int R = N % 500;

  if (R <= A)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import Control.Monad
import Text.Printf
import Control.Applicative
import Data.List as L

main :: IO()
main = do
  _ <- getLine
  a <- map read . words <$> getLine
  let f n = n * (n - 1) `div` 2
  printf "%d" $ sum.map (f.length) $ group.sort $ scanl (+) 0 a


Measured memory_bytes: 114044
/*input
2 3
1 2 3
0 1 1
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long

int a[501][501];
int i,j;
int sum = 0;

signed main(){
  int n,m;
  cin >> n >> m;
  for(i = 0;i < n;i++){
      for(j = 0;j < m;j++){
      	cin >> a[i][j];
      	sum += a[i][j]; 
      }
  }  
  vector< pair<int,int> > to,from;
  for(i = 0;i < n;i++){
  	for(j = 0;j < m;j++){
  		if(a[i][j]%2){
  			if(j < m-1 ){
  				a[i][j]--;
  				a[i][j+1]++;
  				to.push_back(make_pair(i+1,j+1));
  				from.push_back(make_pair(i+1,j+2));
  			}
  			else if(i < n-1){
  				a[i][j]--;
  				a[i+1][j]++;
  				to.push_back(make_pair(i+1,j+1));
  				from.push_back(make_pair(i+2,j+1));
  			}
  		}
  	}
  }
  cout << to.size() << endl;
  for(i = 0;i < to.size();i++){
  	cout << to[i].first << " " << to[i].second << " " << from[i].first << " " << from[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 8164
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
  int n,x[101],y[101];
  int i;
  double dis1=0,dis2=0,dis3=0,disi=0,max=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&x[i]);
  for(i=0;i<n;i++)
    scanf("%d",&y[i]);
  for(i=0;i<n;i++){
    dis1 += abs(x[i]-y[i]);
    dis2 += pow((double)x[i]-y[i],2.0);
    dis3 += pow((double)abs(x[i]-y[i]),3.0);
    disi = abs(x[i]-y[i]);
    if(max<disi)
      max = disi;
  }

  printf("%.6f\n",dis1);
  printf("%.6f\n",sqrt(dis2));
  printf("%.6f\n",pow(dis3,1.0/3.0));
  printf("%.6f\n",max);

  return 0;
}

Measured memory_bytes: 1980
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int co[110] = { 0 };
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			co[a - 1]++;
		}
	}
	int ans = 0;
	for (int k = 0; k < n; k++) {
		if (co[k] == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{
    int n, m;
    int[] x, y, z;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        m = int.Parse(input[1]);

        x = new int[m];
        y = new int[m];
        z = new int[m];

        for (int i=0; i<m; i++)
        {
            input = Console.ReadLine().Split(' ');
            x[i] = int.Parse(input[0]) - 1;
            y[i] = int.Parse(input[1]) - 1;
            z[i] = int.Parse(input[2]);
        }

        var uf = new UnionFind(n);
        for(int i=0; i<m; i++)
        {
            uf.Union(x[i], y[i]);
        }
        int[] t = new int[n];
        int u = 0;
        int ans = 0;
        for(int i=0; i<n; i++)
        {
            u = uf.Find(i);
            if(t[u] == 0)
            {
                t[u]++;
                ans++;
            }
        }
        Console.WriteLine(ans);

    }


    

    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}

// UnionFind(int n)
// n: the number of nodes
// int Find(int node): return the parent
// void Union(int node, int node)

public class UnionFind
{
    int[] par;
    int n;
    public UnionFind(int t)
    {
        n = t;
        par = new int[n];
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
        }
    }

    public int Find(int x)
    {
        if (par[x] == x) return x;
        else
        {
            par[x] = Find(par[x]);
            return par[x];
        }
    }

    public void Union(int x, int y)
    {
        x = Find(x);
        y = Find(y);
        if (x == y) return;
        else par[x] = y;
    }
}


Measured memory_bytes: 16960
N, M = (int(x) for x in input().split())
B = [False]*N
cnt = [0]*N
ans = 0
pena = 0
for i in range(M):
  p, S = (str(x) for x in input().split())
  p = int(p)
  if S=="AC" and B[p-1]==False:
    B[p-1]=True
    ans+=1
  elif S=="WA" and B[p-1]==False:
    cnt[p-1]+=1
for i in range(N):
  if B[i]==True:
    pena+=cnt[i]
print(ans, end=" ")
print(pena)

Measured memory_bytes: 10456
import java.util.*
fun main(args: Array<String>) {
    val s = readLine()!!
    val K = readLine()!!.toInt()

    val topK = LinkedList<String>()
    (0 until s.length).forEach { i ->
        (i + 1 .. Math.min(s.length, i + 1 + K)).forEach { j ->
            val sub = s.substring(i, j)
            if (!topK.contains(sub)) {
                topK.add(s.substring(i, j))
            }
            topK.sort()
            if (topK.size > K) {
                topK.removeLast()
            }
        }
    }
    println(topK.get(K - 1))
}


Measured memory_bytes: 38728
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

bool compare(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> abs(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        abs[i] = make_pair(a, b);
    }

    sort(abs.begin(), abs.end(), compare);
    int time = 0;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
        time += abs[i].first;
        if (abs[i].second < time) ok = false;
    }
    
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
map<char,int> m;
void solve(){  
   m.insert({'A',10});
   m.insert({'B',11});
   m.insert({'C',12});
   m.insert({'D',13});
   m.insert({'E',14});
   m.insert({'F',15});
   char x,y;
   cin>>x>>y;
   if(m[x]<m[y])cout<<"<";
   else if(m[x]==m[y])cout<<"=";
   else cout<<">";
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

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

    vector<int> L(n+1), R(n+1);
    L[0] = 0;
    for (int i = 0; i < n; i++) {
        if (L[i] == 0) L[i + 1] = A[i];
        else
            L[i + 1] = __gcd(L[i], A[i]);
    }

    R[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (R[i+1] == 0) R[i] = A[i];
        else
            R[i] = __gcd(R[i+1], A[i]);
    }

    int mx = 0;
    for (int i = 0; i < n; i++) {
        if (R[i+1] == 0) mx = max(mx, L[i]);
        else if (L[i] == 0) mx = max(mx, R[i+1]);
        else
            mx = max(mx, __gcd(R[i+1], L[i]));
    }
    cout << mx << endl;


    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <deque>
#include <utility>

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

constexpr double EPS = 1e-7;

signed main() {

	while (true) {
		int n;
		std::cin >> n;
		if (n == 0) break;

		std::vector<double> x(n), y(n);
		REP(i, n) std::cin >> x[i] >> y[i];

		int ans = 1;

		REP(i, n) FOR(j, i + 1, n) {
			double dist = std::hypot(x[i] - x[j], y[i] - y[j]);
			if (dist > 2 + EPS) continue;

			// iとjの中点m
			double mx = (x[i] + x[j]) / 2;
			double my = (y[i] + y[j]) / 2;

			// 線分ijから中心への距離
			double r = std::sqrt(1 - (dist / 2) * (dist / 2));

			// 中心c
			for (int sign = -1; sign <= 1; sign += 2) {
				// 移動のベクトルv
				double vx = sign * r * (y[j] - y[i]) / dist;
				double vy = sign * r * -(x[j] - x[i]) / dist;

				double cx = mx + vx;
				double cy = my + vy;

				int cnt = 0;
				REP(k, n) {
					if (std::hypot(cx - x[k], cy - y[k]) < 1 + EPS) ++cnt;
				}
				ans = std::max(ans, cnt);
			}
		}
		std::cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18



int main(){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    A--;B--;C--;D--;
    string S;
    cin >> S;
    if(C < D){
        bool ok = true;
        repr(i,A,D){
            if(S[i+1] == '#' && S[i] == '#') ok = false;
        }
        if(ok) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        bool ok = false;
        repr(i,B-1,D){
            if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.') ok = true;
        }
        repr(i,A,C){
            if(S[i+1] == '#' && S[i] == '#') ok = false;
        }
        if(ok) cout << "Yes" << endl;
        else cout << "No" << endl;

    }
}
  


  


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main (void) {
  int G[101][101] = {0}, sum[101] = {0}, rank[101] = {0};
  int a, b, c, d;
  int n;

  cin >> n;

  for(int i = 1; i <= n*(n-1)/2; i++) {
    cin >> a >> b >> c >> d;
    if(c < d) {
      G[a][b] = 0; G[b][a] = 3;
    } else if(c == d) {
      G[a][b] = 1; G[b][a] = 1;
    } else {
      G[a][b] = 3; G[b][a] = 0;
    }
  }

  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      if (i == j) continue;
      sum[i] += G[i][j];
    }
  }

  //cout << sum[0] << " " << sum[1] << " " << sum[2] << " " << sum[3] << endl;

  int daburi = 1;

  // rankの出し方は俺が考えたアルゴリズムじゃない
  for(int i = 1; i <= n; i++) {
    rank[i] = 1;
    for(int j = 1; j <= n; j++) {
      if(sum[i] < sum[j]) rank[i]++;
    }
  }

  for(int i = 1; i <= n; i++) {
    cout << rank[i] << endl;
  }

  return 0;
}

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

#define MIN(a,b) (a)>(b)?(b):(a)

using namespace std;

int main() {
	int N, K, Q;
	vector<int> A;
	cin >> N >> K >> Q;
	vector<int> point(N,0);

	for (int i = 0, a; i < Q; i++) {
		cin >> a;
		point[a-1]++;
	}
	for (auto& i : point) {
		if (K-Q+i<=0) {
			cout << "No";
		}
		else {
			cout << "Yes";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <functional>

using namespace std;

#define PQ priority_queue
#define VT vector
#define MP make_pair
#define FOR(i, b, e) for(int i=b;i<e;i++)
#define CaseRead int _TT; scanf("%d", &_TT); for (int kase = 1; kase <= _TT; kase++)

typedef long long ll;

char ma[25][25];
int n, m;
vector<string> v;

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

void solve(int x, int y) {
//    printf("solve(%d, %d)\n", x, y);
    for (int i = 0; i < 8; i++) {
        string s = "";
        s += ma[x][y];
        int nx, ny;
        nx = (x + n + dx[i]) % n;
        ny = (y + m + dy[i]) % m;

        while (nx != x || ny != y) {
            s += ma[nx][ny];
            nx = (nx + n + dx[i]) % n;
            ny = (ny + m + dy[i]) % m;
        }
        v.push_back(s);
//        cout << s << endl;
    }
}



int main()
{
    while (1) {
        scanf("%d%d", &n, &m);
        v.clear();
        if (n == 0 && m == 0) break;
        for (int i = 0; i < n; i++) scanf("%s", ma[i]);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++) solve(i, j);
        sort(v.begin(), v.end());
        int len = 0;
        string ans;

        for (int i = 1; i < v.size(); i++) {
//            cout << "compare " << v[i] << " and " << v[i-1] << endl;
            int len1 = 0;
            for (int j = 0; j < min(v[i].length(), v[i-1].length()) && v[i][j] == v[i-1][j]; j++) {
                len1++;
            }
            if (len1 > len) {
                len = len1;
                ans = v[i].substr(0, len1);
            }
        }
        if (ans.length() < 2) cout << 0 << endl;
        else cout << ans << endl;
            
    }

    return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<vector<vector<int>>> bfr(5, vector<vector<int>>(4, vector<int>(11, 0)));
	
	int a, b, c,v;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c >> v;
		bfr[a][b][c] += v;
	}

	for (int i = 1; i <= 4; i++) {
		for (int j = 1; j <= 3; j++) {
			for (int k = 1; k <= 10; k++) {
				cout << " " << bfr[i][j][k];
			}
			cout << endl;
		}
		if (i != 4) {
			cout << "####################" << endl;
		}
	}
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

string s;

void solve()
{
	const int N = s.length();
	int ans = 0;
	for(int i=1; i<N;++i) if(s[i]!=s[i-1]) ans++;
	cout << ans << endl;
}

int main()
{
	cin >> s;
	solve();
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a,s = 0;
  cin >> n;
  a=n;
  while (a!=0) {
    s += a-a/10*10;
    a /= 10;
  }
  if (n%s==0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

long long A, B, C, D;
long long ans;

int main() {
	cin >> A >> B >> C >> D;
	long long x = C * D;
	if (C < D) {
		long long tmp = C;
		C = D;
		D = tmp;
	}
	long long r = C % D;
	long long c_tmp = C;
	long long d_tmp = D;
	while (r != 0) {
		c_tmp = d_tmp;
		d_tmp = r;
		r = c_tmp % d_tmp;
	}
	long long LCM = x / d_tmp;


	ans = B - A + 1;
	ans -= (B / C);
	ans -= (B / D);
	ans += (B / LCM);
	ans += ((A - 1) / C);
	ans += ((A - 1) / D);
	ans -= ((A - 1) / LCM);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{long long n=0,c=0;
    cin>>n;
    long long a[n];
    for(long long j=0;j<n;j++)
    cin>>a[j];
    sort(a,a+n);
    for(long long i=0;i<n-2;i++)
    {
        for(long long j=i+1;j<n-1;j++)
        {
            for(long long k=j+1;k<n;k++)
            {
                if(a[k]<(a[i]+a[j])&&a[k]!=a[j]&&a[j]!=a[i]&&a[i]!=a[k])
                c++;
            }
        }
    }
    cout<<c;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;

  if(n%2==0)cout<<setprecision(10)<<1.0/2<<endl;
  else cout<<setprecision(10)<<(double)(n/2+1)/n<<endl;



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
#include<set>
#define itn int
#define retrun return
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int main(void) {
	llong x;
	llong ans;
	cin >> x;
	llong a = x / 11;
	a *= 2;
	int b = x % 11;
	if (b == 0) {
		ans = a;
	}
	else if (b <= 6) {
		ans = a + 1;
	}
	else {
		ans = a + 2;
	}

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

Measured memory_bytes: 256
N,X = map(int, input().split())
D=0
L=list(map(int, input().split()))
i=0
while (D<=X)and(i<N+1):
  if (i<N):
    D+=L[i]
  i+=1
#  if i>N:
 #   break
print(i)
  
  


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP (i, N) cin >> A[i];
    map<int, int> mp1, mp2;
    REP (i, N) {
        mp1[i + A[i]]++;
        mp2[i - A[i]]++;
    }
    int ans = 0;
    for (auto p : mp1) {
        ans += p.second * mp2[p.first];
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 38984
L = int(input())
l = L - 1
N = 0
while l > 0:
	l = l // 2
	N += 1
E = [(i+1, i+2, 0) for i in range(N - 1)]
E += [(i+1, i+2, 2 ** (N - i - 2)) for i in range(N - 1)]

if L == 2 ** N:
	w = 2 ** (N-1)
	E.append((1,2,w))
	if w > 1:
		E.append((1,2,w + w // 2))
else:
	rest = L - (2 ** (N - 1))
	cnt = 0
	bit = [0 for i in range(N-1)]
	while rest > 0:
		bit[cnt] = (rest % 2)
		rest = rest // 2
		cnt += 1
	bit.reverse()

	weight = 2 ** (N-1)
	for i in range(len(bit)):
		if bit[i] == 1:
			E.append((1, i+2, weight))
			weight += 2 ** (N - i - 2)

if L == 2:
	N = 2
	E = [(1,2,0),(1,2,1)]
print(N, len(E))
for e in E:
	print(e[0], e[1], e[2])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t A,B,K;
cin>>A>>B>>K;
if(A>=K){
    cout<<A-K<<' '<<B;
}else if(A+B>=K){
    cout<<'0'<<' '<<B-K+A<<endl;
}else{
    cout<<'0'<<' '<<'0'<<endl;
}
}

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

using namespace std;

using int64 = long long;

int main() {
  int N, A[100];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];
  cout << *max_element(A, A + N) - *min_element(A, A + N) << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		int Q = sc.nextInt();
		int[][] cnt = new int[N][N];
		for (int i = 0; i < M; ++i) {
			int L = sc.nextInt() - 1;
			int R = sc.nextInt() - 1;
			++cnt[L][R];
		}
		for (int i = N - 2; i >= 0; --i) {
			for (int j = 0; j < N; ++j) {
				cnt[i][j] += cnt[i + 1][j];
			}
		}
		for (int i = 1; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				cnt[j][i] += cnt[j][i - 1];
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < Q; ++i) {
			int p = sc.nextInt() - 1;
			int q = sc.nextInt() - 1;
			pw.println(cnt[p][q]);
		}
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 32172
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    Int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int u, v; cin >> u >> v; u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<int> visited(N);
    vector<pair<int, bool>> A;
    for (int i = 0; i < N; i++) {
        int cnt = 0;
        bool able = true;
        stack<pair<int, int>> S;
        S.emplace(i, 1);
        while (!S.empty()) {
            int t, c; tie(t, c) = S.top(); S.pop();
            if (visited[t]) continue;
            visited[t] = c, cnt++;
            for (int n : G[t]) {
                if (visited[n] == 0) S.emplace(n, 3-c);
                if (visited[n] == c) able = false;
            }
        }
        if (cnt) A.emplace_back(cnt, able);
    }
    Int single = 0, able = 0, unable = 0;
    for (auto& a : A) {
        if (a.first == 1) single++;
        else if (a.second) able++;
        else unable++;
    }
    Int ans = 0;
    ans += single * single + single * (N - single) * 2;
    ans += able * able * 2;
    ans += able * unable;
    ans += unable * able;
    ans += unable * unable;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int n, m;
int main() {
    int n;
    cin >> n;
    if ( n >= 1000 ) cout << "ABD" << endl;
    else             cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math
from collections import Counter
import itertools
import fractions
from decimal import *
#import numpy as np
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
X=LI()

i = 0
for x in X:
    i+=1
    if x == 0:
        print(i)
        exit()
        

Measured memory_bytes: 10292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n;
double x[1005],y[1005],r[1005],dp[1005];
int main(){
	cin>>x[0]>>y[0]>>x[1]>>y[1];
	cin>>n;
	for(int i=2;i<=n+1;i++) cin>>x[i]>>y[i]>>r[i];
	rep(i,n+2)dp[i]=1e18;
	priority_queue<Q,vector<Q>,greater<Q> >que;
	que.push(mp(0,0));
	dp[0] = 0.0;
	while(!que.empty()){
		Q q = que.top(); que.pop();
		//cout<<dp[q.sc]<<" " <<q.fi<<endl;
		if(abs(q.fi-dp[q.sc]) > 1e-7) continue;
		rep(i,n+2){
		    if(i==q.sc) continue;
			double xx = sqrt((x[i]-x[q.sc])*(x[i]-x[q.sc])+(y[i]-y[q.sc])*(y[i]-y[q.sc]));
			double y1 = r[i];
			double y2 = r[q.sc];
			xx -= (y1+y2);
			xx = max(xx,0.0);
			if(dp[q.sc]+xx<dp[i]-1e-10){
				dp[i] = dp[q.sc]+xx;
				que.push(mp(dp[i],i));
			}
		}
	}
	printf("%.10f\n",dp[1]);
}

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

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

    vector<long long> a(n);
    REP(i, n)   cin >> a[i];

    vector<bool> sign = {true, false};
    vector<long long> cnt = {0, 0};

    long long total;

    REP(k, 2){
        vector<long long> a_tmp = a;
        total = 0;
        for (int i = 0; i < n; ++i) {
            total += a_tmp[i];

            if (sign[k] && total >= 0) {
                a_tmp[i] -= (total + 1);
                cnt[k] += (total + 1);
                sign[k] = false;
                total = -1;
            }
            
            else if (!sign[k] && total <= 0) {
                a_tmp[i] += (abs(total) + 1);
                cnt[k] += (abs(total) + 1);
                sign[k] = true;
                total = 1;
            }

            else
                sign[k] = !sign[k];
        }
    }

    cout << min(cnt[0], cnt[1]) << endl;
}

Measured memory_bytes: 1804
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_sum = [0]
for i in range(N):
    A_sum.append(A[i] + A_sum[i])
B_sum = [0]
for i in range(M):
    B_sum.append(B[i] + B_sum[i])   
    
b_idx = 0
for i in range(1, M+1):
    if B_sum[i] <= K:
        b_idx = i
ans = 0
for i in range(N+1):
    if b_idx > 0:
        while A_sum[i] + B_sum[b_idx] > K:
            b_idx -= 1
            if b_idx < 0:
                b_idx = 0
                break
    if A_sum[i] + B_sum[b_idx] <= K:
        ans = max(ans, i+b_idx)
print(ans)

Measured memory_bytes: 132336
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 2000;

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> g[MAX_N];
    REP(i, N - 1) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        g[A].pb(B);
        g[B].pb(A);
    }
    int ret = MAX_N;
    if (K % 2 == 0) {
        REP(v, N) {
            int d[MAX_N];
            fill(d, d + N, MAX_N);
            queue<int> q;
            q.push(v);
            d[v] = 0;
            while (!q.empty()) {
                int u = q.front();
                q.pop();
                if (d[u] == K / 2) {
                    continue;
                }
                REP(i, g[u].size()) {
                    int to = g[u][i];
                    if (d[to] > d[u] + 1) {
                        d[to] = d[u] + 1;
                        q.push(to);
                    }
                }
            }
            int n_remove = 0;
            REP(i, N) {
                if (d[i] > K / 2) {
                    n_remove++;
                }
            }
            ret = min(ret, n_remove);
        }
    } else {
        REP(v, N) REP (j, g[v].size()) {
            int u = g[v][j];
            int d[MAX_N];
            fill(d, d + N, MAX_N);
            queue<int> q;
            q.push(v);
            q.push(u);
            d[v] = 0;
            d[u] = 0;
            while (!q.empty()) {
                int u = q.front();
                q.pop();
                if (d[u] == K / 2) {
                    continue;
                }
                REP(i, g[u].size()) {
                    int to = g[u][i];
                    if (d[to] > d[u] + 1) {
                        d[to] = d[u] + 1;
                        q.push(to);
                    }
                }
            }
            int n_remove = 0;
            REP(i, N) {
                if (d[i] > K / 2) {
                    n_remove++;
                }
            }
            ret = min(ret, n_remove);
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,m,sum=0,x;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>x;
		sum+=x;
	}
	if(sum<n)cout<<"No";
	else  cout<<"Yes";
} 

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    ll sum = 0;
    rep(i, n + 1) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;


}


Measured memory_bytes: 3600
var numbers = [];

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input.split('\n').forEach(function(line) {
  if (line !== '') {
    numbers.push(parseInt(line.trim(), 10));
  }
});

// Eliminate the first element which describes the size of the array.
numbers.shift();

var max = numbers[1] - numbers[0];
var min = numbers[0];
for (var i = 1; i < numbers.length; i += 1) {
  max = Math.max(max, numbers[i] - min);
  min = Math.min(min, numbers[i]);
};
console.log(max);

Measured memory_bytes: 37024
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

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

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int a, b, c ,d;
	cin >> a >> b >> c >> d;
	int turn = 0;
	while(a > 0 and c > 0){
		turn++;
		if(turn&1) c-=b;
		else a-=d;
	}	
	if(turn&1) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3656
import sys
from collections import Counter
N = int(input())
As = list(map(int, input().split()))

Ls = {}
Rs = {}
ct = Counter()

for idx, A in enumerate(As, start=1):
	Ls[idx] = idx + A
	ct[idx - A] +=1

ans = 0
for L_value in Ls.values():
	ans += ct[L_value]
print(ans)



Measured memory_bytes: 64024
use std::io::Read;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let h: usize = it.next().unwrap().parse().unwrap();
    let w: usize = it.next().unwrap().parse().unwrap();
    let mut a: Vec<Vec<char>> = (0..h)
        .map(|_| it.next().unwrap().chars().collect())
        .collect();

    let mut x = 0;
    let mut y = 0;

    let dx = vec![0, 1];
    let dy = vec![1, 0];

    if a[x][y] != '#' {
        println!("Impossible");
        return;
    }

    loop {
        a[x][y] = '.';
        if x == h - 1 && y == w - 1 {
            break;
        }
        let mut found = false;
        for i in 0..2 {
            let nx = x + dx[i];
            let ny = y + dy[i];
            if nx < h && ny < w && a[nx][ny] == '#' {
                x = nx;
                y = ny;
                found = true;
                break;
            }
        }
        if !found {
            println!("Impossible");
            return;
        }
    }
    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                println!("Impossible");
                return;
            }
        }
    }
    println!("Possible");
}


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

using namespace std;

#define MAXN 50
#define MAXV 2500

long long dp[MAXN+5][MAXN+5][MAXV+5];
int x[MAXN+5];
int n, a;

long long ways(int p, int c, int s)
{
    if (p == n) {
        return (c > 0 && c*a == s);
    }
    long long &ret = dp[p][c][s];
    if (ret >= 0) return ret;
    return ret = ways(p+1, c+1, s+x[p]) + ways(p+1, c, s);
}

int main()
{
    scanf("%d%d", &n, &a);
    for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
    memset(dp, -1, sizeof(dp));
    printf("%lld\n",ways(0, 0, 0));
    return 0;
}


Measured memory_bytes: 59392
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
int n,m,k,dp[1<<21],lim1[21][21],lim2[21][21],to[1<<21],ans;
vector<int> g[1<<21];
int main() {
	scanf("%d%d%d",&n,&m,&k);
	n--;
	for(int i=1;i<=k;i++) {
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		b=n-b;
		lim1[a][b]=1;
		lim2[a][b]=c;
	}
	for(int i=0;i<(1<<n);i++) {
		for(int j=1;j<n;j++) {
			if (i&(1<<j)) continue;
			if (!(i&(1<<(j-1)))) continue;
			int tmpi=i^(1<<j)^(1<<(j-1));
			g[i].push_back(tmpi);
		}
	}
//	for(int i=0;i<(1<<n);i++) {
//		printf("%d: ",i);
//		for(int j=0;j<(int)g[i].size();j++) printf("%d ",g[i][j]);
//		puts("");
//	}
	for(int i=0;i<(1<<n);i++) {
		to[i]=(1<<n);
		for(int j=0;j<n;j++) {
			if (i&(1<<j)) continue;
			int tmpi=i^(1<<j);
			to[i]=tmpi;
			break;
		}
//		printf("%d: %d\n",i,to[i]);
	}
	dp[0]=1;
	for(int i=1;i<=m;i++) {
		for(int j=0;j<(1<<n);j++) {
			dp[to[j]]=(dp[to[j]]+dp[j])%mod;
		}
		for(int l=0;l<n;l++) {
			for(int j=0;j<(1<<n);j++) {
				if ((int)g[j].size()>l) dp[g[j][l]]=(dp[g[j][l]]+dp[j])%mod;
			}
		}
		for(int j=0;j<n;j++) {
			if (!lim1[i][j]) continue;
			for(int l=0;l<(1<<n);l++) {
				if ((l&(1<<j) ? 1 : 0)!=lim2[i][j]) {
					dp[l]=0;
				}
			}
		}
//		for(int j=0;j<(1<<n);j++) printf("%d%c",dp[j]," \n"[j+1==(1<<n)]);
	}
	for(int i=0;i<(1<<n);i++) {
		ans=(ans+dp[i])%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 78080
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n = NextInt()
da = NextIntList()
ans = 0
for i in range(n):
    if i%2 == 0 and da[i]%2 == 1:
        ans += 1

print(ans)

Measured memory_bytes: 9288
from collections import deque
n = int(input())
a = list(map(int,input().split()))

b = deque([])
for i in range(n):
    if i % 2 == 0:
        b.appendleft(a[i])
    if i % 2 == 1:
        b.append(a[i])
if n % 2 == 0:
    b = list(reversed(b))

print(*b)

Measured memory_bytes: 25412
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int d,n;
    while(scanf("%d%d",&d,&n)==2)
    {
        long long t=1;
        for(int i=0;i<d;i++)
            t*=100;
        if(n==100)
            n++;
        printf("%I64d\n",t*n);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
const long long inf = 1000000001; // const 書き換え禁止

int main(void){
    int n,k;
    cin >> n >> k;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    
    int sum = 0;
    rep(i,k){
        sum += vec.at(i);
        //cout << sum << endl;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3628
import bisect
N,M,V,P= map(int,input().split())
A = list(map(int,input().split()))

A.sort()
B = [0]*N
B[0] = A[0]

for i in range(1,N):
    B[i] = B[i-1] + A[i]

#print(A)
#print(B)
mn = 0 # NG
mx = N-1 # OK
while True:
    k = (mn+mx)//2
    #print(mn,mx,k)
    c = A[k]
    c += M
    p = bisect.bisect_right(A,c)
    flag = False
    #print("k",k)
    #print("c",c)
    #print("p",p)
    ALL = V*M
    ALL -= (k+1)*M # left
    ALL -= (P-1)*M # right
    if N-P < p:
        if ALL <= 0:
            flag = True
        #print("ALL",ALL)
        #print(N-P-k,B[N-P]-B[k])
        res = c*(N-P-k) - (B[N-P] - B[k])
        #print("res",res)
        if ALL <= res:
            flag = True
    #print("flag",flag)
    if mx - mn == 1:
        if flag:
            mx = k
        else:
            mn = k
        break
    if flag:
        mx = k
    else:
        mn = k
#print(mn,mx)
print(N-mx)




Measured memory_bytes: 62612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
vector<int> num(3);
int main(){
    rep(i, 3) cin >> num[i];
    sort(all(num));
    int cnt=0;

    while(num[1] < num[2]){
        num[0]++;
        num[1]++;
        cnt++;
    }
    if((num[2]-num[0])%2 == 1){
        num[2]++;
        num[1]++;
        cnt++;
    }
    while(num[0] < num[2]){
        num[0] += 2;
        cnt++;
    }
    out(cnt);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } // 1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } // 8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
//snippet
#define N 200009

int main() {
	int n, a[N];
	LL ans = 0;
	scanf("%d", &n);
	rep(i, n)scanf("%d",a+i);
	qsort(a, n, sizeof(int), des);
	Rep(i,1,n)ans+=a[i/2];
	printf("%lld",ans);

	return 0;
}

Measured memory_bytes: 3104
import scala.io.StdIn
 
object Main extends App {
  val Array(n, m)  = StdIn.readLine().split(" ").map(_.toInt)
  var r = Array.fill(n)(0)
 
  for(i <- 0 to m - 1){
    val ar = StdIn.readLine().split(" ").map(_.toInt)
    ar.foreach(e => r(e - 1) = r(e - 1) + 1)
  }
  r.foreach(println)
 
}

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

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

    int n = 0;
    ll ans = 0;
    n = (int)S.size();
    for (int tmp = 0; tmp < (1 << 9); tmp++)
    {
        bitset<9> s(tmp);
        int start = 0;
        if (tmp >= (1 << (n - 1)))
        {
            break;
        }
        for (int i = 0; i < n - 1; i++)
        {
            if (s.test(i))
            {
                string c = S.substr(start, i - start + 1);
                start = i + 1;
                ans += stoll(c);
            }
        }
        string c = S.substr(start, n - start);
        ans += stoll(c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1001

ll N,K;
ll dp[NUM][NUM];

ll recursive(ll num_ball,ll num_box){

	if(dp[num_ball][num_box] != -1)return dp[num_ball][num_box];

	if(num_ball == 0 || num_box == 1)return 1;

	ll ret = 0;

	for(ll next_box = 1; next_box <= num_box; next_box++){
		if(next_box > num_ball)break;
		ret += recursive(num_ball-next_box,next_box);
		ret %= MOD;
	}

	return dp[num_ball][num_box] = ret;
}

int main(){

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

	for(ll i = 0; i <= N; i++){
		for(ll p = 0; p <= K; p++){
			dp[i][p] = -1;
		}
	}

	printf("%lld\n",recursive(N,K));

	return 0;
}




Measured memory_bytes: 11024