akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int s, w;
  cin >> s >> w;
  cout << (s > w ? "safe" : "unsafe") << endl;
}

Measured memory_bytes: 3628
import numpy as np 
N, P = map(int, input().split())
A = np.array(list(map(int, input().split())))

even = ((A % 2) == 0).sum()
odd = len(A) - even
flag = True

if (P == 1) & (odd == 0):
  print(0)
  flag = False

if flag:
  if odd == 0:
    print(2**even)
  else:
    print((2**even) * (2**(odd - 1)))

Measured memory_bytes: 12484
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    vector<int> a;
    int sum, diff;
    int ruiseki = 0;
    sum = 0;
    diff = 100000000;

    REP(i, n)
    {
        int t;
        cin >> t;
        sum += t;
        a.push_back(t);
    }
    //sort(a.begin(), a.end());

    REP(i, n)
    {
        ruiseki += a[i];
        diff = min(abs(sum - 2 * ruiseki), diff);
    }
    cout << diff << endl;
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun l ->
    let a = Array.init l (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let min3 a b c     = min a (min b c) in
    let min4 a b c d   = min (min a b) (min c d) in
    let min5 a b c d e = min (min a b) (min3 c d e) in

    let rec loop i f0 f1 f2 f3 f4 =
        if i = l then min5 f0 f1 f2 f3 f4 else
            let g0 = f0 + a.(i) in
            let g1 =
                if a.(i) = 0       then min f0 f1 + 2 else
                if a.(i) mod 2 = 1 then min f0 f1 + 1 else
                                        min f0 f1
            in
            let g2 =
                if a.(i) = 0       then min3 f0 f1 f2 + 1 else
                if a.(i) mod 2 = 1 then min3 f0 f1 f2     else
                                        min3 f0 f1 f2 + 1
            in
            let g3 =
                if a.(i) = 0       then min4 f0 f1 f2 f3 + 2 else
                if a.(i) mod 2 = 1 then min4 f0 f1 f2 f3 + 1 else
                                        min4 f0 f1 f2 f3
            in
            let g4 = a.(i) + min5 f0 f1 f2 f3 f4 in
            loop (i + 1) g0 g1 g2 g3 g4
    in
    loop 0 0 0 0 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 7520
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 //	ios::sync_with_stdio(0);
 //   cin.tie(0);
    lli n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    lli a[n]={0},k=0;
    for(lli i=0;i<n-1;i++){
    	if(s[i]=='A' && s[i+1]=='C'){
    		i++;
    		a[i]++;
		}
	}
	for(lli i=1;i<n;i++)a[i]=a[i-1]+a[i];
    //couta(a,n);cout<<endl;
    while(q--){
    	lli x,y;cin>>x>>y;
    	x--,y--;
		cout<<a[y]-a[x]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=10000;

int main(){
	int X;
	cin>>X;
	if(X==7||X==5||X==3)cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,dp[100005];
int DP(int x)
{
	if(x<0) return 1e8;
	if(x==0) return 0;
	if(dp[x]!=-1) return dp[x];
	dp[x]=1e8;
	for(int i=6;i<=x;i*=6)
		dp[x]=min(dp[x],DP(x-i)+1);
	for(int i=9;i<=x;i*=9)
		dp[x]=min(dp[x],DP(x-i)+1);
	dp[x]=min(dp[x],DP(x-1)+1);
	return dp[x];
}
int main()
{
	scanf("%d",&n);
	memset(dp,-1,sizeof dp);
	printf("%d\n",DP(n));
	return 0;
}


Measured memory_bytes: 1024
M,D = map(int,input().split())
ans = 0
for m in range(1,M+1):
    for d in range(10,D+1):
        d1 = d%10
        d10 = (d-d1)//10
        if d1 >= 2 and d10 >= 2:
            if d1*d10 == m:
                ans += 1
print(ans)

Measured memory_bytes: 40304
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
using namespace std;

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

	long nB[100000];
	long nA[100000];
	memset(nA, 0, sizeof(nA));
	memset(nB, 0, sizeof(nB));

	long lX = 0;
	long lnPrev = 0;
	for (int i = 0; i < N-1; i++)
	{
		cin >> nB[i];
	}
	for (int i = 0; i < N; i++)
	{
		if (i == 0)
			nA[i] = nB[i];
		else if (i == N - 1)
			nA[i] = lnPrev;
		else
		{
			if (lnPrev < nB[i])
				nA[i] = lnPrev;
			else
				nA[i] = nB[i];
		}
		lnPrev = nB[i];
	}

	long lnSum = 0;
	for (int i = 0; i < N; i++)
		lnSum += nA[i];

	cout << lnSum;
	return 0;
}


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

string s, t;
int sn, tn, ans;

int main() {
	cin >> s >> t;
	sn = s.size();
	tn = t.size();

	ans = tn;

	for (int i = 0; i < sn - tn + 1; ++i) {
		int c = 0;
		for (int j = 0; j < tn; ++j) {
			if (s[i + j] != t[j])
				++c;
		}
		ans = min(c, ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    System.out.println(dfs(h));
  }

  public static int dfs(int[] hana) {
    int m = 100;
    for(int i = 0; i < hana.length; i++) {
      m = Math.min(m, hana[i]);
    }
    int ans = m;
    for(int i = 0; i < hana.length; i++) {
      hana[i] -= m;
    }
    int p = -1;
    int q = -1;
    int t = 0;
    for(int i = 0; i < hana.length; i++) {
      if(hana[i] > 0) {
        if(t == 0) {
          p = i;
          t = 1;
        } else {

        }
      } else {
        if(t == 1) {
          q = i - 1;
          t = 0;
          int[] hana2 = new int[q - p + 1];
          for(int j = 0; j < q - p + 1; j++) { 
            hana2[j] = hana[j + p];
          }
          ans += dfs(hana2);
          p = -1;
        }
      }
      if((i == hana.length - 1) && (p != -1)) {
        q = hana.length - 1;
        int[] hana2 = new int[q - p + 1];
        for(int j = 0; j < q - p + 1; j++) { 
          hana2[j] = hana[j + p];
        }
        ans += dfs(hana2);
      }
    }
    return ans;
  }
}


Measured memory_bytes: 35612
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main() {
	string s; cin>>s;
	rep(i,3) cout<<s[i];
	cout<<endl;


	return 0;
}


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

int main(){
    int N;
    static int64_t L, X[300000], T[300000];
    cin >> N >> L;
    for(int i=0; i<N; i++) cin >> X[i];
    for(int i=0; i<N; i++) cin >> T[i];

    int64_t C = 0;
    int A[300000];
    for(int i=0; i<N; i++){
        int64_t c = (T[i]-1) / (2*L);
        C += c;
        T[i] -= c * 2 * L;
        A[i] = (T[i] > 2*(L-X[i])) * 2 + (T[i] > 2*X[i]);
    }

    bitset<300000> deleted;
    deque<int> q0, q2;
    int p1max = -1, p2max = -1, delmax = -1;
    int rem = 0;
    for(int i=0; i<N; i++){
        if(A[i] == 1){
            if(q0.size()){
                deleted[q0.front()] = deleted[i] = true;
                p1max = max(p1max, q0.front());
                p2max = max(p2max, i);
                q0.pop_front();
                C++;
            }
        }else if(A[i] == 0){
            if(q2.size()){
                deleted[q2.front()] = deleted[i] = true;
                p1max = max(p1max, q2.front());
                p2max = max(p2max, i);
                q2.pop_front();
                C++;
            }else{
                q0.push_back(i);
            }
        }else if(A[i] == 2){
            q2.push_back(i);
        }else if(A[i] == 3){
            C++;
            deleted[i] = true;
            delmax = max(delmax, i);
        }
    }

    int d = q0.size()/2;
    for(int i=0; i<d; i++){
        p1max = max(p1max, q0[i]);
        p2max = max(p2max, q0[i+d]);
        deleted[q0[i]] = deleted[q0[i+d]] = true;
        C++;
    }

    int livemax = -1;
    for(int i=0; i<N; i++) if(!deleted[i]){
        C++;
        livemax = max(livemax, i);
    }
    if(delmax > max(livemax, p2max) || p1max > livemax || A[livemax] == 2) C++;

    int64_t ans = C * 2 * L;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int a[200010], b[200010]; 
int main() {
	int n;
	cin >> n;
	rep(i,n) cin >> a[i+1];

	int m = 0;
	for (int i = n; i >= 1; i--)
	{
		int sum = 0;
		for (int j = i; j <= n; j += i) sum += b[j];
		if (sum % 2 != a[i]) {
			b[i]++;
			m++;
 		}
	}
	
	cout << m << endl;
	rep(i,n) {
		if (b[i+1]) cout << i+1 << ' ';
	}
	if (m > 0) cout << endl;
	return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

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

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int h, w;
    cin >> h >> w;
    pair<int, int> start, goal;
    cin >> start.first >> start.second >> goal.first >> goal.second;
    start.first--;
    start.second--;
    goal.first--;
    goal.second--;
    vector<string> vs(h);
    REP(i, h)
    cin >> vs[i];
    vector<vector<int>> cost(h, vector<int>(w, -1));
    cost[start.first][start.second] = 0;
    queue<pair<int, int>> Q;
    queue<pair<int, int>> Q2;
    Q.push(start);
    int a = 0;
    while (!Q.empty()) {
        while (!Q.empty()) {
            pair<int, int> q = Q.front();
            Q.pop();
            Q2.push(q);
            REP(i, 4)
            {
                if (WRAP(q.first + dy[i], q.second + dx[i], h, w)) {
                    if (vs[q.first + dy[i]][q.second + dx[i]] == '.') {
                        if (cost[q.first + dy[i]][q.second + dx[i]] == -1 || cost[q.first + dy[i]][q.second + dx[i]] > a) {
                            cost[q.first + dy[i]][q.second + dx[i]] = a;
                            Q.push({ q.first + dy[i], q.second + dx[i] });
                        }
                    }
                }
            }
        }
        while (!Q2.empty()) {
            pair<int, int> q = Q2.front();
            Q2.pop();
            REP(i, 5)
            {
                REP(j, 5)
                {
                    if (WRAP(q.first + i - 2, q.second + j - 2, h, w)) {
                        if (vs[q.first + i - 2][q.second + j - 2] == '.') {
                            if (cost[q.first + i - 2][q.second + j - 2] == -1 || cost[q.first + i - 2][q.second + j - 2] > a + 1) {
                                cost[q.first + i - 2][q.second + j - 2] = a + 1;
                                Q.push({ q.first + i - 2, q.second + j - 2 });
                            }
                        }
                    }
                }
            }
        }
        a++;
    }
    cout << cost[goal.first][goal.second] << endl;
}

Measured memory_bytes: 9448
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
#define endl "\n"
//use emplace_back() instead of push_back()
const ll mod=1e9+7;
template<typename T>
void print(T t)
{
    for(const auto& e:t)cout<<e<<" ";
    cout<<endl;
}
ll power(ll x, ll y, ll p) 
{ 
    int res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
} 
vector<int>g[1000001];
int vis[1000001];    
int in[100001];
int low[100001];
int timer=0;
vector<pair<int,int> >v;
int f;
void dfs(int n,int p)
{
    vis[n]=1;
    low[n]=in[n]=timer++;    
    if(timer!=1)v.push_back({p,n});
    for(auto ch:g[n])
    {
        if(ch==p)continue;
        if(vis[ch])
        {
            low[n]=min(low[n],in[ch]);
            if(in[n]>in[ch])v.push_back({n,ch});
        }
        else
        {
            dfs(ch,n);
            if(in[n]<low[ch]){f=1;return;}            
            low[n]=min(low[n],low[ch]);
        }
    }    
}
ll josephus(ll n) 
{
    ll p = 1; 
    while (p <= n) 
        p *= 2; 
    return (2 * n) - p + 1; 
}

bool isprime(ll n)
{
    if(n==1)return false;
    for(ll i=2;i*i<=n;i++)
    if(n%i==0)return false;
    return true;
}
vector<ll>aa;
void printallpf(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
            {
                aa.push_back(i);
                if(i!=n/i)
                if(isprime(n/i))aa.push_back(n/i),n=i;
                n=n/i;
            }
            
        }
    }    
}
void primeFactors(int n)  
{
       while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  for (int i = 3; i <= sqrt(n); i = i + 2)  
    {    
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }
    if (n > 2)  
        cout << n << " ";  
}  
int dsu[100001];
void dsuunion(int u,int v)
{
	dsu[v]+=dsu[u];
	dsu[u]=v;
}
ll find(int a)
{
	if(dsu[a]<0)return a;
	else
	return dsu[a]=find(dsu[a]);
}
ll nod(ll x)
{
	ll cnt=0;
	while(x)
	{
		x=x>>1;
		cnt++;
	}
	return cnt;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin>>x;
    for(ll i=-200;i<201;i++)
    {
		ll f=0;
		for(ll j=-200;j<201;j++)
		{
			ll a=powl(i,5);
			ll b=powl(j,5);
			if((a-b)==x)
			{
				cout<<i<<" "<<j<<endl;
				f=1;
				break;				
			}
		}
		if(f)break;
	}
    return 0;
}


Measured memory_bytes: 27152
from collections import Counter
while 1:
  h,w=map(int,input().split())
  if h==w==0:break
  xs,ys=[0],[0]
  for _ in range(h):ys+=[ys[-1]+int(input())]
  for _ in range(w):xs+=[xs[-1]+int(input())]
  print(sum(c*c-c for c in Counter(x-y for y in ys for x in xs).values())//2)

Measured memory_bytes: 56176
<?php
$hoge=array();
while($hoge[]=trim(fgets(STDIN))){}
$hage=array_count_values($hoge);
$max = max($hage);
$koge= array_keys($hage,$max);
sort($koge,SORT_ASC);
foreach ($koge as $val) {
    echo $val.PHP_EOL;
}
?>


Measured memory_bytes: 9316
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool InBounds(const vector<string> &mat, int x, int y)
{
    return 0 <= x && x < (int)mat.size() && 0 <= y && y < (int)mat[x].size();
}

bool ValidCell(const vector<string> &mat, int x, int y)
{
    constexpr char kBlack = '#';
    const vector<pair<int, int>> kMods = { {-1, 0}, {0, 1}, {1, 0}, {0, -1} };

    if (mat[x][y] != kBlack) {
        return true;
    }

    for (const auto &mod : kMods) {
        int cx = x + mod.first;
        int cy = y + mod.second;

        if (InBounds(mat, cx, cy) && mat[cx][cy] == kBlack) {
            return true;
        }
    }
    return false;
}

int main()
{
    int rows, cols;
    cin >> rows >> cols;
    cin.get();

    vector<string> mat(rows);
    for (auto &row : mat) {
        getline(cin, row);
    }

    auto valid = true;
    for (int i = 0; i < rows; i += 1) {
        for (int j = 0; j < cols; j += 1) {
            if (!ValidCell(mat, i, j)) {
                valid = false;
            }
        }
    }

    cout << (valid ? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	var N int = nextInt()
	var L []int = make([]int, N)
	for i := 0; i < N; i++ {
		L[i] = nextInt()
	}
	sort.Ints(L)
	var result int
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			for k := j + 1; k < N; k++ {
				if L[i] != L[j] && L[j] != L[k] && L[k] != L[i] {
					if L[k] < L[i]+L[j] {
						result++
					}
				}
			}
		}
	}
	fmt.Println(result)
}


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


int main() {
    int n;
    int a[1000] = { 0 };
    int flag = 1;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    for (int i = 0; i < n; i++) {
        if (a[i] % 2==0) {
            if (a[i] % 3!=0 && a[i] % 5 != 0) flag = 0;
        }
    }
    if (flag) printf("APPROVED");
    else printf("DENIED");
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int m = 0;
    List<Integer> list = new ArrayList<>();
    for(int i = 1; i < k + 1; i++){
        for(int j = 1; j < k + 1; j++){
            for(int l = 1; l < k + 1; l++){
                m = gcd(i,j);
                list.add(gcd(m,l));
            }
        }
    }
    int sum = 0;
    for(int i = 0 ; i < k*k*k ; i++){
        sum += list.get(i);
    }
    System.out.println(sum);
    
}

static int gcd (int a, int b) {
	int temp;
	while((temp = a%b)!=0) {
		a = b;
		b = temp;
	}
	return b;
}


}

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

int main(){
    int n,x;
    cin >> n >> x;
    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int a[n];
    for(int i = 0; i < n; i++){
        a[i] = abs(x - p[i]);
    }
    int ans = a[0];
    for(int i = 1; i < n; i++){
        ans = __gcd(ans,a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n,ans = 1;
    double T,A;
    cin >> n >> T >> A;
    vector<double> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
        h[i] = T-h[i]*0.006;
        h[i] = abs(h[i]-A);
    }
    double mn = h[0];
    for (int i = 1; i < n; ++i) {
        if(mn > h[i]){
            mn = h[i];
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = [0] * N
for i in range(N, 0, -1):
    sum = 0
    for j in range(i*2, N+1, i):
        sum += b[j-1]
    if sum % 2 == 0:
        b[i-1] = a[i-1]
    else:
        b[i-1] = 1 - a[i-1]
count = b.count(1)
print(b.count(1))
if count > 0:
    ans = ''
    for i in range(1, N+1):
        if b[i-1] == 1:
            ans += str(i) + ' '
    print(ans[:-1])


Measured memory_bytes: 10036
N, M = map(int, input().split())
results = {}
penalty = 0
acs = 0

for i in range(M):
    ans = input().split()
    try:
        results[ans[0]].append(ans[1])
    except KeyError:
        results[ans[0]] = [ans[1]]

for data in results.values():
    if "AC" in data:
        acs += 1
        penalty += data[:data.index("AC")].count("WA")

print(acs, penalty)

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

sum=0
for i in range(1,n+1):
  dumy=0
  for j in range(5):
    dumy+=i%10**(j+1)//10**j
  if dumy>=a:
    if dumy<=b:
      sum+=i
    
  
print(sum)

Measured memory_bytes: 40176
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define MP make_pair
#define int ll int

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef map<int,int>MII;
typedef vector<int> VI;
const int MAX = 1e4 + 5;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
//int root(int x){return x==f[x]?x:f[x]=root(f[x]);}


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int n;
    cin>>n;vector<PPII>re;MII mr;
    for(int i=0;i<n;i++)
    {
        int x,l;
        cin>>x>>l;
        re.pb({{x-l,1},i});
        re.pb({{x+l,-1},i});
    }
    sort(all(re));int max1=0;
    for(int i=0;i<2*n;i++)
    {
        if(re[i].FI.SE==1)
        {
            mr[re[i].SE]=max(mr[re[i].SE],max1);
        }
        else
        {
            max1=max(max1,mr[re[i].SE]+1);
        }
    }
    cout<<max1<<endl;
}


return 0;
}





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

using namespace std;

typedef long long ll;
typedef long double ld;

string s;

ll cur=0LL;
ll ans=0LL;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>s;
    for(auto &it:s)
    {
        if(it=='B')
        {
            cur++;
        }
        else
        {
            ans+=cur;
        }
    }
    cout<<ans<<"\n";
    return 0;
}
/**


**/


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

int main(){
  string s;cin>>s;
  char c='<';ll num=0LL;
  vector<ll> count;
  for(int i=0;i<s.size();i++){
  	if(s[i]!=c){
      count.push_back(num);
      num=1LL;
    }else{
      num++;
    }
    c=s[i];
  }
  count.push_back(num);
  ll ans=0;
  for(int i=0;i+1<count.size();i+=2)ans-=min(count[i], count[i+1]);
  for(auto &e: count){
  	ans+=(e+1)*e/2;
  }
  cout<<ans<<endl;
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

// -1: 左から落ちる、0: 落ちない、1: 右から落ちる
int64_t simulate(const string& s, const vector<pair<char, int64_t>>& spells,
                 int64_t idx) {
    int64_t n = s.size();

    for (const auto& spell : spells) {
        if (spell.first == s[idx]) {
            idx += spell.second;

            if (idx < 0) {
                return -1L;
            }
            if (idx >= n) {
                return 1L;
            }
        }
    }

    return 0L;
}

int main() {
    int64_t n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<pair<char, int64_t>> spells(q);
    for (auto&& sp : spells) {
        char d;
        cin >> sp.first >> d;

        assert('A' <= sp.first && sp.first <= 'Z');
        assert(d == 'L' || d == 'R');

        sp.second = (d == 'R' ? 1 : -1);
    }

    auto r = irange(0L, n);
    auto it1 = partition_point(r.begin(), r.end(), [&](int64_t idx) {
        return simulate(s, spells, idx) < 0;
    });
    auto it2 = partition_point(r.begin(), r.end(), [&](int64_t idx) {
        return simulate(s, spells, idx) <= 0;
    });

    cout << it2 - it1 << endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	if(n%2==1) {
		int a=1,b=n;
		for(int i=1;i<=m;++i) {
			printf("%d %d\n",a,b);
			a++;
			b--;
		}
		return 0;
	}
	else {
		int a=1,b=1+m,cnt=0;
		while(a<b&&cnt<m) {
			printf("%d %d\n",a,b);
			a++,b--;
			++cnt;
		}
		a=m+2;
		b=2*m+1;
		while(a<b&&cnt<m) {
			printf("%d %d\n",a,b);
			a++,b--;
			++cnt;
		}
//		printf("%d\n",cnt);
	}
}

Measured memory_bytes: 3820
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

template<class T> void swap(T &a, T &b ){
    T temp;
    temp = a;
    a = b;
    b = temp;   
}

int main(){
    int N;
    int ans;
    int i;

    ans = 1;
    cin >> N;
    for(i=0;i<3;i++){
        ans *= N;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	char s[100001];
	int n, a, b, pass = 0, fpass = 0;
	scanf("%d%d%d", &n, &a, &b);
	scanf("%s", s);
	for (int i = 0; i < strlen(s); i++) {
		if (s[i] == 'a') {
			if (pass < a + b) {
				printf("Yes\n");
				pass++;
			} else {
				printf("No\n");
			}
		} else if (s[i] == 'b') {
			if (pass < a + b && fpass < b) {
				printf("Yes\n");
				fpass++;
				pass++;
			} else {
				printf("No\n");
			}
		} else {
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n,res = 0,now = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        char c;
        cin >> c;
        if(c=='I') now ++;
        else now--;
        res = max(res,now);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
int ball[100005];
int mark[100005];

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

	for (int i = 1; i <= n; i++) {
		ball[i] = 1;
		mark[i] = 0;
	}

	mark[1] = 1;

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		if (mark[x]) mark[y] = 1;
		ball[x]--;
		ball[y]++;
		if (ball[x] == 0) mark[x] = 0;
	}

	int ans = 0;

	for (int i = 0; i <= n; i++) {
		if (mark[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define mod 1000000007
typedef struct{
    int penalty;
    int ac;
}Q;
int main(void){
    int n,m; cin >> n >> m;
    Q q[100010];
    rep(i,m){
        q[i].penalty = q[i].ac = 0;
    }
    int ansl=0,ansr=0;
    rep(i,m){
        int p; string s; cin >> p >> s;
        p--;
        if(q[p].ac == 0){
            if(s=="AC"){
                q[p].ac = 1;
                ansl++;
                ansr += q[p].penalty;
            }else{
                q[p].penalty++;
            }
        }
    }
    cout << ansl << " " << ansr << endl;
}





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

constexpr int mod = 1e9 + 7;

int dp[301][301][301];

void add(int& x, int y) {
    x += y;
    if(x >= mod) x -= mod;
}

struct segment {
    int l, x;
    segment(int l_, int x_) : l(l_), x(x_) {}
};

int main() {
    int n, m; cin >> n >> m;
    vector<vector<segment>> seg(n + 1);
    for(int i = 0; i < m; ++i) {
        int l, r, x; cin >> l >> r >> x;
        seg[r].emplace_back(l, x);
    }

    //vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(n + 1, vector<int>(n + 1)));
    dp[0][0][0] = 1;
    for(int rp = 0; rp < n; ++rp) {
        for(int i = 0; i <= rp; ++i) {
            for(int j = i; j <= rp; ++j) {
                array<int, 3> max_v = {{0, 0, rp + 1}}, cur = {{i, j, rp}};
                do {
                    do {
                        array<int, 3> nxt;
                        for(int k = 0; k < 3; ++k) {
                            nxt[k] = max(cur[k], max_v[k]);
                        }
                        add(dp[nxt[0]][nxt[1]][nxt[2]], dp[cur[0]][cur[1]][cur[2]]);
                    } while(next_permutation(max_v.begin(), max_v.end()));
                } while(next_permutation(cur.begin(), cur.end()));
            }
        }

        const int r = rp + 1;
        for(auto const& s : seg[r]) {
            const int l = s.l;
            if(s.x == 1) {
                for(int i = 0; i < r; ++i) {
                    for(int j = l; j < r; ++j) {
                        dp[i][j][r] = dp[i][r][j] = dp[r][i][j] = 0;
                        dp[j][i][r] = dp[j][r][i] = dp[r][j][i] = 0;
                    }
                }
            } else if(s.x == 2) {
                for(int i = 0; i < l; ++i) {
                    for(int j = 0; j < l; ++j) {
                        dp[i][j][r] = dp[i][r][j] = dp[r][i][j] = 0;
                    }
                }
                for(int i = l; i < r; ++i) {
                    for(int j = l; j < r; ++j) {
                        dp[i][j][r] = dp[i][r][j] = dp[r][i][j] = 0;
                    }
                }
            } else if(s.x == 3) {
                for(int i = 0; i < l; ++i) {
                    for(int j = 0; j < r; ++j) {
                        dp[i][j][r] = dp[i][r][j] = dp[r][i][j] = 0;
                        dp[j][i][r] = dp[j][r][i] = dp[r][j][i] = 0;
                    }
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i; j < n; ++j) {
            vector<int> idx = {i, j, n};
            do {
                add(ans, dp[idx[0]][idx[1]][idx[2]]);
            } while(next_permutation(idx.begin(), idx.end()));
        }
    }

    cout << ans << endl;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<P> a(n);
    for (int i = 0;i < n;++i) cin >> a[i].first >> a[i].second;
    sort(a.begin(),a.end());
    int ans = 0;
    int mn1,mn2,mx1,mx2;
    mn1 = mn2 = INT_MAX;
    mx1 = mx2 = 0;
    for (int i = 0;i < n;++i) {
        if (a[i].second <= mn1) {
            mn1 = a[i].second;
            mx1 = a[i].first;
        }
        if (a[i].first > mx2) {
            mx2 = a[i].first;
            mn2 = a[i].second;
        }
    }
    for (int i = 0;i < n;++i) ans = max(ans,a[i].second-a[i].first+1+max(0,mn1-mx2+1));
    multiset<P> st1;
    multiset<int> st2;
    for (int i = 0;i < n;++i) {
        if (a[i].second != mn1 && a[i].first != mx2) {
            st1.insert(a[i]);
        }
        if (a[i].first == mx2) st2.insert(a[i].second);
    }
    st1.insert(P(-1,INT_MAX));
    if (!st1.empty()) {
        auto p = prev(st1.end());
        while (1) {
            // st1.erase(p);
            // if (p->second > mn1) continue;
            ans = max(ans,max(0,mn1-max(mx1,p->first)+1)+max(0,*st2.begin()-mx2+1));
            st2.insert(p->second);
            if (p == st1.begin()) break;
            p--;
        }
        if (!st2.empty()) ans = max(ans,mn1-mx1+1+max(0,*st2.begin()-mx2+1));
        cout << ans << endl;
    } else {
    }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 100005;

/*
	dp[i][j] : prob to have j heads among i tossed coins
*/

double dp[3005][3005];
int main(){
	fastio;
	int n;
	cin >> n;
	vector<double> p(n+1);
	for(int i = 1; i <= n; i++)
		cin >> p[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){ // tosses
		for(int j = 0; j <= i; j++){ // heads
			dp[i][j] = (j > 0 ?(dp[i-1][j-1] * p[i]):0) + (dp[i-1][j] * (1-p[i]));
		}
	}
	double ans = 0;
	for(int i = n/2+1; i <= n; i++)
		ans += dp[n][i];
	cout << fixed << setprecision(10) << ans << '\n';
	return 0;
}


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

using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const ll MAXN = 2e6 + 10, inf = 1e18, mod = 1e9 + 7;

struct pair_hash {
	template <class T1, class T2>
	std::size_t operator () (const std::pair<T1,T2> &p) const {
		auto h1 = std::hash<T1>{}(p.first);
		auto h2 = std::hash<T2>{}(p.second);

		return h1 ^ h2;  
	}
};

ll pw(ll te, ll tee) {
	if (tee == 0)	return 1;
	ll res = pw(te, tee / 2);
	return (tee % 2 ? te * res * res : res * res);
}
ll k, a[60];

void Read_input() {
	cin >> k;
	if (k == 0) {
		cout << 4 << endl;
		cout << 3 << " " << 3 << " " << 3 << " " << 3;
		exit(0);
	}
}

void Solve() {
	for (ll i = 1; i <= 50; i++)	a[i] = i - 1;
	ll t = (k - 1) / 50;
	k %= 50;
	for (ll i = 1; i <= 50; i++)	a[i] += t;
	if (k == 0)
		for (ll i = 1; i <= 50; i++)	a[i]++;
	else {
		for (ll i = 1; i <= k; i++) {
			sort(a + 1, a + 51);
			a[1] += 50;
			for (ll j = 2; j <= 50; j++)	a[j]--;
		}
	}
	cout << 50 << endl;
	cout << a[1];
	for (ll i = 2; i <= 50; i++)	cout << " " << a[i];
}


int main() {

	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	//freopen("input.txt", "r", stdin),	freopen("output.txt", "w", stdout);

	Read_input(),	Solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
 
#define INF (int)1e9+7
 
static const int dy[4] = {0,1,0,-1};
static const int dx[4] = {1,0,-1,0};
 
using namespace std;
 
int cnt[100010];

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

    int a = 0;
    cnt[0] = 0;
    for(int i = 1; i < s.size(); i++){
        if(s[i-1] == 'A' && s[i] == 'C'){
            a++;
        }
        cnt[i] = a;
    }

    rep(i, q){
        int li, ri;
        cin >> li >> ri;
        li--;
        ri--;
        cout << cnt[ri] - cnt[li] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string a;
	int l,num=0,x;
	while((cin>>a)!=0){
		x=0;
		l=a.size();
		for(int i=0;i<l;i++){
			if(a[i]>47&&a[i]<58){
				num=num-x;
				x=x*10+a[i]-48;
				num=num+x;
			}
			else x=0;	
		}
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 0
#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;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 g[510][510] = {};
vector<int> visited;
int64 N;

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

    cin >> N;
    int64 cnt = 0;
    while ((1LL << cnt) < N) cnt++;
    for (int i = cnt-1; i >= 0; i--) {
        REP(j, N) {
            REP(k, N) {
                if ((j >> i & 1 != k >> i & 1) && (j >> (i+1)) == (k >> (i+1))) {
                    g[j][k] = g[k][j] = i+1;
                }
            }
        }
    }
    REP(i, N) {
        FOR(j, i+1, N) {
            cout << g[i][j] << " ";
        }
        cout << endl;
    }
}



Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(){
    int H, W;
    cin >> H >> W;
    for(int i = 0; i < W + 2; i++){
        cout << "#";
    }
    cout << endl;
    for(int i = 0; i < H; i++){
        string text;
        cin >> text;
        cout << "#" << text << "#" << endl;
    }
    for(int i = 0; i < W + 2; i++){
        cout << "#";
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());
        
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int i=A; i<B; i++){
            map.put(i, 1);
        }
        
        int ans = 0;
        for(int i=C; i<D; i++){
            if(map.get(i) != null){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()
a = li()

#max, minとる
amax = max(a)
amin = min(a)
key = 0
key_idx = 0

if abs(amax) >= abs(amin):
    key = amax
    key_idx = a.index(amax) + 1
else:
    key = amin
    key_idx = a.index(amin) + 1
    
anew = [ai + key for ai in a]

print(2*n-1)
for i in range(1,n+1):
    print(key_idx, i)
if key >= 0:
    for i in range(1,n):
        print(i,i+1)
else:
    for i in range(n,1,-1):
        print(i, i-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long INF = 10000000000000;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  int V = N + 2;
  vector<map<int, long long>> E(V);
  long long ans = 0;
  for (int i = 0; i < N; i++){
    if (a[i] > 0){
      ans += a[i];
      E[N][i] = a[i];
      E[i][N + 1] = 0;
    } else {
      E[N][i] = 0;
      E[i][N + 1] = abs(a[i]);
    }
  }
  for (int i = 1; i <= N; i++){
    for (int j = i * 2; j <= N; j += i){
      E[j - 1][i - 1] = INF;
    }
  }
  while (1){
    vector<long long> flow(V, INF);
    vector<int> prev(V, -1);
    prev[N] = N;
    queue<int> Q;
    Q.push(N);
    while (!Q.empty()){
      int v = Q.front();
      Q.pop();
      for (auto edge : E[v]){
        int w = edge.first;
        long long c = edge.second;
        if (prev[w] == -1){
          prev[w] = v;
          flow[w] = min(flow[v], c);
          Q.push(w);
        }
      }
    }
    if (prev[V - 1] == -1){
      break;
    }
    long long f = flow[V - 1];
    int v = V - 1;
    while (v != N){
      E[v][prev[v]] += f;
      E[prev[v]][v] -= f;
      if (E[prev[v]][v] == 0){
        E[prev[v]].erase(v);
      }
      v = prev[v];
    }
    ans -= f;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<Int> a(n);
    vector<Int> b(n);
    vector<Int> c(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) cin>>c[i];
    Int ans=0;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    for(int i=0; i<n; i++){
        Int tmp=b[i];
        auto da=lower_bound(a.begin(),a.end(),tmp)-a.begin();
        auto dc=c.end()-upper_bound(c.begin(),c.end(),tmp);
        ans+=da*dc;
    }
    cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 5560
#!/usr/bin/env python3
import sys


def solve(S: str):
    if(S[0] == S[1] or S[1] == S[2] or S[2] == S[3]):
        print('Bad')
    else:
        print('Good')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
if N == 1:
    ans = 0
else:
    ans = 10 ** (N - 1)
limit = 10 ** N
while ans < limit:
    l = str(ans)
    for s, c in sc:
        if not int(l[s-1]) == c:
            break
    else:
        print(ans)
        exit()
    ans += 1
print(-1)


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
int n, p = -1;
int vis[26];
char s[26];
int main() {
	scanf("%s", s);
	n = strlen(s);
	for(int i = 0; i < n; ++i) {
		vis[s[i] - 'a'] = 1;
	}
	if(n < 26) {
		for(int i = 0; i < 26; ++i) {
			if(!vis[i]) {
				printf("%s%c\n", s, (char)(i + 'a'));
				return 0;
			}
		}
	} 
	for(int i = n - 1; ~i; --i) {
		for(int j = s[i] - 'a' + 1; j < 26; ++j) {
			if(!vis[j]) {
				s[i] = (char)(j + 'a');
				s[i + 1] = 0;
				printf("%s", s);
				return 0;
			}
		}
		vis[s[i] - 'a'] = 0;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256