akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long

int main() {
    IO;
    string result = "";
    ll num;
    cin>>num;

    while (num > 0) {
      num--;
      int remainder = num % 26;
      char digit = (char) (remainder + 97);
      result = digit + result;
      num = (num - remainder) / 26;
    }
    
    cout<<result<<endl;
  
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
char a, b;
/**********************************/

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


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

int main(){
	int N, A, B, ans=0, x;
	cin >> N >> A >> B;
	for(int i=1; i<=N; i++){
		x=(i/10000)+(i%10000)/1000+(i%1000)/100+(i%100)/10+i%10;
		if(A<=x&&x<=B){
			ans += i;
		}
	}
	cout << ans ;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int p[8], q[8];

signed main() {
	int i;
	
	vector<int> perm;
	
	cin >> n;
	rep(i, n) { cin >> p[i]; p[i]--; }
	rep(i, n) { cin >> q[i]; q[i]--; }
	rep(i, n) perm.push_back(i);
	
	int cnt = 0;
	int a, b;
	do {
		rep(i, n) if (perm[i] != p[i]) break;
		if (i == n) a = cnt;
		rep(i, n) if (perm[i] != q[i]) break;
		if (i == n) b = cnt;
		cnt++;
	} while (next_permutation(perm.begin(), perm.end()));
	
	cout << abs(a - b) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int ans=0;
		Scanner sc = new Scanner(System.in);
		String hako = sc.nextLine();
		char[] c = hako.toCharArray();
		if(c[c.length-1] == 's') {

			System.out.print(hako + "es");
		}
		else {
			System.out.println(hako + "s");
		}
			
	}
}


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

int main(){
    ll n,a[100009],dp[100009];
    cin >> n;
    for(int i=1; i<=n; i++)cin >> a[i];
    dp[n]=0;
    dp[n-1]=abs(a[n]-a[n-1]);
    for(int i=n-2; i>=1; i--){
        dp[i]=min(dp[i+1]+abs(a[i]-a[i+1]),dp[i+2]+abs(a[i]-a[i+2]));
    }
    cout << dp[1] << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  cin>>n;
  ll a[n-1];
  unordered_map <ll,ll> mp{0};
  fo(i,n-1)
  {
    cin>>a[i];
    mp[a[i]]++;
  }
  for(ll i=1;i<=n;i++)
    cout<<mp[i]<<kk;
  return 0;
}

Measured memory_bytes: 12992
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    puts(a<=8 && b<=8 ? "Yay!" : ":(");
}

