akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int h,w,n;
  cin>>h>>w>>n;
  vector<string> s(h);
  for(Int i=0;i<h;i++) cin>>s[i];

  auto dp=make_v<Int>(n+1,h,w);
  fill_v(dp,-1);
  
  Int y,x,d=0;
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      if(s[i][j]=='S')
	y=i,x=j;

  using T = tuple<Int, Int, Int>;
  queue<T> q;
  dp[d][y][x]=0;
  q.emplace(d,y,x);

  auto in=[&](Int y,Int x){return 0<=y&&y<h&&0<=x&&x<w;};
  Int dy[]={0,0,1,-1};
  Int dx[]={1,-1,0,0};
  while(!q.empty()){
    tie(d,y,x)=q.front();q.pop();
    for(Int k=0;k<4;k++){
      Int ny=y+dy[k],nx=x+dx[k],nd=d;
      if(!in(ny,nx)||s[ny][nx]=='X') continue;
      if(s[ny][nx]=='0'+(d+1)) nd++;
      if(~dp[nd][ny][nx]) continue;
      dp[nd][ny][nx]=dp[d][y][x]+1;
      q.emplace(nd,ny,nx);
    }
  }
  
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      if(s[i][j]=='0'+n)
	cout<<dp[n][i][j]<<endl;
  
  return 0;
}



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

namespace id_0027cs
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (vs[0] == 0)
                {
                    break;
                }
                var theDay = new DateTime(2004, vs[0], vs[1]);
                var culture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
                Console.WriteLine(theDay.ToString("dddd", culture));
            }
        }
    }
}



Measured memory_bytes: 9856
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=1e5+11;
const int M=1e6+11;
const int inf=1e9+1;
const ld EPS=1e-6;
const ll INF=1e18;
const ll mod=/*998244353*/1e9+7;
const int dx[4]={0,0,-1,1};
const int dy[4]={-1,1,0,0};

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  int n;
  cin>>n;
  if(n<=599)cout<<8;
  else if(n<=799)cout<<7;
  else if(n<=999)cout<<6;
  else if(n<=1199)cout<<5;
  else if(n<=1399)cout<<4;
  else if(n<=1599)cout<<3;
  else if(n<=1799)cout<<2;
  else cout<<1;
}


Measured memory_bytes: 3648
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k = scan.nextInt();

		unionFind uf = new unionFind(n);

		int i,x,y;

		int[] f = new int[n + 1];
		int[] rc = new int[n + 1];
		for(i = 0; i < m; i++) {
			x = scan.nextInt();
			y = scan.nextInt();

			f[x]++;
			f[y]++;

			uf.union(x, y);
		}

		for(i = 1; i <= n; i++) {
			rc[i] = uf.size(i) - f[i] - 1;
		}

		for(i = 0; i < k; i++) {
			x = scan.nextInt();
			y = scan.nextInt();

			if(uf.same(x, y)) {
				rc[x]--;
				rc[y]--;
			}
		}

		for(i = 1; i <= n; i++) {
			out.print(rc[i] + " ");
		}
		out.close();
	}

}
class unionFind{
	int[] par;
	int[] size;

	unionFind(int x){
		this.par = new int[x + 1];
		this.size = new int[x + 1];

		int i;
		for(i = 0; i <= x; i++)
			this.par[i] = i;
		Arrays.fill(this.size, 1);
	}

	int root(int x) {
		int r = x;
		while (r != this.par[r]) {
	        r = this.par[r];
	      }

		return r;
	}

	void union(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if(rx == ry)
			return;

		if(this.size[rx] < this.size[ry]) {
			this.size[ry] += this.size[rx];
			this.par[rx] = ry;
		}else {
			this.size[rx] += this.size[ry];
			this.par[ry] = rx;
		}
	}

	int size(int x) {
		return this.size[root(x)];
	}

	boolean same(int x, int y) {
		int rx = root(x);
		int ry = root(y);

		return rx == ry;
	}
}

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

