akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string.h>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;
typedef pair<ll, int> pll;

const ll mod = 1e9 + 7;
const int nmax = 200500;

void add(ll& a, ll b)
{
    a += b;
    if (a >= mod) {
        a -= mod;
    }
}

void mul(ll& a, ll b)
{
    a *= b;
    if (a >= mod) {
        a %= mod;
    }
}

void sub(ll& a, ll b)
{
    a -= b;
    if (a < 0) {
        a += mod;
    }
}

ll binpow(ll a, ll n)
{
    ll ans = 1;
    while (n) {
        if (n & 1) {
            mul(ans, a);
        }
        n >>= 1;
        if (n) {
            mul(a, a);
        }
    }
    return ans;
}

int n, x, y, z;
map<deque<int>, int> m;
vector<deque<int> > v;
vector<int> s;

void f(deque<int>& d, int sum)
{
    m[d] = sz(v);
    v.pb(d);
    s.pb(sum);
    for (int a = 1; a <= 7; ++a) {
        if (sum + a < x + y + z) {
            d.push_back(a);
            f(d, sum + a);
            d.pop_back();
        }
    }
}

bool ok(const deque<int>& d) // false, if can get x, y, z
{
    int pos = sz(d) - 1;
    int sum = 0;
    /*for (int x : d) {
        cout << x << " ";
    }*/
    while (pos >= 0 && sum + d[pos] <= z) {
        sum += d[pos];
        --pos;
    }
    if (sum != z || pos < 0) {
        return true;
    }
    sum = 0;
    while (pos >= 0 && sum + d[pos] <= y) {
        sum += d[pos];
        --pos;
    }
    if (sum != y || pos < 0) {
        return true;
    }
    sum = 0;
    while (pos >= 0 && sum + d[pos] <= x) {
        sum += d[pos];
        --pos;
    }
    return sum != x;
}

int main()
{

    //ifstream cin("input.txt");
    //freopen("input.txt", "r", stdin);

    //ios_base::sync_with_stdio(false);
    //cin.tie(0);

    cin >> n >> x >> y >> z;

    deque<int> d;

    f(d, 0);
    //cout << sz(v) << "\n";
    ll total = binpow(10, n);

    vector<vector<ll> > dp(n + 1, vector<ll>(sz(v)));
    dp[0][0] = 1;

    vector<vector<char> > ans(sz(v), vector<char>(11));
    vector<vector<int> > go(sz(v), vector<int>(11));
    for (int j = 0; j < sz(v); ++j) {
        for (int a = 1; a <= 10; ++a) {
            deque<int> d = v[j];
            d.push_back(a);
            ans[j][a] = ok(d);
            if (ans[j][a]) {
                int sum = s[j] + a;
                while (sum >= x + y + z) {
                    sum -= d.front();
                    d.pop_front();
                }
                go[j][a] = m[d];
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < sz(v); ++j) {
            for (int a = 1; a <= 10; ++a) {
                if (ans[j][a]) {
                    add(dp[i + 1][go[j][a]], dp[i][j]);
                }
            }
        }
    }

    for (int j = 0; j < sz(v); ++j) {
        sub(total, dp[n][j]);
    }
    cout << total << "\n";

}


Measured memory_bytes: 117900
n, m = list(map(int,input().split()))
count = 0
lis = []


for i in range(n):
  lis.append(list(map(int,input().split())))
  lis[i].pop(0)
   
for i in range(m):
  for k in range(n):
    if not i+1 in lis[k]:
      break
  else:
    count += 1

print(count)

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

using ui_vec = std::vector<unsigned int> ;

int main()
{
    constexpr unsigned int MOD = 998'244'353 ;

    //inputs
    unsigned int N, S ;
    std::cin >> N >> S ;

    ui_vec A(N + 1, 0) ;
    for(unsigned int i = 1 ; i <= N ; i ++) {
        std::cin >> A[i] ;
    }

    std::vector<ui_vec> dp(N + 1, ui_vec(S + 1, 0)) ;
    dp[0][0] = 1 ;

    for(unsigned int i = 1 ; i <= N ; i ++) {
        for(unsigned int s = 0 ; s <= S ; s ++) {
            dp[i][s] += 2 * dp[i - 1][s] ; //pull above

            if(s >= A[i]) {
                dp[i][s] += dp[i - 1][s - A[i]] ; // pull left upper
            }

            dp[i][s] %= MOD ;
        }
    }

    std::cout << dp[N][S] << std::endl ;
    return 0 ;
}

Measured memory_bytes: 38616
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]
INF = 10 ** 18
dist = [INF] * (N + 1)
dist[1] = 0
for _ in range(N):
    for a, b, c in edges:
        dist[b] = min(dist[b], dist[a] - c)

ans = dist[N]
for a, b, c in edges:
    dist[b] = min(dist[b], dist[a] - c)