Measured memory_bytes: 256
//Code by: Nikhil Shukla, MMMUT GKP
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define V vector
#define pb push_back
#define all x x.begin(),x.end()
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc ll t; cin>>t; while(t--)
#define tc1 ll tt=1; while(tt--)
#define fir first
#define sec second
#define mod 998244353
#define out1(x) cout<<x<<"\n";
#define out2(x,y) cout<<x<<" "<<y<<"\n";
#define debug() cout<<"I am in\n";
#define Vll vector<long long>
#define FOR(i,x,n) for(ll i=x;i<n;i++)
#define RFOR(i,x,n) for(ll i=x;i>=n;i--)
////////////////////////////////////////////////////////////////////////////////////////
/*vector<ll>graph[100001];
vector<ll>temp;
vector<bool>visited(100001,false);
//long long count=0;
void dfs(long long node)
{
       // count++;
        temp.pb(node);
        visited[node]=1;
        for(ll i=0;i<graph[node].size();i++)
        {
            if(!visited[graph[node][i]])
            dfs(graph[node][i]);
        }
}*/
void solve(ll n,ll W,ll weight[],ll value[],ll V)
{
    ll dp[n+1][V+1],i,j;
    FOR(i,0,n+1)
    {
        FOR(j,0,V+1)
        dp[i][j]=1000000000000000*(j!=0);
    }
    for(i=1;i<=n;i++)
    {
        ll wi=weight[i-1];
        ll vi=value[i-1];
        for(j=0;j<=V;j++)
        {
            if(vi<=j)
            {
                dp[i][j]=min(wi+dp[i-1][j-vi],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    ll ans=0;
    FOR(i,1,V+1)
    {
        if(dp[n][i]<=W)
        ans=i;
    }
    cout<<ans<<"\n";
}
int main()
{
    fast()
    tc1
    {
        ll n,W;
        cin>>n>>W;
        ll weight[n];
        ll value[n];
        ll V=0;
        FOR(i,0,n)
        {
            cin>>weight[i]>>value[i];
            V+=value[i];
        }
        solve(n,W,weight,value,V);
    }
    return 0;
}


Measured memory_bytes: 82392
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){

    int n;
    scanf("%d", &n);
    vector<int> v(n);
    for(int i = 0; i < n; i++) scanf("%d", &v[i]);
    vector<int> dp(n+1, 0);
    for(int i = 1; i < n; i++){
    	dp[i] = dp[i-1] + abs(v[i] - v[i-1]);
    	if(i >= 2) dp[i] = min(dp[i], dp[i-2] + abs(v[i]-v[i-2]));
    }
    printf("%d\n", dp[n-1]);
	return 0;
}

Measured memory_bytes: 1024
import Data.List.Split (splitOn)
import System.IO (isEOF)

newtype Point = Point (Double,Double)
newtype Vector = Vector (Double,Double)
data Direction = Leftward | Rightward deriving Eq

main = do
    quit <- isEOF
    if quit then return () else do
        input >>= return . test >>= output
        main

input :: IO [Point]
input = do
    line <- getLine
    let
        [x1,y1,x2,y2,x3,y3,x4,y4] = map read $ splitOn "," line
    return [Point (x1,y1), Point (x2,y2), Point (x3,y3), Point (x4,y4)]

output :: Bool -> IO ()
output b = putStrLn (if b then "YES" else "NO")

test :: [Point] -> Bool
test ps = ds `seq` (all (==Leftward) ds || all (==Rightward) ds)
    where
    ds = take (length ps) ds'
    ds' = directions vs'
    vs' = vectors ps'
    ps' = cycle ps

-- infinite points to infinite vectors
vectors :: [Point] -> [Vector]
vectors (p0:p1:ps) = vector p0 p1 : vectors (p1:ps)

vector :: Point -> Point -> Vector
vector (Point (ox,oy)) (Point (px,py)) = Vector (px-ox,py-oy)

-- infinite vectors to infinite directions
directions :: [Vector] -> [Direction]
directions (v0:v1:vs) = direction v0 v1 : directions (v1:vs)

direction :: Vector -> Vector -> Direction
direction (Vector (a,b)) (Vector (c,d))
    | a*d - b*c > 0.0 = Leftward
    | a*d - b*c < 0.0 = Rightward

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

int32 N;
bool ok[21][21];
int64 dp[1 << 21] = {};
int32 idx[1 << 21] = {};

int main(void){
	REP(i, N) idx[1 << i] = i;
	cin >> N;
	REP(i, N){
		REP(j, N){
			cin >> ok[i][j];
		}
	}
	dp[0] = 1;
	REP(j, 1 << N){
		int32 i = __builtin_popcount(j);
		REP(k, N){
			if(ok[i][k] && (j >> k & 1) == 0){
				dp[j | 1 << k] += dp[j];
				dp[j | 1 << k] %= mod;
			}
		}
	}
	cout << dp[(1 << N) -1] << endl;
}


Measured memory_bytes: 16640
import java.util.Scanner;

public class Main
{

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

		int n = Integer.parseInt(sc.next());

		long[] value = new long[n];

		for (int i = 0; i < n; i++) {
			value[i] = Long.parseLong(sc.next());
		}

		boolean minuscount = false;
		long max = 0;

		for (int i = 0; i < n; i++) {
			if (value[i] < 0) minuscount = !minuscount;
		}

		for (int i = 0; i < n; i++) {
			max += Math.abs(value[i]);
		}

		if (minuscount) {
			long min = Math.abs(value[0]);

			for (int i = 0; i < n; i++) {
				if (min > Math.abs(value[i])) {
					min = Math.abs(value[i]);
				}
			}

			max -= min * 2L;
		}

		System.out.println(max);


		sc.close();
	}

}

Measured memory_bytes: 48180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, q; cin >> n >> q;
    vector <int> s(n), t(n), x(n);
    for (int i = 0; i < n; ++ i) {
        cin >> s[i] >> t[i] >> x[i];
    }
    vector <int> d(q);
    for (int i = 0; i < q; ++ i) {
        cin >> d[i];
    }
    vector <pair <int, int> > cmd;
    for (int i = 0; i < n; ++ i) {
        int l = lower_bound(d.begin(), d.end(), s[i] - x[i]) - d.begin();
        int r = lower_bound(d.begin(), d.end(), t[i] - x[i]) - d.begin();
        if (l == r) continue;
        cmd.push_back(make_pair(l, x[i]));
        cmd.push_back(make_pair(r, -x[i]));
    }
    sort(cmd.begin(), cmd.end());
    set <int> st;
    for (int i = 0, j = 0; i < q; ++ i) {
        while (j < cmd.size() && cmd[j].first == i) {
            // cerr << cmd[j].first << " " << cmd[j].second << endl;
            if (cmd[j].second < 0) st.erase(-cmd[j].second);
            else st.insert(cmd[j].second);
            ++ j;
        }
        cout << (st.empty() ? -1 : *st.begin()) << endl;
    }
    return 0;
}


Measured memory_bytes: 16876
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 200, inf = 1e6; int n;
int edge[maxN][maxN], dist[maxN][maxN];

int floydWarshall()
{
  for (int k = 0; k < n; k ++)
    for (int u = 0; u < n; u ++)
      for (int v = 0; v < n; v ++)
      {
        if (edge[u][v] != 0 && dist[k][u] + dist[k][v] < inf && dist[k][u] == dist[k][v])
          return -1;
        dist[u][v] = min(dist[u][v], dist[u][k] + dist[k][v]);
      }
  int ans = 0;
  for (int i = 0; i < n; i ++) ans = max(ans, *max_element(dist[i], dist[i]+n) + 1);
  return ans;
}

int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; i ++)
    for (int j = 0; j < n; j ++)
    {
      scanf("%1d", &edge[i][j]);
      dist[i][j] = edge[i][j] ? 1 : (i != j) *inf;
    }

  int ans = floydWarshall();
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    long double n, k;
    cin >> n >> k;

    long double ans = 0;
    for(long double i = 1.0; i <= n; i += 1.0) {
        int p = ceil(log2(k / i));
        // int p = (int) (log2(k / i)) + 1;
        if(p <= 0) p = 0.0;
        if(i >= k) p = 0.0;
        ans += pow(0.50, p) / n;
        // cout << p << ' '; 
    }
    // cout << endl;

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

    return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	switch {
	case a != b && a != c:
		fmt.Println(a)
	case b != a && b != c:
		fmt.Println(b)
	default:
		fmt.Println(c)
	}
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e4+5;
int num[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i*i<=n;i++)
        for(int j=1;j*j<=n;j++)
            for(int k=1;k*k<=n;k++)
            {
                int sum=i*i+j*j+k*k+i*j+i*k+j*k;
                if(sum<=n)
                    num[sum]++;
            }
    for(int i=1;i<=n;i++)
        printf("%d\n",num[i]);
    return 0;
}


