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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

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

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e5+5;
string s;
ll n,m;
ll a,p;
ll num1, num2[N];
ll result1, result2;
bool ac[N];

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  rep(i,m) {
    cin >> p >> s;
    p--;
    if(!ac[p]) {
      if(s == "AC") {
        num1++;
        ac[p] = true;
      } else {
        num2[p]++;
      }
    }
  }
  rep(i,n) {
    if(ac[i]) {
      result2 += num2[i];
    }
  }
  cout << num1 << ' ' << result2 << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline ostream& operator<<(ostream& is, vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "" : " "); return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();
    auto dp = vec<ll>(n + 1, 4);
    dp[0][0] = 1;
    string abc = "ABC";
    FOR(i, 0, n)FOR(j, 0, 4) {
        (dp[i + 1][j] += dp[i][j] * (s[i] == '?' ? 3 : 1)) %= mod;
        if (j < 3 && (s[i] == '?' || s[i] == abc[j])) {
            (dp[i + 1][j + 1] += dp[i][j]) %= mod;
        }
    }

    print(dp[n][3]);
}

Measured memory_bytes: 7376
// Aizu Vol0 0039: Roman Figure
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);

int roman[26];

int main()
{
	int d, d2;
	char buf[100], *p;
	int ans;

	for (d = 0; d < 26; d++) roman[d] = 0;
	roman['I' - 'A'] = 1;
	roman['V' - 'A'] = 5;
	roman['X' - 'A'] = 10;
	roman['L' - 'A'] = 50;
	roman['C' - 'A'] = 100;
	roman['D' - 'A'] = 500;
	roman['M' - 'A'] = 1000;

	while (gets(buf) != NULL) {
		p = buf, ans = 0;
		while (*p) {
			if (isupper(*p)) {
				d = roman[*p++ - 'A'], d2 = roman[*p - 'A'];
				if (isupper(*p) && d2 > d) ans += d2 - d, p++;
				else ans += d;
			} else p++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	string s;
	cin >> s;
	if(s=="ARC")
		cout << "ABC" << endl;
	else
		cout << "ARC" << endl;




}

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

int main()
{
	int a;
	int b;
	
	//??\???
	cin >> a;
	cin >> b;
	
	
	if (a < b){
		cout << "a < b\n";
	}
	
	else if (a > b){
		cout << "a > b\n";
	}
	
	else{
		cout << "a == b\n";
	}
	
	return 0;
}

Measured memory_bytes: 3056
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0]*(k+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  ai = A[i-1]
  now = 0
  for ki in range(k+1):
    now += dp[i-1][ki]
    if ki - ai > 0:
      now -= dp[i-1][ki-ai-1]
    dp[i][ki] = now % mod
print(dp[n][k])
# print(dp)

Measured memory_bytes: 119404
<?php
list($n, $a) = ints();
$x = ints();
for ($i = 0; $i < $n; ++$i) $x[$i] -= $a;
$dp[-1][0] = 1;
for ($i = 0; $i < $n; ++$i) {
    foreach ($dp[$i - 1] as $j => $v) {
        if (isset($dp[$i][$j])) $dp[$i][$j] += $v;
        else $dp[$i][$j] = $v;
        if (isset($dp[$i][$j + $x[$i]])) $dp[$i][$j + $x[$i]] += $v;
        else $dp[$i][$j + $x[$i]] = $v;
    }
}
echo $dp[$n - 1][0] - 1;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 17060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

long long power(long long x, long long n, long long mod = 1000000007) {
    if (n == 0) return 1;
    if (n % 2 == 0) return power(x * x % mod, n/2, mod);
    else return x * power(x, n-1, mod) % mod;
}

void solve() {
    int p;
    cin >> p;
    VI a(p);
    REP(i,0,p) cin >> a[i];
    VVI r(p,VI(p));
    VI g(p);
    REP(i,1,p) {
        RREP(j,1,p) {
            if ((i * j) % p == p - 1) {
                g[i] = j;
                break;
            }
        }
    }
    REP(i,0,p) {
        int mul = 1;
        REP(j,0,p) {
            r[i][j] = g[mul];
            mul *= i;
            mul %= p;
        }
        if (i) r[i][0] = 0;
    }
    r[0][0] = 1;
    r[0][p-1] =  p - 1;
    /* 
    REP(i,0,p) {
        REP(j,0,p) cout << r[i][j] << " ";
        cout << endl;
    }
    */
    VI ans(p);
    REP(i,0,p) {
        if (a[i] != 1) continue;
        REP(j,0,p) ans[j] = (ans[j] + r[i][j]) % p;
    }
    REP(i,0,p) cout << ans[i] << " ";
    cout << endl;
}

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

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

int main()
{
    int A, B, i=1;
    cin >> A >> B;
    while(1){
        if(floor(i*0.08)==A && floor(i*0.1)==B){
            cout << i << endl;
            return 0;
        }

        if(i>100000000){
            cout << -1 << endl;
            return 0;
        }
        i++;
    }

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define inputv(arr,n) for(ll i=0;i<n;i++){ll value;cin>>value;arr.pb(value);}
#define sz(a) ((ll)(a).size())
#define len(a) ((ll)(a).length())
#define precise cout<<fixed<<setprecision(0); 
#define F first
#define S second
#define vi vector <int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
#define nl cout<<"\n"
using namespace std;
ll power(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;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
// hashing for pairs
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
//sort in reverse order
bool compare(ll x, ll y){
    return x>y;
}
void solve()
{
  map<string,ll>cnt;
  ll n;
  cin>>n;
  string s;
  rep(i,n)
  {
    cin>>s;
    cnt[s]++;
  }
  cout<<"AC x "<<cnt["AC"];nl;
  cout<<"WA x "<<cnt["WA"];nl;
  cout<<"TLE x "<<cnt["TLE"];nl;
  cout<<"RE x "<<cnt["RE"];nl;
  return;
}
int main()
{
    IOS;
    int T=1;
   // cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f

using namespace std;

const int N = 1000, M = 1000;

int n, m, k;
char s[N][M];
int a[N][M];
int bel[N], sum[N];

int main() {
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 0; i < n; i++) scanf("%s", s[i]);
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < m; j++) 
			a[i][j] = s[i][j] - '0';
	int ans = n + m;
	for (int mask = 0; mask < (1 << (n - 1)); mask++) {
		int tot = 0, res = 0;
		for (int i = 0; i < n; i++) {
			bel[i] = tot;
			if (mask >> i & 1)
				++tot;
		}
		memset(sum, 0, sizeof sum);
		for (int i = 0; i < m; i++) {
			int flg = 0;
			for (int j = 0; j < n; j++) {
				sum[bel[j]] += a[j][i];
				if (sum[bel[j]] > k) 
					flg = 1;
			}
			if (flg) {
				memset(sum, 0, sizeof sum);
				res++;
				for (int j = 0; j < n; j++) {
					sum[bel[j]] += a[j][i];
					if (sum[bel[j]] > k) res = n + m;
				}
			}
			if (res == n + m) break;
		}
		ans = min(ans, res + tot);
	}
	printf("%d\n", ans);
	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	long long n, m;
	cin >> n >> m;
	if (n > m)
		n = n % m;
	cout << min(n, m - n);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int total;
	
	total = 0;
	for (i = 0; i < 10; i++){
		scanf("%d", &n);
		total += n;
	}
	
	printf("%d\n", total);
	
	return (0);
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int a[300010];
int f[300010];
int n;
bool check(int mid)
{
	int mn=0;
	bool flag=true;
	for(int i=2;i<=n+1;i+=2)
	{
		flag=(f[i-1]-mn>=mid);
		if(flag)
			mn=min(mn,f[i]);
	}
	return flag;
}
int main()
{
	int W=0,B=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		f[i]=f[i-1];
		if(i&1){
			B+=a[i];
			f[i]+=a[i];
		}
		else{
			W+=a[i];
			f[i]-=a[i];
		}
	}
	if(n%2==0){
		printf("%d %d\n",max(W,B),min(W,B));
		return 0;
	}
	int l=0,r=1e9;
	while(l+1<r)
	{
		int mid=(l+r)>>1;
		if(check(mid))l=mid;
		else r=mid;
	}
	int res=max(B,W+l);
	printf("%d %d\n",res,W+B-res);
	return 0;
}

Measured memory_bytes: 2560
using System;

namespace AizuOnlineJudgement.ITP1_1_D
{
	public static class Program
	{
		public static void Main (string[] args)
		{
			var S = int.Parse (Console.ReadLine ());
			var s = S % 60;
			var m = S / 60 % 60;
			var h = S / 3600;
			Console.WriteLine (h + ":" + m + ":" + s);
		}
	}
}



Measured memory_bytes: 9220
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
vector<int> v;

signed main(){
	cin>>N;
	while(N!=0){
		N--;
		v.push_back(N%26);
		N/=26;
	}
	reverse(v.begin(),v.end());
	REP(i,v.size()){
		cout<<char('a'+v[i]);
	}
	cout<<endl;
	return 0;
}


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

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

  string ans;
  if (S[0] == 'A') ans = 'T'; 
  else if (S[0] == 'T') ans = 'A'; 
  else if (S[0] == 'G') ans = 'C'; 
  else if (S[0] == 'C') ans = 'G'; 
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  char b;
  cin >> b;
  switch(b){
    case 'A':
      cout<<'T'<<endl;
      break;
  	case 'T':
      cout<<'A'<<endl;
      break;
    case 'G':
      cout<<'C'<<endl;
      break;
    case 'C':
      cout<<'G'<<endl;
      break;
  }
  return 0;
}

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


int main() {
    ll n,m;
    cin >> n >> m;
    vector<pair<ll,ll>>price(n);
    rep(i,n){
        cin >> price.at(i).first >> price.at(i).second;
    }
    sort(price.begin(),price.end());
    ll sum = 0;
    ll remain = m;
    ll i = 0;
    while(remain > 0){
        if(remain - price.at(i).second > 0){
            remain -= price.at(i).second;
            sum += price.at(i).first * price.at(i).second;
        }else{
            sum += price.at(i).first * remain;
            break;
        }
        i++;
    }
    cout << sum << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 1792
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
# S = [input() for _ in range(N)]
from collections import defaultdict, Counter

d = defaultdict(int)

for _ in range(N):
    s = input()
    d[s[0]] += 1

# print(d)

ans = 0
charlist = list("MARCH")
for i in range(1<<5):
    if not Counter( list ( "{0:05b}".format(i)) )["1"] == 3:
        continue
    
    s = 1
    for e,i in enumerate(list("{0:05b}".format(i))):
        if i == "1":
            s *= d[ charlist[e] ]

    ans += s
print(ans)
    


Measured memory_bytes: 44920
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x1,x2,x3;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	x1=abs(a-b)+abs(b-c);
	x2=abs(a-c)+abs(b-a);
	x3=abs(b-c)+abs(c-a);
    printf("%d",min(x1,min(x3,x2)));
 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
vector<pair<int,int> > pi;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a==b) cout<<"Yes";
    else cout<<"No";
    cout<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N], B[MAX_N], C[MAX_N];
pi P[MAX_N];
map<int, int> G;

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> P[i].sec;
	rep(i, 0, N) cin >> P[i].fst;
	sort(P, P + N);
	rep(i, 0, N) {
		A[i] = P[i].sec;
		C[i] = A[i];
	}
	rep(i, 0, N) B[i] = P[i].fst;
	sort(A, A + N);

	rep(i, 0, N) {
		if(A[i] > B[i]) {
			cout << "No\n"; return;
		}
	}
	rep(i, 0, N - 1) {
		if(A[i + 1] <= B[i]) {
			cout << "Yes\n"; return;
		}
	}
	rep(i, 0, N) {
		if(G.count(C[i])) {
			cout << "Yes\n"; return;
		}
		G[C[i]] = A[i];
	}
	int at = C[0];
	rep(i, 0, N - 1) {
		at = G[at];
		if(at == C[0]) {
			cout << "Yes\n"; return;
		}
	}
	cout << "No\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    string w[3] = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;

    REP(i,3){
        if(s == w[i]){
            cout << w[(i + 1) % 3] << endl;
            break;
        }
    }

    return 0;
}

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

