akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var n = NextInt();
        var ans = int.MaxValue;

        for (var a = 1; a < n; a++) {
            var b = n - a;
            ans = Math.Min(ans, DigitsSum(a) + DigitsSum(b));
        }
        WriteLine(ans);
    }

    static int DigitsSum(int x) {
        var result = 0;
        while (x != 0) {
            result += x % 10;
            x /= 10;
        }
        return result;
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

const int mod = 1e9 + 7;

void add_self(ll &x, ll y) {
	x += y;
	if(x > mod) x -= mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<vector<ll>> a(n + 1, vector<ll>(n + 1)), dp(n + 1, vector<ll>(1 << n));
	for(int i = 1; i <= n; ++ i)
		for(int j = 1; j <= n; ++ j)
			cin >> a[i][j];
	auto get_next = [](int x) {
		int c = x&(-x), r = x + c;
		return (((r^x) >> 2) / c) | r;
	};
	dp[0][0] = 1;
	for(int i = 1; i <= n ; ++ i) {
		for(int mask = (1 << i) - 1; mask < (1 << n); mask = get_next(mask)) {
			for(int j = 1; j <= n; ++ j) {
				if(!a[i][j] || !((mask >> (j - 1)) & 1)) continue;
				add_self(dp[i][mask], dp[i - 1][mask & ~(1 << (j - 1))]);
			}
		}
	}
	cout << dp[n][(1 << n) - 1] << '\n';
}


Measured memory_bytes: 377216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <deque>
#include <iomanip>
#include <queue>
#include <stdio.h>
using namespace std;
#define rep(i,n) for (ll i=0;i<n;i++)
#define REP(i,n) for (ll i=1;i<=n;i++)
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078160628620899
typedef long long ll;
typedef pair<ll, ll> Pll;
const ll MOD = 1000000007;
const ll INF = 1000000000000000;

string S, T;
ll ans, sum, now, N, M, A;
double a, b;

int main() {
	cin >> a;
	b = a / 3;
	cout << fixed << setprecision(10) << b * b * b << endl;
	return 0;
}


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

#define lint long long int
#define N_MAX 200000


int main()
{
    lint x;
    cin >> x;
    
    lint y = 0, money = 100;
    do {
        money *= 1.01;
        y++;
    }
    while (money < x);
    cout << y << endl;
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int INF = 1<<30;
const ll LINF = 1LL<<61;

int main()
{
    string s;
    cin >> s;
    if(s == "RSR") cout << 1 << endl;
    else cout << count(s.begin(), s.end(), 'R') << endl;
    //cout << s << endl;
    return 0;
}

Measured memory_bytes: 3616
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

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

		int a[3], b[3];
		for (int i = 0; i <= 100; i++) {
				a[0] = i;
				b[0] = c[0][0] - a[0];

				for (int j = 0; j <= 100; j++) {
						a[1] = j;
						b[1] = c[1][1] - a[1];
						if (c[0][1] != a[0] + b[1]) continue;
						if (c[1][0] != a[1] + b[0]) continue;

						for (int k = 0; k <= 100; k++) {
								a[2] = k;
								b[2] = c[2][2] - a[2];
								if (c[0][2] != a[0] + b[2]) continue;
								if (c[1][2] != a[1] + b[2]) continue;
								if (c[2][1] != a[2] + b[1]) continue;
								if (c[2][0] != a[2] + b[0]) continue;
								cout << "Yes" << endl;
								return 0;
						}
				}
		}
		cout << "No" << endl;
		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = 100 * 1000 + 7;
int a[MAXN];
int go[MAXN][20];
int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    int l;
    scanf("%d", &l);
    for (int i = 0; i < 20; i++)
    {
        go[n + 1][i] = n + 1;
    }
    for (int i = 1; i <= n; i++)
    {
        if (a[i] + l > a[n])
        {
            go[i][0] = n + 1;
        }
        else
        {
            int bl = i, br = n + 1;
            while (br - bl > 1)
            {
                int bm = (bl + br) / 2;
                if (a[bm] <= a[i] + l)
                {
                    bl = bm;
                }
                else
                {
                    br = bm;
                }
            }
            go[i][0] = bl;
        }
    }
    for (int i = 1; i < 20; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            go[j][i] = go[go[j][i - 1]][i - 1];
        }
    }
    int q;
    scanf("%d", &q);
    for (int i = 1; i <= q; i++)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        if (u > v) swap(u, v);
        int res = 0;
        for (int j = 19; j >= 0; j--)
        {
            if (go[u][j] < v)
            {
                res += (1 << j);
                u = go[u][j];
            }
        }
        res++;
        printf("%d\n", res);
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    int previous = 0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(i!=0 && a-previous == 1){
            v.push_back(previous);
        }
        previous = a;
    }
    int sum = 0;
    for(int i=0; i<n; i++){
        int b;
        cin >> b;
        sum += b;
    }
    vector<int> c(n);
    for(int i=0; i<n; i++) cin >> c[i];
    
    for(auto e: v){
        sum += c[e-1];
    }
    cout << sum << endl;
    return 0;
}


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

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

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

