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

#define int long long  
#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()
 
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846//20 decimals
#define MOD 1000000007
 

int32_t main(){
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
     IOS
   string s;
   cin>>s;
   string ans="Yes";
    for(int i=1;i<=sz(s);i++)
    {
        if(i&1)
        {
            if(s[i-1]=='L'){
                ans="No";
                break;
            }
        }
        else
        {
            if(s[i-1]=='R')
            {
                ans="No";
                break;
            }
        }
    }
    cout<<ans;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 1000
main(){
  int n, i;
  int A[N];

  scanf("%d", &n);
  for( i = 1; i <= n; i++) scanf("%d",&A[i]);

  for (i = 1; i <= n; i++) {
    printf("node %d: key = %d, ",i,A[i]);
    if( i/2 != 0 )printf("parent key = %d, ",A[i/2]);
    if( 2*i <= n ) printf("left key = %d, ",A[2*i]);
    if( 2*i+1 <= n ) printf("right key = %d, ",A[2*i+1]);
    printf("\n");
  } 
  return 0;
}

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	string s; cin >> s;
	bool all = true;
	rep(i, ((int)s.size() - 2) * all) {
		string t = s.substr(i, 3);
		map<char, int> mp;
		for (char c : t) mp[c]++;
		bool ok = true;
		for (P x : mp) ok = ok && x.second <= t.size() / 2;
		if (!ok) {
			cout << i + 1 << " " << i + 3 << endl;
			all = false;
			break;
		}
	}
	if (s.size() == 2 && s[0] == s[1]) {
		cout << "1 2" << endl;
		all = false;
	}
	if (all) cout << "-1 -1" << endl;
	system("pause");
}

Measured memory_bytes: 760
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = float('inf')
for i in range(M):
    x, y, c = map(int,input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(min(min(a)+min(b), ans))

Measured memory_bytes: 18736
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);

  puts((a == b)? "Yes": "No");
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  while(str[0]!='0'){
    int i,o=0;
    for(i=0;i<str.size();i++){
      o+=str[i]-'0';
    }
    cout << o << endl;
    cin >> str;
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int count = 0;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int i;
  for (i = 0; i < N; i++) {
    if (a.at(i) == 1){
      count++;
      break;
    }
    else if(i == N-1){
      cout << -1 << endl;
      return 0;
    }
  }
  
  int A = 2;
  for (int j = i+1; j < N; j++) {
    if (a.at(j) == A){
      count++;
      A++;
    }
  }
  cout << N - count << endl;
}
    
    
    
    

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

    const ll N = 2e5 + 7;
    const ll mod = 1e9 + 7;
    const ll inf = 1e9;

ll n , ans;
ll a[N];
map < ll , ll > mp;
void solve(){
    cin >> n;
    for(ll i = 1; i <= n; ++ i){
        cin >> a[i];
        ans += mp[i - a[i]];
        mp[a[i] + i] ++;
        //mp[i - a[i]] ++;
    }
    cout << ans;
}

int main(){
    TIME
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**



**/


Measured memory_bytes: 27864
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();
            if (K == 1) {
                System.out.println(0);
                return;
            }
            System.out.println(N - K);
        }
    }
}


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

int arr[4][100009], n;
long long dp[100009], psum[100009];