using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  for(int i = 0;
      i < s.length()
        && i < t.length();
      ++i)
    {
      if(s[i] < t[i])
        {
          cout << "Yes" << endl;
          return 0;
        }
      else if (s[i] > t[i])
        {
          cout << "No" << endl;
          return 0;
        }
    }

  if(s.length() < t.length())
    {
      cout << "Yes" << endl;
    }
  else
    {
      cout << "No" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits>

int calc_sum_of_digits(int x) {
    int ret = 0;
    while (x) {
        ret += x % 10;
        x /= 10;
    }

    return ret;
}

int main() {
    int N;
    std::cin >> N;

    int ret = std::numeric_limits<int>::max();
    for (int a = 1; a < N; ++a) {
        const int b = N - a;

        ret = std::min(ret, calc_sum_of_digits(a) + calc_sum_of_digits(b));
    }

    std::cout << ret << std::endl;
}


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

using namespace std;
int n;
long long int ar[200001];
long long int ans = LONG_MAX;
int main() {
    scanf("%d", &n);

    for (int i = 1; i <= n; i++) {
        scanf("%lld", &ar[i]);
        ar[i] += ar[i-1];
    }

    for (int i = 1; i < n; i++) {
        long long int lsum = ar[i];
        long long int rsum = ar[n] - lsum;
        ans = min(ans, abs(lsum-rsum));
    }
    printf("%lld\n", ans);

    //for (int i = 0; i <=n; i++)
    //    printf("%d ", ar[i]);


    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define rep1(i,n) for (long long int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    string st; cin >> st;
    vector<int> v(4,0); //N0 W1 S2 E3
    rep(i,st.length()) {
        switch(st[i]) {
            case('N'):
                v[0]++;
                break;
            case('S'):
                v[1]++;
                break;
            case('E'):
                v[2]++;
                break;
            case('W'):
                v[3]++;
                break;
        }
    }

    string ans = "Yes";
    if ((v[0] > 0 || v[1] > 0) && v[0] * v[1] == 0)
        ans = "No";
    if ((v[2] > 0 || v[3] > 0) && v[2] * v[3] == 0) 
        ans = "No";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define gap ' '
#define abs(x) ((x)>0?(x):-(x))
#define INF 1e18
#define mod  10000007
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,w;
    cin>>n>>w;
    vector<pii> v;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int W,V;
        cin>>W>>V;
        v.pb({W,V});
        sum+=V;
    }
    int dp[n+1][sum+1];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=sum;j++)
        dp[i][j]=-1;
    for(int i=0;i<=n;i++)
        dp[i][0]=0;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=sum;j++)
        {
            if(j-v[i-1].se>=0 && dp[i-1][j-v[i-1].se]!=-1)
            {
                if(dp[i-1][j-v[i-1].se]+v[i-1].fi<=w)
                {
                    if(dp[i][j]==-1)
                dp[i][j]=dp[i-1][j-v[i-1].se]+v[i-1].fi;

                     if(dp[i][j]!=-1)
                        dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1].se]+v[i-1].fi);
                    if(dp[i-1][j]!=-1) dp[i][j]=min(dp[i][j],dp[i-1][j]);
                    }
                else dp[i][j]=dp[i-1][j];

            }
            else dp[i][j]=dp[i-1][j];

        }
    }
