akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
long long dp[200000][3] = {};
int main(){
#define int long long
	int n;
	cin >> n;
	vector<int> inputs;
	int a;
	cin >> a;
	inputs.push_back(a);
	REP(i, n - 1) {
		int a;
		string b;
		cin >> b >> a;
		if (b == "+") {
			inputs.push_back(a);
		}
		else {
			inputs.push_back(-a);
		}
	}
	REP(i, 200000) {
		REP(q, 3) {
			dp[i][q] = -LONG_INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < inputs.size(); ++i) {
		for (int q = 0; q < 3; ++q) {
			if (inputs[i] < 0) {
				if (q == 0) {
					dp[i + 1][1] = max(dp[i + 1][1], dp[i][q] + inputs[i]);
				}
				else {
					dp[i + 1][1] = max(dp[i + 1][1], dp[i][q] + inputs[i]);
					dp[i + 1][2] = max(dp[i + 1][2], dp[i][q] - inputs[i]);
				}
			}
			else {
				for (int j = 0; j <= q; ++j) {
					int geko = 1;
					REP(t, j) {
						geko *= -1;
					}
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][q] + geko * inputs[i]);
				}
			}
		}
	}
	long long ans = max({ dp[n][0],dp[n][1],dp[n][2] });
	cout << ans << endl;
}

Measured memory_bytes: 5876
import scala.io.StdIn.readDouble

object Main extends App {
  def cubeRoot(q:Double) = {
    def f(x:Double):Double = {
      val x3 = x*x*x
      if( Math.abs(x3-q) < 0.00001*q ) x
      else f(x- (x3-q)/(3*x*x))
    }
    f(q/2)
  }
  var x = 0D
  while( {x=readDouble;x} != -1D ) {
    println(cubeRoot(x))
  }
}

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


int main(){
    int n;
    cin >> n;
    int kalan = n%100;
    int bolum = n/100;
    while(bolum--){
        if(kalan == 0){
            cout << "1";
            return 0;
        }
        if(kalan>=5)
            kalan-=5;
        else if(kalan == 4)
            kalan-=4;
        else if(kalan == 3)
            kalan-=3;
        else if(kalan == 2)
            kalan-=2;
        else if(kalan == 1)
            kalan-=1;
    }
    if(kalan == 0)
    	cout << "1";
    	else
    cout << "0";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> fs(n);
	ll ans = 0;
	rep(i, n) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		fs.at(i) = s;
	}
	sort(fs.begin(), fs.end());
	ll count = 1;
	string now = fs[0];
	rep2(i, 1, n) {

		if (fs[i] != now) {
			count = 1;
			now = fs[i];
		}
		else ++count;
		ans += count - 1;
	}
	cout << ans << endl;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class CSkillUp {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n,m,x;
        in>>n>>m>>x;
        vector<ll> c(n);
        vector<vector<ll>> a(n,vector<ll>(m));
        rep(i,n){
            in>>c.at(i);
            rep(j,m){
                in>>a.at(i).at(j);
            }
        }
        ll ans = INF;
        for(int tmp = 0; tmp<(1<<12); tmp++){
            bitset<12> bs(tmp);
            ll sumc=0;
            rep(i,n){
                if(bs.test(i))sumc+=c.at(i);
            }
            vector<ll> suma(m);
            rep(i,n){
                if(bs.test(i)){
                    rep(j,m){
                        suma.at(j)+=a.at(i).at(j);
                    }
                }
            }
            bool flag=true;
            rep(i,m){
                if(suma.at(i)<x) flag=false;
            }
            if(flag) {
                ans=min(ans,sumc);
            }

        }
//        vector<ll> mv(m,0);
//        ll ans=0;
//        rep(i,n){
//            ans+=c.at(i);
//            rep(j,m){
//                mv.at(j)+=a.at(i).at(j);
//            }
//            bool flag = true;
//            rep(j,m){
//                if(mv.at(j)<x) flag=false;
//            }
//            if(flag) break;
//        }
        if(ans==INF) ans=-1;
        out<<ans<<endl;

	}
};


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


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    map<ll, ll> d;
    for(size_t i=0;i<N; i++)
    {
        ll _d;
        cin >> _d;
        d[_d]++;
    }
    cout << d.size() << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3628
N,M = map(int,input().split())
LR = [[int(x) for x in input().split()] for _ in range(M)]
L = 1
R = N
for l,r in LR:
  L = max(L,l)
  R = min(R,r)
  
if L > R:
  print(0)
else:
  print(R-L+1)


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