int main()
{
    scanf("%d",&n);
    for(int i=1; i<=3; i++) for(int j=1; j<=n; j++) scanf("%d",&arr[i][j]);
    sort(arr[1]+1, arr[1]+n+1);
    sort(arr[2]+1, arr[2]+n+1);
    sort(arr[3]+1, arr[3]+n+1);
    for(int i=1; i<=n; i++) psum[i] = (long long)n-i+1;
    for(int i=1; i<=n; i++) dp[i] = psum[upper_bound(arr[3]+1, arr[3]+n+1, arr[2][i]) - arr[3]];
    for(int i=n; i>=1; i--) psum[i] = psum[i+1] + dp[i];
    long long ans = 0;
    for(int i=1; i<=n; i++) ans += psum[upper_bound(arr[2]+1, arr[2]+n+1, arr[1][i]) - arr[2]];
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,a[N];

int main() {
	n=gi(),m=gi();
	for(int i=1;i<=2*n;i++) a[i]=gi();
	sort(a+1,a+2*n+1);
	int l=0,r=n;
	while(l<r) {
		int mid=(l+r)>>1;
		bool fl=1;
		for(int i=2*mid+1,j=2*n;i<j;i++,j--)
			if(a[i]+a[j]<m) fl=0;
		if(fl) r=mid;
		else l=mid+1;
	}
	int ans=0;
	for(int i=1,j=2*l;i<j;i++,j--)
		ans=max(ans,a[i]+a[j]);
	for(int i=2*l+1,j=2*n;i<j;i++,j--)
		ans=max(ans,a[i]+a[j]-m);
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

const int mod = 1000000007;

int dp[52][3], used[128], n;

struct grid
{
    bool type;
    long long r, c, g, rc, rg, cr, cg, gr, gc;
};

int main()
{    
    cin >> n;
    
    string s[2];
    
    cin >> s[0] >> s[1];
    
    vector<grid> v;
    
    grid x;
    
    int i;
    
    if (s[0][0] == s[1][0])
    {
        x.type = 0;
        i = 1;
        
        x.r = 1;
        x.g = 1;
        x.c = 1;
    }
    else
    {
        x.type = 1;
        i = 2;
        x.rc = 1;
        x.rg = 1;
        x.cr = 1;
        x.cg = 1;
        x.gr = 1;
        x.gc = 1;
    }
    
    for (; i < n; i++)
    {
            grid y;
        
            if (s[0][i] == s[1][i])
            {
                y.type = 0;
                
                if (x.type == 0)
                {
                    y.r = (x.c + x.g) % mod;
                    y.c = (x.g + x.r) % mod;
                    y.g = (x.r + x.c) % mod;
                }
                else
                {
                    y.r = (x.cg + x.gc) % mod;
                    y.c = (x.rg + x.gr) % mod;
                    y.g = (x.rc + x.cr) % mod;
                }
            }
            else
            {
                i++;
                 y.type = 1;
                 
                 if (x.type == 0)
                 {
                    y.rg = x.c;
                    y.rc = x.g;
                    y.cr = x.g;
                    y.cg = x.r;
                    y.gr = x.c;
                    y.gc = x.r;
                 }
                 else
                 {
                    y.rg = (x.gr + x.cr + x.gc) % mod;
                    y.rc = (x.cr + x.gr + x.cg) % mod;
                    y.cr = (x.rc + x.rg + x.cg) % mod;
                    y.cg = (x.gc + x.gr + x.rc) % mod;
                    y.gr = (x.rg + x.rc + x.cg) % mod;
                    y.gc = (x.cg + x.rg + x.cr) % mod;    
                 }
            }
        
        x = y;
    }
    
    long long ans = 0;
    
    if (x.type == 0)
        ans += x.r + x.g + x.c;    
    else
        ans += x.rg + x.rc + x.gr + x.gc + x.cg + x.cr;
        
    ans %= mod;
    
    cout << ans;
        
    return 0;    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='7')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3636
my ($n) = split(/\s+/, <STDIN>);
my (@h) = split(/\s+/, <STDIN>);

my $val = 0;
my $max = 0;
for my $i (@h) {
    if ($max <= $i) {
	$max = $i;
	$val++;
    }
}
print $val, "\n";


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, a, b; cin >> n >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % n == 0) {
      cout << "OK" << '\n';
      return 0;
    }
  }
  cout << "NG" << '\n';
}


Measured memory_bytes: 3652
def resolve():
    S = input()

    # YY: 00<=YY<=99
    # MM: 01<=MM<=12
    
    f_canYY = lambda x: '00' <= x and x <= '99'
    f_canMM = lambda x: '01' <= x and x <= '12'

    a = S[0:2]
    b = S[2:4]

    yymm = f_canYY(a) and f_canMM(b)
    mmyy = f_canMM(a) and f_canYY(b)

    if yymm and mmyy:
        print('AMBIGUOUS')
    elif yymm and not mmyy:
        print('YYMM')
    elif not yymm and mmyy:
        print('MMYY')
    else:
        print('NA')
        
