akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		s.nextLine();
		int[][] a = new int[N][3];
		String str ;
		String[] result;
		
	
		for(int i = 0;i <N;i++)
		{
			result = s.nextLine().split(" ");
			for(int j = 0; j < a[i].length;j++)
			{
				a[i][j] = Integer.parseInt(result[j]);
			}
			Arrays.sort(a[i]);
		}
		
		for(int i = 0;i<N;i++)
		{
			if(a[i][1]*a[i][1]+a[i][0]*a[i][0]-a[i][2]*a[i][2]==0)
			{
				str = "YES";
			}else{
				str = "NO";
			}
			System.out.println(str);

		}
	}
}

Measured memory_bytes: 32280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,d,a;
	cin>>n>>d>>a;
	vector<pair<ll,ll>>ch;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		ch.push_back(make_pair(x,y));
	}
	sort(ch.begin(),ch.end());
	queue<pair<ll,ll>>q;
	ll ans=0;
	ll dm=0;
	for(ll i=0;i<n;i++){
		ll nowx=ch[i].first;
		while(q.size()!=0&&q.front().first<nowx){
			dm-=q.front().second;
			q.pop();
		}
		ch[i].second-=dm;
		if(ch[i].second>0){
			ans+=(ch[i].second+a-1)/a;
			ll dm1=((ch[i].second+a-1)/a)*a;
			dm+=dm1;
			q.push(make_pair(nowx+2*d,dm1));
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 6128
#include <stdio.h>
int main(){
  int n, m, A[1024][1024], b[1024],i,j,c[1024];
  scanf("%d %d",&n, &m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d", &A[i][j]);

    }
  }
  for(j=0;j<m;j++){
    scanf("%d", &b[j]);
  }
  for(i=0;i<1024;i++){
    c[i] = 0;
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      c[i] += A[i][j] * b[j];
    }
  }
  for(i=0;i<n;i++){
    printf("%d\n", c[i]);
  }


  return 0;
}



Measured memory_bytes: 2124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        long ans = 0;
        if((a + b) > 2 * c) {
            int m = Math.min(x, y);
            ans += m * 2 * c;
            x -= m;
            y -= m;
            if(x > 0 && a > 2 * c) {
                ans += x * 2 * c;
                y -= x;
            } else if(x > 0) ans += x * a;
            if(y > 0 && b > 2 * c) {
                ans += y * 2 * c;
                x -= y;
            } else if(y > 0) ans += y * b;
        }
        else if(a > 2 * c) {
            ans += x * a;
            y -= x;
            if(y > 0) ans += y * b;
        }
        else if(b > 2 * c) {
            ans += y * b;
            x -= y;
            if(x > 0) ans += x * a;
        }
        else ans += x * a + y * b;

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = input()
def point(hand):
  if(hand == "r"):
    return P
  elif(hand == "s"):
    return R
  else:
    return S
ans = 0
lose = [0] * N
for i in range(K):
  ans += point(T[i])
for i in range(K,N):
  if((T[i] != T[i-K]) or (lose[i-K] == 1)):
    ans += point(T[i])
  else:
    lose[i] = 1
print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int h, w;
    cin >> h >> w;
    vector<string> pixels(h);
    rep(i, h) cin >> pixels[i];
    rep(i, h) rep(_, 2) cout << pixels[i] << endl;
}

Measured memory_bytes: 3680
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}




void solve(long long N){
  ll n = N/10;
  ll ans = n;
  if(N%2==1) {
    std::cout << 0 << std::endl;
    return;
  }
  while(n>=5) {
    n = n/5;
    ans+= n;
  }
  // ll i=1;
  // while(N/(50*i)!=0) {
  //   ans+=ceil((double)(N/(50*i))/(double)2);
  //   i*=10;
  // }
  // std::cout << ceil((double)(360/50)/(double)2) << std::endl;

  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}



Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp =[0 for _ in range(n)]
for i in range(1, n):
    if i >= 2:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    else:
        dp[i] = abs(h[i]-h[i-1])
print(dp[n-1])

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

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 XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

/*int ter_search(int l,int r)
{
    while((r-l)>0)
    {
        int m1=l+(r-l)/3;
        int m2=r-(r-l)/3;
        int f1=f(m1);
        int f2=f(m2);
        if(f1>f2)
         l=m1+1;
         else
          r=m2-1;
    }
    return f(l);
}*/

