akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  int i,j,a;
  int n,m,mid;
  int count = 0;

  scanf("%d",&n);

  int S[n];
  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&m);
  int T[m];
  
  for(i=0;i<m;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<m;i++){
   int left = 0;
   int right = n;
   
   while(left < right){
     mid = (left + right)/2;
     if(T[i] == S[mid]){
       count++;
       break;
     } if(T[i] > S[mid]) {
       left = mid +1;
     } else if(T[i] < S[mid]) {
       right = mid;
     } 
    }  
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2280
from collections import deque
n=int(input())
e=[]
edge=[[] for _ in range(n)]
for i in range(n-1):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
    e.append(str(x-1)+" "+str(y-1))
par=[0]*n #自分の親と何番でつながっているか
visited=[0]*n
visited[0]=1
que=deque([0])
ans=dict()
K=0
while que:
    now=que.popleft()
    color=1
    for x in edge[now]:
        if visited[x]:
            continue
        visited[x]=1
        que.append(x)
        if color==par[now]:
            color+=1
        par[x]=color
        ans[str(min(x,now))+" "+str(max(x,now))]=color
        color+=1
print(max(ans.values()))
for i in e:
    print(ans[i])

Measured memory_bytes: 125300
N,H = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N)]
ab.sort(key=lambda x: x[1])
ab.sort(reverse=True,key=lambda x: x[0])
A,B = ab[0]
ab.sort(reverse=True,key=lambda x: x[1])
ans = 0
i=0
while i<N:
    if H<=0:
        break
    
    if ab[i][1]>=A:
        H-=ab[i][1]
        i+= 1
        ans += 1
        continue
    else:
        break
from math import ceil
if H>=0:
    ans += ceil(H/A)
print(ans)


Measured memory_bytes: 28948
from itertools import accumulate
import numpy as np
N, K = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))
A = (A+1)/2

B = np.insert(A,0,0)
B = list(accumulate(B))
answer = []
for i in range(N-K+1):
    answer.append(B[i+K]-B[i])

print(max(answer))

Measured memory_bytes: 33884
n, m = [int(x) for x in input().split()]

light_list = [0] * m
for i in range(m):
    temp = [int(x) for x in input().split()]
    light = 0
    for j in range(1, temp[0] + 1):
        light |= 1 << (temp[j] - 1)
    light_list[i] = light

p_list = [int(x) for x in input().split()]

def popcount(x):
    x = x - ((x >> 1) & 0x5555)
    x = (x & 0x3333) + ((x >> 2) & 0x3333)
    x = (x + (x >> 4)) & 0x0f0f
    x = x + (x >> 8)
    return x & 0xf

ans = 0
for i in range(2 ** n):
    temp = 0
    for j in range(m):
        if popcount(i & light_list[j]) % 2 != p_list[j]:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, m) = readIntegerList()
    val aList = readIntegerList()
    val sum = aList.sum()
    val ansList = aList.filter { it * (4 * m) >= sum }
    if (ansList.size >= m) {
        println("Yes")
    } else {
        println("No")
    }
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 37832
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int main(void){
        char a[10];
        scanf("%s",a);
        if(a[0]!='7' && a[1]!='7' && a[2]!='7'){
                printf("No\n");
        } else {
                printf("Yes\n");
        }
	return 0;

       
}



Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, a, b) for(int i=a; i<b; i++)
#define per(i, a, b) for(int i=b-1; i>=a; i--)
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
char s[14],t[14],u[14];
int main(){
    scanf("%s%s",&s,&t);
    int a,b;
    cin>>a>>b;
    scanf("%s",&u);
    int w=strlen(s),m=strlen(t),q=strlen(u);
    if(w!=m){
    	if(w==q)a--;
    	if(m==q)b--;
	}
	else{
		ifor(w){
			if(s[i]!=u[i]){
				b--;
			
				break;
			}
			if(t[i]!=u[i]){
				a--;
				break;
			}
		}
	}
	cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
C = {i:0 for i in range(1,N+1)}
for i in range(1,N+1):
    C[A[i]] += 1
tot = 0
for i in range(1,N+1):
    tot += (C[i]*(C[i]-1))//2
for i in range(1,N+1):
    c = C[A[i]]-1
    ans = tot-(C[A[i]]*(C[A[i]]-1))//2+(c*(c-1))//2
    print(ans)

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

long long n, m, sum = 0;

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    sum += a;
  }
  cout << max(-1LL, n - sum) << endl;
  return 0;
}

