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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
// template starts
typedef long long int ll;
ll fact(ll n, ll p){
	ll ans = 1;
	for(ll i = 1; i <= n; i++){
		ans *= i;
		ans %= p;
	}
	return ans;
}
ll power(ll x, ll n, ll p){
	ll res = 1;
	if(n == 1) return x%p;
	if(n%2 == 1) res = x%p;

	ll temp = power(x,n/2,p);
	return res*((temp*temp)%p)%p;
}
ll inv(ll a, ll p){
	return power(a,p-2,p);
}
ll nCr(ll n, ll r, ll p){
	if(r > n) return 0;
	ll t1 = fact(n,p);
	ll t2 = inv(fact(r,p),p);
	ll t3 = inv(fact(n-r,p),p);

	return (((t1*t2)%p)*t3)%p;
}
vector<vector<ll> > multiply(vector<vector<ll> > &a, vector<vector<ll> > &b, ll p){
	int r1,c1,r2,c2;
	r1 = a.size(); c1 = a[0].size();
	r2 = b.size(); c2 = b[0].size();

	vector<vector<ll> > result(r1,vector<ll>(c2,0));

	if(c1 != r2) return result;

	for(int i = 0; i < r1; i++){
		for(int j = 0; j < c2; j++){
			for(int k = 0; k < c1; k++){
				result[i][j] += a[i][k]*b[k][j];
				result[i][j] %= p;
			}
		}
	}
	return result;
}

vector<vector<ll> > power(vector<vector<ll> >&a,ll n, ll p){
	int r = a.size();
	vector<vector<ll> > result(r,vector<ll>(r,0));
	for(int i = 0; i < r; i++) result[i][i] = 1;

	while(n > 0){
		if(n%2 == 1){
			result = multiply(result,a,p);
		}
		n /= 2;
		a = multiply(a,a,p);
	}
	return result;
}
// template ends here

ll no_factors(ll N){
	
}

void solve(){
	// code starts from here
	ll N;
	cin >> N;
	
	set<ll> s;
	s.insert(N); 
	if(N != 2)s.insert(N-1);
	for(ll i = 2; i*i <= N; i++){
		if(N%i == 0){
			ll f1 = i, f2 = N/i;
			
			ll temp = N;
			while(temp%f1 == 0) temp /= f1;
			if(temp%f1 == 1) s.insert(f1);
			
			temp = N;
			while(temp%f2 == 0) temp /= f2;
			if(temp%f2 == 1) s.insert(f2);
//			
//			temp--;
//			for(ll j = 2; j*j <= temp; j++){
//				if(temp%j == 0){
//					if(s.find(j) == s.end()){
//						s.insert(j);
//					}
//				}
//			}
//			temp = N;
//			while(temp%f2 == 0) temp/= f2;
//			for(ll j = 2; j*j <= temp; j++){
//				if(temp%j == 0){
//					if(s.find(j) == s.end()){
//						s.insert(j);
//					}
//				}
//			}
		}
	}
	
	for(ll i =2; i*i <= N-1; i++){
		if((N-1)%i == 0){
			s.insert(i);
			s.insert(N/i);
		}
	}
	
	cout << s.size() << endl;
}

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

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>

using namespace std;