Measured memory_bytes: 1676
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
int main() {
    int n;
    cin >> n;
    int s[n+1]={0};
    rep (i,n){
      cin >> s[i];
    }
    int ma = 0,sum;
    rep (i,n){
      sum=0;
      rep (j,n+1){
        sum+=s[j];
        //cout << sum << " " << s[i] << endl;
        if ((sum-s[i])%10!=0){
          ma = max(ma,sum-s[i]);
          //cout << ma << endl;
        }
      }
      if (sum % 10 != 0){
        ma = max(ma,sum);
        break;
      }
    }
    cout << ma << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main()
{
	int n;
	scanf("%d%*c", &n);
	for (int i = 0; i < n; i++){
		string m;
		
		getline(cin, m);
		while (m.find("Hoshino") != -1){
			m.replace(m.find("Hoshino"), 7, "Hoshina");
		}
		cout << m << endl;
	}
	return (0);
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> check(110, 0);

  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    
    if (x == y) check[i] = 1;
    
  }
  
  
  for (int i = 0; i < N-2; i++) {
    if (check[i] && check[i+1] && check[i+2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  
  cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define N 100010
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int m,n,a[N*2],ma,mi,ansn;
int main(){
	read(n);read(m);
	ma=n*2;mi=0;
	for (int i=1;i<=n*2;i++) read(a[i]);
	sort(a+1,a+n+n+1);
	for (int i=1;i<=n+n;i++){
		int l=1,r=n+n+1,mid;
		while (l<r){
			mid=(l+r)/2;
			if (a[mid]+a[i]<m) l=mid+1;else r=mid;
		}
		if((i+r)%2==0)ma=min(ma,i+r-2);else ma=min(ma,i+r-3);
		if((i+r)%2==1)mi=max(mi,i+r-n-n-1);else mi=max(mi,i+r-n-n);
	}
	ansn=0;
	for (int i=1,j=mi;i<=j;i++,j--)ansn=max(ansn,a[i]+a[j]);
	for (int i=mi+1,j=n+n;i<j;i++,j--) ansn=max(ansn,a[i]+a[j]-m);
	cout<<ansn<<endl;
	return 0;
}

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

using namespace std;

void autoinput()
{
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
}

#define ll long long
#define scan(x) scanf("%lld",&x)
#define pb push_back
#define mp make_pair
const ll mod=(998244353);


ll bigmod(ll N,ll P)
{
    if(P==0) return 1;
    if(P%2==0)
    {
        ll ret=bigmod(N,P/2);
        return ((ret%mod)*(ret%mod))%mod;
    }
    else return ((N%mod)*(bigmod(N,P-1)%mod))%mod;

}


std::vector< ll > v[200005];
ll ans[200005];
map < pair < ll , ll >, ll  > wt;
bool visited[200005];

ll find_w(ll a, ll b)
{
    if(a>b)
        swap(a,b);
    return wt[mp(a,b)];
}
void mw(ll a , ll b, ll w)
{
    v[a].pb(b);
    v[b].pb(a);
    if(a>b)
        swap(a,b);
    wt[mp(a,b)]=w;
}


void dfs(ll x, ll color)
{
    if(visited[x])
        return;
    visited[x]=1;
    for(auto it: v[x])
    {
        if(visited[it])
            continue;
        ll we= find_w(x,it);
        if(we%2==0)
        {
            ans[it]=color;
        }
        else
            ans[it]=1-color;
        dfs(it,ans[it]);
    }

}

int main()
{

   // autoinput();
    memset(ans,-1,sizeof ans);
    ll i,j,k,l,m,n,w;
    cin >> n;
    for(i=0;i<n-1;i++)
    {
        cin >> j >> k >> w;
        mw(j,k,w);

    }
    for(i=1;i<=n;i++)
    {
        if(ans[i]==-1)
        {
            ans[i]=0;
            dfs(i,0);
        }
    }
    for(i=1;i<=n;i++)
    {
        cout << ans[i] <<endl;
    }
}


Measured memory_bytes: 20864
#include <iostream>
#define MOD 1000000007
using namespace std;

int main() {
  long long S; cin >> S;
  long long dp[S + 1];
  for (int i = 0; i <= S; i++) dp[i] = 0;
  for (int i = 3; i <= S; i++){
    dp[i] = 1;
    for (int j = 1; j <= i - 3; j++){
      dp[i] += dp[j];
      dp[i] %= MOD;
    }
  }
  cout << dp[S] << endl;
}

Measured memory_bytes: 3620
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
s=input()
li=[[-1]*10 for i in range(n+1)]
for i in range(n):
    li[-i-2]=li[-i-1][:]
    li[-i-2][int(s[-i-1])]=n-1-i

ans=0
for i in range(1000):
    tmp=str(i)
    while len(tmp)!=3:
        tmp= "0"+tmp
    now=0
    for j in range(3):
        if li[now][int(tmp[j])]==-1:
            break
        now=li[now][int(tmp[j])]+1
        if j==2:
            ans+=1
print(ans)

Measured memory_bytes: 49264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n + 1];
		long[] b = new long[n];
		for(int i = 0; i < n + 1; i++) {
			a[i] = sc.nextLong();
		}
		for(int i = 0; i < n; i++) {
			b[i] = sc.nextLong();
		}
		long cnt = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] >= b[i]) {
				cnt += b[i];
			} else {
				cnt += a[i];
				b[i] -= a[i];
				if(b[i] <= a[i + 1]) {
					a[i + 1] -= b[i];
					cnt += b[i];
				} else {
					cnt += a[i + 1];
					a[i + 1] = 0;
				}
			}
		}
		System.out.println(cnt);

	}

}


