akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAXN 100005
int tab[MAXN][3];
int dp[MAXN][3];
int lastday;
int max(int a,int b){
  return a>b ? a : b ;
}
int solve(int n,int last){
  int sum=0;
  if (n>lastday) {
    return 0;
  }
  if (last!=-1&&dp[n][last]!=-1) {
    return dp[n][last];
  }
    for (int j = 0; j < 3; j++) {
      if (last!=j) {
       sum=max(sum,tab[n][j]+solve(n+1,j));
       dp[n][last]=sum;
      }
  }
  return sum;
}
int main() {
  for (int i = 0; i < MAXN; i++) {
     for (int j = 0; j < 3; j++) {
          dp[i][j]=-1;
     }
  }
  int last =-1;
 scanf("%d",&lastday);
 for (int i = 0; i < lastday; i++) {
   for (size_t j = 0; j < 3; j++) {
       scanf("%d",&tab[i][j]);
   }
 }
 printf("%d\n",solve(0,last) );
return 0;
}


Measured memory_bytes: 10368
using System;

namespace ABC168A
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int a = int.Parse(Console.ReadLine());
            
            for (int i = 0; a >= 10; a -= 10)
                i = 0;

            if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9)
                Console.WriteLine("hon");

             if (a ==0 || a == 1 || a == 6 || a ==8)
                Console.WriteLine("pon");


            if (a == 3)
                Console.WriteLine("bon");
         }

    }
}


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k; cin >> n >> k;
    int p[n];
    for (int i = 0; i < n; ++i) cin >> p[i];
    sort(p, p + n);
    int ans = 0;
    for (int i = 0; i < k; ++i) ans += p[i];
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 3656
import java.util.*;


public class Main {
    static int MAX = 510000;
    static int MOD = 1000000007;
    static long[] fac = new long[MAX];
    static long[] finv= new long[MAX];
    static long[] inv = new long[MAX];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        COMinit();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for (int i=0;i<n;i++)a[i]=sc.nextInt();
        Arrays.sort(a);
        long ans = 0;
        for (int i=0;i<n;i++){
            long max = 0;
            long min = 0;
            if (i>=k-1)max = COM(i,k-1);
            if (i<=n-k)min = COM(n-i-1,k-1);
            ans=(ans+(max*a[i])%MOD-(min*a[i])%MOD+MOD)%MOD;
        }
        System.out.println(ans);
    }
    static void COMinit(){
        fac[0]=1;
        fac[1]=1;
        finv[0]=1;
        finv[1]=1;
        inv[1]=1;
        for (int i=2;i<MAX;i++){
            fac[i]=fac[i-1]*i%MOD;
            inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
            finv[i]=finv[i-1]*inv[i]%MOD;
        }
    }
    static long COM(int n, int k){
        if (n<k)return 0;
        if (n<0||k<0)return 0;
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
    }
}


Measured memory_bytes: 70812
n = int(input())
a = list(map(int, input().split()))

ans = sum(a)
for i in range(n):
  if i % 2:
    ans -= a[i] * 2
  
print(ans, end=" ")
  
for i in range(1, n):
  ans = a[i-1]*2 - ans
  print(ans, end=" ")

Measured memory_bytes: 14028
// https://atcoder.jp/contests/abc139/tasks/abc139_e
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

