akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int N, s[SIZE];
vector<pair<int,ll>> suml[SIZE], sumr[SIZE];

int main(){

  scanf("%d", &N);

  for (int i=0; i<N; i++) {
    scanf("%d", s+i);
  }

  for (int i=1; i<=N-1; i++) {
    ll sum = 0;
    for (int j=0; j<=N-1; j+=i) {
      sum += s[j];
      suml[j].push_back({i, sum});
    }
  }

  for (int i=1; i<=N-1; i++) {
    ll sum = 0;
    for (int j=N-1; j>=0; j-=i) {
      sum += s[j];
      sumr[j].push_back({i, sum});
    }
  }

  ll ans = 0;

  for (int A=1; A<N-1; A++) {
    int r = N-1 - A;

    for (int i=0; i<sumr[A].size(); i++) {
      int d = sumr[A][i].first;
      int B = A - d;
      if (B > 0 && (A % d != 0 || A / d > r / d)) {
        ans = max(ans, sumr[A][i].second + suml[r][i].second);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 63472
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll ans = 0;
  ll now = 0;
  rep(i,n){
    ans+=max(0LL,now-a[i]);
    maxs(now,a[i]);
  }
  cout<<ans<<endl;
  return 0;
}

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



int isPrime[100019], okay[100019], cum[100019];
void sieve()
{

    for(int i=2;i<=100009;i+=2)
        isPrime[i]=1;

     isPrime[2]=0;

    for(int i=3; i<=100009; i+=2)
    {
        if(isPrime[i]==0)
        {
            if(isPrime[(i+1)/2]==0)
                okay[i]=1;

            for(int j=2; i*j<=100009; j++)
            {
                isPrime[i*j]=1;
            }

        }
    }

    isPrime[1]=1;


//    for(int i=1; i<=10; i++)
//    {
//        if(okay[i]==1)
//        {
//            printf("%d\n",i);
//        }
//    }




    for(int i=3; i<=100009; i++)
    {
        cum[i]= cum[i-1]+okay[i];
       // printf("%d\n",cum[i]);
    }




}

int main()
{

    sieve();

    int q,l,r;
    scanf("%d",&q);


    while(q--)
    {
        scanf("%d %d",&l,&r);

        printf("%d\n",cum[r]-cum[l-1]);



    }


}




Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

template <typename T>
T gcd(T a, T b){ return b%a==0 ? a : gcd(b%a, a); }

unordered_map<i64,i64> pfact(i64 m)
{
    unordered_map<i64,i64> ps;
    i64 tmp = m;
    for(i64 i=2;i*i<=m;++i)
    {
        while(tmp%i == 0)
        {
            if(ps.count(i) == 0)
                ps[i] = 0;
            ps[i]++;
            tmp /= i;
        }

        if(tmp == 1)
            break;
    }

    if(tmp > 1)
    {
        if(ps.count(tmp) == 0)
        ps[tmp] = 0;
        ps[tmp]++;
    }

    return ps;
}

int main()
{   
    i64 a,b;
    cin >> a >> b;
    i64 g = gcd(a,b);
    auto pm = pfact(g);
    cout << pm.size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

lis=[]
for i in range(0,n-1):
  if a[i]==a[i+1]-1:
    lis.append(a[i])
plus=0
for j in range(0,len(lis)):
  plus+=c[lis[j]-1]
print(sum(b)+plus)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  bool second_win = true;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 2 == 1)
      second_win = false;
  }
  puts(second_win ? "second" : "first");
  return 0;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
ans=0
for i in range(4):
    if (A+i)%4==0:
        break
    ans=ans^(A+i)
for i in range(B-3,B+1):
    if i%4==3:
        end=i+1
        break
for i in range(end,B+1):
    ans=ans^i
print(ans)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int y = input.nextInt();
        String ans = "No";
        for (int i = 0; i < x+1; i++){
            if (i*2 + (x-i)*4 == y){
                ans = "Yes";
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35600
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <list>


constexpr int INF = 1050000000;
constexpr int MOD = 1000000007;
constexpr long long LONGINF = 1005000000000000000;
using namespace std;

using ll = long long;


int main() {
	int w, h; cin >> w >> h;
	int n; cin >> n;
	int a[10005];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int x = 0;

	int ans[100][100];

	for (int i = 0; i < w; i++) {
		if (i & 1) {
			for (int j = 0; j < h;) {
				while (j < h&&a[x]) {
					ans[i][j] = x + 1;
					j++; a[x] -= 1;
				}
				if (a[x] < 1) { x++; }
			}
		}
		else {
			for (int j = h-1; j >= 0;) {
				while (j >= 0&&a[x]) {
					ans[i][j] = x + 1;
					j--; a[x] -= 1;
				}
				if (a[x] < 1) { x++; }
			}
		}
	}

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h-1; j++) {
			cout << ans[i][j]<<" ";
		}
		cout << ans[i][h - 1] << endl;
	}

}

Measured memory_bytes: 384
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
cnt = 0

for i in range(n):
    a = list(map(int, input().split()))
    tmp = 0
    for j in range(m):
        tmp += a[j]*b[j]
    if tmp + c > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 9188
maxx = 2000001;
maxnum = 10010;

n=int(input())
A=[int(x) for x in input().split()]  
A.insert(0,0) 
B=[-1 for x in range(n)]
C=[0 for x in range(maxnum)]



for a in A[1:]:
    C[a]+=1
for i in range(1,maxnum): # 累加和
    C[i]+=C[i - 1]
    
for j in range(1,n+1):
    B[C[A[j]]-1]=A[j]
    C[A[j]]-=1

lens=len(B)    
for i in range(0,lens-1):
    print(B[i],end=' ')
print(B[lens-1])


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

int main()
{
	int x,y,z;
	scanf("%d %d %d",&x,&y,&z);
	int ans=0;
	x=x-z;
	while(x>=y+z)
	{
		x=x-y-z;
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		P[] p = new P[N];
		for (int i = 0; i < N; ++i) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			p[i] = new P(a, b);
		}
		Arrays.sort(p);
		int[][] dp = new int[N + 1][N + 1];
		final int INF = 1 << 30;
		for (int[] a : dp) {
			Arrays.fill(a, INF);
		}
		dp[0][0] = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (dp[i][j] != INF) {
					dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);
					if (dp[i][j] + p[i].a <= p[i].b) {
						dp[i + 1][j + 1] = Math.min(dp[i + 1][j + 1], dp[i][j] + p[i].a);
					}
				}
			}
		}
		int ans = 0;
		for (int i = 0; i <= N; ++i) {
			for (int j = 0; j <= N; ++j) {
				if (dp[i][j] != INF) {
					ans = Math.max(ans, j);
				}
			}
		}
		System.out.println(ans);
	}

	static class P implements Comparable<P> {
		int a, b;

		P(int a, int b) {
			this.a = a;
			this.b = b;
		}

		public int compareTo(P o) {
			return this.b - o.b;
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  vector<vector<int>> c(310,vector<int>(310));
  ll ans=0;
  rep(i,n)rep(j,n){ cin>>c[i][j]; ans+=c[i][j]; }

  rep(i,n)rep(j,n){ 
    bool flag=false;
    rep(k,n)if(i!=j && i!=k && j!=k){
      if(c[i][j]>c[i][k]+c[k][j]){ cout << -1 << endl; return 0; }
      if(c[i][j]==c[i][k]+c[k][j] && !flag){ ans-=c[i][j]; flag=true; continue; }
    }
  }
  cout << ans/2 << endl; 
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll c[100000];
int main(void){
  ll n,m,cnt=0;
  scanf("%lld %lld",&n,&m);
  for(ll i=1;i<=sqrt(m);i++){
    if(m%i<1){
      c[cnt++]=i;
      c[cnt++]=m/i;
    }
  }
  qsort(c,cnt,sizeof(ll),d);
  FOR(cnt){
    if(c[i]<=m/n){
      PRL(c[i]);
      break;
    }
  }
  return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int L = -1;
  int sl = s.length();
  int tl = t.length();
  for (int i = 0; i < sl-tl+1; i++) {
    for (int j = 0; j < tl; j++) {
      if (s[i+j] != t[j] && s[i+j] != '?') break;
      else if (j == tl-1) L = i;  
    }
  }
  if (L == -1) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for (int i = L; i < L+tl; i++) s[i] = t[i-L];

  for (int i = 0; i < sl; i++) {
    if (s[i] == '?') s[i] = 'a';
  }
  cout << s << endl;
}

Measured memory_bytes: 3576
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 0

def insertionSort(g):
  global cnt
  for i in range(1, n):
    v = a[i]
    j = i-g
    while j>=0 and a[j]>v:
      a[j+g] = a[j]
      j -= g
      cnt += 1
    a[j+g] = v

def shellSort():
  m = len(a)//2
  g = [m]
  while m>1:
    m = m//2
    g.append(m)
  print(len(g))
  print(" ".join(map(str, g)))
  for ele in g:
    insertionSort(ele)

shellSort()
print(cnt)
for ele in a:
  print(ele)


Measured memory_bytes: 45512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll mod=998244353;

ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
ll c(ll n,ll r){
    ll res=1;
    for(ll i=1;i<=r;i++)res=res*power(i,mod-2)%mod *(n-i+1) %mod;
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m,k;cin>>n>>m>>k;
    ll ans=0;ll cur=1;
    for(int i=0;i<=k;i++){
       // cout<<c(n-1,i)<<' '<<m<<' '<<power(m-1,n-i-1)<<endl;
        ans+=(cur%mod) *m %mod *power(m-1,n-i-1);
        ans%=mod;
        cur=(cur*(n-1-i)%mod)*power(i+1,mod-2) %mod;
    }
    cout<<ans;
    
}

Measured memory_bytes: 3652
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, m; cin>>n>>m;
    priority_queue<ll> que;
    for(int i=0; i<n; i++){
        ll a; cin>>a;
        que.emplace(a);
    }

    for(int i=0; i<m; i++){
        ll num = que.top(); que.pop();
        que.emplace(num / 2);
    }

    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += que.top(); que.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
H,W = map(int,input().split())
listAl = [chr(i) for i in range(65,65+26)]
ans = 0
# main
for i in range(H):
    listSnuke = [i for i in input().split()]
    if "snuke" in listSnuke:
        ans = listAl[listSnuke.index("snuke")] + str(i + 1)
        break
print(ans)

Measured memory_bytes: 3060
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

k=int(input())
ans=0
for i in range(k):
    for j in range(k):
        for l in range(k):
            ans+=gcd(gcd(i+1,j+1),l+1)
print(ans)

Measured memory_bytes: 68428
"use strict";
const Main = (input) =>{
	let xs = input.trim().split('\n');    
    let A = xs[0].trim().split(' ').map(v=>parseInt(v,10));
    //console.log(A);
    let B = xs[1].trim().split(' ').map(v=>parseInt(v,10));
    //console.log(B);
    if(A[0] > B[0]){
      console.log('GREATER');
    }else if(B[0] > A[0]){
      console.log('LESS');
    }else{
      console.log('EQUAL');
    }
  }
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

int main() {
    int K;
    cin >> K;
    vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << vec[K - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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 <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 <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n;
  cin >> n;

  vector<int> a(n);
  vector<int> b(n);
  rep(i,n) cin >> a[i] >> b[i];

  int64_t res = 0;
  rrep(i,n,0) {
    int64_t nex = (res+a[i]) % b[i];
    if(nex != 0) res += b[i]-nex;
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#define lli long long int

using namespace std;

const lli inf = 1000000000;

lli dij(lli cost[101][101], int n, int s, int t)
{
  lli d[101];
  bool vis[101];
  
  fill(vis, vis+(n+1), false);
  fill(d, d+(n+1), inf);
  d[s] = 0;
  
  while(1){
    int v = -1;
    for(int i = 1; i <= n; i++){
      if(!vis[i] && (v == -1 || d[i] < d[v])){
	v = i;
      }
    }
    if(v == -1){
      break;
    }
    vis[v] = true;
    for(int i = 1; i <= n; i++){
      d[i] = min(d[i], d[v]+cost[v][i]);
    }
  }
  
  return d[t];
}

int main()
{
  int n, m, s, t;
  lli a[101][101], u;
  
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0){
      break;
    }
    fill(&a[1][1], &a[n][n], inf);
    for(int i = 1; i <= n; i++){
      a[i][i] = 0;
    }
    
    while(m--){
      cin >> s;
      if(s == 1){
	cin >> s >> t >> u;
	if(a[s][t] > u){
	  a[s][t] = a[t][s] = u;
	}
      } else {
	cin >> s >> t;
	u = dij(a, n, s, t);
	if(u >= inf){
	  u = -1;
	}
	cout << u << endl;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 948
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int height = sc.nextInt();
    int width = sc.nextInt();

    int area = calculateArea(height, width);
    int circumference = calculateCircumference(height, width);
    System.out.println(String.format("%d %d", area, circumference));
  }

  /**
  * ??¢???????±???????????????????
  * @param height ??????
  * @param width ???
  * @return ??¢???
  */
  private static int calculateArea(int height, int width) {
    return height * width;
  }

  /**
  * ??¨?????????????±???????????????????
  * @param height ??????
  * @param width ???
  * @return ??¨?????????
  */
  private static int calculateCircumference(int height, int width) {
    return (height + width) * 2;
  }
}

Measured memory_bytes: 26168
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        String p = scan.nextLine();

        String ans = s + s.substring(0, p.length());

        if (ans.indexOf(p) >= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26008
from collections import Counter

S = input()

if len(set(S)) == 1:
    print("YES" if len(S) == 1 else "NO")
elif len(set(S)) == 2:
    print("YES" if len(S) <= 2 else "NO")
else:
    c = Counter(S)
    print("YES" if max(c["a"], c["b"], c["c"]) - min(c["a"], c["b"], c["c"]) <= 1 else "NO")

Measured memory_bytes: 3444
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
using ll = long long;
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);

}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	llint ans = 0, n = 0, m = 0, count = 0, sum = 0;
	llint k, a, b,d;
	bool check = false;
	string ss;
	vector<llint> array;
	cin >> n >> k;
	vector<bool> bo(n,false);
	rep(i, k) {
		cin >> d;
		rep(j, d) {
			cin >> a;
			bo.at(a - 1) = true;
		}
	}
	rep(i, n)if (bo.at(i) == false)ans++;
	cout << ans << endl;
	please AC;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

int main(){
  int N, M;cin>>N>>M;
  vll X, Y,Z;
  for (int i=0;i<N;++i){
    ll x, y, z;cin>>x>>y>>z;
    X.push_back(x);Y.push_back(y);Z.push_back(z);
  }
  ll ans=0;
  vi sgn={-1,1};
  for (int i=0;i<2;++i){
    for (int j=0;j<2;++j){
      for (int k=0;k<2;++k){
        vll S;
        for (int n=0;n<N;++n){
          S.push_back(X[n]*sgn[i]+Y[n]*sgn[j]+Z[n]*sgn[k]);
        }
        sort(S.begin(), S.end(), greater<ll>());
        ll tmp=0;
        for (int n=0;n<M;++n){
          tmp+=S[n];
        }
        ans=max(ans, tmp);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N;
	
	cin >> N;
	
	int ans = 0;
	for(int i=1; i<=N; i++){
		if((1 <= i && i <= 9) || (100 <= i && i <= 999) || (10000 <= i && i <= 99999))
			ans++;
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1,v2;
		v1.push_back(0);
		for(v1.push_back(r);m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
//			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
//			v2.push_back(0);
			v2.insert(v2.end(),ity-v1.begin()&1?1:2,0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1])it+=2;
			if(*it+n-x==v2.back()){++it;v2.pop_back();}
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
		for(x=0;*it<q;++it)
			m=*it++,x+=*it-m;
	}
}

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

int n,a,b;

void work()
{
	scanf("%d %d %d",&n,&a,&b);
	if (a>b)  printf("0");
	else  if (n==1)  printf("%d",a==b);
	else  printf("%lld",1LL*(n-2)*(b-a)+1);
}

int main()
{
	work();
	return 0;
}


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

int main(){
  int l, m, n;

  while(cin >> l, l){
    int ans = -1;

    for(int i = 0; i < 12; i++){
      int m, n;
      cin >> m >> n;

      if(ans != -1) continue;

      l -= m - n;

      if(l <= 0){
        ans = i + 1;
      }
    }

    if(ans == -1){
      cout << "NA\n";
    }
    else{
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N;
    cin >> N;
    map<char,int> mp;
    string S, T;
    cin >> S;
    REP(int,j,0,S.size()) mp[S.at(j)]++;
    REP(int,i,1,N){
        map<char,int> mp1;
        cin >> S;
        REP(int,j,0,S.size()) mp1[S.at(j)]++;
        for ( auto&x : mp ){
            mp[x.first] = min( mp1[x.first], x.second );
        }
        //for ( auto&x : mp1 ) cout << mp[x.first] << endl;
    }
    for ( auto&x : mp ){
        REP(int,i,0,x.second) T += x.first;
    }
    cout << T << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

from collections import Counter

ctr = Counter(s)
sorted(ctr.most_common(), key=lambda x: x[1], reverse=True)
mx = sorted(ctr.most_common(), key=lambda x: x[1], reverse=True)[0][1]
li = []
for k, v in sorted(ctr.most_common(), key=lambda x: x[1], reverse=True):
    if v == mx:
        li.append(k)

li.sort()
for val in li:
    print(val)


Measured memory_bytes: 126416
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        l:i64,
        r:i64,
    }
    let mut ans = std::i64::MAX;
    if r - l >= 2019 {
        ans=0;
    }else{
        for i in l..r+1 {
            for j in l..r+1 {
                if i<j {
                    
                        ans = std::cmp::min(ans, (i*j)%2019);
                    
                }
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
def f(n):
	s = 1
	for i in range(1, n + 1):
		s = (s * i) % int(10e8 + 7)
	return s

a, b = map(int, raw_input().split())

if a == b:
	print int((2 * f(a) * f(a)) % int(10e8 + 7))
elif (a - b == 1) or (b - a == 1):
	print int((f(a) * f(b)) % int(10e8 + 7))
else:
	print 0

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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

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

const int N = (int)2e5 + 123, inf = 1e9;
const ll INF = 1e18;
int n, ans, a[N];
bool used[N];
void check(int x){
	map<int, vector< int > > last;
	for(int i = 0; i < n; i++){
		if(used[i] || a[i] >= x)
			continue;
		if(!last[x - a[i]].empty()){
			ans++;
			used[i] = 1;
			used[last[x - a[i]].back()] = 1;
			last[x - a[i]].pop_back();
		}else
			last[a[i]].pb(i);
	}
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for(int i = 30; i >= 0; i--)
		check(1 << i);
	printf("%d", ans);
	return 0;
}



Measured memory_bytes: 38656
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <math.h>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(void){
    string s, t = "keyence";
    cin >> s;
    
    int f = 0, l = 0;
    for (int i = 0; i < 7; i++) {
        if (s[i] == t[i]) f++;
        else break;
    }
    
    for (int i = 0; i < 7; i++) {
        if (s[s.size() - 1 - i] == t[6 - i]) l++;
        else break;
    }
    
    if (f + l >= 7 || s == t) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}


Measured memory_bytes: 256
import java.io.*;
 
public class Main {
  public Main() {
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String str = br.readLine();
      System.out.println(str.replace("apple", "xxxxx").replace("peach", "apple").replace("xxxxx", "peach"));
      br.close();
    } catch(IOException e) {
      System.out.println(e.getMessage());
    }
  }
 
  public static void main(String[] args) {
    new Main();
  }
}

Measured memory_bytes: 24256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int t1 = M1 + 60*H1;
    int t2 = M2 + 60*H2;
    cout << t2-t1-K << "\n";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  if (a*b <= 0) {
    cout << "Zero" << endl;
  } else if (a > 0 || (b-(a-1)) % 2 == 0) {
    cout << "Positive" << endl;
  } else {
    cout << "Negative" << endl;
  }
}


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

const double PI=acos(-1.0);

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

    int res10000 = -1, res5000 = -1, res1000 = -1;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; i + j <= n; j++) {
            int k = n - i - j;
            int sum = 10000*i + 5000*j + 1000*k;
            if(y == sum) {
                res10000 = i;
                res5000 = j;
                res1000 = k;
            }
        }
    }

    cout << res10000 << " " << res5000 << " " << res1000 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b =sc.nextInt(),m=sc.nextInt();
        int[] an = new int[a];
        int[] bn = new int[b];
        int[] x = new int[m];
        int[] y = new int[m];
        int[]c = new int[m];
        for(int i = 0;i<a;i++){
            an[i] = sc.nextInt();
        }
        for(int i = 0;i<b;i++){
            bn[i] = sc.nextInt();
        }
        for(int i = 0;i<m;i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        int ans = 1001001001;
        for(int i=0;i<m;i++){
            int tmp = an[x[i]-1]+bn[y[i]-1]-c[i];
            ans = Math.min(ans,tmp);
        }
        Arrays.sort(an);
        Arrays.sort(bn);
        ans = Math.min(ans,an[0]+bn[0]);
        System.out.println(ans);
    }
}

Measured memory_bytes: 134408
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <cassert>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

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

    vector<int> ans(N + 1);
    vector<vector<int>> g(N + 1);

    while (M--) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    queue<int> Q;
    vector<bool> used(N + 1);
    used[1] = true;
    for (Q.push(1); !Q.empty(); Q.pop()) {
        auto el = Q.front();
        for (auto v : g[el]) {
            if (!used[v]) {
                ans[v] = el;
                used[v] = 1;
                Q.push(v);
            }
        }
    }

    cout << "Yes\n";
    for (int i = 2; i <= N; i++)
        cout << ans[i] << "\n";

    return 0;
}


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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i1=0;i1<n;i1++){
        cin>>a[i1];
    }
    sort(a,a+n);
    int ans=0;
    for(int i1=0;i1<k;i1++){
        ans+=a[i1];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3628
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,K; R(N,K);
    int an=0;
    FOR(i,1,N){
        int x;
        R(x);
        an+=(x>=K);
    }
    W(an);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
alphabet = [chr(i) for i in range(97, 97+26)]
num = list()
ans = ""

for j in range(0, 26):
	for i in range(0, n):
		num.append(50)
		if list(s[i]).count(alphabet[j]) < num[j]:
			num[j] = s[i].count(alphabet[j])
	for k in range(num[j]):
		ans += alphabet[j]
print(ans)

Measured memory_bytes: 3064
(defn input []
  (let [[N M] (->> (clojure.string/split (read-line) #"\s")
                (map #(Integer/parseInt %)))]
    (list N M
      (->> (repeatedly M read-line)
        (into []
          (comp (map #(clojure.string/split % #"\s"))
            (map (partial mapv #(Integer/parseInt %)))))))))

(defn CoutningRoads ^"[S" [[N M Rs]]
  (let [Array (short-array N (short 0))]
    (doseq [r Rs
            :let [[id1 id2] (map dec r)]]
      (do
        (->> (aget ^"[S" Array id1)
          inc
          short
          (aset ^"[S" Array id1))
        (->> (aget ^"[S" Array id2)
          inc
          short
          (aset ^"[S" Array id2))))
    Array))


(->> (input)
  CoutningRoads
  (map #(printf "%s\n" %))
  (apply str)
  print)

Measured memory_bytes: 87648
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;

bool check( const vector < int > data){
  for(int i = 1 ; i < 10 ; i++ ){
    if(data[i] >= 2){
      vector< int > vc(data);
      bool flag = true;
      vc[i] -= 2;
      for(int j = 1 ; j < 10 ; j++ ){
        while( vc[j] % 3 != 0){
          for(int k = 0 ; k < 3 ; k++ ){
            vc[k + j]--;
            if(vc[k + j] < 0) flag = false;
          }
        }
      }
      if(flag) return true;
    }
  }
  return false;
}

int main(){
  string s;
  while(cin >> s){
    string ret;
    vector< int > num(15,0);

    for(int i = 0 ; i < 13 ; i++ ){
      num[s[i] - '0']++;
    }

    for(int i = 1 ; i < 10 ; i++ ){
      num[i]++;
      if(num[i] < 5 && check(num)) ret += i + '0';
      num[i]--;
    }
    for(int i = 0 ; i < ret.size() ; i++ ){
      cout << (i ? " " : "" ) << ret[i];
    }
    if(ret.empty()) cout << 0;
    cout << endl;
  }
}

Measured memory_bytes: 1204
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String T = sc.next();
		String ans = null;

		for (int i = S.length() - T.length(); i >= 0; i--){
			String part = S.substring(i, i + T.length());
			boolean match = true;
			for (int j=0; j < part.length(); j++){
				if (part.charAt(j) != '?' && part.charAt(j) != T.charAt(j)){
					match = false;
					break;
				}
			}
			if (match){
				StringBuilder sb = new StringBuilder();
				sb.append(S);
				sb.replace(i, i+T.length(), T);
				ans = sb.toString().replace("?", "a");
				break;
			}
		}

		if (ans == null){
			ans = "UNRESTORABLE";
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, m; std::cin >> n >> m;
    std::vector<std::pair<int, int>> ans;
    if (n & 1) {
        for (int i = 0; i < m; i++)
            ans.emplace_back(i + 1, n - i);
    }
    else {
        for (int i = 0; i < m; i++) {
            if (i & 1) ans.emplace_back(
                n / 2 + 1 + i / 2, n - 1 - i / 2);
            else ans.emplace_back(
                1 + i / 2, n / 2 - i / 2);
        }
    }
    for (auto &p : ans)
        std::cout << p.first << " " << p.second << std::endl;
    return 0;
}


Measured memory_bytes: 4332
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int a, b, ans = 0;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        string t = to_string(i);
        if ((t[0] == t[4]) && t[1] == t[3])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int main() {
	string s;
	cin >> s;
	bool a = false, b = false;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'A') {
			a = true;
		}
		if (s[i] == 'B') {
			b = true;
		}
	}
	if (a && b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def make(n, now):
    global cnt, k
    # print(n, now, cnt)
    if n == 0:
        cnt += 1
        if cnt == k:
            return now
        return
    # print(n, now, cnt)
    for i in range(max(0, now[-1] - 1), min(10, now[-1] + 2)):
        ans = make(n - 1, now + [i])
        if ans:
            return ans


k = int(input())
cnt = 0
n = 0
ans = [1]
while cnt < k:
    for i in range(1, 10):
        ans = make(n, [i])
        if ans:
            break
    n += 1
# print(ans)
for i in ans:
    print(i, end = "")

Measured memory_bytes: 59996
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	sc.Split(bufio.ScanWords)
	p := nextInts(n)

	// search
	sum := 0
	ans := 0.0
	for i := 0; i < n; i++ {
		sum += p[i]
		if i < k-1 {
			continue
		} else if i > k-1 {
			sum -= p[i-k]
		}
		tmp := float64(sum+k) / 2.0 // k範囲の累積和
		if ans < tmp {
			ans = tmp
		}
	}
	fmt.Printf("%.12f", ans)
}


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

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

    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int r=0;
    r+=a[2]-a[1];
    a[1]+=r;
    a[0]+=r;
    //cout<<a[0]<<a[1]<<a[2]<<r<<endl;
    if((a[2]-a[0])%2==0)
        cout<<(a[2]-a[0])/2+r<<endl;
    else
        cout<<(a[2]-a[0])/2+r+2<<endl;

    return 0;
}


Measured memory_bytes: 3624