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

int main()
{
    long long n,i,m=0,a=0;
    cin>>n;
    long long h[n+1];h[0]=0;
    for(i=1;i<=n;i++)
    {
      cin>>h[i];
      if(h[i]<=h[i-1]) {a++;}
      else {m=max(a,m);a=0;} 
    }
    m=max(a,m);
    cout<<m;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>

int main(void){

	int a, b, c;
	int judge = 0;

	scanf("%d %d %d", &a, &b, &c);

	for (int i = a; i <= b; i++){
		if (c%i == 0){
			judge++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

ll dp[100001][2], a[100001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    FOR(i, 0, n) cin >> a[i];
    dp[0][0] = a[0]; dp[0][1] = LLONG_MIN / 2;
    FOR(i, 1, n) {
        dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i];
        dp[i][1] = max(dp[i - 1][0] - 2 * a[i - 1], dp[i - 1][1] + 2 * a[i - 1]) - a[i];
    }
    cout << max(dp[n - 1][0], dp[n - 1][1]);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

ll Gcd(ll m, ll n){
    ll tmp;
    while(m % n != 0){
        tmp = n;
        n = m % n;
        m = tmp;
    }
    return n;
}

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll num = b-(a-1);
    ll ans(0);

    ll num_c = (b/c)-((a-1)/c);
    ll num_d = (b/d)-((a-1)/d);

    ll cd = c * d / Gcd(c,d);
    // cout << cd << endl;

    ll num_cd = (b/cd)-((a-1)/cd);

    ans = num - (num_c + num_d - num_cd);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
S = int(input())
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if S == 10 ** 18:
    X2 = 10 ** 9
    Y3 = 10 ** 9
else:
    X2 = int(math.sqrt(S) + 1)
    Y3 = X2
    s = X2 ** 2  - S #残りの面積
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s//i <= 10 ** 9 and i <= 10 ** 9:
            X3 = i
            Y2 = s//i
            break

print (0, 0, X2, Y2, X3, Y3)


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=105;
const int L=2005;

int n,m,l,u,v,d,p,t;
int dp[N][N];
int match[L];
bool vis[L];

void floyd() {
    for (int k=0;k<n;k++) {
        dp[k][k]=0;
        for (int i=0;i<n;i++) {
            for (int j=0;j<n;j++) {
                if (i!=j) dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
}

vector<int> g[L];

int dfs(int u) {
    vis[u]=1;
    for (int i=0;i<g[u].size();i++) {
        int to=g[u][i];
        if (match[to]==-1||(!vis[match[to]]&&dfs(match[to]))) {
            match[u]=to;
            match[to]=u;
            return 1;
        }
    }
    return 0;
}

int main()
{
    while (true) {
        scanf("%d%d%d",&n,&m,&l);
        if (n==0&&m==0&&l==0) break;
        memset(dp,INF,sizeof(dp));
        for (int i=0;i<m;i++) {
            scanf("%d%d%d",&u,&v,&d);
            dp[u][v]=dp[v][u]=d;
        }
        vector<PII> reqs;
        for (int i=0;i<l;i++) {
            scanf("%d%d",&p,&t);
            reqs.pb(mp(p,t));
        }
        floyd();
        for (int i=0;i<2*l;i++) g[i].clear();
        for (int i=0;i<l;i++) {
            for (int j=0;j<l;j++) {
                int a=reqs[i].first;
                int b=reqs[j].first;
                if (i!=j&&reqs[i].second+dp[a][b]<=reqs[j].second) {
                    g[i].pb(j+l);
                    g[j+l].pb(i);
                }
            }
        }

        memset(match,-1,sizeof(match));
        int mx_match=0;
        for (int i=0;i<2*l;i++) {
            if (match[i]==-1) {
                memset(vis,0,sizeof(vis));
                mx_match+=dfs(i);
            }
        }
        printf("%d\n",l-mx_match);
    }
}



Measured memory_bytes: 11644
# Coding by Rute
# C - Build Stairsの解説を始めます。
N = int(input())
H = list(map(int,input().split()))
f = 0 #フラグ関数です。
for i in range(1,N):
  if H[-(i+1)] <= H[-i]:
    #階段の高さが単調非減少かを調べます。
    continue
  else:
    if H[-(i+1)]-H[-i] == 1:
      #そうでない場合、高さが1小さければ、H[-(i+1)]を1小さくすれば良いです。
      #もし高さが2以上小さければ、その時点で単調非減少とすることができないのでフラグ関数に1を加えます。
      H[-(i+1)] -= 1
    else:
      f += 1
      break
if f == 0:
  print("Yes")
else:
  print("No")
#計算量は判定でO(N)かかります。
#以上、C - Build Stairsの解説でした。



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

namespace ABC018A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (a + b == c || a + c == b || b + c == a)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;


int main(){
	int N,A,B;
	cin>>N>>A>>B;
	int cnt[3]={};
	for(int i=0;i<N;i++){
		int x;cin>>x;
		if(x<=A)cnt[0]++;
		else if(x<=B)cnt[1]++;
		else cnt[2]++;
	}
	int mini = 9999999;
	for(int i=0;i<3;i++){
		mini = min(mini,cnt[i]);
	}
	cout<<mini<<endl;
	
	
	return 0;
}


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

int main(){
    int n, T;
    cin >> n >> T;
    int c, t;
    int cost = 100000;
    for(int i=0; i<n; i++){
        cin >> c >> t;
        if(t <= T){
            cost = min(cost, c);
        }
    }
    if(cost == 100000){
        cout << "TLE" << endl;
    }
    else{
        cout << cost << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int N,X;
  cin >> N >> X;
  int sum=0;
  int m=1001;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    sum+=a;
    m=min(m,a);
  }
  cout << N+(X-sum)/m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define int ll

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

    vector<pair<int,int>> ans;
    ll n;cin>>n;
    vector<ll> a(n);
    ll M=-LINF,m=LINF,Midx,midx;
    rep(i,n){
        cin>>a[i];
        if(M<a[i]){
            Midx=i;
            M=a[i];
        }
        if(m>a[i]){
            midx=i;
            m=a[i];
        }
    }
    bool p=true;
    if(M>=0&&m>=0){
        
    }
    else if(M<=0&&m<=0){
        p=false;
    }
    else{
        if(abs(M)>=abs(m)){
            rep(i,n){
                if(a[i]<0){
                    a[i]+=M;
                    ans.push_back(make_pair(Midx,i));
                }
            }
        }
        else{
            p=false;
            rep(i,n){
                if(a[i]>0){
                    a[i]+=m;
                    ans.push_back(make_pair(midx,i));
                }
            }
        }
    }
    //全部正
    if(p){
        //前から累積和を作ればいい
        for(int i=1;i<n;i++){
            ans.push_back(make_pair(i-1,i));
            a[i]+=a[i-1];
        }
    }
    //全部負
    else{
        //後から累積和を作ればいい
        for(int i=n-2;i>=0;i--){
            ans.push_back(make_pair(i+1,i));
            a[i]+=a[i+1];
        }
    }
    //debug(a);
    cout<<ans.size()<<endl;
    for(auto x:ans){
        cout<<x.first+1<<' '<<x.second+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  ll n;cin>>n;
  vector<ll>x(n);
  ll ans=10000000;
  for(int i=0;i<n;i++){
    cin>>x.at(i);
  }
  
  for(int j=1;j<=100;j++){ 
    ll sum=0;
    for(int i=0;i<n;i++){
      sum+=(x.at(i)-j)*(x.at(i)-j);
    }
    ans=min(ans,sum);
  }
  cout<<ans;
}
      
      
  
    

  
    

    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<map>
#include<vector> 
using namespace std;
typedef long long LL;
const int maxn=1<<19;
typedef pair< int , int > PII;
PII a[maxn]; int b[maxn]; 

PII work(int i,int j)
{
	int fmax=a[i].first;
	int smax=a[i].second;
	if(a[j].first>fmax)
	{
		smax=fmax;
		fmax=a[j].first;
	}
	else if(a[j].first>smax) smax=a[j].first;
	else if(a[j].second>smax) smax=a[j].second;
	return make_pair(fmax,smax);
}


int main(void)
{
	int n; scanf("%d",&n);
	int len=1<<n;
	for(int i=0;i<len;i++) scanf("%d",&b[i]);
	for(int i=0;i<len;i++) a[i]=make_pair(b[i],-1);
	for(int i=0;i<n;i++)
	{
		for(int s=0;s<len;s++)
		{
			if((s>>i)&1) a[s]=work(s,(s^(1<<i)));
		}
	}
	int res=-1;
	for(int i=1;i<len;i++)
	{
		res=max(res,a[i].first+a[i].second);
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 8192
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <limits>
#include <type_traits>

using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;
 
int main() {
    int N;
    double A[Nmax];
    double sum=0;
    cin >> N;
    FOR(i,0,N){
        cin >> A[i];
        A[i] = 1 / A[i];
        sum += A[i];
    }
    cout << 1 / sum << endl;
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















template <typename T>
class BIT {
private:
    int b;    // bit.size() < 2^n になる最小の2^n
    vector<T> bit;
    
public:
    BIT(int n) : bit(n + 1){
        b = 1;
        while(b <= n){
            b <<= 1;
        }
    }
    
    // posまでの合計
    T sum(int pos){
        T sum = 0;
    
        for(pos++; pos > 0; pos -= pos & -pos){
            sum += bit[pos];
        }
        
        return sum;
    }
    
    void add(int pos, T x){
        for(pos++; pos < bit.size(); pos += pos & -pos){
            bit[pos] += x;
        }
    }
    
    int lower_bound(T x){
        int res = 0;
    
        for(int i = b; i > 0; i >>= 1){
            if(res + i < bit.size() && bit[res + i] < x){
                x -= bit[res + i];
                res += i;
            }
        }
        
        return res;
    }
};


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    vector<ll> b(n + 1);
    REP(i, n){
        b[i + 1] = a[i] + b[i] - k;
    }
    vector<ll> t = b;
    sort(t.begin(), t.end());
    vector<ll> c(n + 1);
    REP(i, n + 1){
        ll l = 0, r = n + 1;
        while(r - l > 1){
            ll m = (l + r) / 2;
            ((t[m] <= b[i])? l : r) = m;
        }
        c[i] = l;
    }
    BIT<ll> bit(n + 1);
    ll ans = 0;
    REP(i, n + 1){
        ans += bit.sum(c[i]);
        bit.add(c[i], 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    char b;
    cin >> b;
    if (b == 'A')
        cout << "T" << endl;
    if (b == 'T')
        cout << "A" << endl;
    if (b == 'G')
        cout << "C" << endl;
    if (b == 'C')
        cout << "G" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int k,a,b;
	cin>>k;
	cin>>a>>b;
	int c=b/k;
	c*=k;
	if (c<=b&&c>=a) cout<<"OK";
	else cout<<"NG";
	return 0;
}

Measured memory_bytes: 3576
# from pprint import pprint
# import math
# import collections

n = int(input())
# n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

MOD = 10 ** 9 + 7

wa = 0
for i in range(1, n):
    wa += a[i]

# print('wa', wa)

ans = 0
j = 1
for i in range(n - 1):
    ttl = a[i] * wa
    ans += ttl

    wa -= a[j]
    j += 1

    # print('new wa', wa)

print(ans % MOD)


Measured memory_bytes: 31412
#include<cstdio>
#include<cstdlib>
#include<iostream> 
#include<algorithm> 
int ic[101];
using namespace std;
int main()
{
	int n,ip[101];
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>ip[i];
	sort(ip+1,ip+n+1);
	for(int i=ip[1];i<=ip[n];i++)
		for(int j=1;j<=n;j++)
			ic[i]+=(ip[j]-i)*(ip[j]-i);
	sort(ic+ip[1],ic+ip[n]);
	cout<<ic[ip[1]]; 
	return 0;
}

Measured memory_bytes: 256
//abc063_b Varied


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

namespace
{
bool bFlag[ 30 ];

bool Chk( const char *S )
{
int i;
int j;
char C;

	i = 0;
	C = S[ i ];
	while( C != '\0' )
	{
		j = C - 'a';
		if( bFlag[ j ] ) return false;

		bFlag[ j ] = true;

		i++;
		C = S[ i ];
	}

	return true;
}

}

int main()
{
char S[ 30 ];

	cin >> S;

	if( Chk( S ) )
		cout << "yes" << endl;
	else
		cout << "no" << endl;

	return 0;
}






Measured memory_bytes: 256
X = int(input())

kyu = 8
if X <= 599:
  kyu = 8
elif X <= 799:
  kyu = 7
elif X <= 999:
  kyu = 6
elif X <= 1199:
  kyu = 5
elif X <= 1399:
  kyu = 4
elif X <= 1599:
  kyu = 3
elif X <= 1799:
  kyu = 2
elif X <= 1999:
  kyu = 1
  
print(kyu)

Measured memory_bytes: 9180
N = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)    

table = [0] * (10**6+5)

pairwise_flg = True
for num in A:
    table[num] += 1

for i in range(2, 10**6+5):
    cnt = 0
    for j in range(i, 10**6+5, i):
        cnt += table[j]
    if cnt > 1:
        pairwise_flg = False    
if pairwise_flg:
    print("pairwise coprime")
    exit()

gcd_val = 0
for num in A:
    gcd_val = gcd(gcd_val, num)

if gcd_val == 1:
    print("setwise coprime")
    exit()
print("not coprime")    

Measured memory_bytes: 194460
/* 문제
2015.

*/


#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <ctime>

#define enp 	printf("**Entry Point**\n")
#define A		first
#define B		second
#define MP		make_pair

using namespace std;

typedef long long ll;

const int INF = 0x6fffffff;
const int MINF = 0x80000000;
const int mod = 1000000007;
const int cons = 100001;
const double pi = 3.141592653589793;



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

	cout << str.substr(0, 4) << " " << str.substr(4) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;


int powerint(int a, int b){
    int ret = 1;
    for (int i = 0; i < b; i++) {
        ret = ret * a; 
    }
    return ret;
}
int main()
{
    int n;
    int A[20];
    int q;
    int m[200];

    // input data starts
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", A + i);
    scanf("%d", &q);
    for (int i = 0; i < q; i++) scanf("%d", m + i);
    // input data ends

    // solve starts
    int N = powerint(2,n);
    int CanMake[N];
    
    for (int i = 0; i < N; i++) {
        bool i_bit[n];

        for (int j = 0; j < n; j++) {
            i_bit[j] = ( i / (powerint(2,j) ) % 2 == 1);
        }

        CanMake[i] = 0;

        for (int j = 0; j < n; j++) {
            CanMake[i] += A[j] * i_bit[j];
        } 
    }
    for (int i = 0; i < q; i++){
        bool ans = false;
        for (int j = 0; j < N; j++) {
            if (m[i] == CanMake[j]) ans = true;
        }
        if (ans == false) printf("no\n");
        else printf("yes\n");
    } 
    // solve ends
    return 0;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<ll> a(n);
    for(auto& it:a) cin>>it;
    ll XOR =0;
    for(int i=2;i<n;i++) XOR^=a[i];
    ll sum=a[0]+a[1];
    if((sum-XOR)&1) return cout<<-1,0;
    ll dif=(sum-XOR)/2;
    ll fi=0;
    vector<int> possible;
    for(int i=62;i>=0;i--){
        int x=XOR>>i&1,d=dif>>i&1;
        if(x==0&&d) fi^=(1LL<<i);
        else if(x&&d==0){
            possible.pb(i);
        }else if(x&&d){
            return cout<<-1,0;
        }
    }
    for(auto bit:possible){
        if((fi^(1LL<<bit))<=a[0]){
            fi^=(1LL<<bit);
        }
    }
    if(fi==0||fi>a[0]) cout<<-1;
    else cout<<a[0]-fi;
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(long long i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(long long i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
using PPI = pair<P, int>;
//ll const mod=998244353;
ll const mod = 1e9 + 7;
const ll MAX = 1000005;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vd = vector<double>;
using vs = vector<string>;
using vp = vector<P>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<double>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;
using vvb = vector<vector<bool>>;
template <typename T>
bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }


int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0, r = 0;
    int cl = 0, cr = 0;
    rep(i, n) {
        if (l == 0 && s[i] == ')')cl++;
        else if (s[i] == ')')l--;
        else if (s[i] == '(')l++;

        if (r == 0 && s[n - i - 1] == '(')cr++;
        else if (s[n-i-1] == '(')r--;
        else if (s[n-i-1] == ')')r++;
    }
    rep(i, cl)printf("(");
    cout << s;
    rep(i, cr)printf(")");
    cout << endl;
    return 0;
}

Measured memory_bytes: 3584
import bisect
a,b,q=map(int,input().split())
S=[];T=[]
for _ in range(a):
    s=int(input())
    S.append(s)
for _ in range(b):
    t=int(input())
    T.append(t)
S.append(10**12)
T.append(10**12)

for _ in range(q):
    x=int(input())
    idx_s=bisect.bisect_left(S,x)
    idx_t=bisect.bisect_left(T,x)
    se=S[idx_s]
    sw=S[idx_s-1]
    te=T[idx_t]
    tw=T[idx_t-1]

    ans=float("inf")
    for ss in [se,sw]:
        for tt in [te,tw]:
            ans=min(ans,abs(ss-x)+abs(tt-ss),abs(tt-x)+abs(tt-ss))
    print(ans)

Measured memory_bytes: 79064
open Printf
open Scanf

let solve s =
  let ls = ["AKIHABARA";
            "KIHABARA"; "AKIHBARA"; "AKIHABRA"; "AKIHABAR";
            "KIHBARA"; "KIHABRA"; "KIHABAR"; "AKIHBRA"; "AKIHBAR"; "AKIHABR";
            "KIHBRA"; "KIHBAR"; "KIHABR"; "AKIHBR";
            "KIHBR"] in
  if List.mem s ls then "YES" else "NO"

let () =
  scanf "%s " solve |> printf "%s\n"


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

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

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

    if(n>k) n = n - (n/k)*k;
    while (n>abs(n-k))
    {
      n = abs(n-k);
    }

    cout << n << endl;
    return 0;
    
}


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


int main(){
    long long int N; cin>>N;
    vector<long long int> L(N+1,0);
    L[0]=2;L[1]=1;
    for(int i=2;i<=N;i++){
        L[i]=L[i-1]+L[i-2];
    }
    cout<<L[N];
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main (String[] args)  {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i=0;i<n;i++) {
			int x = sc.nextInt();
			if (x%2==0 && x%3!=0 && x%5!=0) {
				System.out.println("DENIED");
				return;
			}
		}
		System.out.println("APPROVED");

	}


}


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

int main(){
    int n,q;
    long long ans=0;
    cin>>n;
    map<int,int> a;
    rep(i,n){
        cin>>q;
        a[q]++;
        ans+=q;
    }
    cin>>q;
    vector<pair<int,int>> b(q);
    rep(i,q)cin>>b[i].first>>b[i].second;

    rep(i,q){
        int diff=b[i].second-b[i].first;
        ans+=diff*a[b[i].first];
        a[b[i].second]+=a[b[i].first];
        a[b[i].first]=0;
        cout<<ans<<endl;
    }
    }


Measured memory_bytes: 8352
n = int(input())
a = list(map(int,input().split()))
ans = 0
while(any(a)):
    f = True
    x = a[0]
    for i,ai in enumerate(a):
        if ai:
            a[i] -= 1
        if ai < 1:
            if x != 0:
                break
        x = ai
    x = a[0]
    ans += 1
    #print(a)
print(ans)

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

int two(int x,int y)
{
  int r=0;
  while(x<y)
  {
    x*=2;
    r++;
  }
  return r;
}

double rui(int x)
{
  double r=1;
  for(int i=0;i<x;i++)
  {
    r/=2;
  }
  return r;
}

int main()
{
  int n,k;
  double ans=0;
  cin>>n>>k;
  for(int i=1;i<=n;i++)
  {
    ans+=rui(two(i,k))/n;
  }
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
}

Measured memory_bytes: 3792
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
   long long a;
   cin>>a;
   vector<long long> vec(a);
   rep(i,a){
       cin>>vec.at(i);
   }
   sort(vec.begin(),vec.end());
   long long then=vec.at(0);
   long long ans=0;
   long long cou=0;
   rep(i,a){
       if(then!=vec.at(i)){
           then=vec.at(i);
           if(cou%2!=0){
               ans++;
           }
           cou=1;
       }
       else{
           cou++;
       }
   }
   if(cou%2==1){
       ans++;
   }
   cout<<ans<<endl;
}





Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {
	
	int n;
	cin >> n;
	vector<int>p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	long long int t = 0;
	long long int a = 0;
	vector<int>x = p, y = p;
	for (int i = 0; i < n; i++) {
		//a += x[i];
		if (i % 2) {///*
			if (x[i] > 0) {
			//	a += abs(x[i]);
				t += abs(x[i]);
				x[i] = 0;
			}
			//*/
			a += x[i];
			if (a >= 0) {
				t += abs( a)+1;
				x[i] += -1*(a+1);
				a = -1;
			}

		}
		else {///*
			if (x[i] < 0) {
			//	a += abs(x[i]);
				t += abs(x[i]);
				x[i] = 0;
			}
			//*/
			a += x[i];
			if (a<=0) {
				t += 1 +abs( a);
				x[i] += abs(1 + a);
				a = 1;
			}
		}
		
	}
	
	x = p;
	long long int m = t;
	t = 0;
	a = 0;
	for (int i = 0; i < n; i++) {
		//cout << a;
	//	a += x[i];
		//cout << p[i];
		if (i % 2==0) {///*
			if (x[i] > 0) {
			//	a += abs(x[i]);
				t += abs(x[i]);
				x[i] = 0;
			}
		//	*/
			a += x[i];
			if (a >= 0) {
				t += abs(a )+ 1;
				x[i] += -1 * (a + 1);
				a = -1;
			}

		}
		else {
			///*
			if (x[i] < 0) {
				//a += abs(x[i]);
				t += abs(x[i]);
				x[i] = 0;
			}
		//	*/
			//cout << "#";
			a += x[i];
			if (a <= 0) {
				t += 1 +abs( a);
				x[i] += abs(1 + a);
				a = 1;
				//cout << "#";
			}

		}
		//cout << a << endl;

	}
	cout << min(m, t) << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i=0; i<(int)(n); i++)
#define REP2(i,x,n) for(int i=x; i<(int)(n); i++)
#define VSORT(v) sort(v.begin(), v.end());
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
int main(){
    string s;
    cin >> s;
    int c = 0;
    if (s[0] == '1'){
        c++;
    }
    if (s[1] == '1'){
        c++;
    }
    if (s[2] == '1'){
        c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int INFTY=(1<<21);
int n,M[MAX][MAX];

int prim(){
  int v,i,u,minv;
  int d[MAX],p[MAX],color[MAX];
  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
d[0]=0;
while(1){
  minv=INFTY;
  u=-1;
  for(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(v=0;v<n;v++){
  if(color[v]!=BLACK&&M[u][v]!=INFTY){
    if(d[v]>M[u][v]){
      d[v]=M[u][v];
      p[v]=u;
      color[v]=GRAY;
    }
  }
}
}
int sum=0;
for(i=0;i<n;i++){
  if(p[i]!=-1)sum+=M[i][p[i]];
}
return sum;
}
int main(){
  scanf("%d",&n);
int i,j;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      int e;
      scanf("%d",&e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  }
printf("%d\n",prim());
return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_ ; ++i)
#define drep(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_ ; --i)
typedef long long LL;
#define inf (0x3f3f3f3f)
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 3) + (x << 1) + (ch - 0x30);
		ch = getchar();
	}
	return flag * x;
}

#define Maxn 100009
int n, l;
int a[Maxn];
int ans[Maxn];
int main() {
#ifdef Qrsikno
	freopen("AGC002-C.in","r",stdin);
	freopen("AGC002-C.out","w",stdout);
#endif
	n = read(), l = read();
	rep(i, 1, n) a[i] = read();
	int beginner = 0;
	rep(i, 1, n - 1) 
		if(a[i] + a[i + 1] >= l) {
			beginner = i;
			break;
		}
	if(!beginner) {
		puts("Impossible");
		return 0;
	}
	puts("Possible");
	int cnt = 0;
	ans[++cnt] = beginner;
	drep(i, beginner - 1, 1) ans[++cnt] = i;
	rep(i, beginner + 1, n - 1) ans[++cnt] = i;
	drep(i, cnt, 1) printf("%d\n", ans[i]);
	return 0;
}



Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[100], res;
int main()
{
  	cin>>n;
  	for(int i=0;i<n;i++)	cin>>a[i];
  	sort(a,a+n);
  	for(int i=0;i<n-2;i++)
      	for(int j=i+1;j<n-1;j++)
          	for(int k=j+1;k<n;k++)
              	if (a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k])	res++;
  	cout<<res;
  	return 0;
}

Measured memory_bytes: 3608
NKQ = list(map(int, input().split()))
N = NKQ[0]
K = NKQ[1]
Q = NKQ[2]
corrCount = {}
for i in range(1,N+1):
    corrCount[i] = 0
As = []
for i in range(Q):
    As.append(int(input()))
minAnsCorr = Q - K + 1
for j in As:
    corrCount[j] += 1
for k in range(1,N+1):
    if corrCount[k] < minAnsCorr:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll MOD=1000000007;
  int h,w,k;
  cin>>h>>w>>k;
  if(w==1){
    cout<<1<<endl;
    return 0;
  }
  ll dp[h+1][w];
  for(int i=0;i<h+1;i++){
    for(int j=0;j<w;j++){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<(1<<(w-1));k++){
        bool ok=true;
        for(int l=0;l<w-2;l++){
          if(((k>>l)&1) and ((k>>(l+1))&1)){
            ok=false;
          }
        }
        if(ok){
          if(j>=1 and ((k>>(j-1))&1)){
            dp[i+1][j-1]+=dp[i][j];
            dp[i+1][j-1]%=MOD;
          }
          else if(j<=w-2 and ((k>>j)&1)){
            dp[i+1][j+1]+=dp[i][j];
            dp[i+1][j+1]%=MOD;
          }
          else{
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=MOD;
          }
        }
      }
    }
  }
  cout<<dp[h][k-1]<<endl;;
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  long long s, l;
  if (N%2==0) {
    s = A[N/2-1] + A[N/2];
    l = B[N/2-1] + B[N/2];
  } else {
    s = A[N/2];
    l = B[N/2];
  }

  cout << l - s + 1 << endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 6448
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args:Array[String]) = {
    var n = 0
    val b = new ArrayBuffer[String]
    while({n=readInt;n} != 0) {
      val l = readLine.split(" ").map(_.toInt)
      if(l.filter(_>=2).length==0) b+="NA"
      else b+=(l.filter(_>=1).length+1).toString
    }
    println(b.mkString("\n"))
  }
}

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

using db = double;
const db pi = 4 * atan(1);

void p(db x) {
	if(x >= 0)
		cout << int(x + 1e-9) << '\n';
	else
		cout << int(x - 1e-9) << '\n';
}

int main() {
	cout << fixed << setprecision(0);
	ios :: sync_with_stdio(false);
	db d, t; char c;
	db x = 0, y = 0, a = 90;
	while(cin >> d >> c >> t) {
		x += d * cos(a / 180 * pi);
		y += d * sin(a / 180 * pi);
		a -= t;
	}
	p(x); p(y);
	return 0;
}

Measured memory_bytes: 3532
#include<stdio.h>
#include<string.h>
int main(){
	char str[200];
	char str2[200];
	long a[500][500];
	scanf("%s",str);
	scanf("%s",str2);
	for (int i=0;i<strlen(str);i++)
		for (int j=0;j<strlen(str2)*2;j++){
			if (str[i]==str2[j%strlen(str2)])
				a[i][j]=a[i-1][j-1]+1;
			if (a[i][j]==strlen(str)){	
				printf("Yes");
				return 0;
			}
		}
	printf("No");
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  int count = 0;
  int ans = 0;
  for(int i=0;i<N-1;i++){
    if(vec.at(i)>=vec.at(i+1)){
      count++;
    }
    else{
      count = 0;
    }
    ans = max(ans,count);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication40
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] a = new int[5];
                int[] d=Console.ReadLine().Split().Select(int.Parse).ToArray();
                if(d[0]==0&&d[1]==0)
                    break;
                a[0]=d[0]+d[1];
                for (int b = 0; b < 4; b++)
                {
                    int[] e = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    a[b + 1] = e[0] + e[1];
                }
                if (a[0] > a[1] && a[0] > a[2] && a[0] > a[3] && a[0] > a[4])
                    Console.WriteLine("A {0}", a[0]);
                if (a[1] > a[0] && a[1] > a[2] && a[1] > a[3] && a[1] > a[4])
                    Console.WriteLine("B {0}", a[1]);
                if (a[2] > a[1] && a[2] > a[0] && a[2] > a[3] && a[2] > a[4])
                    Console.WriteLine("C {0}", a[2]);
                if (a[3] > a[1] && a[3] > a[2] && a[3] > a[0] && a[3] > a[4])
                    Console.WriteLine("D {0}", a[3]);
                if (a[4] > a[1] && a[4] > a[2] && a[4] > a[3] && a[4] > a[0])
                    Console.WriteLine("E {0}", a[4]);
            } 

        }
    }
}

Measured memory_bytes: 9452
N = gets.to_i
S = gets.chomp

black_counts = [0]
white_counts = [0]
S.chars.each_with_index do |c, i|
  black_counts[i + 1] = black_counts[i]
  white_counts[i + 1] = white_counts[i]
  if c == '#'
    black_counts[i + 1] += 1
  elsif c == '.'
    white_counts[i + 1] += 1
  end
end

ans = Float::INFINITY
0.upto(N) do |i|
  # 左の#を.に変え、右の.を#に変える数
  left_black = black_counts[i]
  right_white = white_counts[-1] - white_counts[i]
  ans = [left_black + right_white, ans].min
end

puts ans


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

using namespace std;

bool arr[85];

int main(){
	for(int i = 1; i <= 9; i++){
    	for(int j = i; j <= 9; j++){
        	arr[i*j] = true;
        }
    }
  	int n;
    cin>>n;
  
  	if(n <= 81 && arr[n]){
    	cout<<"Yes"<<'\n';
    }else{
      cout<<"No"<<'\n';
    }
  	return 0;
}

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

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		//ロボット（区間）の総数（配列の要素数）
		int N = int.Parse(Console.ReadLine());
		//腕の終点（X+L）と腕の長さ(L)とをジャグ配列に格納
		long[][]robots = new long[N][];

		//Xi, Liを読み込む
		for(int i=0; i<N; i++){
				//読み込み
				string[] line = Console.ReadLine().Split(' ');
				long Xi = long.Parse(line[0]);
				long Li = long.Parse(line[1]);

				//配列に格納
				robots[i] = new long[2];
				robots[i][0] = Xi+Li;
				robots[i][1] = Li;
		}

		//終点の順に、始点と終点とを配列に格納
		//始点を格納
		long[] starts = new long[N];
		//終点を格納
		long[] ends = new long[N];

		//ソートし、格納
		Array.Sort(robots, StructuralComparisons.StructuralComparer);
		for(int i=0; i<N; i++){
				long L = robots[i][1];
				long X = robots[i][0] - L;
				starts[i] = X-L;
				ends[i] = X+L;
		}

		/*
		左端のロボットを残す最適解が存在するので、貪欲法で解けるとのこと
		*/
		//現在の終点よりも右にあれば、加える
		long curEnd = ends[0];
		int cnt = 1;
		for(int i=0; i<N; i++){
				//i番目のロボの始点が被らない場所にある場合
				if(starts[i] >= curEnd){
						//カウント
						cnt ++;
						//現在の終点を更新
						curEnd = ends[i];
				}
		}

		//出力
		Console.WriteLine(cnt);
	}
}



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

