akhauriyash/Code-Regression huggingface dataset:
def fuctorial(n):
    ret = 1
    while n > 0:
        ret *= n
        n -= 1
    return ret

def combination(n, k, MOD):
    return (fuctorial(n) // (fuctorial(n-k) * fuctorial(k)))%MOD


def main():
    N, K = map(int, input().split())
    MOD = 10**9+7
    for i in range(1, K + 1):
        if i > N - K + 1:
            print(0)
        else:
            print(combination(N - K + 1, i,MOD) * combination(K - 1, i - 1,MOD) % MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
/*
 *Team hhu_6814
 *Author big_yellow_doge
 */
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <set>
#include <list>
using namespace std;
//ios::sync_with_stdio(false);
const int MINF = 0x7fffffff;
const int INF = 0x3f3f3f3f;
const int Maxn = 1e5+5;
typedef long long ll;

int main()
{
    ll k,a,b,ans=1;
    scanf("%lld%lld%lld",&k,&a,&b);
    if(b-a<=2) printf("%lld\n",k+ans);
    else{
        if(ans < a&&ans+k>a+1){
            k-=a-ans,ans=a;
        }
        if(ans>=a){
            ans+=(b-a)*(k/2);
            ans+=k&1;
        }
        if(ans<a) ans+=k;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MID (l+r)/2
#define ll long long
typedef pair<ll, ll> ii;
#define S second
#define F first

ll seg[1000000];
ll n, k;

void update(ll p, ll l=0, ll r=n-1, ll ind=1){
	if(l==r && l==p)
		seg[ind]++;
	else if(l==r || p<l || p>r) return;
	else{
		update(p, l, MID, ind*2);
		update(p, MID+1, r, ind*2+1);
		seg[ind] = seg[ind*2] + seg[ind*2+1];
	}
}

ll query(ll rl, ll rr, ll l=0, ll r=n-1, ll ind=1){
	if(rl<=l && r<=rr) return seg[ind];
	else if(rl>r || l>rr) return 0;
	else{
		return query(rl, rr, l, MID, ind*2) + query(rl, rr, MID+1, r, ind*2+1);
	}
}

int main(){
	cin>>n>>k;
	ll a[n];
	ll tot=0;
	ll t[n+1];
	vector<ii> s;
	//s.push_back(ii(0,0));
	for(ll i=0;i<n;i++){
		cin>>a[i];
		tot+=a[i];
		tot-=k;
		t[i] = tot;
		s.push_back(ii(t[i], i));
	}
	sort(s.begin(), s.end());
	ll ans=0;
	for(ll i=s.size()-1;i>=0;i--){
		if(s[i].F>=0) ans++;
		ans += query(s[i].S + 1, n-1);
		update(s[i].S);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 13676
n=int(input())
v=list(map(int,input().split()))
odd=[[0,0] for i in range(10**5+1)]
even=[[0,0] for i in range(10**5+1)]
for i in range(1,10**5+1):
    odd[i][1]=i
    even[i][1]=i
for i in range(n):
    if (i+1)%2==1:
        odd[v[i]][0]+=1
    else:
        even[v[i]][0]+=1
odd=sorted(odd,reverse=True)
even=sorted(even,reverse=True)
ans=0
if(odd[0][0]+even[0][0]==n): #odd[0][0]=n//2
    if(odd[0][1]==even[0][1]):
        ans=n//2
    else:
        ans=0

else:
    # odd 19,1 even 20,19のときに、(1+20)=21よりも(19+19)=38のほうがいいい。
    if(odd[0][1]==even[0][1]):
        if(odd[0][0]+even[1][0]<=odd[1][0]+even[0][0]):
            ans=(n//2-odd[1][0])+(n//2-even[0][0])
        else:
            ans=(n//2-odd[0][0])+(n//2-even[1][0])

    else:
        ans=(n//2-odd[0][0])+(n//2-even[0][0])
print(ans)


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

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a > k) cout << k << endl;
  else if (a + b >= k) cout << a << endl;
  else cout << a - (k - a - b) << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

int fdigit(int n){
	int res;
	while(n>0){
		if(n<10)res=n;
		n/=10;
	}
	return res;
}

int ldigit(int n){
	return n%10;
}

void solve(){
	int n;
	cin>>n;
	v<vi> h(10,vi(10));
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			for(int k=1;k<=n;k++){
				if(fdigit(k)==i && ldigit(k)==j)h[i][j]++;
			}
		}
	}
	int ans=0;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			ans+=h[i][j]*h[j][i];
		}
	}
	cout<<ans<<ln;
}

signed main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 3632
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    DP = [[-10 ** 20] * 2 for _ in range(N)]
    DP[0][0] = A[0]
    DP[0][1] = -1 * A[0]
    for i in range(1, N):
        a = A[i]
        DP[i][0] = max(max(DP[i-1][0] + a, DP[i-1][1] - a), DP[i][0])
        DP[i][1] = max(max(DP[i-1][0] - a, DP[i-1][1] + a), DP[i][1])

    print(DP[N-1][0])

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 25580
#include <stdio.h>
#include  <iostream>
using namespace std;
int abs(int a) {
	return a > 0 ? a : (-a);
}
int n, k, x, sum;
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		sum += (abs(x) < abs(k-x) ? abs(x) : abs(k-x));
	}
	cout << 2*sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
/*input
1 100000
1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	bool dp[k+1];
	memset(dp,false,sizeof(dp));
    dp[0]=true;
    for(int i=0;i<n;i++)
    {
    	dp[arr[i]]=true;
    }
    for(int i=1;i<=k;i++)
    {
    	int count1=0;
    	int c1=0;
    		int c2=0;

    	for(int j=0;j<n;j++)
    	{
    		if(i-arr[j]>0){
    			c1++;
    			if(!dp[i-arr[j]]){
    				dp[i]=true;
    			}
    		}
    	}
    	
    
    }
    // for(int i=0;i<=k;i++)
    // {
    // 	if(dp[i])
    // 	{
    // 		cout<<'F';
    // 	}
    // 	else
    // 	{
    // 		cout<<'S';
    // 	}
    // 
    if(dp[k])
    {
    	cout<<"First";
    }
    else{
    	cout<<"Second";
    }
 }


Measured memory_bytes: 512
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

struct edge {
    int a;
    int b;
    int c;
};

void solve() {
    cini(n);
    vector<set<int>> tree(n);
    vector<edge> edges;
    for(int i=0; i<n-1; i++) {
        cini(a);
        cini(b);
        a--;
        b--;
        edges.push_back({a,b,-1});
        tree[a].insert(i);           
        tree[b].insert(i);
    }

    int maxCol=0;

/* pedge edge to parent, which is colored. */
    function<void(int,int)> dfs=[&](int node, int pedge) {
        int c=1;
        int pc=pedge>=0?edges[pedge].c:-1;
        for(int idx : tree[node]) {
            if(idx==pedge)
                continue;

            int chl;
            if(edges[idx].a==node)
                chl=edges[idx].b;
            else 
                chl=edges[idx].a;
            if(c==pc)
                c++;
            edges[idx].c=c;
            maxCol=max(maxCol,c);
            c++;
            dfs(chl,idx);
        }
    };

    dfs(0,-1);

    cout<<maxCol<<endl;
    for(int i=0; i<n-1; i++)
        cout<<edges[i].c<<endl;
}

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int t=1;
    while(t--)
        solve();
}



Measured memory_bytes: 15668
#include <stdio.h>
#include <stdlib.h>

#define N 128
#define INT(X) \
  ( *( (const int *)(X) ) )

static int
compare (
  const void * a,
  const void * b
  )
{
  return ( INT( b ) - INT( a ) );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  struct ti
  {
    int pt;
    int no;
  }   p[ N ] = { { 0 } };
  int res[ N ];
  int n, i;

  scanf ( "%d", &n );
  for ( i = 0; i < n; ++i )
  {
    p[ i ].no = i;
  }

  { const int lc = n * ( n - 1 ) / 2;
    for ( i = 0; i < lc; ++i )
    {
      int an, bn, ap, bp;

      scanf ( "%d%d%d%d", &an, &bn, &ap, &bp );
      p[ an - 1 ].pt += 3 * !!( ap > bp ) + !!( ap == bp );
      p[ bn - 1 ].pt += 3 * !!( bp > ap ) + !!( bp == ap );
    }
  }

  qsort ( p, n, sizeof ( struct ti ), compare );
  for ( i = 0; i < n; ++i )
  {
    res[ p[ i ].no ] = i + 1;
    if ( i > 0 && p[ i ].pt == p[ i - 1 ].pt )
    {
      res[ p[ i ].no ] = res[ p[ i - 1 ].no ];
    }
  }

  for ( i = 0; i < n; ++i )
  {
    printf ( "%d\n", res[ i ] );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  int n,ave,ans,y; ave=0; y=0;
  cin>>n;
  int x[n];
  rep(i,n){
    cin>>x[i];
    ave+=x[i];
  }
  
  ave=ave/n;
  
  rep(i,n){
    y+=(x[i]-ave)*(x[i]-ave);
  }
  ans=y;
  ave++; y=0;
  rep(i,n){
    y+=(x[i]-ave)*(x[i]-ave);
  }
  ans=min(ans,y);
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
   int N;
   cin>>N;
   int A[N],B[N],C[N];
   for(int i=0;i<N;i++){
       cin>>A[i];
   }
   for(int i=0;i<N;i++){
       cin>>B[i];
   }
   for(int i=0;i<N-1;i++){
       cin>>C[i];
   }
   int sum=0;
   for(int i=0;i<N;i++){
       sum+=B[A[i]-1];
       if(A[i]==A[i-1]+1 & i-1>=0){
           sum+=C[A[i-1]-1];
       }
   }
   cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



/*const int MOD = ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}*/

/*int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/

using namespace std;

const int MAXN = (int) 2e5;

int dp[MAXN + 1][3];

int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, j;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string str;
    cin >> str;
    int n = str.size();
    str = " " + str;

    for(i = 1; i <= n; i++) {
        for(j = 1; j <= min(i, 2); j++) {
            if(i == j) {
                dp[i][i] = 1;
                continue;
            }
            for(int k = 1; k <= 2; k++) {
                if(i - j - k >= 0 && str.substr(i - j - k + 1, k) != str.substr(i - j + 1, j)) {
                    dp[i][j] = max(dp[i][j], dp[i - j][k] + 1);
                }
            }
        }
    }

    cout << max(dp[n][1], dp[n][2]);

    return 0;
}


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

using namespace std;

int main(){
	
	while(1){
		
		int n,a,b,c,x;
		
		cin>>n>>a>>b>>c>>x;
		
		if(n==0) break;
		
		int y[n];
		
		for(int i=0;i<n;i++){
			cin >> y[i];
		}
		
		int ri=0;
		int f=-1;
		
		while(f<=10001&&ri<n){
			if(x==y[ri]){
				ri++;
			}
			f++;
			x=(a*x+b)%c;
		}
		if(f>10000) cout << "-1" << endl;
		else cout << f << endl;
	}
		
	return 0;
	
}


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

void eliminate_a_number(vector<vector<int>>& v, const int x){
    for(auto& vv : v) vv.erase(find(begin(vv), end(vv), x)); }

bool eliminate_all_bad(vector<vector<int>>& v, const int maxnr){
    map<int, int> nr_ap;
    for(auto& x : v) ++nr_ap[x.front()];
    bool rez = false;
    for(const auto p : nr_ap){
        if(p.second > maxnr){
            eliminate_a_number(v, p.first);
            rez = true; } }
    return rez; }

bool is_possible(vector<vector<int>> v, const int maxnr){
    while(true){
        if(any_of(begin(v), end(v), [](const vector<int>& v){ return v.empty(); })){
            return false; }
        if(!eliminate_all_bad(v, maxnr)) return true; } }

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(n, vector<int>(m, 0));
    for(auto& x : v) for(auto& y : x) cin >> y;

    int step, rez;
    for(step = 512, rez = n; step; step /= 2){
        if(rez-step < 1) continue;
        if(is_possible(v, rez-step)) rez -= step; }
    cout << rez << endl;
    return 0 ;} 



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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

string s;
int n, k;
int b[1000];
int ans;
signed main() {
    cin >> n;
    for (int i=0;i<n-1;i++) {
        cin >> b[i];
    }

    ans += b[0];
    for (int i=0;i<n-2;i++) {
        ans += min(b[i],b[i+1]);
    }
    ans += b[n-2];

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>

typedef long long ll;

constexpr long long INFLL = 1e18;

using namespace std;

int main()
{
    string s;
    cin >> s;
    int count = 0;

    for (int i = 0; i < s.size() / 2; i++)
    {
        if (s.at(i) != s.at(s.size() - 1 - i))
        {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

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

char str[33];

int main(void) {
	int count;

	cin.tie(0);

	while (cin >> str, str[0] != '#') {
		count = 0;

		for (int i = 0; i < 31; i++) {
			if (strlen(str) - 1 == i) break;

			if ((('a' <= str[i] && str[i] <= 'g') | ('q' <= str[i] && str[i] <= 't') | ('v' <= str[i] && str[i] <= 'x') | str[i] == 'z') && ( ('h' <= str[i + 1] && str[i + 1] <= 'p') | (str[i + 1] == 'u' | str[i + 1] == 'y'))) {
				count++;
			} else if ((('a' <= str[i + 1] && str[i + 1] <= 'g') | ('q' <= str[i + 1] && str[i + 1] <= 't') | ('v' <= str[i + 1] && str[i + 1] <= 'x') | str[i + 1] == 'z') && ( ('h' <= str[i] && str[i] <= 'p') | (str[i] == 'u' | str[i] == 'y'))) {
				count++;
			}

		}
		cout << count << "\n";
	}
	return 0;
}

Measured memory_bytes: 1140
import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())
mod=10**9+7
RUISEKI=[0]
for a in A:
    RUISEKI.append((RUISEKI[-1]+a)%mod)

ans=0
for i in range(N):
    ans+=A[i]*(RUISEKI[-1]-RUISEKI[i+1])
    ans%=mod
print ans


Measured memory_bytes: 99992
#include <stdio.h>

int main(){
	int i,n;//0?n?10000なのでintでおk
	scanf("%d",&n);
	i = 0;
	long long int data[10010];//0?n?10000なので10001でよいが多めに用意しておくのが安全
	scanf("%lld",&data[0]);
	long long max,min,sum;
	max = data[0]; min = data[0]; sum = data[0];
	for(i=1;i<n;i++){
		scanf("%lld",&data[i]);
		if(max<data[i]) max = data[i];
		if(min>data[i]) min = data[i];
		sum += data[i];
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 676
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N], v = new int[N];
        for(int i = 0; i < N; i++){
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        long[][] x = new long[W+1][N];
        x[0][0] = 0;
        for(int i = 0; i <= W; i++){
            for(int j = 0; j < N; j++){
                if(j == 0){
                    if(i >= w[0]) x[i][0] = v[0];
                    else x[i][0] = 0;
                }
                else if(i >= w[j]){
                    x[i][j] = Math.max(x[i][j-1], x[i - w[j]][j - 1] + v[j]);
                }
                else{
                    x[i][j] = x[i][j-1];
                }
            }
        }
        System.out.println(x[W][N-1]);
    }
}

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

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


Measured memory_bytes: 640
use proconio::{input,fastout};

#[fastout]
fn main() {
  input!{l:i32, r:i32, d:i32,};
  let mut i = 0;
  let mut cnt = 0;
  loop{
    if l <= i && r >= i {
      cnt += 1;
    }
    if r < i {
      break;
    }
    i += d;
  }
  println!("{}",cnt);
}


Measured memory_bytes: 2200
#include <iostream>

using namespace std;

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin >> k;
	long long ans = 0;
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			int num = gcd(a, b);
			for (int c = 1; c <= k; c++) {
				ans += gcd(num, c);
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
using ll = long long;


int main() {
    string s, ans = "";
    cin >> s;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '0') {
            ans += "0";
        } else if (s[i] == '1') {
            ans += "1";
        } else {
            ans = ans.substr(0, ans.length() - 1);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"
import "strconv"

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	var aint int
	var bint int
	aint, _ = strconv.Atoi(a)
	bint, _ = strconv.Atoi(b)
	fmt.Printf("%d %d %f\n", aint/bint, aint%bint, float64(aint)/float64(bint))
}



Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
    ll N;
    cin >> N;
    vector<ll> a;
    for(ll i = 0; i < N; ++i){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(),a.end());
    int count = 1;
    vector<pair<int,int> > b;
    if(N == 1){
        b.push_back(make_pair(a[0],count));
    } else {
        for(int i = 0; i < N - 1; ++i){
            if(a[i+1] == a[i]) ++count;
            else{
                b.push_back(make_pair(a[i],count));
                count = 1;
            }
        }
        b.push_back(make_pair(a[N-1],count));
    }
    ll ans = 0;
    for(ll i = 0; i < b.size(); ++i) ans += b[i].second % 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p  = pair<int,int>;
const ll INF = (ll)1e9+7;

const int MAX = (int)1e6;
const int MOD = (int)1e9+7;

int main(){
	string s;
  	int n;
	cin >> n >> s;
    ll ans = 0;
    for(int i=0;i<=999;i++){
        int m;
        m = s.find(i/100+'0');
      	if(m== string::npos) continue;
      	m = s.find(i/10%10+'0',m+1);
      	if(m== string::npos) continue;
        m = s.find(i%10+'0',m+1);
        if(m!=string::npos) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <cmath>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N;
    double T, A;
    cin >> N >> T >> A;

    vector<double> hs(N, 0.0);
    for (int i = 0; i < N; i++) {
        cin >> hs[i];
    }

    double cand = double(1e9);
    int idx = -1;
    for (int i = 0; i < N; i++) {
        double v = fabs((T - hs[i] * 0.006) - A);
        if (v < cand) {
            idx = i;
            cand = v;
        }
    }
    cout << idx + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

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 LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


class Matrix():
    def __init__(self, A):
        self.A = A
        self.row = len(A)
        self.col = len(A[0])

    def __iter__(self):
        return self.A.__iter__()

    def __getitem__(self, i):
        return self.A.__getitem__(i)

    def __add__(self, B):
        aa = self.A
        bb = B.A
        return Matrix([[aa[i][j] + bb[i][j] for j in range(self.col)] for i in range(self.row)])

    def __sub__(self, B):
        aa = self.A
        bb = B.A
        return Matrix([[aa[i][j] - bb[i][j] for j in range(self.col)] for i in range(self.row)])

    def __mul__(self, B):
        aa = self.A
        bb = B.A
        a = []
        for i in range(self.row):
            ai = aa[i]
            r = []
            for j in range(B.col):
                r.append(sum([ai[k] * bb[k][j] for k in range(self.col)]))
            a.append(r)
        return Matrix(a)

    def __truediv__(self, x):
        pass

    def lu(self):
        size = self.row
        T = copy.deepcopy(self.A)
        L = [[0]*size for _ in range(size)]
        U = [[0]*size for _ in range(size)]
        for i in range(size):
            for j in range(i,size):
                L[j][i] = T[j][i]
            for j in range(i,size):
                U[i][j] = T[i][j] / T[i][i]
            for j in range(i+1,size):
                for k in range(i+1,size):
                    T[j][k] -= L[j][i] * U[i][k]

        return Matrix(L),Matrix(U)

    def __str__(self):
        return self.A.__str__()

def solve_se(A, b):
    n = A.row
    L,U = A.lu()
    y = []
    for i in range(n):
        t = b[i]
        for k in range(i):
            t -= L[i][k] * y[k]
        y.append(t / L[i][i])

    x = [0] * n
    for i in range(n-1,-1,-1):
        t = y[i]
        for k in range(i+1,n):
            t -= U[i][k] * x[k]
        x[i] = t
    return x


def main():
    sa = [s for s in sys.stdin.read().split('\n') if s]
    r = []
    for s in sa:
        a,b,c,d,e,f = [int(c) for c in s.split()]
        A = Matrix([[a,b],[d,e]])
        B = [c,f]
        x = solve_se(A,B)
        r.append(' '.join(map(lambda t: '{:01.3f}'.format(1.0*t), x)))

    return '\n'.join(r)

print(main())

Measured memory_bytes: 13380
#include<bits/stdc++.h>
#define ll long long
#define N 210
#define mo 1000000007 
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
int m,n,a[N],f[N],nb,b[N],c[N];
ll jie[N],nj[N],ans;
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
ll C(int x,int y){return (jie[x]*nj[y]%mo)*nj[x-y]%mo;}
void chk(){
	nb=0;memset(b,0,sizeof(b));
	for (int i=(n+1)/2;i>=0;i--)
		for (int j=1;j<=f[i];j++)b[++nb]=i;
	for (int i=1,n0=0,n1=0;i<=m;i++){
		c[i]=0;
		if (a[i]==0){n0++;if (n0<=nb)c[i]=n0;
		}else if (n1<n0){n1++;if (b[n1])c[i]=n1;}
		if (i==m&&(n0<nb||b[n1+1]))return ;
	}
	for (int i=1,ne=0;i<=m;i++){
		if (!c[i])ne=max(0,ne-1);
		else if (a[i])ne+=b[c[i]]-1;
		if (i==m&&ne) return ;
	}
	ll x1=1,n0=2,n1=nb-1;
	if (nb==0) n0--,n1++;
	for (int i=1;i<=nb;i++)if (b[i])n0+=2,n1+=b[i]*2-1;else n1++;
	for (int i=0;i<=(n+1)/2;i++){x1=x1*C(nb,f[i])%mo;nb-=f[i];}
	ans=(ans+x1*C(n+n0-1,n0+n1-1))%mo;
}
void fen(int x,int no){
	int ne=max(2,no*2);
	if (no>n+1)chk();
	else for (int i=0;i<=x/ne;i++){f[no]=i;fen(x-i*ne,no+1);}
}
int main(){
	read(n);read(m);
	jie[0]=1;for (int i=1;i<=200;i++)jie[i]=jie[i-1]*i%mo;
	nj[200]=po(jie[200],mo-2);for (int i=199;i>=0;i--)nj[i]=nj[i+1]*(i+1)%mo;
	for (int i=1;i<=m;i++){char ch=getchar();while (ch!='b'&&ch!='r')ch=getchar();a[i]=(ch=='b');}
	fen(n+1,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    if (x >= 1800)
    {
        cout << 1 << endl;
    }
    else if (x >= 1600)
    {
        cout << 2 << endl;
    }
    else if (x >= 1400)
    {
        cout << 3 << endl;
    }
    else if (x >= 1200)
    {
        cout << 4 << endl;
    }
    else if (x >= 1000)
    {
        cout << 5 << endl;
    }
    else if (x >= 800)
    {
        cout << 6 << endl;
    }
    else if (x >= 600)
    {
        cout << 7 << endl;
    }
    else if (x >= 400)
    {
        cout << 8 << endl;
    }

    return 0;
}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) 0
#endif
#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = (int) 5e5 + 2;
int ar[NN];
int b[NN];
int n, m, k, x;
string s;

integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int x;
    cin >> x >> n;
    unordered_set<int> S;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        S.insert(a);
    }
    if (!S.count(x)){
        cout << x << endl;
        return 0;
    }
    for (int i = 1; ; i++){
        if (!S.count(x-i)){
            cout << x-i << endl;
            return 0;
        }
        if (!S.count(x+i)){
            cout << x+i << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3624
S = input()
y = 0
sum_t = 0
up = False
pre = y
for i in range(len(S)):
	if S[i] == '<':
		if up & (i!=(len(S))):
			y += 1
			sum_t += y
		else:
			y = 1
			sum_t += y
		up = True
	elif S[i] == '>':
		if up == False & (i!=(len(S))):
			y += 1
			sum_t += y
			if y <= pre:
				sum_t -=1
		else:
			pre = y
			y = 1
		up = False
print(sum_t)

Measured memory_bytes: 4212
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	int n;
	long a, b;
	long v[110] = {0}, v2[110] = {0};
	
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++){
		scanf("%ld %ld", &a, &b);
		v[a] += b;
		v2[a] += b;
	}
	
	sort(v, v + n + 1);
	reverse(v, v + n + 1);
	
	for (int i = 1; i <= n; i++){
		if (v2[i] == v[0]){
			printf("%ld %ld\n", i, v2[i]);
			break;
		}
	}
}

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

int main()
{
	int a,b;
	string s;
	cin>>a>>b>>s;
	
	bool f=1;
	for(int i=0;i<a;i++)
		if(s[i]<'0'||'9'<s[i]) f=0;
	if(s[a]!='-') f=0;
	for(int i=a+1;i<=a+b;i++)
		if(s[i]<'0'||'9'<s[i]) f=0;
	
	cout<<(f? "Yes":"No")<<endl;
	
	return 0;
}


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

#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
int sqr(int x){return x*x;}
inline int add(int a, int b){ int c = a + b; if(c >= MOD) c -= MOD; return c; }
inline int mul(int a, int b){ return (a * 1ll * b) % MOD; }
inline int sub(int a, int b){ int c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 300*1000 + 10;



int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n;
    vi u(n) , v(n);
    for(int i =0;i<n;++i){
        int a, b; cin>>a>>b;
        u[i] = a+b;
        v[i] = a-b;
    }
    sort(all(u));
    sort(all(v));
    cout << max(u.back() - u[0] , v.back() - v[0]);
    
   

    return 0;
}
    

// Химаншу
// check overflow
// special case n == 1



Measured memory_bytes: 6360
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = []
for i in range(2**d):
    tmp = 0
    cnt = 0
    gg = g 
    bag = []
    for j in range(d):
        if (i>>j)&1:
            # すべて解く
            tmp += 100*(j+1)*pc[j][0] + pc[j][1]
            cnt += pc[j][0]
            bag += [j]
    if tmp >= gg:
        ans += [cnt]
    else:
        gg -= tmp 
        for j in range(d-1, -1, -1):
            if j not in bag:
                c = (gg-1)//(100*(j+1))+1
                if 0 <= c <= pc[j][0]:
                    gg -= 100*(j+1)*c + pc[j][1]
                    cnt += c 
                if gg <= 0:
                    ans += [cnt]
                    break
        
print(min(ans))


Measured memory_bytes: 41200
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n;
	cin >> n;
	ll L[87] = {};
	L[0] = 2;
	L[1] = 1;
	for(int i = 2; i<= 86; i++){
		L[i] = L[i-1] + L[i-2];
	}
 	cout << L[n] << endl;
}

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

#define int ll

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int MAXN = 2E3 + 100;
int dp[MAXN][MAXN];

void maxi(int &x, int y) {
	x = max(x, y);
}

void solve() {
	memset(dp, 0, sizeof(dp));
	int n;
	cin >> n;
	vpi a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i].fs;
		a[i].sd = i;
	}
	sort(all(a), greater<pi>());
	for(int i = 0; i < n; i++) {
		for(int j = 0; j <= i; j++) {
			//debug(i, j, dp[i][j]);
			int l = j, r = n - i + j - 1;
			int idx = a[i].sd, val = a[i].fs;
			debug(l, r, i, j);
			maxi(dp[i + 1][j + 1], dp[i][j] + val * abs(idx - l));
			maxi(dp[i + 1][j], dp[i][j] + val * abs(idx - r));
		}
	}
	int res = 0;
	for(int i = 0; i <= n; i++)
		maxi(res, dp[n][i]);
	cout << res << '\n';
}

int32_t main() {
	// int t;
	// cin >> t;
	// while(t--)
	solve();
}


Measured memory_bytes: 38104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCoder
{
    class ABC179A
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            //string[] str = Console.ReadLine().Split(' ');
            int l = s.Length;
            string ans;
            if(s[l-1]=='s')
            {
                ans = s+"es";
            }
            else
            {
                ans = s+"s";
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 25680
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

ll N, X;
ll len[55];
ll pat[55];

ll rec(ll n, ll x) {
  if(x==0) return 0;
  if(n==0) return 1;
  
  if(x<=1+len[n-1])
    return rec(n-1, x-1);
  else
    return pat[n-1]+1+rec(n-1, x-1-len[n-1]-1);
  
}

int main(void) {
  cin >> N >> X;
  ll i, j;
  
  len[0]=1;
  pat[0]=1;
  for(i=1; i<=N; i++) {
    len[i]=1+len[i-1]+1+len[i-1]+1;
    pat[i]=pat[i-1]+1+pat[i-1];
  }
  
  pt(rec(N, X));
  
}


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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(0);
    
    int r;
    cin>>r;
    float p;
    p =2*3.14159*r;
    printf("%.5f\n",p);
    
    return 0;
}
    
    

Measured memory_bytes: 3736
n,k=map(int,input().split())
def f(cnt):
  return cnt+3*cnt*(cnt-1)+cnt*(cnt-1)*(cnt-2)
if k%2!=0:
  cnt=n//k
  print(f(cnt))
else:
  cnt=n//k
  cnt2=0
  for i in range(n):
    i+=1
    if i%k==k//2:
      cnt2+=1
  print(f(cnt)+f(cnt2))

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

long long gcd(long long a, long long b){

    if(b == 0) return a;
    else return gcd(b, (a % b));
}

int main(){

    long long n, m; cin >> n >> m;
    string s, t; cin >> s >> t;
    long long G = gcd(n, m);
    long long L = (m * n) / G;
    map<long long, char> a;
    bool ok = true;
    
    for(long long i = 0; i < n; i++){
        long long num = (L / n) * i;
        if(a.find(num) == a.end()){
            a[num] = s[i];
        }else{
            if(a[num] != s[i]){
                ok = false;
                while(1){}
            }
        }
    }

    for(long long i = 0; i < m; i++){
        long long num = (L / m) * i;
        if(a.find(num) == a.end()){
            a[num] = t[i];
        }else{
            if(a[num] != t[i]) ok = false;
        }
    }

    if(ok) cout << L << endl;
    else cout << -1 << endl;
    return 0;

}

Measured memory_bytes: 10880
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
int main() {
	int N, M, l = -1, r = 1000000;
	scanf("%d %d", &N, &M);
	for(int i=0;i<M;++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		l = max(l, x);
		r = min(r, y);
	}
	int ans = r-l+1;
	ans = max(ans, 0);
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if (B >= A * C ) {
		printf("%d\n", C);
	} else if (B < A * C && int (B / A) != 0) {
		printf("%d\n", int (B / A));
	} else {
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    int x; cin >> x;
    int maxn = 1;
    for (int y = 2; y < x; y++) {
        for (int p = 2; (int)pow(y, p) <= x; p++) {
            maxn = max(maxn, (int)pow(y, p));
        }
    }
    cout << maxn << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t="",u="",alph="abcdefghijklmnopqrstuvwxyz",alphh="zyxwvutsrqponmlkjihgfedcba";
  cin >> s;
  if(s.size()==26&&s==alphh){
    cout << -1 << endl;
    return 0;
  }else if(s.size()==26&&s!=alphh){
    for(int i=s.size()-1;i>=0;i--){
      for(int j=s.size()-1;j>=0;j--){
        string ss=s.substr(j,s.size()-j);
        sort(ss.begin(),ss.end());
        for(int k=0;k<ss.size();k++){
          if(ss[k]>s[j-1]){
            cout << s.substr(0,j-1) << ss[k] << endl;
            return 0;
          }
        }
      }
    }
  }
  t+=s;
  sort(s.begin(),s.end());
  for(int i=0;i<alph.size();i++){
    if(s[i]!=alph[i]){
      cout << t << alph[i] << endl;
      return 0;
    }
  }
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n),buka(n);
  for(int i=1;i<n;i++){
    cin >> a.at(i);
    buka.at(a.at(i)-1)++;
  }
  for(int j=0;j<n;j++)
    cout << buka.at(j) << endl;
}

Measured memory_bytes: 4792
#include <stdio.h>

int main()
{
    int A[100][100], b[100], c[100];
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d ", &A[i][j]);
        }
    }
    for (int i = 0; i < m; i++)
    {
        scanf("%d ", &b[i]);
    }
    for (int i = 0; i < n; i++)
    {
        c[i] = 0;
        for (int j = 0; j < m; j++)
        {
            c[i] = c[i] + A[i][j] * b[j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
long long ans[25][25][25][25];
long long H , W;
char c[25][25];

struct az
{
	int x;
	int y;
	int cnt;
}q[1000005];

int main()
{
	scanf("%lld%lld",&H,&W);
	for(int i=1;i<=H;++i)
	   for(int j=1;j<=W;++j)
	       scanf(" %c",&c[i][j]);
	for(int i=1;i<=H;++i)
	{
		for(int j=1;j<=W;++j)
		{
			if(c[i][j]=='#') continue;
			int l=0,r=1;
			q[1].x=i;
			q[1].y=j;
			q[1].cnt=0;
			ans[i][j][i][j]=-1;
			while(l<r)
			{
				++l;
				int dx=q[l].x;
				int dy=q[l].y;
				int now=q[l].cnt;
				if(dx > 1 && !ans[i][j][dx-1][dy] && c[dx-1][dy] !='#') 
				{
					++r;
					q[r].x=dx-1;
					q[r].y=dy;
					q[r].cnt=now+1;
					ans[i][j][dx-1][dy]=now+1;
				}
				if(dy > 1 && !ans[i][j][dx][dy-1] && c[dx][dy-1] !='#') 
				{
					++r;
					q[r].x=dx;
					q[r].y=dy-1;
					q[r].cnt=now+1;
					ans[i][j][dx][dy-1]=now+1;
				}
				if(dx < H && !ans[i][j][dx+1][dy] && c[dx+1][dy] !='#') 
				{
					++r;
					q[r].x=dx+1;
					q[r].y=dy;
					q[r].cnt=now+1;
					ans[i][j][dx+1][dy]=now+1;
				}
				if(dy < W && !ans[i][j][dx][dy+1] && c[dx][dy+1] !='#') 
				{
					++r;
					q[r].x=dx;
					q[r].y=dy+1;
					q[r].cnt=now+1;
					ans[i][j][dx][dy+1]=now+1;
				}
			}
		}
	}
	long long sum=0;
	for(int i=1;i<=H;++i)
		for(int j=1;j<=W;++j)
			for(int k=1;k<=H;++k)
			   for(int s=1;s<=W;++s)
			       sum=max(sum,ans[i][j][k][s]);
	//cout<<ans[3][1][1][5]<<endl;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 5720
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int h, n;
    cin >> h >> n;
    long long a[n], mp[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> mp[i];
    }
    long long dp[n][h + 1];
    const long long inf = LLONG_MAX / 3;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= h; j++)
        {
            dp[i][j] = LLONG_MAX / 3;
            if (j == 0)
            {
                dp[i][j] = 0;
            }
            else if (i == 0)
            {
                dp[i][j] = (j + a[i] - 1) / a[i] * mp[i];
            }
            else if (j <= a[i])
            {
                dp[i][j] = min(mp[i], dp[i - 1][j]);
            }
            else
            {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - a[i]] + mp[i]);
            }
        }
    }
    cout << dp[n - 1][h];
    return 0;
}

Measured memory_bytes: 78464
class GraphBits
	def initialize(n)
		@n = n

		@bits = 1
		(n-1).times {
			@bits = (@bits << @n + 1) | 1
		}

		@ones = 1
		(n-1).times { @ones = (@ones << @n) | 1 }
		@select_mask = (0..@n-1).map{|i| @ones << i}

		@pos = {}
		x = 1
		@n.times {|i|
			@pos[x] = i
			x = (x << 1) | 1
		}
	end

	def add_edge(i, j)
		@bits |= (1 << i * @n + j)
		@select_mask[i] |= (@ones << j)
	end

	def del_node(i)
		tmp = @bits & (@ones << i)
		@bits -= tmp
	end

	def select_node(i)
		@bits -= (@bits & @select_mask[i])
	end

	def deleted?(i)
		@bits[i * @n + i] == 0
	end

	def deg_zero?(i)
		tmp = subbits(i)
		tmp & (tmp - 1) == 0
	end

	def deg_one?(i)
		tmp = subbits(i)
		tmp &= (tmp - 1) 
		tmp & (tmp - 1) == 0
	end

	def subbits(i)
		(@bits >> i * @n) & ((1 << @n) - 1)
	end

	def opposite(i)
		tmp = subbits(i)
		tmp -= (1 << i)
		@pos[(tmp ^ (tmp - 1))]
	end
end

def search(w, graph, i)
	return w if i >= $weight.size
	return $lower_bound if w + $accum[i] <= $lower_bound
	return search(w, graph, i+1) if graph.deleted?(i)
	return search(w + $weight[i], graph, i+1) if graph.deg_zero?(i)

	g = graph.dup
	g.select_node(i)
	x =  search(w + $weight[i], g, i+1)

	g = graph
	if g.deg_one?(i)
		k = g.opposite(i)
		g.select_node(k)
		y = search(w + $weight[k], g, i+1)		
	else
		g.del_node(i)
   		y = search(w, g, i+1)
	end

	ans = x > y ? x : y
	$lower_bound = ans if ans > $lower_bound
	ans
end

loop {
	n = gets.to_i
	break if n == 0

	index = {}
	graph = GraphBits.new(n)
	$weight = Array.new(n)
		
	n.times {
		country, $weight_str, _, *neighbours = gets.split

		i = (index[country] ||= index.size)
		$weight[i] = $weight_str.to_i

		neighbours.each{|neighbour|
			j = (index[neighbour] ||= index.size)
			graph.add_edge(i, j)
		}
	}

	$lower_bound = 0
	$accum = $weight.reverse.inject([0]){|a, w| a + [a[-1] + w]}
	$accum = $accum[1..-1].reverse

	graph.select_node(0)
	p search($weight[0], graph, 1)
}

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

using namespace std;

void bit(vector<vector<int> > v, int goal)
{
    int n = v.size();
    int res = 100*10;
    for (int bit=0; bit<(1<<n); ++bit)
    {   
        int tmp = goal;
        int cnt = 0;
        vector<bool> state(n,false);
        
        for (int i=0; i<n; ++i)
        {
            if(bit & 1<<i)
            {
                tmp -= v[i][0]*(100)*(i+1) + v[i][1];
                state[i] = true;
                cnt += v[i][0];
                // cout << i << " ";
            }
        }
        // cout << " cnt:" << cnt << " tmp:" << tmp << endl;
        // cout << endl;

        if(tmp<=0) 
        {
            if(cnt<res) res = cnt;
            continue;
        }

        bool done = false;
        for ( int j=n; j>0; --j)
        {
            if(!state[j-1]) //未使用
            {
                for (int k=0; k<v[j-1][0]; ++k)
                {
                    tmp -= (100)*(j);
                    cnt += 1;
                    if(tmp<=0)
                    {
                        if(cnt < res) res = cnt;
                        done = true;
                        break;
                    }  
                }
            }
            if(done) break;
        }
    }

    cout << res << endl;
    return;
}

int main()
{
    int D,G;
    cin >> D >> G ;
    vector<vector<int> > vec(D,vector<int>(3,0));
    // vector<pair<double,pair<int,int> > >  vec;
    long long comp = 0;
    for (int i=0; i<D; ++i)
    {
        int p,c;
        cin >> p >> c;
        vec[i][0] = p;
        vec[i][1] = c;
        // vec.push_back(make_pair(c/p,make_pair(p,c)));
    }

    bit(vec,G);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{  int i,t,j;
int a[3];
for(i=0;i<3;i++)
{
    cin>>a[i];
}
   for(i=0;i<3;i++)
   {
    for(j=i+1;j<3;j++)
    {
      if(a[i]>a[j])
      {
          t=a[i];
          a[i]=a[j];
          a[j]=t;
      }
    }
   }
   for(i=0;i<3;i++)
   {
       if(i==2)
            cout<<a[i]<<endl;
       else
            cout<<a[i]<<' ';


   }

    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin >> n >> m;
  long long c1=0,c2=0;
  if(n>=2)
  {
    c1 = (n*(n-1))/2 ;
  }
  if(m>=2)
  {
    c2 =  (m*(m-1))/2;
  }
  cout << c1+c2;
  
  

}  

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

static const int MOD = 1000000007;
using ll = int64_t;
using namespace std;

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

struct Node {
    int d, l, r;
    explicit Node(int d) : d(d), l(-1), r(-1){};
    Node() : d(0), l(-1), r(-1){};
};

int main() {
    ll n, l;
    cin >> n >> l;
    ll ans = 0;
    vector<Node> v;
    v.emplace_back();
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        int x = 0;
        for (auto &&j : s) {
            if(j == '0'){
                if(v[x].l == -1){
                    v[x].l = static_cast<int>(v.size());
                    v.emplace_back(v[x].d + 1);
                }
                x = v[x].l;
            }else {
                if(v[x].r == -1){
                    v[x].r = static_cast<int>(v.size());
                    v.emplace_back(v[x].d + 1);
                }
                x = v[x].r;
            }
        }
    }
    for (auto &i : v) {
        if((i.l == -1) + (i.r == -1) == 1){
            ans ^= (l- i.d)&(i.d-l);
        }
    }
    puts(ans ? "Alice":  "Bob");
    return 0;
}


Measured memory_bytes: 2104