using namespace std;

int parent(int i){return i/2;}
int right(int i){return 2*i+1;}
int left(int i){return 2*i;}

int main()
{
    int n;
    vector<int> node;
    cin>>n;
    node.emplace_back(-1);
    for (int i = 1; i < n+1; i++)
    {
        int key;
        cin>>key;
        node.emplace_back(key);
    }
    for (int i = 1; i <= n; i++)
    {
        cout<<"node "<<i<<": "<<"key = "<<node[i]<<", ";
        if(parent(i)>=1)cout<<"parent key = "<<node[parent(i)]<<", ";
        if(left(i)<=n)cout<<"left key = "<<node[left(i)]<<", ";
        if(right(i)<=n)cout<<"right key = "<<node[right(i)]<<", ";
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3116
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int l=sc.nextInt(),r=sc.nextInt(),d=sc.nextInt(),f=0;
    for(int i=l;i<=r;i++){
      if(i%d==0){
        f++;
      }
    }
    System.out.println(f);
  }
}


Measured memory_bytes: 35620
from collections import Counter

input()
a_list = list(map(int, input().split()))

c = Counter(a_list)
divisible = [True] * (10**6+1)
for el, count in c.items():
    if count!=1:
        divisible[el] = False
    for i in range(el*2, 10**6+1, el):
        divisible[i] = False
a_list = list(set(a_list))
ans = len(
    [1 for a in a_list if divisible[a]]
)    
print(ans)

Measured memory_bytes: 52980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H,vector<char>(W));
  for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++){
          cin >> data.at(i).at(j);
      }
  }


//01置換
vector<vector<int>> bit(H,vector<int>(W,0));
  for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
          if(data.at(i).at(j)=='#'){
              bit.at(i).at(j)=1;
          }
      }
  }

//行のチェック
  vector<int> rj(H,0);
  for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
          if(bit.at(i).at(j)==1){
            rj.at(i) ++;
            break;
          }
      }
  }
  int rsize =0;
  for (int i = 0; i < H; i++){
      rsize += rj.at(i);
  }
//行の圧縮
  vector<vector<int>> rbit(rsize,vector<int>(W,0));
  int k =0;
  for (int i = 0; i < H; i++){
    if(rj.at(i)==0){
    }else{
        for (int j = 0; j < W; j++){
            rbit.at(k).at(j) =bit.at(i).at(j);
        }
        k++;
    }
  } 


//列のチェック
  vector<int> cj(W,0);
  for (int i = 0; i < W; i++){
      for (int j = 0; j < H; j++){
          if(bit.at(j).at(i)==1){
            cj.at(i) ++;
            break;
          }
      }
  }
  int csize =0;
  for (int i = 0; i < W; i++){
      csize += cj.at(i);
  }
//列の圧縮
  vector<vector<int>> cbit(rsize,vector<int>(csize,0));
  int l = 0;
  for (int i = 0; i < W; i++){
    if(cj.at(i)==0){
    }else{
        for (int j = 0; j < rsize; j++){
            cbit.at(j).at(l) =rbit.at(j).at(i);
        }
        l++;
    }
  } 

//表の置換

vector<vector<char>> ans(rsize,vector<char>(csize));
  for (int i = 0; i < rsize; i++){
      for (int j = 0; j < csize; j++){
          if(cbit.at(i).at(j)==1){
              ans.at(i).at(j)='#';
          }else{
              ans.at(i).at(j)='.';
          }
      }
  }

