akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

#include<cstring>
struct edge { int to, cap, rev; };
vector<edge> G[100000];
bool used[100000];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, mod);
		if (f == 0)return flow;
		flow += f;
	}
}

int h,w,c,m,nw,nc,nm;
void solve() {
	rep(i, 1000) {
		G[i].clear();
	}
	int s = 800; int t = 801;
	rep(i, h) {
		add_edge(s, i, 1);
		add_edge(i, i + 100, 1);
	}
	rep(i, w) {
		add_edge(i + 200, i + 300, 1);
	}
	add_edge(w + 200, w + 300, nw);
	rep(i, c) {
		add_edge(i + 400, i + 500, 1);
	}
	add_edge(c + 400, c + 500, nc);
	rep(i, m) {
		add_edge(i + 600, i + 700, 1);
		add_edge(i + 700, t,1);
	}
	add_edge(m + 600, m + 700, nm);
	rep(i, h) {
		add_edge(i + 100, w + 200, mod);
	}
	rep(i, w) {
		add_edge(i + 300, c + 400,mod);
	}
	rep(i, c) {
		add_edge(i + 500, m + 600, mod);
		add_edge(w + 300, i + 400, mod);
	}
	rep(i, m) {
		add_edge(c + 500, i + 600, mod);
	}
	//add_edge(w + 300, c + 400, mod);
	//add_edge(c + 500, m + 600, mod);
	add_edge(m + 700, t, mod);
	rep(i, w) {
		int x; cin >> x;
		rep(j, x) {
			int u; cin >> u; u--;
			add_edge(u + 100, i+200, 1);
		}
	}
	rep(i, c) {
		int x; cin >> x;
		rep(j, x) {
			int u; cin >> u; u--;
			add_edge(u + 300, i+400, 1);
		}
	}
	rep(i, m) {
		int x; cin >> x;
		rep(j, x) {
			int u; cin >> u; u--;
			add_edge(u + 500, i + 600, 1);
		}
	}
	int ans = max_flow(s, t);
	//cout << "ans is ";
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	while (cin >> h>>w>>c>>m>>nw>>nc>>nm,h>=0) {
		solve();
	}
	//stop
	return 0;
}




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

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++) cin >> a[i];
    bool vis[n + 1];
    memset(vis, 0, sizeof vis);
    int now = 1;
    vector<int> path;
    while (!vis[now]) {
        vis[now] = true;
        path.push_back(now);
        now = a[now];
    }
    if (k < path.size()) cout << path[k] << "\n";
    else {
        vector<int> ans;
        bool ok = false;
        for (int i = 0; i < path.size(); i++) {
            ok |= (path[i] == now);
            if (ok) {
                ans.push_back(path[i]);
                //cout << path[i] << " ";
            }
        }
        //cout << "\n";
        k -= path.size() - 1;
        k = (k%ans.size()) ? k%ans.size() - 1 : ans.size() - 1;
        cout << ans[k] << "\n";
    }
}