bool judge[1000][1000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, cnt = 0;
    cin >> n;
    vector<queue<int>> q(n);
    REP(i, n) REP(j, n - 1) {
        cin >> t;
        q[i].push(t - 1);
    }
    set<int> sl;
    REP(i, n) sl.insert(i);
    while (true) {
        // 全てのキューが空なら終了
        if (sl.size() == 0) {
            break;
        }
        set<int> sk;
        bool nfound = true;
        // 前回更新したペアのみ
        for (auto i : sl) {
            int sp = q[i].front();
            judge[i][sp] = true;
            if (judge[sp][i]) {
                nfound = false;
                q[i].pop();
                q[sp].pop();
                if (!q[i].empty()) {
                    sk.insert(i);
                }
                if (!q[sp].empty()) {
                    sk.insert(sp);
                }
            }
        }
        if (nfound) {
            cout << "-1\n";
            return 0;
        }
        sl = sk;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


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

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

    int h, w;
    cin >> h >> w;

    vector<vector<int>> cost(10, vector<int>(10));
    rep(i, 10) rep(j, 10) cin >> cost[i][j];

    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];

    const int INF = 1001001001;

    vector<int> dist(10, INF);
    dist[1] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push(make_pair(0, 1));

    while(!pq.empty()){
        pair<int, int> p = pq.top();
        int v = p.second;
        pq.pop();

        rep(nv, 10){
            if(nv == v) continue;

            if(dist[nv] > dist[v] + cost[nv][v]){
                dist[nv] = dist[v] + cost[nv][v];

                pq.push(make_pair(dist[nv], nv));
            }
        }
    }


    int res = 0;
    rep(i, h) rep(j, w){
        if(a[i][j] == -1) continue;
        res += dist[a[i][j]];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long n, t;
    cin >> n >> t;
    vector<pair<long long, long long> > a(n);
    for(int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;

    sort(a.begin(), a.end());
    
    vector<long long> d(t, -1e9);
    d[0] = 0;

    long long ans = 0;
    for(int i = 0; i < n; ++i)
        for(int j = t - 1; j >= 0; --j){
            if(d[j] == -1e9) continue;
            ans = max(ans, d[j] + a[i].second);
            if(j + a[i].first < t) d[j + a[i].first] = max(d[j + a[i].first], d[j] + a[i].second);
        }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
	vector<int> a(3)$in(a, 3);
	int cnt = 0;
	if(a[0] == a[1]) cnt++;
	if(a[0] == a[2]) cnt++;
	if(a[1] == a[2]) cnt++;
	if(cnt == 1) cout << "Yes" << el;
	else cout << "No" << el;
    return 0;
}


Measured memory_bytes: 3052
a, b = map(int, input().split())
if a<=0 and 0<=b:
    print('Zero')
    exit()
elif a > 0:
    print('Positive')
    exit()
else:
    if ( b - a + 1 ) % 2 == 0:
        print('Positive')
        exit()
    else:
        print('Negative')
        exit()


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

int main(void) {
    int N, ans = 0;
    cin >> N;
    vector<int> A(N);
    vector<int> keys;
    map<int, int> m;

    for(int i = 0; i < N; i++){
        cin >> A[i];

        if(m.count(A[i]) == 1) {
            if(m[A[i]]++ == 1)
                keys.push_back(A[i]);
        }
        else {
            m[A[i]] = 1;
        }
    }

    for(auto itr = keys.begin(); itr != keys.end();) {
        int n = m[*itr];
        int diff = 0;
        if(n >= 3) {
            diff = n % 2 == 0 ? n - 2 : n - 1;
        }
        m[*itr] = n-diff;
        ans += diff;

        if(n-diff == 1) {
            keys.erase(itr);
        }
        else {
            itr++;
        }
    }


    ans += (keys.size() + 2 - 1) / 2 * 2;

    cout << N - ans << endl;

    return 0;
}

Measured memory_bytes: 5376
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val abcd = sc.next()

  var array = BooleanArray(3) { false }

  for (bit in 0..7) {
    if (bit and 0b100 > 0) {
      array[0] = true
    }
    if (bit and 0b010 > 0) {
      array[1] = true
    }
    if (bit and 0b001 > 0) {
      array[2] = true
    }

    var tmp = Character.getNumericValue(abcd[0])
    for (i in 1..3) {
      val c = Character.getNumericValue(abcd[i])
      if (array[i - 1]) {
        tmp += c
      } else {
        tmp -= c
      }
    }
    if (tmp == 7) {
      break
    }
    array = BooleanArray(4) { false }
  }

  val ans = mutableListOf<Char>()
  ans.add(abcd[0])
  for (i in 1..3) {
    if (array[i - 1]) {
      ans.add('+')
    } else {
      ans.add('-')
    }
    ans.add(abcd[i])
  }
  println(ans.joinToString("") + "=7")


}


Measured memory_bytes: 31532
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int currentAttackerIndex = Array.IndexOf(A, A.Min());
            int nextAttackerIndex;
            while (true)
            {
                A = A.Select((x, i) => i != currentAttackerIndex ? x % A[currentAttackerIndex] : x)
                     .ToArray();
                nextAttackerIndex = Array.IndexOf(A, A.Where(x => x != 0).Min());
                if (A[currentAttackerIndex] == A[nextAttackerIndex])
                {
                    Console.WriteLine(A[currentAttackerIndex]);
                    return;
                }
                currentAttackerIndex = nextAttackerIndex;
            }
        }
    }
}


Measured memory_bytes: 21600
from collections import defaultdict
N = int(input())
d_list = [int(d) for d in input().split(' ')]


def search(d_list):
    if d_list[0] != 0:
        return 0

    d_dict = defaultdict(int)
    unique_values = set()
    for d in d_list:
        d_dict[d] += 1
        unique_values.add(d)

    if d_dict.get(0) and d_dict.get(0) >= 2:
        return 0

    unique_num = len(unique_values)
    if not sum(unique_values) == unique_num * (unique_num - 1) / 2:
        return 0

    result = 1

    for v in unique_values:
        if v == 0:
            continue
        prev_node_num = d_dict.get(v-1)
        current_node_num = d_dict.get(v)

        result *= prev_node_num ** current_node_num
    return result % 998244353

