akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int roc = 0;
string s;
int insu();
int kou();
int shiki();

int insu() {
	if(s[roc] >= '0' && s[roc] <= '9') {
		int j = roc;
		while(roc < s.size() && s[roc] >= '0' && s[roc] <= '9') ++roc;
		return stoi(s.substr(j, roc - j));
	} else {
		++roc;
		int res = shiki();
		++roc;
		return res;
	}
}

int kou() {
	int res = insu();
	while (s[roc] == '*' || s[roc] == '/') {
		if(s[roc] == '*') {
			++roc;
			res *= insu();
		}
		else {
			++roc;
			res /= insu();
		}
	}
	return res;
}

int shiki() {
	int res = kou();
	while (s[roc] == '+' || s[roc] == '-') {
		if(s[roc] == '+') {
			++roc;
			res += kou();
		}
		else {
			++roc;
			res -= kou();
		}
	}
	return res;
}

int main(void) {
	int n;
	cin>>n;
	REP(roop, n) {
		roc = 0;
		cin>>s;
		s.pop_back();
		cout<<shiki()<<endl;
	}
}

Measured memory_bytes: 3140
import sys
input = sys.stdin.readline

A, B = map(int, input().split())

a = set(range(int(A / 0.08), int((A + 1) / 0.08)))
b = set(range(int(B / 0.1), int((B + 1) / 0.1)))
if abs(A / 0.08 - int(A / 0.08)):
    a.remove(int(A / 0.08))
print(min(a & b)) if a & b else print(-1)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int c1,c2,c3;
  int ok,ng;
  while(cin>>c1>>c2>>c3){
    ok=0;
    ng=0;
    for(int i=1;i<=10;i++){
      if(i!=c1 && i!=c2 && i!=c3){
	if(c1+c2+i<=20){
	  ok++;
	}else{
	  ng++;
	}
      }
    }
    if(ok>=ng) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,a,b;
    cin >> n >> a >> b;
    ll cnt = n/(a+b);
    ll ans = cnt*a;
    ll rem = n%(a+b);
    if(rem>a) ans += a;
    else ans+=rem;
    cout << ans;
    cout << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a+w<b) cout<<b-a-w<<"\n";
    else if(b+w<a) cout<<a-b-w<<"\n";
    else cout<<0<<endl;
}

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