long long gcd(long long a, long long b) {
    return a ? gcd(b % a, a) : b;
}

int main() {
    long long a, b;
    cin >> a >> b;
    long long n = gcd(a, b);

    int cnt = 1; //１はカウントしておく
    for (int i = 2; (long long)i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0) n /= i;
            cnt++; //素数
        }
    }
    if (n > 1) cnt++; // nの場合

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  cout << s.front() << s.size()-2 << s.back() << endl;
  return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define N (1000000000+7)
bool digit[10];
int a[5] = { -1 };

int main(void) {
	int n, k, x;
	cin >> n >> k;
	for (int i = 0;i < k;i++) {
		cin >> x;
		digit[x] = true;
	}
	bool flag = true;
	for (int i = n;;i++) {
		int num = i, count = 0;
		bool flag = true;
		while (num >= 10) {
			a[count] = num % 10;
			num = (num - num % 10) / 10;
			count++;
		}
		a[count] = num;
		for (int j = 0;j <= count;j++) {
			if (digit[a[j]]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;
  if (left > right) {
    cout << "Left";
  } else if (left == right) {
    cout << "Balanced";
  } else {
    cout << "Right";
  }
}

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

typedef struct E{
    int to, cost;
}edge;
const int MAX_V = 200100;
const int INF = 1e9;
vector<vector<edge>> E(MAX_V);
int d[MAX_V];
void dijkstra(int s){
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> que;
    fill_n(d, MAX_V, INF);
    d[s] = 0;
    que.push(pair<int,int>(0, s));
    while(!que.empty()){
        pair<int,int> p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(int i = 0; i < E[v].size(); i++){
            edge t = E[v][i];
            if(d[t.to] > d[v] + t.cost){
                d[t.to] = d[v] + t.cost;
                que.push(pair<int,int>(d[t.to], t.to));
            }
        }
    }
}

int main(){
    int a, b, r;
    cin >> a >> b >> r;
    for(int i = 0; i < b; i++){    
        edge e;
        int s;
        cin >> s >> e.to >> e.cost;
        E[s].push_back(e);
    }
    dijkstra(r);
    for(int i = 0; i < a; i++){
        if(d[i] == INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


Measured memory_bytes: 15808
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = print n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStrLn n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  [n, m] <- readInts
  lr     <- map toPair <$> readIntLists m
  print $ solve lr

solve lr = length [l .. r]
 where
  l = maximum $ map fst lr
  r = minimum $ map snd lr


Measured memory_bytes: 40316
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
typedef complex<double> P;
typedef long long ll;

int h,w,c;
int field[10][10];
int maxCnt;
int ct=0;
bool passed[10][10];

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


void rePaint(int x,int y,int oc,int nc){
  if(field[y][x]==oc&&!passed[y][x]){
    passed[y][x]=true;
    field[y][x]=nc;
    for(int i = 0; i < 4; i++){
      int ny=y+dy[i];
      int nx=x+dx[i];
      if(ny>=0&&nx>=0&&ny<h&&nx<w
	 &&!passed[ny][nx]&&field[ny][nx]==oc)
	rePaint(nx,ny,oc,nc);
    }
  }
}


void Cnt(int x,int y,int c){
  if(field[y][x]==c&&!passed[y][x]){
    passed[y][x]=true;
    ct++;
    for(int i = 0; i < 4; i++){
      int ny=y+dy[i];
      int nx=x+dx[i];
      if(ny>=0&&nx>=0&&ny<h&&nx<w&&!passed[ny][nx]&&field[ny][nx]==c){
	Cnt(nx,ny,c);
      }
    }
  }
}

void change(int n){
  if(n==0){
    // ¶ãÌplÆ¯¶FÉÈéplÌ
    int t=field[0][0];
    if(t!=c)return;
    ct=0;
    memset(passed,0,sizeof(passed));
    Cnt(0,0,t);
    maxCnt=max(ct,maxCnt);
    return;
  }
  for(int i = 1; i <= 6; i++){
    if(field[0][0]==i)continue;
    int tmp[10][10];
    for(int j = 0; j < 10; j++)
      for(int k = 0; k < 10; k++)
	tmp[j][k]=field[j][k];
    memset(passed,0,sizeof(passed));
    // ¶ãÆ¯¶FðàÂàÌðiÌFÅhèÖ¦
    rePaint(0,0,field[0][0],i);
    // ÄA
    change(n-1);
    for(int j = 0; j < 10; j++)
      for(int k = 0; k < 10; k++)
	field[j][k]=tmp[j][k];
  }
}

int main(){
  while(cin>>h>>w>>c&&!(h==0&&c==0&&w==0)){
    maxCnt=0;
    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
	cin>>field[i][j];
    change(5);
    cout<<maxCnt<<endl;
  }
  return 0;
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0) break;
			
			int[][] input = new int[n+1][n+1];
			
			//????°????????????????
			for(int i = 0; i < n ;i++){
				input[i][n] = 0;
			}
			
			int sum = 0;
			//??§????????°??\?????¨?¨???????????????????
			for(int i = 0; i < n; i++){
				String[] tmpArray = br.readLine().split(" ");
				for(int j = 0; j < n; j++){
					input[i][j] = Integer.parseInt(tmpArray[j]);
					input[i][n] += input[i][j];
					input[n][j] += input[i][j];
					sum += input[i][j];
				}
			}
			input[n][n] = sum;
			
			//??????
			for(int i = 0; i <= n; i++){
				for(int j = 0; j <= n; j++){
					System.out.printf("%5d", input[i][j]);
				}
				System.out.println();
			}
		}
	}

}

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

int main()
{
int n,sum=0;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n,greater<int>());
for(int i=0;i<n;i++)
{
if(i%2==0)
sum+=a[i];
else
sum-=a[i];
}
printf("%d",sum);
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;

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

int main(){
  int H,W;cin>>H>>W;
  char A[H][W];
  queue<ii> que;
  int dist[H][W];
  for (int i=0;i<H;++i){
    for (int j=0;j<W;++j){
      dist[i][j]=2001;
    }
  }
  
  for (int i=0;i<H;++i){
    for (int j=0;j<W;++j){
      cin>>A[i][j];
      if(A[i][j]=='#') {que.push({i,j});dist[i][j]=0;}
    }
  }

  while(!que.empty()){
    ii p=que.front();que.pop();
    int y=p.first, x=p.second;
    for (int k=0;k<4;++k){
      int ny=y+dy[k], nx=x+dx[k];
      if(0<=ny&&ny<H&&0<=nx&&nx<W){
        dist[ny][nx]=min(dist[y][x]+1, dist[ny][nx]);
        if(A[ny][nx]!='#'){
          que.push({ny,nx});A[ny][nx]='#';
        }
      }
    }
  }

  int ans=0;
  for (int i=0;i<H;++i){
    for (int j=0;j<W;++j){
      ans=max(ans, dist[i][j]);
    }
  }

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

Measured memory_bytes: 13328