akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
	int joi[3][3];
	int JOI[3][3];
	int sum[3] = {0};
	int SUM[3] = {0};
	int ans[3] = {0};
	for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> joi[i][j];
            if(j == 2) sum[i] += joi[i][j];
            else if(j == 1) sum[i] += (joi[i][j] * 60);
            else if(j == 0) sum[i] += (joi[i][j] * 3600);
        }
        for(int j = 0; j < 3; j++){
            cin >> JOI[i][j];
            if(j == 2) SUM[i] += JOI[i][j];
            else if(j == 1) SUM[i] += JOI[i][j] * 60;
            else if(j == 0) SUM[i] += JOI[i][j] * 3600;
        }
        ans[i] = SUM[i] - sum[i];
        int cnt[3] = {0};
        int j = 0;
        while(ans[i] != 0){
            if(ans[i] >= 3600){
                ans[i] -= 3600;
                cnt[j]++;
            }
            else if(ans[i] >= 60){
                ans[i] -= 60;
                cnt[j+1]++;
            }
            else if(ans[i] >= 1){
                ans[i] -= 1;
                cnt[j+2]++;
            }
        }
        for(int j = 0; j < 3; j++){
            joi[i][j] = cnt[j];
        }
	}
	for(int i = 0; i < 3; i++){
        for(int j = 0; j < 2; j++){
            cout << joi[i][j] << " ";
        }
        cout << joi[i][2] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	long long ans0 = 0; 
	{
		long long sum0 = 0;
		//+-+-
		for (int i = 0; i < N; ++i) {
			sum0 += A[i];
			if (0 == i%2) {
				if (sum0 <= 0) {
					ans0 += (1 - sum0);
					sum0 = 1;
				}
			}
			else {
				if (sum0 >= 0) {
					ans0 += (sum0 -(-1));
					sum0 = -1;
				}
			}
		}
	}	
	long long ans1 = 0;
	{
		long long sum1 = 0;
		//-+-+
		for (int i = 0; i < N; ++i) {
			sum1 += A[i];
			if (1 == i % 2) {
				if (sum1 <= 0) {
					ans1 += (1 - sum1);
					sum1 = 1;
				}
			}
			else {
				if (sum1 >= 0) {
					ans1 += (sum1 - (-1));
					sum1 = -1;
				}
			}
		}
	}
	cout << min(ans0,ans1)<<endl;
	return 0;
}

Measured memory_bytes: 4032
N, D = map(int, input().split())
items = []
for i in range(N):
    items.append(tuple(map(int, input().split())))

res = set()
for i in range(1000):
    res.add(i ** 2)

ans = 0
for i in range(N):
    a = 0
    for j in range(i + 1, N):
        tmp = 0
        for k in range(D):
            y = items[i][k]
            x = items[j][k]
            tmp += abs(y-x) ** 2
        a = tmp
        if a in res:
            ans += 1
print(ans)


Measured memory_bytes: 3064
import itertools

S = input()

total = 0
prev = 0
for p in itertools.product([False, True], repeat=len(S)-1):
    prev = 0
    for i in range(len(p)):
        if p[i]:
            total += int(S[prev:i+1])
            prev = i+1
    total += int(S[prev:])

if total == 0:
    total = int(S)
print(total)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define maxn 100000 * 2 + 10
using namespace std;
int main()
{
    double co = 0;
    double cd = 0;
    int n;
    cin>>n;
    for(int i = 1 ; i <= n ; i++)
    {
        if(i&1)
            cd++;
        else
            co++;
    }
    double mid = cd/(double)n;
    printf("%.6lf\n",mid);
}


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