int main(){
  ll N,M,X,i,k,sum,m;
  ll min = 1111111111;
  ll C[22];
  ll A[22][22];
  bool a = false;
  cin >> N >> M >> X;
  for(i=0;i<=N-1;i++){
    cin >> C[i];
    for(k=0;k<=M-1;k++)
      cin >> A[i][k];
      }
  for(int bit = 0;bit < (1<<N);bit++){
    bool x = true;
    sum = 0;
    for(k=0;k<=M-1;k++){
      m = 0;
      for(i=0;i<=N-1;i++){
        if (bit & (1 << i)) m += A[i][k];
      }
      if(m<X) x = false;
    }
    for(i=0;i<=N-1;i++)
      if(bit & (1 << i)) sum += C[i];
    if(x && sum < min) min = sum,a=true;  
  }
  if(a) cout << min << endl;
  else cout << -1;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    K, A, B = MI()

    ans = 1
    if (B-A) <= 2:
        ans += K
    else:
        sa = A - ans
        K -= sa
        ans = A
        p, q = K // 2, K % 2
        ans += (B-A) * p + q
    print(ans)


if __name__ == '__main__':
    solve()



Measured memory_bytes: 9236
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n,m;
    int num[100005];
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>num[i];
    int t=n/m;
    while((t*m)<n+t-1){
        t++;
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<assert.h>

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

struct SegmentTree{

   static const int N=1<<17;
   static const int Z=0;
   vector<int> seg, lazy;
   SegmentTree(){
      seg.resize(2*N-1, 0);
      lazy.resize(2*N-1, 0);
   }

   void update(int i, int l, int r){
      if(lazy[i]){
         seg[i]+=lazy[i]*(r-l);
         if(r-l>1){
            lazy[2*i+1]+=lazy[i];
            lazy[2*i+2]+=lazy[i];
         }
         lazy[i]=0;
      }
   }

   void add(int a, int b, int x, int i=0, int l=0, int r=N){
      update(i, l, r);
      if(b<=l or r<=a){
         return;
      }else if(a<=l and r<=b){
         lazy[i]+=x;
         update(i, l, r);
      }else{
         //update(i, l, r);
         int m=(r+l)/2;
         add(a, b, x, 2*i+1, l, m);
         add(a, b, x, 2*i+2, m, r);
         seg[i]=seg[2*i+1]+seg[2*i+2];
      }
   }

   int sum(int a, int b, int i=0, int l=0, int r=N){
      update(i, l, r);
      if(b<=l or r<=a){
         return Z;
      }else if(a<=l and r<=b){
         return seg[i];
      }else{
         //update(i, l, r);
         int m=(r+l)/2;
         int vl=sum(a, b, 2*i+1, l, m);
         int vr=sum(a, b, 2*i+2, m, r);
         return vl+vr;
      }
   }

};

signed main(){

   int N, Q;
   cin>> N>> Q;
   SegmentTree st;
   while(Q--){
      int q; cin>> q;
      if(q==0){
         int s, t, x;
         cin>> s>> t>> x;
         st.add(s-1, t, x);
      }else{
         int s, t;
         cin>> s>> t;
         cout<< st.sum(s-1, t)<< endl;
      }
   }

   return 0;
}

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

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

int N;
int h[100010][3];
long long dp[100010][3];

int main(){
    cin >> N;
    for(int i=0;i<N;++i) cin >> h[i][0] >> h[i][1] >> h[i][2];

    for(int i=0;i<N;++i){
        for(int j=0;j<3;++j){
            for(int k=0;k<3;++k){
                if(j==k) continue;
                chmax(dp[i+1][j],dp[i][k] + h[i][j]);
            }
        }
    }

    long long ans = 0;
    for(int i=0;i<3;++i){
        chmax(ans,dp[N][i]);
    }
    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int ans=0,l=LEN(s);
    rep(i,l){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
using namespace std;

ll a[301][301],b[305]={0},p[305],c;
mll m;
vll v[301];
set<pair<ll,ll> > s;
int main()
{
    ios::sync_with_stdio(false);

    ll n,i,j,k,t,m2;

    cin>>n>>m2;

    fo(i,n)
    {
        fo(j,m2)
            cin>>a[i][j];
    }

    fo(i,n)
    {
        b[a[i][0]]++;
        v[a[i][0]].push_back(i);
        p[i]=0;
    }

    ll ans=0,d,d2;
    fo(i,m2)
    {
        //cout<<i+1<<" "<<b[i+1]<<endl;
        m[i+1]=b[i+1];
        s.insert(make_pair(b[i+1],i+1));
    }

    ans=(s.rbegin()->first);

    while(s.size()>1)
    {
        //cout<<s.size()<<endl;
        auto it=s.rbegin();
        c=it->second;
        m[c]=-1;
        auto it3=s.end();
        it3--;
        s.erase(it3);

        fo(i,v[c].size())
        {
            d=v[c][i];
            j=p[v[c][i]];
            while(m[a[d][j]]==-1)
                j++;
            p[d]=j;
            d2=a[d][j];
            s.erase(s.find(make_pair(m[d2],d2)));
            m[d2]++;
            s.insert(make_pair(m[d2],d2));
            v[d2].push_back(d);
        }
        v[c].clear();
        ans=min(ans,(s.rbegin()->first));
    }

    cout<<ans;
    return 0;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define eprintf(...) fprintf(stderr,__VA_ARGS__)

const int N=int(1e5)+5;
const int mo=int(1e9)+7;
const ll inf=ll(1e18)+7;

int n;

ll A[2],S[N];
int f[2][N],sum[2][N];
int last[2][N];
int p[2];

inline int getsum(const int t,const int l,const int r){
	return l>r?0:(sum[t][r]-sum[t][l-1]+mo)%mo;
}

int main(){
	scanf("%d%lld%lld",&n,&A[0],&A[1]);
	S[0]=-inf;
	for(int i=1;i<=n;i++) scanf("%lld",&S[i]);
	for(int t=0;t<=1;t++)
		for(int i=1;i<=n;i++){
			last[t][i]=(i>1&&S[i]-S[i-1]>=A[t]?last[t][i-1]:i);
		}
	f[0][1]=1;
	f[1][1]=1;
	sum[0][1]=1;
	sum[1][1]=1;
	p[0]=0;
	p[1]=0;
	for(int i=2;i<=n;i++)
		for(int t=0;t<=1;t++){
			for(;S[i]-S[p[t]+1]>=A[t];p[t]++);
			f[t][i]=getsum(t^1,last[t^1][i-1],min(i-1,p[t]+1));
			sum[t][i]=(sum[t][i-1]+f[t][i])%mo;
		}
	int ans=0;
	for(int t=0;t<=1;t++){
		int q=n;
		while(q>1&&S[q]-S[q-1]>=A[t]) q--;
		ans=(ans+getsum(t,q,n))%mo;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll l,r,d;
    cin>>l>>r>>d;
    ll ans=0;
    rep(l,i,r+1){
        if(i%d==0)++ans;
    }
    cout<<ans;
}


Measured memory_bytes: 3632
N=str(input())
N1 = int(N[-1])

if N1==2 or N1==4 or N1==5 or N1==7 or N1==9:
  print('hon')
elif N1==0 or N1==1 or N1==6 or N1==8:
  print('pon')
else:print('bon')

Measured memory_bytes: 9168
#include <stdio.h>
int main(){
  long x,tmp,result=0;
  
  scanf("%ld",&x);
  tmp=x;

  result+=(tmp/11)*2;
  tmp=tmp%11;
  
  if(7<=tmp){
    result+=2;
  } else if(1<=tmp && tmp<7) {
    result+=1;
  }
  
  printf("%ld",result);
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int l, r, ans = 20192019;
    cin>>l>>r;
    r -= (l / 2019) * 2019;
    if (r > 2019) r = r % 2019 + 2019;
    l %= 2019;
    //cout<<l<<" "<<r<<endl;
    FOR(i,l,r) FOR(j,i+1,r+1) {
        ans = min(ans, (i*j)%2019);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=60;
ll dp[N*N*N];
int ans,L,lim,n,f[N],dp_sz;
pair<ll,int>a[N];

bool cmp(const pair<ll,int>&x,const pair<ll,int>&y){
	if(x.first*y.second!=y.first*x.second)return x.first*y.second<y.first*x.second;
	return x.second<y.second;
}
void ins(ll x,int y){dp_sz+=y;for(int i=dp_sz;i>=y;--i)dp[i]=min(dp[i],dp[i-y]+x);}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>L>>lim>>a[1].first;a[1].second=1;
	for(int i=2;i<=n;++i){
		cin>>a[i].first>>f[i];a[i].second=1;
		for(int j=f[i];j;j=f[j])a[j].first+=a[i].first,a[j].second++;
	}
	sort(a+1,a+n+1,cmp);
	memset(dp,0x3f,sizeof dp);dp_sz=0;dp[0]=0;
	for(int i=1;i<=n;++i){
		int sz=min(lim,n);if(a[i].second==n)sz=n;
		for(int j=0;(1<<j)<=sz;sz-=(1<<j),++j)ins(a[i].first<<j,a[i].second<<j);
		if(sz)ins(a[i].first*sz,a[i].second*sz);
	}
	for(int i=0;i<=dp_sz&&dp[i]<=L;++i){
		int sum=i,ls=L-dp[i];
		for(int j=1;j<=n;++j){
			int sz=max(lim-n,0);if(a[j].second==n)sz=ls;
			int tmp=min((ll)sz,ls/a[j].first);
			sum+=tmp*a[j].second;ls-=tmp*a[j].first;
		}
		ans=max(ans,sum);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>

int main()
{
	int x,y,z,tmp;
	scanf("%d%d%d",&x,&y,&z);
	tmp=x;x=y;y=tmp;
	tmp=x;x=z;z=tmp;
	printf("%d %d %d",x,y,z);
	return 0;
}


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


void solve(std::string S){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;

    string ans;
    if (S == "Sunny"){
      ans = "Cloudy";
    }
    else if (S == "Cloudy") {
      ans = "Rainy";
    }
    else{
      ans = "Sunny";
    }
	
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INT_INF 1000000000
#define DOUBLE_INF 1e18
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main()
{
  int a, b;
  cin >> a >> b;
  if (a + b == 15) {
    cout << "+" << endl;
  } else if (a * b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string s[10005];
int type[10005];
int cnt[4];
int ans=0;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin >> s[i];
		if(s[i][0]=='B')type[i]+=1;
		if(s[i][s[i].size()-1]=='A')type[i]+=2;
		cnt[type[i]]++;
		int pr=0;
		for(int j=0;j<s[i].size();j++){
			if(s[i][j]=='A'){
				pr=1;
			}else if(s[i][j]=='B'){
				if(pr==1){
					ans++;
				}
				pr=0;
			}else{
				pr=0;
			}
		}
	}
	if(cnt[3]>=1){
		ans+=cnt[3]-1;
		if(cnt[1]>=1){
			cnt[1]--;
			ans++;
		}
		if(cnt[2]>=1){
			cnt[2]--;
			ans++;
		}
	}
	ans+=min(cnt[1],cnt[2]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 896
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.* ;
 
class Main{
  public static void main(String[] args)throws IOException{
      
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\?????????
    String str = br.readLine();
  
    String[] strAry = str.split(" ");
    int a = Integer.parseInt(strAry[0]);
  	int b = Integer.parseInt(strAry[1]);
  	int c;
  	while ( a!=0 || b!=0 ) {  
  		if (a < b) {}
  			
  		else if ( a> b) {c= a; a= b; b= c;
  		}
  		System.out.println( a + " " + b);
  	     str = br.readLine();
 		 strAry = str.split(" ");
         a = Integer.parseInt(strAry[0]);
         b = Integer.parseInt(strAry[1]);
  	}
  	}	
  		
  	}
  

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

using namespace std;

int x, y;
int a[2005];

inline int min3(int num1, int num2, int num3) {
    int minn = (num1 < num2) ? num1 : num2;
    minn = (minn < num3) ? minn : num3;
    return minn;
}

int dis(int i, int j) {
    int v1 = abs(j - i);
    int v2 = abs(x - i) + 1 + abs(j - y);
    int v3 = abs(y - i) + 1 + abs(j - x);
    return min3(v1, v2, v3);
}

int main() {
    int n;
    cin >> n >> x >> y;
    for (int j = 2; j <= n; j++) {
        for (int i = 1; i < j; i++) {
            a[dis(i, j)]++;
        }
    }
    for (int k = 1; k <= n - 1; k++) {
        cout << a[k] << endl;
    }
    return 0;
}

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

int main()
{
  int k, n;
  cin >> k >> n;
  int a[n];
  rep(i, n){
    cin >> a[i];
  }
  int ans = 0;
  rep(i, n - 1){
    ans = max(ans, a[i + 1] - a[i]);
  }
  ans = max(ans, (k - a[n - 1]) + a[0]);
  cout << k - ans << endl;

  return 0;
}

Measured memory_bytes: 4404
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N; cin >> N;
  VI A(N);
  REP(i,N) cin >> A[i];

  int ans = 0;
  REP(i,N){
	int minj = i;
	FOR(j,i,N)
	  if(A[j] < A[minj])
		minj = j;
	if(i != minj) ++ans;
	swap(A[i], A[minj]);
  }

  cout << A[0];
  REP(i,N-1) cout << " " << A[i+1];
  cout << endl;

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

Measured memory_bytes: 1196
n, x, y = map(int, input().split())
ans = [0] * n
for i in range(1, n+1):
    for j in range(i+1, n+1):
        dist = min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))
        ans[dist] += 1
for i in range(1, n):
    print(ans[i])

Measured memory_bytes: 3444
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int a[202020], n;

struct BIT {
	int bit[202020];
	void init() {
		REP(i, 202020)bit[i] = 0;
	}
	int sum(int i) {
		int s = 0;
		while (i>0) {
			s += bit[i];
			i -= i& -i;
		}
		return s;
	}
	void add(int i, int x) {
		while (i <= 202020) {
			bit[i] += x;
			i += i& -i;
		}
	}
};

vector<pair<LL,LL>> v;

int main() {
	BIT bit;
	bit.init();
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		v.emplace_back(make_pair(a[i],i));
	}
	sort(ALL(v));
	REP(i, n) {
		a[v[i].second] = i + 1;
	}
	LL ans = 0;
	for (int j = 0; j < n; j++) {
		ans += j - bit.sum(a[j]);
		bit.add(a[j], 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 8248
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

string s,t;
int pd[3002][3002];

void read(){
  cin >> s >> t;
}

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

  read();

  for(int i=0;i<=sz(s);i++){
    for(int j=0;j<=sz(t);j++){
      if(i == 0 or j == 0){
        pd[i][j] = 0;
      }
      else if(s[i-1] == t[j-1]){
        pd[i][j] = pd[i-1][j-1] + 1;
      } else {
        pd[i][j] = max(pd[i-1][j], pd[i][j-1]);
      }
    }
  }


  string ans = "";

  int i = sz(s), j = sz(t);

  while(i > 0 and j > 0){
    if(s[i-1] == t[j-1]){
      ans += (s[i-1]);
      i--, j--;
    } else if(pd[i-1][j] > pd[i][j-1]) i--;
    else j--;
  }

  reverse(ans.begin(), ans.end());
  // ans.resize(sz(ans)-1);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b,c;cin>>a>>b>>c;
  set<int> ans;
  ans.insert(a);
  ans.insert(b);
  ans.insert(c);
  cout<<ans.size()<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <cmath>
#include <bitset>
#include <queue>
#include <set>
#include <numeric>
#include <unordered_set>

using namespace std;

#define ef emplace_front
#define eb emplace_back
#define mp make_pair
#define MOD 1000000007

typedef long double f80;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef unordered_set<int> usi;
typedef set<int> si;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int a,b;
	cin>>a>>b;
	cout<<6-a-b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,t,a[100001],num,ans,num1,ans1;
int read()
{
	int x=0,f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c<='9'&&c>='0'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
int main()
{
	n=read();t=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=n;i>=1;i--){num=max(num,a[i]);ans=max(ans,num-a[i]);}
	for(int i=n;i>=1;i--){num1=max(num1,a[i]);if(num1-a[i]==ans)ans1++;}
	cout<<ans1<<endl;
	return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    int n;
    cin >> n;
    vector<int> v(n+1);
    for(int i = 1; i < n; i++){
        int a;
        cin >> a;
        v[a]++;
    }
    for(int i = 1; i < n+1; i++){
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3996
import java.util.*;
import java.io.*;
public class Main {
	static long mod = 1000000007; 
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int[] arr1 = new int[n];
		int[] arr2 = new int[m];
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; i++){
			arr1[i] = Integer.parseInt(st.nextToken());
		}
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < m; i++){
			arr2[i] = Integer.parseInt(st.nextToken());
		}
		System.out.println((count(arr1, n, arr2, m)+1)%mod);
	}
	static long count(int[] s, int n,  int[] t, int m) 
	{ 
		long[][] dp = new long[n+1][m+1]; 
		for (int i = 1; i <= n; i++) { 
			for (int j = 1; j <= m; j++) {
				if (s[i-1] == t[j-1]){
					dp[i][j] = (1 + dp[i][j-1] + dp[i-1][j])%mod;
				}
				else{
					dp[i][j] = ((dp[i][j-1] + dp[i-1][j])%mod - dp[i-1][j-1] + mod)%mod;
				}
			} 
		} 
		return dp[n][m]; 
	}

}


Measured memory_bytes: 84692
//
// Created on 2020/03/22.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

int main() {

    int n;
    cin>>n;
    vector<int>A(n);
    map<int,long long>mp;
    for (int i = 0; i < n; ++i) {
        cin>>A[i];
        mp[A[i]] += 1;
    }
    long long sum = 0;
    map<int,long long>mp2;
    for(auto x:mp){
        mp2[x.first] = ((x.second)*(x.second-1))/2;
        sum += mp2[x.first];
    }

    map<int,long long>mp3;
    for(auto x:mp){
        mp3[x.first] = ((mp[x.first]-1)*(mp[x.first]-2))/2;
    }

    for (int j = 0; j < n; ++j) {
        long long ans = 0;
        ans = sum - mp2[A[j]] + mp3[A[j]];
        cout<<ans<<endl;
    }

}


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

using namespace std;
using ll = long long;

int const N = 100 * 1000 + 16;

int a[N];
int n, A, B;

bool chk(int cnt) {
  int left = cnt;
  for(int i = 0; i < n; ++i) {
    int x = a[i];
    int l = 0;
    int r = left;
    int used = -1;
    while(l <= r) {
      int m = l + r >> 1;
      if(1ll * m * A + 1ll * (cnt-m) * B >= x)
        r = m - 1, used = m;
      else
        l = m + 1;
    }

    if(used == -1)
      return false;

    left -= used;
  }

  return true;
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  cin >> n >> A >> B;

  copy_n(istream_iterator<int>(cin), n, a);
  sort(a, a+n, greater<int>());

  int l = 1;
  int r = 1000 * 1000 * 1000;
  int ans = r;

  while(l <= r) {
    int m = l + r >> 1;
    if(chk(m))
      r = m - 1, ans = m;
    else
      l = m + 1;
  }

  cout << ans << endl;
}

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

const int N = 2e5 + 5;
int arr[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    double res = 0;
    for (int i = 0; i < n; i++) {
        double in;
        cin >> in;
        res += (1 / in);
    }
    cout << fixed << setprecision(8) << (1 / res);
    return 0;
}


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

typedef long long ll;

int main () {
	int N;
	vector <string> v;
	cin >> N;
	for (int i=0; i<N; i++) {
		string tmp;
		cin >> tmp;
		v.push_back (tmp);
	}
	sort (v.begin(), v.end());
	v.erase ( unique (v.begin(), v.end ()), v.end ());
	cout << v.size () << endl;
	return 0;
}

Measured memory_bytes: 11660
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(x>=r&&x<=W-r){
		if(y>=r&&y<=H-r){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}


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

const int maxn = 500005, inf = 1 << 30;

#define mp make_pair
#define x first 
#define y second 
pair<int, int> a[maxn], b[maxn];
char s[maxn], t[maxn];

int n, ans = inf, c, d;

inline void chkmin(int &a, int b) {if (a > b) a = b;}

void solve()
{
	for (int i = 0; i <= n; ++i) {
        if ((a[1].y + b[1].y + i) & 1) continue;
        int res = 0, now = 1;
        while (now <= c) { 
            int ps = a[now].x, pt = now + i <= d ? b[now + i].x : n + 1;
            res += abs(pt - ps), ++ now;
        }
        while (now + i <= d) res += n + 1 - b[now + i].x, ++ now;
        for (int j = 1; j <= i; ++j) {
            int pt = j <= d ? b[j].x : n + 1; 
            res += pt - 1; 
        }
        chkmin(ans, res);
    }
}

int main()
{
    scanf("%d%s%s", &n, s + 1, t + 1);

    for (int i = 1; i <= n; ++i) { 
        if (s[i] != s[i - 1]) a[++c] = mp(i, s[i] ^ 48);
        if (t[i] != t[i - 1]) b[++d] = mp(i, t[i] ^ 48);
    }
    solve(), swap(c, d), swap(a, b), solve();
	
    printf("%d\n", ans);
	
    return 0;
}



Measured memory_bytes: 8064
import java.util.Scanner;


public class Main {

	public static void main(String [] args) {
		
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			if(x == 0 && y == 0) {
				break;
			
			}else if(x <= y){         //左のイコールは不要かもしれない
				System.out.println(x + " " + y);
			
			}else if(y < x){
				System.out.println(y + " " + x);
				
			}else {
				
			}
		}
		
				
	}
}


Measured memory_bytes: 36424
from collections import deque

N, M = [int(i) for i in input().split(' ')]
    
links = [[] for _ in range(N + 1)]

for _ in range(M):
    a, b = [int(i) for i in input().split(' ')]
    links[a].append(b)
    links[b].append(a)

q = deque([1])

results = [-1 for _ in range(N + 1)]

while q:
    i = q.popleft()
    for j in links[i]:
        if results[j] == -1:
            results[j] = i
            q.append(j)

print('Yes')
print('\n'.join(str(i) for i in results[2:]))

Measured memory_bytes: 41772
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

ll h[202000];
vector<ll> edge[200100];


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    int i;
    xrep(i, 1, n+1) cin >> h[i];
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        edge[x].pb(y);
        edge[y].pb(x);
    }
    int ans(0);
    xrep(i, 1, n+1) {
        int j;
        rep(j, sz(edge[i])) {
            int y = edge[i][j];
            if (h[y] >= h[i]) break;
        }
        if (j == sz(edge[i])) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12608
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N, M;
	cin >> N;
	map<string, int> m;
	for(int i=0; i<N; ++i){
		string S;
		cin >> S;
		++m[S];
	}
	cin >> M;
	for(int i=0; i<M; ++i){
		string S;
		cin >> S;
		--m[S];
	}
	int ans = 0;
	for(const auto& value : m){
		ans = max(ans, value.second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include <string>
using namespace std;
typedef long long llint;

llint n,c,k;
llint t[100005];
void input(){
  cin >> n >> c >> k;
  for(int i=0;i<n;i++){
    cin >> t[i];
  }
}

void solve(){
  input();
  sort(t,t+n);
  llint ans=1;
  llint x=t[0];
  llint nb=1;
  for(int i=1;i<n;i++){
    if(t[i]>x+k||nb==c){
      ans++;
      x=t[i];
      nb=1;
    }
    else nb++;
  }
  cout << ans << endl;
}
int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 1024
n = gets.to_i
pp = gets.split.map(&:to_i)
q = gets.split.map(&:to_i)

a = b = 0
i = 0
(1..n).to_a.permutation do |arr|
    a = i if arr == pp
    b = i if arr == q
    i += 1
end

puts (a - b).abs

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

int main()
{
  int x;	cin>>x;
  cout<<!x;
}

static int fastio = []() {
    #define endl '\n'
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    return 0;
}();


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

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

int n, m;
const int MAX_N = 101;
const int MAX_I = 21;
ll dp[MAX_N][MAX_I];

int main() {
	cin >> n;
	memset(&dp[0][0], 0, sizeof(ll) * MAX_N * MAX_I);
	cin >> m;
	dp[1][m] = 1;
	for(int i=2; i<n; i++) {
		cin >> m;
		for(int j=0; j<MAX_I; j++) {				
			if(j+m < MAX_I) dp[i][j+m] += dp[i-1][j];
			if(j-m >= 0)	dp[i][j-m] += dp[i-1][j];
		}
	}

	cin >> m;
	printf("%lld\n", dp[n-1][m]);
}

Measured memory_bytes: 1172
/* 
    HARSHAD VAGHASIYA
 
        @DAIICT
    
          H_M_Vaghasiya
    
            */
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define MAX_INT 100000
#define ld long double
#define pb push_back
#define mp make_pair
#define p_ push
int main()
{
    ll i,j,k,n,m,x,y;
    cin>>n>>k;
    vector<ll> a(n);
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    ll mod=1000000007;
   for (i = 0; i < n; i++) {
		for ( j = i + 1; j < n; j++) {
			if (a[i] > a[j]) {
				ans += (k * (k + 1)) / 2;
				ans %= mod;
			}
			else if (a[i] < a[j]) {
				ans += ((k)*(k - 1)) / 2;
				ans %= mod;
			}
		}
	}
	cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[], int N) {
	int i;
	for ( i = 0; i < N; i++ ) {
		if( i > 0 ) {
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i, j, v;
	
	for ( i = 1; i < N; i++ ) {
		v = A[i];
		j = i - 1;
		while ( j >= 0 && A[j] > v ) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		
		trace(A, N);
	}
}

int main()
{
	int N,i, j;
	int A[100];
	
	scanf("%d", &N);
	
	for ( i = 0; i < N; i++ ) {
		scanf("%d", &A[i]);
	}
	
	trace(A, N);
	insertionSort(A, N);
	
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int v[n];
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    int m = 0;
    for(int a = 0; a <= min(n, k); a++){
        for(int b = 0; a+b <= min(n, k); b++){
            int tmp = 0;
            vector<int> minus;
            for(int i = 0; i < a; i++){
                tmp+=v[i];
                if(v[i] < 0){
                    minus.push_back(v[i]);
                }
            }
            for(int i = 0; i < b; i++){
                tmp+=v[n-1-i];
                if(v[n-i-1] < 0){
                    minus.push_back(v[n-1-i]);
                }
            }
            sort(minus.begin(), minus.end());
            for(int i = 0; i < k-(a+b) && i < minus.size(); i++){
                tmp -= minus[i];
            }
            m = max(m, tmp);
        }
    }

    cout << m << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int x, y, z;
	cin >> x;
	if(x == 1){
		 cout <<"Hello World";
	}else{
		cin >> y >> z;
		cout << y+z <<endl;
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	int b, f, r, v;
	int hotel[4][3][10];
	rep(i, 4) rep(j, 3) rep(k, 10) hotel[i][j][k] = 0;

	rep(i, n)
	{
		cin >> b >> f >> r >> v;
		hotel[b-1][f-1][r-1] += v;
	}

	rep(i, 4)
	{
		rep(j, 3)
		{
			rep(k, 10)
			{
				cout << ' ' << hotel[i][j][k];
			}
			cout << endl;
		}
		if(i != 3)
		{
			rep(j, 20) cout << '#';
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3168
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

#define MOD 1000000007

int main() {
  ll N, M;

  cin >> N >> M;

  vvll edge(N + 1);
  for (int i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  ll ans = 0;
  queue<pair<ll, vector<bool> > > que;
  que.push(make_pair(1, vector<bool>(N + 1, false)));
  while (!que.empty()) {
    auto tmp = que.front();
    que.pop();

    ll v = tmp.first;
    vector<bool> visited = tmp.second;
    visited[v] = true;

    bool comp = true;
    for (int i = 1; i <= N; i++) {
      if (visited[i] == false) {
        comp = false;
        break;
      }
    }  // i
    if (comp) {
      ans++;
      continue;
    }

    for (auto p : edge[v]) {
      if(!visited[p]){
        que.push(make_pair(p, visited));
      }
    } // p
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int h = 0;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int H;
        cin >> H;
        if (h <= H)
        {
            h = H;
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MOD 1000000007

long long int dp[3][1000010]={0};

int main()
{
    int n,i;

    scanf("%d",&n);

    for(i=1;i<=n;i++)
    {
        if(i==1)
        {
            dp[0][i]=8;
            dp[1][i]=1;
            dp[2][i]=0;
        }
        else
        {
            dp[0][i]=(dp[0][i-1]*8)%MOD;
            dp[1][i]=((dp[1][i-1]*9)%MOD+(dp[0][i-1])%MOD)%MOD;
            dp[2][i]=((dp[2][i-1]*10)%MOD+(dp[1][i-1]*2)%MOD)%MOD;
        }
    }
	printf("%lld",dp[2][n]);
}


Measured memory_bytes: 25076
N,A=map(int,input().split())
x=list(map(int,input().split()))
ans=0
y=[0]*(len(x))
for k in range(len(x)):
    y[k]=x[k]-A
minus=0
plus=0
for k in range(N):
    if y[k]<0:
        minus-=y[k]
    if y[k]>0:
        plus+=y[k]
total=minus+plus+1
ans=[[0 for i in range(N)]for j in range(total)]
ans[y[0]+minus][0]=1
ans[minus][0]=ans[minus][0]+1
for j in range(N-1):
    for t in range(total):
        if 0<=t-y[j+1]<total:
            ans[t][j+1] =ans[t][j]+ans[t-y[j+1]][j]
        else:
            ans[t][j+1] =ans[t][j]
print(ans[minus][N-1]-1)

Measured memory_bytes: 4340
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
def run():
    N, S = map(int, sysread().split())
    A = [0]+ list(map(int,sysread().split()))
    dp = [[0] * (S+1) for _ in range(N+1)]
    if A[1] <= S:
        dp[1][A[1]] = 1
    mod = 998244353
    for r in range(1, N):
        if A[r+1] <= S:
            dp[r+1][A[r+1]] += r+1
            dp[r + 1][A[r + 1]] %= mod
        for s in range(1,S+1):
            dp[r+1][s] += dp[r][s] + dp[r][s] - dp[r-1][s]
            dp[r+1][s] %= mod
            if s + A[r+1] <= S:
                dp[r+1][s+A[r+1]] += dp[r][s] - dp[r-1][s]
                dp[r + 1][s + A[r + 1]] %= mod
    print(dp[N][S] % mod)


if __name__ == "__main__":
    run()


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

	vi p(n);
	rep(i, 0, n) cin >> p[i];

	int ans = 0;
	rep(i, 1, n-1){
		if((p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1])){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

int main() {
    string N;
    cin >> N;
    int ichi = N[N.size() - 1] - '0';
    if (ichi == 2 || ichi == 4 || ichi == 5 || ichi == 7 || ichi == 9) {
        cout << "hon" << endl;
    } else if (ichi == 0 || ichi == 1 || ichi == 6 || ichi == 8) {
        cout << "pon" << endl;
    } else if (ichi == 3) {
        cout << "bon" << endl;
    }
}

Measured memory_bytes: 3620
#include<stdio.h>
 
int count[26];
char a;
 
int main(void){
    int i,j;
    while(1){
        i = scanf("%c",&a);
        if(a >= 'a' && a <= 'z')
            count[a - 'a']++;
        else if(a >= 'A' && a <= 'Z')
            count[a - 'A']++;
        if(i == EOF)
            break;
    }
    for(i = 0;i < 26;i++){
        printf("%c : %d\n",'a' + i,count[i]);
    }
    return 0;
}


Measured memory_bytes: 2104