akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int N, a[MAX];

int main(void) {
    scanf("%d", &N);
    int ma = 0, mi = INF;
    REP(i, N) {
        scanf("%d", a + i);
        chmin(mi, a[i]);
        chmax(ma, a[i]);
    }
    if (ma - mi >= 2) {
        cout << "No" << endl;
        return 0;
    }
    if (ma == mi) {
        if (ma == N - 1 || ma == 1) {
            cout << "Yes" << endl;
            return 0;
        }
        if (N / 2 < ma) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        int cnt[2];
        REP(i, 2) cnt[i] = 0;
        REP(i, N) {
            cnt[a[i] == mi]++;
        }
        if (mi == 1 && cnt[1] == 1) {
            cout << "Yes" << endl;
            return 0;
        }
        if (cnt[1] <= ma - 1) {
            if ((N - cnt[1]) / 2 < ma - cnt[1]) {
                cout << "No" << endl;
            } else {
                cout << "Yes" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

void solve(long long x) {
  cout << !x << endl;
}

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


Measured memory_bytes: 3684
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var abx = Sarray();
            var a = (double)abx[0];
            var b = (double)abx[1];
            var x = (double)abx[2];
            var theta = 0d;
            var th = a * b * a / 2.0;
            if (th <= x)
            {
                var z = 2 * x / (a * a) - b;
                theta = Atan2(a, b - z);
            }
            else
            {
                var z =2* x / (b * a);
                theta = Atan2(z, b);
            }
            //rad→deg
            WriteLine(90.0 - theta * 180 / PI);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main(){
	/*****input*****/
	string s;
    cin >> s ;


	/*****calc*****/
    string ans = "hi";
    int n = s.length();
    bool j = true;

     if(n % 2 != 0){
  		j = false;
    }

    for(int i=0; i<n-1; i+=2){
    	if(s[i] == 'h' && s[i+1] == 'i'){
    		continue;
    	}
    	j = false;
    }

    /*****ans*****/
    if(j) {
    	cout << "Yes" << endl;
    }
    else{
    	cout << "No" << endl;
    }
//    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

count = 0

def dfs(i, now, done):
    global count
    if i == N-1:
        count += 1
        return

    for j in ab[now]:
        if j not in done:
            dfs(i+1, j, done + [j])
    return

dfs(0, 0, [0])
print(count)


Measured memory_bytes: 9140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> card(N);
    for(auto& in:card) cin >> in;
    sort(card.begin(),card.end());
    
    vector<pii> m;
    int pre_v = -1;
    for(int i = 0; i < N;i++){
        if(pre_v == card[i]){
            m[m.size() - 1].second++;
        }else{
            m.push_back({card[i],1});
            pre_v = card[i];
        }
    }
    
    ll cnt = 0;
    for(int i = 0; i < (int)m.size();i++){
        if(m[i].second == 1) cnt++;
        else{
            if(m[i].second >= 3){
                if(m[i].second%2 == 0){
                    m[i].second = 2;
                }else{
                    m[i].second = 1;
                    cnt++;
                }
            }
        }
    }
    ll check = ((int)m.size() - cnt);
    if(check%2 == 0){
        cnt += check;
    }else{
        cnt += (check - 1);
    }
    cout << cnt << endl;
    return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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; }


int main()
{
    string o,e;
    cin >> o >> e;

    rep(i,e.size()) cout << o[i] << e[i];
    if( o.size() != e.size() ) cout << o[o.size()-1];
    cout << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const int MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int m = cin.Int();
			HashSet<int>[] to = new HashSet<int>[n + 1];
			for (int i = 0; i < n + 1; i++) {
				to[i] = new HashSet<int>();
			}

			int a = 0;
			int b = 0;
			for (int i = 0; i < m; i++) {
				a = cin.Int();
				b = cin.Int();
				to[a].Add(b);
				to[b].Add(a);
			}

			List<int> path = new List<int>();
			path.Add(a);
			path.Add(b);

			HashSet<int> done = new HashSet<int>();
			done.Add(a);
			done.Add(b);
			while (true) {
				bool adds = false;
				foreach (int v in to[path.First()]) {
					if (done.Contains(v) == false) {
						path.Insert(0, v);
						done.Add(v);
						adds = true;
						break;
					}
				}

				if (adds == false) {
					foreach (int v in to[path.Last()]) {
						if (done.Contains(v) == false) {
							path.Add(v);
							done.Add(v);
							adds = true;
							break;
						}
					}
				}

				if (adds == false) {
					break;
				}
			}

			StringBuilder sb = new StringBuilder();
			sb.AppendLine(path.Count().ToString());
			foreach (int v in path) {
				sb.Append($"{v} ");
			}
			Console.WriteLine(sb.ToString());
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			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] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			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] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			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] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 46784
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

a = []
for _ in range(3):
    line = [int(item) for item in input().split()]
    a += line

n = int(input())
ok = [False] * 9
for _ in range(n):
    b = int(input())
    for i in range(9):
        if a[i] == b:
            ok[i] = True

        
if ok[0] and ok[3] and ok[6]:
    print("Yes")
elif ok[1] and ok[4] and ok[7]:
    print("Yes")
elif ok[2] and ok[5] and ok[8]:
    print("Yes")
elif ok[0] and ok[1] and ok[2]:
    print("Yes")
elif ok[3] and ok[4] and ok[5]:
    print("Yes")
elif ok[6] and ok[7] and ok[8]:
    print("Yes")
elif ok[0] and ok[4] and ok[8]:
    print("Yes")
elif ok[2] and ok[4] and ok[6]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import numpy as np

N=int(input())
W = np.array(list(map(int,input().split())))

minS=1000
for i in range(1,N):
  s1=np.sum(W[:i])
  s2=np.sum(W[i:])
  
  
  
  
  ds=abs(s1-s2)
  #print(W[:i],W[i:],ds)
  if ds<minS:
    #print("min")
    minS=ds
print(minS)

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

int main() {
int n,x,sum=0;
cin>>n>>x;
int m[n];
REP(i,n){
  cin>>m[i];
  sum++;
  x-=m[i];
}

sort(m,m+n);

while (1)
{
  /* code */
  if (x<m[0])
  {
    /* code */
    break;
  }
   sum++;
  x-=m[0];
  
}

cout<<sum<<endl;


}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for (int i = s.size() / 2 - 1; i > 0; i--) {
    if (s.substr(0, i) == s.substr(i, i)) {
      cout << i * 2 << endl;
      return 0;
    }
  }
  return 0;
}


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

int top = -1, S[200];

void push(int i) {
    top++;
    S[top] = i;
}

int pop() {
    int i = S[top];
    top--;
    return i;
}

int main() {
    char s;
    while (scanf("%s", &s) != EOF) {
        if (s == '+') {
            push(pop() + pop());
        } else if (s == '-') {
            int a = pop(); int b = pop();
            push(b - a);
        } else if (s == '*') {
            push(pop() * pop());
        } else {
            push(atoi(&s));
        }
    }
    
    cout << pop() << endl;
}


Measured memory_bytes: 3148
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// 1行、文字列
		String a = br.readLine();
		String b = br.readLine();

		String ans = "EQUAL";
		
		if(a.length() > b.length()) { System.out.println("GREATER"); return; }
		if(a.length() < b.length()) { System.out.println("LESS"); return; }

		
		for(int i=0; i<a.length(); i++) {
			if (a.charAt(i) > b.charAt(i)) { ans = "GREATER"; break;}
			if (a.charAt(i) < b.charAt(i)) { ans = "LESS"; break;}
		}
		
        System.out.println(ans);
        return;
    }


}