Measured memory_bytes: 90756
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val l = new Array[Int](n)
    for (i <- 0 until n) {
      l(i) = sc.nextInt
    }
    val sortedL = l.sorted

    var count = 0
    for (i <- 0 until n - 2; j <- i + 1 until n - 1) {
      val a = sortedL(i)
      val b = sortedL(j)

      val k = sortedL.lastIndexWhere(_ < a + b, n - 1)
      if (k > 0) {
        count += k - j
      }

      // 解説見る前の回答↓
      //      var flg = true
      //      var k = n - 1
      //      while (flg && k >= j + 1) {
      //        val c = sortedL(k)
      //        if (c < a + b) {
      //          flg = false
      //        } else {
      //          k -= 1
      //        }
      //      }
      //      count += k - j
    }
    println(count)
  }
}


Measured memory_bytes: 104740
import math as mt
n,a,b = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
left = mt.ceil(min(h)/a)
right = mt.ceil(max(h)/b)
while left <= right :
    K = mt.floor((left + right) / 2)
    if(left == right):
        print(K)
        break
    else:
        sum = 0
        for i in range(n):
            sum += max(0, mt.ceil((h[i] - K*b)/(a-b)))
        if(sum <= K):
            right = K
        else:
            left = K+1

Measured memory_bytes: 7068
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10, MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a , b;
	cin >> a >> b;
	cout << a * b << '\n';
}

