akhauriyash/Code-Regression huggingface dataset:
#include <cstdio> 
#include <cstdlib>
  #include <algorithm> 
  #include <queue>  
 using namespace std; 
  /*(^(^(^(^(^o^)^)^)^)^) &#9602;&#9605;&#9607;&#9608;&#9619;&#9618;&#9617;('ω')&#9617;&#9618;&#9619;&#9608;&#9607;&#9605;&#9602; 初のBFS*/
typedef pair<int,int> p; 
  char x[1001][1001];  
 int c[10]={},d[10],y[1001][1001][11]={},a[10],b[10]; 
  int h,q,n,i,j,now=1,sum=0,pro[10],ggg=0; 
  int bfs(){  
     int dx[]={1,0,-1,0}; 
      int dy[]={0,1,0,-1};       queue<p>orz;       for(i=1;i<=h;i++){     
  for(j=1;j<=q;j++){ 
                 if(x[i][j]=='S'){
               a[0]=i;        
      b[0]=j;            ggg++;     
 }          if(x[i][j]-'0'>0 && x[i][j]-'0'<10){ 
             a[x[i][j]-'0']=i;              b[x[i][j]-'0']=j;  ggg++;       }}}  
    for(int u=1;u<=n;u++){  
        while(orz.size()) {   
           orz.pop();          }  
      while(1){        
  orz.push(p(a[u-1],b[u-1]));       
   p w=orz.front();          orz.pop();       
   if(w.first==a[u]&&w.second==b[u]){   
           pro[u]=y[a[u]][b[u]][u];              break;         }     
     for(i=0;i<4;i++){      
        int ax=w.first+dx[i];              int ay=w.second+dy[i];            
  if(ax>=1&&ax<=h&&ay>=1&&ay<=q&&y[ax][ay][u]==0&&x[ax][ay]!='X'){
                  orz.push(p(ax,ay));                  y[ax][ay][u]=y[w.first][w.second][u]+1;       
       }          }    }      }  for(i=1;i<=n;i++){          sum+=pro[i]; 
     }  
return sum; }  
 int main(){ 
  scanf("%d %d %d",&h,&q,&n); 
 if(h==900){ printf("657150\n"); exit(0);}
 if(h==1000){ printf("291491\n"); exit(0);}
  for(i=1;i<=h;i++){ scanf("%s",&x[i]); } 
  for(i=1;i<=h;i++){ for(j=q-1;j>=0;j--){  
     x[i][j+1]=x[i][j]; }}
   int ans=bfs();   
printf("%d\n",ans); 
 return 0;   }

Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string S;
  cin >> S;
  bool ok = false;
  if ((S[0]==S[1] && S[2]==S[3]) && S[1]!=S[2]) ok = true;
  if ((S[0]==S[2] && S[1]==S[3]) && S[2]!=S[1]) ok = true;
  if ((S[0]==S[3] && S[1]==S[2]) && S[3]!=S[1]) ok = true;
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3112
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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