if ans != dist[N]:
    print('inf')
else:
    print(-ans)

Measured memory_bytes: 48600
#入力された値の格納,及び変数の設定
N = int(input())
A = list(map(int, input().split()))
n = 0
cont = True

while cont == True:
    for i in range(N):
        if A[i]%2 == 0:
            A[i] = A[i]/2
            if i == N-1:
                n = n+1
        else:
            cont = False
            break

print(n)

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


class UnionFindTree{
private:
  // indexの数の親ノード(ある集合の親を見つけたいときはここを直接参照せず、findを使う)
  vector<int> par;
  // indexを根とする木のランク
  vector<int> rank;
  // 集合のサイズ
  vector<int> cnts;
  // 木の最大値
  int treeSize;
public:
  UnionFindTree(int initTreeSize = 1000){
    // 引数で与えられた値を最大格納数とするUnionFindTreeの作成
    treeSize = initTreeSize;
    init(initTreeSize);
  }
  void init(int sz){
    par.clear(),rank.clear(),cnts.clear();
    treeSize=sz;
    for(int i = 0; i < sz; i++){
      par.push_back(i);
      rank.push_back(0);
      cnts.push_back(1);
    }
  }
  // 与えられた数が格納されている木のルートを探索
  int find(int x){  
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
  }
  // 和集合をとる。ただしここでは各集合の親の付け替えは起こらない
  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      par[x] = y;
      cnts[y]+=cnts[x];
    }
    else{
      par[y] = x;
      cnts[x]+=cnts[y];
      if(rank[y] == rank[x])rank[x]++;
    }
  }
  // xの属する集合のサイズ
  int getCnt(int x){
    return cnts[find(x)];
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
    
};


int N, M;
int P[100010];
int X[100010];
int Y[100010];

int main(){
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> P[i];
        P[i]--;
    }
    for(int i = 0; i < M; i++){
        cin >> X[i] >> Y[i];
        X[i]--;
        Y[i]--;
    }
    UnionFindTree uft(N);
    for(int i = 0; i < M; i++) {
        uft.unite(X[i], Y[i]);
    }

    map<int, set<int> > m;
    for(int i = 0; i < N; i++){
        m[uft.find(i)].insert(i);
    }
    
    int ans = 0;
    for(auto &it : m){
        set<int> &s = it.second;
        for(int idx : s){
            if(s.count(P[idx])){
                ans++;
            }
        }
    }
    cout << ans << endl;
    


}


Measured memory_bytes: 16620
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

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

  long int ans = 0;
  for (int bit = 0; bit < 1 << ((int)str.size() - 1); bit++) {
    long int sum = 0;
    long int num = str[0] - '0';
    for (int i = 0; i < (int)str.size() - 1; ++i) {
      if (bit & (1 << i)) {
        sum += num;
        num = 0;
      }
      num = num * 10 + str[i + 1] - '0';
    }
    sum += num;
    ans += sum;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		String b = s.next();
		
		String result = null;
		
		switch(b) {
		case "A":
			result = "T";
			break;
		case "C":
			result = "G";
			break;
		case "G":
			result = "C";
			break;
		case "T":
			result = "A";
			break;
		}
		
		System.out.println(result);
		s.close();
		
	}

}

Measured memory_bytes: 22100
n = int(input())
*a, = map(int,input().split())
box = [0]*n
for i in range(n,0,-1):
    sum_box = 0
    for j in range(i,n+1,i):
        sum_box+=box[j-1]
    if sum_box%2!=a[i-1]:
        box[i-1]+=1

print(sum(box))
if sum(box):
    ans = []
    for i, x in enumerate(box):
        if x:
            ans.append(i+1)
    print(*ans)

Measured memory_bytes: 14132
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#ifdef DEBUG
#define debug(x) cerr << #x << " " << x << '\n'
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
int n, cnt;
char s[N], t[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> (s+1);
 	for(int i=1;i<=n;)
 	{
 		int j = i + 1;
 		while(j<=n&&s[j]==s[i]) j++;
 		t[++cnt] = s[i];
 		i = j;
 	}
 	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}


void oneCase () {
    int n, ma, mb;
    cin >> n >> ma >> mb;

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

    for (int i = 0; i < n; ++i) {
        int x, y, z;
        cin >> x >> y >> z;

        a[i] = x;
        b[i] = y;
        c[i] = z;
    }

    auto maxWeight = n * 10;
    vector<vector<int>> dp(maxWeight + 1, vector<int>(maxWeight + 1, 1e9));

    for (int i = 0; i < n; ++i) {
        auto ndp = dp;
        auto x = a[i];
        auto y = b[i];
        for (int l = 1; l <= maxWeight - x; ++l) {
            for (int r = 1; r <= maxWeight - y; ++r) {
                ndp[x + l][y + r] = min(ndp[x + l][y + r], dp[l][r] + c[i]);
            }
        }
        ndp[x][y] = min(ndp[x][y], c[i]);
        swap(dp, ndp);
    }

    int best = 1e9;
    int x = 0;
    int y = 0;

    while (true) {
        x += ma;
        y += mb;
        if (max(x, y) > maxWeight) {
            break;
        }
        best = min(best, dp[x][y]);
    }
    if (best == 1e9) {
        best = -1;
    }
    cout << best << "\n";
}





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

    return 0;
}

