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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll R; cin>>R;
  if(R<1200) cout<<"ABC";
  else if(R<2800) cout<<"ARC";
  else cout<<"AGC";
		
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define SIZE 10101010
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
int main()
{
	int num, gen;
	scanf("%d%d", &num, &gen);
	invinit();
	ll r = 0;
	int t = num - gen;
	for (int i = 1; i <= gen; i++)
	{
		ll s = 0;
		for (int j = 0; j < i; j++)
		{
			int rem = i - j;
			ll z = kai[t] * kai[rem] % mod*com(t + rem - 1, t) % mod*com(i, j) % mod;
			if (i < gen)
			{
				ll q = kai[num - j - 1] * invkai[num - gen + i - j] % mod;
				z = (z*q) % mod;
			}
			if (j % 2 == 0)s = (s + z) % mod;
			else s = (s + mod - z) % mod;
		}
		//printf("%d %lld\n", i, s);
		r = (r + s) % mod;
	}
	printf("%lld\n", r);
}

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

using namespace std;
#define MX 1e5+1
#define pb push_back
#define prr pair<int,int> 



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    


    string s1;
    cin>>s1;
    if((s1[2]==s1[3] )&& (s1[4]==s1[5])){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }

}



















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

using namespace std;

const int maxn = 5010;
const int mod = 1e9+7;

int n, A, B;
int f[maxn][2], g[maxn][2], a[maxn][maxn], h[maxn];

int calh(int l, int a, int b) {
	if (!a && !b) return h[l];
	if (l == 1) return 1;
	return h[l - a - b];
}

int main() {
	scanf("%d%d%d", &n, &A, &B);
	if (A > B) swap(A, B);
	f[0][0] = g[0][0] = 1;
	a[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			if (!j || j >= A) a[i][0] = (a[i][0] + a[i-1][j]) % mod;
			a[i][j+1] = (a[i][j+1] + a[i-1][j]) % mod;
		}
	}
	for (int i = 0; i <= n; i++) {
		h[i] = (h[i] + a[i][0]) % mod;
		for (int j = A; j <= i; j++) {
			h[i] = (h[i] + a[i][j]) % mod;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int k = 1; k < A; k++) {
			f[i][0] = (f[i][0] + g[i-k][0]) % mod;
			f[i][1] = (f[i][1] + g[i-k][1]) % mod;
		}
		for (int k = 1; k < B && k <= i; k++) {
			g[i][0] = (g[i][0] + 1LL * f[i-k][0] * calh(k, k < i, i != n) % mod) % mod;
		}
		for (int k = 1; k <= i; k++) {
			g[i][1] = (g[i][1] + 1LL * f[i-k][1] * calh(k, k < i, i != n) % mod) % mod;
		}
		for (int k = B; k <= i; k++) {
			g[i][1] = (g[i][1] + 1LL * f[i-k][0] * calh(k, k < i, i != n) % mod) % mod;
		}
	}
	int ans = (f[n][1] + g[n][1]) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 70772
let pow_mod x y m =
  let rec doit x y =
    if y = 0 then 1
    else
      let z = doit (x*x mod m) (y / 2) in
      if y mod 2 = 1 then x*z mod m else z in
  doit x y

let prime_p n =
  if n == 2 then true
  else if n < 2 || n mod 2 = 0 then false
  else if pow_mod 2 (n - 1) n = 1 then true
  else false

let () =
  let n = read_int () in
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (acc + (if prime_p (read_int ()) then 1 else 0)) in
  (doit 0 0) |> Printf.printf "%d\n"

Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  int N, H, W;
  cin >> N >> H >> W;

  int ans = 0;
  rep(i, 0, N) {
    int a, b;
    cin >> a >> b;
    if (H<=a && W<=b) ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
k,n=map(int,input().split())
a=list(map(int,input().split()))
ans=0

if a[n-1]-a[0] <= k-a[n-1]+a[0]:
    print(a[n-1]-a[0])
else:
    for i in range(n):
        ans=max(ans,a[i]-a[i-1])
    ans=max(ans,k-a[n-1]+a[0])
    print(k-ans)


Measured memory_bytes: 26444
#include <iostream>
#include <cmath>

using namespace std;

const int INF=1000000001;

int dp[101][100003];
int weight[102],value[102];

int main () {
	int n,W;
	cin>>n>>W;
	for(int i=1;i<=100001;i++){
		dp[0][i]=INF;
	}
	for(int i=1;i<=n;i++){
		cin>>weight[i]>>value[i];
		for(int j=1;j<=100001;j++){
			dp[i][j]=INF;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=100000;j>0;j--){
			if(j<value[i]){
				dp[i][j]=min(dp[i-1][j],dp[i][j+1]);
				continue;
			}
			dp[i][j]=min(min(dp[i][j+1],dp[i-1][j]),dp[i-1][j-value[i]]+weight[i]);
		}
	}
	int rj;
	for(int i=100000;i>0;i--){
		if(dp[n][i]<=W){
			rj=i;
			break;
		}
	}
	cout<<rj;


return 0;
}



Measured memory_bytes: 39680
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>


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


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

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}