Measured memory_bytes: 23124
var si = process.stdin;
si.resume();
si.setEncoding('utf8');

si.on('data', function (chunk) {
    var line = chunk.toString().split(/\r\n|\r|\n/);
    var N = Number(line[0]);
    var A = line[1].split(/ /).map(Number);

    function printA() {
        console.log(A.join(" "));
    }
    
    printA();
    
    // insertion sort
    var i, v, j;
    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        printA(A);
    }
});

Measured memory_bytes: 16916
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextIntSlice(size int) []int {
	re := make([]int, size)
	for i := 0; i < size; i++ {
		re[i] = nextInt()
	}
	return re
}

func max(a []int) int {
	max := a[0]
	for _, v := range a {
		if v > max {
			max = v
		}
	}
	return max
}

func min(a []int) int {
	min := a[0]
	for _, v := range a {
		if v < min {
			min = v
		}
	}
	return min
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextIntSlice(n)

	fmt.Println(max(a) - min(a))
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int n = parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());

		int g = parseInt(st.nextToken());

		for (int i = 0; i < n - 1; i++) {
			g = gcd(g, parseInt(st.nextToken()));
		}

		for (int i = 1; i <= g; i++) {
			if (g % i == 0) {
				System.out.println(i);
			}
		}
	}

	static int gcd(int a, int b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

}

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

