akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b,q=map(int,input().split())
    S=[-INF]+[int(input()) for _ in range(a)]+[INF]
    T=[-INF]+[int(input()) for _ in range(b)]+[INF]
    X=[int(input()) for _ in range(q)]
    from bisect import bisect
    for x in X:
        i=bisect(S,x)
        j=bisect(T,x)
        sleft=x-S[i-1]
        sright=S[i]-x
        tleft=x-T[j-1]
        tright=T[j]-x
        LL=max(sleft,tleft)
        RR=max(sright,tright)
        LR=sleft+tright+min(sleft,tright)
        RL=sright+tleft+min(sright,tleft)
        print(min(LL,RR,LR,RL))

resolve()

Measured memory_bytes: 16120
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  




void solve(){
int x , y ; cin >> x >> y ;
x%=y;
cout << min(x,y-x) << endl;
}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int[] d = new int[N+1];
        d[1] = 1;
        d[0] = -1;
        for (int i = 2; i <= N; i++) {
            if(d[i] != 0) continue;
            d[i] = i;
            for (int j = i+i; j <= N; j+=i) {
                if(d[j] == 0) d[j] = i;
            }
        }
        long ans =0;
        for (int i = 1; i <=N; i++) {
            HashMap<Integer,Integer> res = new HashMap<>();
            int k = i;
            while(k!=1){
                res.putIfAbsent(d[k],0);
                res.put(d[k],res.get(d[k])+1);
                k /= d[k];
            }
            // System.out.println(res);
            long count = 1;
            for (Integer j : res.values()) {
                count *= (j+1);
            }
            // System.out.println(count);
            ans += i*count;
        }
        out.println(ans);
    }

 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 95956
#include<cstdio>
int main(){for(int n,a,c,r,t;c=r=scanf("%d",&n),n;printf("%d\n",r))for(char d[]="123456",s[9];n--;r+=*d-48)scanf("%s",s),*s%6-4?a=*s%5+*s%2*2+c&3,a+=a/2?2-a%2*2:1,t=*d,*d=d[a],d[a]=d[5],d[5]=d[5-a],d[5-a]=t:c+=*s+3;}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

long double pita(pair<int,int> p1 , pair<int,int> p2){
    return sqrt(pow(p1.first-p2.first, 2)+pow(p1.second-p2.second, 2));
}