Measured memory_bytes: 6280
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
    {
        cout<<"a > b"<<endl;
    }
    else if(a<b)
    {
        cout<<"a < b"<<endl;
    }
    else
    {
        cout<<"a == b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
// 型に合わせた値 2倍してもオーバーフローしないようにする
const int INF = 1e9;
// const LL INF = 1e17;

int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    vector<int> v(D);
    // vを0, 1, 2, … D-1 という数値で埋める
    iota(all(v), 0);

    int ans = INF;
    while(1){
        int solve = 0, score = 0;
        for(auto i : v){
            if(score + 100*(i+1)*p[i] + c[i] <= G){
                solve += p[i];
                score += 100*(i+1)*p[i] + c[i];
            }else{
                int less = G-score;
                if(less == 0) break;
                solve += min(p[i], (less-1)/(100*(i+1)) + 1);
                break;
            }
        }
        ans = min(ans, solve);
        if(!next_permutation(all(v))) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def getlist():
	return list(map(int, input().split()))

K, A, B = getlist()
if A + 2 >= B:
	print(K + 1)
else:
	if (K + 1) / A < 1:
		print(K + 1)
	else:
		ans = A + int((K + 1 - A) // 2) * (B - A) + ((K + 1 - A) % 2)
		print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, d;
  vector<int> v;
  cin >> n;
  REP(i, n) {
    cin >> d;
    v.push_back(d);
  }
  sort(v.begin(), v.end());

  cout << v[n / 2] - v[n / 2 - 1] << endl;
  return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 110;

vector< vector<int> > d(N, vector<int>() );
int ans = 2;

void dfs(int now, bool visited[], int sum){
    sum++;
    int dsize = d[now].size();
    REP(i, dsize){
        int next = d[now][i];
        if(!visited[next]){
            visited[next] = true;
            dfs(next, visited, sum);
            visited[next] = false;
        }
    }
    ans = max(ans, sum);
}

int main(){
    int n;
    vector<int> v;
    while(cin >>n && n){
        ans = 2;
        REP(i, N) d[i].clear();
        REP(i, n){
            int a, b; cin >>a >>b;
            d[a].push_back(b);
            d[b].push_back(a);
            if(find(v.begin(), v.end(), a) == v.end()) v.push_back(a);
            if(find(v.begin(), v.end(), b) == v.end()) v.push_back(b);
        }
        int vsize = v.size();
        REP(i, vsize){
            bool visited[N];
            memset(visited, 0, sizeof(visited));
            visited[v[i]] = true;
            dfs(v[i], visited, 0);
        }
        cout <<ans <<endl;
    }
    return 0;
}

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

int solve(int d, int w) {
    int e[d][w];
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < w; j++) {
            cin >> e[i][j];
        }
    }
    int ans = 0;
    for (int x1 = 0; x1 < d; x1++) {
        for (int x2 = 0; x2 < d; x2++) {
            if (x2 - x1 < 2) continue;
            for (int y1 = 0; y1 < w; y1++) {
                for (int y2 = 0; y2 < w; y2++) {
                    if (y2 - y1 < 2) continue;
                    int inner_height = 0;
                    int surround_height = 100;
                    int inner_sum = 0;
                    int counter = 0;
                    for (int i = 0; i < d; i++) {
                        for (int j = 0; j < w; j++) {
                            if (x1 < i && i < x2 && y1 < j && j < y2) {
                                inner_height = max(inner_height, e[i][j]);
                                inner_sum += e[i][j];
                                counter++;
                            }
                            if (x1 <= i && i <= x2 && (j == y1 || j == y2)) {
                                surround_height = min(surround_height, e[i][j]);
                            }
                            if (y1 <= j && j <= y2 && (i == x1 || i == x2)) {
                                surround_height = min(surround_height, e[i][j]);
                            }
                        }
                    }
                    if (surround_height > inner_height) {
                        int tmp = counter * surround_height - inner_sum;
                        ans = max(ans, tmp);
                    }
                }
            }
        }
    }
    return ans;
}

int main() {
    int d, w;
    while (true) {
        cin >> d >> w;
        if (!d && !w) return 0;
        cout << solve(d, w) << endl;
    }
}


Measured memory_bytes: 3024
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
struct Key {
	int price, pattern;
};
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<Key> keys(m);
	for (auto i = 0; i < m; ++i) {
		int b;
		std::cin >> keys[i].price >> b;
		int c;
		for (auto _i = 0; _i < b; ++_i) {
			std::cin >> c;
			keys[i].pattern |= 1 << (c - 1);
		}
	}
	std::vector<int> min_price(1 << n, INT_MAX); min_price[0] = 0;
	for (auto i = 0; i < (1 << n); ++i) if (min_price[i] != INT_MAX) {
		for (const auto& key : keys) {
			if (min_price[i | key.pattern] > min_price[i] + key.price) {
				min_price[i | key.pattern] = min_price[i] + key.price;
			}
		}
	}
	if (min_price.back() == INT_MAX) {
		std::cout << -1 << '\n';
	}
	else {
		std::cout << min_price.back() << '\n';
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, j, H, W;

  for( ; ; )
  {
    scanf("%d %d", &H, &W);

    if( H == 0 && W == 0 )
      break;

    for( i = 0 ; i < H ; i++ )
    {
      if( i % 2 == 0 )
      {
        for( j = 0 ; j < W ; j++ )
        {
          if( j % 2 == 0 )
            printf("#");
          else
            printf(".");
        }
      }
      else
      {
        for( j = 0 ; j < W ; j++ )
        {
          if( j % 2 == 0 )
            printf(".");
          else
            printf("#");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2100
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

m = sum(B)-sum(A)
cnt1 = 0
cnt2 = 0
for a, b in zip(A, B):
    if a > b:
        cnt1 += (a-b)
    elif a < b:
        cnt2 += (b-a+1)//2
    else:
        pass

if cnt1 <= m and cnt2 <= m:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 73408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;

long long N, ans = 0;

void dfs(long long x, int a, int b, int c){
        if(x > N) return;
        if(a&&b&&c) ans++;
        dfs(x*10+3, 1, b, c);
        dfs(x*10+5, a, 1, c);
        dfs(x*10+7, a, b, 1);
}

int main(){
    cin >> N;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0,a;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a%2)cnt++;
  }
  cout << ((cnt%2)?"NO":"YES") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>

int main(){
  std::string str1;
  std::string str2;
  std::cin>>str1;
  std::cin>>str2;
  int A[1001][1001]={0};
  for(int i=0;i<=str1.size();i++){
    A[i][0]=i;
  }
  for(int j=0;j<=str2.size();j++){
    A[0][j]=j;
  }
  for(int i=1;i<=str1.size();i++){
    for(int j=1;j<=str2.size();j++){
      if(str1[i-1]==str2[j-1]){
	A[i][j]=A[i-1][j-1];
      }else{
	A[i][j]=std::min(std::min(A[i-1][j]+1,A[i][j-1]+1),A[i-1][j-1]+1);
      }  
    }
  }
  std::cout<<A[str1.size()][str2.size()]<<"\n";
  return 0;
}



Measured memory_bytes: 7140
#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 int long long
#define double long double

main(){
	int n,a,b;
	cin>>n>>a>>b;
	if((a-b)%2==0){
		cout<<abs(a-b)/2<<endl;
	}
	else {
		if((max(a,b)-1)<(n-min(a,b))){
			int left=min(a,b)-1;
			int count=(max(a,b)-min(a,b)+1)/2;
			cout<<count+left<<endl;
		}else{
			int right=n-max(a,b);
			int count=(n-min(a,b)-right+1)/2;
			cout<<count+right<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int a,b;
double a_d,b_d;
int d,r;
//int w,h,x,y,r;

int main(void) {
  scanf("%d %d",&a,&b);
    //printf("%d %d\n",num[1][k],num[2][k]);
    d=a/b;
    r=a%b;
    a_d=(double)a;
    b_d=(double)b;
  printf("%d %d %.5f\n",d,r,a_d/b_d);
}



Measured memory_bytes: 2104
fun main(args: Array<String>) {
    ddcc2020quala()
}

fun ddcc2020quala() {
    val xy = readLine()!!.split(' ').map { it.toInt() }

    val list = listOf(300000, 200000, 100000)
    val answer = if (xy.all { it == 1 }) 1000000 else xy.map { if (it in 1..3) list[it - 1] else 0 }.sum()
    
    println(answer)
}


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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define all(v) (v).begin(),(v).end()
typedef long long ll;

const int N = 2*50*20+10;
string vs[2][100];
ll cost[100];

vector<pair<ll,ll>> g[N];

int id_no[2][110][110];
tuple<int,int,int> parc[N];
int no_final;

void printp(int id){
	int cor, i, j; tie(cor,i,j) = parc[id];
	printf("no = (%d,%d,%d)\n", cor,i,j);
}

void merge(int cor, int i_suf, int tam, int j_cand){
	int id_no_orig = id_no[cor][i_suf][tam];
	int id_no_dest;
	int tami = sz(vs[cor][i_suf]);
	fr(i,min(tam,sz(vs[!cor][j_cand]))){
		if(vs[cor][i_suf][tami-tam+i]!=vs[!cor][j_cand][i]) return;
	}
	if(tam==sz(vs[!cor][j_cand])){
		g[id_no_orig].emplace_back(no_final,cost[j_cand]);
		return;
	}
	if(tam>sz(vs[!cor][j_cand])){
		id_no_dest = id_no[cor][i_suf][tam-sz(vs[!cor][j_cand])];
		g[id_no_orig].emplace_back(id_no_dest,cost[j_cand]);
		return;
	}
	id_no_dest = id_no[!cor][j_cand][sz(vs[!cor][j_cand])-tam];
	g[id_no_orig].emplace_back(id_no_dest,cost[j_cand]);
}

int n_no;
ll dij(){
	vector<bool> vis(n_no+1,0);
	set<pair<ll,ll>> pq;
	pq.emplace(0,0);
	while(!pq.empty()){
		ll no, dist;
		tie(dist,no) = *pq.begin(), pq.erase(pq.begin());
		if(no==no_final) return dist;
		if(vis[no]) continue;
		vis[no] = 1;
		for(auto &par : g[no]){
			ll edge, it; tie(it,edge) = par;
			pq.emplace(dist+edge,it);
		}
	}
	return -1;
}

bool pref_eq(string &s1, string &s2){
	fr(i,min(sz(s1),sz(s2))){
		if(s1[i]!=s2[i]) return 0;
	}
	return 1;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	
	n_no = 1;
	fr(i,n){
		string ss; cin >> ss >> cost[i];
		vs[0][i] = ss;
		reverse(all(ss));
		vs[1][i] = ss;
	}
	
	fr(cor,2) fr(i,n){
		for(int tam = 1; tam<=sz(vs[cor][i]); tam++){
			parc[n_no] = {cor,i,tam};
			id_no[cor][i][tam] = n_no++;
		}
	}
	no_final = n_no;
	
	fr(cor,2) fr(i,n){
		for(int tam = 1; tam<=sz(vs[cor][i]); tam++){
			fr(j,n){
				merge(cor,i,tam,j);
			}
		}
	}
	
	
	fr(id,n){
		string s = vs[0][id];
		fr(i,sz(s)){
			{
				string s1,s2;
				fr(j,i) s1+=s[j];
				reverse(all(s1));
				for(int j = i; j<sz(s); j++) s2+=s[j];
				if(pref_eq(s1,s2)){
				int dif = sz(s1)-sz(s2);
				if(dif==0){
					g[0].emplace_back(no_final,cost[id]);
				} else if(dif>0){
					int id_dest = id_no[1][id][dif];
					g[0].emplace_back(id_dest,cost[id]);
				} else if(dif<0){
					dif = -dif;
					int id_dest = id_no[0][id][dif];
					g[0].emplace_back(id_dest,cost[id]);
				}
				}
			}
			
			{
				string s1,s2;
				fr(j,i) s1+=s[j];
				reverse(all(s1));
				for(int j = i+1; j<sz(s); j++) s2+=s[j];
				if(!pref_eq(s1,s2)) continue;
				int dif = sz(s1)-sz(s2);
				if(dif==0){
					g[0].emplace_back(no_final,cost[id]);
				} else if(dif>0){
					int id_dest = id_no[1][id][dif];
					g[0].emplace_back(id_dest,cost[id]);
				} else if(dif<0){
					dif = -dif;
					int id_dest = id_no[0][id][dif];
					g[0].emplace_back(id_dest,cost[id]);
				}
			}
		}
	}
	
	ll ans = dij();
	
	printf("%lld\n", ans);
	
}

Measured memory_bytes: 3920
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll; 

void vdeb(vector<double> &da) {
	int size = da.size();
	rip(i, size - 1, 0) {
		printf("%f ", da[i]);
	}
	printf("%f\n", da[size - 1]);
}
 
void vvdeb(vector<vector<double>> &da) {
	int size = da.size();
	rip(i, size, 0) {
		vdeb(da[i]);
	}
}

int main(){
	int n;
	cin >> n;
	int su=0;
	vector<int> a(4,0);
	int gg;
	rip(i,n,0){
		cin >> gg;
		a[gg]++;
		su+=gg;
	}
	vector<vector<double>> dp(2,(vector<double>((n+1)*(n+1),0)));
	vector<vector<double>> dpp(2,(vector<double>((n+1)*(n+1),0)));
	vector<vector<bool>> ju(2,(vector<bool>((n+1)*(n+1),false)));
	ju[su%2][a[1]+a[2]*(n+1)]=true;
	dpp[su%2][a[1]+a[2]*(n+1)]=1;
	int x,y,z;
	for(int i=su;i>0;i--){
		rip(j,(n+1)*(n+1),0){
			ju[(i+1)%2][j]=false;
			dpp[(i+1)%2][j]=0;
			dp[(i+1)%2][j]=0;
		}
		rip(j,(n+1)*(n+1),0){
			x=j%(n+1);
			y=j/(n+1);
			z=i-x-y*2;
			//printf("%d %d %d\n",x,y,z);
			if(z%3){
				continue;
			}else{
				z/=3;
			}
			if(!ju[i%2][j]){
				continue;
			}
			//cout << i;
			//printf(" %d %d %d\n",x,y,z);
			if(x>0){
				dp[(i+1)%2][j-1]+=(dp[i%2][j]/dpp[i%2][j]+(double)n/(x+y+z))/(x+y+z)*dpp[i%2][j]*x;
				dpp[(i+1)%2][j-1]+=(double)dpp[i%2][j]*x/(x+y+z);
				ju[(i+1)%2][j-1]=true;
			}
			if(y>0){
				dp[(i+1)%2][j-n]+=(dp[i%2][j]/dpp[i%2][j]+(double)n/(x+y+z))/(x+y+z)*dpp[i%2][j]*y;
				dpp[(i+1)%2][j-n]+=(double)dpp[i%2][j]*y/(x+y+z);
				ju[(i+1)%2][j-n]=true;
			}
			if(z>0){
				dp[(i+1)%2][j+n+1]+=(dp[i%2][j]/dpp[i%2][j]+(double)n/(x+y+z))/(x+y+z)*dpp[i%2][j]*z;
				dpp[(i+1)%2][j+n+1]+=(double)dpp[i%2][j]*z/(x+y+z);
				ju[(i+1)%2][j+n+1]=true;
			}
		}
	}
	printf("%.10lf\n",dp[0][0]);
	//vvdeb(dp);
	//vvdeb(dpp);
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n,m,l; ll res=0;
	ll k;
	cin>>n>>k;
	VI h(n),b(n);
	rep(i, n) cin >> h[i];
	//nが小さいとセグフォになる可能性
	VI dp(1000010,INF);
	//初期化
	dp[0]=0;
	rep(i,n){
		rep(w,k+1){
			if(i+w>=n) continue;
			ll cost=abs(h[i+w]-h[i]);
			dp[i+w]=min(dp[i+w],dp[i]+cost);
		}
	}
	res=dp[n-1];
	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    
    System.out.println((a * b) % 2 == 0 ? "Even" : "Odd");
  }
}


Measured memory_bytes: 21844
fn main() {
    let input: Vec<isize> = read_vec();
    let (k, x) = (input[0], input[1]);
    let start = x - k + 1;
    let end = x + k;

    for i in start..end {
        print!("{} ", i);
    }
    println!("\n");
}





//**********************************************************************************************************************************************//

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

const int maxn = 2e5 + 5;
int n, m;
map<int, int> hs[maxn];

void solve() {
    cin >> n >> m;
    FOR(i, 0, m) {
        int u, v; cin >> u >> v; u--, v--;
        hs[u][v] = hs[v][u] = 1;
    }
    FOR(i, 1, n) {
        if (hs[0][i] && hs[i][n - 1]) {
            cout << "POSSIBLE\n";
            return;
        }
    }
    cout << "IMPOSSIBLE\n";
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}

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

int H, W, Max;
queue<pair<int, pair<int, int>>> Q;
int dist[1002][1002]; // represents 2D distance
bitset<1002> G[1002];
char tmp;

int d;
short dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
pair<int, int> u, newu;
void bfs()
{
	while (!Q.empty())
	{
		d = Q.front().first;
		u = Q.front().second;
		Q.pop();
		if (dist[u.first][u.second] != -1)
			continue;									 // If visited (distance has been set), continue
		dist[u.first][u.second] = d; // Set distance

		for (int i = 0; i < 4; i++)
		{
			newu = make_pair(u.first + dx[i], u.second + dy[i]);
			if (newu.first < 0 || newu.first >= H || newu.second < 0 || newu.second >= W)
				continue;
			Q.push(make_pair(d + 1, newu));
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	memset(dist, -1, sizeof(dist));
	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> tmp;
			if (tmp == '.')
				G[i][j] = false;
			else
			{
				G[i][j] = true;
				Q.push(make_pair(0, make_pair(i, j)));
			}
		}
	}

	bfs();
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (dist[i][j] > Max)
				Max = dist[i][j];
		}
	}

	cout << Max << "\n";
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<int> a(n); 
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }

  vector<int> ans(n);
  rep(i,n){
    ans[a[i]] = i;
    ans[a[i]]++;
  }

  rep(i,n){
    cout << ans[i];
    if(i != n-1) cout << " ";
  }
  cout << endl;

}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=10005,INF=1<<29;
int dp[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int C,N,M;cin>>C>>N>>M;
    vector<int> w(N),v(N);
    for(int i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;j<=C;j++){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j+w[i]<=C) dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
        }
    }
    
    for(int k=1;k<=M;k++){
        int ans=0;
        for(int j=0;j<=C/k;j++){
            ans=max(ans,dp[N][j]);
        }
        cout<<ll(ans)*ll(k)<<endl;
    }
}



Measured memory_bytes: 394092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());

            boolean ok = false;

            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= m; j++) {
                    if ((i * (m - j) + (n - i) * j) == k) ok = true;
                }
            }
            out.println(ok ? "Yes" : "No");

        }

    }
}