Measured memory_bytes: 3624
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (B % A == 0)
            System.out.println(B + A);
        else
            System.out.println(B - A);
    }
}


Measured memory_bytes: 23764
#include"bits/stdc++.h"
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	vector<int> x{a,b,c};
	sort(x.begin(),x.end());
	auto it=unique(x.begin(),x.end());
	cout<<it-x.begin();
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int num;
	scanf("%d", &num);
	int firstDigit, secondDigit, thirdDigit;
	//987 % 100 = 87
	firstDigit = num / 100;
	secondDigit = (num % 100) / 10;
	thirdDigit = num % 10;
	if (firstDigit == 7 || secondDigit == 7 || thirdDigit == 7) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1628
#include<stdio.h>

int main(void){
    int N;
    int i,j;

    scanf("%d",&N);

    int a[N];
    int f[N+1];

    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
        f[i]=0;
    }

    for(i=N-1;i>=0;i--){
        int base=N/(i+1);
        int sum_f=0;
        if(base==1){
            f[i+1]=a[i];
        }else{
            for(j=2;j<=base;j++){
                sum_f+=f[(i+1)*j];
            }
            sum_f%=2;
            f[i+1]=sum_f^a[i];
        }
    }
    int count=0;
    for(i=1;i<=N;i++){
        if(f[i]==1){
            count++;
        }
    }

    printf("%d\n",count);
    for(i=1;i<=N;i++){
        if(f[i]==1){
            printf("%d ",i);
        }
    }

    return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int m;
    cin >> m;
    map<string, pair<Int, Int>> mp;
    for (Int i = 0; i < (Int)m; i++) {
        string a;
        Int x, y;
        cin >> a >> x >> y;
        mp[a] = {x, y};
    }
    Int n;
    cin >> n;
    stack<vector<bool>> st;
    for (Int i = 0; i < (Int)n; i++) {
        string s;
        cin >> s;
        vector<bool> v(256, false);
        if (isdigit(s[0])) {
            v[stoll(s)] = true;
            st.push(v);
        } else if (isalpha(s[0])) {
            for (Int j = mp[s].first; j <= (Int)mp[s].second; j++) {
                v[j] = true;
            }
            st.push(v);
        } else {
            vector<bool> b = st.top();
            st.pop();
            vector<bool> a = st.top();
            st.pop();
            if (s[0] == '+') {
                for (Int j = 0; j < (Int)256; j++) {
                    if (not a[j]) continue;
                    for (Int k = 0; k < (Int)256; k++) {
                        if (not b[k]) continue;
                        v[(j + k) % 256] = true;
                    }
                }
            }
            if (s[0] == '-') {
                for (Int j = 0; j < (Int)256; j++) {
                    if (not a[j]) continue;
                    for (Int k = 0; k < (Int)256; k++) {
                        if (not b[k]) continue;
                        v[(j - k + 256) % 256] = true;
                    }
                }
            }   
            if (s[0] == '*') {
                for (Int j = 0; j < (Int)256; j++) {
                    if (not a[j]) continue;
                    for (Int k = 0; k < (Int)256; k++) {
                        if (not b[k]) continue;
                        v[(j * k) % 256] = true;
                    }
                }
            }
            if (s[0] == '/') {
                for (Int j = 0; j < (Int)256; j++) {
                    if (not a[j]) continue;
                    for (Int k = 0; k < (Int)256; k++) {
                        if (not b[k]) continue;
                        if (k == 0) {
                            print("error");
                            return 0;
                        }
                        v[(j / k) % 256] = true;
                    }
                }
            }
            st.push(v);
        }
    }
    print("correct");
    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