int main(){
    int N;
    cin >> N;
    map<int, pair<int,int>> mp;
    for(int i=0;i<N;i++){
        int x,y;
        cin >> x >> y;
        mp[i+1]=make_pair(x,y);
    }
    vector<int> v;
    for(int i=0;i<N;i++){
        v.push_back(i+1);
    }
    
    int cnt=0;
    long double sum=0;
    do{
        cnt += 1;
        for(int i=0;i<N-1;i++){
            sum += pita(mp[v[i]], mp[v[i+1]]);
        }
    }while(next_permutation(v.begin(), v.end()));

    cout << fixed << setprecision(10) << sum/cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

vector<lli> g[N];
bool vis[N];
lli ans[N];


vector<lli>  dijkstra() {
    priority_queue<pair<lli, lli>, vector<pair<lli, lli> > , greater<pair<lli, lli > >> pq;
    vector<lli> dis(N, inf);
    lli src = 1;
    pq.push({0, src});
    dis[src] = 0;
    while(!pq.empty()) {
        lli u = pq.top().second;
        pq.pop();
        for(auto it : g[u]) {
            lli v = it;
            lli weight = 1;
            if(dis[u] + weight < dis[v]) {
                dis[v] = dis[u] + weight;
                pq.push({dis[v], v});
            }
        }
    }
    return dis;
}



void solve()
{

    lli n, m;
    cin>>n>>m;
    for(int i = 0; i < m; i ++) {
        lli a, b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<lli> dis = dijkstra();

    bool ok = 1;

    for(int i = 2; i <= n; i ++) {
        lli mn = inf;
        lli f = -1;
        for(auto it : g[i]) {
            if(dis[it] < mn) {
                mn = dis[it];
                f = it;
            }
        }
        if(f == -1)
            ok = 0;
        else
            ans[i] = f;
    }
    if(!ok) {
        cout<<"No\n";
        return ;
    }
    cout<<"Yes\n";
    for(int i = 2; i <= n; i ++) {
        cout<<ans[i]<<'\n';
    }
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 20336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s;

int main(){
	cin >> s;
	if (s[0] == s[s.size() - 1]){
		cout << s[0] << endl;
	}
	else{
		cout << 'o' << endl;
	}
}

Measured memory_bytes: 1176
N,M=map(int,input().split())
mod = 10**9+7
fram = [1]
for i in range(1,N+1):
  fram.append(fram[-1]*i%mod)

#def framod(n, mod, a=1):
#    for i in range(1,n+1):
#        a = a * i % mod
#    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=fram[n]
    b=fram[k]
    c=fram[n-k]
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

def cnt(n):
  s = sum([comb(n-i,i,mod)%mod for i in range(n//2+1)])
  s = s%mod
  return s

A0 = 0
ans = 1
for i in range(M):
  A1 = int(input()) - 1
  ans = (ans * cnt(A1-A0))%mod
  A0 = A1+2
ans = (ans * cnt(N-A0))%mod
print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 0;
    for (ll i = a; i <= b; i++) {
        if (c%i == 0) ans++;
    }
    cout << ans << endl;
}


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

int main(){
  long long N;
  cin >>N;
  int a[20];
  int keta=0;
  long long NA=N;
  while(NA>0){
    NA=NA/10;
    keta++;
  }
  int keta2=0;
  NA=N+1;
  while(NA>0){
    NA=NA/10;
    keta2++;
  }
  int i=0;
  NA=N;
  while(NA>0){
    a[i]=NA%10;
    NA=NA/10;
    i++;
  }
  
  if(keta==1){
    cout<<N<<endl;
    return 0;
  }
  if(keta2>keta){
    cout<<keta*9<<endl;
    return 0;
  }
  if(N+1==(a[keta-1]+1)*pow(10,keta-1)){
    cout<<a[keta-1]+9*(keta-1)<<endl;
    return 0;
  }
  cout<<a[keta-1]-1+(keta-1)*9<<endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = (1..2*n).to_a
m = gets.to_i
m.times {
    k = gets.to_i
    if k == 0
        a = a[0..n-1].zip(a[n..-1]).flatten
    else
        a = a[k..-1] + a[0..k-1]
    end
}
puts a

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
const double PI = acos(-1.0);

int main()
{
	while(scanf("%d",&N),N != -1){
		double rad = 0.0,dist = 1.0;
		FOR(i,1,N){
			double x = sqrt(1 + dist * dist);
			double d = acos(dist / x);
			rad += d;
			dist = x;
		}
		printf("%.10f\n%.10f\n",cos(rad) * dist,sin(rad) * dist);
	}

	return 0;
}

Measured memory_bytes: 3416
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
   public static void main(String[] args) {
     
        //sec--1
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] p = new int[N];
        for(int i=0; i<N; i++) {
          p[i] = sc.nextInt();
        }
     
        //sec--2
        Arrays.sort(p); //配列要素を昇順（値が小さい順）で並べ替え
     
        //sec--3
        int cnt = 0;
        for(int i=0; i<K; i++) {
          cnt += p[i];
        }
     
        //sec--4
        System.out.println(cnt);
   }
}

Measured memory_bytes: 38740
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll ,ll >
    #define msi           map<string,ll >
    #define mis           map<ll , string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    #define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll , ll >>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define N             100000000
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    using namespace std;
    ll min(ll a,ll b)
    {
        return a>b?b:a;
    }
    ll max(ll a,ll b)
    {
        return a>b?a:b;
    }
    const ll maxn=2e5+500;
    void solve()
    {
      ll k;
      cin>>k;
      ll g=0;
      rep(i,1,k+1)
      {
        rep(j,1,k+1)
        {
            rep(l,1,k+1)
            {
                g+=__gcd(i,__gcd(j,l));
            }
        }
      }
      cout<<g;
    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //#ifndef ONLINE_JUDGE
       //freopen("input.txt","r",stdin);
       //freopen("output.txt","w",stdout);
        //#endif
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }
    
/*
5 1
2 4 8 2 4
*/
   


Measured memory_bytes: 3644
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int N;
	long long int ans=0;
	cin>>N;
	vector<int>A(N-1);
	for(int i=0;i<N-1;++i)
	{
		cin>>A[i];
	}
	for(int i =0;i<N;i++)
	{
		
		if(i==0)ans+=A[i];
		else if(i!=N-1)ans+=min(A[i-1],A[i]);
		else ans+=A[i-1];
	}
	cout<<ans;
}


Measured memory_bytes: 384
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
xs = [a, b, c, d, e]
result = 'Yay!'
for i in range(5):
    for j in range(i + 1, 5):
        if k < xs[j] - xs[i]:
            result = ':('
            break
print(result)

Measured memory_bytes: 38256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);++i)
typedef long long int ll;
const double PI=3.14159265358979323846;

class DWaterBottle {
public:
	void solve(std::istream& in, std::ostream& out) {
        out << setprecision(16);
        double a,b,x;
        in >> a >> b >> x;
        double h=x/(a*a);
        if(h>=b/2) {
            double t = b - h;
            double ans = 360 * (atan(2 * t / a)) / (PI * 2);
            out << ans << endl;
            return ;
        }else{
            double t=2*x/(b*a);
            double ans = 360 * (atan(b / t)) / (PI * 2);
            out << ans << endl;
            return ;
        }
	}
};


int main() {
	DWaterBottle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef struct counter_info {
    int depth;
    int position;
} ci;
typedef struct sum_info {
    int sum;
    int position;
} si;
stack<ci> contour;
stack<si> sumstack;

void print()
{
    int allsum = 0;
    long stacksize = sumstack.size();
    int a[sumstack.size()];
    for (int i = 0; i < stacksize; i++) {
	allsum += sumstack.top().sum;
	a[i] = sumstack.top().sum;
	sumstack.pop();
    }
    cout << allsum << endl;
    cout << stacksize;
    int alength = sizeof(a) / sizeof(a[0]);
    for (int i = alength - 1; i >= 0; i--) {
	cout << " " << a[i];
    }
    cout << endl;
}
void pushToSumStack(int position, int sum)
{
    si* sinfo = (si*)malloc(sizeof(si));
    sinfo->sum = sum;
    sinfo->position = position;
    sumstack.push(*sinfo);
}
void calTotalSum(int position, int sum)
{
    if (sumstack.empty()) {
	pushToSumStack(position, sum);
	return;
    }
    si sumtop = sumstack.top();
    si newtop = sumtop;
    if (position > sumtop.position) {
	pushToSumStack(position, sum);
	return;
    }
    while (position < sumtop.position) {
	sumstack.pop();
	newtop.sum += sum;
	if (sumstack.empty()) {
	    break;
	}
	sumtop = sumstack.top();
	sum = sumtop.sum;
    }
    sumstack.push(newtop);
}
void solve(char c[20000])
{

    int N = strlen(c);
    int depth = 0;
    for (int i = 0; i < N; i++) {
	if ('\\' == c[i]) {
	    depth++;
	    ci* cinfo = (ci*)malloc(sizeof(ci));
	    cinfo->depth = depth;
	    cinfo->position = i;
	    contour.push(*cinfo);
	    //	    sum += depth - 0.5;
	}
	if ('/' == c[i]) {
	    if (contour.empty()) {
		continue;
	    }
	    int sum = 0;
	    ci ctop = contour.top();
	    if (ctop.depth == depth) {
		contour.pop();
		if (c[i - 1] == '\\') {
		    sum = 1;
		    si* sinfo = (si*)malloc(sizeof(si));
		    sinfo->sum = sum;
		    sinfo->position = ctop.position;
		    sumstack.push(*sinfo);
		} else {
		    sum = i - ctop.position;
		    calTotalSum(ctop.position, sum);
		}
	    }
	    depth--;
	}
	if ('_' == c[i]) {
	}
    }
    print();
}

int main()
{
    char c[20000];
    while (scanf("%s", c) != 1) {
    }
    solve(c);
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

struct Tree{
  string data="";
  map<string,Tree*> child;
};

int main(){
  string s;
  cin >> s;
  string t;
  Tree* root=new Tree();
  vector<Tree*> mem(21);
  vector<int> indent(21);
  mem[0]=root;
  indent[0]=0;
  int depth=0;
  getline(cin,t);
  while(getline(cin,t)){
    int i=0;
    for(;;i++){
      if(t[i]!=' '){
        if(indent[depth]<i) depth++,indent[depth]=i;
        else{
          while(indent[depth]>i) depth--;
        }
        break;
      }
    }
    int j=i;
    for(;;j++){
      if(t[j]==':') break;
    }
    mem[depth+1]=new Tree();
    mem[depth]->child[t.substr(i,j-i)]=mem[depth+1];
    if(j+1<t.length()){
      mem[depth+1]->data=t.substr(j+2);
    }
  }
  Tree* now=root;
  int pre=1;
  s+='.';
  for(int i=1;i<s.length();i++){
    if(s[i]=='.'){
      auto itr=now->child.find(s.substr(pre,i-pre));
      if(itr==now->child.end()){
        cout << "no such property" << endl;
        return 0;
      }else{
        now=itr->second;
      }
      pre=i+1;
    }
  }
  if(now->data=="") cout << "object" << endl;
  else cout << "string \"" << now->data << "\"" << endl;
  return 0;
}



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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k;

    ll N;
    cin >> N;
    ll ans = 0;
    for(i = 1; i < N; i++) {
        ll sub = N / i;
        if(N % i == 0)
            sub--;
        ans += sub;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 100005;

int vis[MAXN], c[MAXN], n, m;
vector<int> adj[MAXN];

bool dfs(int s, int color){
	if(c[s]){
		return c[s] == color;
	}
	c[s] = color;
	bool res = true;
	for(auto t:adj[s]){
		if(!dfs(t, 3-color)){
			res = false;
		}
	}
	return res;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		int x,y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int isolated=0,bipartite=0,other=0;
	for(int i=1;i<=n;i++){
		if(!c[i]){
			if(adj[i].size()){
				if(dfs(i, 1)){
					bipartite++;
				}
				else other++;
			}
			else {
				isolated++;
				c[i]=1;
			}
		}
	}
	//cerr << isolated << " " << bipartite << " " << other << endl;
	int ans = isolated*isolated + 2*isolated*(n-isolated) + 2*bipartite*bipartite + other*other + 2*other*bipartite;
	cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 12416
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    char a,b;
    cin>>a>>b;
    if(a>b){
        cout<<">"<<endl;
    }else if(a<b){
        cout<<"<"<<endl;
    }else{
        cout<<"="<<endl;
    }
}

Measured memory_bytes: 3628
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a+b >= c {
		fmt.Println(b + c)
		return
	}
	fmt.Println(a + 2*b + 1)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), "")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

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

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "YES"
		fmt.Println(reply)
		return
	}
	reply = "NO"
	fmt.Println(reply)
}

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

