akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

void dfs(const vvi& G, vector<bool>& seen, int& timer, vi& prenum, vi& lowest, vi& parent, int current, int prev) {
    lowest[current] = prenum[current] = timer++;
    seen[current] = true;

    for (auto next : G[current]) {
        if (!seen[next]) {  // Included in DFS Tree.
            parent[next] = current;
            dfs(G, seen, timer, prenum, lowest, parent, next, current);
            lowest[current] = min(lowest[current], lowest[next]);
        } else if (next != prev) {  // Back edge.
            lowest[current] = min(lowest[current], prenum[next]);
        }
    }
}

set<int> art_points(const vvi& G) {
    vi prenum(G.size(), -1), lowest(G.size(), -1), parent(G.size(), -1);
    vector<bool> seen(G.size(), false);
    int timer = 1;

    // Construct DFS tree with 0 as root.
    dfs(G, seen, timer, prenum, lowest, parent, 0, -1);

    set<int> ap;
    int np = 0;
    rep(i, 1, G.size()) {
        int p = parent[i];
        if (p == 0) {
            np++;
        } else if (prenum[p] <= lowest[i]) {
            ap.insert(p);
        }
    }
    // Root is AP if root has more than 2 children.
    if (np >= 2) { ap.insert(0); }

    return ap;
}

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

    int v, e;
    scanf("%d %d", &v, &e);

    vvi G(v);
    rep(i, 0, e) {
        int s, t;
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
        G[t].push_back(s);
    }

    set<int> ap = art_points(G);
    for (auto v : ap) { cout << v << endl; }
    return 0;
}


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

using namespace std;

vector<int> points[50];


double distance( vector<int> & v1, vector<int> v2 ){

    double sum = 0;

    for( int i = 0; i < v1.size(); i++ ){
        sum += pow( ( v1[i] - v2[i] ), 2 );
    }

    return sqrt( sum );
}


bool comp( double num, double dis ){
    if( abs( num - dis  ) <= 0.0 ){
        return true;
    }

    return false;
}

int solve( int MAX ){

    int cont = 0;

    for( int i = 0; i < MAX; i++){
        for( int j = i + 1; j < MAX; j++ ){

            double dis = distance( points[ i ], points[ j ] );

            int up = (double) ceil( dis );

            int dow = (double)floor( dis );

            if( comp( up, dis ) || comp( dow, dis ) ){
                cont++;
            }

        }
    }
    return cont;

}

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

    //freopen( ".in", "r", stdin );

    int n, d;

    cin >>n >>d;

    int auxN = n;
    int auxD = d;

    int i = 0;

    while( n-- ){
        while( d -- ){
            int x;
            cin >>x;
            points[ i ].push_back( x );
        }
        d = auxD;
        i++;
    }

    cout <<solve( auxN ) <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

int main(){
    ios::sync_with_stdio(0);
    int x;cin>>x;
    while(x--){
        cout<<"ACL";
    }
}



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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int n, m, a, cnt = 0, ans = 0, wmax, mmax = 0;
   cin >> n >> m;
   vector<int> x, y;

   rep(i, m)
   {
      cin >> a;
      x.push_back(a);
   }

   if (n >= m)
   {
      cout << 0 << '\n';
      return 0;
   }

   sort(all(x));

   rep(i, m)
   {
      if (i != 0)
      {
         cnt = x[i] - x[i - 1];
         ans += cnt;
         y.push_back(cnt);
      }
   }

   gsort(y);
   cnt = 0;
   rep(i, n - 1)
   {
      cnt += y[i];
   }

   cout << ans - cnt << '\n';
}

Measured memory_bytes: 2548
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u64> = procon_read();
	let n = v[0];
	if n%2 == 0 {
		println!("{}", n);
	}else{
		println!("{}", 2*n);
	}
}

Measured memory_bytes: 4352
n, y = map(int, input().split())
flag = False
a = 0
b = 0
c = 0

for a in range(0, n+1):
    for b in range(0, n+1-a):
        c = n - a - b
        if(10000*a+5000*b+1000*c==y):
            print('{} {} {}'.format(a, b, c))
            flag = True
            break
        else:
            continue
        break
    else:
        continue
    break
    
