akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        //char[] S = sc.next().toCharArray();
        int count=0;
        for(int i=1; i<N+1; i++){
            if(i<10){
                count++;
            }
            if(100<=i && i<1000){
                count++;
            }
            if(10000<=i && i<100000){
                count++;
            }
        }

          System.out.println(count);
        }
    }

Measured memory_bytes: 35772
E = [input() for i in range(2)]
E0 = E[0].split()
K = int(E0[0])
N = int(E0[1])
E12 = E[1].split()
E1 = [int(s) for s in E12]
E1.append(K + E1[0])
d = 0
M = 0
gap = []
for k in range(len(E1)-1):
    gap.append(int(E1[k+1]) - int(E1[k]))
    d += gap[k]
    M = max(M, gap[k])


d -= M

print(d)

Measured memory_bytes: 28608
package main

import (
	"fmt"
)

func cal(n int) int {
	if n%2 == 0 {
		n /= 2
	} else {
		n = n*3 + 1
	}
	return n
}

func main() {
	var first, num, ans int

	fmt.Scan(&first)
	sequence := make([]int, 1000000)
	exsits := make(map[int]bool, 1000000)

	sequence[0] = first
	exsits[first] = true

	for i := 1; ; i++ {
		num = cal(sequence[i-1])

		if exsits[num] {
			ans = i + 1
			break
		}
		sequence[i] = num
		exsits[num] = true
	}

	fmt.Println(ans)
}


Measured memory_bytes: 26112
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll A, B;
    cin >> A >> B;
    for (double i = 0; i <= 100 * 100; ++i)
        if (ll(i * 0.08) == A && ll(i * 0.1) == B){
            print(ll(i));
            return 0;
        }
    print(-1);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