int main() {
    int64_t N; cin >> N;
    vector<int64_t> H(N);
    for (int64_t i = 0; i < N; i++) cin >> H[i];

    int64_t res = 0, ans = -1;
    for (int64_t i = 0, j = 1; i < N - 1; i++, j++) {
        if (H.at(i) >= H.at(j)) res++;
        else {
            ans = max(ans, res);
            res = 0;
        }
    }
    ans = max(ans, res);
    cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

typedef pair<int, ll> P;
vector<vector<P>> G;

ll dist[100000];

void dfs(int v, int p, ll cost) {
    dist[v] = cost;
    rep(i, G[v].size()) {
        if (G[v][i].first == p) continue;
        dfs(G[v][i].first, v, cost + G[v][i].second);
    }
}

int main() {
    int N;
    cin >> N;
    G.resize(N);
    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back(make_pair(b, c));
        G[b].push_back(make_pair(a, c));
    }

    int Q, K;
    cin >> Q >> K;
    K--;
    dfs(K, -1, 0L);

    rep(i, Q) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << dist[x] + dist[y] << endl;
    }
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	ll i, j, k, p, q, r, x, y, u, n, m;
    cin>>n;
    vl v1,v2;
    for(i=0;i<n;i++){
        cin>>x>>y;
        v1.pb(x+y);
        v2.pb(x-y);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    p=v1[n-1]-v1[0];
    q=v2[n-1]-v2[0];
    cout<<max(p,q)<<endl;


}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




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