if not flag:
    print('-1 -1 -1')
    

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int[] map = new int[N];
        for (int i = 0; i < N; i++) {
        	map[i] = sc.nextInt();
        }
        
        int count = 0;
        int index = 1;
        while(true) {
        	if (map[index-1] == 2) {
        		count++;
        		System.out.println(count);
        		return;
        	} else {
        		count++;
        		index = map[index-1];
        	}
        	
        	if (count > N) {
        		System.out.println(-1);
        		return;
        	}
        }
    }
    
}

Measured memory_bytes: 51196
n = input()

def koch(n,p1,p2):
    s = [0] * 2 
    t = [0] * 2 
    u = [0] * 2 
    if n == 0:
        return 0
    s[0] = (2.00 * p1[0] + 1.00 * p2[0]) / 3.00
    s[1] = (2.00 * p1[1] + 1.00 * p2[1]) / 3.00
    t[0] = (1.00 * p1[0] + 2.00 * p2[0]) / 3.00
    t[1] = (1.00 * p1[1] + 2.00 * p2[1]) / 3.00
    u[0] = (t[0] - s[0]) * (1.00 / 2.00) - (t[1] - s[1]) * (3.00**0.5 / 2.00) + s[0] 
    u[1] = (t[0] - s[0]) * (3.00**0.5 / 2.00) + (t[1] - s[1]) * (1.00 / 2.00) + s[1]    


    koch(n-1, p1, s)
    print "{0:.10f}".format(s[0]),"{0:.10f}".format(s[1])
    koch(n-1, s, u)
    print "{0:.10f}".format(u[0]),"{0:.10f}".format(u[1])
    koch(n-1, u, t)
    print "{0:.10f}".format(t[0]),"{0:.10f}".format(t[1])  
    koch(n-1, t, p2)




start = [0.00,0.00]
goal = [100.00,0.00]
print "{0:.10f}".format(start[0]),"{0:.10f}".format(start[1])
koch(n,start,goal)
print "{0:.10f}".format(goal[0]),"{0:.10f}".format(goal[1])

Measured memory_bytes: 6560
#include <stdio.h>
int main(void){
  int P,Q,R,min;
  printf("");scanf("%d", &P);
  printf("");scanf("%d", &Q);
  printf("");scanf("%d", &R);
  min = P + Q;
  if(min > Q + R){min = Q + R;}
  if(min > R + P){min = R + P;}
  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define N 3005
const double PI=acos(-1.0);
typedef long long ll;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,L,t[N];
double X,Y;
int main(){
	n=read(),L=read();
	for(int i=1;i<=n;++i){
		t[i]=read();
	}
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			X+=(n-2*(j-i))*cos(PI*(t[i]+t[j])/L);
			Y+=(n-2*(j-i))*sin(PI*(t[i]+t[j])/L);
		}
	}
	ll all=1LL*n*(n-1)*(n-2)/6;
	printf("%.12lf %.12lf\n",X/all,Y/all);
	return 0;
}



Measured memory_bytes: 4072
N, M = map(int, input().split())
AB = list(list(map(int, input().split())) for _ in range(M))

AB_sorted = sorted(AB, key=lambda x : x[1])

removed_bridge = []
for ab in AB_sorted:
    if removed_bridge:
        if ab[0] < removed_bridge[-1] < ab[1]:
            continue
    removed_bridge.append(ab[1] - 0.5)

print(len(removed_bridge))

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arrDiv[10000005] ;

int main()
{
    ll n, limit, ans = 0 ;
    cin >> n ;

    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            arrDiv[j]++ ;
        }
    }

    for (int i = 1; i <= n; i++) {
        ans += (arrDiv[i] * i) ;
    }
    cout << ans ;


    return 0 ;
}