resolve()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  string s;
  cin >> s;
  
  vector<int>dir(N,0);
  
  if(s[0] == 'E')
    dir[0] = 1;
  
  for(int i=1;i<N;i++){
    if(s[i] == 'E')
      dir[i] = dir[i - 1] + 1;
    else
      dir[i] = dir[i - 1];
  }
  
  int ans_min = 999999;
  for(int i=0;i<N;i++){
    int ans = 0;
    if(i == 0)
      ans = dir[N - 1];
    else if(i == N)
      ans = N - 1 - dir[N - 2];
    else
      ans = (i - dir[i - 1]) + (dir[N - 1] - dir[i]);
    
    if(ans < ans_min)
      ans_min = ans;
  }
  
  cout << ans_min << endl;
  
  return 0;
}

Measured memory_bytes: 1796
from collections import deque
x = input()
A = 0
S1 = deque()
S2 = deque()

for i in range(len(x)):
    if x[i] == "\\":
        S1.append(i)
    elif x[i] == "/" and len(S1) > 0 :
        j = S1.pop()
        A += i - j
        a  = i - j
        while  len(S2) > 0 and S2[-1][0] > j:
            a += S2[-1][1]
            S2.pop()
        S2.append([j,a])
print(A)

if len(S2)== 0:
    print(0)
else:
    print(len(S2),"",end="")
    for i in range(len(S2)):
        if i == len(S2) - 1:
            print(S2[i][1])
        else:
            print(S2[i][1],"",end="")


Measured memory_bytes: 7336
n=int(input())
A=list(map(int,input().split()))

maximal=max(A)
print(maximal,end=" ")
B=list(map(lambda x:abs(x - maximal/2),A))
minimam=B.index(min(B))
if A[minimam]==maximal:
    print("0")
else:
    print(A[minimam])

Measured memory_bytes: 14052
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int n;
int a[MAX_N];

int mymax(int arr[], int n)
{
  int m = 0;
  for (int i = 0; i < n; i++) {
    m = max(m, arr[i]);
  }
  return m;
}

int main(void)
{
  cin >> n;
  REP(i, n) cin >> a[i];

  int amax = mymax(a, n);

  int half = amax / 2;

  int idx = 0;
  int m = INT_MAX;
  // search near by half
  for (int i = 0; i < n; i++) {
    if (a[i] == amax) continue;
    if (abs(a[i] - half) < m) {
      m = abs(a[i] - half);
      idx = i;
    }
  }

  printf("%d %d\n", amax, a[idx]);

  return 0;
}


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

