akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    vector<string> bs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> bs[i];
    }
    vector<vector<int>> chrs(n, vector<int>(26, 0));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < bs[i].size(); j++)
        {
            int k = int(bs[i][j]);
            chrs[i][k - 97]++;
        }
    }
    vector<char> l;
    for (int i = 0; i < 26; i++)
    {
        int k = 50 * 100;
        for (int j = 0; j < n; j++)
        {
            k = min(k, chrs[j][i]);
        }
        for (int j = 0; j < k; j++)
        {
            l.emplace_back(char(97 + i));
        }
    }
    sort(l.begin(), l.end());
    for (int i = 0; i < l.size(); i++)
    {
        cout << l[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
function main(input) {
  input=input.trim();
  const N = parseInt(input.split(" ")[0], 10);
  const M = parseInt(input.split(" ")[1], 10);
  const X = parseInt(input.split(" ")[2], 10);
  const Y = parseInt(input.split(" ")[3], 10);
  const arrX = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
  const arrY = input.split('\n')[2].split(' ').map((n) => parseInt(n, 10));
  var ans=0

  //Zで全探索
  for(var i=0; i<Y-X; i++){
    var judgeX=0;
    var judgeY=0;
    var Z=X+1+i;
    for(var j=0; j<N; j++){
      if(arrX[j]>=Z){
        judgeX++;
      }
    }
    for(var k=0; k<M; k++){
      if(arrY[k]<Z){
        judgeY++;
      }
    }
    //条件に反する場合ans処理しない
    if(judgeX>0||judgeY>0){
    }else{
      ans++
    }
  }

  if(ans>0){
    console.log("No War");
  }else{
    console.log("War");
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 11468
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
    int n;
    scanf("%d", &n);
    if (n & 1)
        printf("%d\n", n / 2 + 1);
    else
        printf("%d\n", n / 2);
    return 0;
}

Measured memory_bytes: 128
oni_A, oni_V = map(int, input().split())
nige_B, nige_W = map(int, input().split())
T = int(input())

d = abs(oni_A - nige_B)

if (nige_W >= oni_V):
    print('NO')
else:
    time = d / (abs(oni_V - nige_W))
    if (time <= T):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
bitset<5000> dp1[5001], dp2[5001];
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  dp1[0][0] = dp2[n][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = k - 1; j >= 0; j--) {
      dp1[i + 1][j] = dp1[i][j] or j - a[i] >= 0 and dp1[i][j - a[i]];
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = k - 1; j >= 0; j--) {
      dp2[i][j] = dp2[i + 1][j] or j - a[i] >= 0 and dp2[i + 1][j - a[i]];
    }
  }
  auto needed = [&](int i) {
    if (a[i] >= k) return true;
    int x = 0, y = k - 1;
    while (true) {
      while (x < k and not dp1[i][x]) x++;
      if (x == k) break;
      while (x + y >= k - a[i]) {
        if (y >= 0 and dp2[i + 1][y]) return true;
        y--;
      }
      x++;
    }
    return false;
  };
  int l = -1, r = n;
  while (true) {
    int m = (l + r) / 2;
    if (needed(m)) r = m;
    else l = m;
    if (r - l == 1) break;
  }
  cout << r << '\n';
  return 0;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;

    int64_t ans = 0;
    for (int i = 1; i <= N; i++)
    {
        if(i%3 != 0 && i%5 != 0) ans += i;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdlib.h>

using namespace std;

void swap(long long int *dat, int i, int j){

  long long int tmp = dat[i];
  dat[i] = dat[j];
  dat[j] = tmp;

}

void quicksort(long long int *dat, int first, int last){
  
  long long int p = dat[first];
  int i = first;
  int j = last;


  while(1){ 
    while( (dat[i] < p) && (i < last) ){
      i++;
    }

    while( (p < dat[j]) && (j > first) ){
      j--;
    }
 
    if(i >= j){
      break;
    }
    
    swap(dat, i, j);
    i++;
    j--;
        
  }
  

  if( first < i - 1 ){
    quicksort(dat, first, i - 1);
  }
  if(j + 1 < last){
    quicksort(dat, j + 1, last);
  }

}

void launch_quick(long long int *dat, int num){
  
  quicksort(dat, 0, num-1);

}


int main(){
  int N,K;

  long long int* high;
  
  long long int ans = 2000000000;
  
  cin >> N >> K;

  high = (long long int*)malloc(sizeof(long long int) * N);

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

  launch_quick(high, N);

  for(int i = 0; i <= N - K; i++){
    long long int diff = high[i + K - 1] - high[i];

    if(diff < ans){
      ans = diff;
    }
    
  }

  cout << ans << "\n";

  return 0;
  
}


Measured memory_bytes: 1024
n = int(input())

mons = [int(i) for i in input().split()]
yuusha = [int(i) for i in input().split()]

taoshita = 0
#taoshinokoshi = mons[:]
for i in range(len(yuusha)):
    if mons[i] > yuusha[i]:
        taoshita = taoshita + yuusha[i]
        mons[i] = mons[i] - yuusha[i]
        yuusha[i] = 0
    else:

        if mons[i] + mons[i+1] < yuusha[i]:
            taoshita = taoshita + mons[i] + mons[i+1]
            mons[i+1] = 0

        else:
            if mons[i] > yuusha[i]:
                taoshita = taoshita + yuusha[i]
            else:
                taoshita = taoshita + yuusha[i]
                mons[i+1] = mons[i+1] - (yuusha[i] - mons[i])


print(taoshita)




Measured memory_bytes: 19004
#include<bits/stdc++.h>
using namespace std;
#define re register
#define int long long
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9'){
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int a,b,c,d,n,ans;
bool v[200005];
char s[200005];
signed main(){
n=read();
d=read();
scanf("%lld%lld%lld",&a,&b,&c);
scanf("%s",s+1);
for(re int i=1;i<=n;++i){
	if(i<=d){
		if(s[i]=='s')ans+=a;
		if(s[i]=='p')ans+=b;
		if(s[i]=='r')ans+=c;
	}
	else if((s[i]!=s[i-d])||v[i-d]){
		if(s[i]=='s')ans+=a;
		if(s[i]=='p')ans+=b;
		if(s[i]=='r')ans+=c;
	}
	else v[i]=1;
}
printf("%lld",ans);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define hell 1000000007
    using namespace std;

    void solve()
    {
     ll a,b,c,p,q,r;
     string s;
     cin>>s;
     cout<<s.substr(0,3);

}

    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 3652
// C - ID

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

map<int, vector<int>> Y_list;
map<pair<int, int>, int> PY_to_idx;

int main() {
	int N, M;
	cin >> N >> M;

	for (int i=0; i<M; i++) {
		int P, Y;
		cin >> P >> Y;
		Y_list[P].push_back(Y);
		PY_to_idx[make_pair(P, Y)] = i;
	}

	vector<string> ans(M);
	for (auto itr : Y_list) {
		int P = itr.first;
		vector<int>& Y_list = itr.second;
		sort(Y_list.begin(), Y_list.end());

		for (int i=0; i<Y_list.size(); i++) {
			int Y = Y_list[i];
			int I = i+1;
			char P_formatted[10], I_formatted[10];
			sprintf(P_formatted, "%06d", P);
			sprintf(I_formatted, "%06d", I);
			ans[PY_to_idx[make_pair(P, Y)]] = (string)P_formatted + (string)I_formatted;
		}
	}

	for (string a : ans) {
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 23584
#include<bits/stdc++.h>
using namespace std;
int k;
int a[10];
int read()
{
	int i=0,f=1;char c=getchar();
	while(c>'9'||c<'0') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') {i=i*10+c-'0';c=getchar();}
	return i*f;
}
bool pd=true;
int main()
{
	for(int i=1;i<=5;i++)
	a[i]=read();
	k=read();
	sort(a+1,a+6);
	for(int i=5;i>=2;i--)
	if(a[i]-a[1]>k)
	pd=false;
	if(pd==false) puts(":(");
	else puts("Yay!");
	return 0;
}

Measured memory_bytes: 384
// Ivan Carvalho
// Problem F - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 3010;

string s,t;
int dp[MAXN][MAXN],N,M;
stack<char> resposta;

int solve(int a,int b){

	if(a < 0 || b < 0) return 0;

	if(dp[a][b] != -1) return dp[a][b];

	if(s[a] == t[b]) return dp[a][b] = 1 + solve(a-1,b-1);

	return dp[a][b] = max(solve(a-1,b),solve(a,b-1));

}

void build(int a,int b){

	if(a < 0 || b < 0) return;

	if(s[a] == t[b]){
		resposta.push(s[a]);
		build(a-1,b-1);
		return;
	}

	if(solve(a-1,b) > solve(a,b-1)) build(a-1,b);
	else build(a,b-1);

}

int main(){

	memset(dp,-1,sizeof(dp));

	cin >> s;
	cin >> t;

	N = (int)s.size();
	M = (int)t.size();

	build(N-1,M-1);

	while(!resposta.empty()){
		cout << resposta.top();
		resposta.pop();
	}
	cout << endl;

	return 0;

}

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

using namespace std;

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

	if (s[3]==s[2]&&s[5]==s[4]){
		cout << "Yes" << endl;

	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 505

vector<int> fav[MAX_N];
int cnt[MAX_N];

int main()
{
    int n, m;
    RI(n, m);
    REP(i, n) {
        REP(j, m) {
            int a;
            RI(a);
            fav[i].PB(--a);
        }
    }
    int minp = n;
    REP(i, m) {
        memset(cnt, 0, sizeof(cnt));

        REP(j, n) {
            cnt[fav[j][0]] += 1;
        }
        int maxp = 0, maxpi = -1;
        REP(j, m) {
            if(maxp < cnt[j]) {
                maxp = cnt[j];
                maxpi = j;
            }
        }
        minp = min(minp, maxp);

        REP(j, n) {
            REPIT(ii, fav[j]) {
                if(*ii == maxpi) {
                    fav[j].erase(ii);
                    break;
                }
            }
        }
    }
    printf("%d\n", minp);
    return 0;
}


Measured memory_bytes: 896
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1e5+5;
int a[N],n,L;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&L);
	fp(i,1,n)scanf("%d",&a[i]);
	R int pos=0;
	fp(i,1,n-1)if(a[i]+a[i+1]>=L){pos=i;break;}
	if(!pos)return puts("Impossible"),0;
	puts("Possible");
	fp(i,1,pos-1)printf("%d\n",i);
	fd(i,n-1,pos+1)printf("%d\n",i);
	printf("%d\n",pos);
	return 0;
}

Measured memory_bytes: 1152
using System;

namespace AtCoder.AtCoderBeginnerContest_117
{
    public class A_EntranceExamination
    {
        public static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var str = line.Split(' ');

            int T = int.Parse(str[0]);
            int X = int.Parse(str[1]);

            double ans = (double)T / (double)X;

            Console.WriteLine("{0}", ans);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){                                                                                                    
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  int a;
  cin>>a;
  if(a==111){
    cout<<3<<endl;
  }
  else if(a==11||a==101||a==110){
    cout<<2<<endl;
  }
  else if(a==0){
    cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define N 200005
#define M 1000000007
#define mod 998244353
using namespace std;


int main()
{
    __

    ll a,b,c,l=0,r=0;

    cin >> a >> b >> c;

    l = 4*a*b;

    r = (c-a-b);
    
    if(r>0) r = r*r;

    if(l<r) cout << "Yes";

    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	int n;
	cin >> n;
	int v[n];
	REP(i,n) cin >> v[i];
	
	sort(v,v+n);
	
	double ans=(v[0]+v[1])/2.0;
	for(int i=2; i<n; i++){
		ans = (ans+v[i])/2.0;
	}
	
	printf("%.8f\n",ans);
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm> 
using namespace std;


int main(){
    int A,B,M;
    cin >> A >> B >> M;
    int mv=1000000;
    int x[A],y[B],c[M][3];
    for(int i = 0; i<A; i++) cin >> x[i];
    for(int i = 0; i<B; i++) cin >> y[i];
    for(int i = 0; i<M; i++) {
        cin >> c[i][0]>> c[i][1]>>c[i][2];
    }

    // for(int i = 0; i< A; i++){
    //     for(int j = 0; j<B; j++){
    //         mv=min(mv,x[i]+y[j]);
    //     } 
    // }
    for(int i = 0; i<M;i++){
        mv=min(mv,x[c[i][0]-1]+y[c[i][1]-1]-c[i][2]);
    }

    sort(x,x+A);sort(y,y+B);
    mv=min(mv,x[0]+y[0]);



    cout << mv<<endl;
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#include <atcoder/all>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, M;
	cin >> N >> M;
	vl A(N), B(M);
	rep(i, N)
		cin >> A[i];
	rep(i, M)
		cin >> B[i];
	vl ans = convolution<998244353LL>(A, B);
	rep(i, N + M - 1)
		cout << ans[i] << " ";
	cout << endl;
	return 0;
}

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

int main()
{
	int a[3];

	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	for (int i = 0; i < 3; i++){
	 	if (i == 2) cout << a[i] << endl;
		else cout << a[i] << " ";
	}
	return (0);
}

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

int main(){
  int64_t N,M,K;
  cin>>N>>M>>K;
  for(int64_t i=0;i<=N;i++)
    for(int64_t j=0;j<=M;j++)
      if(i*(M-j)+j*(N-i)==K){
        cout<<"Yes"<<endl;
        return 0;
      }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sn = new Scanner(System.in);
        
        int numNight = sn.nextInt();
        int firstKNight = sn.nextInt();
        int priceK = sn.nextInt();
        int pricePostK = sn.nextInt();
        
        int rate1=0;
        int rate2=0;
        if(numNight>=firstKNight){
            rate1 = firstKNight * priceK;
            rate2 = Math.max(0, (numNight-firstKNight)*pricePostK);
        }else{
            rate1 = numNight * priceK;
        }

        System.out.println(rate1+rate2);
        
    }
    
}


Measured memory_bytes: 9548
#include<cctype>
#include<iostream>
#include<stdio.h>
using namespace std;


int main(){

	int i=0;
	int c;
	char ch;


	while (1){
		scanf("%c", &ch);
		if (ch == '\n'){
			cout << endl;
			return 0;
		}

		if (isupper(ch))ch = tolower(ch);
		else ch = toupper(ch);
		cout << ch;

	}



}




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

using namespace std;

char s[100005];

int main() {
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	
	int res = 1;
	
	for (int i = 1; i < n; i++) res += (s[i] != s[i - 1]);
	
	printf("%d\n", res);
}


Measured memory_bytes: 384
sx, sy, tx, ty = [int(x) for x in input().split()]
x = tx - sx
y = ty - sy
l = ["R"]*x + ["U"]*y + ["L"]*x + ["D"]*y + ["D"] + ["R"] * (x+1) + ["U"]*(y+1) + ["L"] + ["U"] + ["L"]*(x+1) + ["D"]*(y+1) +["R"]
print("".join(l))

Measured memory_bytes: 3288
def div_neg_2(a):
    if a>0:
        return -(a//2), a%2
    elif a==0:
        return 0,0
    else:
        if (-a) % 2 == 1:
            return ((-a)+1)//2,1
        else:
            return (-a)//2,0

N = int(input())

ans = ""
next_n = N
while True:
    div, rem = div_neg_2(next_n)
    ans += str(rem)
    if div == 0:
        break
    next_n = div
print(ans[::-1])


Measured memory_bytes: 3064
N,*A=map(int,open(0).read().split())
A=[0]+A+[0]
f=abs
s=sum(f(i-j)for i,j in zip(A,A[1:]))
print(*[s-f(i-j)-f(j-k)+f(i-k)for i,j,k in zip(A,A[1:],A[2:])])

Measured memory_bytes: 14232
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  cout << n * m << endl;
}

Measured memory_bytes: 3644
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: i64,
        A: i64,
    }

    // 払えるのは [500n, 500n+A]円
    let mut rest = N;
    let n = rest / 500;
    rest -= 500 * n;
    if 0 <= rest && rest <= A {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<vector>

int main(void){
    
    std::vector<int> ar(3);
    for(int i = 0; i < 3; i++){
        std::cin >> ar[i];
    }
    std::sort(ar.begin(), ar.end());
    
    std::cout << ar[0] << " " << ar[1] << " " << ar[2] << std::endl;
    return 0;
}


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

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	for(auto &i:a)cin >> i;
	vector<ll> b(n),c(n),d(n);

	b[0] = 1000;
	c[0] = b[0]/a[0];
	d[0] = b[0]%a[0];
	for(ll i = 1;i<n;i++)
	{
		for(ll j = 0;j<i;j++)
		{
			b[i] = max(b[i],b[j]);
			b[i] = max(b[i],d[j]+c[j]*a[i]);
		}
		c[i] = b[i] / a[i];
		d[i] = b[i] % a[i];
	}
	ll ans = 0;
	for(ll i = 0;i<n;i++)
		ans = max(ans,b[i]);
	cout << ans << endl;

}


Measured memory_bytes: 3660
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  cout << s.at(0) << s.size() - 2 << s.at(s.size()-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;


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


Measured memory_bytes: 1152
fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val num = tenToRadix(n, k)

    println(num.toString().length)
}

fun tenToRadix(num:Int,mathRadix:Int):String{
    var funNum = num
    var result:String = ""
    while(funNum >= mathRadix){
        result = result+Integer.toString(funNum%mathRadix)
        funNum = funNum/mathRadix
    }
    result = result+Integer.toString(funNum)
    return result.reversed();
}

Measured memory_bytes: 35944
import queue
K = int(input())
number = queue.Queue()
number_list = list()
for i in range(1, 10):
    number.put(i)
    number_list.append(i)
vector = [-1, 0, 1]
while len(number_list) <= K:
    n = number.get()
    amari = n % 10
    for v in vector:
        dn = amari + v
        N = n * 10 + dn
        if 0 <= dn <= 9:
            number.put(N)
            number_list.append(N)

print(number_list[K-1])

Measured memory_bytes: 8560
#include <stdio.h>

int b[8][8],at[8],ay[8],b2[8][8];

int aaa(int t){
  int i,j,x,tt,bt[8][8];
  if(at[t]==1){
    if(t==7){
      //printf("r\n");
      return 1;
    }
    //printf("rr\n");
    return aaa(t+1);
  }
  
  for(i=0;i<8;i++){
    //printf("%d %d  %d\n",t,i,b2[t][i]);
    if(ay[i]==0 && b2[t][i]==0){
      at[t]=1;
      ay[i]=1;
      for(j=0;j<8;j++){
	if(-1<t-j && -1<i-j){
	  bt[t-j][i-j] = b2[t-j][i-j];
	  b2[t-j][i-j]=-1;
	}
	if(-1<t-j && i+j<8){
	  bt[t-j][i+j] = b2[t-j][i+j];
	  b2[t-j][i+j]=-1;
	}
	if(t+j<8 && -1<i-j){
	  bt[t+j][i-j] = b2[t+j][i-j];
	  b2[t+j][i-j]=-1;
	}
	if(t+j<8 && i+j<8){
	  bt[t+j][i+j] = b2[t+j][i+j];
	  b2[t+j][i+j]=-1;
	}
      }
      b2[t][i]=1;
      if(t==7)return 1;
      
      x=aaa(t+1);

      
      if(x==1){
	return 1;
      }
      else{
	at[t]=0;
	ay[i]=0;
	for(j=0;j<8;j++){
	  if(-1<t-j && -1<i-j){
	    b2[t-j][i-j]=bt[t-j][i-j];
	  }
	  if(-1<t-j && i+j<8){
	    b2[t-j][i+j]=bt[t-j][i+j];
	  }
	  if(t+j<8 && -1<i-j){
	    b2[t+j][i-j]=bt[t+j][i-j];
	  }
	  if(t+j<8 && i+j<8){
	    b2[t+j][i+j]=bt[t+j][i+j];
	  }
	}
	b2[t][i]=0;
      }
    }
  }
  return 0;
}
      

int main(){
  int i,j,k,n,t,y,count;

  scanf("%d",&n);

  for(i=0;i<8;i++){
    at[i]=0;
    ay[i]=0;
    for(j=0;j<8;j++){
      b[i][j]=0;
      b2[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&t,&y);
    b[t][y]=1;
    for(j=0;j<8;j++){
      if(-1<t-j && -1<y-j){
	b[t-j][y-j]=-1;
	b2[t-j][y-j]=-1;
      }
      if(-1<t-j && y+j<8){
	b[t-j][y+j]=-1;
	b2[t-j][y+j]=-1;
      }
      if(t+j<8 && -1<y-j){
	b[t+j][y-j]=-1;
	b2[t+j][y-j]=-1;
      }
      if(t+j<8 && y+j<8){
	b[t+j][y+j]=-1;
	b2[t+j][y+j]=-1;
      }
    }
    b[t][y]=1;
    b2[t][y]=1;
    at[t]=1;
    ay[y]=1;
  }

  /*for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(b[i][j]==1){
	printf("Q");
      }
      else{
	printf(".");
      }
    }
    printf("\n");
  }

  t=0;*/
  aaa(0);
  //while(1){
  //if(aaa(t)==1)//break;
      //t++;
    //}

  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(b2[i][j]==1){
	printf("Q");
      }
      else{
	printf(".");
      }
    }
    printf("\n");
  }

  return 0;
}
    



Measured memory_bytes: 2112
//ALDS1_12A
#include <iostream>
using namespace std;

static const int MAX=100;
static const int INF=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

int prim(){
 int u,minv;
 int d[MAX],p[MAX],color[MAX];
 for(int i=0;i<n;i++){
  d[i]=INF;
  p[i]=-1;
  color[i]=WHITE;
 }
 d[0]=0;
 while(true){
  minv=INF;
  u=-1;
  for(int i=0;i<n;i++){
   if(minv>d[i] && color[i]!=BLACK){
    u=i;
    minv=d[i];
   }
  }
  if(u==-1) break;
  color[u]=BLACK;
  for(int v=0;v<n;v++){
   if(color[v]!=BLACK && M[u][v]!=INF){
    if(d[v]>M[u][v]){
     d[v]=M[u][v];
     p[v]=u;
     color[v]=GRAY;
    }
   }
  }
 }
 int sum=0;
 for(int i=0;i<n;i++){
  if(p[i]!=-1) sum+=M[i][p[i]];
 }
 return sum;
} 

int main(){
 cin>>n;
 for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
   int e;
   cin>>e;
   M[i][j]=(e==-1) ? INF:e;
  }
 }
 cout<<prim()<<endl;
 return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
//#define MOD 998244353
#define EPS (1 >> 30)
#define INF (1 << 30)
//#define INF (1LL << 60)
//#define int long long

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    vector<int> a(n);
    vector<int> b(n);
    ll ans = 0;
    ll aa = 0;
    ll ab=0;
    ll bb = 0;
    rep(i, n)
    {
        rep(j, s[i].size() - 1)
        {
            if (s[i][j] == 'A' && s[i][j + 1] == 'B')
            {
                ans++;
            }
        }
        
        if (s[i][s[i].size() - 1] == 'A')
        {
        if (s[i][0] == 'B')
        {
            ab++;
            continue;
        }
            aa++;
        }
        if (s[i][0] == 'B')
        {
            bb++;
        }
    }
    if(ab==0){
        cout<<ans+min(aa,bb);
    }
    else if(aa+bb==0){
        cout<<ans+ab-1<<endl;
    }
    else{
        cout<<ans+ab+min(aa,bb)<<endl;
    }
    
}

Measured memory_bytes: 896
a,b = map(int,input().split())
if (a < 0 and b < 0):
  if ((b-a)%2 == 0):
    print('Negative')
  else:
    print('Positive')
elif (a > 0 and b > 0):
  print('Positive')
elif (a <= 0 and b >= 0):
  print('Zero')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

void out(bool yes){
  if(yes){
    cout << "Yes" << endl;
  }
  else{ 
    cout << "No" << endl;
  }
}

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  int H, W; cin >> H >> W;
  if(H == 1 && W == 1){
    out(true);
    return 0;
  }
  
  int one = 0;
  int two = 0;
  if(H % 2 == 1 && W % 2 == 1){
    one = 1;
    two = H / 2 + W / 2;
  }
  else if(H % 2 == 1){
    two = W / 2 ;
  }
  else if(W % 2 == 1){
    two = H / 2 ;
  }
  int four = (H / 2) * (W / 2);
  DEBUG(four);
  DEBUG(two);
  DEBUG(one);

  vector<int> v(30);
  rep(i, H){
    string str;
    cin >> str;
    rep(j, str.size()){
      v[str[j] - 'a']++;
      if(v[str[j] - 'a'] >= 4 && four > 0){
        four--;
        v[str[j] - 'a'] -=4;
      }
    }
  }

  rep(j, 1000)
  rep(i, 30){
    if(v[i] >= 2 && two > 0){
      two--;
      v[i] -= 2;
    }
  }

  rep(i, 30){
    if(v[i] >= 1 && one > 0){
      one--;
      v[i]--;
    }
  }

  rep(i, 30){
    DEBUG(v[i]);
  }

  DEBUG(four);
  DEBUG(two);
  DEBUG(one);
  if(!four && !two && !one){
    out(true);
  }
  else{
    out(false);
  }
}  


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int x, ans = 0;
    cin >> x;
    ans += (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    N = int(input())
    S = input()

    str_list = list(set(S))
    max_cnt = 0
    
    for i in range(1, N):
        cnt = 0
        first_str = S[:i]
        last_str = S[i:]

        for j in str_list:
            if j in first_str and j in last_str:
                cnt += 1
        if cnt > max_cnt:
            max_cnt = cnt
    
    print(max_cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
// ALDS1_1_B 最大公約数

#include <iostream>

using namespace std;

int main()
{
  int x, y;
  cin >> x >> y;

  int great = max(x, y);
  int small = min(x, y);

  while(1){
    int b = great % small;
    if (!b) break;
    great = small; small = b;
  }

  cout << small << endl;

  return 0;
}



Measured memory_bytes: 3096
//g++  7.4.0

#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    std::string s;
    cin >> s;

    double hourhand = 360.0 * ((double)h/12.0) + 30.0 * ((double)m/60.0);
    double minutehand = 360.0 * ((double)m/60.0);
    double delta = std::abs(minutehand - hourhand);
    //cout << hourhand << ", " << minutehand << ", " << delta << endl;
    
    // 余弦定理
    double ans = std::sqrt(a*a + b*b - 2.0 * a * b * cos(delta * M_PI/180.0));
    printf("%.12lf\n", ans);
    
    return 0;
}



Measured memory_bytes: 4064
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n,m,k;
		cin>>n>>m>>k;
		if(m==1)
		{
			if(k==(n-1))
			cout<<1;
			else
			cout<<0;
			return 0;
		}
		ll ans=(m*po(m-1,n-1))%mod;
		ll sub=ans;
		m=po(m-1,mod-2);
		FOR(i,0,k)
		{
			sub=(sub*(n-i-1))%mod;
			sub=(sub*po(i+1,mod-2))%mod;
			sub=(sub*m)%mod;
			ans+=sub;
		}
		cout<<ans%mod;
	}
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main()
{
    char Mark;
    char m[4] = {'S','H','C','D'};
    int Card[4][13]= {};
    int num,n,i,mark,j;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf(" %c %d", &Mark, &num);

        if (Mark == 'S')
            mark = 0;
        else if (Mark == 'H')
            mark = 1;
        else if (Mark == 'C')
            mark = 2;
        else if (Mark == 'D')
            mark = 3;

        Card[mark][num-1]=1;
    }
    for (i = 0; i < 4; ++i)
    {
        for (j = 0; j < 13; ++j)
        {
            if (Card[i][j]==0)
            {
                printf("%c %d\n", m[i], j + 1);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>

long gcd(long x, long y)
{
	return y ? gcd(y, x % y) : x;
}

long lcm(long x, long y)
{
	return x * y / gcd(x, y);
}

int main(void)
{
	char S[100001], T[100001];
	long N, M, tmp1, tmp2, i;
	scanf("%ld%ld%s%s", &N, &M, S, T);
	tmp1 = lcm(N, M);
	tmp2 = lcm(tmp1 / N, tmp1 / M);
	for (i = 0; S[i / (tmp1 / N)] != '\0' && T[i / (tmp1 / M)] != '\0'; i += tmp2) {
		if (S[i / (tmp1 / N)] != T[i / (tmp1 / M)]) {
			puts("-1");
			return 0;
		}
	}
	printf("%ld", tmp1);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <array>

using namespace std;

const int MOD = 2019;

// source: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int modpow(int a, int n) {
  long long res = 1;
  while (n > 0) {
    if (n % 2 == 1) res = res * a % MOD;
    a = a * a % MOD;
    n /= 2;
  }
  return res;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();

  array<int, 2020> mod_counts;
  fill(mod_counts.begin(), mod_counts.end(), 0);
  mod_counts[0]++;
  int m = 0;
  for (int i = n - 1; i >= 0; i--) {
    m = (m + (s[i] - '0') * modpow(10, n - i - 1)) % MOD;
    mod_counts[m]++;
  }

  long long answer = 0;
  for (int i : mod_counts) {
    answer += i * (i - 1) / 2;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3756
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<int> xs;
vector<int> ys;

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

    xs.resize(N);
    ys.resize(N);
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        xs[i] = x;
        ys[i] = x;
    }

    sort(ys.begin(), ys.end());

    int left = ys[(int) ys.size() / 2 - 1];
    int right = ys[(int) ys.size() / 2];
    // printf("left: %d, right: %d\n", left, right);

    for (int i = 0; i < N; i++) {
        if (xs[i] <= left) {
            cout << right << endl;
        } else {
            cout << left << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4740
#include<stdio.h>
int main(){
  int n,a,b;
  scanf("%d",&n);
  while(n--){
    scanf("%d %d",&a,&b);
    if(a>b){
      if(a>5){
	while(a<10)printf("%d ",a++);
	a=5;
      }
      while(a-b&&a)printf("%d ",a--);
    }
    while(b-a)printf("%d ",a++);
    printf("%d\n",b);
  }
  return 0;
}
  

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  
  int s=0,m=-1;
  
  for(int i=0;i<n-1;i++)
  {
      if(a[i]>=a[i+1])
      s+=1;
      else
      s=0;
      m=max(s,m);
  }
  
  if(n==1)
  cout<<"0";
  else
  cout<<m;
  
 return 0; 
}

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

int main(void)
{
  int a[3];
  for (int i = 0; i < 3; i++) cin >> a[i];
  sort(a, a + 3);
  if (a[2] == a[1] + a[0]) cout << "Yes";
  else cout << "No";
  cout << "\n";
}


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

long long gcd(long long a,long long b){//最小公倍数
  if(b==0) return a;
  return gcd(b,a%b);
}

long long lcm(long long a,long long b){
  long long x= gcd(a,b);
  return (b/x)*a;
}

int main(){
  int n;
  cin>>n;
  long long ans=1;
  for(int i=0;i<n;i++){
    long long a;
    cin>>a;
    ans=lcm(ans,a);
  }cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Abc166C
    {

        static int n;
        static int m;
        static int q;
        static int[][] abcd;
        static int[] a;

        public static void Main()
        {
            var nm = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            n = nm[0];
            m = nm[1];
            var h = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var way = new List<int>[n];

            for (int i = 0; i < m; i++)
            {
                var ab = Console.ReadLine().Split(' ').Select(j => int.Parse(j) - 1).ToArray();
                if (way[ab[0]] == null)
                    way[ab[0]] = new List<int>();
                if (way[ab[1]] == null)
                    way[ab[1]] = new List<int>();
                way[ab[0]].Add(ab[1]);
                way[ab[1]].Add(ab[0]);
            }

            int count = 0;
            for (int i = 0; i < n; i++)
                if (way[i] == null || way[i].All(j => h[i] > h[j]))
                    count++;
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 56936
#include <bits/stdc++.h>
using namespace std;
int n,dist1[100005],dist2[100005],resf,ress;
vector<int> son[100005];
void dfs1(int c,int f,int d)
{
	dist1[c]=d;
	for(int i=0;i<son[c].size();i++)
		if (son[c][i]!=f)
			dfs1(son[c][i],c,d+1);
}
void dfs2(int c,int f,int d)
{
	dist2[c]=d;
	for(int i=0;i<son[c].size();i++)
		if (son[c][i]!=f)
			dfs2(son[c][i],c,d+1);
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		son[a].push_back(b);
		son[b].push_back(a);	
	}
	dfs1(1,-1,0);
	dfs2(n,-1,0);
	for(int i=1;i<=n;i++)
		if (dist1[i]<=dist2[i])
			resf++;
		else
			ress++;
	if (resf>ress)
		cout<<"Fennec";
	else
		cout<<"Snuke";
	return 0;
} 

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

#define ios  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main() {
    ios;
   ll n,m;
   cin>>n>>m;

   ll arr[n+2][m+2];
   for(ll i=0;i<=n+1;i++)
   {
       for(ll j=0;j<=m+1;j++)
       {
           if(i==0||j==0||i==n+1||j==m+1)
            arr[i][j]=0;
           else
           {
               char c;
               cin>>c;
               if(c=='.')
                arr[i][j]=1;
               else
                arr[i][j]=0;
           }
       }
   }


   for(ll i=n;i>0;i--)
   {
       for(ll j=m;j>0;j--)
       {

           if(arr[i][j]==1)
           arr[i][j]=(arr[i+1][j]+arr[i][j+1])%1000000007;
           if(i==n&&j==m)
            arr[i][j]=1;
       }
   }
   cout<<arr[1][1];
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <stack>
#include <vector>
#include <string>
using namespace std;

int main(){
  while(true){
    string s;
    getline(cin, s);
    if(s == ".")
      break;
    
    stack<char> st;
    bool flag = false;
    for(int i=0; i<s.size(); i++){
      if(s[i] == '(' || s[i] == '['){
        st.push(s[i]);
        continue;
      }

      if(s[i] == ')'){
        if(st.empty()){
          flag = true;
          break;
        }
        if(st.top() == '('){
          st.pop();
        }else{
          flag = true;
          break;
        }
      }
      if(s[i] == ']'){
        if(st.empty()){
          flag = true;
          break;
        }
        if(st.top() == '['){
          st.pop();
        }else{
          flag = true;
          break;
        }
      }
    }

    if(flag || !st.empty())
      cout << "no" << endl;
    else
      cout << "yes" << endl;
  }
  
  return 0;
}

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

int main() {

  int N, M;
  cin >> N >> M;

  vector<pair<int,int>> store(N);
  for (int i = 0; i < N; i++) {
    cin >> store[i].first >> store[i].second;
  }

  sort(store.begin(), store.end());
  
  long long answer = 0;

  int current = 0;
  while (0 < M) {
    answer += (long long) store[current].first * min(M, store[current].second);
    M -= store[current].second;
    current++;
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 1024
// include
#include <iostream>
#include <stdio.h>
#include<string.h>
#include<vector>
#include<string>
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;


int main(void) {
	int i, count, flag = 0;
	char c;
	string s;
	cin >> s;
	for (c = 'a'; c <= 'z'; c++) {
		count = 0;
		for (i = 0; s[i] != '\0'; i++) {
			if (s[i] == c) {
				count++;
			}
		}
		if (count % 2 != 0) {
			flag = 1;
		}
	}
	if (flag == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int H,W,i,j;
    
    while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0){break;}
    
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            if((j!=0&&j!=W-1)&&(i!=0&&i!=H-1)){
                printf(".");
            }
            else{printf("#");}
        }
        printf("\n");
    }
     printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int cost[9] = {2,5,5,4,5,6,3,7,6};
vector <char>  ok ;
string smax(string s, string t){
    if(s.size()>t.size()) return s; 
    else if(s.size()<t.size()) return t; 
    return max(s,t); 
}
int main(){
    int n,m; cin>>n>>m;
    rep(i,m) {char a; cin>>a; ok.push_back(a);}
    vector <string> dp (10050, "-");
    dp[0] = "";
    rep(i,n){
        if(dp[i] == "-") continue;
        rep(j, ok.size()){
            dp[i + cost[ok[j] - '1']] = smax(dp[i + cost[ok[j] - '1']], dp[i] + ok[j]);
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 43648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll ans;
ll prem[100010];
int a[100010];
int main(){
	cin>>n;
	int x;cin>>x;
	if(n==0){
		if(x==1)cout<<1;
		else cout<<-1;
		return 0;
	}
	if(x!=0){
		cout<<-1;
		return 0;
	}
	for(int i=1;i<=n;i++)cin>>a[i];
	prem[n]=a[n];
	for(int i=n-1;i>=1;i--)
	prem[i]=prem[i+1]+a[i];
	ll la=1;ans=1;
	for(int i=1;i<=n;i++){
		x=a[i];
		if(la*2<x){
			cout<<-1;
			return 0;
		}
		la=la*2-x;
		if(la>prem[i+1])la=prem[i+1];
		if(i==n)la=0;
		ans+=la+a[i];
	}
	cout<<ans;
    return 0;
}








Measured memory_bytes: 4804
#include<bits/stdc++.h>
#define ld long double
#define ll long long
#define st first
#define nd second
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
using namespace std;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x;
	cin>>x;
	if(x>=30) cout<<"Yes";
	else cout<<"No";
}


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

int main(){
    int t ,n, k, q;
    cin >> n >> k >> q;
    int a[n]={0};
    rep(i,q){
        int b;
        cin >> b;
        b--;
        a[b]++;
    }
    rep(i,n){
        if(k-q+a[i]<=0)
            cout << "No" << endl;
        else {
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 1024
n = int(input())
a = [0]*n
for i in range(n):
  a[i] = int(input())
routed = {1}
steps = 0
for i in range(n):
  if i == 0:
    posn = 1
  elif posn == 2:
    break
  elif a[posn-1] in routed:
    steps = -1
    break
  posn = a[posn-1]
  steps += 1
  routed.add(posn)
print(steps)

Measured memory_bytes: 13164
/*
 * Author:  Teletubbies
 * Created Time:  2012年08月29日 星期三 16&#26102;07分14秒
 * File Name: 1009.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <time.h>
#include <cctype>
#include <functional>
#include <deque>
#include <iomanip>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <sstream>
#include <utility>

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORD(i,a,b) for (int i=(a); i>=(b); i--)
#define REP(i,b) FOR(i,0,b)
#define sf scanf
#define pf printf
using namespace std;
const int maxint = -1u>>1;
const double pi = 3.14159265358979323;
const double eps = 1e-8;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<int>::iterator vit;

double px,py,vx,vy;
int l[55],r[55],b[55],t[55];
int n,v;

bool check(double vx,double vy,double px){
    double tmpt,yy1,yy2,tt,ppy;
    //cout << vx << " " << vy << endl;
    tt=px/vx;
    ppy=vy*tt-0.5*9.8*tt*tt;
    if (ppy<py) return false;//diguo egg
    for (int i=0; i<n; i++) {
        if (l[i]<px && px<=r[i]) { //muban zhongjian de 
            tmpt=l[i]/vx;
            yy1=vy*tmpt-0.5*9.8*tmpt*tmpt;
            tmpt=px/vx;
            yy2=vy*tmpt-0.5*9.8*tmpt*tmpt; //zhuangqiang de 
            if (yy1>=b[i] && yy1<=t[i]) return false;
            if (yy2>=b[i] && yy2<=t[i]) return false;
            if (yy1<=b[i] && yy2>=b[i]) return false;
            if (yy1>=b[i] && yy2<=b[i]) return false;
            if (yy1>=t[i] && yy1<=t[i]) return false;
            if (yy1<=t[i] && yy2>=t[i]) return false;
        }
        else {
            if (l[i]<px) { //shifou ke feiguo 
                tmpt=l[i]/vx;
                yy1=vy*tmpt-0.5*9.8*tmpt*tmpt;
                tmpt=r[i]/vx;
                yy2=vy*tmpt-0.5*9.8*tmpt*tmpt; //zhuangqiang de 
                if (yy1>=b[i] && yy1<=t[i]) return false;
                if (yy2>=b[i] && yy2<=t[i]) return false;
                if (yy1<=b[i] && yy2>=b[i]) return false;
                if (yy1>=b[i] && yy2<=b[i]) return false;
                if (yy1>=t[i] && yy1<=t[i]) return false;
                if (yy1<=t[i] && yy2>=t[i]) return false;
            }
        }      
        
    }
    return true;
}

int main() 
{
    while (~scanf("%d%d%lf%lf",&n,&v,&px,&py)) {
        for (int i=0; i<n; i++) {
            scanf("%d%d%d%d",&l[i],&b[i],&r[i],&t[i]);
        }    
        bool flag=false;
        for (int i=1; i<=v*1000; i++) {
            vx=i*1.0/1000;
            vy=sqrt(v*v-vx*vx);
            if (check(vx,vy,px)) {
                flag=true;
                puts("Yes");
                break;
            }
        }
        if (!flag) puts("No");
        
    }
    return 0;
}

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

long long gcd(long long a,long long b){
  long long r,tmp;

  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

  vector<long long> t(n);
  for (int i = 0; i < n; i++)
  {
    cin >> t[i];
  }

  long long g = t[0];
  for (int i = 1; i < n; i++)
  {
    g = t[i]/gcd(g,t[i])*g;
  }
  cout << g << endl;  
}

Measured memory_bytes: 256
from itertools import accumulate, chain

n, c = map(int, input().split())
xs, vs = zip(*(map(int, input().split()) for _ in range(n)))

ds = [j - i for i, j in zip(chain([0], xs), chain(xs, [c]))]

clockwise1      = chain([0], (v - d*2 for v, d in zip(accumulate(vs), accumulate(ds))))
anticlockwise1  = chain([0], (v - d for v, d in zip(accumulate(vs[::-1]), accumulate(ds[::-1]))))
clock_anticlock = (x + y for x, y in zip(clockwise1, reversed(list(accumulate(anticlockwise1, func=max)))))

anticlockwise2  = chain([0], (v - d*2 for v, d in zip(accumulate(vs[::-1]), accumulate(ds[::-1]))))
clockwise2      = chain([0], (v - d for v, d in zip(accumulate(vs), accumulate(ds))))
anticlock_clock = (x + y for x, y in zip(anticlockwise2, reversed(list(accumulate(clockwise2, func=max)))))
 
print(max(chain(anticlock_clock, clock_anticlock)))

Measured memory_bytes: 59224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
using ll = long long;

int main() {
	int n;
	string s;
	cin >> s;
	n = s.size();
	cout << s;
	if (s[n - 1] == 's') cout << 'e';
	cout << 's' << endl;
	return 0;
}


Measured memory_bytes: 3624