int main() {
    
    int t;
    t=1;
    //cin >> t;
    while(t--){
        string s,t;
        cin >> s >> t;
        
        int lens = s.size();
        int lent = t.size();
        
        int dp[lens+1][lent+1];
        memset(dp,0,sizeof(dp));
        
        for(int i=1;i<=s.size();i++){
            for(int j=1;j<=t.size();j++){
                if(s[i-1]==t[j-1]){
                    dp[i][j] = dp[i-1][j-1]+1;
                }else{
                    dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        
        int row = lens;
        int col = lent;
        string ans = "";
        while(row>0&&col>0){
            if(dp[row][col]==0){
                break;
            }
            if(s[row-1]==t[col-1]){
                ans = s[row-1]+ans;
                row--;
                col--;
            }else{
                if(dp[row-1][col]>=dp[row][col-1]){
                    row--;
                }else{
                    col--;
                }
            }
        }

        cout << ans << endl;


    }
    return 0;

}

Measured memory_bytes: 35456
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}

int main() {
  lli n;
  cin >> n;
  vector<lli> v(n+1);
  iota(begin(v), end(v), 0);
  vector<lli> c;
  for (int i=2; i<=n; ++i) {
    if (v[i] != 1) {
      lli cnt = 0;
      for (int j=i; j<=n; ++j) {
	while (v[j] % i == 0) {
	  v[j] /= i;
	  cnt++;
	}
      }
      c.push_back(cnt);
    }
  }
  lli c2=0, c4=0, c14=0, c24=0, c74=0;
  for (lli x : c) {
    if (x >= 2) ++c2;
    if (x >= 4) ++c4;
    if (x >= 14) ++c14;
    if (x >= 24) ++c24;
    if (x >= 74) ++c74;
  }
  lli ans = (c2 - 2) * c4 * (c4 - 1) / 2
	  + c14 * (c4 - 1)
	  + c24 * (c2 - 1)
	  + c74;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
A=[0]*n
a=round(n**0.5)+1
for x in range(1,a):
  for y in range(1,a):
    for z in range(1,a):
      b=x*x+y*y+z*z+x*y+y*z+z*x
      if b-1<n:
        A[b-1]+=1
for i in range(n):
  print(A[i])

Measured memory_bytes: 9456
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=510;
int n,m,s,ans;
int a[maxn],b[maxn];
bool ck(int k) {
	int t=0;
	for (int i=1;i<=n;i++) t+=a[i]%k,b[i]=a[i]%k;
	sort(b+1,b+n+1);
	int t2=0;
	for (int i=1;i<=n-t/k;i++) t2+=b[i];
	return t2<=m;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	for (int i=1;i<=n;i++)
		read(a[i]),s+=a[i];
	for (int i=1;i*i<=s;i++) {
		if (s%i!=0) continue;
		if (ck(i)) ans=max(ans,i);
		if (ck(s/i)) ans=max(ans,s/i);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
class Array
  include Comparable
  def cumsum(s = 0); map{|k| s += k } end
  def diff; s = self[0]; self[1...(self.size)].map{|k|d=k-s; s=k; d} end
end
include Math
mod = 10 ** 9 + 7
def max(a,b); a > b ? a : b end
def min(a,b); a < b ? a : b end
def swap(a,b); a, b = b, a  end
def yn(f); puts f ? "Yes" : "No" end
def yes; puts "Yes"; exit end
def no; puts "No"; exit end
#(n, k), (s, k), a, f = $<.map{|l| l.to_s.split.map(&:to_i) }
# n = gets.to_s.to_i
a, b = gets.to_s.split
a = a.to_i
b100 = b.delete(".").to_i
#m = Array.new(n){ gets.to_s.split.map{|e|e.to_i} }
#s = gets.to_s.chomp
ans = (a * b100 / 100).floor

puts ans

Measured memory_bytes: 14372
import sys
N = int(input())
num_list = [int(i) for i in input().split()]
if 0 in num_list:
  print(0)
else:
  mul = 1
  for a in num_list:
    mul *= a
    if mul > 10**18:
      print(-1)
      sys.exit()
  print(mul)


Measured memory_bytes: 21568
num = input().split(' ')
point = input().split(' ')
point_int = [int(point[i]) for i in range(3)]
data = input()
count = 1
result = 0
judge = [0 for i in range(int(num[0]))]
for i in range(int(num[0])):
    if(data[i] == 'r'):
        if(i - int(num[1]) >= 0):
            if(data[i - int(num[1])] == 'r'):
                if(judge[i - int(num[1])] == 0):
                    result += point_int[2]
                    judge[i] = 1
                else:
                    pass

            else:
                result += point_int[2]
                judge[i] = 1
        else:
            result += point_int[2]
            judge[i] = 1
    elif(data[i] == 's'):
        if(i - int(num[1]) >= 0):
            if(data[i - int(num[1])] == 's'):
                if(judge[i - int(num[1])] == 0):
                    result += point_int[0]
                    judge[i] = 1
                else:
                    pass
            else:
                result += point_int[0]
                judge[i] = 1
        else:
            result += point_int[0]
            judge[i] = 1

    else:
        if(i - int(num[1]) >= 0):
            if(data[i - int(num[1])] == 'p'):
                if(judge[i - int(num[1])] == 0):
                    result += point_int[1]
                    judge[i] = 1
                else:
                    pass
            else:
                result += point_int[1]
                judge[i] = 1
        else:
            result += point_int[1]
            judge[i] = 1

print(result)


Measured memory_bytes: 4340
#include<cstdio>
#define k 0.01
using namespace std;
typedef long long ll; 
int main()
{
	ll m = 100LL;
	ll x;
	int ans = 0;
	scanf("%lld",&x);
	while(m < x)
	{
		m += m*k;
		ans++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1736
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
is_prime = [1] * (10**5 + 1)
is_prime[0] = 0
is_prime[1] = 0
for i in range(2,10**5+1):
    if is_prime[i]:
        for j in range(i*2,10**5+1,i):
            is_prime[j] = 0
for i in range(10**5,1,-1):
    if is_prime[i]:
        if is_prime[(i+1)//2]:
            pass
        else:
            is_prime[i] = 0
is_prime = list(accumulate(is_prime))
for q in range(I()):
    l,r = readInts()
    l -= 1
    print(is_prime[r] - is_prime[l])


Measured memory_bytes: 13764
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  101
map<string,vii> m;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
//    cin>>t;
    while(t--)
{
    ll n;
    cin>>n;
    pair<pair<string,ll>,ll> v[n];
    rep(i,0,n)
    cin>>v[i].F.F>>v[i].F.S;
    rep(i,0,n)v[i].S=i+1;
    sort(v,v+n);
    set<string> s;
    rep(i,0,n)
    {
    	m[v[i].F.F].pb({v[i].F.S,v[i].S});
    	s.insert(v[i].F.F);
    	sort(m[v[i].F.F].rbegin(),m[v[i].F.F].rend());
    }
    for(auto i:s)
    {
    	rep(j,0,sz(m[i]))
    	{
    		cout<<m[i][j].S<<endl;
    	}
    }
}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << x
#define print(x) cout << x << '\n'
#define debug(x) cerr << #x << ": " << x << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        s = "";
        while(n){
            s = (n % 2 ? '1' : '0') + s;
            if(n % 2) n--;
            n /= -2;
        }
        if(s.size() == 0) s = "0";
        print(s);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool jud(vector<int> a,int n){
    bool ans=false;
    for(int i=0;i<n;i++){
        if(a.at(i)%2==1){
            return ans;
        }
    }
    ans=true;
    return ans;
}
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        if(a.at(i)%2==1){
            cout<<0<<endl;
            return 0;
        }
    }
    int cnt=0;
    while(jud(a,n)){
        cnt++;
        for(int i=0;i<n;i++){
            a.at(i)/=2;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0;
    string A, B, C;
    cin >> N >> A >> B >> C;
    rep(i, N){
        cnt = 0;
        if(A[i] == B[i])
            cnt++;
        if(B[i] == C[i])
            cnt++;
        if(A[i] == C[i])
            cnt++;
        if(cnt == 1)
            ans++;
        if(cnt == 0)
            ans += 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int, input().split()))
isApproved = [False for _ in range(n)]

for i in range(len(a)):
    if a[i]%2 == 0:
        if (a[i]%3 == 0) or (a[i]%5 == 0):
            isApproved[i] = True
        else:
            isApproved[i] = False
    else:
        isApproved[i] = True

if all(isApproved):
    print("APPROVED")
else:
    print("DENIED")

               

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n[10000000];
int k[10000000];
int main(){
  int a,b=0;
  cin>>a;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==a){
	b=1;
	break;
      }
    }
  }
  if(b==1) cout<<"Yes\n";
  else cout<<"No\n";
  return(0);
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t a,b,c;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> a>>b>>c;
	if (a <= c&&c <= b) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}


	return 0;
}
#endif


#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N,M;
int32_t count[10000000];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N>>M;
	for (int32_t i = 0; i < M; ++i)
	{
		int a, b;
		in >> a >> b; --a; --b;
		count[a]++;
		count[b]++;

	}

	for (int32_t i = 0; i < N; ++i)
	{
		std::cout << count[i] << '\n';

	}

	return 0;
}
#endif


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> cs(n); cin >> cs;
    cs.resize(unique(cs.begin(), cs.end()) - cs.begin());
    printde(cs);
    vector<ll> accs(*max_element(cs.begin(), cs.end()) + 1);
    ll ans = 1;
    for(int i = (int)cs.size() - 1; i >= 0; i--){
        ll a = accs[cs[i]];
        accs[cs[i]] += ans;
        accs[cs[i]] %= M;
        ans = ans + a;
        ans %= M;
        printde(i, ans, cs[i], accs);
    }
    cout << ans << '\n';
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m; cin >> n >> m;
	vector<pll> v(n);
	REP(i, n)cin >> v[i].first >> v[i].second;
	sort(ALL(v));
	ll ans = 0;
	int i = 0;
	while (m > 0) {
		while (v[i].second == 0)i++;
		ll d = min(v[i].second, m);
		m -= d;
		v[i].second -= d;
		ans += d * v[i].first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

	

int main(void)
{
	//変数の宣言
	int n;
	char array[300010];
	int i,j,k;
	int count=0;
	int max=0;
	int num=0;
	int ans=0;
	
	//データの読み込み
	scanf("%d\n%s",&n,&array);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=1;i<n;i++){
		if(array[i]=='W'){
			count--;
		}else{
			count++;
		}
		
		if(count>max){
			max=count;
			num=i;
		}
	}
	
	for(i=0;i<num;i++){
		if(array[i]=='W'){
			ans++;
		}
	}
	for(i=num+1;i<n;i++){
		if(array[i]=='E'){
			ans++;
		}
	}
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int H, W;
    cin >> H >> W;
    vector< string > s(H);

    rep(i,H) cin >> s[i];

    rep(i,H) rep(j,W) {
        if (s[i][j] == '.') continue;
        if (i > 0 && s[i - 1][j] == '#') continue;
        if (i < H - 1 && s[i + 1][j] == '#') continue;
        if (j > 0 && s[i][j - 1] == '#') continue;
        if (j < W - 1 && s[i][j + 1] == '#') continue;
        cout << "No" << endl;
        return 0; 
    }

    cout << "Yes" << endl;
    
    return 0;
}

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

using namespace std;

int main() {
	int n;
	double sum = 0, a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		sum += float(1 / a);
	}

	double ans = 1 / sum;

	printf("%.10f", ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>

int n, d;
int v[111][111];

bool chk(int id1, int id2) {
	int s = 0;
	for(int i=0;i<d;i++) {
		int t = v[id1][i] - v[id2][i];
		s += t*t;
	}
	int x = int(sqrt(s) + 1e-6);
	return x*x==s;
}

int main() {
	scanf("%d%d", &n, &d);
	for(int i=0;i<n;i++)
		for(int j=0;j<d;j++) scanf("%d", &v[i][j]);
	
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(chk(i, j)) ans++;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
line1 = input().split()
n = int(line1[0])
k = int(line1[1])
a = [int(ai) for ai in input().split()]

route = [0]
use = {0}
for j in range(k):
  now = a[route[j]] - 1
  if now in use:
    break
  else:
    route.append(now)
    use.add(now)

l_start = route.index(now)
print(route[l_start + ((k - l_start) % (len(route) - l_start))] + 1)

Measured memory_bytes: 35272
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iterator>
using namespace std;

int main(){
    #ifdef INPUT
//        freopen("input","r",stdin);
//        freopen("output","w",stdout);
    #endif // INPUT
//    ios::sync_with_stdio(false);
//    cin.fill(NULL);

    string str;
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int ans = 0;
        cin >> str;
        for(int i=0; i<n; )
        {
            if(str[i]!=str[i+1])
            {
                ++ ans;
                ++i;
            }else{
                while(str[i]==str[i+1])
                    ++ i;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 512
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


n, k = inpl()
tmp = math.log(n) / math.log(k) + 1
print(int(tmp))


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

int main() {
	int n;
	cin >> n;
	map<string, int> mp;
	
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;

	return 0;
}

Measured memory_bytes: 3604
// 解説後
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

// 連結した文字列は十分に長いので、足りない場合は考えない。
// N<=10^5なので、O(NlogN)の方法でやりたい。
// tの文字に対応するsの文字を順番に見つけて、そのさいに通過したsの文字数を累計すれば良い。
// 文字数分だけループするとすれば、次の文字を見つける方法はO(logN)でなければならない。
//
// 1文字目も含めて見つけたいので、lower_bound()を使う。
// なので、次の文字を見つけるためには、resultは見つけた文字のインデックス+1となる。
// 表示する値は1スタートのインデックスなので、resultをそのまま出力できる。
int solve_E() {
  std::string s;  // もととなる文字列
  std::string t;  // 見つけたい文字列
  std::cin >> s >> t;

  // 文字の種類ごとにs内のインデックスの配列を作る
  std::vector<std::vector<size_t>> indices_by_char(26);  // aからzの26文字
  for (size_t i = 0; i < s.size(); ++i) {
    indices_by_char[s[i] - 'a'].push_back(i);
  }

  // sからtを作れるかを調べる
  int64_t result = 0;
  for (const auto t_i : t) {
    // t_iがsに含まれていなければ、sからtを作れない
    const auto& indices = indices_by_char[t_i - 'a'];
    if (indices.empty()) {
      std::cout << "-1";
      return 0;
    }

    // t_iと同じ文字をまだ見ていない部分から見つける
    const size_t offset = result % s.size();  // sにおける未見部分の先頭
    auto iter = std::lower_bound(indices.cbegin(), indices.cend(), offset);
    if (iter == indices.end()) {
      // 現在地以降にt_iと同じ文字がない場合、次の繰り返し分から選択する
      result += s.size() - offset;
      result += indices[0] + 1;  // 次の文字から探し始めたいので+1
    } else {
      // 現在地以降にt_oと同じ文字がある場合、それを選択する
      result += *iter - offset + 1;  // 次の文字から探し始めたいので+1
    }
  }

  // 結果発表
  std::cout << result;
  return 0;
}

int main() {
  return solve_E();
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    ll n;
    cin >> n;
    ll ans = n - 1;
    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ll tmp = i - 1;
            tmp += n / i - 1;
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const int mod=1e9+7;
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
map<int,int>s,t;
int main(){
//    freopen("out.txt","r",stdin);
//    freopen("outt.txt","w",stdout);
    int n,m,a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        if(a>b) swap(a,b);
        if(a==1) s[b]=1;
        if(b==n) t[a]=1;
    }
    for(int i=1;i<=n;i++){
        if(s[i]&&t[i]) return 0*puts("POSSIBLE");
    }
    puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 18944
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

struct edge {
	int source;
	int distination;
	long long length;
};

struct node {
	long long distance;
	//int predecessor;
	bool distanceIsNotInf;
};

//0始まりでフォーマットして入力すること.返値は距離と, 負の重みの閉路があればtrue.
pair<long long, bool> bellmanFord(node* nodes, int numOfNodes, edge* edges, int numOfEdges, int startAt, int endAt) noexcept {
	bool minusCycle = false;

	//relax
	for (int i = 0; i < numOfNodes - 1; ++i) {
		for (int j = 0; j < numOfEdges; ++j) {
			int u = edges[j].source;
			int v = edges[j].distination;

			if (!nodes[v].distanceIsNotInf || nodes[v].distance > nodes[u].distance + edges[j].length) {
				nodes[v].distance = nodes[u].distance + edges[j].length;
				//nodes[v].predecessor = u;
				nodes[v].distanceIsNotInf = true;
			}
		}
	}

	//閉路の確認
	for (int i = 0; i < numOfEdges; ++i) {
		int u = edges[i].source;
		int v = edges[i].distination;

		if (!nodes[v].distanceIsNotInf || nodes[v].distance > nodes[u].distance + edges[i].length) {
			minusCycle = true;
			break;
		}
	}

	return pair<long long, bool>(nodes[endAt].distance, minusCycle);
}

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

	int h, w;
	cin >> h >> w;
	string* s;
	s = new string[h];
	rep(i, h) cin >> s[i];

	node* nodes;
	nodes = new node[h*w];
	edge* edges;
	edges = new edge[h*w * 2 - h - w];

	rep(i, h) {
		rep(j, w) {
			if (i == 0 && j == 0) {
				nodes[i*w + j].distance = 0;
				nodes[i*w + j].distanceIsNotInf = true;
			}
			else {
				nodes[i*w + j].distance = MOD;
				nodes[i*w + j].distanceIsNotInf = false;
			}

			if (i != h - 1) {
				edges[i*w + j].source = i * w + j;
				edges[i*w + j].distination = (i + 1)*w + j;
				if (s[i][j] == s[i + 1][j]) edges[i*w + j].length = 0;
				else edges[i*w + j].length = 1;
			}

			if (j != w-1) {
				edges[w*(h - 1) + i * (w - 1) + j].source = i * w + j;
				edges[w*(h - 1) + i * (w - 1) + j].distination = i * w + j + 1;
				if (s[i][j] == s[i][j + 1]) edges[w*(h - 1) + i * (w - 1) + j].length = 0;
				else edges[w*(h - 1) + i * (w - 1) + j].length = 1;
			}
		}
	}

	ll ans = bellmanFord(nodes, h*w, edges, (h - 1)*w + (w - 1)*h, 0, h*w - 1).first;
	ans /= 2;
	if (s[0][0] != s[h - 1][w - 1]) ++ans;
	else if (s[0][0] == '#') ++ans;

	cout << ans << "\n";

	return 0;
 }


Measured memory_bytes: 768
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		boolean ok = false;
		LOOP:for(int i = 0; i <= N; i++) {
			for(int j = 0; j <= N-i; j++) {
				if(i*10000 + j*5000 + (N-j-i)*1000 == Y) {
					ok = true;
					System.out.println(i + " " + j + " " + (N-j-i));
					break LOOP;
				}
			}
		}
		if(!ok)
			System.out.println(-1 + " " + -1 + " " + -1);

	}

}

Measured memory_bytes: 23124
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct list{
  struct list *next;
  struct list *prev;
  int data;
};
struct list *nil;				/* 番兵 */

void init(){
  nil=malloc(sizeof(struct list));
  nil->prev=nil;
  nil->next=nil;
}
void insert(int x){
  struct list *tmp;
  tmp=malloc(sizeof(struct list));
  tmp->data=x;
  nil->next->prev=tmp;
  tmp->next=nil->next;
  nil->next=tmp;
  tmp->prev=nil;
}
struct list *listsearch(int x){
  struct list *tmp=nil->next;
  while((tmp!=nil)&&(tmp->data!=x))
	tmp=tmp->next;
  return tmp;
}
void delete(struct list *cur){
  if(cur == nil)
	return;
  cur->next->prev=cur->prev;
  cur->prev->next=cur->next;
  free(cur);
}
void deletelist(int x){
  delete(listsearch(x));
}
void deletefirst(){
  delete(nil->next);
}
void deletelast(){
 delete(nil->prev);
}
void printlist(){
  struct list *cur=nil->next;
  int x=0;
  while(1){
	if(cur==nil)
	  break;
	if(x>0)
	  printf(" ");
	++x;
	printf("%d", cur->data);
	cur=cur->next;
}
  printf("\n");
}
int main(){
  int n;
  scanf("%d", &n);
  int i;
  char line[100];
  int num;
  init();
  for(i=0; i<n; ++i){
	scanf("%s %d", line, &num);
	if(strcmp(line, "insert")==0)
	  insert(num);
	else if(strcmp(line, "delete")==0)
	  deletelist(num);
	else if(strcmp(line, "deleteFirst")==0)
	  deletefirst();
	else if(strcmp(line, "deleteLast")==0)
	  deletelast();
	  }
   printlist();
  return 0;
}



Measured memory_bytes: 32952
#include <iostream>
#include <string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int N, A, B,countA=0,countB=0;
	string S;
	cin >> N >> A >> B >> S;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'c')cout << "No" << endl;
		else {
			countA++;
			if (A + B >= countA) {
				if (S[i] == 'b') {
					countB++;
					if (countB <= B)cout << "Yes" << endl;
					else {
						countA--;
						cout << "No" << endl; 
					}
				}
				else cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

L=input()
N=len(L)

# dp[i][j] := i桁目まで考えた時、j=0はi桁目まで一致(L=A+B)、j=1は既にA+BがL未満(L>A+B)になった状態
dp=list2d(N+1, 2, 0)
# 0桁目(始まる前)は同じとみなしてj=0に1通り
dp[0][0]=1

for i in range(N):
    # i桁目のa+bを0にする場合
    # Lのi桁目が0なら
    if L[i]=='0':
        # 何も変化しない
        dp[i+1][0]+=dp[i][0]
        dp[i+1][1]+=dp[i][1]
    # Lのi桁目が1なら
    else:
        # これまでL=A+BだったものもL>A+Bになるので、j=1もj=0もj=1に遷移させる
        dp[i+1][1]+=dp[i][0]+dp[i][1]
    dp[i+1][0]%=MOD
    dp[i+1][1]%=MOD

    # i桁目のa+bを1にする場合
    # Lのi桁目が0なら
    if L[i]=='0':
        # 既にL>A+Bだったものだけが遷移できる(aを1とするかbを1とするかで*2)
        dp[i+1][1]+=dp[i][1]*2
    # Lのi桁目が1なら
    else:
        # 状態は変化しない(ただしaを1とするかbを1とするかで*2)
        dp[i+1][0]+=dp[i][0]*2
        dp[i+1][1]+=dp[i][1]*2
    dp[i+1][0]%=MOD
    dp[i+1][1]%=MOD
# 最終的にL=A+Bだった分とL>A+Bだった分を合計する
print((dp[N][0]+dp[N][1])%MOD)


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";

#define p push_back
typedef long long ll;
int main()
{IOS
ll n,count=0;
cin>>n;

for(auto i=1;i<=n;i++)
{ ll k=n/i;
count=count+(k*(k+1)*i)/2;}
cout<<count;
return 0;}

Measured memory_bytes: 3652
N = gets.to_i
strs = gets.split.map(&:to_i).map(&:abs)

b_ary = []
strs.each_with_index do |str, idx|
  b_ary << str - (idx+1)
end
b_ary.sort!
b_middle_num = b_ary[N/2]

puts b_ary.map {|b| (b-b_middle_num).abs}.inject(0, :+)

Measured memory_bytes: 21432
#include<stdio.h>
int main (void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a>b){
    printf("a > b\n");
  }else if(a==b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <iostream>

int main(void)
{
    std::string a, b, c;
    std::cin >> a >> b >> c;
    char a_last = a[a.length() - 1];
    char b_last = b[b.length() - 1];
    char b_first = b[0];
    char c_first = c[0];
    bool flag = (a_last == b_first) && (b_last == c_first);
    std::cout << (flag ? "YES" : "NO") << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;
int link[210][210], rr[210];
int a, b, c;
using namespace std;
int main()
{
    //cout << 0x3f << endl;
    memset(link, 0x3f3f3f3f, sizeof(link)); //cout << link[2][2] << endl;
    int n, m, r;
    scanf("%d%d%d", &n, &m, &r);
    for(int i = 0; i < r; i++)
    {
        scanf("%d", &rr[i]), rr[i]--;
    }

    sort(rr, rr+r);
    for(int i = 0; i < m; i++)
    {
        scanf("%d%d%d", &a, &b, &c);
        link[--a][--b] = link[b][a] = c;
    }
    int ans = 0;
    for(int k = 0; k < n; k++)
    {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                link[i][j] = min( link[i][j], link[i][k] + link[k][j]);
            }
        }
    }
    int mi = INT_MAX;
    do
    {
        int ans = 0;

        for(int i = 0; i + 1 < r; i++)
        {
            ans += link[rr[i]][rr[i+1]];

        }
        mi = min(ans, mi);
    }
    while(next_permutation(rr, rr + r));
    cout << mi << endl;
}


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

const int mod = 1e9+7; 
long long calc(long long a, long long b, long long p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		long long d = calc(a, b / 2, p);
		return (d * d) % p;
	}
	else
		return (a * calc(a, b - 1, p)) % p;
}
long long nCr(long long n, long long r)
 {
  long long x = 1;
  long long y  = 1;
  for (long long i = 1; i <= r; ++i )
	 {
    x *= (n-i+1);
		x %= mod;
    y  *= i;
		y %= mod;
  }
  return x * calc(y, mod - 2, mod) % mod;
}
signed main(void)
{
	int n, k;
	ll ans;
	cin >> n >> k;
	ans = 0;
	for (int i = 1; i <= k; i++)
	{
		ans = nCr(n - k + 1, i);
		ans *= nCr(k - 1, i - 1);
		ans %= mod;
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
    double l;
    cin >> l;
    double s = l/3;
    double ans = s*s*s;
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;

fn read(s: &mut StdinLock) -> f64 {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .skip_while(|c| c.is_whitespace())
        .fold(0.0, |a, x| (x as u8 - b'0') as f64 + a * 10.0)
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let l = read(&mut s);
    println!("{:.12}", l*l*l/3.0/3.0/3.0);
}

Measured memory_bytes: 4352
#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(int i=0;i<x;i++)
#define repn(i,x) for(int 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())
int main(){
	int a,b,c,n;cin>>a>>b>>c>>n;
	int ans = 0;
	for(int i=0;i*a<=n;i++){
		for(int j=0;i*a+j*b<=n;j++){
			int zan = n-i*a-j*b;
			if(zan%c == 0) ans++;
		}
	}
	cout << ans << endl;
}

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

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    long double v = (long double)pow(a, 2) * b;

    long double tan;
    if (v < 2 * x)
    {
        tan = (v - x) / pow(a, 3) * 2;
    }
    else
    {
        tan = (long double)a * pow(b, 2) / x / 2;
    }

    long double theta = atan(tan);
    long double ans = 180 * theta / M_PI;

    cout << setprecision(7) << ans << endl;
    return 0;
}

Measured memory_bytes: 4136
n = int(input())
AB = []
for _ in range(n):
    a, b = map(int, input().split())
    tot = a+b
    AB.append([a, b, tot])

AB = sorted(AB, key=lambda x:x[2], reverse=True)

a_eat = 0
b_eat = 0

for i in range(n):
    if i%2 == 0:
        a_eat += AB[i][0]
    else:
        b_eat += AB[i][1]

ans = a_eat - b_eat
print(ans)

Measured memory_bytes: 25228
#include<bits/stdc++.h>
using namespace std;
int n, m, x, c[15], v[15][15], w[15], ans=1e9;
void dfs(int k, int s){
	if(s>=ans) return;
	if(k>n){
		int flag=0;
		for(int i=1; i<=m; i++){
			if(w[i]<x){
				flag=1;
				break;
			}
		}
		if(!flag) ans=s;
		return;
	}
	dfs(k+1, s);
	for(int i=1; i<=m; i++){
		w[i]+=v[k][i];
	}
	dfs(k+1, s+c[k]);
	for(int i=1; i<=m; i++){
		w[i]-=v[k][i];
	}
}
int main(){
	scanf("%d%d%d", &n, &m, &x);
	for(int i=1; i<=n; i++){
		scanf("%d", &c[i]);
		for(int j=1; j<=m; j++){
			scanf("%d", &v[i][j]);
		}
	}
	dfs(1, 0);
	if(ans==1e9) printf("-1");
	else printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3820
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

int n, m, k;
int a[N];
int d[3001][3001][3];

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for (int i = 1; i <= n; i++){
		for (int l = 0, r = i - 1; r < n; l++, r++){
			if (i == 1){
				d[l][r][1] = a[l];
				d[l][r][0] = -a[l];
			}
			else{
				d[l][r][1] = max(d[l + 1][r][0] + a[l], d[l][r - 1][0] + a[r]);
				d[l][r][0] = min(d[l + 1][r][1] - a[l], d[l][r - 1][1] - a[r]);
			}
		}
	}
	cout << d[0][n - 1][1];
	return 0;
}












Measured memory_bytes: 213248
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 200000
#define maxh 1000001
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,LL> piLL;

LL c;
int n;
int h[maxn];
LL dp[maxn];
vector<piLL> tree;

void init() {
	tree.resize(4*maxh, piLL(0, LLONG_MAX));
}

LL calcCost(int pos, piLL func) {
	return (LL) func.fi * pos + func.se;
}

LL query(int tx, int ty, int q, int id) {
	LL currCost = calcCost(q, tree[id]);
	if(ty == tx+1)
		return currCost;
	int mid = (tx + ty) >> 1;
	LL childCost;
	if(q < mid)
		childCost = query(tx, mid, q, id*2);
	else
		childCost = query(mid, ty, q, id*2+1);
	return min(currCost, childCost);
}

void update(int tx, int ty, piLL p, int id) {
	int mid = (tx + ty) >> 1;
	bool leftSmaller = calcCost(tx, p) < calcCost(tx, tree[id]);
	bool midSmaller = calcCost(mid, p) < calcCost(mid, tree[id]);
	if(midSmaller)
		swap(tree[id], p);
	if(ty == tx+1)
		return;
	if(leftSmaller != midSmaller)
		update(tx, mid, p, id*2);
	else
		update(mid, ty, p, id*2+1);
}

int main() {
	init();
	scanf("%d%lld",&n,&c);
	for( int i = 0 ; i < n ; i++ )
		scanf("%d",&h[i]);
	for( int i = 0 ; i < n ; i++ ) {
		if(i)
			dp[i] = query(1, maxh, h[i], 1) + (LL) h[i]*h[i] + c;
		piLL p = piLL(-2*h[i], dp[i] + (LL) h[i]*h[i]);
		update(1, maxh, p, 1);
	}
	printf("%lld\n",dp[n-1]);
	return 0;
}


Measured memory_bytes: 65024
from collections import deque

n = int(input())
A = [[int(i) for i in input().split()] for j in range(n - 1)]
C = [int(i) for i in input().split()]
C.sort(reverse=True)

E = [[] for i in range(n + 1)]
V = [0] * (n + 1)

for a, b in A:
    E[a].append(b)
    E[b].append(a)

t = 0
ma = 0

for i, e in enumerate(E):
    if len(e) > ma:
        t = i
        ma = len(e)

Q = deque()
Q.append((t, 0))
i = 0
visited = [False] * (n + 1)
ans = 0

while Q:
    v, c = Q.popleft()
    if visited[v]:
        continue
    visited[v] = True
    V[v] = C[i]
    ans += min(c, C[i])
    for e in E[v]:
        Q.append((e, C[i]))
    i += 1

print(ans)
print(*V[1:])

Measured memory_bytes: 7556
a = gets.to_i + 1
b = gets.to_i + 1
c = gets.to_i + 1
x = gets.to_i
cnt = 0

a.times do |i|
  b.times do |j|
    c.times do |k|
      cnt += 1 if 500*i + 100*j + 50*k == x
    end
  end
end
puts cnt


Measured memory_bytes: 14284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll INF = 1e18;

int main(void)
{
    ll n, m, l=0, r=INF;
    cin >> n >> m;
    vector<ll> a(200000,0);
    rep(i,m){
        ll a, b;
        cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }
    cout << max(0LL, r-l+1) << endl;
    return 0;
}

Measured memory_bytes: 4784
import math
import itertools
N = int(input())
A = []
for i in range(N):
  a = list(map(int,input().split()))
  A.append(a)
K = 0
dp = [[0]*(N+1) for _ in range(N+1)]
for i in range(N-1):
  for j in range(i+1,N):
    xi = A[i][0]
    yi = A[i][1]
    xj = A[j][0]
    yj = A[j][1]
    t = ((xi-xj)**2+(yi-yj)**2)**(1/2)
    dp[i+1][j+1] = t 
    dp[j+1][i+1] = t
l= []
for i in range(1,N+1):
  l.append(i)
for v in itertools.permutations(l):
  for j in range(N-1):
    K += dp[v[j]][v[j+1]]
print(K/(math.factorial(N)))

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


int main(){
  long long X;
  int i=1;
  long long money = 100;
  cin >> X;
  while(1){
    money += (money*0.01);
    if(money >= X){
      cout << i << endl;
      return 0;
    }
    i++;
  }
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  int B[N];
  for (int i=0; i<N; i++) {
    cin >> B[i];
  }
  
  int C[N-1];
  for (int i=0; i<N-1; i++) {
    cin >> C[i];
  }
  
  int S = 0;
  
  for (int i=0; i<N-1; i++) {
    if (A[i+1] == A[i]+1) {
      S += C[A[i]-1];
    }
  }
  
  for (int i=0; i<N; i++) {
    S += B[i];
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
 
        // tenka1_2018_b
        int i = 0;
        while (k > 0) {
        	k--;
        	if (i%2 == 0) {
        		// a
        		if (a%2 != 0) {
        			a--;
        		}
        		int half = a / 2;
        		a -= half;
        		b += half;
        	} else {
        		// b
        		if (b%2 != 0) {
        			b--;
        		}
        		int half = b / 2;
        		b -= half;
        		a += half;
        	}
        	i++;
        }
        System.out.println(a + " " + b);
	}
}

Measured memory_bytes: 22612
//TC
#include<iostream>
#include<cctype>

using namespace std;

int main()
{
	char c[1200];
	int i = 0;
	
	cin.getline(c, sizeof(c));
	while(c[i] != '\0'){

		if(isalpha(c[i])){
			if(islower(c[i]))
				cout << (char)toupper(c[i++]);
			else
				cout << (char)tolower(c[i++]);
		}else{
			cout << c[i++];
		}
		
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3064
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass

s = l()
moji = ""
for i in range(len(s)):
    if s[i] == "0":
        moji = moji + "0"
    elif s[i] == "1":
        moji = moji + "1"
    else:
        moji = moji[:-1]
print(moji)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define pii pair<int, int>
#define fst first
#define snd second
#define pub push_back
#define vi vector<int>
#define ll long long

using namespace std;

int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long n, res = 0; cin >> n;
	for (long long i = 2; i * i <= n; i++)
	{
		ll to = 0;
		while (n % i == 0)
		{
			to++;
			n /= i;
		}
		if (to)
		{
			int val = sqrt(2 * to);
			if (val * (val + 1) > 2 * to) {val--;}
			res += val;
		}
	}
	if (n > 1) {res++;}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 3696
n = int(input())
s = input()
maxc = 0
for i in range(1,n):
    cnt = 0
    sl = list(set(s[:i]))
    sr = list(set(s[i:]))
    for j in range(len(sl[:i])):
        if sl.count(sl[j])>0 and sr.count(sl[j]):
            cnt += 1
    maxc = max(maxc,cnt)
print(maxc)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int a, b, c, rect=0, rho=0;

	while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if(a*a + b*b == c*c){ rect++;	}	//長方形
		else if(a == b){ rho++; }	//ひし形

	}
	printf("%d\n%d\n", rect, rho);

	return 0;
}

Measured memory_bytes: 596