using namespace std;

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);

	int l[n][m];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++) {
			scanf("%d", &l[i][j]);
			l[i][j]--;
		}
	
	for(int i = 1; i <= n; i++) {
		vector<int> cnt[m];
		int choice[n];
		fill(choice, choice + n, 0);
		bool lock[m];
		memset(lock, 0, sizeof(lock));

		queue<int> q;
		for(int j = 0; j < n; j++)
			q.push(j);
		
		bool ok = true;
		while(!q.empty()) {
			int cur = q.front();
			q.pop();

			while(choice[cur] < m) {
				int next = l[cur][choice[cur]];
				if(lock[next] == true)
					choice[cur]++;
				else
					break;
			}

			if(choice[cur] == m) {
				ok = false;
				break;
			}	
			
			int next = l[cur][choice[cur]];
			cnt[next].push_back(cur);
			if((int)cnt[next].size() > i) {
				for(auto j : cnt[next]) {
					q.push(j);
					lock[next] = true;
				}
			}			
		}

		if(ok) {
			printf("%d\n", i);
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

    int ans = 700;
    string s;
    cin >> s;
    for (auto &&si : s)
    {
        if (si == 'o')
            ans += 100;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
input = gets.chomp.split
a = input[0].to_i - 1
b = input[1].to_i
c = input[2].to_i
d = input[3].to_i

cd = c.lcm(d)

a_c = a / c
a_d = a / d
a_cd = a / cd

b_c = b / c
b_d = b / d
b_cd = b / cd

puts (b - b_c - b_d + b_cd) - (a - a_c - a_d + a_cd)

Measured memory_bytes: 1788
X,Y=map(int,input().split())
Prize1=0
Prize2=0
if X+Y==2:
  Prize2=400000
if X==3:
  Prize1=Prize1+100000
elif X==2:
  Prize1=Prize1+200000
elif X==1:
  Prize1=Prize1+300000
if Y==3:
  Prize1=Prize1+100000
elif Y==2:
  Prize1=Prize1+200000
elif Y==1:
  Prize1=Prize1+300000
print(Prize1+Prize2)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;



int main(void) {
  ll N, K[3];
  cin >> N >> K[0] >> K[1] >> K[2];
  ll i, j;
  ll ans=INF;
  ll l[11];
  
  for(i=0; i<N; i++) cin >> l[i];
  
  for(ll S=0; S<pow(4, N); S++) {
    vector<ll> g[4];
    ll s[3]={};
    ll t=S;
    for(i=0; i<N; i++) {
      ll id=t%4;
      t/=4;
      
      g[id].push_back(i);
      
      if(id==3) continue;
      s[id]+=l[i];
    }
    
    if(g[0].empty()||g[1].empty()||g[2].empty()) continue;
    
    ll cost=0;
    for(i=0; i<3; i++) {
      cost+=abs(s[i]-K[i]);
      cost+=10*((ll)g[i].size()-1);
    }
    
    chmin(ans, cost);
    
  }
  
  pt(ans);
  
}






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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;

    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    #endif // _DEBUG

    long long x;
    cin>>x;
    long long p = 100, i = 0;
    while (p < x) {
        p += p / 100;
        i++;
    }
    cout<<i;
    return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  
  int c[501], s[501], f[501], t[501];
  for(int i=0; i<n-1; i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  c[n-1] = s[n-1] = f[n-1] = 0;
  
  for(int train=0; train<n; train++){
    t[train] = s[train];
    //printf("train %d  start %d\n", train, s[train]); fflush(stdout);
    for(int sta=train+1; sta<n; sta++){
      int start_next = max(t[train] + c[sta-1], s[sta]);
      //printf(" sta %d  start %d %d\n", sta, start_next, s[sta]); fflush(stdout);
      if(sta < n-1 && start_next % f[sta] != 0) 
        start_next += f[sta] - (start_next % f[sta]);
      t[train] = start_next;
      //printf(" sta %d  start %d\n", sta, start_next); fflush(stdout);
    }
  }
  
  for(int i=0; i<n; i++){
    cout << t[i] << endl;
  }

  return 0;
}


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[] lens = new int[n];
      for(int i = 0; i < n; i++)
        lens[i] = sc.nextInt();
      Arrays.sort(lens);
      int cnt = 0;
      for(int i = n - 1; i >= 2; i--) {
        int left = 0, right = i - 1;
        while(left < right) {
          if(lens[left] + lens[right] > lens[i]) {
            cnt += right - left;
            right--;
            continue;
          }
          left++;
        }
      }
      System.out.println(cnt);
  }
}

Measured memory_bytes: 27988
A=list(map(int,input().split()))

list=[0]*101
#A~B秒までの要素を+1
for i in range(A[0],A[1]+1):
  list[i]+=1
#C~D秒までの要素を+1
for i in range(A[2],A[3]+1):
  list[i]+=1
if list.count(2)>=1:
  print(list.count(2)-1)
else:
  print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t;

string a,b,c;


int main()
{
	fast;
	cin>>a;
	for(int i=0;i<a.size();i++)
		cout<<'x';
}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

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

typedef long long ll;
const ll mod=1e9+7;
const ll N=1e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll n;
	cin>>n;
	map<ll,ll> cnt;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			n/=i;
			cnt[i]++;
		}
	}
	if(n!=1) cnt[n]++;
	ll ans=0;
	for(auto i:cnt){
		for(int j=1;j<=i.second;j++){
			ans++;
			i.second-=j;
		}
	}
	cout<<ans;
}


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

using lint = long long;
#define bit(n) (lint(1) << n)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<lint> d(n);
    for (int i = 0; i < n; i++) {
        d[i] = s[i] - '0';
    }

    lint ans = 0;
    for (int i = 0; i < bit(n); i++) {
        lint num = 0;
        for (int j = 0; j < n; j++) {
            if (!(i & bit(j))) {
                num *= 10;
                num += d[j];
            } else {
                ans += num;
                num = 0;
            }
        }
        ans += num;
    }

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

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