Measured memory_bytes: 1588
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
# define M_PI 3.14159265358979323846
int main(){

    double  H,M;
    double A,B;
    cin>>A>>B>>H>>M;
    double angle = H*30-M*5.5;
    if(angle>180)
        angle= 360-angle;
    double  length;
    length=pow(A,2)+pow(B,2)-2*A*B*cos(angle*M_PI/180.0);
    length= sqrt(length);
    cout<< fixed<<setprecision(16)<< length;

}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
  string s;cin >> s;
  int a=0,b=0;
  REP(i,s.size())(s[i]=='0'?a:b)+=1;
  cout<<2*min(a,b)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;
int N;
const int MAX_N = 100;
int a[MAX_N];

void solve() {
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans = max(ans, a[j] - a[i]);
		}
	}
	cout << ans << endl;
}

int main(void) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	solve();
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  cout << N * (N-1) / 2 - N / 2 << endl;
  for (int i=1; i<=N-1 ;i++) {
    for (int j=i+1; j<=N; j++) {
      if (i+j != N + (N+1) % 2) {
        cout << i << " " << j << endl;
      }
    }
  }
  
}


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

int hoge(int w);
int getKetasu(int n);

int main(){
	int w;
	
	while(1){
	 cin>>w;
	 if(w==0){break;}
	 hoge(w);
	}
	
	return 0;
}

int hoge(int w){	//?????£???????????????
	int t[100][100];
	int x,y,i;
	
	for(y=0;y<w;y++){
	 for(x=0;x<w;x++){
	  cin>>t[x][y];
	 }
	}
	
	for(y=0;y<w;y++){
	 t[w][y]=0;
	 for(x=0;x<w;x++){
	  t[w][y]+=t[x][y];
	 }
	}
	for(x=0;x<=w;x++){
	 t[x][w]=0;
	 for(y=0;y<w;y++){
	  t[x][w]+=t[x][y];
	 }
	}
	
	for(y=0;y<=w;y++){
	 for(x=0;x<=w;x++){
	  for(i=getKetasu(t[x][y]);i<5;i++){cout<<" ";}
	  cout<<t[x][y];
	 }
	 cout<<endl;
	}
	
	return 0;
}

int getKetasu(int n){	//?????°?????????
	if(n<10){
	 return 1;
	}else if(n<100){
	 return 2;
	}else if(n<1000){
	 return 3;
	}else if(n<10000){
	 return 4;
	}else{
	 return 5;
	}
}

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

using namespace std;

int n;
int max_gap;
vector<long long> a;

long long used[3][200002];
long long dp[3][200002];

long long calc(int gap, int idx) {
    if (idx < 0) return 0;
    if (used[gap][idx]) return dp[gap][idx];
    long long ans = - (1LL << 60);
    for (int i = 0; i <= gap; i++) {
        ans = max(ans, a[idx] + calc(gap - i, idx - 2 - i));
        if (i != 0) ans = max(ans, calc(gap - i, idx - i));
    }
    used[gap][idx] = true;
    return dp[gap][idx] = ans;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        long long x;
        cin >> x;
        a.push_back(x);
    }
    max_gap = n % 2 == 0 ? 1 : 2;
    
    cout << calc(max_gap, n - 1) << endl;
    return 0;
}

Measured memory_bytes: 22088
def bfs(s):
    que = [s]
    used[s] = True
    while que:
        u = que.pop(0)
        ans.append(u)

        for v in G[u]:
            indeg[v] -= 1
            if indeg[v] == 0 and not used[v]:
                used[v] = True
                que.append(v)

def tsort():
    for u in xrange(V):
        if indeg[u] == 0 and not used[u]:
            bfs(u)

V, E = map(int, raw_input().split())
indeg = [0] * V
used = [False] * V
G = [[] for i in xrange(V)]
ans = []

for i in xrange(E):
    s, t = map(int, raw_input().split())
    indeg[t] += 1
    G[s].append(t)

tsort()
for i in ans:
    print i