print(search(d_list))


Measured memory_bytes: 22212
while gets do
  a = Array.new(13,0)
  $_.split(",").map(&:to_i).each do |i|
    a[i-1]+=1
  end
  if a.member?(4) then
    puts "four card"
  elsif a.member?(2) then
    if a.member?(3) then
      puts "full house"
    elsif a.index(2) == a.rindex(2) then
      puts "one pair"
    else
      puts "two pair"
    end
  elsif a.member?(3) then
    puts "three card"
  elsif a.join =~ /1{5}/ || a.join =~ /10{8}1{4}/ then
    puts "straight"
  else
    puts "null"
  end
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

vector<ll> soinsu(ll num){
  vector<ll> v;
  //v.push_back(1);
  for (int i=1;i<sqrt(num);i++){
    if (num%i==0){
      v.push_back(i);
      if (i*i != num) v.push_back(num/i);
      //cout << num2 << endl;
    }
  }
  sort(v.begin(),v.end());
  
  return v;
}



int main(){
  ll n, k;
  cin >> n >> k;
  ll A[n];
  ll sum = 0;
  for(int i=0;i<n;i++){
    cin >> A[i];
    sum += A[i];
  }
  
  vector<ll> vec;
  vec = soinsu(sum);
  
  ll max = 1;
  //for (int i=0;i<vec.size();i++) cout << vec[i] << endl;
  for (int i=0;i<vec.size();i++){
    //cout << "soinsu " << vec[i] << endl;
    
    priority_queue< ll, vector<ll>, greater<ll> > que;
    for (int j=0;j<n;j++){
      que.push(A[j]%vec[i]);
    }
    ll R[n];
    R[0] = que.top(); que.pop();
    for (int j=1;j<n;j++){
      ll tmp;
      tmp = que.top(); que.pop();
      R[j] = R[j-1]+tmp;
    }
    //for (int j=0;j<n;j++) cout << R[j] << endl;
    
    for (int j=0;j<n;j++){
      //cout << R[j] << " " << R[n-1] << " " << (R[n-1]-R[j]) << " " << vec[i]*(n-1-j) << endl;
      if (R[j] == vec[i]*(n-1-j) - (R[n-1]-R[j]) && R[j]<=k){
        max = vec[i];
        break;
      }
    }
  }
  
  cout << max << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 4e2 + 10, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
ll original[N][N] = { }, SP[N][N] = { }, n, d[N][N] = { }, fa[N][N];
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> n;
	lp(i,1,n)
	{
		lp(j,1,n)
		{
			cin >> original[i][j];
			SP[i][j] = original[i][j];
			if (i == j) {
				if (SP[i][j])
					f(-1);
			}
		}
	}
	lp(k,1,n)
	{
		lp(i,1,n)
		{
			lp(j,1,n)
				SP[i][j] = min(SP[i][j], SP[i][k] + SP[k][j]);
		}
	}
	lp(k,1,n)
	{
		lp(i,1,n)
		{
			lp(j,i,n)
			{
				if (original[i][j] != SP[i][j])
					f(-1);
				if (SP[i][j] == SP[i][k] + SP[k][j] && k != i && k != j)
					fa[i][j] = 1;
			}
		}
	}
	ll sum = 0;
	lp(i,1,n)
		lp(j,i+1,n)
			if (!fa[i][j])
				sum += SP[i][j];
	f(sum);
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,x,y,z;
    scanf("%d%d",&a,&b);
    x=a+b;
    y=a-b;
    z=a*b;
    if(x>=y && x>=z)
        printf("%d\n",x);
    else if(y>=x && y>=z)
        printf("%d\n",y);
    else if(z>=x && z>=y)
        printf("%d\n",z);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int A,P;
    cin>>A>>P;
    cout<<(3*A+P)/2<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC069_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var cntFour = 0;
            var cntTwo = 0;
            for (int i = 0; i < N; i++)
            {
                if (a[i] % 4 == 0)
                {
                    cntFour++;
                }
                else if (a[i] % 2 == 0)
                {
                    cntTwo++;
                }
            }

            if (cntTwo % 2 == 1) cntTwo--;

            var achieve = N - 2 * cntFour - cntTwo <= 1;
            Console.WriteLine(achieve ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 19680
n = int(input())
di = [0]*5
for i in range(n):
    s = input()
    if s[0] == "M":
        di[0] += 1
    elif s[0] == "A":
        di[1] += 1
    elif s[0] == "R":
        di[2] += 1
    elif s[0] == "C":
        di[3] += 1
    elif s[0] == "H":
        di[4] += 1
p = 0
for j in range(3):
    for k in range(j+1,4):
        for l in range(k+1,5):
            if di[j] != 0 and di[k] != 0 and di[l] != 0:
                p += di[j]*di[k]*di[l]
print(p)

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

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

    int m = 0, count = 0;

    for(int i=0;i<s.size();i++){
        if (i%2 == 0){
            if (s[i] == '0'){
                m += 1;
            }
        }else{
            if (s[i] == '1'){
                m += 1;
            }
        }
    }

    // count = min(m, s.size()-m);
    if (m < s.size()-m){
        cout << m;
    }else{
        cout << (s.size()-m);
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#define abs(k) ((k > 0) ? (k) : (-1)*(k))
using namespace std;
int main(){
	int n;
	cin >> n;
	int h[n];
	int dp[n];
	for(int a = 0;a < n;a++){
		cin >> h[a];
		dp[a] = 0;
	}
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int a = 2;a < n;a++){
		dp[a] = min(dp[a-2] + abs(h[a-2]-h[a]),dp[a-1] + abs(h[a-1]-h[a]));
	}
	cout << dp[n-1];
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

inline int timeOf(int h, int m){
  return h * 60 + m;
}

int main(){
  while(int n = getInt()){
    vector<int> ans(1000, 0);
    vector<int> in(1000, -1);

    REP(i, n){
      int M, D;
      int h, m;
      char s[2];
      int id;

      scanf("%02d/%02d %02d:%02d %s %03d",
            &M, &D, &h, &m, s, &id);

      if(s[0] == 'I'){
        in[id] = timeOf(h, m);
      }else{
        int t = timeOf(h, m);
        if(id == 0){
          for(int j = 1; j < 1000; j++){
            if(in[j] != -1){
              ans[j] += t - max(in[j], in[0]);
            }
          }
        }else{
          if(in[0] != -1){
            ans[id] += t - max(in[id], in[0]);
          }
        }
        in[id] = -1;
      }
    }

    printf("%d\n", *max_element(ans.begin() + 1, ans.end()));
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
S = input()
S1 = list(S)

for i in range(len(S1)):
    if (ord(S1[i]) + N) < 91:
        S1[i] = chr(ord(S1[i]) + N)
    else:
        S1[i] = chr((ord(S1[i])+N-65)%26+65)
S = ''.join(S1)
print(S)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		System.out.println(X*X*X);
//		for (int i = 0; i < N; i++) {
//			String s = sc.next();
//			String[] array = s.split(",");
//		}
	}
}

Measured memory_bytes: 26132
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        bool[] bukket = new bool[1000000];
        int count = 0;
        while (true)
        {
            count++;
            if (bukket[n])
            {
                Console.WriteLine(count);
                break;
            }
            else
            {
                bukket[n] = true;
                if (n % 2 == 0)
                {
                    n = n / 2;
                }
                else
                {
                    n = 3 * n + 1;
                }
            }
        }
    }
}

Measured memory_bytes: 11872
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL divisor[10101010];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    
    // 2. 約数を保存.
    repx(i, 1, 10101010) repex(j, i, 10101010, i) divisor[j]++;
    
    // 3. 集計.
    LL ans = 0;
    repx(i, 1, N + 1) ans += i * divisor[i];
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 82736
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int x, y;

void input() {
	cin >> x >> y;
}

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

	input();

	cout << x + (y / 2) << "\n";

	return 0;
}

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