//    for(int i=1;i<=n;i++)
//    {
//        for(int j=1;j<=sum;j++)
//            cout<<dp[i][j]<<gap;
//        cout<<endl;
//    }
    int ans=-1;
    for(int i=sum;i>=1;i--)
        {for(int j=1;j<=n;j++)
        if(dp[j][i]!=-1)
        {
            ans=i;
            break;
        }
        if(ans!=-1) break;
    }
cout<<ans;

}


Measured memory_bytes: 39680
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int now,al;
string s;

bool formula(void){
	
	if(isupper(s[now])){
		now++;
		return s[now-1]=='T';
	}
	
	if(islower(s[now])){
		now++;
		return (al>>(s[now-1]-'a'))&1;
	}
	
	if(s[now]=='('){
		now++;
		bool res1=formula();
		
		if(s[now]=='*'){
			now++;
			bool res2=formula();
			if(s[now]==')')now++;
			return res1&res2;
		}
		if(s[now]=='+'){
			now++;
			bool res2=formula();
			if(s[now]==')')now++;
			return res1|res2;
		}
		if(s[now]=='-' && s[now+1]=='>'){
			now+=2;
			bool res2=formula();
			if(s[now]==')')now++;
			if(res1==true && res2==false)return false;
			return true;
		}
	}
	
	if(s[now]=='-'){
		now++;
		bool res=formula();
		return !res;
	}
}