using namespace std;
ll arr[100010];
int main()
{
	 ll n;
	scanf("%lld",&n);
	for(int i = 0;  i< n ; i++)
	{
		ll l , r;
		scanf("%lld %lld",&l,&r);
		for(int j = l ; j <= r; j++)
		{
			arr[j] = 1;
		}
	}
	ll ans = 0;
	for(int i = 1 ; i<= 100000 ; i++)
	{
		if(arr[i] == 1)
		{
			ans++;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
// atcoder/abc055/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, m;
  while (cin >> n >> m) {

    auto fn = [&] (lli x) {
      lli s = n;
      lli c = m;
      c -= max(0LL, x - s) * 2;
      return x * 2LL <= c;
    };

    lli small = 0;
    lli large = 1LL << 60;
    while (small + 1 < large) {
      lli mid = (small + large) / 2;
      if (fn(mid)) small = mid;
      else large = mid;
    }
    cout << (fn(large) ? large : small) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<vector>
#include<sstream>
#include<deque>
#include<algorithm>
#include<queue>

using namespace std;

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

int dp[2][100001];
int masu[100001];
int main(){
	while(1){
		rep(i,2)rep(j,100001){
			dp[i][j]=0;
		}
		rep(j,100001){
			masu[j]=0;
		}
		
		int n,m;
		scanf("%d%d",&n,&m);
		if(n==0)break;
		
		int fflg=0;
		rep(i,m){
			int a;
			scanf("%d",&a);
			if(a==0){
				fflg=1;
				continue;
			}
			
			masu[a]=1;
		}
		
		reps(i,n){
			if(masu[i]==1){
				dp[0][i]=dp[0][i-1]+1;
			}
		}
		
		reps(i,n){
			if(masu[i]==1){
				dp[1][i]=dp[1][i-1]+1;
			}else{
				dp[1][i]=dp[0][i-1]+1;
			}
		}
		
		int maxi=-1;
		reps(i,n){
			maxi=max(maxi,dp[fflg][i]);
		}
		
		printf("%d\n",maxi);
	}
	
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
	float A, B, T;
	cin >> A >> B >> T;

	float Max = T + 0.5f;

	float Timer = 0.0f;
	int Num = 0;

	for (Timer = A; Timer <= Max; Timer += A)
	{
		Num += B;
	}

	cout << Num;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
#define MAX 1001

int lcs(string X, string Y){
  int c[MAX][MAX]; 
  int m = X.length();
  int n = Y.length();
  for(int i=0; i<m; i++){
    c[i][0] = 0;
  }
  for(int i=0; i<=n; i++){
    c[0][i] = 0;
  }
  for(int i=1; i<=m; i++){
    for(int j=1; j<=n; j++){
      if(X[i-1] == Y[j-1]){
        c[i][j] = c[i-1][j-1] + 1;
      }else{
        c[i][j] = (c[i][j-1] > c[i-1][j] ? c[i][j-1] : c[i-1][j]);
      }
    }
  }
  return c[m][n];
}

int main(void){
  int q, l;
  string X, Y;
  cin >> q;
  for(int i=0; i<q; i++){
    cin >> X >> Y;
    l = lcs(X, Y);
    cout << l << endl;
  }
  return 0;
}



Measured memory_bytes: 7060
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
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; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n;
  while (cin >> n, n) {
    int p;
    vpii v;
    {
      vpii a(n);
      cin >> a;
      int m;
      cin >> m;
      vpii b(m);
      cin >> b;
      p = n + m;
      v.reserve(p);
      for (auto &x : a) v.push_back(move(x));
      for (auto &x : b) v.push_back(move(x));
    }
    sort(all(v), [](auto &a, auto &b) {
      if (a.first != b.first) return a.first < b.first;
      return a.second > b.second;
    });
    vi dp(p);
    rep(i, p) {
      int s = 0;
      rep(j, i) if (v[j].second < v[i].second) cmax(s, dp[j]);
      dp[i] = s + 1;
    }
    cout << *max_element(all(dp)) << endl;
  }
}

Measured memory_bytes: 3096
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
    	Scanner scan=new Scanner(System.in);
    	int sx=scan.nextInt();
    	int sy=scan.nextInt();
    	int tx=scan.nextInt();
    	int ty=scan.nextInt();
    	for(int i=0;i<tx-sx;i++) {
    		System.out.print("R");
    	}
    	for(int i=0;i<ty-sy;i++) {
    		System.out.print("U");
    	}
    	for(int i=0;i<tx-sx;i++) {
    		System.out.print("L");
    	}
    	for(int i=0;i<ty-sy;i++) {
    		System.out.print("D");
    	}
    	System.out.print("D");
    	for(int i=0;i<tx-sx+1;i++) {
    		System.out.print("R");
    	}
    	for(int i=0;i<ty-sy+1;i++) {
    		System.out.print("U");
    	}
    	System.out.print("LU");
    	for(int i=0;i<tx-sx+1;i++) {
    		System.out.print("L");
    	}
    	for(int i=0;i<ty-sy+1;i++) {
    		System.out.print("D");
    	}
    	System.out.println("R");
    }
}

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

vector<long> v[8];


int main(){
  int N, M;
  cin >> N >> M;
  for(int i=0; i<N; i++){
    long x, y, z;
    cin >> x >> y >> z;
    v[0].push_back(x+y+z);
    v[1].push_back(x+y-z);
    v[2].push_back(x-y+z);
    v[3].push_back(x-y-z);
    v[4].push_back(-x+y+z);
    v[5].push_back(-x+y-z);
    v[6].push_back(-x-y+z);
    v[7].push_back(-x-y-z);
  }
  for(int i=0; i<8; i++){
    sort(v[i].begin(), v[i].end(), greater<long>());
  }
  long max=0;
  for(int i=0; i<M; i++){
    max+=v[0][i];
  }
  for(int i=1; i<8; i++){
    long tmp=0;
    for(int j=0; j<M; j++){
      tmp+= v[i][j];
    }
    if(max<tmp) max =tmp;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 384
public class Main { 
	public static void main(String[] args){
		int inSeconds = new java.util.Scanner(System.in).nextInt();
		int outHours = inSeconds / (60*60);
		inSeconds = inSeconds % (60*60);
		int outMinutes = inSeconds / 60;
		inSeconds = inSeconds % 60;
		int outSeconds = inSeconds;
		System.out.println(outHours + ":" +outMinutes + ":" + outSeconds);
	}
}

Measured memory_bytes: 17232
#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testcases \
    int tcc;      \
    cin >> tcc;   \
    for (int tc = 1; tc <= tcc; tc++)
//-----------------------------------------
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef LOAFNOB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//----------------------------------------------

int main() {
    fast_io;
    int x,y; cin>>x>>y;
    cout<<(y>=x?"unsafe":"safe");
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, x[100], y[100];

int main(){
	P div[100][100];
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> x[i] >> y[i];
	}
	
	for(ll i = 1; i <= n; i++){
		for(ll j = 1; j < i; j++){
			ll ibuf = i;
			ll jbuf = j;
			if(x[i] > x[j]){
				ibuf = j;
				jbuf = i;
			}
			else{
				if(x[i] == x[j] && y[i] > y[j]){
					ibuf = j;
					jbuf = i;
				}	
			}
			div[i][j] = P(x[jbuf]-x[ibuf], y[jbuf]-y[ibuf]);
		}
	}
	
	map<P, ll> mp;
	for(ll i = 1; i <= n; i++){
		for(ll j = 1; j < i; j++){
			if(mp.find(div[i][j]) != mp.end()){
				mp[div[i][j]] = mp[div[i][j]] + 1;
			}
			else{
				mp[div[i][j]] = 1;
			}
		}
	}
	
	ll ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		ans = max(itr->second, ans);
	}
	if(n == 1){cout << 1 << endl;}
	else{cout << n-ans << endl;}
	return 0;
}

Measured memory_bytes: 512
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let M: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (d, c): (Vec<usize>, Vec<usize>) = {
        let (mut d, mut c) = (vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            d.push(iter.next().unwrap().parse().unwrap());
            c.push(iter.next().unwrap().parse().unwrap());
        }
        (d, c)
    };

    let s = (0..M).map(|i| d[i] * c[i]).sum::<usize>();
    let y = if s <= 9 { 0 } else { 1 + (s - 10) / 9 };
    let ans = c.iter().sum::<usize>() - 1 + y;

    println!("{}", ans);
}


Measured memory_bytes: 10492
/*

                   _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;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in));
	int t=0;
	rep(i,n)if(in[i]<0)t=i;
	if(t==n-1)t=n-2;
	// -3 -2 -1 0 1 2 3
	int s=0;
	rep(i,n)if(i<=t)s-=in[i];else s+=in[i];
	cout<<s<<endl;
	loop(i,1,t+1){
		cout<<in[n-1]<<" "<<in[i]<<endl;
		in[n-1]-=in[i];
	}
	loop(i,t+1,n-1){
		cout<<in[0]<<" "<<in[i]<<endl;
		in[0]-=in[i];
	}
	cout<<in[n-1]<<" "<<in[0]<<endl;
}


Measured memory_bytes: 2688
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int bfs(int stage[12][12]){

	int count = 0;
	for(int y=0;y<12;y++){
		for(int x=0;x<12;x++){
			if(stage[y][x]==0) continue;
			count++;
			queue<P> que;
			que.push(P(x,y));

			while(!que.empty()){
				int x = que.front().first;
				int y = que.front().second;

				que.pop();

				stage[y][x] = 0;

				for(int i=-1;i<=1;i++){
					for(int j=-1;j<=1;j++){
						if(i*j != 0 || (i==j && i==0)) continue;
						int dx = x + i;
						int dy = y + j;

						if(dx < 0 || dx >=12 || dy < 0 || dy >= 12) continue;
						if(stage[dy][dx]==0) continue;
						que.push(P(dx,dy));
					}
				}
			}
		}
	}
	return count;
}

int main(){
	string str;

	int stage[12][12];

	while(getline(cin,str)){
		if(str.empty()) continue;

		for(int y=0;y<12;y++){
			for(int x=0;x<12;x++){
				stage[y][x]=str[x]-'0';
			}
			getline(cin,str);
		}

		cout << bfs(stage) << endl;
	}
}

Measured memory_bytes: 6684
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,t = iim()
T = iil()

ans = t
for i in range(1,n):
    ans += min(T[i]-T[i-1],t)

print(ans)

Measured memory_bytes: 25708
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;


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

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

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

 struct UF {
	vector<int>par;//親
	vector<int>sz;//要素数

  UF(int n){
    sz.resize(n,1);
    par.resize(n);
    for(int i=0;i<n;++i){
      par[i]=i;
    }
  }

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);//経路圧縮
		}
	}

	//xとyの属する集合を併合
	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return false;//すでに同じ集合に属している

		if (sz[x] < sz[y]) {//要素数が小さい方を下に
			par[x] = y;
      sz[y]+=sz[x];
		}
		else {
			par[y] = x;
			sz[x]+=sz[y];
		}
		return true;
	}

	//xとyが同じ集合に属するかを判定
	bool same(int x, int y) {
		return find(x) == find(y);
	}

    int size(int k){//要素数を求める
        return sz[find(k)];
    }
};


void solve(){
	int n,q;
  cin>>n>>q;
  UF tree(n);
  while(q--){
    int t,u,v;
    cin>>t>>u>>v;
    if(!t){
      tree.unite(u,v);
    }
    else{
      cout<<tree.same(u,v)<<"\n";
    }
  }
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 4604
#include <stdio.h>
 
int main(){
   char a[101],b[101],c[101];
   int n,m,i;
    
   scanf("%d",&n);
   scanf("%s",a);
   scanf("%s",b);
   scanf("%s",c);
   for (m=i=0;i<n;i++) 
      if (a[i]==b[i] && a[i]==c[i]) continue;
      else if (a[i]==b[i] || a[i]==c[i] || b[i]==c[i]) m++;
      else m+=2;
   printf("%d\n",m);
   return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  int v[n]; rep(i, n) cin >> v[i];
  int c[n]; rep(i, n) cin >> c[i];

  int ans = 0;
  rep(i, n) {
    if(v[i] > c[i]) ans += v[i]-c[i];
  } cout << ans;
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
//#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

signed main (){
    string s;
    cin>>s;
    rep(i,0,s.size()){
        cout<<s[i];
        if(i==3)cout<<" ";
    }
    cout<<endl;
    


    
}
/*
1-21-2
*/


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



int main() {
  int x;
  cin >> x;
  int sum = 0;
  if(x >= 500){
      int i= x/500;

      sum = 1000*i;

      x-= 500*i;
  }

  if(x >= 5){
      int i= x/5;

      sum += 5*i;
  }
  cout << sum << endl;
  return 0;


}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    string s;cin>>s;
    int s_length = s.size();
    int ss_length = (s_length-1)/2;
    string sf,sb; sf=s;sb=s;
    sf.erase(ss_length,s_length-ss_length);
    sb.erase(0,ss_length+1);
    if(sf==sb){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#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 T, X;
    cin >> T >> X;
    cout << 1.0 * T / X << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  int N, ans=0;
  cin >> N;
  int a[N+1];
  a[0] = 0;
  rep(i, N){
    cin >> a[i+1];
  }
  rep(i, N){
    ans += max(0, a[i+1]-a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

class Main{

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
/*
		String nums = sc.nextLine();
		String num[] = nums.split(" ");
		ArrayList alist = new ArrayList();
		for(int i = 0;i < num.length;i++){
			alist.add(Integer.parseInt(num[i]));
		}
*/	
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int tmp = 0;
		if(a > b){
			tmp = a;
			a = b;
			b = tmp;
		}
		if(b > c){
			tmp = b;
			b = c;
			c = tmp;
		}
		if(a > b){
			tmp = a;
			a = b;
			b = tmp;
		}
		
		//Collections.sort(alist);

		System.out.println(a + " " + b + " " + c);
	}
}


Measured memory_bytes: 26276
#include <iostream>
using namespace std;
 
int main() {
  string str;
  int n;
  cin >> n;
  cin >> str;
  if (str.size() <= n){
    cout << str << endl;
  }
  else if (str.size() >= n){
    int m = 0;
   while (m < n){
      cout << str.at(m);
       m = m + 1;
    }
      cout << "..." << endl;
  }
    
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer n = Integer.parseInt(scan.next());
        ArrayList<Integer> array = new ArrayList<Integer>();
        ArrayList<Integer> array2 = new ArrayList<Integer>();

        for(int i=0;i<n;i++)   
            array.add(Integer.parseInt(scan.next()));

        for(int i=0;i<n;i++){
            array2.add(array.get(i));
        }

        Collections.sort(array2);


        int max = Collections.max(array);
        int max2 = array2.get(array2.size()-2);
        for(int i=0;i<n;i++){
            if(array.get(i) != max){
                System.out.println(max);
            }else{
                System.out.println(max2);
            }
        }

    }
}

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

long long N, M, a[100009][3], maxn =-(1LL << 60);

int main() {
  cin >> N >> M;
  for(int i=1; i<=N; i++) {
    for(int j=0; j<3; j++) {
      cin >> a[i][j];
    }
  }

  for(int i=0; i<8; i++) {
    vector<long long> vec;
    for(int j=1; j<=N; j++) {
      long long S = 0;
      for(int k=0; k<3; k++) {
        // 2^3通りの正負記号について
	// 例) i = 3
	// k = 0 の時 3/1 = 3 は2で割り切れず (-)
	// k = 1 の時 3/2 = 1 は2で割り切れず (-)
	// k = 2 の時 3/4 = 0 は2で割り切れる (+)
	if((i/(1<<k))%2==0) {
	  S += a[j][k];
	} else {
	  S -= a[j][k];
	}
      }
      vec.push_back(S);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    long long ans = 0;
    for(int j=0; j<M; j++) {
      ans += vec[j];
    }
    maxn = max(maxn, ans);
  }
  cout << maxn << endl;
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,bil;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>bil;
        if(bil%2==0){
            if(bil%3!=0 && bil%5!=0){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
}

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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int n;
    cin>>n;
    string s;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }
    int ma = 0;
    for(auto i:mp){
        ma = max(ma,i.second);
    }
    for(auto i:mp){
        if(i.second == ma){
            cout << i.first << endl;
        }
    }
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;


int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<int>> c(10,vector<int>(10));
    vector<vector<int>> a(h,vector<int>(w));
    vector<int> d(10);
    rep(i,10) {
        rep(j,10) cin >> c[i][j];
    } 
    rep(i,h) {
        rep(j,w) {
            cin >> a[i][j];
        }
    }
    rep(i,10) {
        int cost=1000;
        priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> p;
        p.push(make_pair(0,i));
        bool flag=0;
        while (1) {
            pair<int,int> now=p.top();
            p.pop();
            if (now.first>=cost) break;
            rep(j,10) {
                if (j==1) cost=min(cost,now.first+c[now.second][1]);
                else if (now.first+c[now.second][j]<cost && now.second!=j) p.push(make_pair(now.first+c[now.second][j],j));
            }
            if (p.empty()) break;
        }
        d[i]=cost;
    }
    int ans=0;
    rep(i,h) {
        rep(j,w) {
            if (a[i][j]*a[i][j]!=1) ans+=d[a[i][j]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384