int c[100005];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        c[a]++;
    }
    int ans=0;
    for(int i=0;i<100000;i++) ans=max(ans,c[i]+c[i+1]+c[i+2]);
    cout<<ans<<endl;
}

Measured memory_bytes: 640
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

N = int(input())
A = [int(i) for i in input().split()]

A.sort()
cnt_mi = 0
if A[0] >= 0:
    ans = sum(A)
    print(ans)
    exit()

for i in range(N):
    if A[i] < 0:
        cnt_mi += 1
    A[i] = abs(A[i])

if cnt_mi%2 == 0:
    ans = sum(A)
    print(ans)
    exit()

A.sort()

ans = sum(A)-2*A[0]
print(ans)


Measured memory_bytes: 16768
import java.time.Year;
import java.util.*;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    // input
    static int s;

    /**
     * input
     */
    static void input(){
        Scanner sc = new Scanner(System.in);
        s = sc.nextInt();
        sc.close();
    }
 

    static int f(int n) {
        if (n%2==0) {
            return n/2;
        } else {
            return 3*n+1;
        }
    }

    static boolean[] memo;

    /**
     * solver
     */
    static void solve(){
        memo = new boolean[1000000];

        int ans = 1;
        int x = s;
        memo[x] = true;

        int y;

        while(true) {
            y = f(x);
            ans ++;

            if (memo[y]) {
                break;
            } else {
                memo[y] = true;
                x = y;
            }
        }

        System.out.println(ans);
    }


    public static void main(String args[]) {

        input();

        solve();
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MAX_V 2000

int D[MAX_V][MAX_V];
int V,E,r;

void warshall_floyd(){
    int i,j,k;
    for(k=0;k<V;k++){
        for(i=0;i<V;i++){
            for(j=0;j<V;j++){
                D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
            }
        }
    }
}

int main(){
    int i,j,s,t,d,dall=0;
    bool flg=false;
    cin>>V>>E>>r;
    for(i=0;i<V;i++){
        for(j=0;j<V;j++){
            if(i==j)D[i][j]=0;
            else D[i][j]=INF;
        }
    }
    for(i=0;i<E;i++){
        cin>>s>>t>>d;
        D[s][t]=d;
        if(d>=0)dall+=d;
    }

    warshall_floyd();
    /*for(i=0;i<V;i++){
        for(j=0;j<V;j++)cout<<D[i][j]<<" ";
        cout<<"\n";
    }*/

    for(i=0;i<V;i++){
        if(D[i][i]<0 && D[r][i]<=dall){
            flg=true;
            break;
        }
    }

    if(flg){
        cout<<"NEGATIVE CYCLE\n";
    }else{
        for(i=0;i<V;i++){
            if(D[r][i]>dall)cout<<"INF\n";
            else cout<<D[r][i]<<"\n";
        }
    }
}


Measured memory_bytes: 10896
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
LL a[90], n;
int main() {
	LL i, j, k;
	scanf("%lld", &n);
	a[0] = 2; a[1] = 1;
	for(i = 2; i <= n; i++) a[i] = a[i-1]+a[i-2];
	printf("%lld\n", a[n]);
	return 0;
}

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

using namespace std;

int main(void) {
	string O,E;
	cin >> O >> E;
	
	string res = "";
	for (int i = 0; i < O.length()+E.length(); ++i) {
		if (i%2 == 0) {
			res += O[i/2];
		}
		else {
			res += E[i/2];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
H,W = list(map(int,input().split()))
N=H*W

#壁のノード
wall=[]
for h in range(H):
    for w_idx,w in enumerate(list(input())):
        if w == '#':
            wall.append(W*h+w_idx+1)
#道のノード        
path=[_ for _ in range(1,N+1) if _ not in wall]

#隣接リスト
ad = {}
for n in range(N):
    ad[n+1]=[]
    
for n in range(N):
    n=n+1
    if n not in wall:
        up = n-W
        if up > 0 and up not in wall:
            ad[n].append(up)
            
        down = n+W
        if down <= N and down not in wall:
            ad[n].append(down)
            
        left = n-1
        if n % W != 1 and left not in wall and left > 0:
            ad[n].append(left)
        
        right = n+1
        if n % W != 0 and right not in wall:
            ad[n].append(right)   

from collections import deque
    
color = {}
for n in range(N):
    color[n+1] = -1

depth = {}
for n in range(N):
    depth[n+1] = -1
    
parent = {}
for n in range(N):
    parent[n+1] = -1
    
group = {}
    
group_= 0
for p in path:
    if color[p] != -1: 
        continue
    elif color[p] == -1: 
        start = p
        color[start] = 0
        que = deque([start])
        visit = deque([])
        group_+=1
        group[group_] = [start]

    depth[start] = 0
    while len(que) > 0:
        start = que[0]
        for v in ad[start]:
            if color[v] == -1:
                que.append(v)
                color[v] = 0
                depth[v] = depth[start]+1
                group[group_].append(v)
                parent[v] = start
                
        color[start] = 1
        visit.append(que.popleft())
        
ans_ = {}
for n in range(N):
    ans_[n+1]=1

for w in wall:
    ans_[w]=0

start = N
short_path=[]

while True:
    short_path.append(start)
    start = parent[start]
    if start == 1:
        short_path.append(start)
        for s in short_path:
            ans_[s] = 0
        print(sum(ans_.values()))
        break
        
    if start == -1:
        print(start)
        break

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

int main (){
  int n=0, ans=0;
  string str;
  cin >> n;
  vector<string> a(n,"");
  
  for (int i=0; i<n; ++i){
    cin >> a.at(i);
    /*
    for (int j=0; j<n; ++j){
      if (str == a.at(j)) break;
      else if (j == n - 1){
        a.at(ans) = str;
        ++ans;
      }
    }
    */
 }
  
  sort(a.begin(),a.end());
  str = a.at(0);
  for (int i=0; i<n; ++i) {
    //cout << a.at(i)<<endl;
    if (a.at(i) != str) {
      str = a.at(i);
      ++ans;
    }
  }
  
  cout << ans +1  << endl;
}

Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

signed main(){
  int a,b;
  cin>>a>>b;
  if(a>=13)cout<<b<<endl;
  else if(a>=6)cout<<b/2<<endl;
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b = (int(_) for _ in input().split())
    l1 = [1,3,5,7,8,10,12]
    l2 = [4,6,9,11]
    if (a in l1 and b in l1) or (a in l2 and b in l2) or (a == 2 and b ==2):
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>

using namespace std;

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

    bool flag = 0;
    if (c - a - b < 0) {
        flag = 0;
    }    
    else if ((c - a - b) * (c - a - b) - 4 * a * b > 0)
        flag = 1;
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}



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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int num = r * 100 + g * 10 + b;

    cout << (num % 4 == 0 ? "YES" : "NO") << endl;
    return 0;
}


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

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

    vector<int> from;

    set<int> to;

    for(int i=0; i<m; i++){
        int a,b; cin>>a>>b;
        if(a == 1)from.push_back(b);
        else if(b == n) to.insert(a);
    }    

    bool flag = false;

    for(int i=0; i<from.size(); i++){     
        if(to.count(from[i])){
            flag = true;
            break;
        }
    }

    if(flag) cout<<"POSSIBLE"<<endl;

    else cout<<"IMPOSSIBLE"<<endl;

    return 0;
}

Measured memory_bytes: 5368
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,N,x=1,ans=0;
  cin>>N;
  vec v(N);
  pvec box(1);
  rep(i,N){
    cin>>v[i];
  }
  vrsort(v);
  box[0]=datas(v[0],1);
  rep1(i,N){
    if(v[i]==box[box.size()-1].first){
      box[box.size()-1].second++;
    }else{
      box.push_back(datas(v[i],1));
    }
  }
  N=box.size();
  x=1LL<<40;
  rep(i,N){
    if(!box[i].second)continue;
    while(box[i].first*2<x)x/=2;
    if(box[i].first*2==x){
      ans+=box[i].second/2;
      continue;
    }
    ll ok=i,ng=N,mid;
    while(ng-ok>1){
      mid=(ok+ng)/2;
      if(box[mid].first<x-box[i].first){
        ng=mid;
      }else{
        ok=mid;
      }
    }
    if(box[ok].first==x-box[i].first&&box[ok].second){
      ans+=min(box[i].second,box[ok].second);
      box[ok].second-=min(box[i].second,box[ok].second);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7792
$nodes = []
$h = 0

def maxHeapify(i)
  left = i * 2
  right = i * 2 + 1
  max = i
  max = left if left <= $h && $nodes[max - 1] < $nodes[left - 1]
  max = right if right <= $h && $nodes[max - 1] < $nodes[right - 1]

  if max != i
    $nodes[i - 1], $nodes[max - 1] = $nodes[max - 1], $nodes[i - 1]
    maxHeapify(max)
  end
end

def buildMaxHeap(h)
  (h / 2).downto(1) do |i|
    maxHeapify(i)
  end
end

def main
  $h = gets.to_i
  $nodes = gets.split.map(&:to_i)
  buildMaxHeap($h)
  puts ' ' + $nodes.join(' ')
end

main



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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int dx[]={-1,1,0,0}, dy[]={0,0,-1,1};
int N, M;
int D[1000][1000];

bool valid_coord(int x, int y)
{
	return 0<=x && x<N && 0<=y && y<M;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int ans=0;
	queue<pair<int,int>> Q;
	string s;
	cin>>N>>M;
	memset(D,0x7f,sizeof(D));
	for(int i=0;i<N;i++) {
		cin>>s;
		for(int j=0;j<M;j++) {
			if(s[j]=='#') {
				D[i][j]=0;
				Q.push({i,j});
			}
		}
	}
	while(!Q.empty()) {
		int x, y;
		tie(x,y)=Q.front();
		Q.pop();
		ans=D[x][y];
		for(int k=0;k<4;k++) {
			if(valid_coord(x+dx[k],y+dy[k]) && D[x+dx[k]][y+dy[k]]==0x7f7f7f7f) {
				D[x+dx[k]][y+dy[k]]=D[x][y]+1;
				Q.push({x+dx[k],y+dy[k]});
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 12304
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;

int dp[105][4][2];

ll choose(ll l, ll r){
  if(l < r || r <= 0 || l <= 0) return 0;
  ll ret = 1;
  for(ll i = l; i >= l - r + 1; i--){
    ret *= i;
  }
  for(ll i = r; i >= 1; i--){
    ret /= i;
  }
  return ret;
}

void solve(){
  string s; cin >> s;
  int x; cin >> x;
  int n = s.size();
  dp[0][0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 4; j++){
      for(int k = 0; k < 2; k++){
        for(int d = 0; d < 10; d++){
          int nd = s[i] - '0', ni = i + 1, nj = j, nk = k;
          if(d != 0) nj++;
          if(nj > x) continue;
          if(k == 0){
            if(d > nd) continue;
            if(d < nd) nk = 1;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  cout << dp[n][x][0] + dp[n][x][1] << endl;


  return;
}

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


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
   fast;
   int n;
   cin >> n;

   int ans = 0;
   f(i,1,n+1){
      ans += (n + 1 - i) * i;
   }

   f(i,0,n-1){
      int u,v;
      cin >> u >> v;
      if(u > v)   swap(u,v);
      ans -= u * (n + 1 - v);
   }

   cout << ans << "\n";
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#define REP0(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
typedef long long ll;
const ll ccc=1000000;
bool prime[ccc+1];
vector<ll> pr;
int main(){
	ll iii,jjj;
	for(iii=0;iii<=ccc;iii++){
		prime[iii]=true;
	}
	prime[0]=false;
	prime[1]=false;
	for(iii=2;iii*iii<=ccc;iii++){
		if(prime[iii]){
			for(jjj=2*iii;jjj<=ccc;jjj+=iii){
				prime[jjj]=false;
			}
		}
	}
	for(iii=2;iii<=ccc;iii++){
		if(prime[iii]){
			pr.push_back(iii);
		}
	}
	int a;
	while(scanf("%d",&a)!=EOF) printf("%d\n",upper_bound(ALL(pr),a)-pr.begin());
	return 0;
}

Measured memory_bytes: 2956
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 998244353; //1000000007;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int x, y;
	get(x, y);
	
	int ans = 0;
	if (tp_abs(x) < tp_abs(y)) {
		if (x < 0) {
			ans++;
		}
		ans += tp_abs(y) - tp_abs(x);
		if (y < 0) {
			ans++;
		}
	}
	else {
		if (x > 0) {
			ans++;
		}
		ans += tp_abs(x) - tp_abs(y);
		if (y > 0) {
			ans++;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3720
import java.util.HashSet;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashSet<String> dic = new HashSet<>();
        int n = sc.nextInt();
        for(int i=0; i<n; i++){
            String S = sc.next();
            String word = sc.next();
            if(S.equals("insert")) dic.add(word);
            else if(S.equals("find")){
                if(dic.contains(word)) System.out.println("yes");
                else System.out.println("no");
            }
        }
    }
}


Measured memory_bytes: 254380
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;
const int N = 200010;
int a[N];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    reverse(a+1,a+1+n);
    LL ans = 0;
    for(int i=2,j=1;i<=n;i++)
    {
        ans+=a[j];
        if(i%2==0) j++;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4600
#include <iostream>
#define int long long

using namespace std;

int cnt[10000001];

signed main() {
	int k;
	cin >> k;
	
	for (int i = 1; i <= k; ++i) {
		for (int j = i; j <= k; j += i) {
			cnt[j]++;
		}
	}
	
	int ans = 0;
	for (int i = 1; i <= k; ++i) ans += i * cnt[i];
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 81724
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string data[9] = {"\',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ"};

char conv(char n, int cnt){
  return data[n-'1'][(cnt-1)];
}

main(){
  string in;
  while(getline(cin, in)){
    string out;
    bool f = true;
    char num;
    int cnt = 0;
    for(int i=0;i<in.size();i++){
      if(f){
        num = in[i];
        cnt++;
        f = false;
      }else{
        if(in[i] == '0'){
          if(num == '0'){
            cnt++;
          }else{
            out += conv(num, cnt);
            num = in[i];
            cnt = 0;
          }
        }else if(num != in[i]){
          if(num == '0') while(cnt--) out += ' ';
          else out += conv(num, cnt);
          num = in[i];
          cnt = 1;
        }else{
          cnt++;
        }
      }
    }
    if(num == '0') while(cnt--) out += ' ';
    else out += conv(num, cnt);
    cout << out << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <array>

int main () {
  auto const max_row =101;
  auto const max_column = 101;

  std::array<std::array<int, max_column>, max_row> A;
  std::array<int, max_column> b;

  int row, column;
  std::cin >> row >> column;

  auto read_each_elm = [](int & a){ std::cin >> a; };
  auto read_each_row = [=](auto & Ai){
                            std::for_each(Ai.begin(), Ai.begin()+column, read_each_elm);
                          };

  std::for_each(A.begin(), A.begin()+row, read_each_row);
  std::for_each(b.begin(), b.begin()+column, read_each_elm);

  for (int i=0; i<row; i++)
    {
      auto sum_row = 0;
      for (int j=0; j<column; j++)
        sum_row += A.at(i).at(j) * b.at(j);
      std::cout << sum_row << std::endl;
    }
}



Measured memory_bytes: 3124
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 2000001
#define MAX 2000000000
int parent(int);
int left(int);
int right(int);
void buildMaxHeap(int*);
void maxHeapify(int*,int);
void swap(int*,int,int);
void printHeap(int*);
void insert(int*,int);
int extract(int*);
int h=0;//size of heap
int main(void)
{
  int arr[N];//array (1-origin)
  char op[10];//operation
  int key;
  arr[0]=MAX+1;
  for(;;)
    {
      scanf("%s",op);
      if(strcmp(op,"insert")==0)
	{
	  scanf("%d",&key);
	  insert(arr,key);
	}
      if(strcmp(op,"extract")==0) printf("%d\n",extract(arr));
      if(strcmp(op,"print")==0) printHeap(arr);//for debugging
      if(strcmp(op,"end")==0) break;
      
    }
  return 0;
}
int parent(int i)
{
  return i/2;
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}
void buildMaxHeap(int *arr)
{
  int i;//counter
  for(i=h/2;i>=1;i--) maxHeapify(arr,i);
}
void maxHeapify(int *arr,int i)
{
  int l=left(i);
  int r=right(i);
  int largest;
  if(i<1) return;
  if(l<=h&&arr[l]>arr[i]) largest=l;
  else largest=i;
  if(r<=h&&arr[r]>arr[largest]) largest=r;
  if(largest!=i)
    {
      swap(arr,i,largest);
      maxHeapify(arr,largest);
    }
}
void swap(int *arr,int x,int y)
{
  int temp;
  temp=arr[x];
  arr[x]=arr[y];
  arr[y]=temp;
}
void printHeap(int *arr)
{
  int i;
  for(i=1;i<=h;i++) printf(" %d",arr[i]);
  printf("\n");
}
void insert(int *arr,int key)
{
  int index;
  h++;
  arr[h]=key;
  for(index=h;index>=1;index=parent(index))
    {
      if(arr[index]<arr[parent(index)]) break;
      maxHeapify(arr,parent(index));
    }
}
int extract(int *arr)
{
  int ret=arr[1];
  arr[1]=arr[h];
  h--;
  maxHeapify(arr,1);
  return ret;
}



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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/


int main() {
  int n, x;
  cin >> n >> x;
  vector<int> arr(n);
  int sum = 0;
  int smallest = 1000;
  rep(i, n) {
    cin >> arr[i];
    sum += arr[i];
    smallest = min(smallest, arr[i]);
  }
  x -= sum;
  cout << n + (x / smallest) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, k;
	cin>>a>>b>>c>>k;
	int sum = 0;
	for(int i = 0; i < k; ++i){
		int A = 2 * a +  b + c;
		int B = a + 2 * b + c;
		int C = a + b + 2 * c;
		if(A > B && A > C){
			a = 2 * a;
		}
		else if(B > A && B > C){
			b = 2 * b;
		}
		else{
			c = 2 * c;
		}
	}
	sum = a + b + c;
	cout<<sum<<endl;
	return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s = "Sunny", c = "Cloudy", r = "Rainy";

string w;

int main(void) {
  // Here your code !
  cin >> w;

  string ans;

  if (w == s) {
    ans = c;  
  } else if (w == c) {
    ans = r;
  } else {
    ans = s;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
dp = [[0,0,0] for _ in range(N)]
dp[0][0],dp[0][1],dp[0][2] = map(int, input().split())
for i in range(1,N):
    a, b, c = map(int, input().split())
    dp[i][0] = max(dp[i-1][1]+a,dp[i-1][2]+a)
    dp[i][1] = max(dp[i-1][0]+b,dp[i-1][2]+b)
    dp[i][2] = max(dp[i-1][1]+c,dp[i-1][0]+c)
print(max(dp[N-1]))

Measured memory_bytes: 59808