int main() {
  int a,b,ans;
  cin >> a >> b;
  a--; b--;
  ans = (a+b-1)/a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    vector<string> s;
    int ans = 0;
    int count_A = 0;
    int count_B = 0;
    int count_both = 0;
    for (int i = 0; i < N; i++) {
        string temp;
        cin >> temp;
        s.push_back(temp);
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j + 1 < s[i].length(); j++) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
        }
        if (s[i][0] == 'B') count_B++;
        if (s[i][s[i].length() - 1] == 'A') count_A++;
        if (s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A') count_both++;
    }
    int pl = (count_A == count_both && count_B == count_both) ? count_both - 1 : min(count_A, count_B);
    ans = pl > 0 ? ans + pl : ans;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  char last = s[0];
  bool bad = false;
  for (int i = 1; i < 4; ++i) {
    if (s[i] == last) {
      bad = true;
      break;
    }
    last = s[i];
  }

  if (bad) cout << "Bad" << endl;
  else cout << "Good" << endl;
  return 0;
}



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

const int N = 100;

vector<int> recipe[N];//store recipe
int price[N];           //store price


int solve(int now){
  int ret = price[now];
  int tmp = 0;
  if (recipe[now].size() == 0)return ret;
  for(int i=0;i<recipe[now].size();i++){
    tmp+=solve(recipe[now][i]);
  }
  return min(ret,tmp);
}