Measured memory_bytes: 81712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  int cnt = 0;
  rep(i, H) {
    cin >> A[i];
    rep(j, W) if(A[i][j] == '#') cnt++;
  }
  if(cnt == H+W-1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
use std::cmp;

const MOD: usize = 998244353;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s: Vec<usize> = sc
        .read::<String>()
        .chars()
        .map(|c| c as usize - '0' as usize)
        .collect();
    let n = s.len();
    let mut dp: Vec<usize> = vec![0; 2 * n + 1];
    dp[s[0]] = 1;
    for i in 0..(2 * n) {
        let mut next = vec![0; 2 * n + 1];
        let add = if i + 1 < n { s[i + 1] } else { 0 };
        let total = cmp::min((i + 1) * 2, 2 * n) - i;
        for cur in 0..(2 * n + 1) {
            if dp[cur] == 0 {
                continue;
            }
            // pop red
            if cur > 0 {
                next[cur - 1 + add] += dp[cur];
                next[cur - 1 + add] %= MOD;
            }
            // pop blue
            if total > cur {
                next[cur + add] += dp[cur];
                next[cur + add] %= MOD;
            }
        }
        dp = next;
    }

    println!("{}", dp[0]);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

typedef long long ll;

int main() {
    ll A, B, C, ans = 1e18;
    int X, Y;
    cin >> A >> B >> C >> X >> Y;
    rep(i, max(X, Y) + 1) {
        ll cost = A * max(0, X - i) + B * max(0, Y - i) + C * i * 2;
        if (cost < ans) ans = cost;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#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, m;
    cin >> n >> m;
    vector<int> num(n, -1);
    vector<bool> ketacheck(n, false);

    rep(i, m) {
        int st, ct;
        cin >> st >> ct;
        if(num[st - 1] != -1 and num[st - 1] != ct ||
           st == 1 and ct == 0 and n > 1) {
            cout << -1 << endl;
            return 0;
        } else {
            num[st - 1] = ct;
        }
    }

    rep(i, n) {
        if(num[i] == -1) {
            if(i == 0 && n > 1)
                num[i] = 1;
            else
                num[i] = 0;
        }
    }
    rep(i,n) {
        cout << num[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
   int n;cin>>n;
   vector<ll> a(n);
   for(int i=0;i<n;i++)cin>>a[i];
   int m;cin>>m;
   vector<vector<ll>> dp(100,vector<ll>(n,-1));
   for(int i=0;i<n;i++){
       ll tmp=a[i]+m;
       int ite=upper_bound(all(a),tmp)-a.begin();
       ite--;
       dp[0][i]=ite;
   }
   for(int i=0;i<99;i++){
       for(int j=0;j<n;j++){
           dp[i+1][j]=dp[i][dp[i][j]];
       }
   }
  int q;
  cin>>q;
  while(q--){
      int a,b;
      cin>>a>>b;
      a--;b--;
      if(a>b)swap(a,b);
      int l=-1,r=200000;
      while(r-l!=1){
          int mid=(l+r)/2;
          int tmp=mid;
          int j=0;
          bool can=false;
          int now=a;
          while(tmp!=0){
             if(tmp&1){
                 now=dp[j][now];
             }
             tmp>>=1;
             j++;
             if(now>=b)can=true;
          }
          if(can)r=mid;
          else l=mid;
      }
      cout<<r<<endl;

  }
}




Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, l, r, answer = 0;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> l >> r ;
        answer += r - l + 1;
    }

    cout << answer << endl;
}

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

int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   
   int N; cin>>N;
   bool ok=true;
   for(int i=0;i<N;i++){
      int a; cin>>a;
      if(a%2==0){
         if(a%3!=0 and a%5!=0) ok=false;
      }
   }
   cout<<(ok? "APPROVED":"DENIED")<<endl;
   return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main{

    static String[] one;
    static String[] two;
    static int[][] matrix;
    static ArrayList<String> str;

    static void table(){

        for(int i=1;i<=one.length;i++){
            for(int j=1;j<=two.length;j++){

                if(one[i-1].equals(two[j-1])){
                    matrix[i][j] = matrix[i-1][j-1]+1;
                }
                else {
                    matrix[i][j] = max(matrix[i-1][j],matrix[i][j-1]);
                }

            }
        }

    }

    static void ans(){
        int i = one.length, j = two.length;
        while (i > 0 && j > 0)
        {
            // If current character in X[] and Y are same, then
            // current character is part of LCS
            if (one[i-1].equals(two[j-1]))
            {
                // Put current character in result
                str.add(0,one[i-1]);

                // reduce values of i, j and index
                i--;
                j--;
            }

            // If not same, then find the larger of two and
            // go in the direction of larger value
            else if (matrix[i-1][j] > matrix[i][j-1])
                i--;
            else
                j--;
        }

    }


    static int max(int a,int b){
        if(a>b){
            return a;
        }
        else{
            return b;
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        one = inp.readLine().split("");
        two = inp.readLine().split("");

        str = new ArrayList<>();

        matrix = new int[one.length+1][two.length+1];
        table();
        ans();
        for (int i=0;i<str.size();i++) {
            System.out.print(str.get(i));
        }




    }
}


Measured memory_bytes: 80468
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////

int main() {
	cout << fixed << setprecision(30);

	ll N, d1, x;
	cin >> N >> d1 >> x;

	long double b = 4.0 * x;
	long double a = 2.0 * d1 + x;

	long double dis = a + (long double)(N - 1) / 2.0 * b;

	long double ans = 0;
	for (ll i = 2; i <= N; i++) {
		long double j = i;
		ans = (1.0 + 1.0 / j) * ans + (j - 1.0) /2.0/  j;
		//cout << ans << endl;
	}
	ans *= dis;

	ans += dis * (long double)N / 2.0;
	cout << ans << endl;

}


Measured memory_bytes: 3780
import sys

input = sys.stdin.readline

def main():
    ans = 0
    a, b, c = map(int, input().split())
    while a%2 == b%2 == c%2 == 0:
        ans += 1
        a, b, c = (b//2 + c//2), (a//2 + c//2), (a//2 + b//2)
        if a == b == c:
            ans = -1
            break

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a, b, c = sorted(a), sorted(b), sorted(c)

ans = 0
for i in b:
    up_index = bisect.bisect_left(a,i)
    down_index = bisect.bisect_right(c,i)
    ans += up_index * (n-down_index)

print(ans)


Measured memory_bytes: 107108
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  cout<<a.at(0)+a.at(1)<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll BIGINT = 1e9 + 7;

long long pow(ll x, ll n)
{
    ll res = 1LL;
    ll acc = 1LL;
    for (int i = 0; acc <= n; ++i)
    {
        if ((n >> i) & 1)
        {
            res = (res * x) % BIGINT;
        }
        x = (x * x) % BIGINT;
        acc *= 2;
    }
    return res;
}

long long modinv(ll a, ll p)
{
    return pow(a, p - 2);
}

long long binomial_coeff(ll n, ll r)
{
    if (2 * r > n)
        r = n - r;
    if (n < r or r < 0)
        return 0LL;

    long long numer = 1LL;
    long long denom = 1LL;
    const int rrr = (int)r;
    REP(i, rrr)
    {
        numer = (numer * n) % BIGINT;
        denom = (denom * r) % BIGINT;
        n--;
        r--;
    }
    return (numer * modinv(denom, BIGINT)) % BIGINT;
}

ll part(ll n, ll x)
{
    return binomial_coeff(n - 1, n - x);
}

ll count(ll N, ll K, ll i)
{
    ll blue = binomial_coeff(K - 1, K - i);
    ll red = binomial_coeff((N - K) + (i + 1 - 1)  - (i - 1), i);
    // cerr << "i = " << i << endl;
    // cerr << "blue: " << blue << endl;
    // cerr << "red: " << red << endl;
    return (blue * red) % BIGINT;
}

int main()
{
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;

    for (int i = 1; i <= K; ++i)
    {
        cout << count(N, K, i) << endl;
    }

    return 0;
}


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

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

    ll ans = 1e18;
    for (int bit = 0; bit < (1 << n); ++bit) {
        int bitcnt = 0;
        ll cur = 0, cost = 0;
        for (int i = 0; i < n; ++i) {
            if(bit & (1 << i)) {
                bitcnt++;
                if(cur >= a[i]) {
                    cost += cur + 1 - a[i];
                    cur = max(cur + 1, a[i]);
                }
            }
            cur = max(cur, a[i]);
        }
        if(bitcnt == k) {
            ans = min(ans, cost);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;


string a;


int main()
{
	while (cin >> a){
		reverse(a.begin(), a.end());
		cout << a << endl;
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	ll ans = 0;
	rep(i, N / R + 1) rep(j, N / G + 1) {
		int r = i * R;
		int g = j * G;
		int b = N - r - g;
		if (b >= 0 && !(b % B)) ans++;
	}
	cout << ans << endl;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  int n;
  cin >> n;
  int perm[n], p[n], q[n];
  REP(i, n) perm[i]=i+1;
  REP(i, n) cin >> p[i];
  REP(i, n) cin >> q[i];
  int p_pl = -1;
  int q_pl = -1;
  int cnt = 0;
  do {
    if(p_pl == -1){
      bool tmp = true;
      REP(i, n) if(perm[i] != p[i]) tmp = false;
      if(tmp) p_pl = cnt;
    }
    if(q_pl == -1){
      bool tmp = true;
      REP(i, n) if(perm[i] != q[i]) tmp = false;
      if(tmp) q_pl = cnt;
    }
    if(p_pl != -1 && q_pl != -1) break;
    cnt++;
  } while (next_permutation(perm, perm+n));
  cout << abs(p_pl-q_pl) << endl;
  return 0;
}

Measured memory_bytes: 3628
import sys
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
input = sys.stdin.readline

N, M, L = map(int, input().split())
graph = np.array([[0 if i == j else float("inf")
                   for i in range(N)] for j in range(N)])
for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c

Q = int(input())
dist = floyd_warshall(graph)


graph2 = np.array([[float("inf")] * N for _ in range(N)])
np.fill_diagonal(graph2, 0)
graph2[(dist <= L) & (dist != 0)] = 1

dist2 = floyd_warshall(graph2)
dist2[dist2 == float("inf")] = 0

for _ in range(Q):
    s, t = map(int, input().split())
    print(int(dist2[s - 1, t - 1]) - 1)


Measured memory_bytes: 19056
N = int(input())
lis = [1] * (10**7+1)
for i in range(2,10**7+1):
    for j in range(i,10**7+1,i):
        lis[j] += 1
ans = 0
for i in range(1,N+1):
    ans += lis[i] * i
print(ans)


Measured memory_bytes: 151348
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		TreeMap <String, Integer> store = new TreeMap <String, Integer>();
		
		
		for (int i = 0; i<N; i++){
			String Si=sc.next();
			int Pi=sc.nextInt();
			
			Si=Si+"_"+Integer.toString(999-Pi);
			store.put(Si, i+1);
			
			}
			
		sc.close();
		
		while (store.isEmpty()==false) {
			System.out.println(store.firstEntry().getValue());
			store.pollFirstEntry();
		}

	}

}


Measured memory_bytes: 23892
s = raw_input()
a = set(list('ACGT'))
j = 0
i = 0
r = 0
while( j < len(s)):
	if s[j] not in a:
		j += 1
		i = j 
	else:
		while(j < len(s) and s[j] in a): j+=1
		r = max(r, j - i )
		i = j
print r

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

int main() {
  string s, t;
  cin >> s >> t;

  map<char, char> m1;
  map<char, char> m2;

  for (int i = 0; i < s.size(); ++i) {
    if (m1.find(t[i]) != m1.end()) {
      if (m1[t[i]] != s[i]) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      m1[t[i]] = s[i];
    }

    if (m2.find(s[i]) != m2.end()) {
      if (m2[s[i]] != t[i]) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      m2[s[i]] = t[i];
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

vector<int>g[200010];
int ans[100010];
bool vis[100010];
void bfs(int rt)
{
    vis[rt]=1;
    queue<int>q;
    q.push(rt);

    while(!q.empty())
    {
        int adj=q.front(); q.pop();
        for(auto x: g[adj])
        {
            if(vis[x]==0)
            {
                vis[x]=1;
                ans[x]=adj;
                q.push(x);
            }
        }
    }
}
int main()
{
    int n,m,a,b;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        scanf("%d%d", &a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }

    bfs(1);
    for(int i= 1; i<=n; i++)
    {
        if(vis[i]==0)
        {
            cout<<"No";
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    for(int i=2; i<=n; i++)
        printf("%d\n", ans[i]);
}


Measured memory_bytes: 13108
s = input()

for i in range(len(s)-2):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        exit()
    elif s[i] == s[i+2]:
        print(i+1, i+3)
        exit()

if s[len(s)-2] == s[len(s)-1]:
    print(len(s)-1, len(s))
else:
    print(-1, -1)

Measured memory_bytes: 3188
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

ll calc(ll a, ll b)
{
    ll cu = MAX(a,b);
    ll ne = MIN(a,b);
    while( ne > 0 ) {
        ll tmp = cu % ne;
        cu = ne;
        ne = tmp;
    }

    return (a/cu * b);
}

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<ll> t(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%lld", &t[i]);
    }

    ll ans=t[0];
    for(i=1; i<n; i++) {
        ans = calc( ans, t[i]);

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

    return 0;
}


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

int main()
{
    ll N;
    cin >> N;

    vector<string> S(N);
    map<string, ll> mp;
    rep(i, N) {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
        mp[S[i]]++;
    }

    ll res = 0;

    for (auto m : mp) {
        if (m.second > 1) {
            res += m.second * (m.second - 1) / 2;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 1000000007
int n, k, a, b;
int main() {
	io	
	cin>>k>>a>>b;
	string ans = "NG";
	if(k >= a &&k <= b) ans = "OK";
	for(int i = k+k; i<=b; i+=k) {
		if(i >= a && i <= b) ans = "OK";
	}
	cout<<ans;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> r(n+1,0); //累積和
  int mod=1000000007;
  for(int i=0;i<n;i++){
    cin >> a[i];
    r.at(i+1)=r[i]+a[i];
  }
  long long ans=0;
  for(int i=0;i<n;i++){
    long long sum=(r[n]-r[i+1]) % mod;
    ans+=sum*a[i];
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5592
#include <iostream>
using namespace std;
int main(){
        int N;
        cin >> N;
        int lt[200][200]={0};
        for( int i=0 ; i<N ; i++ ){
                int x,y,n;
                cin >> x >> n;
                for(int l=0 ; l<n ; l++ ){
                        cin >> y;
                        lt[x-1][y-1]=1;
                }
        }
        for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                        cout<<lt[i][j];
                        if(j!=N-1)cout<<" ";
                }
                cout<<endl;
        }
        return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//
constexpr int N_MAX = 100010;
struct Edge
{
  int to ,cost;
  Edge(int to, int cost) :to(to), cost(cost){}
  Edge() {}
};
vector<vector<Edge>> G;
bool visited[N_MAX];
ll x[N_MAX] = {};
bool is_consistent = true;
void dfs(int current,int pos)
{
  visited[current] = true;
  x[current] = pos;
  for(auto edge : G[current])
  {
    int next_x = x[current] + edge.cost;
    if(visited[edge.to])
    {
      if(x[edge.to] != next_x)
      {
        is_consistent = false;
        return;        
      }
    }
    else
    {
      dfs(edge.to,next_x);
    }
  }
  return;
}
signed main()
{
  ios();
  int N,M;
  cin >> N >> M;
  rep(i,N)
  {
    visited[i] = false;
    x[i]  = 0;
  }
  G.resize(N);
  rep(i,M)
  {
    int L,R,D;
    cin >> L >> R >> D ;
    G[L-1].push_back(Edge(R-1,D));
    G[R-1].push_back(Edge(L-1,-D));
  }

  rep(i,N)
  {
    if(!visited[i])
    {
      dfs(i,0);
    }
  }
  if(is_consistent)
  {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 11520
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int>A(N);
    cin >> A;
    ll a = A[0];
    ll b = accumulate(ALL(A), 0LL) - A[0];
    ll m = abs(a - b);

    FOR(i, 1, N - 1) {
        a += A[i];
        b -= A[i];
        m = min(abs(a - b), m);
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int ans = 0;
    cin >> N;
    vector<int> vec(N, 0);
    for(int i = 0;i < N;i++){
        cin >> vec[i];
    }
    for(int i = 0;i < N;i++){
        for(int j = i + 1; j < N;j++){
            for(int k = j + 1;k < N;k++){
                int a = vec[i];
                int b = vec[j];
                int c = vec[k];
                if(a + b > c && a + c > b && b + c > a && a != b && b != c && a != c){
                    ans++;
                }
            }
        }
    }
    cout << ans << std::endl;
    return 0;
}


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

int main(){
  string s,t; cin>>s>>t;
  int check=1;
  for (int i=0; i<s.size(); i++){
    if (s[i]!=t[i]) check=0;
  }
  cout<<(check==1 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	int N;
	VI a;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int in;
		scanf("%d", &in);
		a.PB(in);
	}
	sort(ALL(a));
	int ans = 0;
	for (int i = 0; i < N; ) {
		int j = i + 1;
		while (j < SZ(a) && a[i] == a[j]) j++;
		debug("%d - %d   %d\n", i, j, a[i]);
		if (j - i >= a[i])
			ans += (j - i - a[i]);
		else
			ans += j - i;
		i = j;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

class BIT {
    int n;
    vi data0, data1;

    void add(vi& data, int i, i64 x) {
        while (i <= n) {
            data[i] += x;
            i += i & -i;
        }
    }

    i64 sum(vi& data, int i) {
        i64 s = 0;
        while (i > 0) {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }

public:
    BIT(int n) : n(n) {
        data0 = vi(n + 1);
        data1 = vi(n + 1);
    }

    // [l, r)
    void add(int l, int r, i64 x) {
        l++;
        r++;
        add(data0, l, -x * (l - 1));
        add(data1, l, x);
        add(data0, r, x * (r - 1));
        add(data1, r, -x);
    }

    // [l, r)
    i64 sum(int l, int r) {
        i64 s = 0;
        s += sum(data0, r) + sum(data1, r) * r;
        s -= sum(data0, l) + sum(data1, l) * l;
        return s;
    }
};

int main() {
    int n;
    cin >> n;
    BIT bit(n);
    int q;
    cin >> q;
    while (q--) {
        int t;
        cin >> t;
        if (t) {
            int i;
            cin >> i;
            i--;
            cout << bit.sum(i, i + 1) << endl;
        } else {
            int s, t, x;
            cin >> s >> t >> x;
            s--;
            t--;
            bit.add(s, t + 1, x);
        }
    }
}


Measured memory_bytes: 4344
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string s;
	int long long k;
	cin>>s>>k;
	int a=0;
	rep(i, min((long long)s.size(), k)){
		if(s[i]!='1'){
			cout<<s[i]<<endl;
			return 0;
		}
	}
	cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int cnt[3][30];

signed main(){
    int N,C;
    cin >> N >> C;
    int d[C][C];
    REP(i,C){
        REP(j,C){
            cin >> d[i][j];
        }
    }
    int c[N][N];
    REP(i,N){
        REP(j,N){
            cin >> c[i][j]; 
            c[i][j]--;
        }
    }
    REP(i,N){
        REP(j,N){
            cnt[(i + j) % 3][c[i][j]]++;
        }
    }
    int ans = INF;
    REP(i,C){
        REP(j,C){
            REP(k,C){
                if(i == j || j == k || k == i){
                    continue;
                }
                int sum = 0;
                REP(l,C){
                    sum += d[l][i] * cnt[0][l];
                    sum += d[l][j] * cnt[1][l];
                    sum += d[l][k] * cnt[2][l];
                }
                ans = min(ans, sum);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
long long Gcd(long long x,long long y);

int main(void){
	long long a,b,g,lcm;
	int i;
	while( scanf("%lld %lld",&a,&b) != EOF ){
		g=Gcd(a,b);
		lcm=a*b/g;
		
		printf("%lld %lld\n",g,lcm);
	}
	
	return 0;
}

long long Gcd(long long x,long long y){
	int i,j;
	long long tmp;
	if(y>=x){
		tmp=x;
		x=y;
		y=tmp;
	}
	
	for(i=0;;i++){
		x=x%y;
		
		tmp=x;
		x=y;
		y=tmp;
		
		if(y==0){
			break;
		}
	}

	return (x);
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

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

  int n = s.length() ;
  cout << s[0] << n-2 << s[n-1] << endl ;
	
  return 0 ;
}



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

int main() {
  char c;
  cin >> c;
  if(c == 'a'){
    cout << "vowel" << endl;
  }else if(c == 'i'){
    cout << "vowel" << endl;
  }else if(c == 'u'){
    cout << "vowel" << endl;
  }else if(c == 'e'){
    cout << "vowel" << endl;
  }else if(c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

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


int main(){

    string s ;
    int n;
    cin >> n >> s ;
    int b = 0 , r = 0 ;
    for(auto c : s)
        r+=(c == 'R'),b+=(c == 'B');

    if(r > b)
        cout << "Yes\n";
    else
        cout << "No\n";



return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(ll i = 0;i < n;i++)
#define FOR(i,a,b) for(ll i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}


int main() {
	ll n,c;
	cin >> n >> c;
	vector<ll> x(n + 2);
	vector<ll> v(n + 1);
	vector<ll> sumv(n + 1);
	vector<ll> f1(n + 1), g1(n + 1), f2(n + 1), g2(n + 1);
	vector<ll> h1(n + 2), h2(n + 2);
	x[0] = x[n + 1] = 0;
	sumv[0] = 0; f1[0] = 0; g1[0] = 0; f2[0] = 0; g2[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> v[i];
		sumv[i] = sumv[i - 1] + v[i];
		f1[i] = sumv[i] - x[i];
		if (f1[i] > g1[i - 1])g1[i] = f1[i];
		else g1[i] = g1[i - 1];
		f2[i] = sumv[i] - 2 * x[i];
		if (f2[i] > g2[i - 1])g2[i] = f2[i];
		else g2[i] = g2[i - 1];
	}
	h1[n + 1] = 0; h2[n + 1] = 0;
	for (int i = n; i > 0; i--) {
		h1[i] = sumv[n] - sumv[i - 1] - 2 * (c - x[i]);
		h2[i] = sumv[n] - sumv[i - 1] - (c - x[i]);
	}
	ll ans = 0;
	for (int b = 1; b <= n + 1; b++) {
		ll tmp = max(h1[b] + g1[b - 1], h2[b] + g2[b - 1]);
		if (tmp > ans)ans = tmp;
	}

	dump(ans);
}




Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	string s,t,u;
	cin>>s>>t>>a>>b>>u;
	if(u==s)
	{
		cout<<a-1<<" "<<b;
	}
	else
	{
		cout<<a<<" "<<b-1;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[6],max1=0,s=0,r=0;
    for(int i=0;i<5;i++)
    {
    	cin>>a[i];
    	if(a[i]%10==0) s+=a[i];
    	else
    	   {  
		      s+=a[i]/10*10+10;
			  r=a[i]/10*10+10-a[i];
			  max1=max(max1,r);
		   }
    	 
	}
     cout<<s-max1; 
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);

using namespace std;

// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// print vector
template <typename T> 
inline ostream &operator<<(ostream &out, vector<T> &a) {
    for(auto &x : a) out << x <<" ";
    return out;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}
int n;
double dp[305][305][305];

double solve(int a, int b, int c)
{
    if(a==0 && b==0 && c==0)
        return dp[a][b][c]=0;
    if(dp[a][b][c]!=-1)
        return dp[a][b][c];
    double p_waste=(double)(n-(a+b+c))/(double)(a+b+c);
    dp[a][b][c]=p_waste;
    // dp[a][b][c]=p_waste/(1-p_waste);
    if(a!=0)
    {
        dp[a][b][c]+=(double)a*((solve(a-1,b,c)+1)/(double)(a+b+c));
    }
    if(b!=0)
    {
        dp[a][b][c]+=(double)b*((solve(a+1,b-1,c)+1)/(double)(a+b+c));
    }
    if(c!=0)
    {
        dp[a][b][c]+=(double)c*((solve(a,b+1,c-1)+1)/(double)(a+b+c));
    }
    return dp[a][b][c];
}

int main()    
{
    #ifdef SANS
        freopen("ongoingin.txt","r",stdin);
        freopen("ongoingout.txt","w",stdout);
    #endif
    fast
    int t=1;
    // cin>>t;
    while(t--)
    {
        cin>>n;
        int one=0,two=0,three=0;
        vector<int> sushi(n);
        for(int i=0; i<305; i++){
            for(int j=0; j<305; j++){
                for(int k=0; k<305; k++)
                    dp[i][j][k]=-1;
            }
        }
        for(int i=0; i<n; i++)
        {
            cin>>sushi[i];
            if(sushi[i]==1)
                one++;
            else if(sushi[i]==2)
                two++;
            else
                three++;
        }
        cout<<setprecision(9)<<fixed;
        cout<<(solve(one,two,three));
    }
    #ifdef SANS
        cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
    #endif
}

Measured memory_bytes: 225472
#include <iostream>

using namespace std;

#define X 9

int main(int argc, char** argv){

	int N = 0;
	int Card[X] = {0};
	bool BINGO[X] = {false};
	int temp = 0;

	for(int i=0;i<X;i++)
		cin >> Card[i];
	cin >> N;

	while(N != 0){
		cin >> temp;
		for(int i=0;i<X;i++){
			if (Card[i] == temp){
				BINGO[i] = true;
				break;
			}
		}
		N--;
	}

	{
		int count = 0;
		//yoko
		for(int i=0; i<3; i++){
			if(BINGO[i*3] && BINGO[i*3+1] && BINGO[i*3+2]) count++; //yoko
			if(BINGO[i] && BINGO[i+3] && BINGO[i+6]) count++; //tate
		}
		if(BINGO[0] && BINGO[4] && BINGO[8]) count++; //naname
		if(BINGO[2] && BINGO[4] && BINGO[6]) count++; //naname

		//naname
		if(count>0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256