akhauriyash/Code-Regression huggingface dataset:
'use strict'
function otoshidama(stdin) {
  const inputs = stdin.split(' ')
  const n = parseInt(inputs[0], 10)
  const y = parseInt(inputs[1], 10)
  for (let i = 0;i <= n;i++) {
    const remain = y - 10000 * i
    if (remain === 0 && n === i) return console.log(n, 0, 0)
    else if (remain < 1000) break
    for (let j = 0;j <= n - i;j++) {
      const sen = n - i - j
      const result = remain - 5000 * j - 1000 * sen
      if (result === 0) return console.log(i, j, sen)
      else if (result < 1000) break
    }
  }
  return console.log(-1, -1, -1)
}
otoshidama(require('fs').readFileSync(0, 'utf8'))

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

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

int main(){
    int n,m,a[100010];
    cin>>n>>m;
    rep(i,m) cin>>a[i];
    ll cnt[100010];
    cnt[0]=1;
    if(a[0]==1) cnt[1]=0;
    else cnt[1]=1;
    int j=0;
    for(int i=2;i<=n;i++){
        while(a[j]<i && j<m-1) j++;
        if(a[j]==i) cnt[i]=0;
        else cnt[i]=(cnt[i-1]+cnt[i-2])%1000000007;
    }
    cout<<cnt[n]<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int N,M;cin >> N >> M;
    int A[101];
    int sum = 0;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }
    int count = 0;
    rep(i,N){
        if(A[i]*4*M >= sum){
            count++;
        }
    }
    if(count>=M)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  repp(i, 1, 10) {
    x = x * r - D;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R') ans++;
    else if(s[i]=='B') ans--;
  }
  ans>0?cout << "Yes\n":cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    
    int[][] stu = new int[N][2];
    for(int i = 0; i < N; i++){
      stu[i][0] = Integer.parseInt(sc.next());
      stu[i][1] = Integer.parseInt(sc.next());
    }
    
    int[][] check = new int[M][2];
    for(int i = 0; i < M; i++){
      check[i][0] = Integer.parseInt(sc.next());
      check[i][1] = Integer.parseInt(sc.next());
    }
    
    for(int i = 0; i < N; i++){
      int ans = 0;
      int min = 1000000000;
      int x1 = stu[i][0];
      int y1 = stu[i][1];
      for(int j = 0; j < M; j++){
        int x2 = check[j][0];
      	int y2 = check[j][1];
        int dis = Math.abs(x1-x2) + Math.abs(y1-y2);
        if(min > dis){
          min = dis;
          ans = j;
        }
      }
      System.out.println(ans+1);
    }
  }
}

Measured memory_bytes: 21844
n,k,q= map(int, input().split())
dic = {}
for i in range(q):
    a = int(input())
    if a not in dic:
        dic[a] = 0
    dic[a] += 1
for i in range(1,n+1):
    tmp = dic[i] if i in dic else 0
    print('Yes' if k - q + tmp > 0 else 'No')


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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std; 

int main(){
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<s.size();i++){
		s[i]='A'+((s[i]-'A')+n)%26;
	}
	cout<<s<<endl;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
    ll n;
    cin>>n;
    vec<ll> x(n),y(n);
    REP(i,n) cin>>x[i]>>y[i];
    ll allx=0,ally=0;
    REP(i,n){
        allx+=x[i];
        ally+=y[i];
    }

    vec<pair<long double, int>> th(n);
    REP(i,n) th[i] = make_pair(atan2((long double)y[i],(long double)x[i]),i);

    sort(all(th));

    ll ans=0;
    REP(l,n){
        rep(r,l,n){
            ll sumx=0,sumy=0;
            rep(i,l,r+1){
                sumx+=x[th[i].second];
                sumy+=y[th[i].second];
            }
            chmax(ans,sumx*sumx+sumy*sumy);
            sumx=allx-sumx;sumy=ally-sumy;
            chmax(ans,sumx*sumx+sumy*sumy);
        }
    }
    cout<<fixed<<setprecision(12)<<sqrt((long double)ans)<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  // or pb_ds;

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#ifndef DEBUG
#define endl "\n"
#endif
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

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

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

template <typename T, typename B = null_type>
using oset =
    tree<T, B, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order / order_of_key

const ld eps = 1e-12;

/*-----------------END TEMPLATE-----------------*/