int main()
{
	fio;
	map<int, int> m;
	int n, ans = 0;
	cin >> n;
	for(int i=0; i<n; i++)
	{
		int a;
		cin >> a;
		m[a]++;
	}
	for(auto it=m.rbegin(); it!=m.rend(); it++)
	{
		int v = it->ff;
		while(v & (v-1))
			v += v & -v;
		int x = it->ff, y;
		if(v == x)
		{
			y = (it->ss >> 1);
			v += x;
		}
		else
			y = min(m[x], m[v-x]);
		m[x] -= y;
		m[v-x] -= y;
		ans += y;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 64256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long dp[5001][5001] = {};

long long powmod(long long x, long long n) {
    long long ret = 1;
    while(n > 0) {
        if(n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

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

    dp[0][0] = 1;
    for(int n=0; n<N; ++n) {
        for(int x=0; x<N; ++x) {
            dp[n + 1][x + 1] = (dp[n + 1][x + 1] + 2 * dp[n][x]) % MOD;
            dp[n + 1][max(x - 1, 0)] = (dp[n + 1][max(x - 1, 0)] + dp[n][x]) % MOD;
        }
    }

    long long res = dp[N][s.size()] * powmod((MOD + 1) / 2, s.size()) % MOD;
    cout << res << endl;
}

Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if((b*2+c)%4)cout<<"NO";
    else cout<<"YES";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main ()
{ 
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},k;
	cin>>k;
	cout<<a[k-1];	
	return 0;
} 

Measured memory_bytes: 256
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

def notab(a, b):
    s = set((a,b))
    for c in "RGB":
        if c not in s:
            return c

n  = load()
s = list(load(str))

cntmap = dict()
for c in 'RGB':
    cnt = 0
    cntmap[c] = [0 for _ in range(n+1)]
    for i in range(n-1, -1, -1):
        if s[i] == c:
            cnt += 1
        cntmap[c][i] = cnt

cnt = 0
for i in range(0, n):
    first = s[i]
    for j in range(i + 1, n):
        if s[j] == first:
            continue
        second = s[j]
        target = notab(first, second)
        if j+(j-i) < n and s[j+(j-i)] == target:
            cnt += cntmap[target][j+1] - 1
        else:
            cnt += cntmap[target][j+1] 
print(cnt)




Measured memory_bytes: 69772
#include<iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= b&&b <= c){
		cout << a << " " << b << " " << c<<endl;
	}
	else if (b<=a&&a<=c){
		cout << b << " " << a << " " << c<<endl;
	}
	else if (a <= c&&c <= b){
		cout << a << " " << c << " " << b<<endl;
	}
	else if (c <= a&&a <= b){
		cout << c << " " << a << " " << b<<endl;
	}
	else if (b <= c&&c <= a){
		cout << b << " " << c << " " << a<<endl;
	}
	else if (c<=b&&b<=a){
		cout << c << " " << b << " " << a<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();
 
function main(){
  
  for(var i = 0, len = input.length; i < len; i++){
    var c = input[i].split(',');
    
    console.log(
         !isInner(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7])
      && !isInner(c[2],c[3],c[4],c[5],c[6],c[7],c[0],c[1])  
      && !isInner(c[4],c[5],c[6],c[7],c[0],c[1],c[2],c[3])
      && !isInner(c[6],c[7],c[0],c[1],c[2],c[3],c[4],c[5]) ?
            'YES':'NO');
  }
  
}

function isInner(x1,y1,x2,y2,x3,y3,x4,y4){
    var v1 = new Vector2D(x1, y1);
    var v2 = new Vector2D(x2, y2);
    var v3 = new Vector2D(x3, y3);
    var vp = new Vector2D(x4, y4);
 
    var v12 = v2.sub(v1);
    var v2p = vp.sub(v2);
     
    var v23 = v3.sub(v2);
    var v3p = vp.sub(v3);
 
    var v31 = v1.sub(v3);
    var v1p = vp.sub(v1);
 
    var c1 = v12.cross(v2p);
    var c2 = v23.cross(v3p);
    var c3 = v31.cross(v1p);
 
    return (c1 >= 0 && c2 >= 0 && c3 >= 0) || (c1 < 0 && c2 < 0 && c3 < 0);
}

function Vector2D(x, y){
  this.x = x - 0, this.y = y - 0;
  this.sub = function(v){
    return new Vector2D(this.x - v.x, this.y - v.y);
  };
  this.cross = function(v){
    return this.x * v.y - this.y * v.x;
  };
}

Measured memory_bytes: 8700
import sys

stdin = sys.stdin.readline
na = lambda: map(int, stdin().split())
ns = lambda: stdin().rstrip()
ni = lambda: int(ns())
def main():
  n = ni()
  b = list(na()) + [1e9]
  a = [b[0]]
  for i in range(n-1):
    a.append(min(b[i], b[i+1]))
  print(sum(a))
main()

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

int main()
{
    int s=0;
    long long n,ans;
    cin >> n;
    int i=sqrt(n);
    for(;i>0;i--)
    {
        if(n%i==0)
        {
            ans=n/i;
             break;
        }


    }
    while(ans>0)
    {
        s++;
        ans/=10;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#E

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
[本番中]
全体から引くことを考えていたが, 考えることが多く解けなかった

[解説AC]
Ai=0かつBi=0は他の全てと仲が悪いので, 単体で用いるしかない(最後に足す)

Ai*Aj + Bi*Bj = 0の式から内積が思い浮かぶ
仲が悪いペアはAi*Bi >= 0 と Aj*Bj <= 0の場合しかないことがわかる
X: Ai*Bi > 0の場合の(|Ai|, |Bi|)の数
y: Ai*Bi < 0の場合の(|Bi|, |Ai|)の数とすると, 
xとyで同じ(A, B)のペアがあると仲が悪い可能性がある
この場合, 以下の3通りのみ使用できる
xのみで使用(少なくとも1つ) or yのみで使用(少なくとも1つ) or xもyも使用しない
つまり, 2**x[(A, B)] - 1 + 2**y[(A, B)] -1 + 1 = 2**x[(A, B)] + 2**y[(A, B)] - 1
これらの積をとり, 最後に全て使用しなかった場合の1を引いた値が答え(最後に(A,B)=(0,0)を足す必要がある)
"""

n = I()
ab = [LI() for _ in range(n)]

x = defaultdict(lambda : 0)
y = defaultdict(lambda : 0)
z = defaultdict(lambda : 0)
tmp = 0
for a, b in ab:
    if a == 0 and b == 0:
        tmp += 1
    elif a == 0:
        x[0] += 1
        z[0] = 1
    elif b == 0:
        y[0] += 1
        z[0] = 1
    else:
        if a * b > 0:
            g = math.gcd(a, b)
            a //= g
            b //= g
            x[(abs(a), abs(b))] += 1
            z[(abs(a), abs(b))] = 1
        else:
            g = math.gcd(a, b)
            a //= g
            b //= g
            y[(abs(b), abs(a))] += 1
            z[(abs(b), abs(a))] = 1

ans = 1
for i in z.keys():
    ans *= (2**x[i] + 2**y[i] - 1)
    ans %= mod
ans -= 1
ans += tmp
ans %= mod
print(ans)






Measured memory_bytes: 192644
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;

int main() {
    int K;
    cin >> K;
    // ポイントは後ろからくっつけることである
    queue<ll> q;
    for (int i=0;i<9;i++) q.push((ll)(i+1));
    int count = 0;
    ll n;
    while (count < K){
        n = q.front();q.pop();
        ll p = n%10;
        for (int i=-1;i<=1;i++){
            ll r = p + (ll)i;
            if (r < 0 || r > 9) continue;
            q.push(n*10+r);
        }
        count++;
    }
    cout << n << endl;

    return 0;
}

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

int H = 0;
int W = 0;
string str[120];

void solve() {
  bool ignH[120] = {0};
  bool ignW[120] = {0};
  set<char> s;
  for (int i = 0; i < H; i++) {
    s.clear();
    for (int j = 0; j < W; j++) {
      s.insert(str[i][j]);
    }
    if (s.size() == 1 && s.find('.') != s.end()) {
      ignH[i] = true;
    }
  }
  for (int j = 0; j < W; j++) {
    s.clear();
    for (int i = 0; i < H; i++) {
      s.insert(str[i][j]);
    }
    if (s.size() == 1 && s.find('.') != s.end()) {
      ignW[j] = true;
    }
  }
  for (int i = 0; i < H; i++) {
    if (ignH[i] == true) continue;
    for (int j = 0; j < W; j++) {
      if (ignW[j] == true) continue;
      printf("%c", str[i][j]);
    }
    puts("");
  }
}

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    cin >> str[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a, b, c; 
	cin >> a >> b >> c;
	cout << a + b + c - max({ a, b, c }) << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
ans=0
for i in range(64):
    x,y=0,0
    for j in a:
        if j>>i&1:
            y+=1
        else:
            x+=1
    ans+=x*y*(1<<i)
    ans%=10**9+7
print(ans)

Measured memory_bytes: 122808
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);


    int N, K;
    cin >> N >> K;
    vector<int>A(N);
    cin >> A;

    cout << round_up(N - 1, K - 1) << endl;
    return 0;

}

Measured memory_bytes: 640
import Control.Monad
import Data.Set hiding (map,filter)
main = do
  [n,d] <- map read . words <$> getLine :: IO [Int]
  xys <- replicateM n $ map (read :: String -> Double) . words <$> getLine :: IO [[Double]]
  print . length . filter (d >=) $ [(ceiling . sqrt) (x^2+y^2) | (x:y:[]) <- xys]

  


Measured memory_bytes: 165652
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  ll h; cin >> h;
  ll ans = 0;
  int i = 0;
  while (h > 0){
    ans += RS(2,i,M*M);
    h /= 2;
    i++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  int mx=0,ans=0;
  for(int i=0;i<3;i++) {
      if(s[i]=='R') {
          mx++;
      }
      else {
          ans=max(ans,mx);
          mx=0;
      }
  }
  ans=max(ans,mx);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 433333;
int n,a[N],mn=2e9,res,k;
int g(int l, int r) {
	int x=r-l+1; if (l>r) return 0;
	if (x) return (x+k-1)/k; else return 0;
}
int main() {
	read(n);read(k);k--;rep(i,1,n)read(a[i]);
	cout<<(n-1+k-1)/k;
	return 0;
}


Measured memory_bytes: 640
import queue

if __name__ == "__main__":
    task = queue.Queue()

    in_buf = input().split(" ")
    num_of_processes = int(in_buf[0])
    quantum = int(in_buf[1])

    for i in range(num_of_processes):
        in_buf = input().split(" ")
        process_name = in_buf[0]
        process_time = int(in_buf[1])
        task.put([process_name, process_time])

    completed_task = []  # 完了したタスクを["タスク名", 完了時間(cumulative)]で格納
    cumulative = 0  # 累計時間

    while True:
        if task.empty():
            break
        else:
            process = task.get()

            if process[1] - quantum <= 0:  # taskが完了
                completed_task.append([process[0], cumulative+process[1]])
                cumulative += process[1]
            else:  # 完了しなかったら、process[1]をquantum分へらして、process[1]をキューの最後の追加
                process[1] = process[1] - quantum
                task.put(process)
                cumulative += quantum

    for i in range(len(completed_task)):
        print("%s %d" % (completed_task[i][0], completed_task[i][1]))



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

int main(){
  string s, t;
  std::cin >> s >> t;
  s += t;
  int a = atoi(s.c_str());
  for (int i = 0; i*i <= a; i++) {
    if(i*i == a){
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

inf = float("inf")
dp = [inf] * (N+1)
# dp[0] = 0

from bisect import bisect_left as bl

for a in A: # i$BHVL\$NMWAG$r8+$k!!(B
    L_idx = bl(dp, a)
    dp[L_idx] = a

# print(dp)
print( bl(dp, inf)   )




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


int main(){
    int n;
    std::cin >> n;
    std::vector<int> l(2*n);
    for(int i = 0 ; i < 2*n;i++){
        std::cin >> l[i];
    }
    std::sort(l.begin(),l.end());
    int sum = 0;
    for(int i = 0;i<2*n;i+=2){
        sum+=l[i];
    }
    std::cout << sum << std::endl;
    return 0;

}


Measured memory_bytes: 256
S = input()
D = len(S)
N = int(S)

if D <= 2:
    print(0)
    exit(0)

lst = [[], [], [], ["357", "375", "537", "573", "735", "753"]]
for d in range(4, D + 1):
    prev = lst[d - 1]
    lstd = []
    for si in prev:
        for i in range(len(si) + 1):
            lstd.append(si[:i] + '3' + si[i:])
            lstd.append(si[:i] + '5' + si[i:])
            lstd.append(si[:i] + '7' + si[i:])
    lst.append(list(set(lstd)))

count = 0
for i in range(3, D):
    count += len(lst[i])

lstd = [int(i) for i in list(set(lst[D]))]
lstd.sort()

import bisect
count += bisect.bisect(lstd, N)
print(count)



Measured memory_bytes: 16788
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define Int long long
#define rep(i, n) for (Int i = 0; i < n; i++)
#define in(params) cin >> params;
#define p(params) cout << params << endl;
#define mod 1000000007LL

using namespace std;

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

  double t;
  vector< double > v;

  for (int i = 0; i < N; i++) {
    cin >> t;
    v.push_back(t);
  }

  sort(v.begin(), v.end());
  for (int i = 0; i < N - 1; i++) {
    t = (v[0] + v[1]) / 2;
//    cout << v[0] << " " << v[1] << endl;
    v[0] = t;
    v[1] = 1000;
    // sort(v.begin(), v.end(), greater< double >());
    sort(v.begin(), v.end());
  }

  cout << v[0] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int fibonacci(int);

int M[100];

int main(){
  int n;

  scanf("%d",&n);

  printf("%d\n",fibonacci(n));

  return 0;
}

int fibonacci(int n){

  if(n==0 || n==1)return M[n] = 1;
  
  if(M[n] != 0)return M[n];
  
  return M[n] = fibonacci(n-1) + fibonacci(n-2);
}



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

int main(){
  string S,T;
  cin >> S >> T;
  int count=0;
  for(int i=0;i<3;i++){
    if(S[i] == T[i]){
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    unsigned int n;
    long long count;
    cin >> n;
    unsigned int a[n+1];
   
    a[0]=0;
    count=0;

    for (int i=1;i<=n;i++){
        a[i]=i;
    }
    for (int j=1;j<=n;j++){
        if((a[j]%3==0&&a[j]%5==0)||(a[j]%3==0&&a[j]%5!=0)||(a[j]%5==0&&a[j]%3!=0)){
            a[j]=0;
        }
    } 
    for (int t=1;t<=n;t++){
        count=count+a[t];
    }
    cout << ""<< count;

    return 0;

}

Measured memory_bytes: 7456
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define met(a,b) memset(a,b,sizeof(a))
struct node
{
    int num[26];
    bool friend operator < (node a,node b)
    {
        for(int i=0;i<26;i++)
        {
            if(a.num[i]!=b.num[i])
                return a.num[i]>b.num[i];
        }
        return false;
    }
}sum[4005],sum1[4005];

set<node>q;
string a,b;

int main()
{
    q.clear();
    met(sum,0);
    met(sum1,0);
    cin>>a>>b;
    for(int i=0; i<a.length(); i++)
    {
        for(int j=0; j<26; j++)
        {
            sum[i+1].num[j]+=sum[i].num[j];
        }
        sum[i+1].num[a[i]-'a']++;
    }
    for(int i=0; i<b.length(); i++)
    {
        for(int j=0; j<26; j++)
        {
            sum1[i+1].num[j]+=sum1[i].num[j];
        }
        sum1[i+1].num[b[i]-'a']++;
    }
    int Max=0;
    for(int len=min((int)a.length(),(int)b.length());len>=1;len--)
    {
        q.clear();
        for(int i=0;i+len<=a.length();i++)
        {
            int j=i+len;
            node x;
            for(int k=0;k<26;k++)
            {
                x.num[k]=sum[j].num[k]-sum[i].num[k];
            }
            q.insert(x);
        }
        for(int i=0;i+len<=b.length();i++)
        {
            int j=i+len;
            node x;
            for(int k=0;k<26;k++)
            {
                x.num[k]=sum1[j].num[k]-sum1[i].num[k];
            }
            if(q.find(x)!=q.end())
            {
                int ans=0;
                for(int k=0;k<26;k++)
                    ans+=x.num[k];
                Max=max(Max,ans);
            }
        }

    }
    printf("%d\n",Max);
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
void func(int n,string&  ans,int last){
	if(ans.size()==n){
		cout<<ans<<endl;
		return ;
	}else{
		for(int i=0;i<=(last+1) ;i++){
			
			ans+=('a'+i);
			func(n,ans,max(last,i));
			ans.erase(ans.size()-1);
		}
	}
	return ;
}
int main(){
	int n;
	cin >>n;
	string ans="";
	func(n,ans,-1);
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
const int N=1e5+10;
int main(){
    int n,q,t;
    vector<int> v[N];
    scanf("%d%d",&n,&q);
    while(q--){
        scanf("%d%d",&n,&t);
        if(n==0){
            scanf("%d",&n);
            v[t].PB(n);
        }
        else if(n==1){
            if(!v[t].empty())printf("%d",v[t][0]);
            for(int i=1;i<v[t].size();i++)printf(" %d",v[t][i]);
            printf("\n");
        }
        else v[t].clear();
    }
}


Measured memory_bytes: 7740
import copy


def main(input_nums):
    k = input_nums[5]
    nums = copy.deepcopy(input_nums)
    nums.pop(5)

    for i_a, num_a in enumerate(nums):
        for i_b, num_b in enumerate(nums):
            if i_a != i_b:
                if abs(num_a - num_b) > k:
                    return ":("

    return "Yay!"


if __name__ == "__main__":
    input_nums = []
    for _ in range(6):
        input_nums.append(int(input()))
    print(main(input_nums))

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long x = sc.NextLong();
        long y = sc.NextLong();

        if (x % y == 0)
        {
            Console.WriteLine(-1);
            return;
        }

        long answer = x * y - x;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;

typedef long long LL;

const LL mod=1000000007;
LL n,m,ans,a[205],f[205][100005];

void upd(LL &x,LL y){x=(x+y)%mod;}

int main(){
	scanf("%lld%lld",&n,&m);
	for (LL i=1;i<=n;++i) scanf("%lld",a+i);
	sort(a+1,a+n+1,greater<LL>());
	f[0][m]=1;
	for (LL i=1;i<=n;++i)
		for (LL j=0;j<=100000;++j) if (f[i-1][j]){
			upd(f[i][j%a[i]],f[i-1][j]);
			upd(f[i][j],f[i-1][j]*(n-i));
		}
	for (LL i=0;i<=100000;++i) upd(ans,f[n][i]*i);
	printf("%lld\n",ans);
	
	return 0;
}
			

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x, a, b;

    cin >> x >> a >> b;

    if (b <= a) {
        cout << "delicious" << endl;
    } else {
        if (b - a <= x) cout << "safe" << endl;
        else cout << "dangerous" << endl;
    }

    return 0;
}


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

using namespace std;

#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

const int N = 2e5 + 1;
int n;

vector<int> g[N], ans(N);
bool color[N];

void dfs(int p, int s, int d = 0)
{
    color[s] = d;
    for (auto v : g[s])
        if (v != p)
            dfs(s, v, d ^ 1);
}

signed main()
{
    fastio;
    cin >> n;
    for (int i = 0; i < n - 1; ++i)
    {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, 1);
    // phase 1
    vector<pair<int, int>> c({{0, 0}, {0, 1}});
    for (int i = 1; i <= n; ++i)
    {
        if (color[i])
        {
            ++c[1].first;
        }
        else
        {
            ++c[0].first;
        }
    }
    sort(begin(c), end(c));
    if (c[0].first <= n / 3)
    {
        int pick = 3;
        for (int i = 1; i <= n; ++i)
        {
            if (color[i] == c[0].second)
            {
                ans[i] = pick, pick += 3;
            }
        }
        for (int i = 1, p = 1; p <= n && i <= n; ++i)
        {
            if (!ans[i])
                ans[i] = p++;
            p += (p % 3 == 0);
        }
        for (int i = 1; i <= n; ++i)
        {
            if (!ans[i])
                ans[i] = pick, pick += 3;
        }
        for (int i = 1; i <= n; ++i)
            cout << ans[i] << " ";
    }
    else
    {
        for (int i = 1, p = 1; p <= n && i <= n; ++i)
        {
            if (color[i])
            {
                ans[i] = p;
                p += 3;
            }
        }
        for (int i = 1, p = 2; p <= n && i <= n; ++i)
        {
            if (!ans[i] && !color[i])
            {
                ans[i] = p;
                p += 3;
            }
        }
        for (int i = 1, p = 3; p <= n && i <= n; ++i)
        {
            if (!ans[i])
            {
                ans[i] = p;
                p += 3;
            }
        }
        for (int i = 1; i <= n; ++i)
        {
            cout << ans[i] << " ";
        }
    }
}

/* input

*/

Measured memory_bytes: 18816
import sys
from heapq import heappush, heappop
from fractions import gcd
#input = sys.stdin.readline

def main():
    a,b,c,d=map(int,input().split())
    dc=int(d*c/gcd(d,c))
    print(b-a+1-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//(dc)-(a-1)//(dc)))

if __name__ == '__main__':
    main()

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

int main(){
    int a, b; cin >> a >> b;
    int q; cin >> q; 
    vector<ll> s(a), t(b);
    for(int i = 0; i < a; i++){
        cin >> s.at(i);
    }
    for(int i = 0; i < b; i++){
        cin >> t.at(i);
    }
    for(int i = 0; i < q; i++){
        int sh, ch;
        ll dist; cin >> dist;
        sh = lower_bound(s.begin(), s.end(), dist) - s.begin();
        ch = lower_bound(t.begin(), t.end(), dist) - t.begin();
        ll ans = 1001001001001;
        for(int j = 0; j <= 1; j++){
            for(int k = 0; k <= 1; k++){
                int sht = sh - j;
                int cht = ch - k;
                if(sht < 0 || cht < 0 || sht >= a || cht >= b) continue;
                ans = min(ans, abs(dist - s.at(sht)) + abs(s.at(sht) - t.at(cht)));
                ans = min(ans, abs(dist - t.at(cht)) + abs(s.at(sht) - t.at(cht)));
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4748
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    size_t n;
    scanf("%zu", &n);

    for (size_t i=0; i<n; ++i) {
        size_t k;
        scanf("%*d %zu", &k);

        vector<int> v(n+1);
        for (size_t j=0; j<k; ++j) {
            size_t d;
            scanf("%zu", &d);

            v[d] = 1;
        }

        for (size_t j=1; j<=n; ++j)
            printf("%d%c", v[j], j<n? ' ':'\n');
    }

    return 0;
}

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

const int maxn = 1e5 + 10, inf = 1e9;
vector<pair<int, int>> G[maxn], g[maxn];
int v[maxn], p[maxn], d[maxn];

struct djset {
    int p[maxn];
    void init() { for (int i = 0; i < maxn; ++i) p[i] = i; }
    int find(int n) { return p[n] == n ? n : p[n] = find(p[n]); }
    void merge(int n, int m) { p[find(n)] = find(m); }
} djs;

bool dfs(int now, int fa) {
    v[now] = 1; p[now] = fa;
    bool ret = false;
    for (auto u : g[now]) if (u.first != now) {
        if (v[u.first] == -1) ret |= dfs(u.first, now);
        else if (v[u.first] == 1) ret = true;
        else p[u.first] = now;
    }
    v[now] = 0;
    return ret;
}

int dfs2(int now, int dist) {
    v[now] = 1; d[now] = dist;
    int ret = dist;
    for (auto u : g[now]) if (u.first != now) {
        if (v[u.first] == -1) ret = max(ret, dfs2(u.first, dist + u.second));
        else if (v[u.first] == 0 && d[u.first] != dist + u.second) { cout << "No" << endl; exit(0); }
    }
    v[now] = 0;
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    djs.init();
    while (m--) {
        int l, r, d; cin >> l >> r >> d;
        if (d == 0) djs.merge(l, r);
        G[l].emplace_back(r, d);
        // G[r].emplace_back(l, d);
    }
    fill(v, v + maxn, -1);
    for (int i = 1; i <= n; ++i) {
        for (auto j : G[i]) g[djs.find(i)].emplace_back(djs.find(j.first), j.second);
    }
    for (int i = 1; i <= n; ++i) {
        // cout << "i = " << i << endl;
        // for (auto j : g[i]) cout << j.first << ' '; cout << endl;
    }
    for (int i = 1; i <= n; ++i) if (v[i] == -1) {
        if (dfs(i, -1)) return cout << "No" << endl, 0;
    }
    fill(v, v + maxn, -1);
    for (int i = 1; i <= n; ++i) if (v[i] == -1 && p[i] == -1) {
        if (dfs2(i, 0) > inf) return cout << "No" << endl, 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
    
    int A , P;
    cin >> A >> P;

    cout << (A * 3 + P) / 2 << endl;
    return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n;
    cin>> n;

    int s[n], a[n], sum= 0;

    cin>> a[0];
    s[0]= a[0];
    for(int i=1; i<n; i++)
    {
        cin>> a[i];
        s[i]= a[i]+ s[i-1];
    }

    for(int i= n-1; i>0; i--)
        sum += (a[i]* s[i-1]);

    cout << sum << '\n';

    return 0;
}




Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

int main() {

    int N;
    std::cin >> N;
    std::vector<long> vs;
    std::map<long, long> m;
    for (long i = 0; i < N; ++i) {
        long a;
        std::cin >> a;
        vs.push_back(a);
        m[a] += 1;
    }
    long s = 0;
    for (auto kv: m) {
        s += std::max(kv.second * (kv.second - 1) / 2, 0L);
    }

    for (long j = 0; j < vs.size(); ++j) {

        long c = vs[j];

        std::cout << (s - (m[c] - 1)) << "\n";

    }


    return 0;
}


Measured memory_bytes: 11888
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];
int B[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> B[i]; B[i]--;
		A[B[i]]++;
	}
	ll res = 0;
	rep(i, 0, N) res += 1ll * A[i] * (A[i] - 1) / 2;
	rep(i, 0, N) {
		cout << res - max(A[B[i]] - 1, 0) << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 3712
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int[] map = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
		}
		
		Arrays.sort(map);
		
		if (N % 2 == 1) {
			if (map[0] != 0) {
				System.out.println(0);
				return;
			}
			
			int count = 2;
			for (int i = 1; i < N; i++) {
				if (map[i] != count) {
					System.out.println(0);
					return;
				}
				
				if (i % 2 == 0) {
					count += 2;
				}
			}
			
			int ans = 1;
			//後は組み合わせ
			for (int i = 0; i < (N - 1) / 2; i++) {
				ans *= 2;
				ans %= 1_000_000_007;
			}
			
			System.out.println(ans);
		} else {
			int count = 1;
			for (int i = 0; i < N; i++) {
				if (map[i] != count) {
					System.out.println(0);
					return;
				}
				
				if (i % 2 == 1) {
					count += 2;
				}
			}
			
			int ans = 1;
			//後は組み合わせ
			for (int i = 0; i < N / 2; i++) {
				ans *= 2;
				ans %= 1_000_000_007;
			}
			
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 50820
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    string s;
    cin>>s;
    int ans  = 0;
    for(auto x : s)
    {
        if(x=='+')
            ans++;
        else
            ans--;
    }

    cout<<ans;


    printclock;
    return 0;
}


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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    unordered_set<int> s;
    for (int i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        s.insert(temp);
    }
    if (s.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 8520
#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 reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  int Q;
  cin >> Q;
  rep(i, Q) {
    i64 a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if (a == b) {
      cout << 2 * a - 2 << endl;
      continue;
    } else if (a + 1 == b) {
      cout << 2 * a - 2 << endl;
      continue;
    }
    i64 c = floor(sqrt(a * b));
    if (c * c == a * b) {
      c--;
    }
    if (c * (c + 1) >= a * b) {
      cout << 2 * c - 2 << endl;
      continue;
    } else if (c * c < a * b) {
      cout << 2 * c - 1 << endl;
      continue;
    }
  }
  return 0;
}

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

using namespace std;

int main() {
    int n; cin >> n;
    
    string s; int sex0; // Male = 0, Female = 1;
    
    cout << 0 << endl;
    cout.flush();
    cin >> s;
    if (s == "Male") {
        sex0 = 0;
    } else if (s == "Female") {
        sex0 = 1;
    } else {
        return 0;
    }
    
    int l = 0, r = n - 1;
    while (l <= r) {
        int mid = (l + r) >> 1, t;
        
        cout << mid << endl;
        cout.flush();
        cin >> s;
        
        if (s == "Male") {
            t = 0;
        } else if (s == "Female") {
            t = 1;
        } else {
            return 0;
        }
        
        if (((mid + t) & 1) != sex0) {
            r = mid;
        } else l = mid + 1;
    }
    
    return 0;
}

Measured memory_bytes: 852
import numpy
N=int(input())
A=list(map(int,input().split()))
B=list(numpy.cumsum(A))+[0]
C=sorted(B)
d=C[0]
cnt=1
ans=0
for i in range(N):
  if C[i+1]==d:
    cnt+=1
  else:
    ans+=cnt*(cnt-1)//2
    cnt=1
    d=C[i+1]
ans+=cnt*(cnt-1)//2
print(ans)    

Measured memory_bytes: 34640
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
p,q = 0,0
for i in range(n):
    if a[i] > b[i]:
        q += a[i]-b[i]
    else:
        p += (b[i]-a[i])//2
if p >= q:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 40560
#include <iostream>
using namespace std;
int main(void){
    long int N,K;
    cin >> N >> K;
    long int count;
  	if(K%2 == 1){
    	count = N/K;
      	cout << count*count*count << endl;
    }else{
      	count = N/K;
      	long int a = count + 1l;
    	if(N%K >= K/2){
        	cout <<	count*count*count + a*a*a;
        }else{
        	cout << count*count*count*2;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[4][100005],n,a[100005],b[100005],c[100005];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
        dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
        dp[2][i]=max(dp[1][i-1],dp[0][i-1])+c[i];
    }
    cout<<max(max(dp[0][n],dp[1][n]),dp[2][n]);
}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[]=new int[N];
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		Arrays.sort(A);
		
		int x=0;int res=0;int i=0;int j=0;
		while(i<N) {
			
			x=A[i];
			while(i<N&&A[i]==x) {
				i++;j++;
			}
			res+=j%2;
			j=0;
		}
		System.out.println(res);
	}
}


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

namespace AOJALDS1_10_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            for (int repeat = 0; repeat < n; repeat++)
            {
                var s = Console.ReadLine();
                var t = Console.ReadLine();

                int[,] dp = new int[s.Length + 1, t.Length + 1];

                for (int i = 0; i < s.Length; i++)
                {
                    for (int j = 0; j < t.Length; j++)
                    {
                        if (s[i] == t[j])
                        {
                            dp[i + 1, j + 1] = dp[i, j] + 1;
                        }
                        else
                        {
                            dp[i + 1, j + 1] = Math.Max(dp[i + 1, j], dp[i, j + 1]);
                        }
                    }
                }
                Console.WriteLine(dp[s.Length, t.Length]);
            }
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 36852