int gcd(int a, int b) { return a ? gcd(b%a, a) : b; }
typedef long long ll;
ll mod = 998244353LL;
ll add(ll x, ll y) { return (x += y) >= mod ? x - mod : x; }
ll sub(ll x, ll y) { return add(x, mod - y); }
ll modpow(ll a, ll b) {
    ll ret = 1; while (b > 0) {
        if (b & 1) ret = ret * a % mod; a = a * a % mod; b >>= 1;
    } return ret;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, X[202], Y[202];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> X[i] >> Y[i];

    ll ans = modpow(2, N);

    // no point
    ans = sub(ans, 1);

    // one point
    ans = sub(ans, N);

    // line points
    rep(i, 0, N) rep(j, i + 1, N) {
        int n = 0;
        rep(k, j + 1, N) {
            int dx1 = X[j] - X[i], dy1 = Y[j] - Y[i];
            int dx2 = X[k] - X[i], dy2 = Y[k] - Y[i];
            // dy1/dx1 == dy2/dx2
            if (dy1 * dx2 == dy2 * dx1) n++;
        }
        ans = sub(ans, modpow(2, n));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N,T = map(int,input().split())
t=list(map(int,input().split()))

def count_time(N,T,t):
    cnt = T
    for i in range(N-1):
        tt =t[i+1]-t[i]        
        if tt <=T:
            cnt += tt
        else:
            cnt += T
    return cnt

print(count_time(N,T,t))

Measured memory_bytes: 25200
/* Filename: ABC077B.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			int N = input.nextInt();
			int sqrtN = (int) Math.sqrt(N);
			
			System.out.println(sqrtN * sqrtN);
		}
	}

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    vector<int> H(N,0);
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    int count=0;
    for(int i=0;i<N;i++){
        if(H[i]>=K){
            count++;
        }
    }
    
    cout<<count<<endl;
    return 0;
    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    int N; cin >> N;
    vector<ll> A(N), B(N), C(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
        for(int i = 0; i < N; i++){
        cin >> B[i];
    }
        for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    ll ans = 0;
    for(int i = 0; i < N; i++){
        auto itr_A = lower_bound(A.begin(), A.end(), B[i]);
        ll count_A = distance(A.begin(), itr_A);
        ll num_A = (itr_A == A.end())? N: count_A;
        
        auto itr_C = upper_bound(C.begin(), C.end(), B[i]);
        ll count_C = distance(C.begin(), itr_C);
        ll num_C = (itr_C == C.end())? 0: N - count_C;
        
        ans += num_A * num_C;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=2005;
long long n,x,a[maxn],b[maxn],now,ans=1e18;
int main(){
	scanf("%lld%lld",&n,&x);
	for (int i=0;i<n;i++) scanf("%lld",&a[i]);
	memset(b,63,sizeof b);
	for (int i=0;i<n;i++){
		now=x*i;
		for (int j=0;j<n;j++)
		b[j]=min(b[j],a[(i+j)%n]),now+=b[j];
		ans=min(ans,now);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
H, W=map(int, input().split())

if W==1 or H==1:
  print(1)
  exit()
  
if W%2==0:
  print(H*W//2)
else:
  if H%2==0:
    print(W*H//2)
  else:
    print(W*(H//2)+W//2+1)

Measured memory_bytes: 2940
N, M = map(int,input().split())
AC_Set = set()
WA_Dict = {}
WA_SUM = 0
for i in range(M):
    num,result = list(input().split())
    if num in AC_Set:
        continue
    else:
        if result == "AC":
            AC_Set.add(num)
            WA_SUM += WA_Dict.get(num,0)
        else:
            WA_Dict[num] = WA_Dict.get(num,0) + 1

print("{} {}".format(len(AC_Set),WA_SUM))


Measured memory_bytes: 14044
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 1010;
int n;
int a[N], b[N];
bool vis[N];
int main(){
	scanf("%d", &n);
	rep(i, 0, n) scanf("%d", a + i);
	vi ope, ansOp;
	ll ans = 0;
	if(*max_element(a, a + n) <= 0) {
		int p = max_element(a, a + n) - a;
		ans = a[p];
		rep(i, 0, p) ope.pb(1);
		for(int i = n - 1; i > p; i--) ope.pb(i - (p - 1));
	} else {
		int be = 0, ed = n;
		while(be < n && a[be] <= 0) {
			be++; ope.pb(1);
		}
		while(ed > 0 && a[ed - 1] <= 0) {
			ope.pb(ed - be); ed--;
		}
		n = ed - be;
		rep(i, be, ed) b[i - be] = a[i];
		//rep(i, 0, n) printf("%d\n", b[i]);
		for(int bit = 0; bit < 2; bit++) {
			vi vis;
			ll t = 0;
			for(int i = 0; i < n; i++) {
				if(i % 2 == bit && b[i] > 0) t += b[i], vis.pb(1);
				else vis.pb(0);
			}
			if(*max_element(all(vis)) == 0) continue;
			vi tOp;
			while(sz(vis) > 1) {
				vi siv;
		//		rep(i, 0, sz(vis)) printf("%d ", vis[i]);
		//		puts("");
				rep(i, 0, sz(vis)) {
					if(vis[i]) {
						siv.pb(vis[i]);
						continue;
					}
					if(sz(siv) == 0 || i + 1 == sz(vis)) {
						tOp.pb(sz(siv) + 1);
					} else if(vis[i - 1] == vis[i + 1]) {
						tOp.pb(sz(siv) + 1);
						siv.pop_back(); siv.pb(vis[i + 1]);
						i++;
					} else siv.pb(vis[i]);
				}
				swap(vis, siv);
			}
			if(ans < t) ans = t, ansOp = tOp;
		}
	}
	printf("%lld\n", ans);
	printf("%d\n", sz(ope) + sz(ansOp));
	for(auto & op : ope) printf("%d\n", op);
	for(auto & op : ansOp) printf("%d\n", op);
	return 0;
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")
MOD = 1000000007


INF = float("inf")
import heapq


ans = []
def dijkstra_heap(G, s, n):
    d = [INF] * n           # 始点sから各頂点への最短距離
    used = [False] * n
    d[s] = 0
    used[s] = False

    edgelist = []
    for edge in G[s]:
        heapq.heappush(edgelist, [edge[0], edge[1], s])

    while len(edgelist) > 0:
        minedge = heapq.heappop(edgelist)       # 距離最小の辺を取り出す
        dist, v, pv = minedge[0], minedge[1], minedge[2]
        
        if used[v]:
            continue
        ans[v] = pv
        d[v] = dist
        used[v] = True

        # v から伸びてる辺を edgelist に入れる
        for edge in G[v]:
            cost, nv = edge[0], edge[1]
            if used[nv]:
                continue
            heapq.heappush(edgelist, [d[v] + cost, nv, v])
    
    return d


def main():
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1; b -= 1
        G[a].append([1, b])
        G[b].append([1, a])

    for _ in range(N):
        ans.append(-1)
    dijkstra_heap(G, 0, N)

    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 167404
using System;

namespace abc055
{
    public class Program
    {
        public static void Main(string[] args)
        {
            uint modulo = (uint) Math.Pow(10, 9) + 7;
 
            int n = Convert.ToInt32(Console.ReadLine());
            ulong p = 1;

            for (int i =1; i <= n; i++)
            {
                p = p * (uint) i;
                p %= modulo;
            }
            Console.WriteLine(p);
        }
    }
}

Measured memory_bytes: 11220
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int N = scan.nextInt();
        int Ti[] = new int[N];
        
        int cost_now;
        int cost_sum = 0;
        
        for( int i = 0 ; i < N ; i++){
          Ti[i] = scan.nextInt();
          cost_sum += Ti[i];
        }
        
        int M = scan.nextInt();
        
        int Pm[] = new int[M];
        int Xm[] = new int[M];
        
        for( int i = 0 ; i < M ; i++){
          Pm[i] = scan.nextInt();
          Xm[i] = scan.nextInt();
        }
        
        for( int i = 0 ; i < M ; i++ ){
          cost_now = cost_sum;
          /*
          for( int j = 0 ; j < N ; j++){
            if(Pm[i]-1 == j)cost_now += Xm[i];
            else cost_now += Ti[j];
          }
          */
          cost_now = cost_now - Ti[ Pm[i]-1 ] + Xm[i];
          
          System.out.println(cost_now);
        }
        
	  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin>>a>>b;
  int c=a;
  long int count=1;
  if(b==1){
      cout<<0<<endl;
  }
  else{
  for(long int i=0;i<10000;i++){
    if(c>=b){
      break;
    }
    else{
      c+=a;
      c-=1;

      count+=1;
    }
  }
  cout<<count<<endl;
  }
}
  

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss; scan(ss);
      printf("%c%ld%c\n", ss.front(), (long)ss.size()-2, ss.back());
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int N, C;
int T[100005], st[100005], tt[100005], s[100005], t[100005], c[100005];
int main(void){
    
    cin >> N >> C;
    for (int i = 0; i < N; i++) cin >> s[i] >> t[i] >> c[i];

    for (int i = 0; i <= 100001; i++) T[i] = 0;

    for (int i = 1; i <= C; i++){
        for (int j = 0; j <= 100000; j++) st[j] = tt[j] = 0;

        for (int j = 0; j < N; j++){
            if (c[j] == i){
                st[s[j]]++; tt[t[j]]++;
            }
        }

        for (int j = 0; j <= 100000; j++){
            if (st[j] + tt[j]>1) st[j] = tt[j] = 0;
        }

        for (int j = 0; j <= 100000; j++){
            if (st[j] == 1) T[j]++;
            if (tt[j] == 1) T[j + 1]--;
        }

    }

    int ans = 0; 
        for (int i = 1; i <= 100000; i++){
        T[i] += T[i - 1];
        ans = max(ans, T[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
#define N 500001 /* A.size()  */
#define MAXN 500001 /* 1 <= A[i] <= MAXN */
int a[N], pre[N], dummy[MAXN];

struct node{
  int count;
  node *left, *right;
  node(int count_, node *left_, node *right_) : count(count_), left(left_), right(right_) {}
  node *insert(int l, int r, int w);
};

node *null = new node(0, NULL, NULL);
node *root[N];

node* node::insert(int l, int r, int w){
  if (l <= w && w <= r){
    if (l==r) return new node(this->count+1, null, null);

    int mid = (l+r)>>1;
    return new node(this->count+1, this->left->insert(l, mid, w), this->right->insert(mid+1, r, w));
  }
  return this;
}

int query(node *a_, int start, int end, int l, int r){
  if (end < l || start > r) return 0;
  if (start >= l && end <= r) return a_->count;
  int mid = (start+end)>>1;
  return query(a_->left, start, mid, l , r) +
         query(a_->right, mid+1, end, l, r);
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  ll n,m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    dummy[a[i]] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    pre[i] = dummy[a[i]];
    dummy[a[i]] = i;
  }

  null->left = null->right = null;
  root[0] = null;
  for (int i = 1; i <= n; ++i) {
    root[i] = ((i==1)? null:root[i-1])-> insert(0, n, pre[i]);
  }

  while(m--){
    int u,v;
    cin >> u >> v;
    int x = query(root[u-1], 0, n, 0, u-1);
    int y = query(root[v], 0, n, 0, u-1);
    cout << y-x << endl;
  }
  return 0;
}
 


Measured memory_bytes: 328536
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<ll>
#define M map<ll,ll>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>
 
#define str string
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
  LCIN(n);
  // if(n%2==0){SCOUT(n/2);SCOUT(n);COUT(n);return 0;}
  FOR(a,1,3501)
    FOR(b,1,3501){
      if(4*a*b-n*a-n*b>0&&(n*a*b)%(4*a*b-n*a-n*b)==0){SCOUT(a);SCOUT(b);COUT((n*a*b)/(4*a*b-n*a-n*b));return 0;}
    }
 
  return 0;
}


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

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

	if (s == u)
	{
		cout << a - 1 << ' ' << b << endl;
	}
	else
	{
		cout << a << ' ' << b - 1 << endl;
	}

	return 0;
}

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

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

using namespace std;
using lint=long long;

template<class T> struct edge{
	int to;
	T wt;
	edge(int to,const T& wt):to(to),wt(wt){}
};
template<class T> using weighted_graph=vector<vector<edge<T>>>;

template<class T>
vector<T> Dijkstra(const weighted_graph<T>& G,int s){
	const T INF=numeric_limits<T>::max();
	int n=G.size();
	vector<T> d(n,INF); d[s]=0;
	priority_queue<pair<T,int>> Q; Q.emplace(0,s);
	while(!Q.empty()){
		T d0=-Q.top().first;
		int u=Q.top().second; Q.pop();
		if(d0>d[u]) continue;
		for(const auto& e:G[u]){
			int v=e.to;
			if(d[v]>d[u]+e.wt) d[v]=d[u]+e.wt, Q.emplace(-d[v],v);
		}
	}
	return d;
}

int main(){
	int x,y; scanf("%d%d",&x,&y);

	map<int,int> f;
	f[ x]=0;
	f[-x]=1;
	f[ y]=2;
	f[-y]=3;
	weighted_graph<lint> G(4);
	G[f[ x]].emplace_back(f[-x],1);
	G[f[-x]].emplace_back(f[ x],1);
	G[f[ y]].emplace_back(f[-y],1);
	G[f[-y]].emplace_back(f[ y],1);
	for(int a:{x,-x,y,-y}) for(int b:{x,-x,y,-y}) if(a<b) {
		G[f[a]].emplace_back(f[b],b-a);
	}
	printf("%lld\n",Dijkstra(G,f[x])[f[y]]);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
string s;
int cnt=1,root,lst;
int main(){
	cin>>s;
	if(s[0]=='0'||s[s.length()-1]=='1'){
		puts("-1");
		return 0;
	}
	for(register int i=0;i<(s.length()>>1);i++){
		if(s[i]!=s[s.length()-i-2]){
			puts("-1");
			return 0;
		}
	}
	for(register int i=0;i<s.length();i++){
		if(s[i]=='1'){
			root=cnt;
			printf("%d %d\n",root,++cnt);
			if(lst)for(register int j=1;j<i+1-lst;j++)printf("%d %d\n",root,++cnt);
			lst=i+1;
		}
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,k;
	double ans = 0;
	cin >> n >> k;
	vector<int> v(n);
	rep(i,0,n)cin >> v[i];
	double cur = 0;
	rep(i,0,k-1)cur += double(v[i] + 1)/2;
	rep(i,k-1,n){
		cur += double(v[i]+1)/2; 
		gmax(ans,cur);
		cur -= double(v[i-k+1]+1)/2;
	}
	cout.precision(35);
	cout << ans << '\n';
}


Measured memory_bytes: 1024
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;


int main() {
    int n ;
    cin >> n  ;
    char c ;
  
    bool f = false ;
    for(int i=0;i<n;i++){
       cin >> c ;
      if(c=='Y') f = true ; 
    } 
    
    if(f)
      cout << "Four" ;
    else
      cout << "Three" ;      
      
    cout << endl ;

	return 0;
}



Measured memory_bytes: 256
a=int(input())
arr=list(map(int,input().split()))
count=0
s=set(arr)
brr=[]
d=dict()
count=0
for i in range(0,len(arr)):
    for j in range(i+1,len(arr)):
        for k in range(j+1,len(arr)):
            brr=[arr[i],arr[j],arr[k]]
            brr.sort()
            if(brr[0]+brr[1]>brr[2]):
                if((not brr[0]==brr[1]) and (not brr[1]==brr[2]) and (not brr[2]==brr[1])):
                    count=count+1
                

print(count)

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

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

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define FS first
#define SE second

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//Greatest Common Devider
LL gcd(LL a,LL b){
  if(b == 0) return a;
  return gcd(b,a%b);
}
//------------------------------------------
//Least Common Multiple
//Must be used with GCD
LL lcm(LL a,LL b){
  LL g = gcd(a,b);
  return a / g * b;
}
//grobal var
//------------------------------------------


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int N,K;
  str S;
  cin >> N >> K;
  cin >> S;
  S[K-1]+=32;
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 3030
#define P 998244353
typedef long long LL;

LL f[N][N];
LL a,b,c,d;

int main(){
    cin>>a>>b>>c>>d;
    f[0][0] = 1;
    int n = c - a, m = d - b;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(i == 0 && j == 0) continue;
            f[i][j] = 0;
            if(i) f[i][j] += f[i - 1][j] * (j + b) % P;
            if(j) f[i][j] += f[i][j - 1] * (i + a) % P;
            if(i * j) f[i][j] -= f[i - 1][j - 1] * (a + i - 1) % P * (b + j - 1) % P;
            f[i][j] = (f[i][j] % P + P) % P;
        }
    }
    printf("%lld\n", f[n][m]);
    return 0;

}

Measured memory_bytes: 74648
s = gets.chomp!
if s[0] == s[1]
  puts "1 2"
  exit
end
(0..(s.length - 3)).each do |num|
  str = (s[num] + s[num + 1] + s[num + 2]).chars.sort.join
  if str[0] == str[1]
    puts (num + 1).to_s + " " + (num + 3).to_s
    exit
  end
  if str[1] == str[2]
    puts (num + 1).to_s + " " + (num + 3).to_s
    exit
  end
end
puts "-1 -1"

Measured memory_bytes: 1916
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int A, B, H, M;
	cin >> A >> B >> H >> M;
	if (M % 2 == 0) {
		int a = H * 30 + M / 2;
		int b = 6 * M;
		if (a == b) {
			cout << abs(A - B);
			return 0;
		}
		else {
			int sa = abs(a - b);
			if (sa == 180) {
				cout << A + B;
				return 0;
			}
		}
	}
	double a = (double)H * (double)30;
	a += 0.5 * (double)M;
	double b = (double)M * (double)6;
	double sa;
	if (b >= a)sa = b - a;
	else sa = a - b;
	double degree = PI / (double)180 * (double)sa;
	double ans = sqrt((double)A * (double)A + (double)B * (double)B - 2.0 * (double)A * (double)B * cos(degree));
	printf("%.15f", ans);
}