Measured memory_bytes: 3688
import collections
n = int(input())
dic = collections.defaultdict(int)
for _ in range(n):
    s = input()
    dic[s] +=1
sorted_dic = sorted(dic.items(), key = lambda x:(-x[1],x[0]))
val = sorted_dic[0][1]
for k,v in sorted_dic:
    if v==val:
        print(k)


Measured memory_bytes: 62264
n, k = map(int, input().split())
p = list(map(int, input().split()))

Es = [(1+p_i)/2 for p_i in p]

t = sum(Es[0:k])
ans = t

for i in range(n-k):
    t -= Es[i]
    t += Es[i+k]
    ans = max(ans,t)

print(ans)

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

#define fr first
#define sc second

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int NMAX = 2e5 + 1, INF = 1e9 + 19, MOD = 1e9;
ll LINF = 1e18;
const double EPS = 1e-8;
long double PI = 3.141592653589793238462643;

char cc[NMAX];

string getString() {
    scanf("%s", cc);
    return string(cc);
}

bool cmp(ii a, ii b) {
    return a.fr < b.fr;
}

main() {
//    freopen("input.txt", "r", stdin);
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 > x2 || x1 == x2 && y1 > y2) {
        swap(x1, x2), swap(y1, y2);
    }
    bool isNorm = (y1 < y2);
    if (x1 > x2) {
        swap(x1, x2);
    }
    if (y1 > y2) {
        swap(y1, y2);
    }
    int n;
    scanf("%d", &n);
    vector<ii> arr;
    for (int i = 0; i < n; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        if (x >= x1 && x <= x2 && y >= y1 && y <= y2) {
            arr.push_back({x, y});
        }
    }
    n = arr.size();
    int d = x2 - x1 + y2 - y1;
    if (n == 0) {
        printf("%lld", 100ll * d);
        return 0;
    }
    cout.precision(40);
    cout.fixed;
    sort(arr.begin(), arr.end(), &cmp);
    vector<int> dp(n + 1, INF);
    dp[0] = -INF;
    int kek = 0;
    if (!isNorm) {
        for (int i = 0; i < n; ++i) {
            arr[i].sc = -arr[i].sc;
        }
    }
    for (int i = 0; i < n; ++i) {
        int j = lower_bound(dp.begin(), dp.end(), arr[i].sc) - dp.begin();
        if (dp[j - 1] < arr[i].sc && dp[j] > arr[i].sc) {
            dp[j] = arr[i].sc;
            if (kek < j) {
                kek = j;
            }
        }
    }
    int mn = min(x2 - x1, y2 - y1) + 1;
    long double ans = 100ll * d - 20 * kek + kek * 5 * PI + 5 * PI * (kek == mn);
    cout << ans;
}


Measured memory_bytes: 2544
#include <iostream>
#include <algorithm>

using namespace std;


int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    string str = S.substr(K - 1, 1);
    transform(str.begin(), str.end(), str.begin(), ::tolower);


    cout << S.replace(K - 1, 1, str);
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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

	LL ret = 0;
	LL a = 0, b = 0, ab = 0;
	REP(i, N){
		string s;
		cin >> s;
		if(*s.rbegin() == 'A' && *s.begin() == 'B') ab++;
		else{
			if(*s.rbegin() == 'A') a++;
			if(*s.begin() == 'B') b++;
		}
		int n = s.length();
		REP(j, n - 1){
			if(s[j] == 'A' && s[j + 1] == 'B') ret++;
		}
	}

	cerr << a << " " << b << " " << ab << endl;
	if(1 < ab){
		ret += ab - 1;
		ab = 1;
	}
	if(0 < ab && 0 < a && 0 < b){
		ret += 2;
		a--; b--;
		ab = 0;
	}
	else if(0 < ab && 0 < a){
		ret++;
		a--;
		ab = 0;
	}
	else if(0 < ab && 0 < b){
		ret++;
		b--;
		ab = 0;
	}
	int tmp = min(a, b);
	ret += tmp;
	a -= tmp;
	b -= tmp;
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

int main() {
	int n, k; std::cin >> n >> k;
	long long int zero{ n / k};
	long long int half{ ((k & 1) == 0 && (n >= k / 2)) ? (n - k / 2) / k + 1 : 0 };
	std::cout << zero * zero * zero + half * half * half << '\n';
}

Measured memory_bytes: 256
// DPL1_B
#include <bits/stdc++.h>
#define endl "\n"
#define _GLIBCXX_DEBUG //配列外参照エラー表示,gcc依存
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