Measured memory_bytes: 23764
/* 
 Author:N_o_o_B 
 Created:September 21 2019 17:21:00
*/
#include <bits/stdc++.h>
using namespace std;

#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll; 
#define all(x) x.begin(),x.end()
#define endl '\n'
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n,m;
    cin >> m >> n;
    int a,b;
    cin >> a >> b;
    vector<vi> ans(n+1,vi(m+1));
    for(int i=1;i<=a;i++) for(int j=1;j<=b;j++) ans[i][j]=1;
    for(int i=a+1;i<=n;i++) for(int j=b+1;j<=m;j++) ans[i][j]=1;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            cout << ans[j][i];
        }
        cout << endl;
    }
   
    time_taken();
    return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i],A[i]--;
    vector<int> idx(N);
    for(int i=0; i<N; i++) idx[A[i]] = i;
    ll ans = 0;
    set<int> se;
    for(int x=N-1; x>=0; x--){
        vector<int> l(2,-1);
        vector<int> r(2,N);
        int i = idx[x];
        se.insert(i);
        {
            auto itr = se.find(i);
            for(int j=0; j<2; j++){
                if(itr == se.begin()) break;
                itr--;
                l[j] = *itr;
            }
        }
        {
            auto itr = se.find(i);
            for(int j=0; j<2; j++){
                itr++;
                if(itr == se.end()) break;
                r[j] = *itr;
            }
        }
        vector<int> ls(2);
        vector<int> rs(2);
        // 奥
        ls[0] = l[0] - l[1];
        // 手前
        ls[1] = i - l[0];
        // 奥
        rs[1] = r[1] - r[0];
        // 手前
        rs[0] = r[0] - i;
        ll c = (ll)ls[0]*rs[0] + (ll)ls[1]*rs[1];
        ans += c * (x+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

int N;
int cnt[3];
double dp[303][303][303];

double func(int a, int b, int c) {
	if (a < 0 || b < 0 || c < 0) return 0;
	if (a == 0 && b == 0 && c == 0) return 0;
	if (dp[a][b][c] != 0) return dp[a][b][c];
	double ret = 0;
	ret += (double)a / (a + b + c) * func(a - 1, b, c);
	ret += (double)b / (a + b + c) * func(a + 1, b - 1, c);
	ret += (double)c / (a + b + c) * func(a, b + 1, c - 1);
	ret += (double)N / (a + b + c);
	return dp[a][b][c] = ret;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		cnt[--a]++;
	}
	printf("%.15f\n", func(cnt[0], cnt[1], cnt[2]));
	return 0;
}

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

int main()
{
	int N;
	string s;
	cin >> N >> s;
	int l = 0, r = 0;
	while (s[l] == '<') l++;
	while (s[N - r - 1] == '>') r++;
	cout << N - min(l, r) << endl;
	return 0;
}

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

int main()
{
  vector<int> tre(3);
  cin >> tre[0] >> tre[1] >> tre[2];
  sort(tre.begin(),tre.end());
  int ans = tre[0] * tre[1] / 2;
  cout << ans << endl;
    
}


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

vector<vector<int>> c;

int Dijsktra(int s) {
  vector<int> color(10), d(10, 1000000000), p(10, -1);
  d[s] = 0;
  while (true) {
    int min_cost = 1000000000, u;
    for (int i = 0; i < 10; i++)
      if (color[i] != 2 && d[i] < min_cost)
        min_cost = d[i], u = i;
    if (min_cost == 1000000000)
      break;
    color[u] = 2;
    for (int v = 0; v < 10; v++) {
      if (color[v] != 2 && c[u][v] != 0)
        if (d[u] + c[u][v] < d[v])
          d[v] = d[u] + c[u][v], p[v] = u, color[v] = 1;
    }
  }

  return d[1];
}

int main() {
  int H, W;
  cin >> H >> W;
  c.resize(10, vector<int>(10));
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j)
      cin >> c[i][j];
  vector<vector<int>> A(H, vector<int>(W));
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      cin >> A[i][j];

  int n[10] = {};
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      if (A[i][j] != -1)
        n[A[i][j]]++;
  int ans = 0;
  for (int i = 0; i < 10; ++i)
    ans += Dijsktra(i) * n[i];

  cout << ans << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> frame(W + 2);
  for (int i = 0; i < W + 2; i++){
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++){
    cout << '#';
    for (int j = 1; j < W + 1; j++){
      cin >> frame.at(j);
      cout << frame.at(j);
    }
    cout << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++){
    cout << '#';
  }
  cout << endl;      
}

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