auto mdist(pair<int, int> a, pair<int, int> b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}
int main() {

	int N, M;
	vector<pair<int, int>> students, chkpoints;
	cin >> N >> M;
	students.resize(N);
	chkpoints.resize(M);
	vector<pair<int, int>> ans;
	pair<int, int> emp = make_pair(1000000000, 0);
	ans.resize(N, emp);//dist, chknum
	rep(i, 0, N) {
		int tempa, tempb;
		cin >> tempa >> tempb;
		students[i] = pair<int, int>(tempa, tempb);
	}
	rep(i, 0, M) {
		int tempc, tempd;
		cin >> tempc >> tempd;
		chkpoints[i] = pair<int, int>(tempc, tempd);
	}

	rep(i, 0, N) {
		rep(j, 0, M) {
			int tdist = mdist(students[i], chkpoints[j]);
			if (tdist < ans[i].first) {
				ans[i].first = tdist;
				ans[i].second = j+1;
			}
		}
	}

	rep(i, 0, N) {
		cout << ans[i].second << endl;
	}
	return 0;
}


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

using namespace std;


int main(){
    int N;
    cin >> N;
    string S[N], copyS[N];
    int P[N], copyP[N];
    int i;
    for(i = 0; i < N; i++){
        cin >> S[i] >> P[i];
    }
    for(i = 0; i < N; i++){
        copyP[i] = P[i];
        copyS[i] = S[i];
    }
    sort(copyS, copyS+N);
    sort(copyP, copyP+N, greater<>());

    int Ans[N];
    int number = 0;

    for(i = 0; i < N; i++){
        if(i == 0 or (i >= 1 and copyS[i] != copyS[i-1])){
            for(int j = 0; j < N; j++){
                for(int k = 0; k < N; k++){
                    if(S[k] == copyS[i] and P[k] == copyP[j]){
                        Ans[number] = k+1;
                        number++;
                        continue;
                    }
                }
            }
        }
    }

    for(i = 0; i < N; i++)
        cout << Ans[i] << endl;
}

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

    using namespace std;

    int main()
    {
      string s,t;
      long ans=0;
      cin>>s>>t;
      for(long i=0;i<s.length()-t.length()+1;i++){
      long counter=0;
      for(long j=i;j<i+t.length();j++){
      if(s[j]==t[j-i]){
      counter++;
      }
      }
      ans=max(ans,counter);
      }
      ans=t.length()-ans;
      cout<<ans<<endl;
      return 0;
    }


Measured memory_bytes: 3596
N, K = map(int, input().split())
nums = list(map(int, input().split()))
dp = [0] * (N+1)
dp[0] = 0
for i in range(1, N):
  min_c = 10**10
  for j in range(1, min(i, K)+1):
    min_c = min(min_c, dp[i-j]+abs(nums[i-j]-nums[i]))
  dp[i] = min_c
print(dp[N-1])


Measured memory_bytes: 52448
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

#define N 1000000007LL;

int H,W,K;

ll amida10(int onbit){
  ll ans=0;
  for(int i=0 ; i < (1 << (W-1)) ; i++){
    if(i & (1<<onbit)){
      bool isok=true;
      for(int j=0;j<=W-3;j++){
        if((i & (1<<j)) && (i & (1<<(j+1))) ) isok=false;
      }
      if(isok) {
        ans++;
      }
    }
  }
  return ans;
}

ll amida01(int offbit){
  ll ans=0;
  for(int i=0 ; i < (1 << (W-1)) ; i++){
    if(!(i & (1<<offbit))){
      bool isok=true;
      for(int j=0;j<=W-3;j++){
        if((i & (1<<j)) && (i & (1<<(j+1))) ) isok=false;
      }
      if(isok) ans++;
    }
  }
  return ans;
}

ll amida02(int offbit){
  ll ans=0;
  for(int i=0 ; i < (1 << (W-1)) ; i++){
    if(!(i & (1<<offbit)) && !(i & (1<<(offbit+1)))){
      bool isok=true;
      for(int j=0;j<=W-3;j++){
        if((i & (1<<j)) && (i & (1<<(j+1))) ) isok=false;
      }
      if(isok) {
        ans++;
      }
    }
  }
  return ans;
}