int main(){
    string S;
    cin >> S;
    int output = 0, j = 0;
    for (int i = 0; i<3; ++i){
        if (S[i] == 'R'){
            j++;
        }
        if (S[i] == 'S'){
            j = 0;
        }
        if (j > output){
            output = j;
        }
    }
    cout << output << "\n";
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll n, A[4001], memo[4001][4001] = {}, ans = 0;
ll solve(int s, int e, bool JOI){
	if(memo[s][e]){
		return memo[s][e];
	}
	if(s == e){
		if(JOI){
			return memo[s][e] = A[s];
		} else{
			return memo[s][e] = 0;
		}
	}
	
	if(JOI){
		return memo[s][e] = max(solve(s + 1, e, 0) + A[s], solve(s,  e - 1, 0) + A[e]);
	} else{
		if(A[s] > A[e]){
			return memo[s][e] = solve(s + 1, e, 1);
		} else{
			return memo[s][e] = solve(s, e - 1, 1);
		}
	}
}

int main() {
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> A[i];
		A[i + n] = A[i];
	}
	
	for(int i = 0; i < n; i++){
		ans = max(ans, solve(i, i + n - 1, 1));
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 124732
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
print(N//3)


Measured memory_bytes: 3888
#include<stdio.h>
#define MAX 100
#define INF 10000001

void dijk();

int n;
int A[MAX][MAX], w[MAX];

int main(){
  int i, j;
  int u, k, v, c;

  scanf("%d", &n);
  //配列Aの初期化
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      A[i][j] = INF;
      }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    for(j = 0 ; j < k ; j++){
      scanf("%d%d", &v, &c);
      A[u][v] = c;//頂点uから頂点vまでの重みを記録する〜
    }
  }

  dijk();
  
  return 0;
}

void dijk(){
  int i, j;
  int min, minj;//minjは最小の重みのときのj(頂点v)のこと
  int visit[MAX];

  for(i = 0; i < n; i++){
    visit[i] = 0;
    w[i] = INF;
  }

  w[0] = 0;//最初の移動距離は0

  for(i = 0;; i++){
    min = INF;
    
    for(j = 0; j < n; j++){
      if(w[j] < min && visit[j] == 0){//常に最小の値を上書きしていく
	min = w[j];
	minj = j;
      }
    }
    
    if(min == INF) break;

    visit[minj] = 1;//移動した点はもう行かぬ
    
    for(j = 0; j < n; j++){
      if(A[minj][j] != INF && w[minj] + A[minj][j] < w[j] && visit[j] == 0){
	w[j] = A[minj][j] + w[minj];
      }
    }
  }

  for(i = 0; i < n; i++){
    printf("%d %d\n", i, w[i]);
  }
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    string s;
    cin>>s;

    int x=s.length(),xx;
    xx=x-1;

    if(x%2==0)
        x=x/2;
    else
        x=(x/2)+1;


    int c=0;
    for(int i=0; i<x; i++)
    {
        if(s[i]!=s[xx-i])
            c++;

        //cout<<s[i]<<" "<<s[xx-i]<<endl;

    }

    cout<<c<<endl;





    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

int map[100000];

int pow(int base, int exponent){
    long long cp = base;
    while(--exponent){
        cp*=base;
        cp%=998244353;
    }
    return (int)cp;
}

int main(){
    long long count = 1;
    int n,max = 0;
    std::cin >> n;
    int input;
    std::cin >> input;
    if(input){
        std::cout << 0;
        return 0;
    }
    for (int i = 1; i < n; ++i) {
        std::cin >> input;
        if(!input){
            std::cout << 0;
            return 0;
        }
        max = std::max(max, input);
        ++map[input];
    }
    for (int i = 1; i < max; ++i) {
        if(!map[i]){
            std::cout << 0;
            return 0;
        }
    }
    for (int i = 2; i <= max; ++i) {
        count *= pow(map[i-1],map[i]);
        count %= 998244353;
    }
    std::cout << count;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long

using namespace std;

int K;

signed main()
{
    cin >> K;
    int mem = 7;
    for(int i = 0; i < K + 10; i++)
    {
        if(mem % K == 0)
        {
            cout << i + 1;
            return 0;
        }
        mem = (mem * 10 + 7) % K;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3660
n=int(input())
a=input()
b=input()
c=input()
d=0
for i in range(n):
  if a[i]==b[i]==c[i]:
    continue
  elif a[i]==b[i] or b[i]==c[i] or a[i]==c[i]:
    d+=1
  else:
    d+=2
print(d)


Measured memory_bytes: 9084
// Problem : D - Div Game
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms

#include<bits/stdc++.h>
using namespace std ;

#define int     long long int
#define pii     pair<int, int>
#define vi      vector<int>
#define vii     vector<pair<int, int>>
#define pb      push_back
#define all(a)  (a).begin(),(a).end()
#define f       first
#define s       second
#define endl    '\n'
#define mod     1000000007    		

pair<int, int> get(int a, int p)
{
	int ans = 0 ;
	int var = 1 ;
	while(p - var >= 0)
	{
		p -= var ;
		ans++ ;
		var++ ;
	}
	return {ans, p} ;
}

void solve()
{
	int n ;
	cin >> n ;
	if(n <= 1)
	{
		cout << 0 << endl ; 
		return ;
	}
	vector<int> v ;
	for(int i = 2 ; i * i <= n ; i++)
	{
		while(n % i == 0)
		{
			v.pb(i) ;
			n /= i ;
		}
	}
	if(n > 1)
		v.pb(n) ;
	
	map<int, int> mp ;
	for(auto i : v)
		mp[i]++ ;
	
	int ans = 0 ; pair<int, int> p ;
	for(auto& i : mp)
	{
		p = get(i.first, i.second) ;
		ans += p.first ;
		i.second = p.second ;
	}
	cout << ans << endl ;
}

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

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

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

int main(){
  int n, s;
  s = 1;
  string h;
  cin >> n >> h;
  for(int i = 1; i < n; i++){
    if(h[i - 1] != h[i])
      s++;
  }
  cout << s << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cmath>
#include<vector>

using namespace std;
using ll = long long;
const ll N = 1e6;
const double PI = acos(-1.0);
#define Test ll tesnum;tesnum = read();while(tesnum--)
ll read();

int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return "BT7274", NULL;
}

inline ll read() {
    ll hcy = 0, dia = 1;char boluo = getchar();
    while (!isdigit(boluo)) {if (boluo == '-')dia = -1;boluo = getchar();}
    while (isdigit(boluo)) {hcy = hcy * 10 + boluo - '0';boluo = getchar();}
    return hcy * dia;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

vector<ll> a, x;

ll solve(ll x) {
    int left = 0, right = 0;
    int n = a.size();
    ll ans = 0;

    ll localsum = 0;
    for (left = 0; left < n; left++) {
        while (right < n) {
            if (localsum + a[right] <= x) {
                localsum += a[right];
                right++;
            } else {
                break;
            }
        }
        localsum -= a[left];
        ans += (right - left);
    }
    return ans;
}

int main(int argc, char** argv) {
    int n, q;
    cin >> n >> q;
    a.resize(n);
    x.resize(n);

    rep(i, n) { cin >> a[i]; }
    rep(i, q) { cin >> x[i]; }
    rep(i, q) { cout << solve(x[i]) << endl; }
    return 0;
};



Measured memory_bytes: 4416
#include <stdio.h>

int main() {
    char str [3];
    int input;
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    while (scanf("%d,%s",&input,str)!=EOF) {
        if (str[0] == 'A' && str[1] == 'B') {
            c++;
        }
        else if (str[0] == 'B') {
            b++;
        }
        else if (str[0] == 'A') {
            a++;
        }
        else if (str[0] == 'O') {
            d++;
        }
    }
    printf("%d\n%d\n%d\n%d\n", a, b, c, d);
    return 0;
}

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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(A+B > C+D)cout << "Left" << endl;
    else if(A+B == C+D)cout << "Balanced" << endl;
    else if(A+B < C+D)cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N, K;
    cin >> N >> K;
    vector<int> A(N+1);
    vector<int> S(N+1); //! accumulated sum
    for (int i = 1; i <= N; ++i) {
        int a; 
        cin >> a;
        --a;  //! to convert '(sum of range) % K = length' to '(sum of range) % K == 0'
        A[i] = a;
    }
    S[0] = 0;
    for (int i = 1; i <= N; ++i) {
        S[i] = (S[i-1] + A[i]) % K;
    }

    LL ans = 0;
    map<int, int> hist;
    for (int i = 1; i <= N; ++i) {
        int out = i-K;
        if (0 <= out) {
            --hist[S[out]];
        }
        if (!S[i]) ++ans;
        ans += hist[S[i]];
        ++hist[S[i]];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	cin>>n;
	int sum =0;
	vector<int> a;
	for(int i=0;i<n;++i){
		int val;
		cin>>val;
		sum += val;
		a.push_back(val);
	}
	int ans = 0;
	int as = sum/n;
	float asn = sum/(float)n;
	for(int i=0;i<n;++i){
		ans += ((a[i]-as)*(a[i]-as));
	}
	//cout<<"asn : "<<asn<<'\n';
	int ct = 0 ;
	int ans1 = 0;
	if(asn - as > 0){
		++as;
		ct ++;
		for(int i=0;i<n;++i){
			ans1 += ((a[i]-as)*(a[i]-as));
		}
	}
	if(ct) cout<<min(ans,ans1)<<'\n';
	else cout<<ans<<'\n';
	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a == b)
    {
        if (b == c)
        {
            printf("No");
        }
        else
        {
            printf("Yes");
        }
    }
    else
    {
        if (b == c || a == c)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    return 0;
}

Measured memory_bytes: 128
K,N=map(int, input().split())
As=[int(i) for i in input().split()]
ans=[]
for num in range(0,len(As)-1):
    ans.append(As[num+1]-As[num])
ans.append((K-max(As))+min(As))
ans.sort()
print(sum(ans[:-1]))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
typedef long long ll;
using namespace std;

int N, L[2000];
ll res;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	sort(L, L + N);
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int t = lower_bound(L, L + N, L[j] - L[i] + 1) - L;
			res += max(0, i - t);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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

	double sum = 0;
	for (int i = 0; i < n; i++) {
		double x;
		cin >> x;
		string s;
		cin >> s;
		if (s[0] == 'J') {
			
			sum += x;
		}
		else {
			
			sum += x * 380000;
		}
		
	}

	cout << setprecision(15) << sum << endl;

}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define Rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

//----------------library in this time--------------------------------
template <typename T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <typename T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <typename T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}
//------------------------main function-------------------------------
void Main(){
    string s;
    cin >> s;
    size_t size_s = s.size();
    vector<u64>ans(size_s,0);
    cout << endl;
    set<u64> idx;
    idx.insert(0);
    idx.insert(size_s);
    for(int i = 0; i < size_s - 1; i++){
        if(s[i] != s[i+1]){
            idx.insert(i + 1);
        }
    }
    set<u64>::iterator itr = idx.begin();
    itr++;
    
    for(; itr != idx.end(); itr++,itr++){
        
        set<u64>::iterator itr_back = itr;
        itr_back--;
        set<u64>::iterator itr_front = itr;
        itr_front++;
        u64 dif_front = *itr_front - *itr;
        u64 dif_back = *itr - *itr_back;
        u64 sum = dif_front + dif_back;
        
        if(sum % 2 == 0){
            u64 clack = *itr;
            ans[clack - 1] = sum / 2;
            ans[clack] = sum / 2;
        }else if(dif_back % 2 == 0 && (dif_back > dif_front || dif_back < dif_front)){
            u64 clack = *itr;
            ans[clack - 1] = sum / 2;
            ans[clack] = sum / 2 + 1;
            
        }else if (dif_back % 2 == 1 && (dif_back < dif_front || dif_back > dif_front)){
            u64 clack = *itr;
            ans[clack - 1] = sum / 2 + 1;
            ans[clack] = sum / 2;
        }
    }
    
    for (auto itr = ans.begin(); itr != ans.end(); itr++) {
        cout << *itr << " ";
    }
    cout << endl;
    
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    
    Main();
    return 0;
}


Measured memory_bytes: 6096
#include <stdio.h>
#include <string.h>

int stricmp(char* ch1, char* ch2) {
	int ch1_length=0, ch2_length=0, dif;

	for (int i = 0; ch1[i] != '\0'; i++) ch1_length++;
	for (int i = 0; ch2[i] != '\0'; i++) ch2_length++;
	if (ch1_length != ch2_length) { return -1; }

	for (int i = 0; ch1[i] != '\0'; i++) {
		dif = ch2[i] - ch1[i];
		if (dif != 0 && dif != 32 && dif != -32) { return -1; }
	}
	return 0;
}


int main() {
	char W[10], T[1000];
	int cnt = 0;
	scanf("%s", W);

	while (true) {
		scanf("%s", T);
		if (strcmp("END_OF_TEXT", T)==0) { break; }
		if (stricmp(W, T)==0) { cnt++; }
	}
	printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 2700
#include <iostream>
using namespace std;
const int N = 100000;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	
	int d[N * 2];
	int a;
	for(int i = 1; i < n; ++i){
		cin >> a;
		d[i] += d[i - 1] + a;
	}
	
	int now = 0;
	int ans = 0;
	for(int i = 0; i < m; ++i){
		cin >> a;
		if(a > 0)
			ans += d[now + a] - d[now];
		else
			ans += d[now] - d[now + a];
		now += a;
		ans %= N;
		//cout << now + 1 << " " << ans << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1592
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;
int main(void){
	int a,b,k,i;
	set<int> s;
	
	cin >> a >> b >> k;
	
	for(i = a; i < a+k && i <= b; i++)
		s.insert(i);
	for(i = b; i > b-k && i >= a; i--)
		s.insert(i);
	for(auto itr = s.begin(); itr != s.end(); itr++)
		cout << *itr << "\n";
}

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

int main() {
  int N;
  int cnt = 1;
  cin >> N;
  vector<string> S(N);
  rep(i, N) cin >> S.at(i);
  sort(S.begin(), S.end());
  for(int i = 0; i < N;){
    for(int j = i + 1; j < N; j++){
      if(S.at(i) != S.at(j)){
        cnt++;
        i = j;
        break;
      }
      else if(j == N - 1){
        i = j;
      }
    }
    if(i == N - 1) break;
  }
  cout << cnt << endl;
}

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

using namespace std;

int main()
{
	int N,k;
	scanf("%d",&N);
	if( N == 1) {
		printf("1\n");
		return 0;
	}
	for(int i=1;;i++){
		if(N >= pow(2,i) && N < pow(2,i+1)){
		printf("%d\n",k=pow(2,i));
		break;
		}}
	return 0;
}


Measured memory_bytes: 256
s = [list(map(int, input().split())) for i in range(2)]
num = 0
for i in range(0, s[0][0]-1):
  if s[1][i]>s[1][i+1]:
    num += abs(s[1][i]-s[1][i+1])
    s[1][i+1]=s[1][i]
print(num)

Measured memory_bytes: 32124
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] tmp = scanner.nextLine().split(" ");

		int ans = 0;
		for(int i = 0; i < 5; i++){

			if(Integer.parseInt(tmp[i]) == 0) {
				ans = i + 1; break;
			}

		}

			System.out.println(ans);

	}

}


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

int main() {
    int n, m;
    int input;
    ll sum = 0;

    cin >> n >> m;

    for(int i = 0;i < m;i++) {
        cin >> input;
        sum +=  input;
    }

    if (sum > n) {
        cout << "-1" << endl;
    } else {
        cout << n - sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

signed main(void) {
  int N;
  cin >> N;
  string flag = "No";
  rep(i, 9) {
    int B = N/(i+1);
    if (N == (i+1) * B) {
      if (B <= 9) {
        flag = "Yes";
      }
    }
  }
  cout << flag << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), n = sc.nextInt();
        int result = 0;

        int[] s = new int[n], f = new int[n];
        for(int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            f[i] = sc.nextInt();
        }

        for(int i = 0; i < n; i++) {
            if(a < f[i] && s[i] < b) {
                result++;
                break;
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 26380
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define F(i,a,b) for(int i=a;i<=b;++i)
int n;
map<string,int> cnt;
int main(){
	cin>>n;
	while(n--){
		string s;cin>>s;
		++cnt[s];
	}
	string s="AC";
	cout<<s<<" x "<<cnt[s]<<endl;
	s="WA";
	cout<<s<<" x "<<cnt[s]<<endl;
	s="TLE";
	cout<<s<<" x "<<cnt[s]<<endl;
	s="RE";
	cout<<s<<" x "<<cnt[s]<<endl;
	return 0;
}

Measured memory_bytes: 3632
/**
 *      AGC 3 B
 *      author  : kyomukyomupurin
 *      created : 2018-10-11 06:53:11
**/

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define int64 long long
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int A[N] = {};

    for (auto i = 0; i < N; ++i) {
        cin >> A[i];
    }

    int64 ans = 0;
    int beg = 0;
    
    while (beg < N){
        int64 len = 0;
        while (A[beg] != 0 && beg < N){
            len += A[beg]; ++beg;
        }
        ans += (len / 2); ++beg;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+7;
int n,ans;
ll a[N],b[N],c[N],sum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
	for(int i=1;i<=n;i++)c[i]=a[i]-b[i];
	sort(c+1,c+n+1);
	for(int i=1;i<=n;i++)sum+=c[i];
	if(sum<0){puts("-1");return 0;}
	sum=0;
	for(int i=1;i<=n;i++)if(c[i]<0)ans++,sum-=c[i];
	if(!ans){puts("0");return 0;}
	for(int i=n;i;i--)
	{
		ans++;
		sum-=c[i];
		if(sum<0){printf("%d\n",ans);return 0;}
	}
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

int main(){
  int n;cin >> n;
  string s;cin >> s;
  int ans = 0;
  int x=0;
  for(auto&i:s){
    if(i=='I') x++;
    if(i=='D') x--;
    chmax(ans,x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())

m = max(A, B, C)
num1 = min(A, B, C)
num2 = min(max(A, B), C) if A == num1 or B == num1 else min(max(B, C), A)
count = 0

if (m - num1) % 2 == (m - num2) % 2:
    if (m - num1) % 2 == 0:
        count += (m - num1) / 2
        count += (m - num2) / 2
    else:
        count += (m - num1) // 2
        count += (m - num2) // 2
        count += 1
    print(int(count))

else:
    if (m - num1) % 2 == 0:
        count += (m - num1) / 2
        count += (m - num2) // 2
        count += 2
    else:
        count += (m - num2) / 2
        count += (m - num1) // 2
        count += 2
    print(int(count))

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
cnt = 0
allsei = False
for i in range(n):
    if a[i] == 0:
        allsei = True
        break
    if a[i] < 0:
        cnt += 1
if cnt%2 == 0:
    allsei = True

ans = 0
mini =12345678901
for i in range(n):
    ans += abs(a[i])
    mini = min(mini,abs(a[i]))
if not allsei:
    ans -= 2*mini
print(ans)

Measured memory_bytes: 14412
import time
import random
d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
# 各日に一番満足度の増加が大きいコンテストを開催する
T = [S[i].index(max(S[i])) for i in range(d)]
score = 0
start = time.time()
while True:
    now = time.time()
    if now - start > 1.5:
        break
    p = random.choice(range(d))
    q = random.choice(range(26))
    memo = T[p]
    T[p] = q
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    new_score = 0
    for i in range(d):
        new_score += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        new_score -= C[j] * (dd - X[j])
    temp = 20000 * (1 - (now - start) / 2)
    prob = 2**((new_score - score) / temp)
    u = random.random()
    if u < prob:
        score = new_score
    else:
        T[p] = memo

for t in T:
    print(t + 1)


Measured memory_bytes: 85820
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin >> x;
    if(400 <= x && x <= 599){
        cout << 8 << endl;
    }else if(600 <= x && x <= 799){
        cout << 7 << endl;
    }else if(800 <= x && x <= 999){
        cout << 6 << endl;
    }else if(1000 <= x && x <= 1199){
        cout << 5 << endl;
    }else if(1200 <= x && x <= 1399){
        cout << 4 << endl;
    }else if(1400 <= x && x <= 1599){
        cout << 3 << endl;
    }else if(1600 <= x && x <= 1799){
        cout << 2 << endl;
    }else if(1800 <= x && x <= 1999){
        cout << 1 << endl;
    }

}




Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int[] arr = inputval();
        int l = arr[0]+arr[1];
        int r = arr[2]+arr[3];
        if(l>r) System.out.println("Left");
        else if(l==r) System.out.println("Balanced");
        else System.out.println("Right");
    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

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

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,int(n)+1)
#define RREP(i,n) RFOR(i,0,n)
#define RREPS(i,n) RFOR(i,1,int(n)+1)
#define ALL(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void pvp(T a, T b) { for (T i = a; i != b; ++i) cout << "(" << i->first << ", " << i->second << ") "; cout << 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 in() { int x; scanf("%d", &x); return x; }
 
using ll = long long;
#define int ll
 
//**********

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

    vector<int> sticks;
    int a;

    REP(i, n_sticks){
        cin >> a;
        sticks.pb(a);
    };

    int ans = 0;
    
    sort(ALL(sticks));
    REP(i, n_sticks-2){
        FOR(j,i+1,n_sticks-1){
            ans += distance(sticks.begin(), lower_bound(ALL(sticks), sticks[i] + sticks[j])) - j - 1;
            // cout << "i,j:" << sticks[i] << sticks[j] << ", ans:" << ans << endl;
        }
    }

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


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

int main(){
    int n;
    cin>>n;
    int x=n;
    int f=0;
    while(x>0){
        f+=x%10;
        x/=10;
    }
    if(n%f==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	int N;
	cin >> N;
	vint L(2*N);
	for (int i = 0; i < 2*N; i++) {
		cin >> L[i];
	}

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

	int ans = 0;

	for (int i = 0; i < N; i++) {
		ans += L[i * 2];
	}

	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int str[2][n];
    int i,j;
    for(i=0; i<2; i++)
        for(j=0; j<n; j++)
        {
            scanf("%d",&str[i][j]);
        }
    int stu[n];
    stu[0]=str[0][0];
    for(i=0;i<n;i++)
        stu[0]+=str[1][i];
    for(i=1;i<n;i++)
    {
        stu[i]=stu[i-1]-str[1][i-1]+str[0][i];
    }
    sort(stu,stu+n);
    cout<<stu[n-1];
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a,b,d,r;
		a = sc.nextInt();
		b = sc.nextInt();
		d=a/b;
		r=a%b;
		double f=(double)a/b;
		System.out.print(d+" "+r+" ");
		System.out.printf("%.8f\n", f);
	}

}

Measured memory_bytes: 26572
#include <bits/stdc++.h>
#define pb push_back
#define lson (k<<1)
#define rson (k<<1|1)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl
#define rep(i,s,t) for(int i=(s),_t=(t);i<_t;++i)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> veci;
inline void Max(int &a,int b)
{
	if(b>a)a=b;
}


const int N=(int)2e5+5;

int n,m,tr[N<<2],tag[N<<2];
veci vec[N];

inline void push_up(int k)
{
	tr[k]=max(tr[lson],tr[rson]);
}

void upd(int k,int val)
{
	tr[k]+=val;
	tag[k]+=val;
}

void push_down(int k)
{
	if(!tag[k])return;
	upd(lson,tag[k]);
	upd(rson,tag[k]);
	tag[k]=0;
}

void cons(int L,int R,int k=1)
{
	if(L==R)
	{
		tr[k]=L-m-1;
		return;
	}
	int mid=L+R>>1;
	cons(L,mid,lson);
	cons(mid+1,R,rson);
	push_up(k);
}

int query(int L,int R,int l,int r,int k=1)
{
	if(L==l&&R==r)return tr[k];
	push_down(k);
	int mid=L+R>>1;
	if(r<=mid)return query(L,mid,l,r,lson);
	if(l>mid)return query(mid+1,R,l,r,rson);
	return max(query(L,mid,l,mid,lson),query(mid+1,R,mid+1,r,rson));
}

void modify(int L,int R,int l,int r,int k=1)
{
	if(L==l&&R==r)return upd(k,1);
	push_down(k);
	int mid=L+R>>1;
	if(r<=mid)modify(L,mid,l,r,lson);
	else if(l>mid)modify(mid+1,R,l,r,rson);
	else
	{
		modify(L,mid,l,mid,lson);
		modify(mid+1,R,mid+1,r,rson);
	}
	push_up(k);
}

int main()
{
	cin>>n>>m;
	for(int i=0,L,R;i<n;++i)
	{
		scanf("%d%d",&L,&R);
		vec[L].pb(R);
	}
	int ans=max(0,n-m);
	cons(2,m+1);
	rep(L,0,m)
	{
		for(int R:vec[L])if(L+1<R)modify(2,m+1,L+2,R);
		Max(ans,query(2,m+1,L+2,m+1)-L);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+9;
const double ep=1e-7;
const int mod=1e9+7;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
#define debug1 puts("?");
#define debug(x) cout<<"##"<<(x)<<endl;
#define mk make_pair
#define PII pair<int,int>
#define PIII pair<int,PII >
#define PIL pair<int,ll>
#define PLI pair<ll,int>
#define eb emplace_back
#define fi first
#define se second
#define rep(i,n) for(register int i=1;i<=(n);++i)
#define sd(x) scanf("%d",&(x))
#define slld(x) scanf("%lld",&(x))
#define sdd(x,y) scanf("%d%d",&(x),&(y))
#define sc(s) scanf("%s",(s))
#define pd(x) printf("%d\n",(x))
#define plld(x) printf("%lld\n",(x))
#define pdk(x) printf("%d ",(x))
typedef long long ll;
int h,w,a[maxn],ans=0;
int ch,cw,dh,dw;
vector<PII >vec;
char s[maxn][maxn]; 
bool vis[maxn][maxn];
int dir[4][2]={1,0,0,1,-1,0,0,-1};
bool check(int x,int y)
{
	if(x<=0||x>h||y<=0||y>w)return 0;
	if(s[x][y]=='#'||vis[x][y])return 0;
	return 1;
}
int bfs()
{
	int now=0;
	queue<PII >q;
	q.push(mk(ch,cw));
	vis[ch][cw]=1;
	while(1)
	{
		if(q.empty())break;
		while(!q.empty())
		{
			PII p=q.front();q.pop();
			vec.eb(mk(p.fi,p.se));
			for(int i=0;i<4;i++)
			{
				int x=p.fi+dir[i][0],y=p.se+dir[i][1];
				if(!check(x,y))continue;
				q.push(mk(x,y));
				vis[x][y]=1;
				if(x==dh&&y==dw)return now;
			}
		}
		for(PII j:vec)
		{
			for(int i=-2;i<=2;i++)
			{
				for(int k=-2;k<=2;k++)
				{
					int x=j.fi+i,y=j.se+k;
					if(!check(x,y))continue;
					q.push(mk(x,y));
					vis[x][y]=1;
					if(x==dh&&y==dw)return now+1;
				}
			}
		}
		vec.clear();
		now++;
	}
	return -1;
}
int main()
{
	sdd(h,w);sdd(ch,cw);sdd(dh,dw);
	rep(i,h)sc(s[i]+1);
	printf("%d\n",bfs());
}

Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

const int MAXN = 100000 + 10;

int main() {
    ll N;
    cin >> N;
    ll ans = -1;
    ll curr = 0;
    ll x;
    for (int i = 0; i < N; ++i) {
        cin >> x;
        while (x % 2 == 0) {
            x >>= 1;
            ++curr;
        }
        if (ans == -1) {
            ans = curr;
        } else {
            ans = min(ans, curr);
        }
        curr = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
    a=0.5*i*(i-1)
    b=0.5*n*(n+1)-0.5*(n-i)*(n-i+1)
    ans+=int(b-a+1)
    
    
print(ans%(10**9+7))

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

int main() {
	ll N, K; cin >> N >> K;
	ll* H = new ll[N + 1];
	ll** dp = new ll * [N];

	for (int i = 0; i <= N; i++) {
		if (i == 0) { H[0] = 0; }
		else { cin >> H[i]; }

		dp[i] = new ll[N + 1];
		for (int j = 0; j <= N; j++) {
			dp[i][j] = INF;
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			if (j == 0) {
				dp[i][j] = 0; continue;
			}
			else if (j == 1) {
				dp[i][j] = H[i];
				continue;
			}
			for (int k = 0; k < i; k++) {
				dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0LL, H[i] - H[k]));
			}
		}
	}

	ll ans = dp[N - 1][N - K];
	for (int i = 1; i <= N; i++) {
		ans = min(ans, dp[i][N - K]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
import fractions
A, B, C, D = map(int, input().split())
lcm = C * D // fractions.gcd(C,D)
wari_A = (A-1) - ((A-1) // C + (A-1) // D - (A-1)//lcm)
wari_B = B - (B// C + B // D - B//lcm)
print(wari_B -wari_A)


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES";
	}
	else cout << "NO";

}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;

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

    int n;
    cin>>n;

    map<string,int> m{};
    set<string> z;
    vector<string> v;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;

        m[s]++;

        if(z.find(s)==z.end()){
            v.push_back(s);
        }

        z.insert(s);
    }

    int m1;
    cin>>m1;

    for(int i=1;i<=m1;i++){
        string s;
        cin>>s;

        m[s]--;
    }

    int ans=0;
    for(int i=0;i<v.size();i++){
        ans=max(ans,m[v[i]]);
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n,i;
  char s[200001][11];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&s[i]);
  }
  qsort(s, n, 11, strcmp);
  int count=1;
  for(i=1;i<n;i++){
    if(strcmp(s[i], s[i-1])!=0){
      count++;
    }
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 5720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		if(a >= 3200){
			System.out.println(s);
		}
		else{
			System.out.println("red");

		}

	}

}

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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<(int)n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=(int)n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()

const int N = 2000100;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

int _;

vector<ll> v[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t; cin >> s >> t;

	ll dp[26]={0};
	for(auto &x: t) dp[x-'a']=1;
	for(auto &x: s) dp[x-'a']=0;
	bool ok = 0;
	for(int i=0; i<26; ++i){
		if(dp[i]>0){
			ok = 1;
		}
		else continue;
	}

	if(ok){
		cout << -1 << endl;
		return 0;
	}		
	
	
	rep(i,0,sz(s),1){
		v[s[i]-'a'].push_back(i);
	}
	
	ll word = -1, last_pos = -1, ans = 0;
	rep(i,0,sz(t),1){
		auto ub = upper_bound(v[t[i]-'a'].begin(), v[t[i]-'a'].end(), word);
		ll gg = ub-v[t[i]-'a'].begin();
		if(gg != sz(v[t[i]-'a'])){
			word = v[t[i]-'a'][gg];
			last_pos = v[t[i]-'a'][gg]+1;
		}
		else{
			++ans;
			word = -1;
			--i;
		}
	}
	cout << ans*sz(s)+last_pos << endl;
	return 0;
}


Measured memory_bytes: 1736