Measured memory_bytes: 4188
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

int hoge(int a, int b){
	int c = a/b;
	if(!c) return 0;
	else if(c%2){
		return (c*b-b)/2 + a-c*b+1;
	} else {
		return (c*b)/2;
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	int A, B;
	int ans = 0;
	
	cin>>A>>B;
	A = max(0ll,A-1);
	
	for(int i = 0, t = 1; i < 50; i++, t*=2){
		ans += ((hoge(B,t)-hoge(A,t))%2)*t;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;

int main(){
  long long H, W;
  int N;
  cin >> H >> W >> N;
  
  map<pair<int, int>, int> m1;
  for(int p = 0; p < N; p++){
    int a, b;
    cin >> a >> b;
    ++m1[{a, b}];
  }
  
  long long num[10] = {0};
  map<pair<int, int>, long long> m2;
  for(auto p : m1){
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        if(p.first.first > i && p.first.second > j && p.first.first - i + 2 <= H && p.first.second - j + 2 <= W) ++m2[{p.first.first - i, p.first.second - j}];
      }
    }
  }
  
  for(auto p : m2){
    ++num[p.second];
  }
  
  num[0] = (H - 2) * (W - 2);
  for(int c = 1; c < 10; c++) num[0] -= num[c];
  
  for(int c = 0; c < 10; c++) cout << num[c] << endl;
  
  return 0;
}

Measured memory_bytes: 62720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tmp = Console.ReadLine().Split(' ');
            double N = double.Parse(tmp[0]);
            double M = double.Parse(tmp[1]);

            // sに対しCが足りない
            if(M < 2*N)
            {
                if(M%2 == 0)
                {
                    Console.WriteLine(M / 2);
                }
                else
                {
                    Console.WriteLine((M - 1) / 2);
                }
            }
            else
            {
                // S に対しCがあまる
                double amari = M - 2 * N;
                double scc = N + Math.Floor(amari / 4);
                Console.WriteLine(scc);
            }

        }

    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#define llint long long