int n;

int fun(int l,int num,int c3,int c5,int c7)
{
    if(l==0)
    {
        return 0;
    }
    int res=0;
    int a=num*10+3;
    int b=num*10+5;
    int c=num*10+7;
    if(a<=n)
    res=res+fun(l-1,a,c3+1,c5,c7)+((c5>0)&&(c7>0));
    if(b<=n)
    res=res+fun(l-1,b,c3,c5+1,c7)+((c3>0)&&(c7>0));
    if(c<=n)
    res=res+fun(l-1,c,c3,c5,c7+1)+((c3>0)&&(c5>0));
    return res;
}

int32_t main()
{
  fast;
    cin>>n;
    int len=0;
    int c=n;
    while(c)
    {
        len++;
        c/=10;
    }
    //cout<<len<<"\n";
    if(len<3)
    {
        cout<<0<<"\n";
    }
    else
    {
        cout<<fun(len,0,0,0,0);
    }
     return 0;
}

Measured memory_bytes: 3672
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = int(input())
    sub_val = 10 ** 18 - s

    x1 = 0
    y1 = 0
    x2 = 0
    y2 = 10 ** 9
    x3 = 10 ** 9
    y3 = 0

    sub_y2 = sub_val // 10 ** 9
    y2 = y2 - sub_y2
    sub_y3 = sub_val % 10 ** 9
    if sub_y3 != 0:
        y3 = 1
        x2 = sub_y3
    print(x1, y1, x2, y2, x3, y3)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
   long long  int x,y;
    cin >> x >> y;
    long long int ans = 0;
    ans = x * (y + 1);
    if(ans%x==0 && ans%y!=0){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main( void ) {
    int h, w;
    std::cin >> h >> w;

    std::vector< std::string > lines;

    for( size_t y = 0; y < h; ++y ) {
        std::string line;
        std::cin >> line;
        lines.push_back( line );
    }

    std::cout << std::string(w+2, '#') << std::endl;
    for( size_t y = 0; y < h; ++y ) {
        std::cout << '#' << lines[ y ] << '#' << std::endl;
    }
    std::cout << std::string(w+2, '#') << std::endl;

    return 0;
}

Measured memory_bytes: 256
I=lambda:map(int,input().split())
N=0xfffff
n,q=I()
c=list(I())
Q=[]
for i in range(q):l,r=I();Q.append(l<<40|r<<20|i)
Q.sort()
A=[[]for i in range(N)]
for i,x in enumerate(c):A[x].append(i)
B=[0]*N
def P(i,x):
	i+=1
	while i<=n:B[i]+=x;i+=i&-i
def G(i):
	s=0
	while i:s+=B[i];i-=i&-i
	return s
for i in A:
	if i:P(i[0],1);i.reverse()
t=0
o=[0]*q
for x in Q:
	l=x>>40
	r=x>>20&N
	i=x&N
	while t+1<l:
		b=A[c[t]]
		P(b[-1],-1)
		b.pop()
		if b:P(b[-1],1)
		t+=1
	o[i]=G(r)-G(l-1)
for i in o:print(i)

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


int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
  int n;
	cin >> n;
  if(n & 1) {
    cout << 0 << '\n';
    return 0;
  }
  int ans = 0;
  int p = 10;
  for(int d = 10, add = n / d; add; ) {
    ans += add;
    d *= 5;
    add = n / d;
  }
  cout << ans << '\n'; 
}

Measured memory_bytes: 256
fun main() {
    val (n, _) = readLine()!!.split(" ").map { it.toInt() }
    val ais = readLine()!!.split(" ").map { it.toInt() }
    val amount = ais.sum()
    println(if (n < amount) {
        -1
    } else {
        n - amount
    })
}


Measured memory_bytes: 39416
#include <iostream>
#include <vector>
#include <cassert>
#include <utility>
using namespace std;
typedef pair<int,int> pii;
#define repeat(i,n) for (int i = 0; i < n; ++i)
#define repeat_from(i,m,n) for (int i = m; i < n; ++i)

#define MAX_N 100000
#define MAX_M 100000
int N, M;