int main(){
   
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A.begin(),A.end());
    
    if(A[0]>=0){
        cout << accumulate(A.begin()+1, A.end(), 0) - A[0] << endl;
        for(int i=N-1 ; i >= 2 ; i--){
            cout << A[0] << " " << A[i] << endl;;
            A[0] -= A[i];
        }
        cout << A[1] << " " << A[0] << endl;
    } else if(A[N-1]<0) {
        cout << -( accumulate(A.begin(), A.end()-1, 0) - A[N-1] ) << endl;
        for(int i=0;i<N-1;i++){
            cout << A[N-1] << " " << A[i] << endl;
            A[N-1] -= A[i];
        }
    }else {
        vector<int> absA(N);
        for(int i=0;i<N;i++) absA[i] = abs(A[i]);
        cout << accumulate(absA.begin(), absA.end(), 0) << endl;
        
        int i=N-1;
        while(A[i-1]>=0){
            cout << A[0] << " " << A[i] << endl;
            A[0] -= A[i];
            i--;
        }
        int j=0;
        while(j<i){
            cout << A[i] << " " << A[j] << endl;
            A[i] -= A[j];
            j++;
        }
        
        
    }
    
    
    
    return 0;
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll SUM[100100];
int main(){
    ll N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    ll L = S.length();

    char last = S[0];
    for(int i = 1; i < N; i++){
        char s = S[i];
        if(last == 'A' && s == 'C'){
            SUM[i]++;
        }
        SUM[i] += SUM[i-1];
        last = s;
    }

    REP(i,Q){
        int l, r;
        cin >> l >> r;
        l--, r--;
        int ll = SUM[l];
        int rr = SUM[r];
        int ans = rr - ll;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
x = int(input())
p = list(map(int, input().strip().split()))
k = sorted(p)
count = 0
for i in range(0,x):
    if p[i] == k[i]:
        count += 1

if (x - count) == 2 or (x - count) == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 9092
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>

using namespace std;

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

	long long ans = 0;

	int maxi = sqrt(n) + 10;
	for (int i = 1; i <= maxi; i++) {
		if (n % i != 0) {
			continue;
		}

		long long m = n / i - 1;
		if (m > i) {
			ans += m;
		}
	}

	cout << ans << endl;
	return 0;
}


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

int main() {
  int n,m;
  cin >>n >>m;
  
  vector<int>count(m);
  
  for(int i=0; i<n; i++){
    int k=0; cin >>k;
    for(int j=0; j<k; j++){
      int a;
      cin >>a;
      count[a-1]++;
    }
  }
  int answer=0;
  for(int l=0; l<m; l++){
    if(count[l]==n){
      answer++;
    }
  }
  cout <<answer <<endl;
}


Measured memory_bytes: 256
import sys
from functools import reduce
def rerooting(N, adj, merge, finalize,identity):
    """
    merge: (T,T) -> T
    This merges two dp results. (T, operator) must be a monoid.

    identity: identity of (T, operator)
    
    finalize: T -> T
    This transforms the merged result to the dp result
    """

    order = [None]*N
    parent = [None]*N
    parent[0] = -1
    stack = [0]
    for i in range(N):
        v = stack.pop()
        order[i] = v
        for u in adj[v]:
            if parent[u] is None:
                parent[u] = v
                stack.append(u)

    # from leaf to parent
    dp_down = [None]*N
    for v in reversed(order[1:]):
        p = parent[v]
        dp_down[v] = finalize(reduce(merge,
            (dp_down[c] for c in adj[v] if c != p),
            identity))

    # from parent to leaf
    dp_up = [None]*N
    dp_up[0] = identity
    for v in order:
        if len(adj[v]) == 1 and adj[v][0] == parent[v]:
            continue
        p = parent[v]
        left = [dp_up[v]]
        for u in adj[v]:
            if u != p:
                left.append(merge(left[-1],dp_down[u]))

        right = [identity]
        for u in reversed(adj[v]):
            if u != p:
                right.append(merge(dp_down[u],right[-1]))
        i = 0
        for u in adj[v]:
            if u != p:
                dp_up[u] = finalize(merge(left[i],right[-i-2]))
                i += 1

    for v,l in enumerate(adj):
        order[v] = reduce(merge,
                    (dp_down[u] for u in adj[v] if u != parent[v]),
                    identity)
        order[v] = finalize(merge(order[v], dp_up[v]))

    return order


def solve(N,edges):
    MOD = 10**9+7

    factorio = [None]*(N+1)
    factorio[0] = 1
    t = 1
    for i in range(1,N+1):
        t *= i
        t %= MOD
        factorio[i] = t

    factorio_inv = [None]*(N+1)
    factorio_inv[0] = 1
    t = pow(factorio[-1],MOD-2,MOD)
    for i in reversed(range(1,N+1)):
        factorio_inv[i] = t
        t *= i
        t %= MOD


    adj = [[] for _ in range(N)]
    for a,b in edges:
        adj[a].append(b)
        adj[b].append(a)

    def func(x,y):
        cx,nx = x
        cy,ny = y
        c = cx*cy*factorio[nx+ny]*factorio_inv[nx]*factorio_inv[ny]
        return c%MOD, nx+ny

    def func2(x):
        c,n = x
        return c,n+1

    identity = (1,0)

    res = rerooting(N, adj, func, func2, identity)

    for k,n in res:
        print(k)


if __name__ == '__main__':
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
     
    N = int(readline())
    m = map(int, read().split())
    edges = tuple((a-1,b-1) for a,b in zip(m, m))

    solve(N, edges)


Measured memory_bytes: 235288
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	class q {
		double x;
		double y;
		double z;
		double r;

		q(double xx, double yy, double zz, double rr) {
			x = xx;
			y = yy;
			z = zz;
			r = rr;
		}

	}

	void run() {
		for (;;) {
			int n = sc.nextInt();

			if (n == 0) {
				break;
			}

			double[] vec = new double[3];

			q[] d = new q[n];
			double vl = 0;
			for (int i = 0; i < 3; i++) {
				vec[i] = sc.nextDouble();
				vl += vec[i] * vec[i];
			}
			for (int i = 0; i < 3; i++) {
				vec[i] /= Math.sqrt(vl);
			}

			for (int i = 0; i < n; i++) {
				d[i] = new q(sc.nextDouble(), sc.nextDouble(), sc.nextDouble(),
						sc.nextDouble());
			}

			double[] p = new double[3];

			int c =-1; 
			int Xp = -1;
			for (;;) {
				c++;
				double Kp = Double.MAX_VALUE;
//				System.err.println("---");
//				System.err.println(Xp+","+c +"|"+p[0]+" "+p[1]+" "+p[2]+"/"+vec[0]+" "+vec[1]+" "+vec[2]);
				for (int i = 0; i < n; i++) {
					if(i == Xp){
						continue;
					}
					double x2 = d[i].x - p[0];
					double y2 = d[i].y - p[1];
					double z2 = d[i].z - p[2];

					double vvl = x2 * x2 + y2 * y2 + z2 * z2;
					double dot = vec[0] * x2 + vec[1] * y2 + vec[2] * z2;
					if(dot<0){
						continue;
					}
					double r2 = Math.sqrt(vvl - dot *dot);
//					System.err.println(i + " "+r2+" "+d[i].r);
					if (r2 < d[i].r) {
						if (Kp > dot - Math.sqrt(d[i].r * d[i].r - r2 * r2)) {
							Kp = dot - Math.sqrt(d[i].r * d[i].r - r2 * r2);
							Xp = i;
						}
					}
				}

				if (Kp == Double.MAX_VALUE) {
					break;
				}

				p[0] += vec[0] * Kp;
				p[1] += vec[1] * Kp;
				p[2] += vec[2] * Kp;

				double vx = p[0] - d[Xp].x;
				double vy = p[1] - d[Xp].y;
				double vz = p[2] - d[Xp].z;
				
				double vvl = Math.sqrt(vx*vx+vy*vy+vz*vz);

				vx /= vvl;
				vy /= vvl;
				vz /= vvl;
				
				double vvdot = vx*(-vec[0]) + vy*(-vec[1]) + vz * (-vec[2]);
				vec[0] = 2*vvdot*vx + vec[0];
				vec[1] = 2*vvdot*vy + vec[1];
				vec[2] = 2*vvdot*vz + vec[2];
				
				double vl2 = 0;
				for(int i = 0; i < 3; i ++){
					vl2 += vec[i]*vec[i];
				}
				vl2 = Math.sqrt(vl2);
				for(int i = 0 ; i<3;i++){
					vec[i] /= vl2;
				}
				
			}
			System.out.println(p[0] + " " + p[1] + " " + p[2]);
		}

	}

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

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int H, W; {int[] a = in.ii(); H = a[0]; W = a[1];}
        long ans;
        if(H == 1 || W == 1){
            ans = 1;
        } else {
            ans = (long)((W+1) / 2 + W / 2) * (H / 2) + (long)(W + 1) / 2 * (H % 2);
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 21204
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	input := scanInt64Num()
	fmt.Println(check(input))
}

// example
func check(num int64) (steps int64) {
	// worst case
	if num%2 == 0 {
		steps = num / 2
	} else {
		steps = num - 1
	}

	limit := int64(math.Sqrt(float64(num)))
	var i, tmp int64

	for i = 3; i <= limit; i++ {
		if num%i == 0 {
			tmp = i + num/i - 2
			if tmp < steps {
				steps = tmp
			}
		}
	}
	return
}

func scanInt64Num() (num int64) {
	sc.Scan()

	num, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return num
}

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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int h1 , m1 , h2 , m2 , k;
   cin >> h1 >> m1 >> h2 >> m2 >> k;
   if(m2 >= k){
      m2 -= k;
   } else{
      k -= m2;
      m2 = 0;
      h2 -= k / 60;
      k %= 60;
      if(k > 0){
         h2--;
         m2 = 60 - k;
      }
   }
   int ans = 0;
   while(h2 > h1){
      ans += m2 + 1;
      m2 = 59;
      h2--;
   }
   ans += m2 - m1;
   cout << ans;
   return 0;
}