vector<int> val(110);
vector<int> wei(110);
vector<vector<int>> dp(110,vector<int>(10010,0));
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n,w;
    cin>>n>>w;
    for(int i=1;i<=n;i++) cin>>val[i]>>wei[i];
    for(int i=0;i<=n-1;i++){
        for(int j=0;j<=w;j++){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j+wei[i+1]<=w) dp[i+1][j+wei[i+1]]=max(dp[i+1][j+wei[i+1]],dp[i][j]+val[i+1]);
        }
    }
    cout<<dp[n][w]<<endl;
    return 0;
}


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

int main(){
	vector<int> v;
	int x;

	v.clear();
	for(int i = 0;i < 3;i++){
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());

	int res = v[0] + v[1];

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
//Diameter of a Tree
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct Edge {
public:
    int t, w;
    Edge(int t, int w): t(t), w(w) {}
};

pair<int, int> bfs(int u, int n, vector<vector<Edge>> &G) {
    int v = u, length = 0;
    vector<bool> visited(n, false);
    queue<pair<int, int>> q;
    q.push(make_pair(u, 0));

    while(!q.empty()) {
        int s = q.front().first;
        int l = q.front().second;
        visited[s] = true;
        if(l > length) {v = s; length = l;}
        q.pop();
        for(auto e: G[s]) {
            if(visited[e.t]) continue;
            q.push(make_pair(e.t, e.w + l));
        }
    }
    return make_pair(v, length);
}

int diameter(int n, vector<vector<Edge>> &G) {
    pair<int, int> p = bfs(0, n ,G);
    int x = p.first;
    pair<int, int> q = bfs(x, n ,G);
    return q.second;
}



int main() {
    int n, s, t, w;
    cin >> n;
    vector<vector<Edge>> G(n);
    for(int i = 1; i < n; i++) {
        cin >> s >> t >> w;
        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }

    cout << diameter(n, G) << endl;

    return 0;
}



Measured memory_bytes: 9364
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]){
  long long a, b, x;

  cin >> a >> b >> x;
  long long ans = b/x - a/x;
  if(a%x==0){
    ans += 1;
  }
  cout << ans << endl;
  
  cout << endl;
  return 0;
}



Measured memory_bytes: 384
import sys
from itertools import groupby

readline = sys.stdin.buffer.readline
readline()
b = list(map(int, readline().split()))

b.sort()
# print(b)

x = len(b)
c = [(k, len(tuple(L))) for k, L in groupby(b)]
# print(c)
m = c[-1][0]
# print(m)
s = [True] * (m + 1)
# print(len(s))

a = 0
for i, le in c:
  if s[i]:
    if le <= 1:
      a += 1
    for v in range(i, m + 1, i):
      s[v] = False
# print(s)
print(a)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

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

    vector<int>D(10);
    rep(i,k){
        int d;
        cin>>d;

        D[d]++;
    }

    for(int i=n;i<=100000;i++){
        int N=i;
        bool jdg=true;

        while(N>0){
            if(D[N%10]==1){
                jdg=false;
                break;
            }
            N/=10;
        }

        if(jdg){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

long eulerPhi(long n) {
  if(n==0) return 0;
  long ans = n;
  for(long x=2; x*x<=n; ++x) {
    if(n%x==0){
      ans -= ans/x;
      while(n%x==0) n/=x;
    }
  }
  if(n>1) ans -= ans/n;
  return ans;
}

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

  cout << eulerPhi(n) << endl;

  return 0;
}

Measured memory_bytes: 3100
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut cur = 1;
    for i in 0..n {
        cur = min(cur + k, 2 * cur);
    }
    println!("{}", cur);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
	int N;
	vector<int> vec;

	cin >> N;
	vec.resize(N);
	for (int i = 0; i < N; i++)
		cin >> vec[i];

	int a1 = 0, a2 = 0;
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());

	for (int i = 0; i < N; i++)
	{
		if (i & 1)
			a2 += vec[i];
		else
			a1 += vec[i];
	}
	cout << a1 - a2 << endl;
	return 0;
}

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