int main(){
  cin >> H >> W >> K;
  ll dp[H+1][W+1];

  if(W==1){
    cout << 1LL << endl;
    return 0;
  }

  dp[1][1]=amida01(0);
  dp[1][2]=amida10(0);
  for(int j=3;j<=W;j++) dp[1][j]=0LL;

  for(int i=2;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(j==1){
        dp[i][j]=(dp[i-1][j]*amida01(0) + dp[i-1][j+1]*amida10(0))%N;
      }else if(j==W){
        dp[i][j]=(dp[i-1][j-1]*amida10(j-2) + dp[i-1][j]*amida01(j-2))%N;
      }else{
        dp[i][j]=(dp[i-1][j-1]*amida10(j-2) + dp[i-1][j]*amida02(j-2)+dp[i-1][j+1]*amida10(j-1))%N;
      }
    }
  }

  cout << dp[H][K] << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	int x = in(), y = in() / 2;
	cout << x + y << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[n];
		for(int i=0;i<n;i++){
			x[i]=sc.nextInt();
		}
		Arrays.sort(x);
		int sum = 0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				for(int k=j+1;k<n;k++){
					if(x[i]<x[j]+x[k]&&x[j]<x[i]+x[k]&&x[k]<x[j]+x[i]){
						sum++;
					}else{
						break;
					}
				}
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 28224
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

const string YES = "Yes";
const string NO = "No";

void solve(ll N, ll A, ll B, string S) {
  for(auto i = 0; i != N; ++i) {
    bool pred = false;
    if (A+B > 0) {
      switch(S[i]) {
        case 'a':
          if (A+B) {
            --A;
          pred = true;
          }
          break;
        case 'b':
          if (B) {
            --B;
            pred = true;
          }
          break;
      }
    }
    cout << (pred ? YES : NO) << endl;
  }
}

int main() {
  ll N;
  cin >> N;
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  string S;
  cin >> S;
  solve(N, A, B, S);
  return 0;
}


Measured memory_bytes: 896
import java.util.*

fun main(){
    val n = rInt()
    val a = readLine()!!.split(' ').map { it.toLong() } as ArrayList<Long>
//    val a = arrayListOf<Long>()
//    for (i in 1..n) a.add(rLong())

    a.sortDescending()

    var ans = a[0]

    for (i in 2 until n){
        ans += a[i/2]
    }

    println(ans)


}



// input
private val inputQue = LinkedList<String>()
private fun myReadLine(){
    inputQue.addAll(readLine()!!.split(' '))
}
private fun read() : String {
    if(inputQue.isEmpty()) myReadLine()
    return inputQue.removeAt(0)
}
private fun rInt() = read().toInt()
private fun rLong() = read().toLong()
private fun rDouble() = read().toDouble()


Measured memory_bytes: 63928
def main():
    n = int(input())
    inlis = list(map(int, input().split()))

    total = sum(inlis)
    ans = 10 ** 20

    for i in range(n-1):
        if i == 0:
            x = inlis[i]
        else:
            x += inlis[i]
        y = total - x
        tmp = abs(x-y)
        if tmp < ans:
            ans = tmp

    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 100436
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int ans = 0;
    for(int i = 0; i < n; i++){
      int nownum = sc.nextInt();
      if(i % 2 == 0 && nownum % 2 == 1){
        ans++;
      }
    }

    System.out.println(ans);

  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

int main() {
    string S; cin >> S;
    int N = S.length();
    string ans = "Yes";
    int flag = 0;
    int benri = (N-1)/2;
    for(int i = 0; i < benri; i++){
        char tmp1 = S[i];
        char tmp2 = S[N-1-i];
        if(tmp1 != tmp2){
            ans = "No";
            flag = 1;
            break;
        }
    }

    if(flag == 0){
        vector<char>data1(benri);
        vector<char>data2(benri);
        for(int i = 0; i < benri; i++){
            data1[i] = S[i];
            data2[i] = S[i+1+benri];
        }
        for(int i = 0; i < benri; i++){
            char tmp1 = data1[i];
            char tmp2 = data1[benri-1-i];
            char tmp3 = data2[i];
            char tmp4 = data2[benri-1-i];
            if(tmp1 != tmp2){
                ans = "No";
                flag = 1;
                break;
            }
            if(tmp3 != tmp4){
                ans = "No";
                flag = 1;
                break;
            }
        }
    }
    cout << ans << endl;
}

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