pii tree[MAX_N];
void init_tree(int n) { repeat (i,n) { tree[i] = pii(i,0); } }
pii find_root(int a) {
    /*   d1   d2
     * a -> b -> c
     *
     *   d1+d2
     * +---------+
     * |      d2 v
     * a -> b -> c
     */
    if (tree[a].first != a) {
        pii pb = find_root(tree[a].first);
        tree[a].first = pb.first;
        tree[a].second += pb.second;
    }
    return tree[a];
}
void union_tree(int a, int b, int w) {
    /*    d1
     *  a -> ra
     * w|     | d3
     *  v d2  v   (w + d2 = d1 + d3)
     *  b -> rb
     */
    pii ra = find_root(a), rb = find_root(b);
    if (ra.first != rb.first) {
        tree[ra.first].first = rb.first;
        tree[ra.first].second = w + rb.second - ra.second;
    } else {
        assert(ra.second - rb.second == w);
    }
}

int main(void) {
    while (true) {
        cin >> N >> M; cin.ignore();
        if (not N or not M) break;
        init_tree(N);
        repeat (i,M) {
            char c; cin >> c;
            if (c == '!') {
                int a, b, w; cin >> a >> b >> w; cin.ignore(); -- a; -- b;
                union_tree(a,b,w);
            } else if (c == '?') {
                int a, b; cin >> a >> b; cin.ignore(); -- a; -- b;
                pii ra = find_root(a), rb = find_root(b);
                if (ra.first == rb.first) {
                    cout << ra.second - rb.second << endl;
                } else {
                    cout << "UNKNOWN" << endl;
                }
            } else {
                assert(false);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2980
n=int(input())
arr=list(map(int,input().split()))
s=0
r=0
ans=0
for l in range(n):
  while r<n:
    if s&arr[r]!=0:
      break
    else:
      s+=arr[r]
      r+=1
  ans+=r-l
  s-=arr[l]  
print(ans)

Measured memory_bytes: 24840
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  long long ret = 0;
  for(int i=1; i<=N; i++){
    int sum = (i/10000)%10 + (i/1000)%10 + (i/100)%10 + (i/10)%10 + (i/1)%10;
    if(sum >= A && sum <= B)
      ret += i;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double sa = max(30*h+m/2.0,6*m)-min(30*h+m/2,6*m);
    double rad = sa*M_PI/180.0;
    printf("%.20f\n",sqrt(a*a+b*b-2*a*b*cos(rad)));
}


Measured memory_bytes: 4248
N = int(input())
ans = [0] * (N + 1)
for i in range (1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      n = i*i+j*j+k*k+i*j+j*k+k*i
      if n <= N:
        ans[n] += 1

print(*ans[1:], sep='\n')



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

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

int main() {
  int A,B;
  cin >> A >> B;
    
  int ans = 0;
  rep(i,LoopMAX){
    if(A + (A - 1) * (i - 1) >= B){
      ans = i;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var h = cin.nextInt();
            var m = cin.nextInt();
                        
            var Mk = (360.0 / 60.0) * m;
            var Hk = (360.0 / 12.0) * h + (30.0 * (m/60.0));

            var cos = Math.Max(Hk, Mk) - Math.Min(Hk, Mk);
            cos = Math.Min(cos, 360 - cos);
            var cc = Math.Pow(a, 2) + Math.Pow(b, 2) - ((2 * a * b) * Math.Cos(cos * Math.PI / 180));
            Console.WriteLine(Math.Sqrt(cc));        
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

const bool DEBUG = false;

int N, M;

void input() { cin >> N >> M; }

int main(int argc, char const *argv[]) {
  input();
  cout << max((N * (N - 1)) / 2, 0) + max((M * (M - 1)) / 2, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
import math

N, M = map(int, input().split())

def mod(num):
    return num % (10 ** 9 + 7)

def calc():
    dp[1] = 1
    for i in range(2, maxmn + 1):
        dp[i] = mod(dp[i-1] * i)

absnm = abs(N - M)

maxmn = max(N, M)
dp = [0]*(maxmn + 1)

if absnm > 1:
    print(0)

else:
    calc()

    if absnm == 1:
        r = mod(dp[M] * dp[N])

    elif absnm == 0:
        r = mod(dp[M] * dp[N] * 2)

    else:
        r = 0

    print(r)

Measured memory_bytes: 12636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
 
template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );
 
const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
 
int main( void ){
	int N, A;
	cin >> N >> A;
	N%=500;
	if (N <= A)
		cout << "Yes\n";
	else
		cout <<"No\n";
}
 
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}

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

ll N, arr[MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> arr[i];
		sum += 2*arr[i];
	}
	sort(arr, arr+N, greater<long>());
	
	ll ans = -1;
	if (N&1) {
		ll cur = sum;
		for (int i = N/2+2; i < N; i++) {
			cur -= 4*arr[i];
		}
		cur -= 3*(arr[N/2] + arr[N/2+1]);
		ans = cur;
		cur = sum;
		for (int i = N/2+1; i < N; i++) {
			cur -= 4*arr[i];
		}
		cur -= arr[N/2-1] + arr[N/2];
		ans = max(ans, cur);
	} else {
		ll cur = sum;
		for (int i = N/2+1; i < N; i++) {
			cur -= 4*arr[i];
		}
		cur -= arr[N/2-1] + 3*arr[N/2];
		ans = cur;
	}
	cout << ans << "\n";
}


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

using namespace std;
int main (){
    int x;
    cin >> x;
    bool flag=true;
    while (flag){
        flag=false;
        for (int i = 2; i*i <x ; i++){
            if(x%i==0) flag=true;
        }
        x++;
    }
    cout << x-1 << "\n";
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong x;
    cin >> x ;
    if(x==0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3224
using System;
using static System.Console;
using static System.Math;

namespace Main
{
    class mymath
    {
        public bool isreversible(char[] a)
        {
            int M = a.Length;
            bool r = true;
            for (int i = 0; i < M / 2; i++)
            {
                if (a[i] != a[M - i - 1])
                {
                    r = false;
                }
            }
            return r;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            char[] S = ReadLine().ToCharArray();
            int N = S.Length;
            int M = (N - 1) / 2;
            int L = (N + 3) / 2;
            char[] S2 = new char[M];
            char[] S3 = new char[N - L + 1];
            Array.Copy(S, 0, S2, 0, M );
            Array.Copy(S, L - 1, S3, 0, N - L + 1);
            var mm = new mymath();

            if(mm.isreversible(S) && mm.isreversible(S2) && mm.isreversible(S3))
            {
                WriteLine("Yes");
            }
            else
            {
                //WriteLine(string.Join("",S2));
                //WriteLine(string.Join("", S3));
                WriteLine("No");
            }
        }
    }
}

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

int main(){
  int N;
  cin >> N;
  int i = N%10;
  if(i==3){
    cout << "bon" << endl;
  }else if(i==0 || i==1 || i==6 || i==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i++){
    cin >> mochi.at(i);
  }
  int max_val = 200;
  int ret = 0;
  int cur_val = 0;
  
  while (1){
    cur_val = 0;
    for (int i = 0; i < N; i++){
      if (mochi.at(i) > cur_val && mochi.at(i) < max_val){
        cur_val = mochi.at(i);
      }
    }
    if (cur_val == 0){break;}
    ret++;
    max_val = cur_val;
  }
  cout << ret << endl;
}

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

ll mul(ll a, ll b) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) {
            r = (r + a) % mod;
        }
        a = (a + a) % mod;
        b /= 2;
    }
    return r;
}

ll power(ll x, ll n) {
    ll res = 1;
    x %= mod; 
    while (n > 0)  
    {  
        if (n & 1)  res = (res*x)%mod;  
        n = n>>1; 
        x = (x*x)%mod;  
    }  
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    ll ans = (n*(n-1))/2 + (m*(m-1))/2;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
s = input()
l = len(s)


def check_kaibun(kaibun):
    n = len(kaibun)
    middle = n // 2
    count = 0
    for i in range(middle):
        if kaibun[i] == kaibun[n - i - 1]:
            count += 1
        else:
            count = 0
            break
    if count == middle:
        return True
    else: 
        return False


left_center = (l-2) // 2
right_center = (l+2) // 2

check0 = check_kaibun(s)
check1 = check_kaibun(s[:left_center + 1])
check2 = check_kaibun(s[right_center:])

if (check0 == True) and (check1 == True) and (check2 == True): 
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int n,game,a,b,c,d;
typedef struct{
	int rank;
	int score;
}Team;
Team team[101];
int main(){
	cin >> n;
	game =n*(n-1)/2;
	for(int i=0;i<game;i++){
		cin >> a >>b >> c >>d;
		if(c>d){
			team[a].score+=3;
			team[b].score+=0;
		}else if(c==d){
			team[a].score+=1;
			team[b].score+=1;
		}else{
			team[a].score+=0;
			team[b].score+=3;
		}
	}
	for(int i=1;i<=n;i++){
		team[i].rank=1;
		for(int j=1;j<=n;j++){
			if(team[i].score<team[j].score)team[i].rank++;
		}
	}
	for(int i=1;i<=n;i++){
		cout << team[i].rank<<endl;
	}
	return 0;
}

Measured memory_bytes: 3068
H,W = map(int,input().split())
C = [list(map(int,input().split())) for i in range(10)]
A = [list(map(int,input().split())) for i in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])
ans = 0
for row in A:
    for a in row:
        if a < 0: continue
        ans += C[a][1]
print(ans)

Measured memory_bytes: 3316
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	map<int, int> vmap;

	rep(x, 1, 110)rep(y, 1, 110)rep(z, 1, 110)
	{
		int v = x * x + y * y + z * z + x * y + y * z + x * z;
		if (v > N)continue;
		vmap[v]++;
	}

	rep(i, 1, N + 1)
	{
		cout << vmap[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4120
n,m = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(m)]
G = [[] for _ in range(n)]
for l in L:
    G[l[0]-1].append(l[1]-1)
    G[l[1]-1].append(l[0]-1)
for g in G:
    print(len(g))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define F first
#define S second
#define INF 1000000000000000000
#define M 1000000007
void YES(bool o){
    if(o)printf("YES\n");
    else printf("NO\n");
}
void Yes(bool o){
    if(o)printf("Yes\n");
    else printf("No\n");
}
ll h[100005];
int main(void){
    int n,k; cin>>n>>k;
    cin>>h[0];
    for(int i=1;i<n;i++){
        cin>>h[i];
    }
    ll ans=1000000000000000000;
    sort(h,h+n);
    for(int i=0;i<=n-k;i++){
        ans=min(ans,h[i+k-1]-h[i]);
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  int n, x;
  cin >> n >> x;
  int sum = 0;
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    sum += l;
    if (x < sum) {
      break;
    }
    cnt++;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll res = LINF;
    for(int i = 0; i < N; i++) {
        if(i != N - 1)
            res = min(res, K - (A[i + 1] - A[i]));
        else
            res = min(res, K - (K - A[i] + A[0]));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int main() {
    LL a = read(), b = read();
    if ((a + b) & 1) {
        puts("IMPOSSIBLE");
    } else {
        cout << (a + b) / 2;
    }
    return 0;
}

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

	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	//freopen("text.in", "r", stdin);
	//freopen("text.out", "w", stdout);

	int n;
	cin >> n;
	long long res = n * n * n;
	cout << res << '\n';
	return 0;
}

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

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	int a[3] , k  , i = 0  , sum = 0 ;
	int b[3] = {1 , 0 , -1} ;  
	cin >> a[0] >> a[1] >> a[2] >> k ; 
	while(k > 0)
	{
		if(k >= a[i])
		{
			sum += a[i] * b[i] ; 
		}
		else
		{
			sum += k * b[i] ; 
		}
		k -= a[i] ; 
		++ i ; 
	}
	cout << sum ; 
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if( a == b ){
		cout << c << endl;
	} else if( a == c ){
		cout << b << endl;
	} else{
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.awt.*;
import java.util.*;
import java.util.List;

import static java.lang.System.*;

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

        int[][] a = new int[H][W];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        int cnt = 0;
        List<Point> from = new ArrayList<>();
        List<Point> to = new ArrayList<>();
        for (int i = 0; i < H - 1; i++) {
            for (int j = 0; j < W; j++) {
                if (a[i][j] % 2 != 0) {
                    a[i][j] -= 1;
                    a[i + 1][j] += 1;
                    cnt++;

                    from.add(new Point(i + 1, j + 1));
                    to.add(new Point(i + 2, j + 1));
                }
            }
        }

        for (int j = 0; j < W - 1; j++) {
            if (a[H - 1][j] % 2 != 0) {
                a[H - 1][j] -= 1;
                a[H - 1][j + 1] += 1;
                cnt++;

                from.add(new Point(H, j + 1));
                to.add(new Point(H, j + 2));
            }
        }

        out.println(cnt);
        for(int i = 0; i < from.size(); i++){
            Point f = from.get(i);
            Point t = to.get(i);
            out.println(f.x + " " + f.y + " " + t.x + " " + t.y);
        }
    }
}

Measured memory_bytes: 103672
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e5;
int par[N + 5];
int l[N + 5], r[N + 5];

int find(int x) {
	if(x == -1) return x;
	if(x == par[x]) return par[x];
	return par[x] = find(par[x]);
}

string s;

LL arr[N + 5];

void hora(int tc) {
	cin>>s;
	int m;
	cin>>m;
	int n = s.size();
	int mid = n / 2;
	int pre = 0;
	for(int i = 0;i < mid;i++) {
		int x = s[i] - 'a';
		int y = s[n - i - 1] - 'a';
		int diff = (x - y + 26) % 26;
		arr[i] = diff;
//		cout<<"TEST "<<i<<" "<<diff<<endl;
		int npre = arr[i];
		if(i != 0) arr[i] = (arr[i] - pre + 26) % 26;
		pre = npre;
		par[i] = i;
//		cout<<i<<" "<<arr[i]<<endl;
	}
	par[mid] = mid;
	arr[mid] = (26 - pre) % 26;
//	cout<<mid<<" "<<arr[mid]<<endl;
	bool bisa = true;
	for(int i = 0;i < m;i++) {
		cin>>l[i]>>r[i];
		l[i]--, r[i]--;
		int lhs = min(l[i], n - l[i] - 1);
		int rhs = min(r[i], n - r[i] - 1);
		if(r[i] < mid) {
			lhs = l[i];
			rhs = r[i] + 1;
		} else if(l[i] > mid) {
			lhs = n - r[i] - 1;
			rhs = n - l[i];
		} else {
			int mini = min(l[i], n - r[i] - 1);
			int maxi = max(l[i], n - r[i] - 1);
			if(mini == maxi) continue;
			lhs = mini;
			rhs = maxi;
		}		
		int u = find(lhs);
		int v = find(rhs);
		if(u != v) {
			arr[u] += arr[v];
			par[v] = u;
		}
	}
	for(int i = 0;i <= mid;i++) {
//		cout<<i<<" "<<find(i)<<" "<<arr[find(i)]<<endl;
		if(arr[find(i)] % 26) bisa = false;
	}
	if(bisa == false) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 1872
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	for ( string S; getline( cin, S ), S != "END OF INPUT"; )
	{
		S += ' ';
		
		for ( int pos = 0, npos; ( npos = S.find( ' ', pos ) ) != string::npos; pos = npos + 1 )
		{
			cout << npos - pos;
		}
		cout << endl;
	}

	return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
// const int MOD = 1e9 + 7;
const ll MOD = 2019;
const ll LINF = 1e18;
ll amari[2019];
int main()
{
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    // あまりの準備l
    int sl = (int)s.length();
    ll ans = 0;
    ll ruiseki = 0;
    amari[ruiseki]++;
    ll tenbeki = 1;
    rep(i,sl)
    {
        ruiseki=(ruiseki + tenbeki*(s[i]-'0'))%MOD;
  
        ans += amari[ruiseki];
        
        amari[ruiseki]++;
        tenbeki = tenbeki*10%MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int main(){
    long a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    long ans = 0;
    while(x>0 && y>0){
        x--;
        y--;
        ans += min(a+b,2*c);
    }
    if(x>0){
        while(x>0){
            x--;
            ans += min(a,2*c);
        }
    }

    if(y>0){
        while(y>0){
            y--;
            ans += min(b,2*c);
        }
    }
    cout << ans << endl;
}


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

// 完全二分木の子の数(葉以外)
#define BINARY_CHILDREN_NUM 2

// 空きノードを示す定数
#define NIL 2100000000

#define MAX 300


// 二分木の定義
struct Node {
    int key;
    Node *left, *right, *parent;
    };

struct BinaryHeap {
    int key, left, right, parent;
    };

struct BinaryHeap Heap[MAX];

// 指定されたキーが存在するか調べる
bool IsFind(BinaryHeap HeapIdx, int nTgt)
{
    if(HeapIdx.key == nTgt) return true;

    if(HeapIdx.key < nTgt) {
            return false;
    } else {
        if(HeapIdx.right != NIL) {
            if(IsFind(Heap[HeapIdx.right], nTgt)) return true;
        }

        if (HeapIdx.left != NIL) {
            if(IsFind(Heap[HeapIdx.left], nTgt)) return true;
        }
    }

    return false;
}

void PrintHeap(int size)
{
    for (int i = 1; i < size+1; i++)
    {
        cout << "node " << i << ": key = "<< Heap[i].key << ", ";
        if(Heap[i].parent != NIL) cout << "parent key = " << Heap[Heap[i].parent].key << ", ";
        if(Heap[i].left != NIL) cout << "left key = " << Heap[Heap[i].left].key << ", ";
        if(Heap[i].right != NIL) cout << "right key = " << Heap[Heap[i].right].key << ", ";
        cout << "\n";
    }
}

int main()
{
    // 節点の個数
    int n = 0;
    // 次数
    int iDeg = 0;
    int iNodeIdx = 0;
    int left, node, root;

    cin >> n;

    // 初期化
    //struct Node iNode[n];
    for (int i = 0; i < MAX; i++)
    {
        Heap[i].parent = Heap[i].left = Heap[i].right = NIL;
    }
    
    // 各ノードに対して、
    // その節点番号、子の情報を、
    // 記憶していく
    for (int i = 1; i < n+1; i++)
    {
        //キーを取得
        cin >> iNodeIdx;
        Heap[i].key = iNodeIdx;
        int tmp = 0;

        // 親・子を取得
        double ParentIdx = floor(i/2);
        if(ParentIdx > 0 && ParentIdx < n+1) Heap[i].parent = ParentIdx;

        tmp = 2 * i;
        if (tmp > 0 && tmp < n+1) Heap[i].left = tmp;
        
        tmp = 2 * i + 1;
        if (tmp > 0 && tmp < n+1) Heap[i].right = tmp;

        //全ての子の情報を記憶する
        // for (int k = 0; k < BINARY_CHILDREN_NUM; k++)
        // {
        //     cin >> node;
        //     if (k == 0)
        //     {
        //         //左の子を記憶
        //         iNode[iNodeIdx].left = node;
        //     }
        //     else
        //     {
        //         //右の子を記憶
        //         iNode[iNodeIdx].right = node;
        //     }
        //     //子の親を記憶する
        //     iNode[node].parent = iNodeIdx;
        //     cout << "ここまで " << n <<  " k " << k << " iNodeIdx " << iNodeIdx << endl;
        // }

    }

    // Nodeのindexごとに出力する
    PrintHeap(n);
    return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    long long ret = 0;
    for (int i=1; i<=n; i++)
        ret += (long long) i * (n / i) * (n / i + 1) / 2;

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3656
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

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

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

fn gcd(x: i64, y: i64) -> i64 {
  if y == 0 {
    x
  } else {
    gcd(y, x % y)
  }
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    a: i64,
    b: i64,
  }
  let mut g = gcd(a, b);
  let mut ans = 1;
  let mut div = 2;
  while div * div <= g {
    if g % div == 0 {
      ans += 1;
      while g % div == 0 {
        g /= div;
      }
    }
    div += 1;
  }
  if g != 1 {
    ans += 1;
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const int INF = 100000005;
const int MAXH = 10005;
int dp[MAXH];
int main() {
  int h, n;
  cin >> h >> n;
  vector<P> M(n);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    M[i] = make_pair(b, a);
  }
  sort(all(M));
  rep(i, h) dp[i] = INF;
  dp[h] = 0;
  rep(i, n) {
    for(int j = h; j >= 0; j--) {
      if(dp[j] == INF) continue;
      int now = max(0, j - M[i].second);
      dp[now] = min(dp[now], dp[j] + M[i].first);
    }
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 256
// questionA.cpp : Defines the entry point for the application.
//

#include <iostream>

using namespace std;

int main()
{
	//cout << "Hello cmake!" << endl;
	string s;
	cin >> s;
	int ret_value = 1;
	if (s == "RRR")
		ret_value = 3;
	else if (s == "SSS")
		ret_value = 0;
	else if (s == "RRS" || s == "SRR")
		ret_value = 2;
	cout << ret_value;
	return 0;
}

Measured memory_bytes: 3568
n=int(input())
a=list(map(int,input().split()))
x,y=a[0],sum(a)-a[0]
ans=abs(y-x)
for i in range(1,n-1):
    x+=a[i]
    y-=a[i]
    t=abs(x-y)
    ans=min(t,ans)
print(ans)

Measured memory_bytes: 24832