int(((((((((((((((main)))))))))))))))() {
  FASTIO;
  ll n, k;
  cin >> n >> k;
  ll mod = n % k;
  ll diff = k - mod;
  cout << min(mod, diff) << endl;
}

/*

0 1 2 3 4 5 6
      B B C C

1 2 3 4 5
    A A A
B B B
      C C

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n,m,k;
const LL mod=998244353;
LL fac[N],inv[N];
LL pm(LL x,LL y){
  LL z=1;
  x%=mod;
  while(y){
    if(y&1)z=z*x%mod;
    x=x*x%mod;
    y>>=1;
  }
  return z;
}
void init(){
  fac[0]=1;
  for(int i=1;i<N;i++)fac[i]=fac[i-1]*i%mod;
  inv[N-1]=pm(fac[N-1],mod-2);
  for(int i=N-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
LL get(int x,int y){
  return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m>>k;
  init();
  LL ans=0;
  for(int i=0;i<=k;i++){
    ans=ans+m*get(n-1,i)%mod*pm(m-1,n-1-i)%mod;
    ans%=mod;
  }
  cout<<ans<<'\n';
 	return 0;
}
//

Measured memory_bytes: 6832
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 21 23:52:50 2019

@author: Yamazaki Kenichi
"""

S = int(input())
r = 10**9

a = (S-1) % r +1
b = (S-1) // r + 1
print('{} 0 0 1 {} {}'.format(r,a,b))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k;
  int ar[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin>>k;
  cout<<ar[k-1];
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{

   int a,b;
   float t;
   cin>>a>>b>>t;
   t+=.5;
   int biscouts=0;
   if(t<a)
   {
      cout<<biscouts<<endl;
   }
   else if(t==a)
      cout<<b<<endl;
   else
   {
      while(t>a)
      {
         biscouts+=b;
         t-=a;
      }
      cout<<biscouts<<endl;
   }

}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		TreeSet<Character> ts = new TreeSet<>();
		for (int i = 0; i < s.length(); i++) {
			ts.add(s.charAt(i));
		}
		if (ts.size() == 26) {
			System.out.println("None");
			return;
		}

		int a = 'a';
		int z = 'z';
		for (int i = a; i <= z; i++) {
			int ans = i;
			if ((int) ts.pollFirst() != ans) {
				System.out.println((char) ans);
				return;
			}
			if (ts.isEmpty()) {
				System.out.println("z");
				return;
			}
		}
	}
}

Measured memory_bytes: 24044
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  in(a),in(b)
#define in3(a,b,c)  in2(a,b),in(c)
#define in4(a,b,c,d)  in2(a,b),in2(c,d)
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
ll read(){
    ll f=1,x=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int n,m;
char a[maxn];
int main(){
	scanf("%s",a+1);
	int l=strlen(a+1);
	in(n);
	for(int i=1;i<=l;i+=n)cout<<a[i];
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{

	public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a;
int b;

a=sc.nextInt();
b=sc.nextInt();

if(a<b){
	System.out.println("a < b");
} else if(a==b){
	System.out.println("a == b");
} else if(a>b){
	System.out.println("a > b");
}


    }
}

Measured memory_bytes: 26228
//        ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 


#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000005
#define MOD 1000000007
                                  //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}

int main() {
    
    fastio;
    int n, k;
    cin >> n >> k;
    long long int n1 = 5000;
    long long int k1 = 5000;
    long long int C[n1+1][k1+1];
    long long int i, j;
 
    // Caculate value of Binomial Coefficient in bottom up manner
    for (i = 0; i <= n1; i++)
    {
        for (j = 0; j <= min(i, k1); j++)
        {
            // Base Cases
            if (j == 0 || j == i)
                C[i][j] = 1;
 
            // Calculate value using previosly stored values
            else
                C[i][j] = (C[i-1][j-1] % MOD + C[i-1][j] % MOD) % MOD;
        }
    }
    ll fact[k+2] = {0};
    fact[0] = 1;
    fr(x, 1, k+1)
    {
        fact[x] = ((fact[x-1] % MOD) * x) % MOD;
    }
    if(k == n)
    {
    	cout << 1 << "\n";
    	fr(x, 2, n)
    	cout << 0 << "\n";
    }
    else{
    fr(x, 1, k)
    {
        ll a1 = (C[k-1][x-1]) % MOD;
        ll a2 = ((2*C[n-k-1][x-1]) % MOD + (C[n-k-1][x]) % MOD) % MOD;
        if(x >= 2)
        a2 = (a2 + (C[n-k-1][x-2]) % MOD) % MOD;
        ll ans = (a1 * a2) % MOD;
        cout << ans << "\n";
    }}
    return 0; 
}

Measured memory_bytes: 195584
package main

import "fmt"

func prmFac(x int) map[int]int {
	pfm := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			x /= i
			pfm[i]++
		}
	}
	if x > 1 {
		pfm[x]++
	}
	return pfm
}

func main() {
	var n, p int
	fmt.Scan(&n, &p)

	ans := 1
	for pn, cnt := range prmFac(p) {
		for i := 0; i < cnt; i++ {
			x := 1
			for j := 0; j < n; j++ {
				x *= pn
				if x > p {
					break
				} else if j == n-1 && p%x == 0 {
					ans *= pn
					p /= x
				}
			}
		}
	}
	fmt.Println(ans)
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

int main(){
    ios::sync_with_stdio(false);
    int i;
    cin >> i;
    if (i==5 || i == 3 || i == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	vector<char> ans;
	string s;
	cin>>s;

	for(int i=0;i<s.size();i++){
		if(s[i]=='0') ans.push_back('0');
		else if(s[i]=='1') ans.push_back('1');
		else if(!ans.empty()) ans.pop_back();
	}

	for(int i=0;i<ans.size();i++) cout<<ans[i];
	cout<<endl;

}

Measured memory_bytes: 256
#coding:utf-8
def isPrime(x):
    if x==1:return False
    if x==2 or x==3:return True
    if x%2==0:return False
    i=3
    while i*i<=x:
        if x%i==0:return False
        i+=2
    return True
pr=[None]*(10**5+1)
for i in range(10**5+1):
    pr[i]=isPrime(i)

#ary[l]:=#(1~l)
ary=[None]*(10**5+1)
ary[0]=0
ary[1]=0
ary[2]=0
for x in range(3,10**5+1):
    if pr[x] and pr[(x+1)/2]:
        ary[x]=ary[x-2]+1
    else:
        ary[x]=ary[x-2]
Q=input()
for i in range(Q):
    l,r=map(int,raw_input().split())
    if l!=1:
        print(ary[r]-ary[l-2])
    else:
        print(ary[r])




Measured memory_bytes: 37020
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//





int main() {
    
    int N, K; cin >> N >> K;
    vector<int> h(N);
    rep(i,N) cin >> h[i];

    vector<ll> dp(N);
    rep(i,N) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        for (int k = 1; k <= K; ++k) {
            if (i - k >= 0) dp[i] = min(dp[i], dp[i-k] + max(h[i] - h[i-k], h[i-k] - h[i]));
        }
    }

    out(dp[N-1]);
    
    return 0;
}






Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main() {
	vector<int>a(5);
	rep(i, 5) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
    string S; cin >> S;
    int N = S.length(), cnt = 0;
    if (N % 2 == 0) {
        int p = N / 2;
        int i = 0, j = N - 1;
        while(i < N / 2) {
            if (S[i] != S[j]) cnt++;
            i++, j--;
        }
    }
    else {
        int p = N / 2;
        int i = 0, j = N - 1;
        while(i < N / 2) {
            if (S[i] != S[j]) cnt++;
            i++, j--;
        }
    }
    cout << cnt << endl;
}


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

int main() {

    string s; cin >> s;
	
	int cnt = s.size() - 2;
	string ans = "";
	ans += s[0];
	ans += to_string(cnt);
	ans += s[s.size() - 1];

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ull N, M;
    cin >> N >> M;
    ull ura;
    if (N>=2 && M>=2){
        ura  = (N-2) * (M-2);
    } else if (N == 1 && M >= 2){
        ura = M-2;
    } else if (M==1 && N>= 2){
        ura = N-2;
    } else{
        ura = 1;
    }
    cout << ura << endl;
    return 0;
}

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

int main(){

  int count = 0, min, minj, size, temp;

  cin >> size;

  int *A = new int[size];

  for(int i = 0; i < size; i++){
    cin >> A[i];
  }

  for(int i = 0; i < size - 1; i++){
    min= A[i];
    minj = i;
    for(int j = i + 1; j < size; j++){
      if(min > A[j]){
        min = A[j];
        minj = j;
      }
    }
    temp = A[minj];
    A[minj] = A[i];
    A[i] = temp;
    if(i != minj){
      count++;
    }
  }

  for(int i = 0; i < size - 1; i++){
    cout << A[i] << " ";
  }
  cout << A[size - 1] << endl;

  cout << count << endl;

  delete[] A;

  return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>
int main(void) {
	int N;
	scanf("%d", &N);
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i*j == N) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

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

int main()
{
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
    
    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, k;
string s;

vector<int> block;
int acc[MAX_N];

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  cin >> s;
  if (s[n - 1] == '0') {
    s.push_back('1');
  }

  int cnt = 0;

  for (int i = 0; i < n; ++i) {
    if (s[i] == '1') continue;
    if (s[i] == '0' && s[i + 1] == '1') {
      cnt += 1;
    }
  }

  if (k >= cnt) {
    printf("%d\n", n);
    return 0;
  }

  cnt = 0;

  int l = 0;

  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      if (i == 0 || s[i - 1] == '1') cnt += 1;
    }

    if (cnt > k) {
      while (s[l] == '1') l += 1;
      while (s[l] == '0') l += 1;
      cnt -= 1;
    }

    ans = max(ans, i - l + 1);
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 512
main = getLine >>= mapM_ print . (\[a,b,c] -> (a * b * (sin (rad c)) / 2) : (sqrt (a^2 + b^2 - 2 * a * b * cos (rad c)) + a + b) : (b * sin (rad c)) : []) . map read . words
  where rad c = pi * c / 180

Measured memory_bytes: 4168
#!/usr/bin/ruby
while(n=gets.to_i)>0
	n.times.map{
		a=gets.split.map(&:to_i)
		n=a.shift
		b=[]
		f=0
		a.each{|e|
			b.push(e)
			if e==10&&f==0 then b.push(0) else f^=1 end
		}
		b=b.each_slice(2).to_a
		if b[9]==[10,0] then b[9]=[10] end
		if b[10]==[10,0] then b[10]=[10] end
		if b[11]==[10,0] then b[11]=[10] end
		while b.size>10
			b[9]+=b.pop
		end
		c=[]
		0.step(8){|i|
			if b[i][0]==10
				if b[i+1][0]==10&&i<8 then c[i]=20+b[i+2][0] else c[i]=10+b[i+1][0]+b[i+1][1] end
			else
				c[i]=b[i][0]+b[i][1]
				if c[i]==10 then c[i]+=b[i+1][0] end
			end
		}
		c[9]=b[9].reduce(&:+)
		[-c.reduce(&:+),n]
	}.sort.each{|e|
		puts "#{e[1]} #{-e[0]}"
	}
end

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

int main(){
  int N,T;
  cin >> N >> T;
  vector<int> time(N);
  for(int i = 0; i < N; i++){
    cin >> time.at(i);
  }
  long long ans, sum = T;
  for(int i = 0; i < N-1; i++){
     ans = min(T,time.at(i+1)-time.at(i));
    sum += ans;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define ll long long int
#define INF 1000000005
#define PI acos(-1.0)
#define f first
#define s second
int ans,target;
vector<vector<int> > adj;
void go(int pos,int mask)
{
  if(mask == target)
  {
   ans++;
   return;
  }
  for(auto &it:adj[pos])
  {
    if(!(mask & (1<<it)))
      go(it,mask | (1<<it));
  }
}
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n,m,i,a,b;
   cin>>n>>m;
   adj.resize(n);
   loop(i,0,m)
   { cin>>a>>b;
     a--;
     b--;
     adj[a].pb(b);
     adj[b].pb(a);
   }
   target = (1<<n)-1;
   go(0,1);
   cout<<ans;
   return 0;
}


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

ll calC(ll a, ll b){

    if(a == 1) return 0;
    ll ans = 1;
    ll tmpB = b;
    ll tmpA = a;
    for(int i = 1; i <= b; i ++){
        ans *= tmpA;
        tmpA --;
    }
    for(int i = 1; i <= b; i ++){
        ans /= tmpB;
        tmpB --;
    }

    return ans;
}
int main() {
    int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
    vector<char> ch(n+1,'.');
    string ans = "No";
    rep(i,n) cin >> ch[i];

    for(int i = a; i < d; i ++){
        if(ch[i] == '#' && ch[i+1] == '#') {
            cout << "No";
            return 0;
        }
    }
    
    if(c < d){
        ans = "Yes";
        for(int i = a; i < d; i ++){
            if(ch[i] == '#' && ch[i+1] == '#') ans = "No";
        }
        cout << ans ;
        return 0;
    }

    for(int i = b-1; i < d; i ++){
        if(ch[i-1] == '.' && ch[i] == '.' && ch[i+1] == '.'){
            ans = "Yes";
        }
    }
    
    cout << ans;


    return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int A = Integer.parseInt(strArr[0]);
		int B = Integer.parseInt(strArr[1]);
		if (A <= 8 && B <= 8)
			System.out.println("Yay!");
		else
			System.out.println(":(");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 20180
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

n,k=i2()
D=[]
A=[]
for j in range(k):
	d=i()
	a=intl()
	D.append(d)
	A.append(a)
s=[]
for i in range(k):
	for j in range(0,D[i]):
		s.append(A[i][j])
s=set(s)
print(n-len(s))

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {

  int n,ac=0,wa=0,tle=0,re=0;
  cin >> n;
  vector<string> s(n);
  REP(i, n){
    cin >> s[i];
    if(s[i]=="AC"){
      ac++;
    }else if(s[i]=="WA"){
      wa++;
    }else if(s[i]=="TLE"){
      tle++;
    }else if(s[i]=="RE"){
      re++;
    }
  }
  cout << "AC x " << ac<<endl;
  cout << "WA x " << wa<<endl;
  cout << "TLE x " << tle<<endl;
  cout << "RE x " << re;
}

Measured memory_bytes: 6424
#include <iostream>
using namespace std;
int main()
{
	int n;
	int m;
	cin >> n; cin >> m;
	int *a = new int[m];

	int s = 0;

	for (int i = 0; i < m; i++) {
		cin >> a[i];
		
	}
	for (int i = 0; i < m; i++)
	{
		s += a[i];
	}
	if (s > n) { cout << "-1"; }
	else { cout << n - s; }

	return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=110,M=1e5+10;
const ll INF=1e18;
int w[N],v[N];
ll dp[M];
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch&15),ch=getchar();
	return x*f;
}
int main()
{
	int n=read(),W=read(),totv=0;
	for (register int i=1;i<=n;++i) w[i]=read(),v[i]=read(),totv+=v[i];
	dp[0]=0;for (register int i=1;i<=totv;++i) dp[i]=INF;
	for (register int i=1;i<=n;++i)
	  for (register int j=totv;j>=v[i];--j)
	    dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
	int ans=0;for (register int i=0;i<=totv;++i) if (dp[i]<=W) ans=i;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#bfs2-AGC033A
h,w=map(int,input().split())
s=[input() for _ in range(h)]

from collections import deque

sxy=[]
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            sxy.append([i,j])
ddx=[1,-1,0,0]
ddy=[0,0,1,-1]

t=[[-1 for _ in range(w)] for _ in range(h)]
q=deque()
for txy in sxy:
    q.append(txy)
    t[txy[0]][txy[1]]=0

count=0
while q:
    y,x=q.popleft()
    count+=1
    for (dx,dy) in zip(ddx,ddy):
        ny=y+dy
        nx=x+dx
        if not (0<=nx<w and 0<=ny<h):continue
        if t[ny][nx]==-1:
            t[ny][nx]=t[y][x]+1
            q.append([ny,nx])
a=0
for i in range(h):
    for j in range(w):
        a=max(a,t[i][j])
print(a)

Measured memory_bytes: 152300
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N,K;
	cin>>N>>K;
	if(N+1>=K*2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
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; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    string s;
    cin >> s;
    int si=s.size();
    cout << s[0] << si-2 <<s[si-1] << endl;
}

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

using namespace std;

int main() {

	string s;
	cin >> s;

	int bcount = 0;
	long long res = 0;
	for (int i = 0; i < s.size(); i++) {

		if (s[i] == 'W') {
			res += bcount;
		}
		else {
			bcount++;

		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

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

	cin >> N >> A;
	int ans = N*N -A;
	
		cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
	vec1.size();
	str1.length();
	vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 1e9+7;
ll expo_mod(ll x, ll y, ll p) 
{ 
	ll res = 1;
	x = x % p; 
	if (x == 0) 
		return 0; 
	while (y > 0) 
	{
		if (y%2==1) 
			res = (res*x) % p; 
		y = y>>1; // y = y/2 
		x = (x*x) % p; 
	} 
	return res; 
} 
ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)
		cout<<k<<"\n";
	else if(k<=a+b)
		cout<<a<<"\n";
	else
	{
		ll ans=2*a-k+b;
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    double m;
    cin>>m;
    double ma=0;
    int maxi=0;
    rep(i,n){
      double a,b,c,max;
      cin>>a>>c>>b;
      if(b==1) max=100+m*c;
      else max=100*pow(1+c/100.0,m);	
      //cout<<max<<endl;
      if(ma<max){
	ma=max;
	maxi=a;
      }
    }
    cout<<maxi<<endl;
  }



}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int m;
int main(){
	cin>>m;
	for(int iii=0;iii<m;iii++){
		ll im;
		cin>>im;
		ll y;
		cin>>y;
		ll n;
		cin>>n;
		ll ans=0;
		for(int kk=0;kk<n;kk++){
			ll sc,cos;
			double rate;
			cin>>sc>>rate>>cos;
			ll tim=im;
			if(sc){
				for(int i=0;i<y;i++){
					tim=tim*(1+rate);
					tim-=cos;
				}
				//cout<<tim<<endl;
				ans=max(ans,tim);
				//cout<<tim<<endl;
			}else{
				double interest=0;
				for(int i=0;i<y;i++){
					interest+=floor(tim*rate);
					tim-=cos;
				}
				tim+=interest;
				ans=max(ans,tim);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
			


Measured memory_bytes: 3176
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int X;
bool b[200000];

int main() {
	cin >> X;
	for (int i = 2; i < X; i++) {
		for (int j = i + i; j < 200000; j += i) {
			b[j] = true;
		}
	}
	for (int i = X;; i++) {
		if (!b[i]) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
using namespace std;

int p[100010];

int main(){
  int N, A, B; scanf("%d%d%d", &N, &A, &B);
  for(int i = 1; i <= N; i++) scanf("%d", &p[i]);

  long long ans = 0;
  for(int i = 2; i <= N; i++){
    int d = p[i] - p[i - 1];
    ans += min(1LL * d * A, 1LL * B);
  }

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 640
use std::io::{self, BufRead};
use std::collections::{BTreeMap, BTreeSet};

fn dfs(es: &Vec<Vec<usize>>, path: &mut BTreeMap<usize, usize>, visited: &mut BTreeSet<usize>, n: usize) -> bool {
  if let Some(v) = path.get(&n) {
    let len = path.len() - v;
    return len % 2 == 0;
  }
  let size = path.len();
  path.insert(n, size);
  for c in &es[n] {
    if !visited.contains(c) && !dfs(es, path, visited, *c) {
      return false;
    }
  }
  path.remove(&n);
  visited.insert(n);
  true
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
  let mut g: Vec<Vec<i32>> = Vec::new();
  for _ in 0..n {
    let s = lines.next().unwrap().unwrap().chars().map(|c| if c == '1' { 1 } else { i32::max_value() }).collect();
    g.push(s);
  }
  for i in 0..n {
    g[i][i] = 0;
  }
  let mut path: BTreeMap<usize, usize> = BTreeMap::new();
  let mut es: Vec<Vec<usize>> = Vec::new();
  for i in 0..n {
    es.push(g[i].iter().enumerate().filter(|tup| *tup.1 == 1).map(|(i, _)| i).collect());
  }
  let mut visited: BTreeSet<usize> = BTreeSet::new();
  if !dfs(&es, &mut path, &mut visited, 0) {
    println!("-1");
    return;
  }
  for k in 0..n {
    for i in 0..n {
      for j in 0..n {
        if g[i][k] != i32::max_value() && g[k][j] != i32::max_value() && g[i][j] > g[i][k] + g[k][j] {
          g[i][j] = g[i][k] + g[k][j];
        }
      }
    }
  }
  let ans = g.iter().map(|l| l.iter().max().unwrap()).max().unwrap();
  println!("{}", ans + 1);
}

Measured memory_bytes: 4352
import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for i in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
for i in range(q):
  v,val=map(int,input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1)
checked=[0]*(n+1)
while q:
  v=q.pop()
  checked[v]=1
  for i in g[v]:
    if checked[i]==1:
      continue
    cnt[i]+=cnt[v]
    q.append(i)
print(*cnt[1:])

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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;
}
template<class T>
inline T GCD(T a, T b) {
    return b ? GCD(b, a % b) : a;
}
template<class T>
inline T LCM(T a, T b) {
    return (a + (b - 1)) / b;
}

int round_int(int a, int b) {
    return (a + (b - 1)) / b;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vvi dp(h + 1, vi(w));
    dp[0][0] = 1;

    rep(i, h) {
        rep(j, w) {
            rep(k, (1 << (w - 1))) {
                bool ok = true;
                rep(l, w - 2) {
                    if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
                        ok = false;
                    }
                }

                if (ok) {
                    if (j >= 1 && ((k >> (j - 1)) & 1)) {
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= mod;
                    }
                    else if (j <= w - 2 && ((k >> j) & 1)) {
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= mod;
                    }
                    else {
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= mod;
                    }
                }
            }
        }
    }
    cout << dp[h][k - 1] << endl;
}

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

int main(){
  int N,C,K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for(int i=0; i<N; i++){
    cin >> T.at(i);
  }
  sort(T.begin(),T.end());
  
  int j=0,t=T.at(0),buses=0;
  for(int i=0; i<N;){
    while(i<N&&t+K>=T.at(i)&&i-j<C){
      i++;
    }
    buses++;
    if(i<N){
      t=T.at(i);
      j=i;
    }
  }
  cout << buses << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::vector<size_t> a(N);
  for (auto& ai: a) scanf("%zu", &ai);

  std::map<size_t, int> m;
  size_t ir = 0;
  for (; ir < N; ++ir) {
    if (a[ir] <= K) ++m[a[ir]];
    if (m.size() == K) {
      ++ir;
      break;
    }
  }

  if (m.size() < K)
    return puts("0"), 0;

  size_t res = ir;
  for (size_t i = 0; i < N; ++i) {
    if (a[i] <= K) {
      auto it = m.find(a[i]);
      if (--it->second == 0) m.erase(it);
    }
    while (m.size() < K && ir < N) {
      if (a[ir] <= K) ++m[a[ir]];
      ++ir;
    }
    if (m.size() == K) {
      res = std::min(res, ir-(i+1));
    }
  }

  printf("%zu\n", res);
}



Measured memory_bytes: 9568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  swap(a,b);
  swap(a,c);
  cout<<a<<" "<<b<<" "<<c;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

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

	vector<int> x(n);
	REP(i, n)x[i] = k;
	REP(i, q) {
		int tmp;
		cin >> tmp;
		x[tmp - 1]++;
	}
	REP(i, n) {
		x[i] -= q;
		if (x[i] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(),, greater<int>())
#define pb push_back
#define ll long long

int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
}
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
}
int cel(int a,int b){return((a-1)/b+1);} 
int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a,int b){
    return (a*b)/gcd(a,b);
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,a,b,c,k,x=0,y;
    cin>>n>>k;vi v(n);
    rep(i,0,n){cin>>v[i];}
    rep(i,0,n-k){
        if(v[i]<v[k+i])cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3984
#include<stdio.h>
int func(int a) {
	if (a == 1) {
		return 1;
	}
	else {
		return func(a - 1)+a;
	}
}

int main(void) {
	int N, ans;

	
	scanf("%d", &N);
	ans = func(N);
	printf("%d\n", ans);

	return 0;
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int M = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
int l[M], r[M];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=0; i<m; i++){
		cin >> l[i] >> r[i];
	}
	int L = l[0], R = r[0];
	for(int i=1; i<m; i++){
		L = max(L, l[i]);
		R = min(R, r[i]);
	}
	int ans = max(0, R - L + 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
n,m = map(int, input().split())
mod = 1000000007
def fac(a,mod):
    res = 1
    for i in range(1,a+1):
        res *= i
        res %= mod
    return res
if n==m:
    print(fac(n,mod) * fac(m,mod) * 2 % mod)
elif (n==m+1):
    print(fac(n,mod) * fac(m,mod) % mod)
elif (n+1==m):
    print(fac(n,mod) * fac(m,mod) % mod)
else:
    print(0)

Measured memory_bytes: 9148