int main(){
  string s,t;
  cin>>s>>t;
  cout<<t<<s<<endl;
}
  

Measured memory_bytes: 256
alpha = [0] * 26
S = []
while True:
    try:
        S += list(input())
    except EOFError:
        break
for s in S:
    if not s.isalpha():
        continue
    c = ord(s.lower())-97
    alpha[c] += 1
for i,a in enumerate(alpha):
    s = chr(i+97)
    print(s + ' : ' + str(a))


Measured memory_bytes: 5576
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int[] a; readC(5, a);

  auto b = a.map!(ai => (ai+9)/10*10).array;
  auto r = 1000;
  foreach (i; 0..5)
    r = min(r, b.sum-b[i]+a[i]);

  writeln(r);
}


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

int main() {
    int x, y;
    cin >> x >> y;
    bool flag = false;

    for (int c = 0;c <= x;c++) {
        int t = (x - c);
        if (2 * c + 4 * t == y) flag = true;
    }

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

    return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] d = new int[n];
        for(int i=0;i<d.length;i++)
        {
            d[i]=scan.nextInt();
        }
        Arrays.sort(d);
        int tmp = d[0],count=1;
        for(int i=1;i<n;i++)
        {
            if(tmp!=d[i])
            {
                tmp=d[i];
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn = 2123;
int s[maxn];
int main() {
    int n, a, b, t, i, j, temp;
    cin >> n >> a >> b;
    t = b - a + 1;  //环的大小
    for (i = 1; i <= n; i++) {
        for (j = i + 1; j <= n; j++) {
            if (j <= a || i >= b) {
                temp = j - i;
                s[temp]++;
            }
            else if (i <= a && j >= b) {
                temp = j - i - t + 2;
                s[temp]++;
            }
            else if (i <= a && (j >= a && j <= b)) {
                temp = min(j - a, t - (j - a)) + a - i;
                s[temp]++;
            }
            else if (j >= b && (i >= a && i <= b)) {
                temp = min(b - i, t - (b - i)) + j - b;
                s[temp]++;
            }
            else {
                temp = min(j - i, t - (j - i));
                s[temp]++;
            }
            //cout << i<<"-"<<j<<":"<<temp << endl;//测试
        }
    }
    for (i = 1; i <= n - 1; i++)cout << s[i] << endl;
    return 0;
}

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

int main(){
  string s, t;  cin >> s >> t;
  int table_len = (int)'z' - (int)'a' + 1;
  vector<int> stable(table_len, 0), ttable(table_len, 0);
  for(int i=0; i<s.size(); i++){
    stable[(int)s[i]-(int)'a']++;
    ttable[(int)t[i]-(int)'a']++;
  }
  sort(stable.begin(), stable.end());
  sort(ttable.begin(), ttable.end());
  string ans = "Yes";
  for(int i=0; i<table_len; i++)
    if(stable[i] != ttable[i])  ans = "No";

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


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

using namespace std;
using i64 = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int K = 1000;
const int NMAX = 1000;
#define FILENAME ""   

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
//	freopen("symposium.in", "r", stdin);
//	freopen("symposium.out", "w", stdout);
   	int n;
   	cin >> n;
   	map <string, int> m;
   	char t;
   	for (int i = 0; i < n; i++)
   	{
   	 	string s;
   	 	cin >> s;
   	 	if (i == 0)
   	 	{
   	 	 	m[s]++;
   	 	 	t = s[sz(s) - 1];
   	 	}
   	 	else 
   	 	{
   	 	 	if (s[0] != t)
   	 	 	{
   	 	 	 	cout << "No";
   	 	 	 	re 0;
   	 		}
   	 		if (m[s] > 0)
   	 		{
   	 		 	cout << "No";
   	 		 	re 0;
   	 		}
   	 		t = s[sz(s) - 1];
   	 		m[s]++;
   	 	}
   	}
   	cout << "Yes";

   	re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long ;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(int H, int W, vector<vector<char>> &area){

    bool flg = true;
    for(int i = 0; i != H; ++i){
        for(int j = 0; j != W; ++j){
            if(area.at(i).at(j) == '#') flg = false;
        }
        if(flg){
            for(int j = 0; j != W; ++j){
                area.at(i).at(j) = 'N';
            }
        }
        flg = true;
    }

    cerr << "called"s << endl;

    for(int j = 0; j != W; ++j){
        for(int i = 0; i != H; ++i){
            if(area.at(i).at(j) == '#') flg = false;
        }
        if(flg){
            for(int i = 0; i != H; ++i){
                area.at(i).at(j) = 'N';
            }
        }
        flg = true;
    }

    cerr << "called"s << endl;

    return;    
}

int main(){

    int H, W;
    cin >> H >> W;
    vector<vector<char>> area(H, vector<char>(W));
    for(int i = 0; i != H; ++i){
        for(int j = 0; j != W; ++j){
            cin >> area.at(i).at(j);
        }
    }

    solver(H, W, area);

    bool flg = false;
    for(int i = 0; i != H; ++i){
        for(int j = 0; j != W; ++j){
            if(area.at(i).at(j) != 'N'){
                cout << area.at(i).at(j);
                flg = true;
                }
        }
        if(flg) cout << endl;
        flg = false;
    }

    return 0;
}

Measured memory_bytes: 3644
M(int*a){return*1[&a]-*a;}n[];*s="%d %d %d %d %d\n";main(){qsort(n,scanf(s,n,n+1,n+2,n+3,n+4,n+5),4,M);exit(!printf(s,*n,n[1],n[2],n[3],n[4]));}

Measured memory_bytes: 0
#include<stdio.h>
#define NMAX 200000
#define RMAX 1000000000
int main()
{
	int a[NMAX] = {0};
	int n = 0;
	scanf("%d", &n);
	int maxv = 0;
	int minv = 0;
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d", &a[i]);
	}
	minv = a[0];
	maxv = a[1] - a[0];
	for(int i = 1 ; i < n ; i++)
	{
		maxv = (maxv > a[i] - minv)?maxv:(a[i] - minv);
		minv = (minv < a[i])?minv:a[i];
	}
	printf("%d\n", maxv);
	return 0;
}


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

const int N = 1e5 + 10;

int n, a[N], sum[N];

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++)	scanf("%d", a+i);
	a[0] = a[n+1] = 0;
	sum[n+1] = 0;
	for(int i=n; i>=1; i--){
		sum[i] = sum[i+1] + abs(a[i] - a[i+1]);
	}
	int cur = 0;
	for(int i=1; i<=n; i++){
		printf("%d\n", cur + sum[i+1] + abs(a[i-1] - a[i+1]));
		cur = cur + abs(a[i-1] - a[i]);
	}
	return 0;
}


Measured memory_bytes: 2048
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

a, b = MAP()
print(a*b//fractions.gcd(a, b))



Measured memory_bytes: 63980
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    int A,B,C;
    cin>>A>>B>>C;
    int a=0;
    int b=0;

    if(A==5){
        a++;
    }
    else{
        b++;
    }
    if(B==5){
        a++;
    }
    else{
        b++;
    }
    if(C==5){
        a++;
    }
    else{
        b++;
    }
    if(a==2&&b==1){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
    char a[2];
    int A,B;
    scanf("%d%s%d",&A,a,&B);
    if(a[0]=='+')
    printf("%d",A+B);
    else
    {
        printf("%d",A-B);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int INF = 1<<30;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = -INF;
    ans = max(ans, a + b);
    ans = max(ans, a - b);
    ans = max(ans, a * b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
function Main(input) {
  input=input.split("\n");
  var array=input[0].split(' ').map(e=>{
    return e-0;
  });
  var a=array[0];
  var b=array[1];
  console.log((4*a>=b&&b>=2*a&&b%2===0)?'Yes':'No');
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 29464
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

k = I()
s = S()
if len(s) <= k:
    print(s)
else:
    print(s[:k]+'...')


Measured memory_bytes: 72544