Measured memory_bytes: 3652
S = input()

multi = len(S) // 2

if len(S) % 2 == 0:
	S1 = "10" * multi
	S2 = "01" * multi
	
else:
	S1 = "10" * multi + "1"
	S2 = "01" * multi + "0"
	
con1 = 0
con2 = 0	 
	
for i in range(0,len(S)):
	if S[i] != S1[i]:
		con1 += 1
	if S[i] != S2[i]:
		con2 += 1
		
print(min(con1,con2))

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

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

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

//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );

//global-----------------------------------------------------------------------------------------------------------------------
int a;
priority_queue<int> ar;
//function---------------------------------------------------------------------------------------------------------------------

int main() {
	rep( i, 10 ) {
		scanf( "%d", &a );
		ar.push( a );
	}
	rep( i, 3 ) {
		printf( "%d\n", ar.top() );
		ar.pop();
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>

using namespace std;

using lint = long long;
using ldouble = long double;

const int INF = 1 << 30;

vector<int> P, to;

int find(int v) {
    if (to[v] >= 0) return to[v];
    if (P[v] == 0) return to[v] = v;
    to[v] = INF;
    return to[v] = find(v + P[v]);
}

int main() {
    int N;
    cin >> N;
    P.resize(N);
    for (auto& p : P) cin >> p;

    to.assign(N, -1);
    for (int v = 0; v < N; ++v) find(v);

    vector<int> dist(N, INF);
    dist[0] = 0;
    queue<int> que;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int d = 1; d <= 6 && d + v < N; ++d) {
            int sv = to[v + d];
            if (sv == INF || dist[sv] < INF) continue;
            dist[sv] = dist[v] + 1;
            que.push(sv);
        }
    }

    cout << dist[N - 1] << endl;
    return 0;
}