using namespace std;

struct UnionFind{
	int size;
	vector<int> parent;
	vector<llint> num;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		num.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i, num[i] = 1;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		num[root_j] += num[root_i];
		parent[root_i] = root_j;
	}
};

llint n, m;
llint a[100005], b[100005];
llint ans[100005];
UnionFind uf(100005);

int main(void)
{
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		cin >> a[i] >> b[i];
	}
	
	llint sum = n*(n-1)/2;
	for(int i = m; i >= 1; i--){
		ans[i] = sum;
		if(!uf.same(a[i], b[i])){
			sum -= uf.num[uf.root(a[i])] * uf.num[uf.root(b[i])];
			uf.unite(a[i], b[i]);
		}
	}
	for(int i= 1; i <= m;i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h> 
    #include <ext/pb_ds/assoc_container.hpp> // Common file  
    #include <ext/pb_ds/tree_policy.hpp>  
    #include <functional>
    #include <unistd.h>
    using namespace std; 
    using namespace std::chrono; 
    using namespace __gnu_pbds;
    typedef tree<int, null_type, less<int>, rb_tree_tag,  
                tree_order_statistics_node_update>  
        ordered_set;  
    #define ll long long int 
    ll brr[200005];
    void addEdge(vector<ll> adj[], ll u, ll v) 
    { 
        adj[u].push_back(v); 
        adj[v].push_back(u); 
    } 
     
int main() 
{ 
	ll n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
  return 0; 
} 


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

vector<pll> enum_divisors(long long N) {
    vector<pll> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            // 重複しないならば i の相方である N/i も push
            res.push_back({i, N / i});
        }
    }
    // 小さい順に並び替える
    return res;
}

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

    ll N;
    cin >> N;
    ll twice = N * 2;
    vector<pll> res = enum_divisors(twice);
    ll a = 0, b = 0;
    rep(i, res.size()) {
        if (abs(res[i].first - res[i].second) == 1) {
            a = max(res[i].first, res[i].second);
            b = min(res[i].first, res[i].second);
        }
    }

    if (a == 0 && b == 0) {
        cout << "No" << endl;
        return 0;
    }

    vector<vector<int>> ans(a, vector<int>(b, 0));
    int yoko_cnt = 1, tate_cnt = 1;
    for (int i = 0; i < a; i++) {
        for (int j = i; j < b; j++) {
            ans[i][j] = yoko_cnt;
            yoko_cnt++;
        }
    }

    for (int i = 0; i < b; i++) {
        for (int j = i + 1; j < a; j++) {
            ans[j][i] = tate_cnt;
            tate_cnt++;
        }
    }

    cout << "Yes" << endl;
    cout << a << endl;
    rep(i, a) {
        cout << b << " ";
        rep(j, b) { cout << ans[i][j] << " "; }
        cout << endl;
    }
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<29;
int main(){
  
  //入力
  int H; int N;
  cin >> H >> N;
  int A[N]; int B[N];
  for(int i=0;i<N;i++) cin >> A[i] >> B[i];
  
  int DP[H+1]; //min{-i~に必要な魔力}
  DP[0]=0;
  for(int i=1;i<=H;i++){
    int minA=INF;
    for(int j=0;j<N;j++){
      minA=min(minA,DP[max(0,i-A[j])]+B[j]);
    }
    DP[i]=minA;
  }
  
  cout << DP[H] << endl;
  
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    string s;
    cin >> s;
    if(s[s.size()-1]=='s') s += "es";
    else s+= "s";
    cout << s << endl;
}

