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

int main(){
  int N,M,s;
  char c;
  string ans;
  cin >> N >> M;
  if (N == 1) ans = "A";
  if (N == 2) ans = "AA";
  if (N == 3) ans = "AAA";
  for (int i=0; i<M; i++){
    cin >> s >> c;
    if ( ans.at(s-1) != 'A' && ans.at(s-1) != c){
      ans = "-1";
      break;
    }
    ans.at(s-1) = c;
  }
  if(ans.at(0) == '0' && ans.size() != 1) ans = "-1";
  if(ans.at(0) == 'A' && ans.size() != 1) ans.at(0) = '1';
  if( ans != "-1"){
    for (int i=0; i<N;i++){if (ans.at(i) == 'A') ans.at(i) = '0';}
  }

  cout << ans << endl;    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

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


    multiset<int> st;
    vector<int> ans;
    rep(k,n){
        if(st.count(-a[k])==0){
            st.insert(a[k]);
        }else{
            st.erase(st.find(-a[k]));
        }

        if(st.count(a[n-k-1])==0){
            st.insert(-a[n-k-1]);
        }else{
            st.erase(st.find(a[n-k-1]));
        }

        if(st.size()==0)ans.pb(k);
    }
    rep(i,ans.size()){
        if(i)cout<<" ";
        cout<<ans[i]+1;
    }
    cout<<endl;
}



Measured memory_bytes: 4192
while io = gets
  a,b,c,d,e,f = io.split(" ").map(&:to_f)
  delta = a*e-b*d
  x = ((e*c-b*f)/delta).round(3)
  y = (a*f-c*d)/delta.round(3)
  if x == 0
    x = 0.000
  end
  if y == 0
    y = 0.000
  end
  puts "#{sprintf("%.3f", x)} #{sprintf("%.3f", y)}"
end

Measured memory_bytes: 8816
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
int n;cin>>n;

vector<pair<int,int>> V(n);

rep(i,n){
    cin>>V.at(i).second;
    cin>>V.at(i).first;
}

bool ans=1;

sort(V.begin(),V.end());

int tim=0;
rep(i,n){
    tim+=V.at(i).second;
    if(!(tim<=V.at(i).first)){
        ans=0;break;
    }
}
if(ans) cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
import collections
import math
def c_c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

B= collections.Counter(A)
l=0
for b in B.values(): 
  if b>=2:
    l+=c_c(b,2) 

for k in range(N):
  if B[A[k]]==0 or B[A[k]]==1:
    print(l)
  else:
    print(l-B[A[k]]+1)
    

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

int A[20004];

int solve(int a, int b, int c, int N)
{
    A[1] = a, A[2] = b, A[3] = c;
    int sum = a+b+c, ptr = 2;
    int lcm = a * b * c;
    
    while(ptr == a || ptr == b || ptr == c || (ptr%a && ptr%b && ptr%c))
        ptr++;
    
    for(int i=4; i<N; i++)
    {
        A[i] = ptr++;
        
        while(ptr == a || ptr == b || ptr == c || (ptr%a && ptr%b && ptr%c))
            ptr++;
        
        sum += A[i];
    }
    
    while((sum + ptr) % lcm)
    {
        ptr++;
        
        while(ptr == a || ptr == b || ptr == c || (ptr%a && ptr%b && ptr%c))
            ptr++;
        
        if(ptr > 30000)
            return 0;
    }
    
    A[N] = ptr;
    return 1;
}