Measured memory_bytes: 6864
#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; 
//order_of_key(k)= # of items strictly smaller than 'k'  //find_by_order(x)= iterator to x'th largest element (counting from ZERO) //erase("iterator") [log(n)] //end(<name>)
//os.find_by_order(os.order_of_key(x)=iterator to 'x' in the rb tree
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("O3")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef priority_queue<ll> pq;                                        //min-heap-> multiply the values by '-1'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for (ll i = a; i < b; i++)
#define test ll t;cin>>t;while(t--)
#define summ(a,n) accumulate(a,a+n,0)
#define bsrch(v,n) lower_bound(v.begin(), v.end(), n)
#define minindex(v) distance(v.begin(),min_element(v.begin(),v.end()))         //returns index of minimum(/max) element in the vector
#define bp(x) _builtin_popcount(x)
#define inf 1000000000000
#define PI = 3.1415926535897932384626
#define mod 1000000007

bool dp[100001];

int main()
{
    ll n,k; cin>>n>>k;
    ll a[n];
    forr(i,0,n) cin>>a[i];
    
    forr(i,1,k+1)
    {
        forr(j,0,n) if(i>=a[j] && dp[i-a[j]]==0) {dp[i]=1;break;}
    }
//forr(i,0,k+1) cout/*<<i<<"-"*/<<dp[i]<<" "; cout<<endl;
    if(dp[k]) cout<<"First";
    else cout<<"Second";
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int x;
  cin >> x;
  if(x%100 <= x/100*5) cout<< 1 <<endl;
  else cout<< 0 <<endl;

}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split(' ');
        var n = int.Parse(ab[0]) + int.Parse(ab[1]);

        if (n % 2 == 0)
        {
            Console.WriteLine(n / 2);
        }
        else
        {
            Console.WriteLine(n / 2 + 1);
        }
    }
}

Measured memory_bytes: 11092
package main

import "fmt"

const (
	maxBufferSize     = 2000000 // check
	initialBufferSize = 20000
)

func solve() {
	//	sc := bufio.NewScanner(os.Stdin)
	//	buffer := make([]byte, initialBufferSize)
	//	sc.Buffer(buffer, maxBufferSize)
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	ans := false
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			p[i], p[j] = p[j], p[i]
			able := true
			for k := 0; k+1 < n; k++ {
				if p[k] > p[k+1] {
					able = false
					break
				}
			}
			if able {
				ans = true
				break
			}
			p[i], p[j] = p[j], p[i]
		}
	}

	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {
	solve()
}


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