Measured memory_bytes: 3620
#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>
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;

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 operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return 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;
	}
};

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

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

	rep(i, S.size() - 8) {
		cout << S[i];
	}

	system("PAUSE");
}


Measured memory_bytes: 504
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		
		
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(W==0&&H==0) {
				break;
			}
			for(int i=0; i<H; i++) {
				for(int j=0; j<W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



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

int main(){
   int n;cin>>n;
   vector<ll> a(n);
   ll mn=INFTY,cnt=0,sum=0;

    rep(i,n){
       cin>>a[i];
       sum += abs(a[i]);
       mn = min(mn,abs(a[i])); 
       if(a[i]<0) cnt++;
    }
    if(cnt%2==0)cout<<sum<<endl;
    else cout<<sum-2*mn<<endl;
return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
int main() {
	ll y1,y2,m1,m2,d1,d2;
	cin>>y1>>m1>>d1>>y2>>m2>>d2;
	if(y1>y2){
		swap(y1,y2);
		swap(m1,m2);
		swap(d1,d2);
	}
	if(y1==y2){
		if(m1==m2 && d1==d2)cout<<0<<endl;
		else cout<<1<<endl;
		return 0;
	}
	if(m1>m2 || (m1==m2 && d1>=d2)){
		cout<<y2-y1<<endl;
	}
	else{
		cout<<y2-y1+1<<endl;
	}
	return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <math.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

vector<lli> graph[N];
bool vis[N];
map<pair<lli, lli>, lli> ma;
lli color[N];

void bfs() {
//    cout<<"YES"<<endl;
    queue<lli> q;
    q.push(1);
    while(!q.empty()) {
        lli v = q.front();
        vis[v] = 1;
        q.pop();
        lli no;
        for(auto it : graph[v]) {
            if(vis[it]) {
                no = color[ma[{it, v}]];
                break ;
            }
        }
        lli c = 1;
        for(auto it : graph[v]) {
            if(vis[it])
                continue ;
            q.push(it);
            if(c == no) {
                c ++;
            }
            color[ma[{it, v}]] = c ++;
        }
    }
//    cout<<"YES"<<endl;
    return ;
}

vector<pair<lli, lli> > v;

void solve()
{
    lli n;
    cin>>n;
    lli a, b;
    for(int i = 0; i < n - 1; i ++) {
        cin>>a>>b;
        v.push_back({a, b});
        graph[a].push_back(b);
        graph[b].push_back(a);
        ma[{a, b}] = i;
        ma[{b, a}] = i;
    }
    bfs();
  //  cout<<"YES"<<endl;
    set<lli> p;
    vector<lli> ans;
    for(int i = 0; i < v.size(); i ++) {
        lli x = color[ma[{v[i].first, v[i].second}]];
        p.insert(x);
        ans.push_back(x);
    }
    cout<<p.size()<<endl;
    for(auto it : ans)
        cout<<it<<endl;
//    cout<<'\n';
    return ;
}

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


    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 28528