int main() {
    
    cin.tie(NULL), cout.tie(NULL);
    
    int N;
    cin >> N;
    
    if(N == 3)
    {
        cout << "2 5 63\n";
        return 0;
    }
    
    int prime[12] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
    
    for(int i=0; i<11; i++)
        for(int j=i+1; j<11; j++)
            for(int k=j+1; k<11; k++)
            {
                if(solve(prime[i], prime[j], prime[k], N))
                {
                    for(int x=1; x<=N; x++)
                        cout << A[x] << " ";
                    cout << "\n";
                    
                    return 0;
                }
            }
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int N, A;
queue<long long> que;
int main () {
    que.push(0);
    que.push(0);
    scanf("%d%d", &N, &A);
    long long x = A;
    for (int i = 2; i <= N; i++) {
        scanf("%d", &A);
        if (i % 2 == 0) {
            que.push(max(que.front()+A, x));
        }
        else {
            que.push(max(que.front()+A, que.back()));
            x += A;
        }
        que.pop();
    }
    printf("%lld\n", que.back());
}

Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC157 {
    public class B {
        static void Main(string[] args) {
            var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var c = inputs[0];
            var between = inputs[1] + inputs[2];


            var answer = c/between * inputs[1] + Math.Min(c%between, inputs[1]);
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
H,W = map(int,input().split())
maze = []
maze.append(list("w" * (W+2)))
for i in range(H):
    k = input()
    maze.append(list("w" + k + "w"))
maze.append(list("w" * (W+2)))

d = [[1,1],[1,0],[1,-1],[0,1],[0,-1],[-1,1],[-1,0],[-1,-1]]

ans = []
for i in range(1,H+1):
    for j in range(1,W+1):
        if maze[i][j] == "#":
            continue
        line = []
        bomb = 0
        for dy,dx in d:
            if maze[i+dy][j+dx] == "#":
                bomb += 1
        maze[i][j] = str(bomb)

for i in range(1,H+1):
    print("".join(map(str,maze[i][1:W+1])))

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

int main() {
  
  int64_t N, Y; cin >> N >> Y;
  
  for (int i = 0; i <= N; i++) {
    
    for (int j = 0; j <= N - i; j++) {
      
      int Yukichi = i, Higuchi = j, Noguchi = N - i - j;
      
      if (Yukichi * 10000 + Higuchi * 5000 + Noguchi * 1000 == Y) {
        
        cout << Yukichi << " " << Higuchi << " " << Noguchi << endl;
        
        return 0;
        
      }
      
    }
    
  }
  
  cout << "-1 -1 -1" << endl;
  
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
 
int main(){
  string s; cin >> s;
  int n = s.size();
  for(int i = 0; i < n; i++){
    if(i+1 < n && s[i] == s[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
    if(i+2 < n && s[i] == s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)

	for i := 1; i < 1005; i++ {
		if i*8/100 == a && i*10/100 == b {
			fmt.Fprintln(writer, i)
			return
		}
	}
	fmt.Fprintln(writer, -1)
}


Measured memory_bytes: 1816
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int ans =0, n, m;
Int dp[5500];
int main(){
    dp[0] = 1;
    cin >> n >> m;
    for(int i = 2;i <= n;i++){
        Int need = 0;
        if(i >= n - n/2 + 1)need = n-i+2;
        else need = n/2 + 1;
        if(i <= n / 2 + 1)need -= n/2 + 1 - i + 1;
//        cout << need << endl;
        for(int j = need;j <= n;j++){
            dp[j] += dp[j-need];
            dp[j] %= m;
        }
    }
    for(int i = 0;i < n;i++){
//        cout << i << " " << dp[i] << endl;
        ans += dp[i] * (n-i) % m;
        ans %= m;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef complex<double> C;

typedef string::const_iterator State;
int formula(State& begin, int s);
int factor(State& begin, int s);

void consume(State& begin, char expected) {
    if (*begin == expected) begin++;
    else {
        cout << "expected: " << expected << endl;
        cout << "but *begin is " << *begin << endl;
        cout << "rest string is" << endl;
        while (*begin) {
            cout << *begin++ ;
        }
        cout << endl;
        exit(1);
    }
}

int formula(State& begin, int s) {
    if (*begin == '-') {
        consume(begin, '-');
        return 2-formula(begin, s);
    } else if (*begin == '(') {
        consume(begin, '(');
        int ret = formula(begin, s);
        if (*begin == '*') {
            consume(begin, '*');
            ret = min(ret, formula(begin, s));
        } else if (*begin == '+') {
            consume(begin, '+');
            ret = max(ret, formula(begin, s));
        }
        consume(begin, ')');
        return ret;
    } else {
        return factor(begin, s);
    }
}

int factor(State& begin, int s) {
    int ret = 0;
    if (isdigit(*begin)) ret = *begin - '0';
    else {
        if (*begin == 'P') ret = ((s%3));
        else if (*begin == 'Q') ret = ((s/3)%3);
        else ret = ((s/9));
    }
    begin++;
    return ret;
}

void solve(const string& s) {
    int ans = 0;
    for (int S = 0; S < 27; S++) {
        State begin = s.begin();
        if (formula(begin, S) == 2) ans++;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    while (cin >> s) {
        if (s == ".") break;
        solve(s);
    }
    return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
#define N 200000
int main(){
  int n,i,j,maxv,minv;
  int data[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  maxv=data[1]-data[0];
  minv=data[0];
  for(j=1;j<n;j++){
    if(maxv<data[j]-minv){
      maxv= data[j]-minv;
    }
    if(minv>data[j]){
      minv=data[j];
    }
  }
  printf("%d\n",maxv);
  return 0;
}



Measured memory_bytes: 2512
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	int a[30] = { 0 };

	REP(i, n) {
		int k;
		scanf("%d", &k);
		REP(j, k) {
			int like;
			scanf("%d", &like);
			a[like-1]++;
		}
	}
	int ans = 0;
	REP(i, m) {
		if (a[i] == n)ans++;
	}
	PRINTD(ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long M, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d)
{
  LL ans = 0;
  function<void(vector<int>)> dfs = [&](vector<int> cur) {
    int n = cur.size();
    if (n == 0)
    {
      for (int i = 1; i <= M; i++)
      {
        auto nxt = cur;
        nxt.push_back(i);
        dfs(nxt);
      }
      return;
    }
    if (n == N)
    {
      LL score = 0;
      for (int i = 0; i < Q; i++)
      {
        int A = a[i] - 1;
        int B = b[i] - 1;
        int C = c[i];
        int D = d[i];
        if (cur[B] - cur[A] == C)
          score += D;
      }
      chmax(ans, score);
      return;
    }
    for (int i = cur.back(); i <= M; i++)
    {
      auto nxt = cur;
      nxt.push_back(i);
      dfs(nxt);
    }
  };
  vector<int> data;
  dfs(data);
  cout << ans << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  long long Q;
  scanf("%lld", &Q);
  std::vector<long long> a(Q);
  std::vector<long long> b(Q);
  std::vector<long long> c(Q);
  std::vector<long long> d(Q);
  for (int i = 0; i < Q; i++)
  {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    scanf("%lld", &c[i]);
    scanf("%lld", &d[i]);
  }
  solve(N, M, Q, std::move(a), std::move(b), std::move(c), std::move(d));
  return 0;
}


Measured memory_bytes: 3636
q = int(input())

bit_flag = 0
BIT_MASK = (1 << 64) - 1

for _ in range(q):

    command, *list_num = input().split()

    if   command == "0":
        # test(i)
        i = int(list_num[0])
        if bit_flag & (2 ** i):
            print(1)
        else:
            print(0)
    elif command == "1":
        # set(i)
        i = int(list_num[0])
        bit_flag = bit_flag | (2 ** i)
    elif command == "2":
        # clear(i)
        i = int(list_num[0])
        bit_flag = bit_flag & ~(2 ** i)
    elif command == "3":
        # flip(i)
        i = int(list_num[0])
        bit_flag = bit_flag ^ (2 ** i)
    elif command == "4":
        # all
        if not(~bit_flag & BIT_MASK):
            print(1)
        else:
            print(0)
    elif command == "5":
        # any
        if bit_flag:
            print(1)
        else:
            print(0)
    elif command == "6":
        # none
        if not bit_flag:
            print(1)
        else:
            print(0)
    elif command == "7":
        # count
        print("{:64b}".format(bit_flag).count("1"))
    elif command == "8":
        # val
        print(bit_flag)
    else:
        raise



Measured memory_bytes: 5632
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] S = sc.next().split("");
    for (int i = 0; i < Math.pow(2,S.length-1); i++) {
      int total = Integer.parseInt(S[0]);
      StringBuilder answer = new StringBuilder(S[0]);
      for (int j = 0; j < S.length-1; j++) {
        if((1 & i>>j) == 1) {
          total += Integer.parseInt(S[j+1]);
          answer.append("+").append(S[j+1]);
        } else {
          total -= Integer.parseInt(S[j+1]);
          answer.append("-").append(S[j+1]);
        }
      }
      if (total == 7) {
        System.out.println(answer.append("=7").toString());
        break;
      }
  	}
  }
}

Measured memory_bytes: 21844
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

#a = list(map(int, input().split()))


a,b = list(map(int, input().split()))

ans=0

while(a>=1):
    ans+=1
    a-=b
    
print(ans)

Measured memory_bytes: 66156
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


Int gcd(Int a, Int b){
    Int p, q, r, s;
    p = a > b ? a : b;
    q = a > b ? b : a;
    while(true){
        s = p/q;
        r = p%q;
        if(r==0){
            break;
        }else{
            p = q;
            q = r;
        }
    }
    return q;
}

Int findFactors(Int num){
    Int cnt = 1;
    bool flg = true;
    
    Int j=2;
    while(j*j <= num){
        if(num%j==0){
            cnt++;
            while(num%j==0) num/=j;
        }
        j++;
    }
    if(num > 1){
        cnt++;
    }
    return cnt;
}

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

    Int a, b;
    cin >> a >> b;

    Int g = gcd(a, b);
    Int ans = findFactors(g);

    // for(auto nn : n){
    //     cout << nn << endl;
    // }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 1
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

N = k()
 
for i in range(1,N+1):
    if 2*N <= (i+1)*i:
        print(i)
        break

Measured memory_bytes: 10472
numS = int(input())
num1 = [int(i) for i in input().split()]
num1.sort(reverse=True)

numA = []
numB = []

for index1 in range(numS ):
    if index1%2 == 0:
        numA.append(num1[index1])
    else:
        numB.append(num1[index1])

print(str(sum(numA) - sum(numB)))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


int main()
{
	int n;
	int a,b,t;
	

	cin >> n >> t;

	int *cost = new int[n];
	int *time = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> cost[i] >> time[i];
	}

	int min = 1001;
	int min_t = 1001;
	for (int i = 0; i < n; i++) {
		if (cost[i] < min && time[i] <= t) {
			min = cost[i];
			min_t = i;
		}
	}

	if (min_t == 1001) {
		cout << "TLE" << endl;
	}
	else {
		cout << min << endl;
	}
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 1000000007
#define inf 1000000000
#define limit 200001
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 

void input()
{
    int n;
    cin >> n;
    vi a(n);

    int x = 0;
    rep(i,n)
    {
        cin >> a[i];
        x = x^a[i];
    }

    rep(i,n)
        cout << (x ^ a[i]) << ' ';
    cout << '\n';


}
 
int main()
{
    

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 3964
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}





int main(){
    
    string s; 
    int a[26];
    rep(i,26) a[i] = 0;
    while(getline(cin,s)){
        rep(i,s.length()){
            if(s[i] >= 'A' && s[i] <= 'Z') a[s[i]-'A']++;
            if(s[i] >= 'a' && s[i] <= 'z') a[s[i]-'a']++;
            
        }
    }

    rep(i,26){
            cout << (char)('a'+ i ) << " : " << a[i] << endl;
    }
    
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
const int inf=1e9+7;
int main(){
    int n;
    cin>>n;
    int h[n];
    vector<int> dp(n,inf);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j:{i+1,i+2}){
          if(j<n){
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
          }
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  repr(i, n, 0) {
    cin >> p[i];
  }

  sorti(p);
  int ans = 0;
  for (int i = 0; i < k; ++i) {
   ans += p[i];
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

const int INF = 1e9;
const int N_MAX = 20;

struct P{int dat,i;};
bool operator<(const P &a, const P &b){return a.dat<b.dat;}

int N;
P xx[N_MAX],yy[N_MAX];
int x[N_MAX],y[N_MAX],p[N_MAX];
ll ans[N_MAX];
int X=0,Y=0;
int sx[N_MAX],sy[N_MAX],vx[N_MAX],vy[N_MAX];
int Min[N_MAX];

void dfs(int idx=0)
{
    if (idx==N){
        int pcnt = X+Y;

        vx[0]=-INF; vx[1]=INF; vx[2]=0;
        rep(i,X) vx[i+3]=sx[i];
        vy[0]=-INF; vy[1]=INF; vy[2]=0;
        rep(i,Y) vy[i+3]=sy[i];
        sort(vx,vx+(X+3));
        sort(vy,vy+(Y+3));

        ll sum=0;
        int j=0;
        rep(i,N){
            while(vx[j]<=xx[i].dat) j++;
            Min[xx[i].i] = min(vx[j]-xx[i].dat,xx[i].dat-vx[j-1]);
        }
        j=0;
        rep(i,N){
            while(vy[j]<=yy[i].dat) j++;
            sum += (ll)min(Min[yy[i].i], min(vy[j]-yy[i].dat,yy[i].dat-vy[j-1])) * p[yy[i].i];
        }
        chmin(ans[pcnt],sum);
        return;
    }
    sx[X++]=x[idx]; dfs(idx+1); X--;
    sy[Y++]=y[idx]; dfs(idx+1); Y--;
    dfs(idx+1);
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N;
    rep(i,N){
        cin>>x[i]>>y[i]>>p[i];
        xx[i] = {x[i],i};
        yy[i] = {y[i],i};
    }
    sort(xx, xx+N);
    sort(yy, yy+N);
    rep(i,N+1) ans[i] = (ll)1e18;
    dfs();
    rep(i,N+1) cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define p pair<ll, int>
using namespace std;

int main() {
    int b;
    while (cin >> b, b) {
        ll k = 1;
        vector<p> res;
        while (1) {
            ll idx = b / k;
            ll mmin;
            if (b % k == 0) {
                mmin = idx - k / 2;
            } else {
                mmin = idx - k / 2 + 1;
            }
            if (mmin <= 0) break;
            ll n = mmin + k - 1;
            ll m = mmin - 1;
            ll sum = n * (n + 1) / 2 - m * (m + 1) / 2;
            if (sum == b) res.push_back(p(mmin, k));
            k++;
        }
        ll mmax = -1;
        int f = 0;
        for (int i = 0; i < res.size(); i++) {
            if (mmax < res[i].second) {
                mmax = res[i].second;
                f = i;
            }
        }
        cout << res[f].first << " " << res[f].second << endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	string S;
	cin >> S;
	int L = S.length();

	int ans = 0, p = -1;
	REP(i, L) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			ans = max(ans, i - p);
		}
		else {
			p = i;
		}
	}

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

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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	if(n%1000 == 0)
		cout<<0;
	else
		cout<<1000-n%1000;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;
  cin >> n;
  int a[n], res = -1;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j) continue;
      res = max(res, abs(a[i] - a[j]));
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 36;

/* typedef */

typedef pair<int,char> pic;

struct Card {
  int v, i;
  char s;
  Card() {}
  Card(int _v, char _s, int _i): v(_v), s(_s), i(_i) {}
  bool operator<(const Card &c) const { return v < c.v; }
  void print() { printf("%c%d", s, v); }
};

/* global variables */

Card as[MAX_N], bs[MAX_N], cs[MAX_N];

/* subroutines */

void bubble_sort(int n, Card as[]) {
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j > i; j--)
      if (as[j] < as[j - 1])
	swap(as[j], as[j - 1]);
}

void selection_sort(int n, Card as[]) {
  for (int i = 0; i < n; i++) {
    int mini = i;
    for (int j = i; j < n; j++)
      if (as[j] < as[mini])
	mini = j;
    if (i != mini) swap(as[i], as[mini]);
  }
}

bool stable(int n, Card as[]) {
  for (int i = 0; i < n; i++) {
    Card &ai = as[i];
    for (int j = i + 1; j < n && ai.v == as[j].v; j++)
      if (ai.i > as[j].i) return false;
  }
  return true;
}

void print_cards(int n, Card as[]) {
  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    as[i].print();
  }
  putchar('\n');
}

/* main */

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

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    cs[i] = bs[i] = as[i] = Card(s[1] - '0', s[0], i);
  }

  bubble_sort(n, bs);
  bool bst = stable(n, bs);
  print_cards(n, bs);
  cout << (bst ? "Stable" : "Not stable") << endl;
  
  selection_sort(n, cs);
  bool cst = stable(n, cs);
  print_cards(n, cs);
  cout << (cst ? "Stable" : "Not stable") << endl;

  return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n - 1); i >= 0; --i)
#define D(n, retu)                                                             \
  REP(i, n) { cin >> retu[i]; }
#define mod 1000000007
#define INF 93193111451418101
#define MIN -933111451418101
//#define INF 931931114518101
using namespace std;
typedef pair<ll, ll> P;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
#define yo 100001
//------------------変数-----------------------//
ll n, maxmove = 0, movesize;

//-------------------関数----------------------//

int main() {
  string s;
  cin >> s;
  REP(i, s.size() - 1) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int null=-1;

struct Node{
	int parent;
	int child;
	int sibling;
	int depth;
	int degree;
};
Node *nodes;

/*
int rootSearch(Node *nodes, int n){
	for( int i=0;;i++ ){
		if( nodes[i].parent==null ){
			return i;
		}
	}
}
*/
int traceRoot(Node *nodes, int id){
	if(nodes[id].parent==null) return id;
	else return traceRoot(nodes, nodes[id].parent);
}

int rootSearch(Node *nodes, int n){
	int start;
	for( int i=0;; i++ ){ 
		if( nodes[i].parent==null ) return i;
		else start=i;
	}
	return traceRoot(nodes, start);
}
		


void setDepth( Node *nodes, int id, int d ){
	nodes[id].depth=d;
//	cout<<"d : "<<d;
//	cout<<"id.child"<<nodes[id].child<<endl;
//	cout<<"id.parent"<<nodes[id].parent<<endl;
	if( nodes[id].sibling !=null ){
		setDepth( nodes, nodes[id].sibling, d );
	}
	if( nodes[id].child !=null ){
		setDepth( nodes, nodes[id].child, d+1 );
	}
	
}

void show(Node *nodes, int n){
	for( int id=0; id<n; id++ ){
		cout<<"node "<<id<<": "
			<<"parent = "<<nodes[id].parent<<", "
			<<"depth = "<<nodes[id].depth<<", ";
		if( nodes[id].parent==null ) cout<<"root, ";
		else if( nodes[id].child==null ) cout<<"leaf, ";
		else cout<<"internal node, ";

		cout<<"[";
		if( nodes[id].child !=null ){
			int tp=nodes[id].child;
			cout<<tp;
			for( int i=1; i<nodes[id].degree; i++ ){
				tp=nodes[tp].sibling;
				cout<<", "<<tp;
			}
		}
		cout<<"]"<<endl;

	}
}

int main()
{
	int n;cin>>n;
	nodes=new Node[n];

	for( int i=0; i<n; i++ ) nodes[i].parent=nodes[i].child=nodes[i].sibling=null;

	int root;	
	for( int i=0, id, deg, cld, prevcld; i<n; i++ ){
		cin>>id>>deg;
		nodes[id].degree=deg;
		
		if( deg>0 ){
			for( int j=0; j<deg; j++ ){ //??????????????????.
				cin>>cld;
				nodes[cld].parent=id; //?????????????????????????????????????????????
				
				if( j==0 ){
					nodes[id].child=cld; //????????????????????????????????????
				}else{
					nodes[prevcld].sibling=cld; //??????????????????????????????
				}
				prevcld=cld;
			}

		}
	//	if( nodes[id].parent==null ) root=id; //root???????????????????????????????????????
	}

	root=rootSearch(nodes, n);
	setDepth(nodes, root, 0);
	show(nodes, n);
}


		

Measured memory_bytes: 6256
import std.stdio, std.range;
void main() {
	string s;
	int n, l;
	for(;;) {
		"%s\n".readf(&s);
		if (s == "-") break;
		"%d\n".readf(&n);
		foreach (i; 0..n) {
			"%d\n".readf(&l);
			s = s.drop(l) ~ s.dropBack(s.length - l);
		}
		s.writeln;
	}
}

Measured memory_bytes: 2436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


// 1白
// 2黒

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,now,a,b,w;
	cin >> n;
	vector<int> co(n,0);
	vector<vector<P>> tree;
	tree.resize(n);
	FOR(i,0,n-1){
		cin >> a >> b >> w;
		a--;b--;
		tree[a].push_back({b,w&1});
		tree[b].push_back({a,w&1});
	}
	stack<int> q;
	q.push(0);
	co[0] = 1;
	while(!q.empty()){
		now = q.top();
		q.pop();
		for(auto to:tree[now]){
			if(co[to.first]==0){
				if(to.second){
					co[to.first] = 3 - co[now];
				}else{
					co[to.first] = co[now];
				}
				q.push(to.first);
			}
		}
	}
	FOR(i,0,n){
		cout << co[i]-1 << endl;
	}
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, 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 ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

inline bool inside(ll y, ll x, ll H, ll W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

char G[100][100];

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vll s(100005);
  for(ll i=1; i<100005; i+=2){
    s[i+2]=s[i];
    if(is_prime(i)&&(is_prime((i+1)/2))) s[i+2]++;
  }
  ll q; cin>>q;
  rep(i,q){
    ll l,r; cin>>l>>r;
    r+=2;
    cout<<s[r]-s[l]<<endl;
  }
}

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

int dp[4001][4001];
int main(){

  string str1, str2;
  int ans;
  while(cin >> str1 >> str2){
    ans  = 0;
    // cout << str1 << endl << str2 << endl;
    memset(dp,0,sizeof(dp));
    for(int i = 1; i <= str1.size(); i++){
      for(int j = 1; j <= str2.size(); j++){
        if(str1[i-1] == str2[j-1]){
          dp[i][j] = dp[i-1][j-1] + 1;
          ans = max(ans, dp[i][j]);
        }else dp[i][j] = 0;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 63748
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int n;
long long a[N];

long long b[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    long long x = 2 * a[1];
    for (int i = 2; i < n; ++i)
    {
        if (i % 2 == 0)
            x -= (2 * a[i]);
        else
            x += (2 * a[i]);
    }
    b[1] = (2 * a[n] + x) / 2;
    for (int i = 1; i < n; ++i)
    {
        b[i + 1] = 2 * a[i] - b[i];
    }
    for (int i = 1; i <= n; ++i)
        cout << b[i] << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
using namespace std;
//ll MOD=1000000000000007;
int main()
{
   FAST

ll a,b,c,ans=0;
cin>>a>>b>>c;
//string s;
//int x,y,z;
//s=a;
//x=s.length();
//s=b;
//y=s.length();
//s=c;
//z=s.length();
if(abs(a/c)<b)
{
	b-=a/c;
	a=a%c;
	if(b%2==0)
	ans=abs(a);
	else
	{
		if(a>0)
		ans=abs(a-c);
		else
		ans=abs(a+c);
	}
}
else
{
	if(a>0)
	ans=abs(a-b*c);
	else
	ans=abs(a+b*c);
}



cout<<ans;
}




Measured memory_bytes: 3604
import math
import sys
n,total = map(int, input().split())
count = 0

for x in range(n+1):
    for y in range(n+1):
        z = total - (1000*x+5000*y)
        if (z%10000==0) and ((x + y + int(z/10000)) == n) and (z/10000 >= 0):
            print(int(z/10000), y, x)
            sys.exit()
print(-1, -1, -1)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

var MOD = 1000000000 + 7

func main() {
	var n int
	fmt.Scan(&n)
	ans := 1
	for i := 0; i < n; i++ {
		ans *= 10
		ans %= MOD
	}
	tmp := 1
	for i := 0; i < n; i++ {
		tmp *= 9
		tmp %= MOD
	}
	tmp *= 2
	tmp %= MOD
	ans -= tmp
	ans %= MOD
	if 0 > ans {
		ans += MOD
	}
	tmp = 1
	for i := 0; i < n; i++ {
		tmp *= 8
		tmp %= MOD
	}
	ans += tmp
	ans %= MOD
	fmt.Println(ans)
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  int a = max(H, W);
  int i = 0;
  int j = 0;
  while(i < N){
    i += a;
    j++;
  }
  cout << j << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll n;
    cin>>n;

    ll ans=0;
    for(ll i=1;i<=n;i++){
        ll x=n/i;
        ans+=i*x*(x+1)/2;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define HASH 18014398241046527
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
template <typename T>
ll SIZEOF(T a){return (ll)a.size();}
ll xlcm(ll a, ll b){return (a/__gcd(a, b))*b;}

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





void SOLVE(){
    inp(n);
    ll z = (n+999)/1000;
    z*=1000;
    cout << z-n << '\n';
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif

    ll TC = 1;
    // cin >> TC;
    for(ll tc1=1; tc1<=TC; tc1++){
        // cout << "Case #" << tc1 << ": ";
        SOLVE();
    }
    printclock;
}

Measured memory_bytes: 3844