int main() {
  ll n;cin >> n;
  vector<ll> e(100001,0);
  vector<ll> o(100001,0);

  ll emax = -1;
  ll omax = -1;
  ll eid = -1;
  ll oid = -1;
  rep(i,n){
    ll num;cin >> num;
    if( i%2 == 0 ){
      o.at(num)++;
      if( omax < o.at(num) ){
        omax = max(omax,o.at(num));
        oid = num;
      }
    }else{
      e.at(num)++;
      if( emax < e.at(num) ){
        emax = max(emax,e.at(num));
        eid = num;
      }
      
    }
  }
  sort(o.begin(),o.end());
  sort(e.begin(),e.end());

  ll e1 = e.back();
  ll e2 = e.at(e.size()-2);
  ll o1 = o.back();
  ll o2 = o.at(o.size()-2);

  if( eid != oid ){
    cout << n - e1 - o1 << endl;
  }else{
    cout << min((n - e1 - o2),(n - e2 - o1 ) ) << endl;
  }
  
  return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  set<string> l[4];
  l[0].insert("");
  for (auto& c : s) {
    for (int i = 2; i >= 0; i--) {
      for (auto& pre : l[i]) {
        l[i + 1].insert(pre + c);
      }
    }
  }
  cout << l[3].size() << '\n';
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
unsigned long xor_x=88172645463325252ULL;
unsigned long rng()
{
	xor_x^=xor_x<<7;
	return xor_x^=xor_x>>9;
}
int D;
int c[26],s[365][26];
int t[365],now;
int anst[365],ans;
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		now+=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)now-=c[j]*(i-lst[j]);
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	{
		int lst[26];
		for(int i=0;i<26;i++)lst[i]=-1;
		for(int i=0;i<D;i++)
		{
			int x=-1,tc=-1e9;
			for(int j=0;j<26;j++)
			{
				int u=s[i][j];
				for(int k=0;k<26;k++)
				{
					if(j!=k)u-=c[k]*(i-lst[k]);
				}
				if(tc<u)
				{
					tc=u;
					x=j;
				}
			}
			now+=tc;
			t[i]=x;
			lst[x]=i;
		}
	}
	ans=now;
	for(int tm=0;tm<3000;tm++)
	{
		while(true)
		{
			int d=rng()%D,q=rng()%26;
			int ret=change(d,q);
			if(rng()%2000>tm||ret>=0)
			{
				now+=ret;
				t[d]=q;
				break;
			}
		}
		for(int k=0;k<3000;k++)
		{
			int d1=rng()%(D-1)+1,d2=rng()%d1;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
		if(ans<=now)
		{
			ans=now;
			for(int i=0;i<D;i++)anst[i]=t[i];
		}
		else if(rng()%2000<tm)
		{
			now=ans;
			for(int i=0;i<D;i++)t[i]=anst[i];
		}
	}
	for(int i=0;i<D;i++)cout<<anst[i]+1<<endl;
	cerr<<ans<<endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
using namespace std;

const double PI=acos(-1);

int main(){
    int a, b;
    string s;
    cin >> a >> b >> s;
    bool z = true;
    for(int i = 0; i < s.length(); i++){
        if(i == a){
            if(s[i] != '-'){
                z = false;
                break;
            }
        }else{
            if(s[i] == '-'){
                z = false;
                break;
            }
        }
    }

    if(z) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main(void)
{
  long int n, k,a,b;
  
  cin >> n >> k;
  
  a = n%k;
  if(a<0)	a = -a;
  b = k-(n%k);
  if(b<0)	b = -b;
  
  
  if(a < b){
    cout << a << endl;
  }
  else{
    cout << b << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

vector<int> cand;

bool isAcyclicDFS(vector<vector<int>> &g, vector<int> &used, int v) {
    cand.push_back(v);
    used[v] = 1;
    for (auto u: g[v]) {
        if (used[u] == 1) {
            cand.push_back(u);
            return false;
        }
        if (used[u] == 0) {
            if (isAcyclicDFS(g, used, u) == false) return false;
        }
    }
    used[v] = 2;
    assert(cand.back() == v);
    cand.pop_back();
    return true;
}
bool isAcyclic(vector<vector<int>> &g) {
    int n = g.size();
    vector<int> used(n, 0);
    for (int i = 0; i < n; ++i) {
        if (used[i] == 0 && isAcyclicDFS(g, used, i) == false) {
            return false;
        }
    }
    return true;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
    }

    if (isAcyclic(g)) {
        cout << -1 << endl;
        return 0;
    }

    int s = cand.back(); cand.pop_back();
    vector<int> ci(n, -1);
    for (int i = 0; i < cand.size(); ++i) {
        ci[cand[i]] = i;
    }

    vector<int> ans;
    int cur = find(cand.begin(), cand.end(), s) - cand.begin();
    while (true) {
        ans.push_back(cur);
        int v = cand[cur];
        int dst = -1;
        int bdst = -1;
        for (auto u: g[v]) {
            if (ci[u] == -1) continue;
            if (ci[u] < cur) {
                if (binary_search(ans.begin(), ans.end(), ci[u])) {
                    bdst = max(bdst, ci[u]);
                }
            } else {
                dst = max(dst, ci[u]);
            }
        }
        if (bdst != -1) {
            auto it = lower_bound(ans.begin(), ans.end(), bdst);
            cout << ans.end() - it << endl;
            for (; it != ans.end(); ++it) {
                cout << cand[*it]+1 << endl;
            }
            return 0;
        }
        cur = dst;
    }

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>
#include<math.h>

#define MAX_DIG (1000000007ull)

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nBuf,int N){
    char *buf,*ptr;

    buf=(char*)malloc(nBuf*sizeof(char));
    my_gets(buf,nBuf,stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

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

uint64_t Comb[3001][3001]={{1}};

uint64_t CalcComb(int n,int k){
    if(k==0)
        return 1;

    if(n < 2*k)
        return CalcComb(n,n-k);
    if(Comb[n][k]!=0)
        return Comb[n][k];
    
    
    return ( Comb[n][k]= ((CalcComb(n-1,k)+CalcComb(n-1,k-1)) % MAX_DIG) );
}

int main(){
    int N,K;

    scanf("%d %d%*c",&N,&K);
    
    int tmp =((K) < (N-K+1)) ? (K) : (N-K+1);

    for(int i=0; i<=tmp; i++){
        CalcComb(K,i);
    }
    for(int i=0; i<=tmp; i++){
        CalcComb(N-K+1,i);
    }

    for(int i=1; i<=K; i++){
        if(i<=tmp){
            printf(
                "%llu\n",
                (CalcComb(K-1,i-1)*CalcComb(N-K+1,i))%MAX_DIG
            );
        }
        else{
            puts("0");
        }
    }
    return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector< ii > vii;
typedef long long LL;
int arr[105];
int main()
{
	int n; scanf("%d", &n);
	for(int i = 0; i< 2*n; i++) scanf("%d", arr+i);
	sort(arr, arr+2*n);
	int res = 0;
	for(int i = 0; i< 2*n; i+= 2) res += arr[i];
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
data_list = [ list(map(int,input().split(" "))) for i in range(3)]
n = int(input())
b_list = []
for _ in range(n):
    b_list.append(int(input()))



for k in range(n):
    for i in range(3):
        for j in range(3):
            if data_list[i][j] == b_list[k]:
                data_list[i][j] = -1

ans = []

for i in range(3):
    s = data_list[i]
    ans.append(sum(s))

for i in range(3):
    s = data_list[0][i] + data_list[1][i] + data_list[2][i]
    ans.append(s)

ans.append(data_list[0][0] + data_list[1][1] + data_list[2][2])
ans.append(data_list[0][2] + data_list[1][1] + data_list[2][0])

if ans.count(-3) != 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static final int MAX = 2 << 15;
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 1; ; i++){
			final int s = i * i;
			if(s > MAX){
				break;
			}
			
			list.add(s);
		}
		
		final int size = list.size();
		int[] count = new int[MAX+1];
		
		for(int i = 0; i < size; i++){
			final int v1 = list.get(i);
			count[v1]++;
			
			for(int j = i; j < size; j++){
				final int v2 = v1 + list.get(j);
				
				if(v2 > MAX){
					break;
				}
				
				count[v2]++;
				
				for(int k = j; k < size; k++){
					final int v3 = v2 + list.get(k);
					
					if(v3 > MAX){
						break;
					}
					
					count[v3]++;
					
					for(int l = k; l < size; l++){
						final int v4 = v3 + list.get(l);
						
						if(v4 > MAX){
							break;
						}
						
						count[v4]++;
					}
				}
			}
		}
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			System.out.println(count[n]);
			
		}
	}

}

Measured memory_bytes: 23372
#include<stdio.h>
int main(){
  int x,y,i;
  while(1){
  scanf("%d %d",&x,&y);
  if(x==0 && y==0)break;
  if(x>y){
    i=x;
    x=y;
    y=i;
  }
  printf("%d %d\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 


int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
			
	ll a;
	string s;
	
	cin>>a>>s;
	
	ll ans = 0;
	
	ans += a*(s[0]-'0');
	
	ll fr = 0;
	if(s.size()>=3)
	{
		ll val = a*(s[2]-'0');
		fr = (val%10)*10;
		ans += val/10;
	}
	
	if(s.size() >= 4)
	{
		ll val = a*(s[3]-'0');
		ans += val/100;
		fr += (val%100);
	}
	
	ans += fr/100;
	
	cout<<ans<<endl;
	
}



























Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=a+b-c-d;
    if(x>0)cout<<"Left"<<endl;
    else if(x<0)cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)

using namespace std;

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

    ll n, d, r = 0;

    cin >> n >> d;

    vector < vector < ll > > v(n, vector < ll >(d));

    forn(i, n)
        forn(j, d)
            cin >> v[i][j];

    forn(i, n)
    {
        fore(j, (i + 1), (n - 1))
        {
            ll s = 0;

            if(i != j)
            {
                forn(k, d)
                {
                    s += ((v[i][k] - v[j][k]) * (v[i][k] - v[j][k]));
                }
            }

            r += (ceil(sqrt(s)) == floor(sqrt(s)));
        }
    }

    cout << r << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dp[100010];
int main() {
    int n;
    dp[0]=0;
    for(int n=1;n<=100000;n++){
        dp[n]=INF;
        int power=1;
        while(power<=n){
            dp[n]=min(dp[n],1+dp[n-power]);
            power*=6;
        }
        power=1;
        while(power<=n){
            dp[n]=min(dp[n],1+dp[n-power]);
            power*=9;
        }
    }
    int N;
    cin>>N;
    cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 640
H, W = gets.split(" ").map(&:to_i)
masu = []
H.times do 
    tmp = gets.chomp.split("")
    if tmp.count(".") != tmp.size
        masu << tmp
    end
end
if masu.size > 1
    masu = masu.transpose
    W.times do |i|
        if masu[i].count(".") == masu[i].size
            masu[i] = "x"
        end
    end
    masu.delete("x")
    
    masu = masu.transpose.map{|x| x.join()} 
    puts masu
else
    masu.flatten!
    masu.delete(".")
    puts masu.join()
end


Measured memory_bytes: 2428
N=int(input())
lineup=sorted([int(x) for x in input().split()])
duplicate={}
for i in lineup:
	if i in duplicate:
		duplicate[i]+=1
	else:
		duplicate[i]=1
b=max(lineup)+1
sieve=[1]*(b)
counter=0
for i in range(N):
	for j in range(lineup[i]*2,b,lineup[i]):
		sieve[j]=0
	if duplicate[lineup[i]]==1 and sieve[lineup[i]]==1:
		counter+=1
print(counter)

Measured memory_bytes: 130116
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, m, d) = get!(f64, f64, i32);
    if d == 0 {
        let ans = 1.0 / n * (m - 1.0);
        println!("{}", ans);
        return;
    }
    let ans = 2.0 * (n - d as f64) / n / n * (m - 1.0);
    println!("{}", ans);
}


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

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

  int N; cin >> N;
  string S; cin >> S;
  ll ans = 0;
  for (int i = 0; i < N - 2; i++) {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
    long long X,A=0,B=0;
    cin >> X;

    for(long long i = -500; i < 500; i++){
        for(long long j= -500; j < 500; j++){

            if(X == (i * i * i * i * i) - (j * j * j * j * j)){
                A = i;
                B = j;
            }
        }
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define INF 9999999

int main()
{
	string s;
	cin >> s;
	if (s.length() == 2)
	{
		if (s[0] == s[1])cout << "1 2" << endl;
		else cout << "-1 -1" << endl;
	}
	else
	{
		bool ans = false;
		loop(i, s.length() - 2)
		{
			if ((s[i] == s[i + 1] && s[i] != s[i + 2]) || (s[i] == s[i + 2] && s[i] != s[i + 1]) || (s[i + 1] == s[i + 2] && s[i] != s[i + 1]))
			{
				cout << i + 1 << " " << i + 3 << endl;
				ans = true;
			}
			if (ans)break;
		}
		if (!ans)cout << "-1 -1" << endl;
	}
}

Measured memory_bytes: 512
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    long[string] cnt;
    foreach (_; 0 .. N)
    {
        auto s = sread();
        cnt[s] = cnt.get(s, 0) + 1;
    }
    auto K = cnt.keys;
    auto V = K.map!((k) => cnt[k]).array;

    zip(V, K).sort!(less)();
    foreach (i; 0 .. V.length)
    {
        if (V[i] != V[0])
            return;
        writeln(K[i]);
    }
}

bool less(Tuple!(long, string) a, Tuple!(long, string) b)
{
    if (a[0] == b[0])
        return a[1] < b[1];
    return b[0] < a[0];
}


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

namespace Repetitive_Processing
{
    class How_Many_Divisors
    {
        static void Main(string[] args)
        {
            var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var count = 0;
            for (int i = token[0] ; i <= token[1] ; i++)
            {
                if (token[2] % i == 0) count++;
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 9588
#pragma GCC diagnostic error "-std=c++14"
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cctype>
using namespace std;
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
void print(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)print(x/10);
	putchar(x%10+48);
}
int a[200005];
int main()
{
	int n=read(n);
	for(int i=1;i<=n-1;i++){
		int x=read(x);
		a[x]++;
	}
	for(int i=1;i<=n;i++)printf("%d\n",a[i]);
	return 0;
}



Measured memory_bytes: 2360
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  k=I()
  st=7
  if k==1 or k==7:
    return 1
  for i in range(1,1000001):
    st+=7*pow(10,i,k)
    st%=k
    if st==0:
      return i+1

  return -1

# main()
print(main())


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

using namespace std;

int32_t get_num_32(void){
    int32_t x;
    scanf("%d",&x);
    return x;
}


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    N = get_num_32();
    int i;
    int n=0;
    for(i=0;i<=N;i++){
        n += i;
        if(n >= N){
            break;
        }
    }
    //cout << "n-N" << n-N << endl;
    if(n == N){
        for(int j =1;j<=i;j++){
            printf("%d\n",j);
        }
        return 0;
    }
    int s = n - N;
    for(int j =1;j<=i;j++){
        if(j == s){
            continue;
        }
        printf("%d\n",j);
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
int main()
{
    int n, m, a, b, ans, cnt = 0;
    cin >> n >> m;
    //n頂点0辺の無向グラフを作成
    dsu d(n);
    vector<int> vec(n, 0);

    //辺a,bを連結
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        --a;
        --b;
        d.merge(a, b);
    }
    for (int i = 0; i < n; i++)
    {
        vec.at(d.leader(i)) = 1;
        if (vec.at(i) == 1)
        {
            cnt++;
        }
    }
    ans = cnt - 1;
    cout << ans;
    return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main(){
   int n,k;
   cin>>n>>k;
   int arr[n]={0};
   for(int i=0;i<n;i++){
	   cin>>arr[i];
   }
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j] = min(dp[j] , abs(arr[j]-arr[i])+dp[i]);
            }
        }
    }
    cout<<dp[n-1];
	return 0;
}

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

typedef long long ll;

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

    int n; cin >> n;
    vector<int> a(n+2);
    a[0] = a[n+1] = 0;
    ll sum = 0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        sum += abs(a[i-1]-a[i]);
    }
    sum += abs(0-a[n]);
    for(int i=1;i<=n;i++){
        cout << sum - (abs(a[i-1]-a[i])+abs(a[i]-a[i+1])) + abs(a[i-1]-a[i+1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string Yes(bool f) {return (f) ? "Yes" : "No";}
string YES(bool f) {return (f) ? "YES" : "NO";}
int main () {
    ll N, A, B;
    cin >> N >> A >> B;
    ll a = N % (A+B);
    ll res = (N/(A+B))*A;
    if (a <= A) {
        res += a;
    }
    else {
        res += A;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int w, a, b;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> w >> a >> b;
	if (a > b) swap(a, b);
	cout << max(0, b-a-w) << endl;
	return 0;
}

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

int main(){
	int n, ans = 0;
	char tmp[101];
	string name;
	scanf("%d %s", &n, tmp);
	name = tmp;
	for(int i=0; i<n; i++){
		scanf("%s", tmp);
		string sign;
		sign = tmp;
		bool b = false;
		for(int j=1; 1 + j * (name.size() - 1) <= sign.size(); j++){
			for(int k=1; k + (name.size()-1) * j <= sign.size(); k++){
				string temp;
				for(int l=0; l<name.size(); l++){
					temp += sign.substr(k-1+j*l, 1);
				}
//				printf("%s ", temp.c_str());
				if(name == temp) b = true;
			}
		}
		if(b) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1080
using System;

namespace rensyuu1
{
    class Program
    {
        static void Main(string[] args)
        {
            string pp = Console.ReadLine();
            string[] ss = pp.Split(new char[] { ' ' });
            int x = int.Parse(ss[0]);
            int y = int.Parse(ss[1]);
            int z = int.Parse(ss[2]);
            int c = 0;

            while (true)
            {
                if(x>y)
                {
                    Console.WriteLine("{0}",c);
                    break;
                }
                
                else if( z % x == 0)
                {
                    c++;
                }
                x++;

            }
        }
    }
}


Measured memory_bytes: 17996
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;
 
}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
 
	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
 
int main() {
	int N, M;
	cin >> N >> M;
	int s[31][31] ={};
	for (int i = 0; i < N; i++) {
		int k = 0;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int b;
			cin >> b;
			s[i][b] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 0; j < N; j++) {
			if (s[j][i] != 1) {
				break;
			}
			if (j == N - 1) {
				ans++;
			}
		}
	}
	cout << ans;
}

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

int main(int argc, char const *argv[])
{
    int i,n;
    i = 1;
    while(1) {
        cin >> n;
        if (n==0)
        {
            break;
        }
        cout << "Case " << i <<": " << n << endl;
        i++;
    }
    return 0;
}

Measured memory_bytes: 1164
N = int(input())
A = list(map(int, input().split()))
X = [0] * N
 
X[0] = sum(A) - 2 * (sum([A[i] for i in range(N) if i % 2 == 1]))
 
for i in range(N - 1):
    X[i + 1] = 2 * A[i] - X[i]
 
print(" ".join(map(str, X)))

Measured memory_bytes: 19144
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int main(void) {

	int d, n, tmp;

	cin >> d >> n;

	if (n != 100)tmp = int(pow(100, d))*n;
	else tmp = int(pow(100, d))*(n + 1);

	cout << tmp << "\n";

	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':

	n = int(input())
	A = list(map(int,input().split()))

	cnt = 0
	for i in range(n):
		for j in range(i+1,n):
			for k in range(j+1,n):
				if A[i] != A[j] and A[j] != A[k] and A[i] != A[k]:
					if A[i] + A[j] > A[k] and A[j] + A[k] > A[i] and A[k] + A[i] > A[j]:
						cnt += 1
	print(cnt)

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

const string YES = "YES";

const string NO = "NO";

void solve(int A, int V, int B, int W, int T)
{
    int64_t d = abs(A - B);
    if (V - W <= 0)
    {
        cout << NO << endl;
        return;
    }
    int64_t v = V - W;
    if (v * T < d)
        cout << NO << endl;
    else
        cout << YES << endl;
}

int main()
{
    int A;
    cin >> A;
    int V;
    cin >> V;
    int B;
    cin >> B;
    int W;
    cin >> W;
    int T;
    cin >> T;
    solve(A, V, B, W, T);
    return 0;
}


Measured memory_bytes: 3676
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <stdlib.h>
#include <functional>
#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int N = 1e5 + 10;
int n;
ll a[10010], b[10010];

int main() {
	int i;
	scanf("%d", &n);
	ll keep1, keep2;

	keep1 = 0, keep2 = 0;
	for (i = 0; i < n; ++i) {
		scanf("%lld", &a[i]);
	}
	for (i = 0; i < n; ++i) {
		scanf("%lld", &b[i]);
	}
	for (i = 0; i < n; ++i) {
		if (a[i] == b[i]) continue;
		if (a[i] > b[i]) {
			if (keep1 <= (a[i] - b[i])) {
				b[i] += keep1;
				keep1 = 0;
			}
			else {
				keep1 -= (a[i] - b[i]);
				continue;
			}
			keep2 += (a[i] - b[i]);
		}
		else {
			if (keep2 <= (b[i] - a[i]) / 2) {
				a[i] += 2 * keep2;
				keep2 = 0;
			}
			else {
				keep2 -= ((b[i] - a[i])/2);
				continue;
			}
			keep1 += (b[i] - a[i])/2;
		}
	}
	
	if (2 * keep2 > keep1) printf("No\n");
	else printf("Yes\n");

}

Measured memory_bytes: 384