main(){
  int n;
  while(cin>>n && n){
    int p;
    map<string,int> M;
    string tmp;
    
    //get buy information
    for(int i=0;i<n;i++){
      cin>>tmp>>p;
      M[tmp]=i;
      price[i]=p;
      recipe[i].clear();
    }
    
    //get recipe
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
      int num,me;
      cin>>tmp>>num;
      me=M[tmp];
      for(int j=0;j<num;j++){
	cin>>tmp;
	recipe[me].push_back(M[tmp]);
      }
    }


    cin>>tmp;
    cout << solve(M[tmp]) <<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <utility>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdint>
#include <algorithm>

using namespace std;

int main(int argc,char** argv) {
    long long int n,m;
    cin >> n >> m;
    long long int res = min(n,m/2);
    n -= res;m -= res * 2;
    res += m / 4;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() 
{  
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
    int N,D;
    cin>>N>>D;
    vector< vector<int> > arr;
    for(int i=0;i<N;i++)
    {
        vector<int> d;
        for(int i=0;i<D;i++)
        {
            int x;
            cin>>x;
            d.push_back(x);
        }
        arr.push_back(d);
    }
    int count=0;
    for(int i=0;i<N;i++)
    {
        for(int j=i+1;j<N;j++)
        {
            int dist=0;
            for(int k=0;k<D;k++)
            {
                dist+=(arr[j][k]-arr[i][k])*((arr[j][k]-arr[i][k]));
            }
            int FLAG=0;
            for(int i=0;i<=500;i++)
            {
                if(i*i==dist)
                {
                    FLAG=1;
                    break;
                }
            }
            if(FLAG==1)
            {
                count++;
            }
        }
    }
    cout<<count;
}

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

int main(void)
{
    long long a,b,len=0;
    cin>>a>>b;

    long long int x=a;

    while (x<=b)
    {
        len++;
        x*=2;
    }
    printf("%lld\n",len);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace  std;
int main ()
{
	int a,c;
	int b[1111];
	cin>>a>>c;
	for(int i=0;i<a;i++)
	{
		cin>>b[i]; 
	} 
	sort(b,b+a);
	int ans=0;
	for(int i=0;i<c;i++)
	{
		ans+=b[i];
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

const int MAX = 710000;
long long fac[MAX], finv[MAX], inv[MAX];

//使う前に実行
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
    ll n, k, ans = 0;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)cin >> a.at(i);
    sort(all(a));
    COMinit();
    rep(i, n-(k-1)){
        ans = ans - (COM(n-i-1, k-1) % mod) * (a.at(i) % mod) % mod;
    }
    reverse(all(a));
    rep(i, n-(k-1)){
        ans = ans + (COM(n-i-1, k-1) % mod) * (a.at(i) % mod) % mod;
    }
    cout << ans % mod << endl;
}


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

using namespace std;

int main(){
	string s;
	cin >> s;
	int i,p=0,m=0;
	for(i=0;i<s.size();i++){
		if(s[i] =='A' || s[i] =='T' || s[i] == 'C' || s[i] == 'G'){
			p++;
			if(m<p) m = p;
		}else{
			p = 0;
		}
	}

	cout << m << endl;
				
	return 0;
}

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

int gcd(int a, int b) {
	if (a > b) swap(a, b);
	if (a == 0) return b;
	else return gcd(b%a, a);
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	cout << 360/gcd(n, 360);
}

Measured memory_bytes: 3580
#include <stdio.h>

int main(void){
	int a, b, c, min, ans;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	int max = 0;

	if(max < a){
		max = a;
		ans = b*c;
	}
	if(max < b){
		max = b;
		ans = a*c;
	}
	if(max < c){
		max = c;
		ans = a*b;
	}

	printf("%d", ans/2);

	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

struct Log{
  int t;
  int s;
};

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n==0){
      return 0;
    }
    int r,q;
    cin >> r;
    vector<list<struct Log>> gakusei(m+1,list<struct Log>());
    int a,b,c,d;
    for(int i=0;i<r;i++){
      cin >> a >> b >> c >> d;
      gakusei[c].push_back({a,d});
    }
    int ts,te,id;
    int ans=0,count=0;
    cin >> q;
    int begin,end;
    for(int i=0;i<q;i++){
      cin >> ts >> te >> id;
      ans=count=0;
      for(auto itr=gakusei[id].begin();itr!=gakusei[id].end();itr++){
        if((*itr).s==1){
          count++;
          if(count==1){
            begin=max((*itr).t,ts);
          }
        }else{
          count--;
          if(count==0){
            end=min((*itr).t,te);
            ans+=(end>begin?end-begin:0);
          }
        }
      }
      cout << ans << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3248
/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
int a,b,c;
int main(){
    read(a),read(b),read(c);
   swap(a,b),swap(a,c);
  cout<<a<<" "<<b<<" "<<c;
	return 0;
}


Measured memory_bytes: 256
def dpf(n):
    dp = [-1]*40
    dp[0] = 1
    dp[1] = 1
    dp[2] = 2

    for i in range(3, n+1):
        dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

    return dp[n]

def solve(i):
    res = -1
    x = dpf(i)    
    day = (x+10-1)//10
    res = (day+365-1)//365
    return res

def main():
    a = []
    for e in iter(input, '0'):
       a.append(int(e)) 

    for i in a:
        print(solve(i))
    
main() 


Measured memory_bytes: 5596
#include <iostream>

using namespace std;


int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    // Alice: A, B
    // Bob:   C, D

    int start = max(A, C);
    A = max(0, A - start);
    B = max(0, B - start);
    C = max(0, C - start);
    D = max(0, D - start);

    int end = min(B, D);

    int x = max(0, end);
    cout << x;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> mypair;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmax(x,y) x= max(x,y)
int main(){

int n;
while(1){
cin>>n;
if(n==0)break;
vector<int> p(n);
vector<vector<mypair> > dp(n+1,vector<mypair> (n*500+1,mypair(-1,-1)) );
dp[0][0] = mypair(0,0);
	rep(i,n)cin>>p[i];
	rep(i,n)rep(j,500*n+1)if(dp[i][j]!=mypair(-1,-1)){
		//if(j>500)cout<<"ok"<<j<<endl;
		int coin = dp[i][j].first,cost = dp[i][j].second;
		if(j>=(p[i]+500)%1000) chmax(dp[i+1][j-(p[i]+500)%1000],mypair(coin+1,cost-p[i]));
		if(1<=p[i]%1000 &&p[i]%1000<=500)chmax(dp[i+1][j+(500-p[i]%1000)],mypair(coin+1,cost-p[i]));
		if(500<p[i]%1000)chmax(dp[i+1][j+(1000-p[i]%1000)],mypair(coin,cost-p[i]));
		chmax(dp[i+1][j],mypair(coin,cost));
	}
	mypair ans = mypair(0,0);
	rep(i,500*n+1)chmax(ans,dp[n][i]);
	cout<<ans.first<<' '<<-ans.second<<endl;
}

	return 0;
}



Measured memory_bytes: 42624
N = int(input())
numbers_list = sorted([int(num) for num in input().split()])
Alice_sum = sum([numbers_list[index] for index in range(N) if index % 2 == 0])
Bob_sum = sum([numbers_list[index] for index in range(N) if index % 2 != 0])
print(abs(Alice_sum - Bob_sum))

Measured memory_bytes: 3060
#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>;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4)
    {
        if (s[i] == '+')
            ans++;
        else
            ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
from sys import stdin
a = stdin.readline().strip()
ans = 0
cur = 0
res = ''
for i in a:
 if i=='p':
  if cur:
   res += "p"
   cur-=1
  else:
   res += "g"
   cur += 1
   ans -=1
 else:
  if cur:
   res += 'p'
   ans += 1
   cur -= 1
  else:
   res += 'g'
   cur += 1

print ans

Measured memory_bytes: 2948
#!/usr/bin/env python3
# -*- coding: utf-8 -*-*-

from sys import stdin


def main():
    X = int(stdin.readline())

    y500 = X // 500
    y5 = (X % 500) // 5
    print(y500 * 1000 + y5 * 5)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int MAXN = 1e5+5;
int n, k, m, pos, ans = 1e9;
int A[MAXN];

int f(int x, int y) {
	if (x > y) return 0;
	int d = y - x + 1;
	if (d % m == 0) return d / m;
	return d / m + 1;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin >> n >> k;
	m = k - 1;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if (A[i] == 1) {
			pos = i;
		}
	}
	
	for (int ile = 1; ile <= k; pos--, ile++)
		ans = min(ans, f(0, pos - 1) + f(pos + k, n - 1));

	cout << ++ans << "\n";

	return 0;
}


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

int main() {
  int x,a; cin >> x >> a;
  if(x<a) cout << 0 << endl;
  else cout << 10 << endl;
}

Measured memory_bytes: 3608
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(;;){
			if(a[i]%2==0){
				a[i]=a[i]/2;
				ans++;
			}
			else{
				break;
			}
		}
	}
	cout<<ans;
    return 0;
} 

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

int main(){
    int a;
    cin >> a ;
    cout << (a-2)*180 << endl;;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,k;
    cin >> n >> k;
    cout << (n%k!=0) << endl;
}


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

int main(){
        int n;
        cin >> n;
        int a[n];
        int before=0;

        int sum_base=0;
        for(int i=0;i<n;i++){
                cin >> a[i];
        }
        for(int i=0;i<n;i++){
                sum_base=sum_base+abs(before-a[i]);
                before=a[i];
        }
        //last one
        sum_base=sum_base+abs(before);

        for(int i=0;i<n;i++){
                int b,c;
                if(i == 0){
                        b=abs(a[i])+abs(a[i]-a[i+1]);
                }else if(i == n-1){
                        b=abs(a[i-1]-a[i])+abs(a[i]);
                }else{
                        b=abs(a[i-1]-a[i])+abs(a[i]-a[i+1]);
                }

                if(i == 0){
                        c=abs(a[i+1]);
                }else if(i == n-1){
                        c=abs(a[i-1]);
                }else{
                        c=abs(a[i-1]-a[i+1]);
                }
                cout << sum_base-(b-c) << endl;
        }

        return 0;
}

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

int n, m;

int main(){
    while (cin >> n >> m){
        vector<int> mass(n), d(m);
        if (n * m == 0)return 0;
        for (int i = 0; i < n; i++) cin >> mass[i];
        for (int i = 0; i < m; i++) cin >> d[i];
        int ans = 0, now = 1;
        for (int i = 0; i < m && now < n; i++)now += d[i] + mass[now + d[i] - 1], ans++;
        cout << ans << endl;
    }
}


Measured memory_bytes: 2996
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int k;
    k=max(a+b,a-b);
    k=max(k,a*b);
    printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 764
#include <iostream>

using namespace std;

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

	int* a = new int[M];
	int* b = new int[M];
	int* j = new int[N];

	for (int i = 0; i < N; i++) j[i] = 0;

	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		j[a[i]-1]++;
		j[b[i]-1]++;
	}

	for (int i = 0; i < N; i++) {
		cout << j[i] << endl;
	}

	}

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