bool equation(void){
	bool res1=formula();
	now++;
	bool res2=formula();
	return (res1==res2);
}

int main(void){
	
	while(cin >> s,s!="#"){
		bool fg=true;
		for(al=0;al<(1<<11);al++)now=0,fg&=equation();
		if(fg)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
n=int(input())
t=list(map(int,input().split()))
m=int(input())

for i in range(m):
    p,x=map(int,input().split())
    ans=0
    for j in range(n):
        if j+1 == p:
            ans+=x
        else:
            ans+=t[j]
    print(ans)
        


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

int main(){
    int n, ans;
    cin >> n;
    int a[n], b[n], c[n], dp[n][3];
    
    for(int i=0; i<n; i++)
	cin >> a[i] >> b[i] >> c[i];

    for(int i=0; i<n; i++)
	for(int j=0; j<3; j++)
	    dp[i][j] = 0;

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
        
    for(int i = 1; i<n; i++){
	dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
	dp[i][1] = max(dp[i-1][2]+b[i], dp[i-1][0]+b[i]);
	dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);	
    }

    ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));    
    cout << ans << "\n";
        
}


Measured memory_bytes: 2560
n,q=map(int,input().split())
s=input()
lr=[input() for __ in range(q)]
cs=[0]*(n+1)

#端がACで-1で止まる文字列指定は大丈夫？.
for i in range(n):
    cs[i+1]=cs[i] + (1 if s[i:i+2] == 'AC' else 0)