int main(void){
    
   int A,B,C,X,Y;
   cin >> A >> B >> C >> X >> Y;
 
   if(A+B <= 2*C){
       cout << A*X + B*Y <<endl;
   }
   else{
       int maxv = max(X,Y);
       int l,r;
       l = 2 * C * maxv;
       if(maxv == X) r = 2 * C * Y + (X - Y) * A;
       else r = 2 * C * X + (Y - X) * B;
       cout << min(l,r) << endl;
   }
}

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> P(100100);
    rep(i, n){
        int a, b; cin >> a >> b;
        if(m-a>=0)P[m-a].push_back(b);//m-a日まで受注可能
    }
    priority_queue<int> que;
    ll res = 0;
    for(int i=m; i>=0; i--){
        for(auto p: P[i]){
            que.push(p);
        }
        if(!que.empty()){
            res += que.top();
            que.pop();
        }
    } 
    cout << res << ln;
}
    


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

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

    vector<int> T(2019);
    long long ans = 0;
    int t = 0;

    for (char s: S)
    {
        vector<int> P(2019);
        P.swap(T);

        for (int i=0; i<2019; i++)
            T[(i*10+s-'0')%2019] = P[i];
        T[s-'0']++;
        ans += T[0];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3372
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	int n;
	cin>>n;
	vvi in(n,vi(2));
	rep(i,n)rep(j,2)cin>>in[i][j^1];
	sort(all(in));
	bool h=true;
	int s=0;
	rep(i,n){
		s+=in[i][1];
		if(s>in[i][0])h=false;
	}

	if(h)yes;
	else no;
}


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

#define int long long

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

    int x1, x2, x3;
    int y1, y2, y3;

    x1 = 0;
    y1 = 0;

    x2 = 1000000000;
    x3 = 1;

    int l = -1, r = 1000000000;

    while(r-l > 1){
        int mid = (r+l)/2;
        if(mid*x2 >= s){
            r = mid;
        }else{
            l = mid;
        }
    }

    y3 = r;
    y2 = y3*x2-s;

    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}

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

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> A(H,vector<char> (W));
    vector<vector<int>> dist(H, vector<int>(W, -1));
    int ans = 0;
    queue<int> que;
    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);
                que.push(j);
                dist[i][j] = 0;
            }
        }
    }

    while(!que.empty())
    {
        int h = que.front();
        que.pop();
        int w = que.front();
        que.pop();
        if(dist[h][w] != -1)
        {
            for (int dir = 0; dir < 4;dir++)
            {
                int nh = h + dy[dir];
                int nw = w + dx[dir];
                if(nh < H && nw < W && nh >= 0 && nw >= 0){
                    if(dist[nh][nw] == -1 && A[nh][nw] == '.'){
                        que.push(nh);
                        que.push(nw);
                        dist[nh][nw] = dist[h][w] + 1;
                        A[nh][nw] = '#';
                    }
                }
            }
        }
    }

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

Measured memory_bytes: 13456
from collections import Counter

# input
N = int(input())
S = Counter([input() for i in range(N)])
M = int(input())
T = Counter([input() for j in range(M)])

# check
max_cnt = 0
for s in S.keys():
    cnt = S[s]
    if s in T.keys():
        cnt -= T[s]

    if max_cnt < cnt:
        max_cnt = cnt

print(max_cnt)