int main() {
    size_t n, q;
    cin >> n >> q;
    vector<size_t> ba(n, 0);
    for (size_t i = 0; i < n - 1; ++i) {
        size_t a, b;
        cin >> a >> b;
        ba[--b] = --a;
    }
    vector<size_t> v(n, 0);
    for (size_t i = 0; i < q; ++i) {
        size_t p, x;
        cin >> p;
        cin >> x;
        v[--p] += x;
    }
    for (size_t j = 0; j < n; ++j) {
        if (ba[j] != j) {
            v[j] += v[ba[j]];
        }
    }
    for (size_t i = 0; i < n; ++i) {
        if (i != 0)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5504
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

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

	class Edge {
		Node to;
		int cap;
		int flow;

		Edge g;
		Edge(Node to, int cap, int flow) {
			this.to = to;
			this.cap = cap;
			this.flow = flow;
		}
		
		void rrf(int f){
			if(g ==null){
				return;
			}
			g.flow -= f;
		}
	}

	class Node {
		int id;

		LinkedList<Edge> e;

		Node(int id) {
			this.id = id;
			e = new LinkedList<Edge>();
		}
	}

	Node[] all;
	boolean[] used;

	int dfs(Node s,Node t){
		if(s==t){
			return 1;
		}
		used[s.id] = true;
		
		for(Edge e: s.e){
			if(!used[e.to.id]){
				if(e.cap - e.flow >0){
					int res = dfs(e.to,t);
					if(res >0){
						e.flow++;
						e.rrf(1);
						return res;
					}
				}			
			}
		}
		return 0;
	}
	
	public void run() {
		for (;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}
			Node[] r = new Node[n];
			Node[] b = new Node[m];
			Node source = new Node(n + m);
			Node sink = new Node(n + m + 1);

			all = new Node[n + m + 2];
			all[n + m] = source;
			all[n + m + 1] = sink;
			int[] red = new int[n];
			int[] blue = new int[m];

			for (int i = 0; i < n; i++) {
				red[i] = sc.nextInt();
				r[i] = new Node(i);

				all[i] = r[i];
				source.e.add(new Edge(r[i], 1, 0));
			}
			for (int j = 0; j < m; j++) {
				blue[j] = sc.nextInt();
				b[j] = new Node(n + j);

				all[n + j] = b[j];
				b[j].e.add(new Edge(sink, 1, 0));
			}

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (gcd(red[i], blue[j]) >= 2) {
						Edge rb = new Edge(b[j], 1, 0);
						Edge br = new Edge(r[i], 1, 1);
						rb.g = br;
						br.g = rb;
						r[i].e.add(rb);
						b[j].e.add(br);
					}
				}
			}

			int sum = 0;
			for (;;) {
				used = new boolean[all.length];
				int res = dfs(source,sink);
				if (res == 0) {
					break;
				} else {
					sum += res;
				}
			}
			System.out.println(sum);
		}
	}

	public static void main(String a[]) {
		Main m = new Main();
		m.run();
	}
}

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

using namespace std;
using ll=long long;

#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i,n) for (int i=0;i<(n);++i)
int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int a,n,ans=0,min5=105,all10=0;cin>>n;
  rep(i,n){
    cin>>a;
    ans+=a;
    if(a%10!=0)min5=min(a,min5);
    if(a%10==0)all10++;
  }
  cout<<(all10!=n&&ans%10!=0?ans:all10!=n?ans-min5:0)<<endl;
}


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

using namespace std;

typedef long long int64;

int main()
{
  int64 N, M, K, A, B, C, T, S[3001];

  cin >> N >> M >> K;
  cin >> A >> B >> C;
  cin >> T;
  for(int i = 0; i < M; i++) cin >> S[i];
  S[M] = N + 1;
  K -= M;

  int64 ret = -1;

  vector< int64 > vs;
  for(int i = 0; i < M; i++) {
    int64 rest = T - (S[i] - 1) * B;
    if(rest < 0) break;
    int64 pv = S[i], reach = min(S[i + 1], pv + rest / A + 1);
    ret += reach - S[i];
    for(int j = 0; j < K && reach < S[i + 1]; j++) {
      rest -= (reach - pv) * C;
      if(rest < 0) break;
      pv = reach;
      reach = min(S[i + 1], pv + rest / A + 1);
      vs.push_back(reach - pv);
    }
  }

  sort(vs.rbegin(), vs.rend());
  for(int i = 0; i < min(K, (int64) vs.size()); i++) ret += vs[i];
  cout << ret << endl;
}

Measured memory_bytes: 6960
import sys
import math

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def meguru_bisect(ok, ng):
        """
        is_okを定義して下さい
        :param ok: 取りうる最小の値-1
        :param ng: 取りうる最大の値+1
        :return: is_okを満たす最小(もしくは最大)の値
        """
        while abs(ok - ng) > 10 ** -5:
            mid = (ok + ng) / 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    def is_ok(x):
        cnt = 0
        for i in range(n):
            if A[i] > x:
                cnt += (A[i] + x - 1) // x - 1

        return cnt <= k

    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    res = meguru_bisect(10 ** 9 + 1, 0)
    print(math.ceil(res))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 92744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    int a, b, c; cin >> a >> b >> c;
    bool ok = false;
    if(a <= c && c <= b) ok = true;
    if(ok) cout << "Yes";
    else cout << "No";
}


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

