akhauriyash/Code-Regression huggingface dataset:
//  Copyright © 2020 Kavish Lodha. All rights reserved.
#include <bits/stdc++.h>
using namespace std;
#define vll vector<long long>
#define mll map<long long,long long>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define pb push_back
#define prll pair<long long,long long>
typedef long long ll;
typedef long double ld;
#define rep(i,a,n)   for(ll i=a; i<n; i++)
#define rrep(i,a,n)  for(ll i=n-1; i>=a; i--)
typedef map<string,ll> msl;
#define mx 2001
#define mod 1000000007
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll extgcd(ll a,ll b,ll& x,ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll revrsno(ll n){
    ll k=0;
    vll z;
    while(n>0){
        z.pb(n%10);
        n/=10;
    }
    rep(i,0,z.size()) k=k*10+z[i];
    return k;
}
bool isPrime(ll n){
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
bool isPowerOfTwo(ll n) { 
   if(n==0) 
   return false; 
   return (ceil(log2(n)) == floor(log2(n))); 
}
ll powm(ll a,ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}
ll divide(ll a,ll b) {
	return (a % mod) * powm(b, mod - 2) % mod;
}
ll mul(ll a,ll b) {
	return ((a % mod) * (b % mod)) % mod;
}
 
ll add(ll a,ll b) {
	return (a % mod + b % mod) % mod;
}
ll Totfun(ll n){
    ll z=n;
    if(n%2==0){
        while(n%2==0){
            n/=2;
        }
        z/=2;
    }
    for(ll i=3;i<=sqrt(n);i+=2){
        if(isPrime(i)&&n%i==0){
          while(n%i==0){
            n/=i;
          }
        z-=z/i;  
        }
    }
    if(n>1){
        z-=z/n;
    }
    return z;
}
ll maxPrimeFactor(ll n) { 
    ll maxPrime=-1; 
    while(n%2==0){
        maxPrime=2; 
        n>>=1; 
    } 
    for (ll i=3;i<=sqrt(n);i+=2) { 
        while(n%i==0){ 
            maxPrime=i; 
            n=n/i; 
        } 
    } 
    if (n>2) maxPrime=n; 
    return maxPrime; 
} 
ll nCr(ll n,ll r){
    if(r>n||r<0) return 0;
    ll z=1;
    for(ll i=n-r+1;i<=n;i++){
        z*=i;
        z/=(i+r-n);
    }
    return z;
}

vll a[mx];
ll l[mx],d[mx];
ll z[mx];
void bfs(ll x){
    queue<ll> q;
    q.push(x);
    l[x]=1;
    d[x]=0;
    while(!q.empty()){
        ll cur=q.front();
        q.pop();
        for(ll i : a[cur]){
            if(1-l[i]){
                q.push(i);
                d[i]=d[cur]+1;
                l[i]=1;
            }
        }
    }
}
int main(){
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
   cout.tie(NULL);
   ll n,x,y;
   cin>>n>>x>>y;
   rep(i,1,n){
       a[i].pb(i+1);
       a[i+1].pb(i);
   }
   a[x].pb(y);
   a[y].pb(x);
   rep(i,1,n+1){
       bfs(i);
       rep(j,1,n+1){
           z[d[j]]++;
           l[j]=0;
       }
   }
   rep(i,1,n) cout<<z[i]/2<<" ";
   return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define MAXN 100000
using namespace std;

int t;
int n,k;
int pos[MAXN];
vector<int>dis;

void solve()
{
	if(n<=k)
	{
		cout<<"0"<<endl;
		return;
	}
	for(int i=1;i<n;i++)
	{
		dis.push_back(pos[i]-pos[i-1]);
	}
	sort(dis.begin(),dis.end());
	int res=0;
	for(int i=0;i<n-k;i++)
	{
		res+=dis[i];
	}
	cout<<res<<endl;
	dis.clear();
}

void input()
{
	scanf("%d",&t);
	for(int i=0;i<t;i++)
	{
		scanf("%d%d",&n,&k);		
		for(int i=0;i<n;i++)
		{
			scanf("%d",&pos[i]);
		}
		solve();
	}
}

int main()
{
	input();
	return 0;
}


Measured memory_bytes: 3752
N = input().split()
N = [int(i) for i in N]
Pi = [[0,0] for i in range(N[0])]
#print(Pi)

Nac = 0
Nwa = 0
for i in range(N[1]):
    M = input().split()
    p = int(M[0])
    judge = str(M[1])

    if(Pi[p-1][1] == 0):
        if(judge == 'AC'):
            Pi[p-1][1] = 1
        else:
            Pi[p-1][0] += 1

for i in range(N[0]):
    if(Pi[i][1] == 1):
        Nac += Pi[i][1]
        Nwa += Pi[i][0]
print(Nac, Nwa)
    


Measured memory_bytes: 13172
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int m,f,r;
  while(cin>>m>>f>>r){
    if(m==-1 && f==-1 && r==-1) return 0;
    
    if(m==-1 || f==-1) cout<<'F'<<endl;
    else if(m+f>=80) cout<<'A'<<endl;
    else if(m+f>=65) cout<<'B'<<endl;
    else if(m+f>=50) cout<<'C'<<endl;
    else if(m+f>=30 && r>=50) cout<<'C'<<endl;
    else if(m+f>=30) cout<<'D'<<endl;
    else cout<<'F'<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  vector<vector<int>> cost(10,vector<int>(10));
  int H,W;
  cin >> H >> W;
  vector<vector<int>> wall(H,vector<int>(W));
  rep(y,10) rep(x,10) cin >> cost[y][x];
  rep(y,H) rep(x,W) cin >> wall[y][x];

  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  ll ans = 0;
  rep(y,H) rep(x,W){if(wall[y][x] == -1) continue;ans += cost[wall[y][x]][1];}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll n,k;
    cin>>n>>k;
    string a;
    cin>>a;
    a[k-1]+=32;
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
L = [0]*m
R = [0]*m
for i in range(m):
    L[i],R[i] = map(int,input().split())
if min(R) - max(L) >= 0:
    print(min(R)-max(L)+1)
else:
    print(0)

Measured memory_bytes: 10868
from collections import deque
def main():
    N = int(input())
    # 辺の集合を隣接リストとして入力
    E = [[] for i in range(N+1)]
    edge_order = []
    for i in range(N-1):
        a,b = map(int, input().split())
        E[a].append(b)
        edge_order.append(b)
    
    # 頂点1から幅優先探索
    queue = deque([1])
    color = [0] * (N+1) 
    while queue:
        V = queue.popleft()
        c = 1
        for i in E[V]:
            if i < V:
                continue
            if c == color[V]:
                c += 1
            color[i] = c
            c += 1
            queue.append(i)

    print(max(color))
    for i in edge_order:
        print(color[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 18556
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int64 i = 1; i <= (int64)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
int64 gcd(int64 a, int64 b) {
	return b != 0 ? gcd(b, a % b) : a;
}
void solve() {
	int64 k; cin >> k;
	int64 ans = 0;
	repn (a, k) {
		repn (b , k) {
			repn (c, k) {
				int64 tmp = gcd(c, gcd(a, b));
				ans += tmp;
			}
		}
	}
	cout << ans << endl;
	return;
}

int main() {
	solve();
  return 0;
}

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

int main() {
	// your code goes here
	cin.tie(NULL);
	cout.tie(NULL);
	
	long long n,k;
	
	while(cin>>n && cin>>k)
	{
		vector<long long>cost(n);
		
		for(int i=0;i<n;i++)cin>>cost[i];
		
		vector<long long>dp(n,INT_MAX);
		
		dp[0] = 0;
		dp[1] = abs(cost[1]-cost[0]);
		
		for(int i=2;i<n;i++)
		{
			for(int j=i-1;j>=0 && j>=i-k;j--)
			{
				dp[i] = min(dp[i],dp[j]+abs(cost[i]-cost[j]));
			}
		}
		
		cout<<dp[n-1]<<endl;
	}
	return 0;
}

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

int main(){
    int h,n;cin>>h>>n;
    int a,b;
    vector<int> dp(20000,-1);
    dp[0]=0;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        for(int j=a;j<20000;j++){
            if(dp[j-a]==-1){
            }
            else{
                if(dp[j]==-1){
                    dp[j]=dp[j-a]+b;
                }
                else{
                    dp[j]=min(dp[j],dp[j-a]+b);
                }
            }
        }
    }
    int ans=1000000000;
    for(int i=h;i<20000;i++){
        if(dp[i]!=-1){
            ans=min(ans,dp[i]);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;

  long ans = 0;

  for (long i = 0; i * i <= N; i++) if (i * i <= N) ans = max(ans, i * i);

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
# Initializing variables
monsterHP, specialMoves = map(int, input().split())
a = list(map(int, input().split()))
sum = 0

# Calculating if the raccoon can win without using the same move twice or more.
for i in range(specialMoves):
    sum += a[i]

if sum >= monsterHP:
    print("Yes")
else:
    print("No")









Measured memory_bytes: 13964
#include "bits/stdc++.h"
using namespace std;

struct Point {double x,y;};
void koch(int n,Point a,Point b){
	setvbuf(stdout, (char *)NULL, _IONBF, 0);
	if(n==0)return;
	Point s,t,u;
	double th=M_PI * 60.0/180.0;
	s.x=(2.0*a.x+1.0*b.x)/3.0;
	s.y=(2.0*a.y+1.0*b.y)/3.0;
	t.x=(1.0*a.x+2.0*b.x)/3.0;
	t.y=(1.0*a.y+2.0*b.y)/3.0;
	u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
	u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1,t,b);
}

int main(){
Point a,b;
int n;
scanf("%d",&n);
a.x=0;
a.y=0;
b.x=100;
b.y=0;
printf("%.8f %.8f\n",a.x,a.y);
koch(n,a,b);
printf("%.8f %.8f\n",b.x,b.y);
return 0;
}

Measured memory_bytes: 3204
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define eb emplace_back
#define ep emplace
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
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;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}

main(){
    ll a=lin(),b=lin(),k=lin();
    cout<<max(a-k,(ll)0);
    cout<<" "<<max(b-max(k-a,(ll)0),0ll);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int>h(n + 5, 0);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  vector<int> dp(n + 5, 1001001001);
  dp[0] = 0;
  
  for(int i = 0; i <= n; i++){
    for (int j = 0; j <= min(k, n-i); j++){
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i+j] - h[i]));
    }
  }
  /*
  for(int i=0; i<n; i++){
    cout << dp[i] << " ";
  }
  */
  cout << dp[n - 1] << "\n";
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[m];
		for(int i=0; i<n; i++){
			x[i] = sc.nextInt();
		}
		for(int i=0; i<m; i++){
			y[i] = sc.nextInt();
		}
		Arrays.sort(x);
		Arrays.sort(y);
		boolean bl = false;
		for(int i=X+1; i<=Y; i++){
			if(x[n-1]<i && i<=y[0]){
				bl = true;
				break;
			}
		}
		System.out.println(bl==true ? "No War" : "War");
	}
}

Measured memory_bytes: 23892
#define pb push_back
#define vi vector<int>
#include<bits/stdc++.h>
using namespace std;
int pro[300000];
void solve(){
	int n;
	cin >> n; 
	for(int i = 0; i < n; i++) cin >> pro[i];
	int ans = INT_MIN, min_ = 0;
	for(int i = 1; i < n; i++){
		ans = max(ans, pro[i] - pro[min_]);
		if(pro[min_] > pro[i]) min_ = i;
	}
//	if(ans == 0) ans = -1;
	cout << ans << endl;
}
int main(void){
	solve();
	return 0;
}


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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846


    void solve(){
        int n,m;
        cin>>n>>m;
        vector<int>sw[n+1];
        for(int i=0;i<m;i++){
            int s;
            cin>>s;
            for(int j=0;j<s;j++){
                int x;
                cin>>x;
                --x;
                sw[x].push_back(i);
            }
        }
        vector<int>p(m);
        for(int i=0;i<m;i++)
            cin>>p[i];
        int total=0;
        for(int i=0;i<(int)(1<<n);i++){
            vector<int>bulb(m);
            for(int j=0;j<n;j++){
                if(i&(1<<j)){
                    for(auto z : sw[j])
                        bulb[z]++;
                }
            }
            bool flag=true;
            for(int j=0;j<m;j++){
                if(bulb[j]%2!=p[j]){
                    flag=false;
                    break;
                }
            }
            if(flag)
                total++;
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


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

using namespace std;
int a[200024];
long long sm[200024];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%d",&a[0]);
	sm[0]=a[0];
	long long sum=a[0];
	for(int i=1;i<n;i++){
		scanf("%d",&a[i]);
		sm[i]=sm[i-1]+a[i];
		sum+=a[i];
	}
	long long ans=abs(2*a[0]-sum);
	for(int i=1;i<n-1;i++){
			ans=min(abs(2*sm[i]-sum),ans);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
let cnt = ref 0

let merge a l m r =
  let init_ary n p = Array.init (n + 1) (fun i -> if i = n then max_int else a.(p + i)) in
  let ai = init_ary (m - l) l in
  let aj = init_ary (r - m) m in
  let rec doit = function
    | (_, _, k) when k = r -> ()
    | (i, j, k) ->
      incr cnt;
      if ai.(i) <= aj.(j) then begin
        a.(k) <- ai.(i);
        doit (i + 1, j, k + 1)
      end else begin
        a.(k) <- aj.(j);
        doit (i, j + 1, k + 1)
      end in
  doit (0, 0, l)

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  print_int a.(0);
  for i = 1 to n - 1 do
    print_string " ";
    print_int a.(i);
  done;
  print_newline ();
  print_int !cnt;
  print_newline ()

Measured memory_bytes: 19480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

ll N, K, S;

void solve()
{
	for(int i=0;i<K;++i) cout << S << ' ';
	if(S != 1000000000){
	    for(int i=K;i<N;++i) cout << 1000000000 << ' ';
	}else{
	    for(int i=K;i<N;++i) cout << 999999999 << ' ';
	}
	cout << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> K >> S;
	solve();
	return 0;
}

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

int main(){
    long long n;
    cin >> n;
    string s;
    cin >> s;

    long long x = 0;
    long long maxv = 0;

    for(long long i = 0; i < n; i++){
        if(s[i] == 'I'){
            x++;
            maxv = max(maxv, x);
        }
        else if(s[i] == 'D'){
            x--;
            maxv = max(maxv, x);
        }
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int count = 0;
    String tmp = "";
    for (int i = 0; i < s.length(); i++) {
      if (i == s.length() - 2 && s.charAt(i) == s.charAt(i + 1)) {
        count++;
        break;
      }
      if (tmp.length() == 1 && tmp.charAt(0) == s.charAt(i))
        tmp = String.valueOf(s.charAt(i++)) + String.valueOf(s.charAt(i));
      else
        tmp = String.valueOf(s.charAt(i));
      count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 40716
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

class UnionFind():
    def __init__(self, n):
        """
        Parameters
        ----------
        n:int
            the number of node
        """
        self.par = [-1] * n # -self.par[i] means the tree size

    def find(self, x):
        """
        Parameters
        ----------
        x:int
            target node

        Return
        ----------
        res:int
            root node
        """
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.par[x] > self.par[y]: # lesser has many nodes
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        '''
        Parameters
        ----------
        x:int
            target node
        
        Return
        ----------
        x:int
            size of  group  to which belongs
        '''
        return - self.par[self.find(x)]
        

n, m, k = inpl()
dame = collections.defaultdict(set)
uf = UnionFind(n)
ans=[0]*n
for i in range(m):
    a, b = inpl()
    a, b = a - 1, b - 1
    dame[a].add(b)
    dame[b].add(a)
    uf.union(a,b)
for i in range(k):
    c, d = inpl()
    c, d = c - 1, d - 1
    if uf.is_same(c,d):
        dame[c].add(d)
        dame[d].add(c)
for i in range(n):
    ans[i] = uf.size(i) - len(dame[i]) - 1
    # 同じグループに所属 - (友達+ブロック) - 自分
print(*ans)

'''

'''

Measured memory_bytes: 123736
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

struct DATA{
  int x;
  int y;
  int num;
};

int mm[3000][3000] = {};

vector<DATA> dice_vec(int sx, int sy,int *dice, char *rot){
  int rotate[4][6] =
    {{5,4,2,3,0,1}, //L
     {4,5,2,3,1,0}, //R
     {0,1,4,5,3,2}, //B
     {0,1,5,4,2,3}};//F

  vector<DATA> vec; 

  int u = 4;
  
  vec.push_back({sx,sy,dice[u]});
  
  for(int i=0;rot[i]!='\0';i++){
    int p = 0;
    int new_dice[6];

    if(rot[i] == 'L'){
      p = 0;
      sx--;
    }
    if(rot[i] == 'R'){
      p = 1;
      sx++;
    }
    if(rot[i] == 'B'){
      p = 2;
      sy++;
    }
    if(rot[i] == 'F'){
      p = 3;
      sy--;
    }
    
    for(int j=0;j<6;j++){
      new_dice[j] = dice[rotate[p][j]];
    }
    for(int j=0;j<6;j++)
      dice[j] = new_dice[j];

    vec.push_back({sx,sy,dice[u]});
  }

  return vec;
}

int dice[SIZE][6]; //lrfbdu
char rot[SIZE][50];

void calc(int n){
  int dp[1<<16] = {};
  int sx[SIZE],sy[SIZE];
  
  for(int i=0;i<n;i++){
    scanf("%d%d",sx+i,sy+i);

    for(int j=0;j<6;j++){
      scanf("%d",dice[i]+j);
    }

    scanf("%s",rot[i]);
  }

  vector<DATA> vec[20];
  
  for(int i=0;i<n;i++){
    vec[i] = dice_vec(sx[i],sy[i],dice[i], rot[i]);

    set<pair<int,int> > ss;
    for(int j=(int)vec[i].size()-1;j>=0;j--){
      if(ss.find({vec[i][j].x,vec[i][j].y}) == ss.end()){
        ss.insert({vec[i][j].x,vec[i][j].y});
      }else{
        vec[i][j].num = 0;
      }
      mm[vec[i][j].x+1500][vec[i][j].y+1500] = 0;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<vec[i].size();j++){
      mm[vec[i][j].x+1500][vec[i][j].y+1500] |= 1<<i;
    }
  }
  
  for(int i=0;i<(1<<n);i++){

    for(int j=0;j<n;j++){
      if(i & (1<<j)) continue;

      int next_bit = i | (1<<j);
      int sum = dp[i];
      //debug(sum);
      
      for(int k=0;k<vec[j].size();k++){
        //cerr << vec[j][k].x << " " << vec[j][k].y << " : " << mm[vec[j][k].x+1500][vec[j][k].y+1500] << endl;
        if((mm[vec[j][k].x+1500][vec[j][k].y+1500] | next_bit) == next_bit){
          sum += vec[j][k].num;
        }
      }
      //debug(sum);

      dp[next_bit] = max(dp[next_bit],sum);
    }
  }

  
  printf("%d\n",dp[(1<<n)-1]);
}

int main(){
  int n;

  while(1){
    scanf("%d",&n);
    if(n == 0) break;
    calc(n);
  }
  
  return 0;
}

Measured memory_bytes: 7144
local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
table.sort(a, function(x, y) return x > y end)
local ans = a[1]
for i = 2, n - 1 do
  local p = 1 + (i // 2)
  ans = ans + a[p]
end
print(ans)


Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
bool cmp(long long int x,long long int y)
{
   return x>y;
}
int main(void)
{
   long long int n,m,x,ans=0;
      cin>>n>>m;
      for(long long int i=0;i<m;i++)
      {
         cin>>x;
         ans=ans+x;
      }
      if(ans>n)
         cout<<-1<<endl;
      else
         cout<<n-ans<<endl;
   return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int, H: int, M: int):
    ax = A * math.cos((H+M/60) * 2 * math.pi / 12)
    ay = A * math.sin((H+M/60) * 2 * math.pi / 12)
    bx = B * math.cos(M * 2 * math.pi / 60)
    by = B * math.sin(M * 2 * math.pi / 60)

    return math.sqrt((ax - bx)**2 + (ay - by)**2)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    print(solve(A, B, H, M))


if __name__ == '__main__':
    main()
    

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

int main() {
  int N;
  string S;
  cin>>N>>S;
  if(N%2==1){cout<<"No"<<endl;}
  else{
    N/=2;
    bool judge=true;
    rep(i,N){
      if(S.at(i)!=S.at(N+i)){judge=false;}
    }
    if(judge){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll n;
l_l p[220000];
ll h[220000],a[220000];
ll dp[220000];
ll bit[220000];
ll max_val(ll *bit,ll ind){
    ll res=0;
    ind++;
    while(ind){
        res=max(res,bit[ind]);
        ind-=ind&-ind;
    }
    return res;
}
void set_val(ll *bit,ll val,ll ind){
    ind++;
    while(ind<220000){
        bit[ind]=max(bit[ind],val);
        ind+=ind&-ind;
    }
    return;
}
int main(){
    cin>>n;
    rep(i,220000)bit[i]=0,dp[i]=0;
    rep(i,n)cin>>h[i];
    rep(i,n)cin>>a[i];
    rep(i,n){
        p[i]={h[i],i};
    }
    sort(p,p+n);
    ll ans=0;
    //cout<<111<<endl;
    rep(i,n){
        ll x=p[i].se;
        dp[p[i].fi]=max(dp[p[i].fi],max_val(bit,x)+a[x]);
        set_val(bit,dp[p[i].fi],x);
        chmax(ans,dp[p[i].fi]);
    }
    //cout<<dp[1]<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13260
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long k = sc.nextLong();
    if(k==0){
      System.out.println(a+" "+b);
      System.exit(0);
    }
    if(b<=k-a){
      b = 0;
    }else if(k-a<0){
    }else{
      b = b-(k-a);
    }
    if(a<=k){
      a = 0;
    }else{
      a = a-k;
    }
    System.out.println(a+" "+b);
  }
}


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

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

using namespace std;

int main(){
  string a,b;cin>>a>>b;
  if(a.size()<b.size()){
    rep(i,b.size()-a.size()){
      a = "0"+a;
    }
  }else{
    rep(i,a.size()-b.size()){
      b = "0"+b;
    }
  }

  if(a>b){
    cout<<"GREATER";
  }else if(a<b){
    cout<<"LESS";
  }else{
    cout<<"EQUAL";
  }
  return 0;
}

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

int main() {
	int a,b;
	cin>>a>>b;
	int ans=0;
	vector<int>vec(a);
	for(int i=0;i<a;i++) {
		int a;
		cin>>a;
		vec.at(i)=a;
	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	for(int i=0;i<b;i++) {
		ans+=vec.at(i);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(max(a,c)-min(a,c)<=d)cout<<"Yes"<<endl;
    else if(max(a,b)-min(a,b)<=d&&max(b,c)-min(b,c)<=d){
        cout<<"Yes"<<endl;
        }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;

	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (ans < k) {
			ans *= 2;
		}
		else {
			ans += k;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]

n = 2 ** d
result = 100 * 10

for i in range(n):
  bin_n = bin(i)[2:]
  bin_n = '0' * (d - len(bin_n)) + bin_n
  max_address = -1
  total = 0
  num_of_question = 0

  for j in range(d):
    if bin_n[j] == '1':
      total += (j+1) * 100 * pc[j][0] + pc[j][1]
      num_of_question += pc[j][0]
    
    else:
      max_address = j
  
  if total >= g:
    result = min(result, num_of_question)
  
  else:
    for _ in range(pc[max_address][0]):
      num_of_question += 1
      total += (max_address+1) * 100
      if total >= g:
        result = min(result, num_of_question)
        break

print(result)

Measured memory_bytes: 9244
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
	bool x = false;
	if((a.second*a.first) < b.second*b.first){
		x = true;
	}
    return x;
}
int main(){
	
	ll r,d,x;
	cin>>r>>d>>x;
	
	for(int i = 0; i < 10; i++){
		cout<<(r*x)-d<<"\n";
		x = (r*x)-d;
	}
	
	
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    long long n,s[100],min = 101,sum = 0;
    scanf("%lld",&n);
    for (long long i = 0; i < n; i++)
    {
        scanf("%lld",&s[i]);
        sum += s[i];
        if(s[i] % 10 != 0)
        {
            if(min > s[i])min = s[i];
        }
    }
    if(sum % 10 != 0)
    {
        printf("%lld",sum);
    }
    else
    {
        if(min == 101)
        {
            printf("0");
        }
        else
        {
            printf("%lld",sum - min);
        }
        
    }
    
}


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

int main(){
    string s;
    cin>>s;
    int ans=0;
    string t[7]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
    rep(i,7){
        if(s==t[i]){
            ans=i+1;
        }
    }
    cout << ans<<endl;
}

Measured memory_bytes: 3552
#include<iostream>

using namespace std;

int main(){
  int a,b,c,x,ans=0;
  cin >> a >> b >> c >> x;
  for (int i=0;i<=a;i++){
    if(x<i*500)break;
    for (int j=0;j<=b;j++){
      if(x<i*500+j*100)break;
      for (int k=0;k<=c;k++){
        if(x==i*500+j*100+k*50){
          ans++;
          break;
        }
  }
  } 
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define mp       make_pair
#define eb       emplace_back
 
const int MAX_V = 100100;
typedef pair<LL, LL> P;
typedef pair<LL, P>PP;
struct edge { LL to, cost; };
vector<edge> G[MAX_V];
LL d[MAX_V];
int n, m;
LL x;
LL h[MAX_V];
 
LL dijkstra() {
	for (int i = 0; i < MAX_V; i++)d[i] = HLINF;
	priority_queue<PP, std::vector<PP>, std::greater<PP>> pq;
	d[0] = 0;
	pq.emplace(mp(d[0], mp(0, x)));
	LL i, pos;
	LL lastgoal = 0;
	while (pq.size()) {
		PP p = pq.top();
		pq.pop();
		i = p.second.first;
		pos = p.second.second;
		if (d[i] < p.first)continue;
		for (int k = 0; k < G[i].size(); k++) {
			edge e = G[i][k];
			if (pos - e.cost > h[e.to]) {
				if (d[e.to] <= d[i] + pos - h[e.to])continue;
				d[e.to] = d[i] + pos - h[e.to];
				pq.emplace(mp(d[e.to], mp(e.to, h[e.to])));
				if (e.to == n - 1)lastgoal = h[e.to];
			}
			else if (0 <= pos - e.cost) {
				if (d[e.to] <= d[i] + e.cost)continue;
				d[e.to] = d[i] + e.cost;
				pq.emplace(mp(d[e.to], mp(e.to, pos - e.cost)));
				if (e.to == n - 1)lastgoal = pos - e.cost;
			}
			else {
				LL num = abs(pos - e.cost);
				if (pos + num > h[i])continue;
				if (d[e.to] <= d[i] + num + e.cost)continue;
				d[e.to] = d[i] + num + e.cost;
				pq.emplace(mp(d[e.to], mp(e.to, 0)));
				if (e.to == n - 1)lastgoal = 0;
			}
		}
	}
	return (d[n - 1] == HLINF ? -1 : d[n - 1] + h[n - 1] - lastgoal);
}
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int a, b;
	LL t;
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> t;
		a--, b--;
		if (h[a] >= t)G[a].emplace_back(edge{ b,t });
		if (h[b] >= t)G[b].emplace_back(edge{ a,t });
	}
	cout << dijkstra() << endl;
}

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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
constexpr int INF = 0x3f3f3f3f; constexpr ll BINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

int solve() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	string s; cin >> s;
	a--, b--, c--, d--;
	auto movea = [&] () {
		if (a == c) return;
		s[a] = '.';
		if (s[a + 1] == '.')
			a++, s[a] = 'a';
		else if (s[a + 2] == '.')
			a += 2, s[a] = 'a';
		else {
			cout << "No" << endl;
			exit(0);
		}
	};
	auto moveb = [&] () {
		if (b == d) return;
		s[b] = '.';
		if (s[b + 1] == '.')
			b++, s[b] = 'b';
		else if (s[b + 2] == '.')
			b += 2, s[b] = 'b';
		else {
			cout << "No" << endl;
			exit(0);
		}
	};
	if (c > d) {
		for (int i=0;i<n;i++) {
			if (b > 0 && s[b - 1] == '.' && s[b + 1] == '.') break;
			moveb();
		}
		for (int i=0;i<n;i++) movea();
		for (int i=0;i<n;i++) moveb();
	} else {
		for (int i=0;i<n;i++) moveb();
		for (int i=0;i<n;i++) movea();
	}
	if (a == c && b == d)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int a, b;
  cin >> a >> b;
  if(a < 6) cout << 0 << endl;
  else if(a < 13) cout << b/2 << endl;
  else cout << b << endl;
  return 0;
}

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

map<string, int> mp;
int main() {
  int n;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    mp[s]++;
  }
  
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    mp[s]--;
  }
  
  int mx = 0;
  for (auto p : mp) {
    mx = max(mx, p.second);
  }
  cout << mx << endl;
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
using namespace std;

ll n;
char lst;
string s;

map < string, ll > a;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w *= -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

inline void work(){
	n = read();
	REP(i, 1, n){
		cin >> s;
		if (a[s] > 0 || s[0] != lst && i > 1){
			puts("No");
			exit(0);
		}
		a[s]++;
		lst = s[s.size() - 1];
	}
	puts("Yes");
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int max = 0;
			int start = 0;
			String sa = in.next();
			String sb = in.next();
			StringBuilder sbb = new StringBuilder();
			int s = sa.length() + sb.length() - 1;
			for (int i = 0; i < s; i++) {
				// if (max > sa.length() - start) {
				// break;
				// }
				if (i < sb.length()) {
					sbb.insert(0, sb.charAt(sb.length() - i - 1));
				} else {
					sbb.insert(0, ' ');
					start++;
				}
				if (i >= sa.length()) {
					sbb.setLength(sbb.length() - 1);
				}
				int count = 0;
				for (int posi = start; posi < sbb.length(); posi++) {
					if (sa.charAt(posi) == sbb.charAt(posi)) {
						count++;
					} else if (count != 0) {
						count = 0;
					}
					max = Math.max(count, max);
				}
			}
			System.out.println(max);
		}
		in.close();
	}
}

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

int main () {
  int N, L;
  cin >> N >> L;
  string S[110];
  for (int i=0;i<N;++i) {
    cin >> S[i];
  }
  sort(S, S + N);
  string ans;
  for (int i=0;i<N;++i) {
    ans += S[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int main(int, char *[])
{
    int N;
    vector<int> P;
    cin >> N;
    P.resize(N+1);
    for(int i = 1; i <= N; ++i)
    {
        int v;
        cin >> v;
        P[v] = i;
    }
    int fixed = 1;
    for(int i = 1, prev, num_continuous; i <= N; ++i)
    {
        if(i == 1)
        {
            num_continuous = 1;
        }
        else if(P[i] > prev)
        {
            ++num_continuous;
        }
        else
        {
            num_continuous = 1;
        }
        fixed = max(fixed , num_continuous);
        prev = P[i];
    }

    cout << (N - fixed) << endl;
    return 0;
}


Measured memory_bytes: 1024
#51 ABC131E
n,k=map(int,input().split())
import sys
if k>(n-1)*(n-2)//2:
	print(-1)
	sys.exit()
res=[[1,i+1] for i in range(1,n)]
c=0
for i in range(1,n-1):
	for j in range(i+1,n):
		if c<(n-1)*(n-2)//2-k:
			res.append([i+1,j+1])
		c+=1
print(len(res))
for t in res:
	print(" ".join(map(str,t)))

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int r;
    int ans;
    cin >> r;
    cout << pow(r, 2) << endl;
    return 0;
}

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

using namespace std;

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

int main() {
  
  int W, Q;
  while(cin >> W >> Q && (W|Q)) {
    int line[W];
    memset(line, -1, sizeof line);
    rep(_, Q) {
      char ch; cin >> ch;
      if(ch == 's') {
        int id, w;
        cin >> id >> w;
        bool good = 0;
        rep(i, W-w+1) {
          if(line[i] == -1) {
            bool ok = 1;
            rep(j, w) if(line[i+j] != -1) { ok = 0; break; }
            if(ok) { rep(j, w) line[i+j] = id; cout << i << endl; good = 1; break; }
          }
        }
        if(!good) {
          cout << "impossible\n";
        }
      }
      else {
        int id; cin >> id;
        rep(i, W) {
          for(int j=0; i+j<W && line[i+j] == id; j++) line[i+j] = -1;
        }
      }
    }
    cout << "END\n";
  }
  
  return 0;
}

Measured memory_bytes: 1168
N=int(input())
t_pre=0
x_pre=0
y_pre=0

for i in range(N):
    t,x,y = map(int,input().split())
    t_af=t-t_pre
    x_af=x-x_pre
    y_af=y-y_pre
    if (abs(x_af+y_af)<=t_af) & ((x_af+y_af+t_af)%2 == 0):
      t_pre=t
      x_pre=x
      y_pre=y
      continue
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 9136
import java.util.Scanner;

public class Main {
	static int DP(int n) {
		int COUNT = 0; 
		for(int a = 0; a < 10; a++)
			for(int b = 0; b < 10; b++)
				for(int c = 0; c < 10; c++)
					for(int d = 0; d < 10; d++) {
						if((a + b + c + d) == n)
							COUNT++;
					}
		return COUNT;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			System.out.println(DP(n));
		}
	}
}



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

class C
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		int n = h[0], k = h[1];
		var a = Read();

		for (int c = 0; c < k; c++)
		{
			var d = new int[n];
			for (int i = 0; i < n; i++)
			{
				d[Math.Max(0, i - a[i])]++;
				if (i + a[i] + 1 < n) d[i + a[i] + 1]--;
			}
			for (int i = 1; i < n; i++)
				d[i] += d[i - 1];

			if (Enumerable.SequenceEqual(a, d)) break;
			a = d;
		}
		Console.WriteLine(string.Join(" ", a));
	}
}


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

int arr[10][10];

void floyd() {
for (int k=0; k<=9; k++)
for (int i=0; i<=9; i++)
for (int j=0; j<=9; j++)
if (i!=j && j!=k && i!=k)
if (arr[i][k]+arr[k][j]<arr[i][j])
arr[i][j]=arr[i][k]+arr[k][j];
}�

int main() {
    int r,c;
    cin >> r >> c;
    
    int cost;
    long long cnt=0;
    for (int i=0;i<10;i++)
        for (int j=0;j<10;j++){
            cin >> arr[i][j];
        }
    
    floyd();
    
    for (int i=0;i<r;i++)
        for (int j=0;j<c;j++){
            cin >> cost;
            if (cost==-1)
                continue;
            cnt+=(long long)arr[cost][1];
        }
        
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                emplace_back
#define mp              make_pair
#define sz(a)           a.size()
#define mods(a, m)          ((a % m + m) % m)   
#define md(a)               mods(a, MOD)
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)     for (int i = b; i < e; i++)
#define forr(i, b, e)     for (int  i = b; i < e; i++)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;
typedef long double       ld;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e7 + 7);
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 22000
int dp[tam];
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    ll h,n;
    cin>>h>>n;
    
    forr(i,0,tam)
        dp[i]=MOD;
    dp[0]=0;
    int hi,ci;
    forr(i,0,n)
    {
        cin>>hi>>ci;
        forr(j,hi,tam)
        {
            dp[j]=min(dp[j],dp[j-hi]+ci);
        }
    }
    int minn=MOD;
    forr(j,h,tam)
    {
        minn=min(minn,dp[j]);
    }
    cout<<minn<<endl;
}
// PLUS ULTRA!


Measured memory_bytes: 384
#![allow(non_snake_case, unused_variables, unused_mut, dead_code)]
//use permutohedron::LexicalPermutation as _;
//use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    proconio::input! {
        N:i64,A:i64,B:i64
    }
    let s = N / (A + B);
    let mut ans = s * A;
    if s * (A + B) < N {
        ans += std::cmp::min(A, N - s * (A + B));
    }
    println!("{}", ans);
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N+1, 0);
  int mod = 1000000007;
  ll ans=0;
  
  rep(i, N){
    cin >> A.at(i);
    B.at(i+1) = B.at(i) + A.at(i);
  }
  rep(i, N){
   ll sum = (B.at(N) - B.at(i+1)) % mod;
    
    ans += A.at(i) * sum;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 6420
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this emplate file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;
/**
 *
 * @author naoyagonda
 */
public class Main {
    public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int input1 = scanner.nextInt();
    int input2 = scanner.nextInt();
    int a=input1,b=0;
    while(true){
	a=a-input2;
	b++;
    if(a<=0) break;
    }
    System.out.println(b);
    }
    
}

Measured memory_bytes: 21844