int main(){
	int n;
	cin >> n;
    ll ns;
    vector<ll> n0(61);
    vector<ll> n1(61);
    rep(i, 61){
      n0.at(i) = 0;
      n1.at(i) = 0;
    }
    rep(i, n){
      cin >> ns;
      rep(j, 61){
        if(ns % 2 == 0){
          n0.at(j)++;
        }else{
          n1.at(j)++;
        }
        ns /= 2;
      }
    }
    ll a = 0;
    ll b = 0;
    ll c = 1;
    rep(i, 61){
      b = n0.at(i) * n1.at(i);
      if(b >= 1000000007) b %= 1000000007;
      b = b * c;
      if(b >= 1000000007) b %= 1000000007;
      a += b;
      if(a >= 1000000007) a %= 1000000007;
      c *= 2;
      if(c >= 1000000007) c %= 1000000007;
    }
	cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc069_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, M;
  cin >> N >> M;

  ll ans;
  if (2 * N < M) {
    ans = N + (M - 2 * N) / 4;
  } else {
    ans = M / 2;
    // ans += (N - ans) / 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[0]=='R' && s[1]=='R' && s[2]=='R'){
    cout<<3<<endl;
  }
  if(s[0]=='R' && s[1]=='R' && s[2]=='S'){
    cout<<2<<endl;
  }
  if(s[0]=='S' && s[1]=='R' && s[2]=='R'){
    cout<<2<<endl;
  }
  if(s[0]=='R' && s[1]=='S' && s[2]=='S'){
    cout<<1<<endl;
  }
  if(s[0]=='S' && s[1]=='R' && s[2]=='S'){
    cout<<1<<endl;
  }
  if(s[0]=='S' && s[1]=='S' && s[2]=='R'){
    cout<<1<<endl;
  }
  if(s[0]=='S' && s[1]=='S' && s[2]=='S'){
    cout<<0<<endl;
  }
  if(s[0]=='R' && s[1]=='S' && s[2]=='R'){
    cout<<1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c;std::cin >> a >> b >> c;
  std::cout << (a==b?c:b==c?a:b) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define test(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
const int M=1e9+7;
ll mod(ll x){
      return ((x%M + M)%M);
}
ll add(ll a, ll b){
      return mod(mod(a)+mod(b));
}
ll mul(ll a, ll b){
      return mod(mod(a)*mod(b));
}
const int MAX = 1e5+5;
int main(){
	fast();
//	test(t){
//		
//	}
	vector<int> v(5);
	for(int &x:v){
		cin>>x;
	}
	for(int i=0;i<5;i++){
		if(v[i]==0){
			cout<<i+1<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3540
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class Counter
{
	readonly Dictionary<int, int> c = new Dictionary<int, int>();
	public int this[int x] { get { return c.ContainsKey(x) ? c[x] : 0; } }
	public void Add(int x)
	{
		if (c.ContainsKey(x)) c[x]++;
		else c[x] = 1;
	}
}
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var c = new Counter();
		var N = F();
		var a = G();
		foreach (var x in a) c.Add(x);
		var m = 1;
		var k = a.Max() + 1;
		for (var x = a.Min() - 1; x <= k; x++) m = Max(m, c[x - 1] + c[x] + c[x + 1]);
		WriteLine(m);
	}
}


Measured memory_bytes: 20960
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

bool ok(string s){
    int x[9] = {1, 2, 3, 1, 2, 3, 1, 2, 3};
    int y[9] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
    REP(i, s.size() - 1){
        int x1 = x[ s[i] - 'A' ];
        int y1 = y[ s[i] - 'A' ];
        int x2 = x[ s[i + 1] - 'A' ];
        int y2 = y[ s[i + 1] - 'A' ];
        if(abs(x1 - x2) + abs(y1 - y2) != 1) return false;
    }
    return true;
}

int main(){
    string s;
    vector<string> ans;
    while(cin >> s){
        if(ok(s)) ans.push_back(s);
    }
    REP(i, ans.size()){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1252
import itertools
N = int(input())
lst = []
for i in range(N):
    x, y = map(int, input().split())
    lst.append([x, y])
dist = list(itertools.permutations(lst))
ans = []
for i in range(len(dist)):
    a = 0
    for j in range(N-1):
        a += ((dist[i][j][0]-dist[i][j+1][0])**2+(dist[i][j][1]-dist[i][j+1][1])**2)**0.5
    ans.append(a)
print(sum(ans)/len(ans))

Measured memory_bytes: 9332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char a,b;
  cin>>a>>b;
  if(a=='H'){
    if(b=='H') cout<<"H"<<endl;
    else cout<<"D"<<endl;
  }else{
    if(b=='D') cout<<"H"<<endl;
    else cout<<"D"<<endl;
  }
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int n, d; cin >> n >> d;
    cout << (n + 2*d)/(2*d + 1);
    return 0;
}


Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
	public static void main (String[] args){
	Scanner scan = new Scanner(System.in);

	String kisupas = scan.nextLine();
	String gusupas = scan.nextLine();
	
	String[] kisu = kisupas.split("", 0);
	String[] gusu = gusupas.split("", 0);

	for(int i=0; i<kisu.length; i++){
	System.out.print(kisu[i]);
	if(i != gusu.length)
	System.out.print(gusu[i]);	
	}
	}
    
}

Measured memory_bytes: 21716
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


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

	if (n >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
long long dat[100010];
long long vec[100010][2];
int main()
{
  int num,query,i,j,z,zb;
  long long t,tt,za;
  i=0;
  scanf("%d%lld%d",&num,&t,&query);
  vec[0][0]=-3000000000000000000LL;
  vec[0][1]=1;
  for(;i<num;i++){
    scanf("%lld%d",&za,&zb);
    vec[i+1][0]=za;
    vec[i+1][1]=zb;
  }
  vec[num+1][0]=3000000000000000000LL;
  vec[num+1][1]=2;
  i=0;
  for(;i<=num;i++){
    if(vec[i][1]==1&&vec[i+1][1]==2){
      tt=(vec[i][0]+vec[i+1][0])/2;
      j=i;
      for(;j>=0;j--){
	if(vec[j][1]==1)dat[j]=tt;
	else break;
      }
      j=i+1;
      for(;j<num+2;j++){
	if(vec[j][1]==2)dat[j]=tt;
	else break;
      }
    }
  }
  i=0;
  for(;i<query;i++){
      scanf("%d",&z);
      if(vec[z][1]==1){
	printf("%lld\n",(vec[z][0]+t<dat[z])?(vec[z][0]+t):(dat[z]));
      }else{
	printf("%lld\n",(vec[z][0]-t<dat[z])?(dat[z]):(vec[z][0]-t));
      }
  }
  return 0;
}

Measured memory_bytes: 5052
#include <iostream>
#include <vector>
#include <string.h>

# define REP(i,n) for(int i=0; i<n;i++)

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	char parentheses[n];
	int p;
	
	const char *LEFT = "(";
	
	int sum = 0;
	int pos = 0;
	int neg = 0;
	
	REP(i,n){
		cin >> parentheses[i];
		if (strncmp(&parentheses[i], LEFT, 1)==0){
			p = 1;
		}else{
			p = -1;
		}
		sum += p;
		
		if (sum<0){
		pos += 1;
		sum += 1;
		}
//			cout << i << " " << parentheses[i] << " " << p << " " << sum << "\n";
		
	}
	
	neg = sum;
	
	REP(i,pos)	cout << "(";
	REP(i,n)	cout << parentheses[i];
	REP(i,neg)	cout << ")";
	
	cout /*<< pos << " " << neg */<< "\n";

	return 0;	
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end(),greater<ll>());
  ll res=0;
  rep(i,n){
    res+=a[(i/2)];
  }
  res-=a[0];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4836
mod=1000000007
def modinverse(a,m)
  b=m
  u=1
  v=0
  while b>0
    t=a/b
    a-=t*b
    u-=t*v
    a,b=b,a
    u,v=v,u
  end
  u%=m
  if u<0
    u+=m
  end
  return u
end
x,y=gets.split.map(&:to_i)
s=x+y
b=s/3
if s%3!=0||x<b||y<b
  puts 0
  exit
end
x-=b
y-=b
a=1
y.times do |i|
  a*=x+i+1
  a%=mod
  a*=modinverse(i+1,mod)
  a%=mod
end
puts a

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);

    for(int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());

    int ans = d[n/2] - d[n/2-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import java.util.stream.IntStream;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int N = Integer.parseInt(sc.next());
        int[] a = IntStream.range(0, N+1).map(i -> Integer.parseInt(sc.next())).toArray();
        int[] b = IntStream.range(0, N).map(i -> Integer.parseInt(sc.next())).toArray();
        long ans = 0;

        for (int i = 0; i < N; i++) {
            if (a[i] >= b[i]) {
                ans += b[i];
            } else if (a[i] < b[i] && a[i+1] >= b[i] - a[i]) {
                ans += b[i];
                a[i+1] -= (b[i] - a[i]);
            } else if (a[i] < b[i] && a[i+1] < b[i] - a[i]) {
                ans += (a[i] + a[i+1]);
                a[i+1] = 0;
            }
        }
        
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 61572
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int64 N, K; cin >> N >> K;
	int64 x = N / K;
	if (K % 2 == 0) {
		int64 y = (N / (K / 2)) - x;
		cout << x * x * x + y * y * y << endl;
	} else {
		cout <<  x * x * x << endl;
	}
	return;
}
int main() {
	solve();
	return 0;
}

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

int main(){
  string S, T;
  cin >> S >> T;

  int max = 0;
  rep(i, S.size()-T.size()+1 ){
    int tmp = 0;
    rep(j, T.size() ){
      if(S[i+j] == T[j])
	tmp++;
    }
    if(max < tmp)
      max = tmp;
  }

  cout << T.size()-max << endl;

  return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int h,w,j,i;
	while(1)
	{
	
	cin>>h>>w;
	if(h==0&&w==0)
	break;
	for(i=0;i<h;i++)	
	{
		for(j=0;j<w;j++)
		{
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}	
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define MAX 1000000007
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;

ll power(ll x, ll y)
{
    ll res = 1;
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1) {
            res = ((res) * (x));
        }
        y = y>>1;  // y = y/2
        x = ((x)*(x));
    }
    return res;
}

int main(){

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

    // int t;
    // cin>>t;

    // while(t--) {
        
        

    // }
    string s;
    cin>>s;
    ll sum=0;
    for(int i=0;i<s.length();i++){
        sum += (s[i]-'0');
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}

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


int main(void)
{
	long int i, j;
	long int n, k;
	long int sum;
	long int max;
	long int count;
	long int x[100];
	long int y[100];
	char s[100001];
	char work;
	
	scanf("%ld%ld%s", &n, &k, s);
	
	count = 0;
	work = s[0];
	for(i = 1; i < n; i++) {
		if(s[i] == work) {
			count++;
		}
		work = s[i];
	}
	
	if(count + 2 * k >= n) {
		sum = n - 1;
	} else {
		sum = count + 2 * k;
	}
	
	printf("%ld\n", sum);
	
	
	return 0;
}


Measured memory_bytes: 256
int preorder[40],inorder[40];
void recover(int fp,int lp,int fi,int li){
	int root=fi;
	for(;root<li;root++)if(preorder[fp]==inorder[root])break;
	if(fi<root)recover(fp+1,fp+(root-fi)+1,fi,root);
	if(root<li-1)recover(fp+(root-fi)+1,lp,root+1,li);
	printf(inorder[root]==preorder[0]?"%d\n":"%d ",inorder[root]);
}
main(){
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",preorder+i);
	for(i=0;i<n;i++)scanf("%d",inorder+i);
	recover(0,n,0,n);
	return 0;
}

Measured memory_bytes: 600
n, k = (int(x) for x in input().split())

mod = 1000000007

count = 0

for i in range(k, n+2):
    sum_i = i * (i-1) /2
    count_i = i*n - 2*sum_i + 1
    count+=count_i
    count%=mod
print(int(count))

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

#define    ll     long long int

map<int, int> mp;
string str = "MARCH";

int main( )
{
    int i, j, k, n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        mp[s[0] - 'A']++;
    }
    ll s = 0;
    for (i = 0; i < 5; i++) {
        for (j = i + 1; j < 5; j++) {
            for (k = j + 1; k < 5; k++) {
                int x, y, z;
                x = str[i] - 'A';
                y = str[j] - 'A';
                z = str[k] - 'A';
                s += ( (ll) mp[x] * mp[y] * mp[z]);
            }
        }
    }
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, long long C, long long K, vector<long long> T){
	ll res = 0;
	SORT(T);
	rep(i, N) {
		// cout << i << endl;
		for (ll j = i; j < N; j++) {
			// cout << i << " " << j << " " << T[i]+K << " " << T[j] << endl;
			if (!(j-i < C && T[j] <= T[i]+K)) {
				i = j-1;
				break;
			}
			if (j == N-1) i = j;
		}
		res++;
	}
	cout << res << endl;
}

int main(){	
	long long C;
	long long K;
	long long N;
	scanf("%lld",&N);
	vector<long long> T(N-1+1);
	scanf("%lld",&C);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&T[i]);
	}
	solve(N, C, K, T);
	return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
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;}

struct UnionFind {
private:
    vector<int> par,ran;
    vector<int> edge,size;
    int n;
public:
    UnionFind(int x){
      n=x;
      par.resize(n,0);
      ran.resize(n,0);
      edge.resize(n,0);
      size.resize(n,1);
      rep(i,n){
        par[i]=i;
      }
    }
    int find(int x) {
        if (par[x]==x)return x;
        else return par[x]=find(par[x]);
    }
    void unite(int x, int y) {
        x=find(x),y=find(y);
        if (x==y){
            edge[x]++;
            return;
        }
        if (ran[x]<ran[y]) {
            par[x]=y;
            size[y]+=size[x];
            edge[y]+=edge[x]+1;
        }
        else {
            par[y]=x;
            size[x]+=size[y];
            edge[x]+=edge[y]+1;
            if (ran[x]==ran[y])ran[x]++;
        }
    }
    bool same(int x,int y) {
        return find(x)==find(y);
    }
    int getSize(int x){
        return size[find(x)];
    }
    int getEdge(int x){
        return edge[find(x)];
    }
};

int n;
int x[200010],y[200010];

void solve(){
    cin >> n;
    UnionFind uf(n);
    vector<int> v(n);
    rep(i,n){
        v[i]=i;
        cin >> x[i] >> y[i];x[i]--;y[i]--;
    }
    sort(v.begin(),v.end(),[](int a,int b){return x[a]<x[b];});
    set<P> se;se.insert(P(mod,0));
    rep(i,n){
        auto it=se.begin();
        if((*it).first<y[v[i]]){
            uf.unite((*it).second,v[i]);it++;
            while((*it).first<y[v[i]]){
                uf.unite((*it).second,v[i]);
                it=se.erase(it);
                if(it==se.end()) break;
            }
        }
        else{
            se.insert(P(y[v[i]],v[i]));
        }
    }
    vector<int> ans(n);
    rep(i,n){
        cout << uf.getSize(i) << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int n, k;
  cin >> n >> k;
  vector<int> a(n+1);
  for(int i=1;i<=n;++i)
    cin >> a[i];
  
  vector<int> dp(n+1, 2e9);
  dp[1] = 0;
  
  for(int i=2;i<=n;++i)
    for(int j=max(1, i-k);j<i;++j)
      dp[i] = min(dp[i], abs(a[i] - a[j]) + dp[j]);
  
  cout << dp[n] << endl;
  
  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			String[] input;
			int a, b, ret = 0;
			String op;
			do {
				input = br.readLine().split(" ");
				a = Integer.parseInt(input[0]);
				op = input[1];
				b = Integer.parseInt(input[2]);
				if (op.equals("?")) {
					break;
				} else {
					if (op.equals("+")) {
						ret = a + b;
					} else if (op.equals("-")) {
						ret = a - b;
					} else if (op.equals("*")) {
						ret = a * b;
					} else if (op.equals("/")) {
						ret = a / b;
					}
					System.out.println(ret);
				}
			} while (true);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

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

  x = N;

  int fx = 0;
  while (N != 0) {
    fx += N % 10;
    N /= 10;
  }

  if (x % fx == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<set>
#include<tuple>

using namespace std;

vector<tuple<int,int,int> > edges;

struct UnionFind{
  vector<int> par;
  UnionFind(int n):par(n){
    iota(begin(par),end(par),0);
  }
  int find(int x){
    return (x==par[x])?x:par[x]=find(par[x]);
  }
  void unite(int a,int b){
    par[find(a)]=find(b);
  }
};

int kr(UnionFind uf,int x){
  int c=0;
  for(int i=x;i<edges.size();i++){
    int s=get<1>(edges[i]),d=get<2>(edges[i]);
    if(uf.find(s)!=uf.find(d)){
      c+=get<0>(edges[i]);
      uf.unite(s,d);
    }
  }
  set<int> s;
  for(int i=0;i<uf.par.size();i++){
    s.insert(uf.find(i));
  }
  return (s.size()==1)?c:1e9;
}

int main(){
  int N,M;
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int S,D,C;
    cin>>S>>D>>C;
    edges.emplace_back(C,S-1,D-1);
  }
  sort(begin(edges),end(edges));
  UnionFind uf(N);
  int tc=kr(uf,0);
  int cc=0;
  int ans=0;
  int nac=0;
  for(int i=0;i<edges.size();i++){
    int s=get<1>(edges[i]),d=get<2>(edges[i]);
    if(uf.find(s)!=uf.find(d)){
      if(tc!=cc+kr(uf,i+1)){
	ans++;
	nac+=get<0>(edges[i]);
      }
      uf.unite(s,d);
      cc+=get<0>(edges[i]);
    }
  }
  cout<<ans<<' '<<nac<<endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    for (int i = 1; i <= 5; i++) {
        int x; cin >> x;
        if (x == 0) {
            cout << i;
            break;
        }
    }
}


Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
a = [int(item) for item in input().split()]

ok = True
for item in a:
    if item % 2 == 0:
        if item % 3 != 0 and item % 5 != 0:
            ok = False
if ok:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
def collatz(num: int) -> int:
    if num%2 == 0:
        return int(num/2)
    return 3*num+1

s = [int(input())]

cnt = 1
while True:
    s.append(collatz(s[-1]))
    cnt += 1
    if s[:-1].count(s[-1]):
        break

print(cnt)


Measured memory_bytes: 2940
/*
	0105:book Index
*/
#include	<iostream>
#include	<vector>
#include	<utility>
#include	<string>
#include	<algorithm>

using namespace std;

typedef pair<string, int> P_SI;

int main(void) {
	string memstr = " ";
	vector<P_SI> words;
	
	while(1) {
		string buf_s;
		int buf_i;
		
		cin >> buf_s >> buf_i;
		if(cin.eof()) { break; }
		words.push_back( P_SI(buf_s, buf_i) );
	}
	sort( words.begin(), words.end() );
	
	vector<P_SI>::iterator it = words.begin();
	bool isFirst = true;
	while( it != words.end() ) {
		string buf_s = (*it).first;
		int buf_i = (*it).second;
		
		if(buf_s != memstr) {
			if(it != words.begin()) {
				cout << endl;
			}
			cout << buf_s << endl;
			memstr = buf_s;
			isFirst = true;
		}
		if(isFirst) {
			cout << buf_i;
			isFirst = false;
		} else {
			cout << ' ' << buf_i;
		}
		it++;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1232
dp=[[0]*3 for _ in range(10**5+1)]
n=int(input())
abc=[[int(i) for i in input().split()] for _ in range(n)]

for i in range(n):
    dp[i + 1][0] = abc[i][0] + max(dp[i][1], dp[i][2])
    dp[i + 1][1] = abc[i][1] + max(dp[i][0], dp[i][2])
    dp[i + 1][2] = abc[i][2] + max(dp[i][0], dp[i][1])
print(max(dp[n]))

Measured memory_bytes: 44128
#include<stdio.h>
int main(void){
    int h1,h2,k1,k2,a,b,c,d,H,K;
    scanf("%d %d",&h1,&h2);
    scanf("%d %d",&k1,&k2);
    scanf("%d %d %d %d",&a,&b,&c,&d);
    H=h1*a+(h1/10)*c+h2*b+(h2/20)*d;
    K=k1*a+(k1/10)*c+k2*b+(k2/20)*d;
    if(H>K){
        printf("hiroshi\n");
    }else if(H<K){
        printf("kenjiro\n");
    }else{
        printf("even\n");
    }
    return 0;
}


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

using namespace std;

void solve() {
    int n;
    cin >> n;

    if (n >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using std::max;
 
const int N=15,Inf=1e9+10;
 
int n,m,map[N][N],f[N][1<<N],M[N][1<<N],sum[1<<N];
 
void Init() {
	scanf("%d%d",&n,&m);
	int a,b,c;
	for (int i=1;i<=m;++i) {
		scanf("%d%d%d",&a,&b,&c);
		a--; b--; 
		map[a][b]=map[b][a]=c;
	}
}
 
int summ;
bool vis[N];
void Dfs(int x,int s) {
	if (vis[x]) return ;
	vis[x]=1;
	for (int i=0;i<n;++i) if ((1<<i)&s && map[x][i]) {
		summ+=map[x][i];
		Dfs(i,s);
	}
}
 
void Solve() {
	int Max=1<<n;
	for (int s=0;s<Max;++s) {
		summ=0;
		for (int i=0;i<n;++i) vis[i]=0;
		for (int i=0;i<n;++i) if ((1<<i)&s) Dfs(i,s);
		sum[s]=summ>>1;
	}
	
	summ=0;
	for (int i=0;i<n;++i)
		for (int j=i;j<n;++j) summ+=map[i][j];
	for (int i=0;i<n;++i)
		for (int s=0;s<Max;++s) f[i][s]=-Inf,M[i][s]=-Inf;
	M[0][1]=0;
	for (int s=0;s<Max;++s) if (s&1) {
		f[0][s]=sum[s];
		for (int t=0;t<n;++t) 
			if (map[t][0]) M[t][s]=max(M[t][s],f[0][s]+map[t][0]);
	}
	for (int s=0;s<Max;++s) {
		for (int i=0;i<n;++i) if ((1<<i)&s) {
			for (int p=s;p;p=(p-1)&s) if (!((1<<i)&p)) {
				f[i][s]=max(f[i][s],M[i][p]+sum[s^p]);
			}
			for (int t=0;t<n;++t) if (map[t][i]) M[t][s]=max(M[t][s],f[i][s]+map[t][i]);
		}
	}
	
	printf("%d\n",summ-f[n-1][Max-1]);
}
 
int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
  int n, a;
  cin >> n >> a;
  if ((n % 500) > a) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long DP[5001*5001];
int P[5000];
void Calc(){
	int N = rei();
	long A = rei();
	long B = rei();
	for(int i=0;i<N;i++){
		int p = rei()-1;
		P[p] = i+1;
	}
	fill(DP,DP+5001*5001,1000000000000000000);
	DP[0] = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=N;j++){
			if(P[i] < j){
				DP[(i+1)*5001+j] = min(DP[(i+1)*5001+j],DP[i*5001+j]+A);
			}
			else if(P[i] > j){
				DP[(i+1)*5001+j] = min(DP[(i+1)*5001+j],DP[i*5001+j]+B);
				DP[(i+1)*5001+P[i]] = min(DP[(i+1)*5001+P[i]],DP[i*5001+j]);
			}
			else{
				DP[(i+1)*5001+j] = min(DP[(i+1)*5001+j],DP[i*5001+j]);
			}
		}
	}
	long ans = 1000000000000000000;
	for(int i=0;i<=N;i++){
		ans = min(ans,DP[N*5001+i]);
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

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

int gcd_multi(vec a){
    int g = a[0];
    FOR(i, 1, a.size()) g = gcd(g, a[i]);
    return g;
}

signed main(){

    int N, X; cin >> N >> X;
    vec x(N); cin >> x;
    REP(i, N) x[i] = llabs(x[i] - X);
    Out(gcd_multi(x));

    return 0;
}


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

vector<vector<int>> edges;
int ct[100000 + 5];
vector<int> rpath;
bool dfs(const int p, const int end, const int mk, vector<int> &path) {
  if ((ct[p] & mk) == mk) return false;
  path.push_back(p);
  ct[p] |= mk;
  if (p == end) {
    rpath = path;
    return true;
  }

  for (auto nxt : edges[p]) {
    if (dfs(nxt, end, mk, path)) return true;
  }

  path.pop_back();
  return false;
}

void dfs(const int p, const int mk) {
  if (ct[p]) return;
  ct[p] = mk;
  for (auto nxt : edges[p]) dfs(nxt, mk);
}
int main() {
  cin >> N;
  edges = vector<vector<int>>(N);
  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }

  vector<int> path;
  dfs(0, N - 1, 1, path);

  const int e1 = (rpath.size() + 1) / 2;
  for (int i = 0; i < rpath.size(); ++i) {
    ct[rpath[i]] = 0;
  }
  const int t1 = rpath[e1 - 1];
  const int t2 = rpath[e1];
  ct[t2] = 2;
  dfs(t1, 1);
  ct[t2] = 0;
  dfs(t2, 2);
  int ct1 = 0;
  int ct2 = 0;
  int cct = 0;
  for (int i = 0; i < N; ++i) {
    if (ct[i] == 1)
      ct1++;
    else if (ct[i] == 2)
      ct2++;
  }
  assert(ct1 + ct2 + cct == N);

  if (ct1 > ct2)
    cout << "Fennec";
  else
    cout << "Snuke";
  cout << endl;
}

Measured memory_bytes: 13304
#include<stdio.h>
#include<math.h>



int main(){
    int n,m;
    int sum, t=0;
    scanf("%d %d", &n, &m);

    sum = 100*(n-m) + 1900*m;

    t = sum * pow(2,m);

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


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

bool pali(string s){
  for (int i = 0; i < s.length()/2; i++) {
    if(s[i] != s[s.length() - 1 - i])return false;
  }
  return true;
}
  

int main(){
  string s, t;
  std::cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if(s[i] != 'x')t.push_back(s[i]);
  }
  if(not pali(t)){
    std::cout << -1 << std::endl;
    return 0;
  }
  int tp = 0, ans = 0, x = 1;
  int tc = (t.length() + 1)/2;
  for (int i = 0; i < s.length(); i++) {
    if(s[i] == t[tp])tp++;
    if(tp == tc){
      while(t.length()%2 == 0 and s[i + x] == 'x')x++;
      string a, b;
      if(t.length()%2){
        a = s.substr(0, i + 1);
        b = s.substr(i);
      }else{
        a = s.substr(0, i + x + 1);
        b = s.substr(i);
      }
      reverse(a.begin(), a.end());
      // std::cout << a << std::endl;
      // std::cout << b << std::endl;
      int ap = 0, bp = 0;
      while(ap < a.length() and bp < b.length()){
        if(a[ap] == b[bp]){
          ap++, bp++;
          continue;
        }
        if(a[ap] == 'x')ap++, ans++;
        else bp++, ans++;
      }
      ans += (a.length() - ap) + (b.length() - bp);
      if(t.length()%2 and x > 1)ans++;
      break;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    X, Y = map(int, input().split())
    for x in range(X + 1):
        if Y == x * 2 + (X - x) * 4:
            print("Yes")
            exit()
    print("No")


if __name__ == "__main__":
    main()


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

int main(){
    int N;
    cin >> N;
    int B[N-1];
    for (int j=0; j<N-1; j++){
        cin >> B[j];
    }

    int ans = B[0];
    for (int i=1; i<N; i++){
        if (i==N-1) ans += B[N-2];
        else ans += min(B[i-1], B[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int maxn=1000005;
int n,ans;
int cnt[1000*1000+5];
int main()
{
    cin >> n;
    int a[n+1];
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)
	{
       if(cnt[a[i]])
	   {
        	cnt[a[i]]=2;
        	continue;
       }
       int val=a[i];
       for(int j=val;j<maxn;j+=val)cnt[j]++;
   }
    for(int i=1;i<=n;i++)if(cnt[a[i]]<=1)ans++; 
    cout<<ans;
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;

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

// Problem Specific Parameter:

#define fst first
#define snd second

ll dp[2510][2510][2];
ll L[5010], R[5010];

const ll inf = 1LL << 60;

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

	{
		using pll = pair<ll, ll>;
		vector<pll> ary;

		rep(i, n) {
			cin >> L[i] >> R[i];
			ary.push_back(pll(L[i] + R[i], L[i]));
		}

		sort(begin(ary), end(ary));

		rep(i, n) {
			L[i] = ary[i].snd;
			R[i] = ary[i].fst - L[i];
		}
	}

	rep(i, n / 2 + 1)rep(j, n / 2 + 1)rep(k, 2) dp[i][j][k] = inf;
	dp[0][0][0] = 0LL;

	const ll m = n % 2;

	// cost = \sum  L_i  + \sum R_i

	rep(i, n) {
		rep(l, i + 1) {
			rep(k, m + 1) {
				const int r = i - l - k;
				if (l < 0 or l > n / 2) continue;
				if (r < 0 or r > n / 2) continue;

				// dp[l][r][k]

				// left
				if (l + 1 <= n / 2) {
					const ll add = 1LL * (n / 2 - 1 - l) * (L[i] + R[i]) + R[i];
					chmin(dp[l + 1][r][k], dp[l][r][k] + add);
				}
				// right
				if (r + 1 <= n / 2) {
					const ll add = 1LL * (n / 2 - 1 - r) * (L[i] + R[i]) + L[i];
					chmin(dp[l][r + 1][k], dp[l][r][k] + add);
				}
				// odd
				if (k + 1 <= m) {
					const ll add = (n / 2) * (L[i] + R[i]);
					chmin(dp[l][r][k + 1], dp[l][r][k] + add);
				}
			}
		}
	}

	cout << dp[n / 2][n / 2][m] << endl;

	return 0;
}

Measured memory_bytes: 98608
N = int(input())
prefs = []
for i in range(N):
    a, b = map(int, input().split())
    prefs.append((a + b, a, b))
prefs.sort(reverse=True)
ans = 0
for i, (p, a, b) in enumerate(prefs):
    if i % 2:
        ans -= b
    else:
        ans += a
print(ans)


Measured memory_bytes: 20988
n,k=list(map(int, input().split()))
x=list(map(int, input().split()))
t=0
tmin=2*(x[n-1]-x[0])
for i in range (0,n-k+1):
    if x[i]>=0:
        t=x[i+k-1]
    else:
        if x[i+k-1]<=0:
            t=abs(x[i])
        else:
            if -1*x[i]<x[i+k-1]:
                t=-2*x[i]+x[i+k-1]
            else:
                t=-1*x[i]+2*x[i+k-1]
    if t<tmin:
        tmin=t
print(tmin)

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

int main () {
  int N;
  cin >> N;
  bool a = false;
  
  for(int i = 0; i < N; i++) {
    string str;
    cin >> str;
    if (str == "Y") {
      a = true;
      break;
    }
  }
  
  if(a) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
s = input()
n = int(input())
for _ in range(n):
    op = list(input().split())
    if op[0]=='replace':
        s = s[:int(op[1])]+op[3]+s[int(op[2])+1:]
    elif op[0]=='reverse':
        s = s[:int(op[1])]+''.join(list(reversed(s[int(op[1]):int(op[2])+1])))+s[int(op[2])+1:]
    else : print(s[int(op[1]):int(op[2])+1])



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s;int q;cin>>s>>q;
    int t,f;
    int rcnt=0;
    string c;
    rep(i,q){
        cin>>t;
        if(t==1){rcnt++;}
        else{
            cin>>f>>c;
            if(f==1){if(rcnt%2==0)s.insert(0,c);else s.push_back(*c.c_str());}
            else{if(rcnt%2==0)s.push_back(*c.c_str());else s.insert(0,c);}
        }
    }
    if(rcnt%2==1)reverse(s.begin(), s.end());
    co(s);
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;
ll gcd(ll a, ll b){
    if (a % b == 0)
    {  return(b);}
    else{return(gcd(b, a % b));}
}
ll lcm(ll a, ll b)
{return a * b / gcd(a, b);}

int main(){
  ll a,b,x;
  cin>>a>>b>>x;
  ll p,q;
  p=(a-1ll)/x;
  if(a==0&&x!=1){p--;}
  q=b/x;
  cout<<q-p;
}

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

using namespace std;

int main() {
  string N;
  cin >> N;
  
  int n = 0;
  for (size_t i = 0, size = N.size(); i < size; ++i) {
    n += N[i] - '0';
    n %= 9;
  }
  cout << (n == 0 ? "Yes" : "No") << endl;
 
  return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
#include<math.h>
#define N 100005
#define K 200005
#define MOD (long long )1e18L +5
#define ll long long int
using namespace std;
  ll a[405];
void add_self(int &a,int b)
{
    a+=b;
    if(a>=MOD)
    {
        a-=MOD;
    }
}
void sub_self(int &a,int b)
{
    a-=b;
    if(a<0)
    {
        a+=MOD;
    }
}
ll sum(ll l,ll r)
{
    ll sum1=0;
    for(ll i=l;i<=r;i++)
    {
        sum1+=a[i];
    }   
    return sum1;
}
ll min(ll a,ll b)
{
    return a<=b?a:b;
}
int main() {
    int n;
    cin>>n;
  
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll dp[n][n];
    // total cost of combining interval {i,j} into one vertex
    //think of it as a binary tree0
    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            if(l==r)
            {
                dp[l][r]=0;
            }
            else{
            dp[l][r]=MOD;
            ll s=sum(l,r);
            for(int i=l;i<=r-1;i++)
            {
                dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+s);// we are calculating the value of the interval {l,r}
            }
            }
        }
            
    }
    cout<<dp[0][n-1]<<endl;

}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String topping = sc.next();
        System.out.println(700 + Arrays.stream(topping.split("")).filter(t -> t.equals("o")).count()*100);
    }
}


Measured memory_bytes: 26964