int main() {
	int X;
	cin >> X;
	if (X < 4) cout << 1 << endl;
	else {
		int MAX = 0;
		for (int p = 2; p < 10; p++) {
			int b = 2;
			int bp = pow(b, p);
			while (bp <= X) {
				MAX = max(MAX, bp);
				b++;
				bp = pow(b,p);
			}
		}
		cout << MAX << endl;
	}


}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner reader=new Scanner(System.in);
    int n=reader.nextInt();
    int k=reader.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=reader.nextInt();
    }
    Arrays.sort(a);
    int sum=0;
    for(int i=a.length-1;i>a.length-1-k;i--){
      sum+=a[i];
    }
    System.out.println(sum); 
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  int s = 1;
  int nn = n;
  while (nn > s) {
    nn -= s;
    s += 1;
  }
  if (nn < s) {
    cout << "No" << endl;
    return 0;
  }
  s += 1;
  vector<vector<int>> v(s);
  for (int i = 0; i < s; ++i){
    v[i].reserve(s);
  }
  int cnt = 1;
  for (int i = 0; i < s; ++i) {
    for (int j = i+1; j < s; ++j) {
      v[i].push_back(cnt);
      v[j].push_back(cnt);
      cnt += 1;
    }
  }

  cout << "Yes" << endl;
  cout << s << endl;
  for(int i = 0; i < s; ++i) {
    cout << s-1;
    for(int j = 0; j < s-1; ++j) {
      cout << " " << v[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 2176
# def div(n):
#     ans = []
#     for i in range(1,int(n**(1/2)+2)):
#         if n%i == 0:
#             ans.append(i)
#             ans.append(n//i)
#     ans = set(ans)
#     return ans

k = int(input())
# print(div(k))
a = 7
for i in range(1,10**7+2):
    if a%k == 0:
        print(i)
        exit()
    a=a*10+7
    a %= k
print(-1)
# print(div(k))


Measured memory_bytes: 63284
#include<bits/stdc++.h>
#define fi first
#define se second
#define R register
#define mp make_pair
#define pb push_back
#define LL long long
#define Ldb long double
#define pii pair<int, int>
using namespace std;
const int N = 1e6 + 10;
const int mod = 998244353;

template <typename T> void read(T &x) {
	int f = 0;
	R char c = getchar();
	while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
	for (x = 0; c >= '0' && c <= '9'; c = getchar())
		x = x * 10 - '0' + c;
	if (f) x = -x;
}

int Qpow(int x, int p) {
	int ans = 1;
	while (p) {
		if (p & 1) ans = 1LL * ans * x % mod;
		x = 1LL * x * x % mod;
		p >>= 1;
	}
	return ans;
}

int Inv(int x) {
	return Qpow(x, mod - 2);
}

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

int n, m;
int inv[N], fac[N], fav[N];

int C(int x, int y) {
	return 1LL * fac[x] * fav[y] % mod * fav[x - y] % mod;
}

int main() {
	read(n); read(m);
	if (n > m) swap(n, m);
	fac[0] = fav[0] = 1;
	inv[1] = fac[1] = fav[1] = 1;
	for (int i = 2; i <= n + m; ++i) {
		inv[i] = 1LL * -mod / i * inv[mod % i] % mod +mod;
		fac[i] = 1LL * fac[i - 1] * i % mod;
		fav[i] = 1LL * fav[i - 1] * inv[i] % mod;
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		int tmp = 1LL * C(i * 2 - 1, i) * C(n + m - i * 2, n - i) % mod;
		ans = (ans + tmp >= mod) ? (ans + tmp - mod) : (ans + tmp);
	}
	ans = (n - 1LL * ans * Inv(C(n + m ,n))) % mod;
	ans = n + m - ans;
	if (ans < 0) ans += mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11904
// BWOTSHEWCHB

#include <bits/stdc++.h>

using namespace std ;

#define int long long
#define pb push_back
#define in insert
#define X first
#define Y second

const int MAXN = 1e6 + 69 , MOD = 1e9 + 7 ;

int n , leaf , dp[MAXN] , height[MAXN] ;
vector <int> g[MAXN] ;

void dfs(int v , int par = -1) {
	for ( auto u : g[v] )
		if ( u != par ) {
			height[u] = height[v] + 1 ;
			if ( height[u] > height[leaf] )
				leaf = u ;
			dfs(u , v) ;
		}
}

int32_t main() {
	ios::sync_with_stdio(false) ;
	cin.tie(0) ; cout.tie(0) ;
	cin >> n ;
	int v , u ;
	for ( int i = 1 ; i < n ; i ++ )
		cin >> v >> u , g[v].pb(u) , g[u].pb(v) ;
	dp[0] = 0 , dp[1] = 1 ;
	for ( int i = 2 ; i <= n ; i ++ )
		dp[i] = (dp[i - 1] | dp[i - 2]) ^ 1 ;
	dfs(1) , memset(height , 0 , sizeof height) , dfs(leaf) ;
	if ( dp[height[leaf]] )
		cout << "Second\n" ;
	else
		cout << "First\n" ;
}


Measured memory_bytes: 50688
#include"bits/stdc++.h"
#include"math.h"

using namespace std;
int main(){
  int N, D;
  cin >> N >> D;
  vector<vector<int>>  S(N , vector<int>(D));
    
    for(int i=0; i<N ; i++){
      for(int j=0; j<D ; j++){
        cin >> S.at(i).at(j);   }}
  
  int ans=0;
  
  for(int i=0 ; i<N; i++){
    for(int j=0 ; j<N; j++){
      if(i!=j){
      double sum=0.0;
      
      for(int k=0 ; k<D; k++){
      int x = S.at(i).at(k)-S.at(j).at(k);
        sum+=x*x;
        
      }
 
  sum=pow(sum,0.5);
      
      if(ceil(sum)==floor(sum)){ans++;}
    }}}
  cout << ans/2 << endl;}
      
      
    
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int a[400030];
 
int main()
{
    int N,C;
    cin >> N >> C;
    vector<P> v[100010];
    for(int i = 0; i < N; i++){
        int s,t,c;
        cin >> s >> t >> c;
        v[c].emplace_back(s,t);
    }
    for(int i = 0; i < 100010; i++) sort(v[i].begin(),v[i].end());
    for(int i = 0; i < 100010; i++){
        for(int j = 0; j < v[i].size(); j++){
            if(j != 0 && v[i][j-1].second == v[i][j].first){
                a[4*v[i][j-1].second-1]++;
                a[4*v[i][j].second-1]--;
            }else{
                a[4*v[i][j].first-2]++;
                a[4*v[i][j].second-1]--;
            }
        }
    }
 
    int res = a[0];
    for(int i = 1; i < 400030; i++){
        a[i] += a[i-1];
        res = max(res,a[i]);
    }
    //for(int i = 0; i < 200; i++) cout << i << ' ' << a[i] << endl;
 
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 5376
s1=int(input())
s2=int(input())
s3=int(input())
s4=int(input())
s5=int(input())
s6=int(input())
s7=int(input())
s8=int(input())
s9=int(input())
s10=int(input())
list=[s1,s2,s3,s4,s5,s6,s7,s8,s9,s10]
print(sum(list))


Measured memory_bytes: 5592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = Console.ReadLine().Trim().Split(' ');
            List<int> lstInp = new List<int>();
            for (int i = 0; i < sS.Length; i++) { lstInp.Add(int.Parse(sS[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = lstInp.Max() - lstInp.Min();

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0;i<N;i++) cin >> H[i];
  
  if(N==1) cout << "Yes" << endl;
  else{
    for(int i=1;i<N-1;i++){
      if(H[i-1] <= H[i]-1 && H[i]-1 <= H[i+1]) H[i]--;
      else if(H[i-1] > H[i] || H[i] > H[i+1]){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int i, n, id, best, count;
  double length, weight, BMI, bestBMI;

  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    count = 0;

    for(i=0; i<n; i++){
      scanf("%d %lf %lf", &id, &length, &weight);

      length /= 100;
      BMI = weight / (length * length);

      if(BMI < 22.0)
	BMI = 22.0 - BMI;
      else
	BMI = BMI - 22.0;

      if(BMI < bestBMI || count == 0){
	bestBMI = BMI;
	best = id;
      }else if(BMI == bestBMI){
	if(id < best)
	  best = id;
      }
      count++;
    }

    printf("%d\n", best);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>


int OutputPoint( int kale )
{
	int ret = 0 ;
	int i ;

	if( kale < 0 )
	{
		for( i = 0 ; i > kale ; --i )
		{
			--ret ;
			if( ret < 0 )
			{
				ret = 7 -1 ;
			}
		}
	}

	else
	{
		for( i = 0 ; i < kale ; ++i )
		{
			++ret ;
			if( ret > 7 -1 )
			{
				ret = 0 ;
			}
		}
	}

	return ret ;
}



int main( void )
{
	char dat[ 30 +1 ][ 3 +1 ] = { "sat" ,"sun" ,"mon" ,"tue" ,"wed" ,"thu" ,"fri" } ;
	
	int day ;
	scanf( "%d" ,&day ) ;

	printf( "%s\n" ,dat[ OutputPoint( day - 9 ) ] ) ;

	return 0 ;
}


Measured memory_bytes: 2120
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

long long x, y;

int solve()
{
  int cnt = 0;
  while (x <= y) {
    cnt++;
    x *= 2;
  }
  return cnt;
}

int main()
{
  cin >> x >> y;
  cout << solve() << endl;
}


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

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

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
count = [0] * 60
m = 1000000007
def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K * x) % 1000000007
        x = (x * x) % 1000000007
        n //= 2
    return (K * x) % 1000000007
mul = [pow_k(2,59-i) for i in range(60)]
for a in A:
    b = bin(a)
    for i in range(1,len(b)-1):
        if b[-i] == '1':
            count[-i] += 1
print(sum([count[i]*(N-count[i])*mul[i]%m for i in range(60)])%m)

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  string s;
  cin >> s;

  int ret = 0;
  REP(i, 4) {
    if(s[i]=='+') ret++;
    else ret--;
  }
  cout << ret << endl;

  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

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

int main(void)
{
    int a, b;
    cin >> a >> b;
    ((a * b % 2 == 0) ? puts("Even") : puts("Odd"));
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a > c) swap(a, c);
  if (b > c) swap(b, c);
  c <<= k;
  cout << a + b + c << endl;
  return 0;
}

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

int	main()
{
	int	N;
	cin >> N;
	int	A[2000];
	int	sum_A = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum_A += A[i];
	}
	bitset<4000000>	dp(1);
	for (int i = 0; i < N; ++i)
		dp |= (dp << A[i]);
	for (int i = (sum_A + 1) / 2; i <= sum_A; ++i) {
		if (dp.test(i)) {
			cout << i << endl;
			break;
		}
	}
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e2+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    ll sum=0;
    int y[x];
    for (int i=0;i<x;i++){
        cin>>y[i];
        sum+=y[i];
    }
    ll s=0,mx=1e18;
    for (int i=x-1;i>0;i--){
        sum-=y[i];
        s+=y[i];
        mx=min(mx,abs(s-sum));
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

long long int MH(long long int x){
	if(x == 1){
		return 1;
	}else{
		return 2*MH(x/2) + 1;
	}
}

int main(){
	long long int h;
	cin >> h;
	long long int ans = MH(h);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
b=[0]+list(map(int,input().split()))
c=[0]+list(map(int,input().split()))
ans=0
for i in range(1,n+1):
    ans+=b[a[i]]
    if a[i]+1==a[i+1]:
        ans+=c[a[i]]
print(ans)

Measured memory_bytes: 38256
#include <stdio.h>

int main(void){

    int v[20], c[20], ans=0;
    int n;

    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &v[i]);
    } 
    for(int i=0; i<n; i++){
        scanf("%d", &c[i]);
    }   

    for(int i=0; i<n; i++){
        if(v[i] - c[i] > 0){
            ans += (v[i] - c[i]);
        }
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
    #define MOD 1000000007
    #define INF 11234567890
    #define in std::cin
    #define out std::cout
    #define rep(i,N) for(LL i=0;i<N;++i)
    typedef long long int LL;
     
    LL N, M, A[112345], B[112345];
    std::vector<LL>G[112345];
    bool visited[112345];
    std::deque<LL>ans;
     
    void dfs1(LL pos)
    {
    	visited[pos] = true;
    	for (auto v : G[pos])
    	{
    		if (!visited[v])
    		{
    			ans.push_front(v);
    			dfs1(v);
    			break;
    		}
    	}
    }
     
    void dfs2(LL pos)
    {
    	visited[pos] = true;
    	for (auto v : G[pos])
    	{
    		if (!visited[v])
    		{
    			ans.push_back(v);
    			dfs2(v);
    			break;
    		}
    	}
    }
     
    int main()
    {
    	in >> N >> M;
    	rep(i, M)
    	{
    		in >> A[i] >> B[i];
    		G[A[i]].push_back(B[i]);
    		G[B[i]].push_back(A[i]);
    	}
    	memset(visited, false, sizeof(visited));
    	ans.push_back(1);
    	dfs1(1);
    	dfs2(1);
     
    	out << ans.size() << std::endl;
    	rep(i, ans.size() - 1) { out << ans[i] << " "; }
    	out << ans[ans.size() - 1] << std::endl;
    	return 0;
    }

Measured memory_bytes: 9472
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

/*--------switch header--------*/
#define ALGORITHM   1
#define CASSERT     0
#define CMATH       1
#define DEQUE       0
#define FUNCTIONAL  1
#define IOMANIP     1
#define IOSTREAM    1
#define LIST        0
#define MAP         0
#define QUEUE       0
#define SET         0
#define STRING      1
#define UTILITY     1
#define VECTOR      1
#define VEC_DEBUG   1

using namespace std;

#pragma region headers
#if VEC_DEBUG
#define _GLIBCXX_DEBUG
#endif
#if ALGORITHM
#include <algorithm>
#endif
#if CASSERT
#include <cassert>
#endif
#if CMATH
#include <cmath>
#endif
#if DEQUE
#include <deque>
#endif
#if FUNCTIONAL
#include <functional>
#endif
#if IOMANIP
#include <iomanip>
#endif
#if IOSTREAM
#include <iostream>
#endif
#if LIST
#include <list>
#endif
#if MAP
#include <map>
#endif
#if QUEUE
#include <queue>
#endif
#if SET
#include <set>
#endif
#if STRING
#include <string>
#endif
#if UTILITY
#include <utility>
#endif
#if VECTOR
#include <vector>
#endif
#pragma endregion


/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    ll n, k; cin >> n >> k;
    n %= k;
    while(true){
        if(!chmin(n, abs(n-k))){
            break;
        }
    }
    cout << n << endl;

return 0;
}

Measured memory_bytes: 3628
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int s;cin>>s;
  int x1,x2,y1,y2;
  int z = ceil(sqrt(s));
  assert(z<=1e9);
  x1 = z;
  y2 = z;
  int r = z*z-s;
  x2 = 1;
  y1 = r;
  dump(r);
  cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(auto &i:arr)cin>>i;
	vector<int>ans(n);
	ans[0]=0;
	ans[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
		ans[i]=min(abs(arr[i]-arr[i-1])+ans[i-1],ans[i-2]+abs(arr[i-2]-arr[i]));
	}
	cout<<ans[n-1]<<endl;
}

Measured memory_bytes: 3992
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int d(int x){
	return ((x)?(d(x/10)+1):0);
}

int main(void){
	int n,i,ans=0;
	cin >> n;
	for(i=1; i<=n; ++i){
		if(d(i)%2){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, P> PP;
const ll MOD = 1000000007LL;
int a[500][500];
int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> a[i][j];
	vector<PP> vec;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j + 1 < W; j++) {
			if (a[i][j] % 2) {
				vec.push_back({ {i,j},{i,j + 1} });
				a[i][j]--;
				a[i][j + 1]++;
			}
		}
	}
	for (int i = 0; i + 1 < H; i++) {
		if (a[i][W-1] % 2) {
			vec.push_back({ { i,W - 1 },{ i + 1,W - 1 } });
			a[i][W - 1]--;
			a[i + 1][W - 1]++;
		}
	}
	cout << vec.size() << endl;
	for (int i = 0; i < vec.size(); i++) {
		printf("%d %d %d %d\n", vec[i].first.first + 1, vec[i].first.second + 1, vec[i].second.first + 1, vec[i].second.second + 1);
	}
}


Measured memory_bytes: 5104
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int a, b, x; cin >> a >> b >> x;
  if(x >= a && x <= a + b) cout << "YES\n";
  else cout << "NO\n";
  return;
}

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


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from math import sqrt
from collections import Counter, deque
N = int(input())
As = list(mapint())
As.sort()
C = Counter(As)
S = set()

MAX = As[-1]
cnt = 0
for n in range(N):
    p = As[n]
    if p in S:
        continue
    i = 1
    while MAX>=p*i:
        S.add(p*i)
        i += 1
    if C[p]>=2:
        continue
    cnt += 1

print(cnt)

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

vector<vector<int>> group((100001), vector<int>(0, 0));

int getNumber(int n, int left, int right, int target) {
	int mid = (left + right) / 2;
	while(true) {
		mid = (left + right) / 2;
		if (group.at(n).at(mid) == target) {
			return mid;
		}
		else if (group.at(n).at(mid) < target) {
			left = mid + 1;
		}
		else {
			right = mid - 1;
		}
	}
} 

int main(){
    int n,m;
	cin >> n >> m;
	vector<int> p(m),y(m);
	for (int i = 0; i < m; i++) {
		cin >> p.at(i) >> y.at(i);
		group.at(p.at(i)).push_back(y.at(i));
	}
    
	for (int i = 1; i <= n; i++) {
		sort(group.at(i).begin(),group.at(i).end());
	}
	
	for (int i = 0; i < m; i++) {
		cout << setfill('0') << setw(6) << right << p.at(i) << setfill('0') << setw(6) << right << getNumber(p.at(i), 0, group.at(p.at(i)).size() - 1, y.at(i)) + 1 << endl;
	}
}


Measured memory_bytes: 7808
ans=0
def solution(a,b,c):
    if (a%2==0 and b%2==0) or (a%2!=0 and b%2!=0):
        ans=(b-a)//2
    else:
        ans=min(a-1,c-b)+1+(b-a)//2
    return ans

c,a,b=map(int,input().split())
print(solution(a,b,c))



Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))


int main(void)
{
	//変数の宣言
	char x[200010];
	int a,b;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int sum=0;
	llong int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%s",&x);
	
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	len=strlen(x);
	a=0;
	b=0;
	for(i=0;i<len;i++){
		if(b>0){
			if(x[i]=='T') b--;
			if(x[i]=='S') b++;
		}else{
			if(x[i]=='T') a++;
			if(x[i]=='S') b++;
		}
	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%d",a*2);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



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

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

	int n, q;
	string s;
  cin >> n >> q >> s;
	vector<int> dp(n);

	rep(i, n-1) {
		dp[i+1] = dp[i];
		if (s[i]=='A' && s[i+1]=='C') ++dp[i+1];
	}
	rep(i, q) {
		int l, r; cin >> l >> r;
		l--, r--;
		cout << dp[r] - dp[l] << endl;
	}

	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); 
  int n;
  cin >> n;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==n){cout << "Yes" << endl; return 0;}
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int a,b;

int main(){
    cin>>a>>b;
    out(((a*b)%2==1?"Odd":"Even"));    
}


Measured memory_bytes: 256
//Coin Chaining Problem
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int C[m], T[m][n + 1];
    for(int i = 0; i < m; i++) {
        cin >> C[i];
        T[i][0] = 0;
    }

    sort(C, C + m);

    for(int i = 0; i < m; i++) {
        if(i == 0) {
            for(int j = 1; j < n + 1; j++) {
                T[i][j] = j / C[i];
            }
        }
        else {
            for(int j = 1; j < n + 1; j++) {
                if(j < C[i]) {
                    T[i][j] = T[i - 1][j];
                } else {
                    T[i][j] = min(T[i - 1][j], T[i][j - C[i]] + 1);
                }
            }
        }
    }

    cout << T[m - 1][n] << endl;
}



Measured memory_bytes: 7060
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	int N, a;
	int cnt_4n = 0;
	int cnt_odd = 0;

	cin >> N;
	rep(i, N) {
		cin >> a;
		if (a % 4 == 0) cnt_4n++;
		else if (a % 2 == 1) cnt_odd++;
	}

	if (cnt_4n + cnt_odd == N) {
		if (cnt_4n >= cnt_odd - 1) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if (cnt_4n >= cnt_odd) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
#include<string>
using namespace std;
#include <numeric> 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using pi=pair<long long,long long>;
#define pii 3.1415926536
#define binary
#define mod 1000000007
typedef long long ll;
typedef long double ld;
bool sortbysec(const pair<long long,long long> &a, 
              const pair<long long,long long> &b) 
{ 
    return (a.first < b.first); 
}
bool compare(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll>&b)
{
    if(a.first.first==b.first.first)return (a.first.second<b.first.second);
    return (a.first.first < b.first.first); 
}
 int lcm(int a, int b)  
 {  
    return (a*b)/__gcd(a, b);  
 }  
 int Kad(ll dp[],ll n)
{
  ll curr_max=0,maxx=INT_MIN;
  for(int i=0;i<n;i++)
  {
    curr_max=curr_max+dp[i];
    if(curr_max>maxx)
      maxx=curr_max;

    if(curr_max<0)
      curr_max=0;
   
  }

  return maxx;
}

/*void dfs(int u)
{
    vis[u]=true;
    //cout<<u<<" ";
    std::vector<ll> ::iterator i;
     for (i = g[u].begin(); i != g[u].end(); ++i) 
        if (!vis[*i]) 
            dfs(*i); 
    for(int i=1;i<g[u].size();i++)
    {
        if(!vis[g[u][i]])
        {
            dfs(i);
        }
    }
}*/


int main(){
    IOS;
    
   ll n;
   cin>>n;
   if(n>=30)
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int A,B;
	cin>>A>>B;
	
	int ans=0;
	if(A>=B){
		ans+=A;
		A--;
		ans+=max(A,B);
	}
	else{
		ans+=B;
		B--;
		ans+=max(A,B);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
	int a, b, c, d, e, k;
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &k);
	if(e - a > k) printf(":(\n");
	else printf("Yay!\n");
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
int a,b,c;cin >>a>> b>>c;
if(a==b and b==c)cout << "No" << endl;
else if(a!=b and b!=c and a!=c)cout << "No" << endl;
else cout << "Yes" << endl;
return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace std;
    using namespace __gnu_pbds; 
    #define lli long long int
    #define fr(i,a,b) for(lli i=a;i<b;i++)
    #define bfr(i,a,b) for(lli i=a;i>=b;i--)
    #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
    #define tc int t;cin>>t;while(t--)
    #define mod 1000000007LL
    #define mod2 998244353LL
    #define all(vec) vec.begin(),vec.end()  
    #define ld long double
    #define pb push_back

    #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


       int main()
    {
                           
             

           
              fio   
             
              string s;
              cin>>s;
              if(s=="ARC")cout<<"ABC";
              else cout<<"ARC";

return 0;}

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

int main() {
    int a,b;
    cin>>a>>b;
    int diff=b-a;
    int res=diff*(diff+1)/2;
    cout<<res-b<<endl;
}


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

const int MAX = 1 << 17;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	vector<int> v(MAX << 1, INT_MAX);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			for (v[x += MAX] = y; x >>= 1;) {
				v[x] = min(v[x << 1], v[(x << 1) | 1]);
			}
		}
		else {
			int res = INT_MAX;
			for (x += MAX, y += MAX + 1; x < y; x >>= 1, y >>= 1) {
				if (x & 1) res = min(res, v[x++]);
				if (y & 1) res = min(res, v[--y]);
			}
			printf("%d\n", res);
		}
	}
	return 0;
}



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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<std::string> S) {
    vector<string> s1, s2;
    rep(i, N) {
        int a = 0;
        rep(j, S[i].size()) {
            if (S[i][j] == '(')
                a++;
            else
                a--;
        }
        if (0 <= a)
            s1.emplace_back(S[i]);
        else
            s2.emplace_back(S[i]);
    }

    vector<pair<long long, long long> > up, down;
    rep(i, s1.size()) {
        int a = 0;
        int b = 0;
        rep(j, s1[i].size()) {
            if (s1[i][j] == '(')
                a++;
            else
                a--;
            b = min(b, a);
        }
        up.emplace_back(-b, a);
    }

    rep(i, s2.size()) {
        int a = 0;
        int b = 0;
        for (int j = s2[i].size() - 1; 0 <= j; j--) {
            if (s2[i][j] == ')')
                a++;
            else
                a--;
            b = min(b, a);
        }
        down.emplace_back(-b, a);
    }

    sort(up.begin(), up.end());
    sort(down.begin(), down.end());

    long long h1 = 0;
    rep(i, up.size()) {
        if (h1 < up[i].first) {
            cout << NO << endl;
            return;
        }
        h1 += up[i].second;
    }

    long long h2 = 0;
    rep(i, down.size()) {
        if (h2 < down[i].first) {
            cout << NO << endl;
            return;
        }
        h2 += down[i].second;
    }

    if (h1 == h2) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 89656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
const ll mod = 1e9 + 7;
const ll inf = 1e11 + 5;
const int MaxN = 2e5 + 5;

int noOfDigits(int n){
	int ans = 0;
	while(n){
		ans++;
		n /= 10;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	int prev;
	cin >> prev;
	prev--;
	bool yes = true;
	for(int i = 1; i < n; i++){
		int x;
		cin >> x;
		if(x > prev){
			prev = --x;
		}
		else if(x < prev){
			yes = false;
		}
	}
	cout << (yes ? ("Yes") : ("No")) << endl;
}		


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n,k,amari,ans = 0;
    cin >> n >> k;
    amari = n % k;
    if (amari == 0){
        ans = 0;
    } else {
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using Int = boost::multiprecision::cpp_int;
int main() {
    Int a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0) cout << "No" << endl;
    else cout << (4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<cmath>
#include<vector>
#include<iostream>
#include<algorithm>
#define debug(ARGS) cout << #ARGS << ": " << ARGS << endl;
using namespace std;

int main(){
  int num; cin >> num;
  int l, r;

  int sum = 0;
  for(int i = 0; i < num; i++){
    cin >> l; cin >> r;
    sum += r - l + 1;
  }

  cout << sum << endl;

  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  ll ans = 0;
  ll sum = 0;
  for (ll i = 1; i <= x; ++i) {
    sum += i;
    if (sum >= x) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;


typedef long long ll;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    ll a, b;
    cin >> a >> b;
    if (a>b) swap(a, b);
    ll k = floor(sqrt((long double)a*b-1));
    if (a==b || a+1==b) {
      cout << 2*(a-1) << "\n";
    } else if (k*(k+1)>=a*b) {
      cout << 2*(k-1) << "\n";
    } else {
      cout << 2*k-1 << "\n";
    }
  }
  return 0;
}


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


int main(){
    string s;
    rep(i,3) cin>>s[i];

    int a = stoi(s);

    if(a%4==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin
def main():
  from builtins import int, map, range
  readline = stdin.readline
  from heapq import heappush, heappop
  n, m = map(int, readline().split())
  jobs = {}
  for _ in range(n):
    a, b = map(int, readline().split())
    if a > m:
      continue
    if a in jobs:
      jobs[a].append(b)
    else:
      jobs[a] = [b]
  result = 0
  candidates = []
  for a in range(1, m + 1):
    if a in jobs:
      for b in jobs[a]:
        heappush(candidates, -b)
    else:
      if len(candidates) == 0:
        continue
    result += -heappop(candidates)
  print(result)
main()


Measured memory_bytes: 26020
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
	var num = Number(input[0])
    var sleepSong = input[num+1]
    var time = 0
	for(var i = 1; i <= num; i++) {
    	var current = input[i].split(' ')
        var currentSong = current[0]
        if(currentSong === sleepSong) {
          for(var j = i+1; j <= num; j++) {
            var current = input[j].split(' ')
        	var currentSongTime = Number(current[1])
            time += currentSongTime
          }
          return console.log(time)
        }
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372