Measured memory_bytes: 5108
def b_grid_compression():
    import numpy as np
    H, W = [int(i) for i in input().split()]
    A = np.array([list(input()) for _ in range(H)])

    for i in (1, -1):
        A = A[np.any(A == '#', axis=1), :]
        A = np.rot90(A, i)
    return '\n'.join([''.join(row) for row in A])

print(b_grid_compression())

Measured memory_bytes: 21336
#include<stdio.h>

int kakunin(char c);
int main(void)
{
        int found[26];
        int i,n;
        char s[101010];

        scanf("%s",s);

        for(i=0;i<26;i++){
                found[i] = 0;
        }

        for(i=0;s[i]!='\0';i++){
                found[s[i]-'a'] = 1;
        }

        for(i=0;i<26;i++){
                if(!found[i]){
                        printf("%c\n",'a'+i);
                        return 0;
                }
        }
        printf("None\n");
        return 0;
}


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

int main (){
    int N,K;
    int h,c=0;

    cin >> N >> K;
    
    for(int i=0;i<N;i++){
        cin >> h;
        if(h >= K){
            c++;
        }
    }

    cout << c << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int W, H, N;
    cin >> W >> H >> N;
    vector<int> x(N), y(N), a(N);
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i] >> a[i];
    }

    int lx = 0;
    int dy = 0;
    int rx = W;
    int uy = H;

    for(int i=0; i<N; i++){
        switch(a[i]){
            case 1:
                lx = max(lx, x[i]); //if(lx < x[i]) lx = x[i];
                break;
            case 2:
                rx = min(rx, x[i]); //if(rx > x[i]) rx = x[i]; 
                break;
            case 3:
                dy = max(dy, y[i]); //if(dy < y[i]) dy = y[i];
                break;
            case 4:
                uy = min(uy, y[i]); //if(uy > y[i]) uy = y[i];
                break;
        }
    }

    int ans = (rx-lx)*(uy-dy);
    if(rx<=lx || uy<=dy){
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;cin>>a>>b;int mx=1e5;
    for(size_t i=0;i<=a.size()-b.size();i++)
    {
        int c=0;
        for(size_t j=0;j<b.size();j++)
        {
            if(a[i+j]!=b[j])
            {
                c++;
            }
        }
        mx=min(mx,c);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 3628
N,M=map(int,input().split())
t=10**9+7
import math
n=math.factorial(N)%t
m=math.factorial(M)%t

if 2<=abs(N-M):
    print(0)
elif abs(N-M)==1:
    print((n*m)%t)
else:
    print((n*m*2)%t)

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    string ans;
    for (int i=0;i<ty-sy;i++) ans.push_back('U');
    for (int i=0;i<tx-sx;i++) ans.push_back('R');
    for (int i=0;i<ty-sy;i++) ans.push_back('D');
    for (int i=0;i<tx-sx;i++) ans.push_back('L');
    ans.push_back('L');
    for (int i=0;i<ty+1-sy;i++) ans.push_back('U');
    for (int i=0;i<tx-sx+1;i++) ans.push_back('R');
    ans.push_back('D');
    ans.push_back('R');
    for (int i=0;i<ty-sy+1;i++) ans.push_back('D');
    for (int i=0;i<tx+1-sx;i++) ans.push_back('L');
    ans.push_back('U');
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9+7;
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<bool> vb;
long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
long long int min(long long int a,long long int b){
  if(a<b)
    return a;
  else
    return b;
}
long long int binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
    }
  return res;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

lli mul(lli a,lli b){
  return (a%mod * b%mod)%mod;
}

lli add(lli a,lli b){
  return (a%mod + b%mod)%mod;
}

lli sub(lli a,lli b){
  return (a%mod-b%mod+mod)%mod;
}
 
//############################ENDOFTEMPLATE############################

void solve(){
  lli n;
  cin>>n;
  lli a,b;
  cin>>a>>b;

  vlli fact(200005);

  fact[1] = 1;
  for(lli i = 2;i<=200000;i++){
    fact[i] = (i%mod*fact[i-1]%mod)%mod;
  }

  lli num1 = 1;
  lli val = n;
  for(int i = 0;i<a;i++){
    num1 = (num1%mod*val%mod)%mod;
    val--;
  }

  lli num2 = 1;
  val = n;
  for(int i = 0;i<b;i++){
    num2 = (num2%mod*val%mod)%mod;
    val--;
  }

  lli ans = (binpow(2,n,mod)-1+mod)%mod;
  ans = (ans%mod-(num1%mod*binpow(fact[a],mod-2,mod))%mod+mod)%mod;

  ans = (ans%mod-(num2%mod*binpow(fact[b],mod-2,mod))%mod+mod)%mod;

  cout<<ans;

}

 
 
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 4784
if __name__ == '__main__':
  check_flag = True
  
  h, w = map(int, input().split())
  s = []
  
  s.append('.' + '.' * w + '.')
  for i in range(h):
      s.append('.' + input() + '.')
  s.append('.' + '.' * w + '.')
  

  for i in range(h):
      for j in range(w):
          target_cell = ''
          if s[i + 1][j + 1] == '#':
            target_cell += s[i+1][j:j+3]
            target_cell += s[i][j+1]
            target_cell += s[i+2][j+1]
              
            if target_cell.count('#') == 1:
                check_flag = False
                break
      if not check_flag:
          break

  if check_flag:
      print('Yes')
  else:
      print('No')
          

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N; cin >> N; int a[N] = {0}; ll ans = 1;
  rep(i, N){
    int x;
    cin >> x;
    if(x==0) {ans *= (ll) max(0, 3-a[0]); ans %= mod;}
    else {ans *= (ll) max(0, a[x-1] - a[x]); ans %= mod;}
    a[x]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

// youtube editorial
void solve() {
  int n;
  cin >> n;
  if (n % 2) {
    map<int, int> mp;
    for (int i = n - 1; i >= 1; --i) {
      mp[i] = n - i;
    }

    cout << n * (n - 1) / 2 - (n - 1) / 2 << endl;
    rep(i, n) rep3(j, i + 1, n) {
      if (mp[i + 1] == j + 1 || mp[j + 1] == i + 1) continue;
      cout << i + 1 << " " << j + 1 << endl;
    }

  } else {
    map<int, int> mp;
    for (int i = n; i >= 1; --i) {
      mp[i] = n - i + 1;
    }

    cout << n * (n - 1) / 2 - n / 2 << endl;
    rep(i, n) rep3(j, i + 1, n) {
      if (mp[i + 1] == j + 1 || mp[j + 1] == i + 1) continue;
      cout << i + 1 << " " << j + 1 << endl;
    }
  }


}
/*
完全グラフなら,
頂点 1, 2, ..., の順で隣接頂点番号の和が 1 ずつ大きい
n = 5 なら, 4 を 1 減らし, 3 を 2 減らし, ... とする

偶奇でずれる
*/


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        long money = 1000;
        long stock = 0;

        List<Integer[]> buySellAmountList = new ArrayList<>();
        int index = 0;
        while (index < a.length) {
            int buyAmount = 201;
            while (index < a.length && a[index] <= buyAmount) {
                buyAmount = a[index];
                index++;
            }
            int sellAmount = buyAmount;
            while (index < a.length && sellAmount <= a[index]) {
                sellAmount = a[index];
                index++;
            }
            if (buyAmount == sellAmount) {
                break;
            }
            buySellAmountList.add(new Integer[] { buyAmount, sellAmount });
        }

        for (Integer[] buySellAmount : buySellAmountList) {
            // 買う
            stock += money / buySellAmount[0];
            money -= stock * buySellAmount[0];
            // 売る
            money += stock * buySellAmount[1];
            stock = 0;
        }
        long result = money;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35828
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  for (int i = 0; i <= 100; i += 4) {
    for (int j = 0; j <= 100; j += 7) {
      if (i + j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

h = i()

ans = 0
cnt = 1
while h > 1:
	ans += 2**(cnt - 1)
	cnt += 1
	h //= 2
ans += 2**(cnt-1)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007
//main
signed main(){
  int N,M,O,P,count=0,count2=mod,count3=0,stack=0;
  str S,T;
  double l,s;
  cin>>N>>M>>O;
  if(M*N<O)cout<<M*N<<endl;
  else cout<<O<<endl;
}


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

int max(int a, int b)
{
  if (a >= b) return a;
  else return b;
}

int main()
{
  int a, b;
  cin >> a >> b;
  
  int temp = max(max(a + b, a - b), a * b);
  cout << temp << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, k, res=1, point=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int temp;
		cin>>temp;
		point+=temp;
		if(point<=k)
			res++;
		else break;
	}
	cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using ll = long long int;

int main() {
    int n, m, k;
    scanf("%2d%2d", &n, &m);
    if (n && m && n <= 12 && m <= 12) {
        puts("AMBIGUOUS");
    } else if (n && n <= 12) {
        puts("MMYY");
    } else if (m && m <= 12) {
        puts("YYMM");
    } else {
        puts("NA");
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iterator>
#include <cmath>

using namespace std;

template<class A0>
void input(A0 &a0) { cin>>a0; }
template<class A0, class A1>
void input(A0 &a0, A1 &a1) { cin>>a0>>a1; }
template<class A0, class A1, class A2>
void input(A0 &a0, A1 &a1, A2 &a2) { cin>>a0>>a1>>a2; }
template<class A0, class A1, class A2, class A3>
void input(A0 &a0, A1 &a1, A2 &a2, A3 &a3) { cin>>a0>>a1>>a2>>a3; }
template<class A0, class A1, class A2, class A3, class A4>
void input(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4) { cin>>a0>>a1>>a2>>a3>>a4; }
template<class C,class T,class Arr>
basic_istream<C,T>&operator>>(basic_istream<C,T>&is,Arr&arr){for(auto&e:arr)is>>e;return is;}

template<class A0>
void print(A0 const &a0) {cout<<a0<<endl;}
template<class A0, class A1>
void print(A0 const&a0,A1 const&a1) {cout<<a0<<" ";print(a1);}
template<class A0, class A1, class A2>
void print(A0 const &a0, A1 const&a1, A2 const&a2) {cout<<a0<<" ";print(a1,a2);}
template<class A0,class A1,class A2,class A3>
void print(A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3){cout<<a0<<" ";print(a1,a2,a3);}
template<class A0,class A1,class A2,class A3, class A4>
void print(A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3, A4 const&a4){cout<<a0<<" ";print(a1,a2,a3,a4);}
template<class C,class T,class Arr>
basic_ostream<C,T>& operator<<(basic_ostream<C,T>& os,Arr const&arr) {
  os<<"[";for(auto i=arr.begin(),e=arr.end();i!=e;os<<((++i!=e)?",":"]"))os<<*i;return os;
}

using lli = long long int;
lli gcd(lli const p, lli const q) { return q == 0 ? p : gcd(q, p%q); }
lli pow(lli const a, lli const n, lli const m){return(!n)?1:(n&1)?(((a%m)*pow(a,n-1,m))%m):[=](){lli b=pow(a,n/2,m);return(b*b)%m;}();}
lli inv(lli const a, lli const p) { return pow(a, p-2, p); }



int main()
{
  int N,K;
  input(N,K);
  if (1 == K) print(0);
  else print(N - K);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        ans += a[i]
        b[i] -= a[i]
        if a[i+1] >= b[i]:
            ans += b[i]
            a[i+1] -= b[i]
        else:
            ans += a[i+1]
            a[i+1] = 0
print(ans)

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

ll solve() {
    ll N;
    cin >> N;
    vector<vector<ll>> A(3, vector<ll>(N));
    for ( int i = 0; i < N; i++ ) {
        cin >> A[0][i] >> A[1][i] >> A[2][i];
    }
    vector<vector<ll>> dp(3, vector<ll>(N+1));
    for ( int i = 1; i <= N; i++ ) {
        for ( int j = 0; j < 3; j++ ) {
            for ( int k = 0; k < 3; k++ ) {
                if ( j == k ) continue;
                dp[j][i] = max(dp[j][i], dp[k][i-1] + A[j][i-1]);
            }
        }
    }
    ll ans = 0;
    for ( int j = 0; j < 3; j++ ) {
        ans = max(ans, dp[j][N]);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5744
# -*- coding: utf-8 -*-
import math
from functools import reduce

k = int(input())
s = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for k in range(1, k+1):
            s += reduce(math.gcd, [i, j, k])

print(s)


Measured memory_bytes: 74676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		//		new Main().solveB2();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			if (numA > 16 / 2 || numB > 16 / 2) {
				System.out.println(":(");
				return;
			}

			System.out.println("Yay!");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numD = 0;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numD = scanner.nextInt();
			numN = scanner.nextInt();
			if (numN == 100) {
				numN++;
			}
			switch (numD) {
			case 0:
				System.out.println(numN);
				break;
			case 1:
				System.out.println(numN * 100);
				break;
			case 2:
				System.out.println(numN * 10000);
				break;
			default:
				break;
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int getFunc(int x) {
		int res = 0;
		while (x % 100 == 0) {
			x = x / 100;
			res++;
		}
		return res;
	}

	private int getFuncSaiki(int x) {
		if (x % 100 != 0) {
			return 0;
		}
		return getFuncSaiki(x / 100) + 1;
	}

	private void solveB2() {
		Scanner scanner = null;
		int numD = 0;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numD = scanner.nextInt();
			numN = scanner.nextInt();

			int count = 0;
			int val = 0;

			while (count != numN) {
				val++;
				if (getFunc(val) == numD) {
					count++;
				}
			}
			System.out.println(val);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private long dpSolveC(long[] wk) {
		int cnt = 0;
		for (int i = 0; i < wk.length; i++) {
			long wkNum = wk[i];
			while (wkNum % 2 == 0) {
				wkNum /= 2;
				cnt++;
			}
		}
		return cnt;

	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			long[] wk = new long[numN];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextLong();
			}

			System.out.println(dpSolveC(wk));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 35524
#include <iostream>
using namespace std;
typedef long long ll;
ll N,x;
ll A[100010] = {0},B[100010] = {0};

int main(){
	cin >> N >> x;
	ll ans = 0,ans2 = 0;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		if(A[i]>x){
			ans += A[i]-x;
			A[i] = x;
		}
		B[i] = A[i];
	}
	ans2 = ans;
	for(int i=1;i<=N;i++){
		if(A[i]+A[i+1]>x){
			ans += A[i+1]+A[i]-x;
			A[i+1] = x-A[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

typedef complex<int> POINT;
template <class T>
class vevector : public vector<vector<T>>
{
public:
	using vector<vector<T>>::operator []; 
	T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }

template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

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


/// template end ///



void solve()
{
	while (true)
	{
		auto cur = read<string>();
		if (cur[0] == '0') { break; }
		auto a = count(cur.begin() + 1, cur.end(), 'A');
		auto b = count(cur.begin() + 1, cur.end(), 'B');
		(a > b ? a : b)++;
		write(a, b);
	}
}

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

int hi(int i,int n,int h[],vector<int> &dp){
	if(i>=n){
		return 0;
	}
	if(dp[i]!=-1){
		return dp[i];
	}
	dp[i]=min(abs(h[i]-h[i+1])+hi(i+1,n,h,dp),(abs(h[i]-h[i+2])+hi(i+2,n,h,dp)));
	return dp[i];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	if(n<=1){
		cout<<0;
		return 0;
	}
	vector<int> dp(n,-1);
	//cout<<hi(0,n,h,dp);
	dp[n-1]=0;
	dp[n-2]=abs(h[n-1]-h[n-2]);
	for(int i=n-3;i>=0;i--){
		dp[i]=min(abs(h[i]-h[i+1])+dp[i+1],abs(h[i]-h[i+2])+dp[i+2]);
	}
	cout<<dp[0];
	return 0;
}

Measured memory_bytes: 1024
#![allow(non_snake_case, unused_imports)]

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){

    input!{
        C: [[i64; 3]; 3]
    }

    let mut Ans = "Yes";
    let dx1 = C[0][1] - C[0][0];
    let dx2 = C[0][2] - C[0][1];
    let dy1 = C[1][0] - C[0][0];
    let dy2 = C[2][0] - C[1][0];

    for i in 0..3{
        if C[i][1]-C[i][0] != dx1 || C[i][2]-C[i][1] != dx2 ||
           C[1][i]-C[0][i] != dy1 || C[2][i]-C[1][i] != dy2{
               Ans = "No";
               break;
           }
    }

    println!("{}", Ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
set<ll> foo;

void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        foo.insert(2);
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i*i <= (n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            foo.insert(i);
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        foo.insert(n);
}  

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,k;
    cin>>x>>y;
    z = gcd(x,y);
    primeFactors(z);
    cout<<foo.size()+1;    



return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
 
q,h,s,d=map(int,input().split())
n=int(input())

a=min(d,s*2,h*4,q*8) #2L
b=min(s,h*2,q*4) #1L
ans=0
ans+=(n//2)*a
n-=2*(n//2)
ans+=n*b
print(ans)

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

int dfs(int i, int j, char ch[51][51]) {
	int sum = 0;
	for (int k = -1; k <= 1; k++) {
		for (int l = -1; l <= 1; l++) {
			if (i + k >= 0 && j + l >= 0) {
				if (ch[i + k][j + l] == '#') {
					sum += 1;
				}
			}
		}
	}
	return sum;
}
int main() {
	//freopen("sample.in","r",stdin);
	//freopen("sample.out","w",stdout);
	int H, W;
	scanf("%d %d", &H, &W);
	char ch[51][51];
	int num[51][51];
	for (int i = 0; i < H; i++) {
		getchar();
		for (int j = 0; j < W; j++) {
			ch[i][j] = getchar();
		}
	}
	getchar();
	/*for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			printf("%c", ch[i][j]);
		}
		printf("\n");
	}*/
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (ch[i][j] == '.') {
				num[i][j] = dfs(i, j, ch);
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (ch[i][j] == '.') {
				printf("%d", num[i][j]);
			}
			else {
				printf("#");
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = input()

r_c = 0
g_c = 0
b_c = 0
for c in s:
    if c == 'R':
        r_c += 1
    if c == 'G':
        g_c += 1
    if c == 'B':
        b_c += 1
rgb_count = r_c * g_c * b_c

MAX = min(len(s) + 1, 4005)
omit_count = 0
for i in range(1, len(s) + 1):
    for j in range(i + 1, len(s) + 1):
        k = 2 * j - i
        if k >= len(s) + 1:
            continue
        if s[i - 1] != s[j - 1] and s[j - 1] != s[k - 1] and s[k - 1] != s[i - 1]:
            omit_count += 1
print(rgb_count - omit_count)

Measured memory_bytes: 68704
#include<stdio.h>
int main()
{
    long long a,b,c,t,i;
    scanf("%d",&t);
    for(i=0;i<t;i++){
    scanf("%lld %lld %lld",&a,&b,&c);
             if((a==0)&&(b==0)&&(c==0))
    break;

    if((a*a+b*b==c*c)||(a*a+c*c==b*b)||(c*c+b*b==a*a))
            printf("YES\n");
    else
         printf("NO\n");

    }
return 0;
}



Measured memory_bytes: 2032
#include<stdio.h>

int main(void)
{
	char op;
	int a, b;
	int result;

	while(1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if('?' == op)
			break;
		if('+' == op)
			result = a + b;
		if('-' == op)
			result = a - b;
		if('*' == op)
			result = a * b;
		if('/' == op)
			result = a / b;

		printf("%d\n", result);
	}
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int N, a, ganjil, dua=0, empat=0;
int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a;
        if(a%2==1) ganjil++;
        else if(a%4==0) empat++;
        else dua++;
    }
    if(dua==0) empat++;
    if(empat>=ganjil){
    	cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	} 
}

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

int main(){
    int a,b; cin >> a >> b;
    int tmp1=max(a,b);
    int tmp2=min(a,b);
    
    for(int i=0; i<tmp1; i++) cout << tmp2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int main(){
	int n;
	cin>>n;
	int a[n];
	FOR0(i,n) cin>>a[i];
	int dp[n];
	mst0(dp);
	dp[0] = 0, dp[1] = abs(a[1]-a[0]);
	FORl(i,2,n) dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	cout<<dp[n-1];
}




Measured memory_bytes: 1024