#define int long long

int dp[20001][256];
int C[17];

signed main() {
    int n, m;
    while(cin>>n>>m, n) {
        for(int i=0; i<20001; ++i)
          for(int j=0; j<256; ++j) dp[i][j] = 1e+9;
        dp[0][128] = 0;
        for(int i=0; i<16; ++i) C[i] = 0;
        for(int i=0; i<m; ++i) cin >> C[i];
        for(int i=1; i<=n; ++i) {
            int x;
            cin >> x;
            for(int j=0; j<256; ++j) {
                for(int k=0; k<m; ++k) {
                    int x2 = j + C[k];
                    if(255<=x2) x2=255;
                    if(x2<=0) x2=0;
                    int diff = (x2-x) * (x2-x);
                    dp[i][x2] = min(dp[i][x2], dp[i-1][j]+diff);
                }
            }
        }

        int ans = 1e+9;
        for(int i=0; i<256; ++i) ans = min(ans, dp[n][i]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 43076
n = int(input())
s = input()
L = ["R","G","B"]
C = [[0] * n for i in range(3)]
for ii in range(3):
    c = L[ii]
    if s[-1] == c:
        C[ii][-1] += 1
    for i in range(n-2,-1,-1):
        if s[i] == c:
            C[ii][i] = C[ii][i+1] + 1
        else:
            C[ii][i] = C[ii][i+1]
# print(C)



ans = 0
for ii in range(3):
    for i in range(n):
        for j in range(i+1, n):
            if s[i] == L[ii] and s[j] == L[(ii+1)%3] or \
                s[j] == L[ii] and s[i] == L[(ii+1)%3]:
                ans += C[(ii+2)%3][j]
                if j + (j-i) < n and s[j + (j-i)] == L[(ii+2)%3]:
                    ans -= 1
print(ans)

Measured memory_bytes: 68508
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define MAX 100005
typedef long long int ll;
typedef long int li;

vector<int> adj[MAX];
bool vis[MAX];
int d[MAX],c[MAX];

int k = 2,ans = 0;

void dfs(int u) {
    vis[u] = true;
    for(int v : adj[u]) {
        if(!vis[v]) {
            d[v] = c[k++];
            ans += d[v];
            dfs(v);
        } 
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    int n,x,y,num;
    cin>>n;
    for(int i=1;i<n;i++) {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    for(int i=1;i<=n;i++) cin>>c[i];
    sort(c+1,c+n+1,greater<int>());
    d[1] = c[1];
    
    dfs(1);
    
    cout<<ans<<"\n";
    for(int i=1;i<=n;i++) cout<<d[i]<<" ";
    return 0;
}

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

int main() {
	long n,k,u, s = 1;
  	cin >> n >> k;
  	s = k;
  	for(long i = 0; i<100; i++){
      for(long j = 0; j<=i; j++){
        s = s*k;
      }
      if (s > n){
        u = i + 1;
        break;
      }
      s = 1;
    }
  	cout << u << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  int n;
  cin >> n;
  Sieve sieve(1e6);
  ll ans = 0;
  for(int i = 1; i < n; i++){
    ll num = 1;
    auto f = sieve.factor(n - i);
    for (auto p : f) {
      num *= (p.second + 1);
    }
    ans += num;
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const int maxx=1e5+10;
int a,b;
ll gcd(ll x,ll y)
{
    return y==0?x:gcd(y,x%y);
}
unsigned long long k;
int main()
{
     cin>>a>>b;
//     k=a*b;
//     cout<<k<<endl;
     cout<<a/gcd(a,b)*b<<endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn
import scala.collection.mutable.Buffer
import scala.annotation.tailrec

object Main extends App {
  val n = StdIn.readInt
  val a = Iterator.continually(StdIn.readInt)
    .take(n)
    .toArray
    .toBuffer
  0 +=: a

  val end = 2
  val visit = Array.ofDim[Boolean](n+1)
  @tailrec
  def rec(cnt:Int, from:Int):Int = {
      val to = a(from)
      if(to == end) cnt
      else if(visit(from)) return -1
      else {
        visit(from) = true
        rec(cnt+1, to)
      }
  }

  val ans = rec(1, 1)

  println(ans)
}

Measured memory_bytes: 38388
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    string s;cin>>s;
    ll n=s.size();
    vector<vector<ll> >dp(n+1,vector<ll>(26));
    rep(i,26){
        dp[n][i]=1;
    }
    for(int i=n-1;i>=0;i--){
        rep(j,26){
            dp[i][j]=dp[i+1][j];
        }
        ll a=n;
        rep(j,26){
            if(dp[i][j]<a){
                a=dp[i][j];
            }
        }
        dp[i][s[i]-'a']=a+1;
    }
    string ans="";
    ll now=n;
    ll idx=26;
    rep(i,26){
        if(now>dp[0][i]){
            now=dp[0][i];
            idx=i;
        }
    }
    ans+=(char)('a'+idx);
    rep(i,n){
        if(s[i]-'a'!=idx)continue;
        rep(j,26){
            if(now>dp[i+1][j]){
                now--;
                idx=j;
            }
        }
        ans+=(char)('a'+idx);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 51892
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int N;
void lucas(int64_t lx,int64_t ly,int k){
  if(k==N){
    cout << lx << endl;
  }else{
    lucas(ly,lx+ly,k+1);
  }
}

int main(){
  int64_t ans = 0LL;
  cin >> N;
  lucas(2,1,0);
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ai = []
for i in range(N):
    ai.append(A[i] - (i + 1))
# print(ai)
ai.sort()

# Nの偶奇に依らず、中央値はこのように表せることが知られている
med = ai[N // 2]

ans = 0
for i in range(N):
    tmp = abs(ai[i] - med)
    ans += tmp
print(ans)


Measured memory_bytes: 30788
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def dfs(graph: list, node: int, start: int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF] * node

    # 始点ノードの距離を0とし、dfsのためのstackを作成
    dist[start] = 0
    stack = [(0, start)]

    while stack:
        cost, cur_node = stack.pop()

        # 未探索のノードをstackに入れる
        for nex_cost, nex_node in graph[cur_node]:
            if dist[nex_node] != INF:
                continue
            else:
                dist[nex_node] = dist[cur_node] + nex_cost
                stack.append((dist[nex_node], nex_node))

    return dist


n, m, p = li()
edges = []
for _ in range(m):
    ai, bi, ci = li()
    ai -= 1
    bi -= 1
    ci -= p
    edges.append((ai, bi, ci))

# グラフ構築
one2n = [[] for _ in range(n)]
n2one = [[] for _ in range(n)]
for ai, bi, _ in edges:
    one2n[ai].append((ci, bi))
    n2one[bi].append((ci, ai))

# 1から到達可能な点を抽出
one2n_dist = dfs(one2n, n, 0)
one2n_reachable = set()
for i, di in enumerate(one2n_dist):
    if di != float('inf'):
        one2n_reachable.add(i)

# Nから到達可能な点を抽出
n2one_dist = dfs(n2one, n, n-1)
n2one_reachable = set()
for i, di in enumerate(n2one_dist):
    if di != float('inf'):
        n2one_reachable.add(i)

one2n_path = one2n_reachable & n2one_reachable


# ベルマンフォード
INF = float('inf')
dist = [-INF]*n
dist[0] = 0

for _ in range(n):
    for ai, bi, ci in edges:
        if ai in one2n_path and bi in one2n_path and dist[ai] + ci > dist[bi]:
            dist[bi] = dist[ai] + ci

aftern = dist[n-1]

modified = False

for ai, bi, ci in edges:
    if ai in one2n_path and bi in one2n_path and dist[ai] + ci > dist[bi]:
        modified = True

# N+1回で更新されていれば-1
if modified:
    print(-1)
else:
    print(max(0, aftern))

Measured memory_bytes: 49164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 1e5 + 10;
VI adj[N];
int col[N];
bool bip = true;
int f[3];

void dfs(int u, int c) {
  if (col[u] != 0) {
    if (c != col[u]) bip = false;
    return;
  }
  col[u] = c;
  f[c]++;

  for (int v: adj[u]) {
    dfs(v, 3 - c);
  }
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  int m; cin >> m;
  for (int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  dfs(1, 1);
  ll ans = 0;
  if (!bip) {
    ans = (n * 1ll * (n - 1)) / 2 - m;
  } else {
    ans = f[1] * 1ll * f[2] - m;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main()
{
    int n, ans=0, a[26], b[26], c;
    string s;
    cin>>n>>s;
    for (int i=0; i<n-1; i++)
    {
        c=0;
        for (int j=0; j<26; j++) { a[j]=0; b[j]=0; }
        for (int j=0; j<=i; j++) a[s[j]-'a']=1;
        for (int j=i+1; j<n; j++) b[s[j]-'a']=1;
        for (int j=0; j<26; j++)
        {
            if (a[j] && b[j]) c++;
        }
        ans=max(ans, c);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define print(x) cout << x << "\n"
typedef long long LL;
typedef vector<LL> vll;

int main() {
    fastcin;
    vll s;
    LL n, in, sum = 0;
    cin >> n;
    s.push_back(0);
    rep(i, 0, n) {
        cin >> in;
        sum += in;
        s.push_back(sum);
    }
    LL l, r, ll, lr, rl, rr, ms, mb, ans = __LONG_LONG_MAX__;
    int wl = 0, wr = 2;
    rep(i, 2, n-1) {
        l = s[i];
        r = s[n]-l;
        ll = s[wl];
        lr = l-ll;
        rl = s[wr]-s[i];
        rr = r-rl;
        while(wl<i-1) {
            LL tmp = s[wl+1]-s[wl];
            if(abs(lr-ll)>abs(lr-tmp-(ll+tmp))) {
                lr -= tmp;
                ll += tmp;
                wl++;
            } else break;
        }
        while(wr<n-1) {
            LL tmp = s[wr+1]-s[wr];
            if(abs(rr-rl)>abs(rr-tmp-(rl+tmp))) {
                rr -= tmp;
                rl += tmp;
                wr++;
            } else break;
        }
        ms = min({ll, lr, rr, rl});
        mb = max({ll, lr, rr, rl});
        ans = min(ans, mb-ms);
    }
    print(ans);
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    for (auto n = 1; n <= N; n++) {
        int max = ceil(sqrt(n));
        int count = 0;
        for (auto x = 1; x <= max; x++) {
            for (auto y = x; y <= max; y++) {
                for (auto z = y; z <= max; z++) {
                    if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
                        if (x == y && y == z) {
                            count += 1;
                        } else if (x == y || y == z) {
                            count += 3;
                        } else {
                            count += 6;
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int k,s; cin >> k >> s;
    int ans=0;
    for(int x=0; x<=k; x++){
        for(int y=0; y<=k; y++){
            if(s-x-y<=k && 0<=s-x-y) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) A[i] = in.nextInt();
		Arrays.sort(A);
		int[] B = new int[N];
		for(int i = 0; i < N; i++) B[i] = in.nextInt();
		Arrays.sort(B);
		int[] C = new int[N];
		for(int i = 0; i < N; i++) C[i] = in.nextInt();
		Arrays.sort(C);
		
		long[] ab = new long[N];
		long[] bc = new long[N];
		
		int index = 0;
		for(int i = 0; i < N; i++){
			//System.out.println(i + " " + index);
			if(index >= N || A[index] >= B[i]){
				if(i != N - 1) ab[i+1] = ab[i];
				continue;
			}
			
			int indexStart = index;
			while(index <= N - 1 && A[index] < B[i]) index++;
			ab[i] += index - indexStart;
			
			if(i != N - 1) ab[i+1] = ab[i];
		}
		
		/*
		for(int aabb : ab) System.out.print(aabb + " ");
		System.out.println();
		*/
		
		index = 0;
		for(int i = 0; i < N; i++){
			//System.out.println(i + " " + index);
			if(index >= N || B[index] >= C[i]){
				if(i != N - 1) bc[i+1] = bc[i];
				continue;
			}
			
			while(index <= N - 1 && B[index] < C[i]){
				bc[i] += ab[index];
				index++;
			}
			
			if(i != N - 1) bc[i+1] = bc[i];
		}
		
		/*
		for(int bbcc : bc) System.out.print(bbcc + " ");
		System.out.println();
		*/
		
		long ans = 0;
		for(long bbcc : bc) ans += bbcc;
		System.out.println(ans);
	}
}


Measured memory_bytes: 91840
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL 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] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL H, W;
	cin >> H >> W;
	LL h, w;
	cin >> h >> w;

	O(H * W - (h * W + w * H) + h * w);


	return 0;
}

Measured memory_bytes: 256
x = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

ans = 0
i = 1
p = 2
if x == 1:
    print(1)
else:
    while p <= 1000:
        while pow(p, i) <= x:
            if pow(p, i)<= x:
                ans = max(ans, pow(p, i))
            i += 1
        i = 2
        p += 1
    print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


class Puzzle
{
public:
	int N, K;
	vector<int> As;
	int ss;

	void input()
	{
		cin >> N >> K;

		int a;
		for (int ni = 0; ni < N; ni++) {
			cin >> a;
			As.push_back(a);
		}
	}

	void play()
	{
		int s = get_s();
		int cost = get_cost(s);
		for (int si = s - 1; si >= 0; si--) {
			int new_cost = get_cost(si);
			if (new_cost < cost) cost = new_cost;
			if (As[si + K - 1] < 0) break;
		}
		printf("%d", cost);
	}

	int get_s()
	{
		int s = N;
		for (int vi = 0; vi < As.size(); vi++) {
			if (As[vi] >= 0) {
				s = vi;
				break;
			}
		}
		ss = s;

		int s_max = N - K;
		if (s > s_max) s = s_max;
		return s;
	}

	int get_cost(int s)
	{
		int cost1 = abs(As[s]) + As[s + K - 1] - As[s];
		int cost2 = abs(As[s + K - 1]) + As[s + K - 1] - As[s];
		int cost = min(cost1, cost2);

		return cost;
	}

};


int main()
{

	Puzzle puz;

	puz.input();
	puz.play();

	return 0;
}



Measured memory_bytes: 892
#include <iostream>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define li long long int //defineしたなら使おう．li* でlong long int*にもなるよ

//C[]に入れてからcountに足さなくても，
//countに直接足せばいいと思う(たぶん)
//void city(li* A,li* B,int i,int j) で宣言して，(li *Cをなくすってこと)
//以下のコメントぽく書き換えるとよさげ
//もちろんli count はグローバル宣言しないといけない
void city(long long int* C,long long int* A,long long int* B,int i,int j){
  if(A[i]>=B[j]){
    C[i]+=B[j]; //count += B[j];
    A[i]-=B[j];
    B[j]=0;
  }else{
    C[i]+=A[i]; //count += A[i];
    B[j]-=A[i];
    A[i] = 0; //
  }
 
 
}
 
int main (){
  int N;
  cin >>N;
  long long int A[N+1],B[N],C[N+1]={0};
  for(int i=0;i<N+1;i++)// rep使える
    cin >>A[i];
  rep(i,N)
    cin >>B[i];
  for(int i=N;i>0;i--){
    city(C,A,B,i,i-1);
    city(C,A,B,i-1,i-1);
  }

  long long int count=0;
  for(int i=0;i<N+1;i++){ // rep使える
    count+=C[i];
  
  }
 
  cout << count;
 
 
 
 
 
 
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main{
  public static void main(String[] args) {
    try {
      Scanner scan = new Scanner(System.in);
      int n, d, x, i=0, choco = 0;

      n = Integer.parseInt(scan.next());
      d = Integer.parseInt(scan.next());
      x = Integer.parseInt(scan.next());

      int a[] = new int[n];

      while(i<n){
        a[i] = Integer.parseInt(scan.next());
        a[i] = (d-1)/a[i];
        i = ++i;
      }

      i = 0;

      while(i<n){
        choco = choco + a[i];
        i = ++i;
      }

      System.out.println(x + n + choco);

    }
    catch (Exception e) {

    }
  }
}


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

#define endl "\n"

#define pi 2*acos(0)
#define INF 1e16
#define MIN 1e-9
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define m_p make_pair
#define p_b push_back
#define ff first
#define ss second
#define n_p(a) next_permutation(all(a))
#define all(v) v.begin(),v.end()
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define rev(s) reverse(all(s))
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define mem(a,k) memset(a,k,sizeof a)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define u_b(X,V) upper_bound(X.begin(),X.end(),V)
#define l_b(X,V) lower_bound(X.begin(),X.end(),V)
#define cnt(s,c) count(all(s),c)

//bitwise helpers
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

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

    int t;

    //cin >> t;
    t = 1;
    for(int test = 1; test <= t ; test++) {
        char c;
        cin >> c;
        if(c == 'A')
            cout << "T" << endl;
        else if(c == 'C')
            cout << "G" << endl;
        else if(c == 'T')
            cout << "A" << endl;
        else
            cout << "C" << endl;
    }

    return 0;
}


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

int main() {
    int n;
    while (cin >> n, n) {
        vector<long long int> v(n + 1);
        v[0] = 1L;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= 3; j++) {
                if(i + j <= n)
                    v[i + j] += v[i];
            }
        }
        cout << (v[n] + 3649L) / 3650L << endl;
    }

    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<ll> A(n);
  rep(i,n)cin >> A.at(i);
  vector<ll> D(n);
  rep(i,n){
    D.at(i) = A.at(i)-(i+1);
  }
  sort(D.begin(),D.end());
  ll median;
  if(n%2==0)median=(D.at(n/2)+D.at(n/2-1))/2;
  else median=D.at(n/2);
  ll ans = 0;
  rep(i,n){
    ans+=abs(D.at(i)-median);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>
int main(void){
   int i,x;
   for(i = 1; i < 10001; i++) {
   scanf("%d", &x);
   if(x == 0) {
   break;
 }

  printf("Case %d: %d\n", i, x);
   }
   return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define inf 100000000000000005LL

signed main()
{
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n; cin>>n;
    map< int,pii > m;
    map<int,int> vis;
    for(int i=0;i<n;i++){
    	int x,y; cin>>x>>y;
    	if(vis[x]==1){
    		m[x].ff=min(m[x].ff,y);
    		m[x].ss=max(m[x].ss,y);
    	}
    	else{
    		m[x].ff=m[x].ss=y;
    		vis[x]=1;
    	}
    }
 
    pair< int,pii > p=*m.begin();
    int a=-p.ff-p.ss.ff,b=-p.ff+p.ss.ss,ans=p.ss.ss-p.ss.ff;
    for(auto it=++m.begin();it!=m.end();it++){
    	pair< int,pii > q=*it;
    	ans=max({ans,q.ss.ss-q.ss.ff,q.ff+q.ss.ss+a,q.ff-q.ss.ff+b});
    	a=max(a,-q.ff-q.ss.ff);
    	b=max(b,-q.ff+q.ss.ss);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 28644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread(){}
template<class T1, class ...T2>
inline void qread(T1 &IEE, T2&... ls){
    register T1 __ = 0, ___ = 1;
    register char ch;
    while(!isdigit(ch = getchar())) ___ = (ch == '-') ? -___ : ___;
    do{
        __ = (__ << 1) + (__ << 3) + (ch ^ 48);
    }while(isdigit(ch = getchar()));
    __ *= ___;
    IEE = __;
    qread(ls...);
    return ;
}
ll n;
string s;
int main(){
    cin >> n >> s;
    if(n >= s.size()){
        cout << s << endl;
    } else {
        for(int i = 0;i < n;i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
	int i,j;
	int r,c;
	int sum=0;
	int total=0;
	int hyou[100][100];
	/*?????????*/
	for(i=0;i<100;i++){
		for(j=0;j<100;j++){
			hyou[i][j]=0;
		}
	}
	/*??°????????\???*/
	scanf("%d %d",&r,&c);
	for (i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&hyou[i][j]);
		}
	}
	/*??¨?????????*/
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			printf("%d ",hyou[i][j]);
			sum+=hyou[i][j];
		}
		printf("%d\n",sum);
		sum=0;
	}
	/*????????????????????????*/
	for(j=0;j<c;j++){
		for(i=0;i<r;i++){
			sum+=hyou[i][j];
			
		}
	printf("%d ",sum);
	total+=sum;
	sum=0;
	}
	printf("%d\n",total);
	return 0;
}

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


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

	int ali[105] = {0};
	int bob[105] = {0};
	for(int i = 0; i < 101; i++){
		if(a <= i and i < b) ali[i] = 1;
		if(c <= i and i < d) bob[i] = 1;
	}
	int cnt = 0;
	for(int i = 0; i < 101; i++){
		if(ali[i] == 1 and bob[i] == 1) cnt++;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    rep(i, N) { cout << s[i] << t[i]; }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(void){
    int N; cin >> N;
    string S; cin >> S;
    
    ll r=0, g=0, b=0;
    for (auto c : S){
        if (c=='R') r++;
        if (c=='G') g++;
        if (c=='B') b++;
    }
    
    ll ans = r * g * b;
    for (int d = 1; d <= N; d++){
        for (int m = 1; m < N-1; m++){
            if (m-d<0||m+d>N-1) continue;
            if (S[m-d]!=S[m+d] && S[m-d]!=S[m] && S[m]!=S[m+d]) ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main()
{
 int N;cin>>N;
 pair<pair<string,int>,int> S[N];
 for(int i = 0;i<N;i++){
 	string moji;
    int p;
    cin>>moji>>p;
    S[i] = make_pair(make_pair(moji,-p),i);
 }
 sort(S,S+N);
 for(auto x:S){
   cout<<x.second+1<<endl;
 }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
S, C = map(int, input().split())
ret = 0
if 2 * S <= C:
    ret += S
    C -= 2 * S
    S = 0
else:
    ret += C // 2
    S -= C // 2
    C %= 2

ret += C // 4
print(ret)




Measured memory_bytes: 9120
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

vll VL,VM;

ll dfs(int LV, ll rest) {
	if (LV == 0)return 1;
	if (rest >= VL[LV]) {
		return VM[LV];
	}
	ll ret = 0;
	rest -= 1;
	if (rest <= 0)return ret;
	ret += dfs(LV - 1, rest);
	rest -= VL[LV - 1];
	if (rest <= 0)return ret;
	ret++;
	rest--;
	if (rest <= 0)return ret;
	ret += dfs(LV - 1, rest);
	rest -= 1;
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, X;
	cin >> N >> X;
	VL.push_back(1);
	VM.push_back(1);
	ll lv_pre = 1;
	ll meat = 1;
	REP(i, N) {
		lv_pre *= 2;
		lv_pre += 3;
		meat *= 2;
		meat += 1;
		VL.push_back(lv_pre);
		VM.push_back(meat);
	}
	cout << dfs(N, X) << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
import java.util.Scanner;
import java.util.ArrayList;

public class Main {

  public static void main(String[] args) {

    ArrayList<Integer> t1 = new ArrayList<Integer>();
    ArrayList<Integer> t2 = new ArrayList<Integer>();
    ArrayList<Integer> t3 = new ArrayList<Integer>();
    ArrayList<Integer> t4 = new ArrayList<Integer>();
    for (int i = 1; i <= 30; i++) {
      t1.add(0);
      t2.add(0);
      t3.add(0);
      t4.add(0);
    }

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();

    for (int i = 0; i < n; i++) {
      int b = scan.nextInt();
      int f = scan.nextInt();
      int r = scan.nextInt();
      int v = scan.nextInt();

      switch (b) {
      case 1:
        t1.set((f-1) * 10 + (r-1), t1.get((f-1) * 10 + (r-1)) + v);
        break;

      case 2:
        t2.set((f-1) * 10 + (r-1), t2.get((f-1) * 10 + (r-1)) + v);
        break;

      case 3:
        t3.set((f-1) * 10 + (r-1), t3.get((f-1) * 10 + (r-1)) + v);
        break;

      case 4:
        t4.set((f-1) * 10 + (r-1), t4.get((f-1) * 10 + (r-1)) + v);
        break;
      }

    }

    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 9; j++) {
        System.out.print(" " + t1.get(10 * i + j));
      }
      System.out.println(" " + t1.get(10 * i + 9));
    }

    for (int i = 0; i < 20; i++) {
      System.out.print("#");
    }
    System.out.println();

    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 9; j++) {
        System.out.print(" " + t2.get(10 * i + j));
      }
      System.out.println(" " + t2.get(10 * i + 9));
    }

    for (int i = 0; i < 20; i++) {
      System.out.print("#");
    }
    System.out.println();
    
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 9; j++) {
        System.out.print(" " + t3.get(10 * i + j));
      }
      System.out.println(" " + t3.get(10 * i + 9));
    }

    for (int i = 0; i < 20; i++) {
      System.out.print("#");
    }
    System.out.println();
    
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 9; j++) {
        System.out.print(" " + t4.get(10 * i + j));
      }
      System.out.println(" " + t4.get(10 * i + 9));
    }

  }

}


Measured memory_bytes: 29440