int main() {
  long long a, b, c; cin >> a >> b >> c;
  string ans = "No";

  long long rule1 = c - a - b;
  long long rule2 = rule1 * rule1 - 4 * a * b;

  if (rule1 > 0 && rule2 > 0) ans = "Yes";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  print_newline ();
  preorder (fun e -> print_string " "; print_int e) t;
  print_newline ()

let () =
  let m = read_int () in
  let t = ref (create ()) in
  for _ = 0 to m - 1 do
    let op = Scanf.scanf "%s " (fun i -> i) in
    if op = "print" then print !t
    else t := insert (Scanf.scanf "%d " (fun i -> i)) !t
  done

Measured memory_bytes: 32028
N,M = map(int,input().split())
A = list(map(int, input().split()))
S = 0
X = 0
for i in range(N):
    S += int(A[i])

for j in range(N):
    if S%(4*M) == 0:
        if A[j] >= S//(4*M):
            X += 1
    else:
        if A[j] > S//(4*M):
            X += 1
if X >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  int lens = s.size(), lent = t.size();
  vector<vector<int> > f(lens + 1, vector<int>(lent + 1, 0));
  vector<vector<int> > pi(lens + 1, vector<int>(lent + 1, 0));
  for(int i = 1; i <= lens; i++){
    for(int j = 1; j <= lent; j++){
      if(s[i - 1] == t[j - 1]){
        f[i][j] = f[i - 1][j - 1] + 1;
        pi[i][j] = 1;
      }
      if(f[i - 1][j] > f[i][j]){
        f[i][j] = f[i - 1][j];
        pi[i][j] = 2;
      }
      if(f[i][j - 1] > f[i][j]){
        f[i][j] = f[i][j - 1];
        pi[i][j] = 3;
      }
    }
  }
  string ans;
  while(pi[lens][lent] && lens > 0 && lent > 0){
    if(pi[lens][lent] == 1){
      ans.push_back(s[lens-1]);
      lens--; lent--;
    } else if(pi[lens][lent] == 2){
      lens--;
    } else {
      lent--;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		long a[] = new long[n];

		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);

			if (a[i] == 0) {
				System.out.println("0");
				return;
			}
		}

		long sum = 1L;
		long max = 1000000000000000000L;
		for (int i = 0; i < n; i++) {
			if (a[i] <= max / sum) {
				sum *= a[i];
			} else {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 50056
import math
import sys,collections
from sys import stdin, stdout  
#MAXN = 10000001

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip() 
def input(): return sys.stdin.readline().strip()
#spf = [0 for i in range(MAXN)] 
def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w') 
def is_subsequence(x, y):
    """Test whether x is a subsequence of y"""
    x = list(x)
    for letter in y:
        if x and x[0] == letter:
            x.pop(0)

    return not x    
def sieve(): 
	spf[1] = 1
	for i in range(2, MAXN): 
		spf[i] = i 
	for i in range(4, MAXN, 2): 
		spf[i] = 2

	for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
		if (spf[i] == i): 
			for j in range(i * i, MAXN, i): 
				if (spf[j] == j): 
					spf[j] = i 
def getFactorization(x): 
	ret = list() 
	while (x != 1): 
		ret.append(spf[x]) 
		x = x // spf[x] 

	return ret 
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    ind,floor = -1,-1
    while left <= right:
        mid = (left + right) // 2
        '''if A[mid] == x:
            return mid'''
        if x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            ind=mid
            left = mid + 1
            
    return ind
def check(st) : 
  
    # Compute sum of digits 
    n = len(st) 
    digitSum = 0
      
    for i in range(0,n) : 
        digitSum = digitSum + (int)(st[i]) 
  
    # Check if sum of digits 
    # is divisible by 9. 
    return (digitSum % 9 == 0)     
def isPowerOfTwo(n): 
    if (n == 0): 
        return False
    while (n != 1): 
            if (n % 2 != 0): 
                return False
            n = n // 2
            
              
    return True
def kitte(n):
	c=0
	while(n!=0):
		n=n//2
		c+=1
	return c	
def aa(b,c):
	m=min(b,c)
	b-=m
	c-=m
	if(c>0 and b>0):
		return(m+((b+c)//3))
	else:
		return(m)
def bb(a,c):
	m=min(a,c)
	a-=m
	c-=m
	if(c>0 and a>0):
		return(m+((a+c)//3))
	else:
		return(m)
def cc(b,a):
	m=min(b,a)
	b-=m
	a-=m
	if(a>0 and b>0):
		return(m+((b+a)//3))
	else:
		return(m)		
def findProductSum(A, n): 
      
    # calculating array sum (a1 + a2 ... + an) 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = (array_sum + A[i])
  
    # calcualting square of array sum 
    # (a1 + a2 + ... + an)^2 
    array_sum_square = (array_sum * array_sum)
  
    # calcualting a1^2 + a2^2 + ... + an^2 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += (A[i] * A[i])
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    return (array_sum_square - 
            individual_square_sum) // 2		
#file()
#sieve() 
mod=(10**9)+7	
def main():
		n=int(input())
		l=get_array()
		s=0
		s=findProductSum(l,n)
		print(s%mod)		

	



	

	
			


		




		






		







			



	

	




	





















	




















		
			


		

			

		





			

	























				

	















	

	










if __name__ == '__main__':
    main()


Measured memory_bytes: 33316
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int q = sc.nextInt();
		int[] a = new int[q];
		int[] b = new int[q];
		int[] c = new int[q];
		int[] d = new int[q];
		for (int i = 0; i < q; ++i) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
			--a[i];
			--b[i];
			--c[i];
			--d[i];
		}
		int[] cum1 = new int[S.length()];
		int[] cum2 = new int[T.length()];
		for (int i = 0; i < S.length(); ++i) {
			if (i > 0)
				cum1[i] = cum1[i - 1];
			if (S.charAt(i) == 'A') {
				cum1[i] = (cum1[i] + 1) % 3;
			} else {
				cum1[i] = (cum1[i] + 2) % 3;
			}
		}
		for (int i = 0; i < T.length(); ++i) {
			if (i > 0)
				cum2[i] = cum2[i - 1];
			if (T.charAt(i) == 'A') {
				cum2[i] = (cum2[i] + 1) % 3;
			} else {
				cum2[i] = (cum2[i] + 2) % 3;
			}
		}
		for (int i = 0; i < q; ++i) {
			int c1 = (cum1[b[i]] - (a[i] > 0 ? cum1[a[i] - 1] : 0) + 3) % 3;
			int c2 = (cum2[d[i]] - (c[i] > 0 ? cum2[c[i] - 1] : 0) + 3) % 3;
			if (c1 != c2) {
				System.out.println("NO");
			} else {
				System.out.println("YES");
			}
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

using namespace std;
using ll = double;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b;
  cin >> a >> b;

  if (a > b)
    cout << "GREATER"
         << "\n";
  else if (a < b)
    cout << "LESS"
         << "\n";
  else
    cout << "EQUAL"
         << "\n";
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

// std::cmp::Reverse doesn't have Clone.
#[derive(Eq, PartialEq, Clone)]
struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let s: Vec<usize> = util::line()
        .chars()
        .map(|c| (c as u8 - 'a' as u8) as usize)
        .collect();

    let mut a = Vec::new();
    let mut x = 0;
    for &c in &s {
        x ^= 1 << c;
        a.push(x);
    }


    let mut dp = vec![u32::max_value() / 2; 1 << 26];
    dp[0] = 0;

    for &x in a.iter() {
        for k in 0..26 {
            dp[x] = min(dp[x], dp[x ^ (1 << k)] + 1);
        }
    }

    println!("{}", max(1, dp[a.last().cloned().unwrap()]));

}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define OUT(a) cout << (a) << "\n"

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 10e9 + 7;

int main() {
    int k,x;
  	cin >> k >> x;
  	for(int i=x-k+1; i<x+k; i++) {
      cout << i << endl;
    }
    return 0;
}


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

int main(){
	int n,m;
	cin >> n>>m;
	vector<int>h(n+1);
	for(int i = 1; i<=n;i++) cin>>h[i];
	vector<bool>check(n+1,1);

	rep(i,m){
		int a,b;
		cin >> a >> b;
		if(h[a] > h[b])check[b] = 0;
		else if(h[a] < h[b]) check[a] = 0;
		else{
			check[a] = 0;
			check[b] = 0;
		}
	}


	int count=0;
	for(int i =1;i<=n;i++){
		//cout << check[i] << ",";
		if(check[i] == 1)count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
bool a[100011]={0,0,0,1};
int b[100011];
int main()
{
  bool f=true;
  int n,l,r;
  for(int i=5;i<100000;i+=4){
    for(int j=3;j<=sqrt(i);j+=2){
      if(i%j==0){
        f=false;
        break;
      }
    }
    if(f){
      for(int j=3;j<=sqrt((i+1)/2);j+=2){
        if((i+1)/2%j==0){
          f=false;
          break;
        }
      }
    }
    if(f)
      a[i]=true;
    f=true;
  }
  for(int i=1;i<=100000;i++)
    b[i]=b[i-1]+a[i];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>l>>r;
    cout<<b[r]-b[l-1]<<"\n";
  }
  return 0;
}

Measured memory_bytes: 1152
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef long long ll;
typedef long double ld;


//define
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

//ll z[1000001]={0};

int main()
{
    /*
    #ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif
    */
    ll z[10][10];
    forin(i,0,9)
    {
        forin(j,0,9)
        z[i][j]=0;
    }
    fio;
    ll n;
    cin>>n;
    forin(i,1,n)
    {
        ll x=i%10;
        ll i1=i;
        ll p=0;
        while(i1)
        {
            p=i1%10;
            i1/=10;
        }
        z[x][p]++;
    }
    ll ans=0;
    forin(i,0,9)
    {
        forin(j,0,9)
        {
            ans+=(z[i][j]*z[j][i]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256