int main() {
	string s, t;
	cin >> s >> t;
	ll ans = 0;
	for (int i = 0; i <= s.size() - t.size(); ++i) {
		ll cnt = 0;
		for (ll j = 0; j < t.size(); ++j) {
			if (s[i + j] == t[j])++cnt;
		}
		ans = max(ans, cnt);
	}
	cout << t.size() - ans << endl;
}


Measured memory_bytes: 3600
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    int N;
    int x;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        int[] X = new int[2*N-1];
        if(x == 1 || x == 2*N-1){
            Console.WriteLine("No");
            return;
        }
        else{
            Console.WriteLine("Yes");
            if(x == 2){
                X[N-1] = x;
                X[N-2] = x-1;
                for(int i=0;i<2*N-1;i++){
                    if(i<N-2){
                        X[i] = i+3;
                    }
                    if(i>N-1){
                        X[i] = i+1;
                    }
                }
            }
            else{
                X[N-1] = x;
                X[N-2] = x+1;
                X[N-3] = x-1;
                X[N] = x-2;
                for(int i=0;i<2*N-1;i++){
                    if((i<N-3 && i<x-3)||(i>N && i>x)){
                        X[i] = i+1;
                    }
                    if(i<N-3 && i>=x-3){
                        X[i] = i+5;
                    }
                    if(i>N && i<=x){
                        X[i] = i-3;
                    }
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<2*N-1;i++){
            sb.Append(X[i]+"\n");
        }
        Console.Write(sb.ToString());
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        x = int.Parse(str[1]);
    }    
}

Measured memory_bytes: 13888
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N;
  map<string, int> m;
  for (int i=0; i<N; i++) {
    cin >> S;
    m[S]++;
  }
  int mv = 0;
  vector<string> ret;
  for (auto& it : m) {
    if (it.second == mv) {
      ret.emplace_back(it.first);
    } else if (it.second > mv) {
      mv = it.second;
      ret.clear();
      ret.emplace_back(it.first);
    }
  }
  for (int i=0; i<ret.size(); i++) {
    cout << ret[i] << '\n';
  }
}

Measured memory_bytes: 25584