Measured memory_bytes: 9332
#include<iostream>
using namespace std;
int main(){
    string s,p,p1;
    int l,i,len,j;
    getline(cin,s);
    l=s.size();
    p="";
    for(i=0;i<l;i++){
        len=p.size();
        if(s[i]=='0')
            p=p+'0';
        else if(s[i]=='1')
            p=p+'1';
        else{
            p1="";
            for(j=0;j<len-1;j++)
                p1=p1+p[j];
            p=p1;
        }
    }
    cout<<p;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>

using namespace std;

int main() {
  int a, b;
  cin>>a>>b;
  int mx = max(a+b, max(a-b, a*b));
  cout<<mx<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long a,v,b,w,t,d;
    cin>>a>>v>>b>>w>>t;
    if(a>b)
        d=a-b;
    else
        d=b-a;
    if(w>=v)
        cout<<"NO"<<endl;
    else if(t*(v-w)<d)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 3636
/**
 *    author:  math2do
 *    created: 12.04.2020 23:20:00
**/

#include <bits/stdc++.h>

using namespace std;

template <typename T>
class graph {
 public:
  struct edge {
    int from;
    int to;
    T cost;
  };
 
  vector<edge> edges;
  vector<vector<int>> g;
  int n;
 
  graph(int _n) : n(_n) {
    g.resize(n);
  }
 
  virtual int add(int from, int to, T cost) = 0;
};

template <typename T>
class forest : public graph<T> {
 public:
  using graph<T>::edges;
  using graph<T>::g;
  using graph<T>::n;
 
  forest(int _n) : graph<T>(_n) {
  }
 
  int add(int from, int to, T cost = 1) {
    assert(0 <= from && from < n && 0 <= to && to < n);
    int id = (int) edges.size();
    assert(id < n - 1);
    g[from].push_back(id);
    g[to].push_back(id);
    edges.push_back({from, to, cost});
    return id;
  }
};

template <typename T>
T diameter(const forest <T> &g) {
  vector <bool> seen(g.n, false);
  vector <T> depth(g.n, -1);

  function <void(int)> dfs = [&](int u) {
    seen[u] = true;
    for (int id : g.g[u]) {
      auto &e = g.edges[id];
      int v = e.from ^ e.to ^ u;
      if (!seen[v]) {
        depth[v] = depth[u] + e.cost;
        dfs(v);
      }
    }
  };

  depth[0] = 0;
  dfs(0);

  T max_depth = numeric_limits<T>::min();
  int from = 0;
  for (int u = 0; u < g.n; u++) {
    if (depth[u] > max_depth) {
      max_depth = depth[u];
      from = u;
    }
  }
  
  //reset
  seen = vector <bool> (g.n, false);
  depth = vector <int> (g.n, -1);
  depth[from] = 0;
  dfs(from);

  T ans = numeric_limits<T>::min();
  for (int u = 0; u < g.n; u++) {
    ans = max(ans, depth[u]);
  }
  return ans;
  // returns length of diameter
} 

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  forest <int> g(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    g.add(x, y, w);
  } 
  int ans = diameter(g);
  cout << ans << endl; 
  return 0;
}



Measured memory_bytes: 16520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=100010,M=4000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const double eps=1e-9,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(1ll*a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

inline int gcd(int x,int y) { return y?gcd(y,x%y):x; }
int head[N],ver[M],nxt[M],du[N];
int n,m,tot=1;
int a[N];
inline void add(int x,int y)
{
	ver[++tot]=y,nxt[tot]=head[x],head[x]=tot,du[y]++;
}

bool G[2010][2010];
bool visit[N];
inline void dfs(int x)
{
	visit[x]=true;
	for(int y=1;y<=n;y++)
	{
		if(visit[y]||!G[x][y]) continue;
		add(x,y);
		dfs(y);
	}
}
priority_queue<int> q;

#ifdef FILE
const int READ_SIZE=1<<20;
char buf[READ_SIZE],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,READ_SIZE,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(gcd(a[i],a[j])>1)
				G[i][j]=G[j][i]=true;
	for(int i=1;i<=n;i++)
		if(!visit[i]) dfs(i);
	
	while(q.size()) q.pop();
	for(int i=1;i<=n;i++)
		if(!du[i]) q.push(i);
	
	while(q.size())
	{
		int x=q.top();q.pop();
		printf("%d ",a[x]);
		for(int i=head[x];i;i=nxt[i])
		{
			int y=ver[i];
			du[y]--;
			if(!du[y]) q.push(y);
		}
	}
	putchar('\n');
	return 0;
}

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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int h, w;
    char c[51][51];
    int dist[51][51];
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
    {
        string s;
        cin >> s;
        for (int j = 1; j <= w; j++)
        {
            c[i][j] = s[j - 1];
        }
    }
    for (int i = 0; i <= h; i++)
        for (int j = 0; j <= w; j++)
            dist[i][j] = INF;

    int cnt_fb = 0;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (c[i][j] == '#')
                cnt_fb++;
        }
    }

    queue<pair<int, int>> q;
    q.push(make_pair(1, 1));
    dist[1][1] = 0;
    while (!q.empty())
    {
        int tmpx = q.front().second;
        int tmpy = q.front().first;
        // cout << "==" << tmpy << "," << tmpx << endl;
        q.pop();
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                // if (abs(i) != abs(j) && tmpx + i >= 1 && tmpx + i <= w && tmpy + j >= 1 && tmpy + j <= h)
                // cout << "b" << tmpy + j << "," << tmpx + i << ":" << c[tmpy + j][tmpx + i] << endl;
                if (abs(i) != abs(j) && tmpx + i >= 1 && tmpx + i <= w && tmpy + j >= 1 && tmpy + j <= h && dist[tmpy + j][tmpx + i] == INF && c[tmpy + j][tmpx + i] == '.')
                {
                    // cout << "a" << tmpy + j << ", " << tmpx + i << endl;
                    q.push(make_pair(tmpy + j, tmpx + i));
                    dist[tmpy + j][tmpx + i] = dist[tmpy][tmpx] + 1;
                    if (tmpy + j == h && tmpx + i == w)
                        goto L;
                }
            }
        }
    }
L:
{
}
    if (dist[h][w] != INF)
        cout << h * w - dist[h][w] - cnt_fb - 1 << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 256
N=gets.to_i
n = N

if n == 0
    puts '0'
    exit
end