//表の出力
    for (int i = 0; i < rsize; i++){
      for (int j = 0; j < csize; j++){
          cout << ans.at(i).at(j);
          if (j == csize-1){
              cout << endl;
            }
        }
    } 
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <atcoder/all>
#define _GLIBCXX_DEBUG
#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;
using namespace atcoder;
typedef long long ll;

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

    int n, m;
    cin >> n >> m;

    dsu uf(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        uf.merge(a, b);
    }

    set<int> st;
    rep(i, n) st.insert(uf.leader(i));

    cout << st.size()-1 << endl;



    return 0;
}

Measured memory_bytes: 7552
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int n,cnt = 0,c = 0;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++){
    cin >> h[i];
    if (h[i] >= cnt){
      c++;
      cnt = h[i];
    }
  }
  cout << c << '\n';
  return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
 
int main(void){
  int a,b,x=0;
  
  scanf("%d%d",&a,&b);
  
  if(a>=b){
    x+=a;
    a--;
  }
  else{
    x+=b;
    b--;
  }
  
   if(a>=b){
    x+=a;
    a--;
  }
  else{
    x+=b;
    b--;
  }
  
  printf("%d\n",x);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int win(vector<int> rock){
    if(rock.size()==1)return rock[0];
    vector<int> rock1(rock.size()/2),rock2(rock.size()/2);
    REP(i,rock.size()/2){
        rock1[i]=rock[i];
        rock2[i]=rock[i+rock.size()/2];
    }
    int a=win(rock1);
    int b=win(rock2);
    if(a>b)return a-b;
    else if(a<b)return b-a;
    return a;
}

int main(){
    
    int N; cin>>N;
    vector<int> A(1<<N);
    REP(i,1<<N)cin>>A[i];
    
    cout<<win(A)<<endl;
    
    return 0;
}


Measured memory_bytes: 5504
//
// Created by Hel Galib on 2019-11-09.
//

#include <iostream>
#include <string>
using namespace std;


int main()
{
    char s[100];
    cin>>s;

    if (s[0] == 'S') cout <<"Cloudy" <<endl;
    else if(s[0] == 'C') cout<<"Rainy" <<endl;
    else if(s[0] == 'R') cout<<"Sunny" << endl;


    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
vector<vector<P>> G(1e6+5);
vector<bool> visited(1e6+5,false);
vector<int> dist(1e6+5);

bool bfs(int v,int d){
  if(visited[v]){
    return dist[v]==d;
  }
  dist[v] = d;
  visited[v] = true;
  for(auto nv: G[v]){
    if(!bfs(nv.first,d+nv.second)) return false;
  }
  return true;
}

int main(){
  int N,M;
  cin >> N >> M;
  for(int i=0; i<M; i++){
    int L,R,D;
    cin >> L >> R >> D;
    G[L].emplace_back(R,D);
    G[R].emplace_back(L,-1*D);
  }
  for(int i=0; i<N; i++){
    if(visited[i]) continue;
    if(!bfs(i,0)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int C[1100], W[1100];
bool dp[1100][1100]; // dp[i][j]: [i, j] にいる人を1人で支えられるか
int dp2[1100]; // dp2[i]: [0, i) にいる人を支えるのに必要な最小人数

int sum(int i, int j){
    return W[i] - W[j + 1];
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> C[i] >> W[i];
    }

    for(int i=N-2;i>=0;--i){
        W[i] += W[i + 1];
    }

    for(int i=0;i<N;++i){
        dp[i][i] = true;
    }

    for(int i=2;i<=N;++i){
        for(int j=0;j+i<=N;++j){
            if((dp[j + 1][j + i - 1] &&
                C[j] >= sum(j + 1, j + i - 1)) ||
               (dp[j][j + i - 2] &&
                C[j + i - 1] >= sum(j, j + i - 2))){
                dp[j][j + i - 1] = true;
            }
        }
    }

    std::fill(dp2, dp2 + N + 1, 1100);
    dp2[0] = 0;

    for(int i=0;i<N;++i){
        for(int j=i;j<N;++j){
            if(dp[i][j]){
                dp2[j + 1] = std::min(dp2[j + 1], dp2[i] + 1);
            }
        }
    }

    int mn = dp2[N];
    std::cout << mn << std::endl;
}



Measured memory_bytes: 4260
using System;
using System.Collections.Generic;
					
public class my
{
	public static void Main()
	{
		var n = my.GetInt();
		
		Vector p1,p2;
		p1.X = 0;
		p1.Y = 0;
		p2.X = 100;
		p2.Y = 0;
		
		WriteVector(p1);
		Koch(n, p1, p2);
		WriteVector(p2);
	}
	
	private static void Koch(int n, Vector p1, Vector p2)
	{
		if(n<=0)	return;
		
		Vector s,t,u;
		
		s.X = (2*p1.X + p2.X) / 3;
		s.Y = (2*p1.Y + p2.Y) / 3;
		t.X = (2*p2.X + p1.X) / 3;
		t.Y = (2*p2.Y + p1.Y) / 3;
		u.X = (t.X-s.X)*1/2 - (t.Y-s.Y)*Math.Sqrt(3)/2+s.X;
		u.Y = (t.X-s.X)*Math.Sqrt(3)/2 + (t.Y-s.Y)*1/2+s.Y;
		
		Koch(n-1, p1, s);
		WriteVector(s);
		Koch(n-1, s, u);
		WriteVector(u);
		Koch(n-1, u, t);
		WriteVector(t);
		Koch(n-1, t, p2);
		
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}

	private static int[] GetIntArray(int n)
	{
		var A = new int[n];
		var s = Console.ReadLine().Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}

	private static int[] GetIntArray(char c)
	{
		return Array.ConvertAll(Console.ReadLine().Split(c), int.Parse);
	}
	
	private static double[] GetDoubleArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
	}
	
	public static string Reverse(string s)
	{
		var c = s.ToCharArray();
		Array.Reverse(c);
		
		return new String(c);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}

	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteVector(Vector v)
	{
		Console.WriteLine(string.Format("{0:f8} {1:f8}", v.X, v.Y));
	}
}

public struct Vector
{
	public double X,Y;
}

Measured memory_bytes: 9396
X=int(input())
tmp=False

for a in range(-10**5//2,10**5//2):
  b5=(int(a**5)-X)
  if b5<0:
    b5=-b5
    tmp=True
  b=int(b5**0.2)
  
  if tmp==True:
    b=-b
    
  if a**5-b**5==X:
    print(a,b)
    break

Measured memory_bytes: 9576
# -*- coding: utf-8 -*-
# dwacon6th-prelims/dwacon6th_prelims_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())

MAX = 10**5 + 100
MOD = 10**9 + 7

fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [1, 1] + [0] * MAX
coef = [1, 1] + [0] * MAX

for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD
    coef[i] = (coef[i - 1] * i + fac[i - 1]) % MOD

def main():
    N = i2n()
    n = N - 1
    x = i2nn()
    total = 0
    for i in range(1, N):
        d = x[i] - x[i - 1]
        total = (total + coef[i] * fac[n] % MOD * finv[i] % MOD * d % MOD) % MOD
    print(total)
    return

main()


Measured memory_bytes: 31832
#include <iostream>
#include <math.h>
using namespace std;

int main (void) {
    int x, a, b;
    cin >> x >> a >> b;

    if (abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }

    return 0;
}


Measured memory_bytes: 3592
import collections


def main():
    s = input()
    downs = collections.deque()
    pools = collections.deque()
    total_area = 0
    for now, char in enumerate(s):
        if char == "\\":
            downs.append(now)
        elif downs and char == "/":
            down = downs.pop()
            sub_area = now - down
            total_area += sub_area
            if not pools:
                pools.append((down, sub_area))
            else:
                while pools and down < pools[-1][0]:
                    sub_area += pools.pop()[1]
                pools.append((down, sub_area))
    print(total_area)
    pools = list(zip(*pools))[1] if pools else []
    print(len(pools), *pools)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6864
#include<stdio.h>
int main(){
    int max=-1000000000,tmp=-1000000000,min=1000000000,n,i,j=0,a[200000],prof[100000];
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    if(n==2){
       
        prof[0]=a[1]-a[0];
        j++;
        
    }else{
        
        for(i=0;i<n;i++){
        
        if(a[i]>max){
            max=a[i];
        }
        
        if(a[i]<min){
            
            prof[j]=max-min;
            j++;
            min=a[i];
            max=-1000000000;
        }
    }
    
    prof[j]=max-min;
    j++;
    }
    
    for(i=0;i<j;i++){
        if(prof[i]>tmp)tmp=prof[i];
    }
    printf("%d\n",tmp);
    
}



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

int N;
int A[210];        
int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

   
    while (true) {
        bool exist_odd = false; 
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  
        }

        if (exist_odd) break;  

        
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res; 
    }

    cout << res << endl;
}

Measured memory_bytes: 256
N=int(input())
N-=1
for i in range(1,15):
  if N>=26**i:
    N-=26**i
    continue
    
  ans=''
  for j in range(i):
    d=N%26
    ans+=chr(d +ord('a'))
    N//=26
  ans=ans[::-1]
  break
print(ans)

Measured memory_bytes: 61816
import math
a,b,h,m=map(int,input().split())
partition=0.5
minute=m*6
# minute=minute*360
hour=30*h + 0.5*m
dif=abs(hour-minute)
cos=math.cos(math.pi*(dif/180));
print(math.sqrt(a**2 + b**2 - 2*a*b*cos))


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << #x << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << #x << "=" << x << "] [" << #y << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << #x << "=" << x << "] [" << #y << "=" << y << "] [" << #z << "=" << z << "]" << '\n';

void solve(){
	string s; cin>>s;
    int n=s.length();
	string just=s;
	reverse(all(just));
	if(just!=s){
		cout<<"No";LOL
		return;
	}
	string lol=s.substr(0,(n-1)/2);
	just=lol;
	reverse(all(just));
	if(just!=lol){
		cout<<"No";LOL
		return;
	}
	lol=s.substr((n+3)/2-1,(n-3)/2+1);
	just=lol;
	reverse(all(just));
	if(just!=lol){
		cout<<"No";LOL
		return;
	}
	cout<<"Yes";LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _=1; //cin>>_;
  while(_--) solve();
  return 0;
}

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

int n, a[100000+10], cnt[100000+10], cntp;
long long ans = 1, mod = 998244353;

int power(long long x,long long t)
{
    if ( t == 0 )
        return 1;
    else if (t % 2 == 0)
        return ( power( (x*x) % mod  , t/2 ) % mod );
    else
        return  ( ( ( power( (x*x) % mod  , t/2 ) % mod ) * x) % mod )  ;
}

int main()
{
   cin >> n;
   for( int i = 0; i < n; i++ )
   {
     cin >> a[i];
     if( ( i == 0 && a[i] != 0 ) || ( a[i] == 0 && i ) )
     {
        cout << 0;
        return 0;
     }
   }

   sort( a, a+n );
   for( int i = 1; i < n; i++ )
   {
     if( a[i] - a[i-1] > 1 )
     {
        cout << 0;
        return 0;
     }
   }
    int i = 1, cntp = 1;
   cnt[0] = 1;
   while( i != n )
   {
      while( i != n && a[i] == cntp )
      {
        i++;
        cnt[cntp]++;
      }
      //cout << cntp << ' ' << cnt[cntp] << endl;
      ans *= power( cnt[cntp-1], cnt[cntp] );
      ans %= mod;
      cntp++;
   }

   cout << ans;
   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct job {
  int t,d;
};
vector<job> jobs;
int main() {
    int n;
    scanf ("%d",&n);
    jobs.resize(n);
    for (auto &a : jobs) scanf ("%d %d",&a.t,&a.d);
    sort(jobs.begin(),jobs.end(),[](job a, job b) {return a.d < b.d;});
    int curtime = 0;
    for (job j : jobs) {
      curtime += j.t;
      if (curtime > j.d) return !printf ("No\n");
    }
    printf ("Yes\n");
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
import math
def dist(x0, y0, x1, y1):
    return ((x0-x1)**2+(y0-y1)**2)**0.5
ans = 10**18
eps = 10**(-7)
for i in range(N):
    for j in range(i):
        for k in range(j):
            xi, yi = xy[i]
            xj, yj = xy[j]
            xk, yk = xy[k]
            a = xi
            b = yi
            c = xj
            d = yj
            e = xk
            f = yk

            aa = a * a
            bb = b * b
            cc = c * c
            dd = d * d
            ee = e * e
            ff = f * f
            
            if (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f)) == 0 or (2 * (e - a)) == 0:
                continue
            py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

            px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a))\
            if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

            r = math.hypot(px - a, py - b)
            flag = True
            for l in range(N):
                xl, yl = xy[l]
                if math.hypot(xl-px, yl-py)<=r+eps:
                    continue
                flag = False
            if flag:
                ans = min(ans, r)
for i in range(N):
    for j in range(i):
        xi, yi = xy[i]
        xj, yj = xy[j]
        px, py = (xi+xj)/2, (yi+yj)/2
        r = dist(xi, yi, xj, yj)/2
        flag = True
        for l in range(N):
            xl, yl = xy[l]
            if math.hypot(xl-px, yl-py)<=r+eps:
                continue
            flag = False
        if flag:
            ans = min(ans, r)
print(ans)







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

int main(){
    int N, K;
    cin >> N >> K;
    int Num[N] = {0};
    for(int i =0; i < N; i++){
        int A;
        cin >> A;
        Num[A] ++;
    }
    sort(Num, Num + N, greater<int>());
    int res = 0;
    for(int i =0; i < K; i++){
        res += Num[i];
    }
    cout << N - res << endl;       
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string x, string y){
  int c[N + 1][N + 1], maxl = 0, i, j;
  int m = x.size();
  int n = y.size();

  x = ' ' + x;
  y = ' ' + y;
 
  for(i = 1; i <= m; i++) c[i][0] = 0;
  for(i = 0; i <= n; i++) c[0][i] = 0;

  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(x[i] == y[j]){
	c[i][j] = c[i - 1][j - 1] + 1;
      } else{
	c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string x, y;
  int q, i;

  cin >> q;
  
  for(i = 0; i < q; i++){
    cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
  return 0;
}

Measured memory_bytes: 6988
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
MOD=10**9+7

d=Counter(a)
tni=0
dv=d.values()
dv=list(dv)
for i in range(len(dv)):
    tni+=dv[i]*(dv[i]-1)//2

for i in range(n):
    r=d[a[i]]
    print(tni-(r-1))



Measured memory_bytes: 26268
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc146/tasks/abc146_b>
 問題文============================================================
 B - ROT N
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    cin >> res;
    for(auto& c:res){
        c = ((c-'A')+N)%26 + 'A';
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import math
N = int(input())
lennum = np.array([26**i for i in range(1,13)])
sumnum = np.array([sum(lennum[:i]) for i in range(12)])
lennum = np.hstack((1, lennum))
lennum,sumnum

dig = min(np.where(sumnum >= N)[0])
n = N - sumnum[dig - 1]
n, dig
ret =''
tmp = n
for i in range(dig)[::-1]:
    dig_i = math.ceil(tmp/lennum[i])
    ret += chr(97 + dig_i - 1)
    tmp = tmp - lennum[i]*(dig_i - 1)
print(ret)

Measured memory_bytes: 27100
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, q;
string s;

int main() {
	cin >> n >> q >> s;
	
	vector<int> v(n + 1);
	inc(i, n) {
		v[i + 1] = v[i] + (s.substr(i, 2) == "AC" ? 1 : 0);
	}
	
	inc(qq, q) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		
		cout << (v[r] - v[l]) << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], *di = dn;

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


	int N = getint();
	int A[500001];
	*A = getint();
	int d[500000];
	rep(i, N) {
		*(d + i) = getint();
		*(A + i + 1) = min(*(A + i), abs(*(A + i) - *(d + i)));
	}
	int B[500000];
	*(B + N - 1) = 0;
	for(int i = N - 1; i >= 1; i--) {
		if (*(B + i) >= 1e9 || *(B + i) * 2 + 1 < *(d + i)) *(B + i - 1) = *(B + i);
		else *(B + i - 1) = *(B + i) + *(d + i);
	}
	int Q = getint();
	rep(i, Q) {
		int q = getint();
		q--;
		if (*(A + q) <= *(B + q)) {
			*di++ = 'N';
			*di++ = 'O';
			*di++ = '\n';
		}
		else {
			*di++ = 'Y';
			*di++ = 'E';
			*di++ = 'S';
			*di++ = '\n';
		}
	}

	fwrite(dn, di - dn, 1, stdout);
	
	Would you please return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int n;
    cin>>n;
    int a[n];
    f(i, n) cin>>a[i];
    sort(a, a + n);
    int ans = 0;
    f(i, n) {
        rep(j, i + 1, n - 1) {
            rep(k, j + 1, n - 1) {
                if(a[i] == a[j] || a[j] == a[k]) continue;
                if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) ans++;
            }
        }
    }
    cout<<ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
package main

import (
  "fmt"
)

func main() {
  var b string

  fmt.Scan(&b)

  if b == "A" {
    fmt.Println("T")
  } else if b == "T" {
    fmt.Println("A")
  } else if b == "G" {
    fmt.Println("C")
  } else if b == "C" {
    fmt.Println("G")
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;


int main(){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout<<"No"<<endl;
        return 0;
    }else{
        cout<<"Yes"<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int main(){
    	int a,b ; cin >> a >> b;
    	
    	
    	int sum = 0;
    	int k;
    	while(b--){
    		cin >> k;
    		sum += k;
    	}

    	if(sum >= a) cout << "Yes" << endl;
    	else  cout << "No" << endl;

    	return 0;
}

Measured memory_bytes: 256
/*input
3
2 1 4
2
1 1
2 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int a[maxn];
int main()
{
	IOS;
	int n;
	cin>>n;
	int sum=0;
	REP(i,n) cin>>a[i];
	REP(i,n) sum+=a[i];
	int q;
	cin>>q;
	while(q--){
		int u,v;
		cin>>u>>v;
		u--;
		cout<<sum+v-a[u]<<'\n';
	} 
	return 0;
}


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

int main(){
    ll N,K,S;
    cin>>N>>K>>S;
    for(ll i=0;i<N-1;++i){
        if(i<K){
            cout<<S<<" ";
        }else{
            if(1000000000!=S){
                cout<<S+1<<" ";
            }else{
                cout<<1<<" ";
            }
        }
    }
    if(K==N){
            cout<<S;
        }else{
            if(1000000000!=S){
                cout<<S+1;
            }else{
                cout<<1;
            }
        }
}

Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n<=1000){
        printf("%d\n",1000-n);
    }
    else if(n<=2000){
        printf("%d\n",2000-n);
    }
    else if(n<=3000){
        printf("%d\n",3000-n);
    }
    else if(n<=4000){
        printf("%d\n",4000-n);
    }
    else if(n<=5000){
        printf("%d\n",5000-n);
    }
    else if(n<=6000){
        printf("%d\n",6000-n);
    }
    else if(n<=7000){
        printf("%d\n",7000-n);
    }
    else if(n<=8000){
        printf("%d\n",8000-n);
    }
    else if(n<=9000){
        printf("%d\n",9000-n);
    }
    else if(n<=10000){
        printf("%d\n",10000-n);
    }
}


Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int A, B, M;
int a[100005], b[100005], x[100005], y[100005], c[100005];

int main(void) {

	cin >> A >> B >> M;
	
	for (int i = 1; i <= A; i++) { cin >> a[i]; }
	int min_a = a[1];

	for (int i = 1; i <= A; i++) { min_a = min(min_a, a[i]); }
	//cout << "min_a= " << min_a << endl;

	for (int i = 1; i <= B; i++) { cin >> b[i]; }

	int min_b = b[1];
	for (int i = 1; i <= B; i++) { min_b = min(min_b, b[i]); }

	for (int i = 1; i <= M; i++) { cin >> x[i] >> y[i] >> c[i]; }

	//cout << "min_b= " << min_b << endl;

	int ans = min_a + min_b;
	//cout << ans << endl;

	for (int i = 1; i <= M; i++) {
		ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
		//cout << a[x[i]] + b[y[i]] - c[i] << endl;
		//cout << x[i] << " " << y[i] << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define y1 ysgh
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-') jp = getchar();
	if (jp == '-')
	   fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9') out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
void print(int x)
{
	if (x >= 10)
	   print(x / 10);
	putchar('0' + x % 10);
}
void write(int x, char c = '\n')
{
	if (x < 0)
	   putchar('-'), x = -x;
	print(x);
	putchar(c);
}
const int inf = 0x7fffffff;
const int N = 2e5 + 10, K = 50;
int n, T, a[N], b[N], p[N], k;
bool cmp(const int &i, const int &j)
{
	ll A = 1LL * (b[i] + 1) * a[j], B = 1LL * (b[j] + 1) * a[i];
	return A == B ? b[i] < b[j] : A < B;
}
int dp[2][K];
int main()
{
//	freopen("1.in", "r", stdin);
//	freopen("eriri.out", "w", stdout);
	n = read(), T = read();
	for (int i = 1; i <= n; ++i)
		a[i] = read(), b[i] = read();
	iota(p + 1, p + 1 + n, 1);
	sort(p + 1, p + 1 + n, cmp);
	k = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (a[p[i]] == 0)
			break;
		k = i;
	}
	int id = 0;
	for (int j = 0; j < K; ++j)
		dp[id][j] = T + 1;
	dp[id][0] = 0;
	for (int i = 1; i <= k; ++i)
	{
		for (int j = 0; j < K; ++j)
			dp[id ^ 1][j] = dp[id][j];
		for (int j = 0; j < K - 1; ++j)
			if (dp[id][j] < T)
			{
				ll t = 1 + 1LL * a[p[i]] * (1 + dp[id][j]) + b[p[i]];
				if (t + dp[id][j] <= T)
					dp[id ^ 1][j + 1] = min(dp[id ^ 1][j + 1], (int)(t + dp[id][j]));				
			}
		id ^= 1;
	}
	int ans = 0;
	for (int j = 0; j < K; ++j)
		if (dp[id][j] <= T)
		{
			int s = j, cur = dp[id][j];
			for (int i = k + 1; i <= n; ++i)
			{
				int t = 1 + b[p[i]];
				if (t + cur > T)
					break;
				cur += t, ++s;
			}
			ans = max(ans, s); 
		}
	write(ans);
	return 0;
}


Measured memory_bytes: 5856
package main

import (
	"fmt"
	"math"
)

type primeFactor struct {
	value int64
	count int
}

func primeFactorization(n int64) []primeFactor {
	p := make([]primeFactor, 0)
	temp := n

	sn := int64(math.Sqrt(float64(n)) + 1)
	for i := int64(2); i <= sn; i++ {
		if temp%i == 0 {
			var cnt int
			for temp%i == 0 {
				cnt++
				temp /= i
			}
			p = append(p, primeFactor{i, cnt})
		}
	}

	if temp != 1 {
		p = append(p, primeFactor{temp, 1})
	}

	if len(p) == 0 {
		p = append(p, primeFactor{n, 1})
	}
	return p
}

func main() {
	var n int64
	fmt.Scanln(&n)

	if n == 1 {
		fmt.Println(0)
		return
	}

	p := primeFactorization(n)

	var prod int
	for _, v := range p {
		c := 1
		for v.count-c >= 0 {
			v.count -= c
			prod++
			c++
		}
	}
	fmt.Println(prod)
}


Measured memory_bytes: 1776
def main():
    N, M = map(int, input().split())
    cnt = [0] * N
    for _ in range(M):
        a, b = map(int, input().split())
        cnt[a-1] += 1
        cnt[b-1] += 1
    for i in range(N):
        if cnt[i] % 2 == 1:
            print("NO")
            return
    print("YES")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3828
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*, ops::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,q:usize,
      mut   stx:[(i64,i64,i64);n],
        d:[i64;q],
    }
    let mut rng = vec![];
    for (s, t, x) in stx {
        rng.push((s - x, 0, x));
        rng.push((t - x, -1, x));
    }
    for &d in d.iter() {
        rng.push((d, 1, 999999999i64));
    }
    rng.sort();
    let mut st = BTreeSet::new();
    for &(x, typ, val) in rng.iter() {
        if typ == 0 {
            st.insert(val);
        } else if typ == -1 {
            st.remove(&val);
        } else {
            println!(
                "{}",
                if let Some(x) = st.iter().next() {
                    *x
                } else {
                    -1
                }
            );
        }
    }
}


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

int main() {
  // N:都市の数、M:道の数
  int N,M;
  cin >> N >> M;
  
  // 配列：各都市からのびている道の本数
  vector<int> roads(N);
  
  for(int i = 0; i < M; i++){
    // M本の各道が結んでいる都市を取得
    int a,b;
    cin >> a >> b;
    
    // 配列を更新
    roads.at(a - 1)++;
    roads.at(b - 1)++;
  }
  
  for(int i = 0; i < roads.size(); i++){
    cout << roads.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i =0; (int)i<n; i++) 
using namespace std;
 
int main(){
  int N,M; cin >> N >> M; char A[N][N],B[M][M];
  rep(i,N) rep(j,N) cin >> A[i][j];
  rep(i,M) rep(j,M) cin >> B[i][j];
  bool check = false;
  rep(i,N-M+1) rep(j,N-M+1) {
      rep(k,M) rep(l,M) if (B[k][l] != A[i+k][j+l]) goto fail; 
      check = true; goto pass; fail:;
  }
  pass: if (check) cout << "Yes" << endl;
  else cout << "No" << endl;}

Measured memory_bytes: 3596