for num in lr:
    l,r=map(int,num.split())
    print(cs[r-1] - cs[l-1])


Measured memory_bytes: 67160
#include <stdio.h>

int main(void){
	int S, h, m, s;

	scanf("%d", &S);
	h = S / (60 * 60);
	m = (S - h * 3600) / 60;
	s = (S - h * 3600) % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
#include<cstdio>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
int main(void)
{
	int n,m,i,j,s;
	long long sum;
	priority_queue<int,vector<int>,greater<int> > qq;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	{
		scanf("%d",&m);
		for(j=0;j<m;j++)	{
			scanf("%d",&s);
			qq.push(s);
		}
		for(j=0;j<m-1;j++)	qq.pop();
	}		
	sum=0;
	for(i=0;i<n;i++)	{
		s=qq.top();
		qq.pop();
		sum+=s;
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 4444
gets
$<.map{|e|n,*a,d=e.split.map &:to_i
h={0=>0,1=>d}
f=->x{h[x]||=[x*d,*a.zip([2,3,5]).map{|a,b|[x%b*d+f[x/b],-x%b*d+f[0--x/b]].min+a}].min}
p f[n]}

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

int main() {
  
  string N;
  cin >> N;
  
  if( N.at(0)=='7' || N.at(1)=='7' || N.at(2)=='7' ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}

Measured memory_bytes: 3628
H, W = input().split()
H = int(H)
W = int(W)
if H == 1 or W == 1:
    result = 1
elif H % 2 == 0:
    pre_result = (W + 1) / 2
    even_row = H / 2
    odd_row = H - even_row
    result2 = (pre_result - 1) * even_row
    result1 = pre_result * odd_row
    result = result1+result2
else:
    pre_result = (W + 1) / 2
    even_row = (H-1)/2
    odd_row = H - even_row
    result2 = (pre_result - 1) * even_row
    result1 = pre_result * odd_row
    result = result1+result2
print(int(result))


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
char ch;

while(1){
    scanf("%c",&ch);
	if(ch<91&&ch>64)ch=ch+32;
	else if(ch<123&&ch>96)ch=ch-32;
	printf("%c",ch);
    if ( ch == '\n' ) break;
}

return 0;
}

Measured memory_bytes: 524
#include<stdio.h>

#include<algorithm>
using namespace std;
void print(char str[],int a,int b)
{

    for(int i=a;i<=b;i++)
        printf("%c",str[i]);
    printf("\n");
}
void replace(char str[],char p[],int a,int b)
{
    int p_length=b-a+1;
    for(int i=0;i<p_length;i++)
        str[a+i]=p[i];
}
void reverse(char str[],int a,int b)
{
    int left=a,right=b;
    while(left<right)
    {
        swap(str[left++],str[right--]);
        }
}
int main()
{
    char str[1001],p[1001],order[8];
    int q,a,b;
    scanf("%s",str);
    scanf("%d",&q);
    for(int i=0;i<q;i++)
    {
       scanf("%s %d %d",order,&a,&b);
        switch(order[2])
        {
        case'i':
            print(str,a,b);
            break;
        case'v':
            reverse(str,a,b);
            break;
        case'p':
           scanf("%s",p);
            replace(str,p,a,b);
            break;
        }
    }
}


Measured memory_bytes: 2684
#include<iostream>
#include<map>
using namespace std;
int main()
{
    map<int,int>s;
    int n,m,x,y;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>x;
        s[x]++;
    }
    cin>>m;
    int flag=0;
    for (int i=0;i<m;i++)
    {
        cin>>y;
        if (!s[y])
        {
            flag=1;
        }
        else
            s[y]--;
    }
    if (!flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 9600
N=int(input())
A=[[tuple(map(int,input().split(' ')))for j in range(int(input()))] for i in range(N)]
say_map=[[-1 for i in range(N)] for j in range(N)]
ans = 0
for n,i in enumerate(A):
    for j,k in i:
        say_map[n][j-1]=k
for i in range(2**N):
    i_bin=format(i,'0{}b'.format(N))
    flg = True
    tmp = 0
    for n,j in enumerate(i_bin):
        j = int(j)
        if j == 1:
            tmp += 1
            for k,l in zip(i_bin,say_map[n]):
                if (int(k)==0 and l==1) or (int(k)==1 and l ==0):
                    flg=False
                    break
            if not flg:
                tmp = 0
                break
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 46684
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int n, x, y, res, k;
int main()
{
    cin>>n>>k>>x>>y;
    for(int i = 1; i <= n; ++i)
    {
        if(i <= k)
            res += x;
        else
            res += y;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion


int n;
string str;
set<int> ix[333];
void solve()
{
    cin>>n>>str;
    int q; cin>> q;
    forn(i, n) ix[str[i]].insert(i);

    forn(i, q)
    {
        int type; cin>>type;
        if (type == 1)
        {
            int idx; char c; cin>>idx>>c;
            --idx;
            ix[str[idx]].erase(idx);
            ix[c].insert(idx);
            str[idx] = c;
        }
        else if (type == 2)
        {
            int lf, rg; cin>>lf>>rg;
            --lf, --rg;
            int ans = 0;
            for(char c = 'a'; c <= 'z'; ++c)
            {
                auto it = ix[c].lower_bound(lf);
                if (it!=ix[c].end() && *it <= rg) ++ans;
            }
            cout << ans << '\n';
        }
    }
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 27224
import sys
from heapq import heapify,heappushpop

def main():
    rl=sys.stdin.readline
    n=int(rl().strip())
    a=list(map(int,rl().strip().split()))
    b=[-x for x in a]
    b.reverse()
    fl=a[:n]
    fs=sum(fl)
    ll=b[:n]
    ls=sum(ll)
    fdl=[0]*(n+1)
    ldl=[0]*(n+1)
    heapify(fl)
    heapify(ll)
    for i in range(1,n+1):
        fmn=heappushpop(fl,a[n+i-1])
        lmn=heappushpop(ll,b[n+i-1])
        fdl[i]=fdl[i-1]+a[n+i-1]-fmn
        ldl[i]=ldl[i-1]+b[n+i-1]-lmn
    ldl.reverse()
    dif=max([x+y for x,y in zip(fdl,ldl)])
    print(fs+ls+dif)

if __name__=='__main__':
    main()



Measured memory_bytes: 49636
#include <stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  if(n==10||n==100||n==1000||n==10000||n==100000){
    printf("10");
  }else{
    int a[5];
    a[0] = n%10;
    a[1] = (n%100)-a[0];
    a[2] = (n%1000)-a[0]-a[1];
    a[3] = (n%10000)-a[0]-a[1]-a[2];
    a[4] = (n%100000)-a[0]-a[1]-a[2]-a[3];

     printf("%d",a[0]+(a[1]/10)+(a[2]/100)+(a[3]/1000)+(a[4]/10000));
  }
  return 0;
}

Measured memory_bytes: 128
import numpy as np

S = input().split(" ")
A = int(S[0])
B = int(S[1])
C = int(S[2])

def calculate(a, b, c):

    arr = np.array([a,b,c])

    maxIndex = np.argmax(arr)
    maxValue = arr[maxIndex]

    sl = []
    for index,ar in enumerate(arr):
        if index == maxIndex:
            continue
        sl.append(maxValue - ar)

    if np.sum(sl) % 2 == 1:
        maxValue = maxValue + 1


    brr = np.array([maxValue-a,maxValue-b,maxValue-c])

    s = brr % 2
    print(np.sum(brr//2) + np.sum(s % 2) // 2)

calculate(A, B, C)


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

int M = pow(10,5)*2;

long long int max_ar(long long int *s,int len){
    long long int mx  = s[0];
    for(int i=0;i<len;i++){
        if(s[i]>mx){mx=s[i];}
    }
    return mx;
}

long long int solve(int *a,int head,int tail,int k){
    int len = tail - head;
    if(len<=0 || k==0){
        
        return 0;}
    if(k==1){
        long long int mx = a[head];
        for(int i=head;i<tail;i++){
            if(a[i]>mx){mx = a[i];}
        }
        return mx;
    }
    else if(k*2 > len){
        long long int sum =0;
        int i = head;
        while(i<tail){
            sum += a[i];
            i +=2;

        }
        return sum;
    }
    else {
        int m = len/2;
        int l = k/2;
        if(len%2==0){
            if(k%2==0){
                long long int s1[3];
                s1[0] = a[head+m-1]+solve(a,head,head+m-2,l-1)+solve(a,head+m+1,tail,l);
                s1[1] = a[head+m]+solve(a,head,head+m-1,l)+solve(a,head+m+2,tail,l-1); 
                s1[2] = solve(a,head,head+m-1,l)+solve(a,head+m+1,tail,l);
                return max_ar(s1,3);
            }
            else{
                long long int s2[2];
                s2[0]=a[head+m-1]+solve(a,head,head+m-2,l)+solve(a,head+m+1,tail,l);
                s2[1]=a[head+m]+solve(a,head,head+m-1,l)+solve(a,head+m+2,tail,l);
                return max_ar(s2,2);
            }
            
        }
        else{
            if(k%2==0){
                long long int s3[4];
                s3[0] = a[head+m] + solve(a,head,head+m-1,l) + solve(a,head+m+2,tail,l-1);
                s3[1] = a[head+m] + solve(a,head,head+m-1,l-1) + solve(a,head+m+2,tail,l);
                s3[2] = a[head+m-1] + solve(a,head,head+m-2,l-1) + solve(a,head+m+1,tail,l);
                s3[3] = a[head+m+1] + solve(a,head,head+m,l) + solve(a,head+m+3,tail,l-1);
                return max_ar(s3,4);
            }
            else{
                long long int s4[5];
                s4[0]= a[head+m] + solve(a,head,head+m-1,l)+solve(a,head+m+2,tail,l);
                s4[1]= a[head+m-1]+solve(a,head,head+m-2,l)+solve(a,head+m+1,tail,l);
                s4[2]= a[head+m-1]+solve(a,head,head+m-2,l-1)+solve(a,head+m+1,tail,l+1);
                s4[3]= a[head+m+1]+solve(a,head,head+m,l)+solve(a,head+m+3,tail,l);
                s4[4]= a[head+m+1]+solve(a,head,head+m,l+1)+solve(a,head+m+3,tail,l-1);
                return max_ar(s4,5);

            }
          
        }
    }

}


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


    cout << solve(A,0,N,N/2) << endl;


    return 0;
}

Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
int a[200010], b[200010];
long long pref[200010];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
        pref[i] = pref[i - 1] + b[i];
    }
    long long sum = 0;
    int answer = 0;
    for (int i = 0; i <= n; ++i) {
        sum += a[i];
        if (sum <= k) {
            int x = i;
            x += upper_bound(pref + 1, pref + 1 + m, k - sum) - pref - 1;
            answer = max(answer, x);
        }
    }
    cout << answer;
}

Measured memory_bytes: 6724
N = int(input()); MOD = pow(10,9)+7
A = list(map(int,input().split()))
S = sum(A)**2%MOD
nijo = 0
for x in A:
  nijo = (nijo + x**2)%MOD
ans = (S-nijo)*pow(2,MOD-2,MOD)%MOD
print(ans%MOD)

Measured memory_bytes: 31568
a,b=map(int,input().split())

def prime_factorize(N):
    prime_set=set([1])
    while N%2==0:
        prime_set.add(2)
        N//=2
    
    f=3
    while f*f<=N:
        if N%f==0:
            prime_set.add(f)
            N//=f
        else:
            f+=2
        
    if N!=1:
        prime_set.add(N)

    return prime_set

A=prime_factorize(a)
B=prime_factorize(b)

print(len(A.intersection(B)))


    

Measured memory_bytes: 3060
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let sc = Scanner()
    let s = sc.Next()
    let t = sc.Next()
    let len = String.length s
    let array = [|for i in 0 .. len - 1 -> s.[i+1..len-1] + s.[0..i]|]
    match Array.tryFind (fun (item: string) -> item = t) array with
        | Some _ -> "Yes"
        | None -> "No"
    |> printfn "%s"

    0


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

int main() {
  int64_t N;
  cin >> N;
  
  int a = N / 500 ;
  int b = N - a * 500;
  int c = a * 1000;
  int d = b / 5 * 5;
  
  cout << c + d << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath> 
using namespace std;
char s[100];
int n, m, k;
int main() {
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= m; j++) {
			if(i * m + j * n - i * j * 2 == k) {
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;	
} 

Measured memory_bytes: 128
n = int(input())
c = list(input())
sc = list(reversed(c))
ans = 0
r = 0
flg  = False

if 'W' not in set(c) or 'R' not in set(c):
    print(ans)


else:
    for i in range(n):
        if flg:
            break
        if c[i] == 'W':
            for j in range(r, n):
                r += 1
                if sc[j] == 'R':
                    if n >= i+j+2:
                        c[i] = 'R'
                        c[-1*j-1] = 'W'
                        ans += 1
                        break
                    else:
                        flg = True
                        break

                
            

    print(ans)

Measured memory_bytes: 12004
#include <algorithm>

namespace rika
{
  template <typename T>
  class edge
  {
  public:
    int to;
    T cost;
    
    edge() = default;
    edge(const edge<T>&) = default;
    edge(edge<T>&&) = default;
    edge& operator =(const edge<T>&) = default;
    edge& operator =(edge<T>&&) = default;

    ~edge() = default;

    edge(int _to, T _cost) : to(_to), cost(_cost) {}
  };
}

namespace rika
{
  namespace internal
  {
    template <typename TValue, typename TGraph>
    std::pair<TValue, int> visit(int from, int v, const TGraph &g)
    {
      auto r = std::make_pair(TValue(), v);
      try{
      for(auto it = g[v].begin(); it != g[v].end(); ++it)
      {
        if(it->to == from)
          continue;
        auto r2 = visit<TValue>(v, it->to, g);
        if(r2.first + it->cost >= r.first)
          r = std::make_pair(r2.first + it->cost, r2.second);
      }
      }
      catch (bool x) {}
      return r;
    }
  }

  template <typename TValue, typename TGraph>
  TValue tree_diameter(const TGraph &g)
  {
    using namespace internal;
    auto r1 = visit<TValue>(-1, 0, g);
    auto r2 = visit<TValue>(-1, r1.second, g);
    return r2.first;
  }
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
int main()
{
  int N;
  cin >> N;
  vector<vector<edge<int>>> g(N * 10);
  for(int i = 0; i < N - 1; i++)
  {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back(edge<int>(t, w));
    g[t].push_back(edge<int>(s, w));
  }
  cout << tree_diameter<int>(g) << endl;
}

Measured memory_bytes: 35428
// https://atcoder.jp/contests/abc052/tasks/arc067_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
const int MOD = 1e9 + 7;

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int_fast64_t max_N, int_fast64_t prime_size> struct Prime {
    bool sieve[max_N];
    int_fast64_t prime[prime_size];
    size_t counter = 0;
    constexpr Prime() : sieve(), prime() {
        for (int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        sieve[0] = sieve[1] = false;
        for (int_fast64_t i = 2; i < max_N; ++i) {
            if (sieve[i]) {
                prime[counter] = i;
                ++counter;
                if (counter > prime_size)
                    break;
            }
            for (int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    constexpr auto p = Prime<100000, 9592>();
    ll ans = 1;
    FOR(i, 2, n + 1) {
        // 素数の場合
        if (p.sieve[i]) {
            // n!の中で素因数iは何乗か？
            ll tot = 0;
            for (int j = i; j <= n; j *= i) { // 2,4,8...
                tot += n / j;                 // 12/2 + 12/4 + 12/8
            }
            //約数の個数*(tot+1)%modで更新
            ans = (ans * (tot + 1)) % MOD;
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string n;
  cin >> n;
  char last = n[n.length() - 1];
  if (last == '3') {
    cout << "bon";
  } else if (last == '0' || last == '1' || last == '6' || last == '8') {
    cout << "pon";
  } else {
    cout << "hon";
  }
}


Measured memory_bytes: 3572