len = 32
sign = 1
s = '10'*(len/2) + '1'
ret = ''
len.downto(0) do |i|
    if sign == 1
        upper = s.to_i(2)
        lower = upper - 2**i + 1
    else
        lower = s.to_i(2) * sign
        upper = lower + 2**i - 1
    end

    s = s[0..-2]

    # p [lower,n,upper]

    if lower <= n && n <= upper
        ret += '1'
        n -= 2**i * sign
    else
        ret += '0'
    end
    sign *= -1
end
puts ret[ret.index('1')..-1]

Measured memory_bytes: 14276
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        System.out.println(mon(n));
        sc.close();
    }
    public static long mon(long a){
        if(a == 1) return 1;
        return 2 * mon(a / 2) + 1;
    }
}

Measured memory_bytes: 35756
#include <iostream>
using namespace std;
int main()
{
	int a,b;
  	cin >> a >> b;
  	if (a * b % 2 == 0)
    {
    	cout << "Even" << endl;
      return (0);
    }
  	else 
    {
    	cout << "Odd" << endl;
      return (0); 
       
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    map<int,int> a,b;
    rep(i,n){
        int v; cin>>v;
        if(i%2==0) a[v]++;
        else b[v]++;
    }
    vector<pair<int,int>> aq,bq;
    for(auto i:a) aq.push_back({i.second,i.first});
    for(auto i:b) bq.push_back({i.second,i.first});
    sort(all(aq)),sort(all(bq));
    reverse(all(aq)),reverse(all(bq));
    if(aq.size()==1&&bq.size()==1){
        pair<int,int> x=aq.front(),y=bq.front();
        if(x.second==y.second) cout<<n/2<<endl;
        else cout<<0<<endl;
        return 0;
    }else if(aq.size()==1){
        pair<int,int> x=aq.front();
        for(auto i:bq){
            pair<int,int> y=i;
            if(x.second!=y.second){
                cout<<n-x.first-y.first<<endl;
                return 0;
            }
        }
    }else if(bq.size()==1){
        pair<int,int> y=bq.front();
        for(auto i:aq){
            pair<int,int> x=i;
            if(x.second!=y.second){
                cout<<n-x.first-y.first<<endl;
                return 0;
            }
        }
    }else{
        pair<int,int> ax[2],bx[2];
        ax[0]=aq[0],ax[1]=aq[1];
        bx[0]=bq[0],bx[1]=bq[1];
        if(ax[0].second!=bx[0].second) cout<<n-ax[0].first-bx[0].first<<endl;
        else cout<<min(n-ax[1].first-bx[0].first,n-ax[0].first-bx[1].first)<<endl;
    }
    // cout<<ax[0].second<<" "<<bx[0].second<<endl;
    // cout<<ax[1].first<<" "<<bx[1].first<<endl;
    return 0;
}


Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,W;cin>>n>>W;
  ll w[n],v[n];
  vector<ll>vv[4];
  for(ll i=0;i<n;i++){
    cin>>w[i]>>v[i];
    vv[w[i]-w[0]].push_back(v[i]);
  }
  for(ll i=0;i<4;i++){
    sort(vv[i].begin(),vv[i].end(),greater<ll>());
  }
  vector<ll>sum[4];
  for(ll i=0;i<4;i++)sum[i].push_back(0);
  for(ll i=0;i<4;i++){
    for(ll j=0;j<vv[i].size();j++){
      sum[i].push_back(sum[i][j]+vv[i][j]);
      //cout<<sum[i][j+1]<<endl;
    }
  }
  ll ans=0;
  for(ll i=0;i<vv[0].size()+1;i++){
    for(ll j=0;j<vv[1].size()+1;j++){
      for(ll k=0;k<vv[2].size()+1;k++){
        for(ll l=0;l<vv[3].size()+1;l++){
          if(i*w[0]+j*(w[0]+1)+k*(w[0]+2)+l*(w[0]+3)<=W){
            ans=max(ans,sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l]);
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}
                           

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int maxn=1e5+10;
using namespace std;

ll quickqow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans*=a;
		a*=a;b>>=1;
	}
	return ans;
}
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{ 
	int n;
	vector<int> v;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		v.push_back(x);
	}
	int ans=1;
	int minx=v[0];
	for(int i=1;i<n;i++)
	{
		if(v[i]<minx)
		{
			ans++;minx=v[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int k,a,b;
  cin >> k >> a >> b;
  int i;
  for(i=a;i<=b;i++)
  {
    if(i%k==0)
    {
     	cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  
  return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int[] A = new int[M];
		
		for(int i = 0; i < M; i++) {
			A[i] = sc.nextInt();
		}
		
		int[][] B = new int[N][M];
		int[][] point = new int[N][M];
		
		for(int i = 0; i < M; i++) {
			for(int j = 0; j < N; j++) {
				B[j][i] = sc.nextInt();
				point[j][i] = 0;
			}
		}
		
		int addPoint = 0;
		
		for(int i = 0; i < M; i++) {
			for(int j = 0; j < N; j++) {
				if(A[i] == B[j][i]) {
					point[j][i]++;
				} else {
					addPoint++;
				}
			}
			
			point[A[i] - 1][i]+=addPoint;
			
			addPoint = 0;
		}
		
		int sum = 0;
		
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				sum+=point[i][j];
			}
			
			System.out.println(sum);
			
			sum = 0;
		}
		
		
	}
}

Measured memory_bytes: 40628
#include <stdio.h>
int main(void){
    int i,n;
    scanf("%d\n",&n);
    int a,j=0;
    for (i=0;i<n;i++){
	scanf("%d",&a);
	if(a%2==0&&a%3!=0&&a%5!=0){
	    printf("DENIED");
	    j++;
	    break;
	    }
	}
    if(j==0)printf("APPROVED");

    return 0;
    }


Measured memory_bytes: 128
import sys

N = int(sys.stdin.readline())
if N == 0:
    print(0)
    sys.exit()
binN = ""
pN = abs(N)
while N != 0:
    if abs(N % -2) == 1:
        binN += "1"
    else:
        binN += "0"
    N += N%(-2)
    N //= -2
print(binN[::-1])

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

typedef long long ll;

int main(){
    ll n, p;
    cin >> n >> p;
    ll ret = 1;
    for(ll i = 2; i*i <= p; i++){
        if(p%i) continue;
        ll cnt = 0;
        while(p%i == 0) cnt++, p /= i;
        while(cnt >= n){
            cnt -= n;
            ret *= i;
        }
    }
    if(p != 1 && n == 1)    ret *= p;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 120
	// https://atcoder.jp/contests/abc120/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		LinkedList<Integer> stack = new LinkedList<>();
		int res = 0;
		
		for (char c: s.toCharArray()) {
			int code = c - '0';
			
			if (!stack.isEmpty() && (code ^ (stack.peek())) == 1) {
				stack.pop();
				res += 2;
			} else {
				stack.push(c-'0');
			}
		}
		
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}

class Point {
	int x;
	int y;
	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 28500
#include <iostream>
#include <string>

using namespace std;

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


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

#define int long long

const int N = 1e5 + 10;
int n, m, cnt, mark[N];
vector <int> adj[N];

void dfs(int v, int c) {
	mark[v] = c;
	for (int i : adj[v])
		if (mark[i] == -1)
			dfs(i, c);
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u, x;
		cin >> v >> u >> x;
		v--; u--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	
	memset(mark, -1, sizeof mark);
	for (int i = 0; i < n; i++)
		if (mark[i] == -1)
			dfs(i, cnt++);
	cout << cnt;
}

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

using namespace std;

#define MAX_V 550
#define INF 1e8

struct edge{
  int to,cap,cost,rev;
  edge(int to,int cap,int cost,int rev) :
    to(to),cap(cap),cost(cost),rev(rev) {}
};

vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(edge(to,cap,cost,G[to].size()));
  G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  while(f > 0){
    fill(dist,dist+MAX_V,INF);
    dist[s] = 0;
    bool update = true;
    while(update){
      update = false;
      for(int v = 0 ; v < MAX_V ; v++){
        if(dist[v] == INF) continue;
        for(int i = 0 ; i < (int)G[v].size() ; i++){
          edge &e = G[v][i];
          if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
            dist[e.to] = dist[v] + e.cost;
            prevv[e.to] = v;
            preve[e.to] = i;
            update = true;
          }
        }
      }
    }
    
    if(dist[t] == INF){
      return -1;
    }
    
    int d = f;
    for(int v = t ; v != s ; v = prevv[v]){
      d = min(d,G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d * dist[t];
    for(int v = t ; v != s ; v = prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  int N;
  while(cin >> N, N){
    for(int i = 0 ; i < MAX_V ; i++){
      G[i].clear();
    }
    int a,b,w;
    for(int i = 0 ; i < N ; i++){
      cin >> a >> b >> w;
      add_edge(a-1,b,1,-w);
    }
    for(int i = 0 ; i < 365 ; i++){
      add_edge(i,i+1,2,0);
    }
    cout << -min_cost_flow(0,365,2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1344
#include "bits/stdc++.h"
using namespace std;
int dp[300][300];//dp[l][r] [l,r]でだるまを落としたときの落とした個数

int main()
{
	while(1)
	{
		int n;
		cin>>n;
		if(n==0)
			break;
		
		int da[300];
		for(int i=0;i<n;i++)
			cin>>da[i];
		fill(dp[0],dp[300],0);
		for(int i=1;i<n;i++)
		{
			int dif=da[i]-da[i-1];
			if(dif<2 && dif>-2)
				dp[i-1][i]=2;
			else
				dp[i-1][i]=0;
		}
		//ここからdp
		for(int k=2;k<n;k++)
		{
			for(int i=0;i<n-k;i++)
			{
				//分割して調べる
				for(int j=i;j<i+k;j++)
				{
					//cerr<<dp[i][j]+dp[j+1][i+k]<<endl;
					dp[i][i+k]=max(dp[i][i+k],dp[i][j]+dp[j+1][i+k]);
				}
				//真ん中が全部消える場合も調べる
				int dif=da[i]-da[i+k];
				if(dp[i+1][i+k-1]==k-1 && dif<2 && dif>-2)
					dp[i][i+k]=k+1;
			}
		}
		cout<<dp[0][n-1]<<endl;
	}
	return 0;
}	


Measured memory_bytes: 3432
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

#define POW2(X) (1<<(X))
#define CKBIT(S,X) (((S)&POW2(X))!=0)

template<class T> inline void nlmin(T &a,T b){ a=min(a,b); }
template<class T> inline void nlmax(T &a,T b){ a=max(a,b); }
template<class T> inline T sqr(T x){ return x*x; }
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())

#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(),A.end()
template<class T> int CMP(T a[],const T b[],int n) { return memcmp(a,b,n*sizeof(T)); }
template<class T> void COPY(T a[],const T b[],int n) { memcpy(a,b,n*sizeof(T)); }
template<class T> void SET(T a[],int val,int n) { memset(a,val,n*sizeof(T)); }
//using uint=unsigned int;
typedef long long int64;
//using uint64=unsigned long long;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VII;
// using VD=vector<double>;
const int kmod = 1000000007;


int main() {

	int N, W;
	while (cin >> N >> W) {
		VI w(N+1), v(N+1);
		FOR (i, 1, N + 1) cin >> w[i] >> v[i];

		vector<int64> dp(W + 1, 0);
		FOR (i, 1, N + 1) RFOR (j, W, w[i] - 1) {
			nlmax(dp[j], dp[j - w[i]] + v[i]);
		}
		cout << dp[W] << endl;

	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int m = max(max(a, b), c);
    int s = a + b + c;
    int ans;
    if (s % 2 == m % 2) {
        ans = (3 * m - s) / 2;
    } else {
        ans = (3 * (m + 1) - s) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d %d" (fun a b c ->
    let module S = Set.Make (struct type t = int * int * int let compare = compare end) in

    let rec loop i a b c set =
        let key = (a, b, c) in
        if S.mem key set then (-1) else
            if (a land 1) lor (b land 1) lor (c land 1) > 0 then i else
                loop (i + 1) ((b + c) / 2) ((a + c) / 2) ((a + b) / 2) (S.add key set)
    in
    loop 0 a b c S.empty |> Printf.printf "%d\n"
)

Measured memory_bytes: 3880
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int A, B, C[12][12], D[101][101], DX[12][12], DY[12][12], NV, V[303][303], K=100;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i,303)rep(j,303) V[i][j]=-1;
    cin>>A>>B;
    rep1(x,A)rep1(y,B) cin>>C[x][y];
    
    vector<int> Xs, Ys;
    NV=1;
    Xs.push_back(NV);
    rep(i,K){
        V[NV][NV+1]=-2;
        NV++;
        Xs.push_back(NV);
    }
    
    NV++;
    Ys.push_back(NV);
    rep(i,K){
        V[NV+1][NV]=-3;
        NV++;
        Ys.push_back(NV);
    }
    
    rep(x,K+1)rep(y,K+1){
        int ret=0;
        rep1(i,A)rep1(j,B){
            ret=max(ret,C[i][j]-x*i-y*j);
        }
        D[x][y]=V[Xs[x]][Ys[y]]=ret;
    }
    
    rep1(i,A)rep1(j,B){
        int mi=1010;
        rep(x,K+1)rep(y,K+1){
            mi=min(mi,x*i+j*y+D[x][y]);
        }
        if(mi!=C[i][j]){
            cout1("Impossible");
            return 0;
        }
    }
    
    int cnt=0;
    rep(x,303)rep(y,303) if(V[x][y]!=-1) cnt++;
    cout1("Possible");
    cout2(NV,cnt);
    rep(x,303)rep(y,303) if(V[x][y]!=-1){
        cout<<x<<" "<<y<<" ";
        if(V[x][y]==-2) cout1("X");
        if(V[x][y]==-3) cout1("Y");
        if(V[x][y]>=0) cout1(V[x][y]);
    }
    cout2(Xs[0],Ys[0]);
}

Measured memory_bytes: 768