akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int c[1080];
string str;
int n;

int main(){
	while(cin >> n, n){
		int ba = 0;
		fill(c, c + n, 0);
		cin >> str;
		str;
		for(int i = 0;i < str.size();i++){
			c[i%n]++;
			switch(str[i]){
				case 'S':
					ba += c[i%n];
					c[i%n] = 0;
					break;
				case 'L':
					c[i%n] += ba;
					ba = 0;
					break;
				case 'M':
					break;
			}
		}
		sort(c, c + n);
		for(int i = 0;i < n;i++){
			cout << c[i] << " ";
		}
		cout << ba << endl;
	}
	return 0;
}

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

int main(){
    
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    int sum=0;
    while (X>0&&Y>0){
        if(A+B>=2*C){
            sum=sum+C+C;
            X--;
            Y--;
        }
        else{sum=sum+A+B;
            X--;
            Y--;
        }
    }
    while(X!=0){
        if(A>=2*C){
            sum=sum+C+C;
            X--;
        }
        else{sum=sum+A;
            X--;
        }
    }
    while(Y!=0){
        if(B>=2*C){
            sum=sum+C+C;
            Y--;
        }
        else{sum=sum+B;
            Y--;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
/*input
5
3 3 3 3 3
*/
#include<bits/stdc++.h>
#define int        long long
#define MOD        1000000007
#define MAX        100005
#define pb         push_back
#define mp         make_pair
#define pii        pair<int,int>
#define mii        map<int,int>
#define vi         vector<int>
#define ff         first
#define ss         second
#define T          int t;cin>>t;while(t--)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define umi        unordered_map<int,int>
#define maxheap    priority_queue<int>
#define minheap    priority_queue<int,vector<int>,greater<int> >
#define inp(n)     for(int i=0;i<n;i++)
#define N          2000005
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())
using namespace std;
using namespace std::chrono;

bool pal(string s){
    int n = s.length();
    for(int i=0,j=n-1;i<j;i++,j--){
        if(s[i] != s[j]) return false;
    }
    return true;
}

signed main(){
    int n;
    cin >> n;
    vi v(n);
    map<int,int>m;
    inp(n){
        cin >> v[i];
        m[v[i]]++;
    }
    int sum = 0;
    for(pii p:m){
        sum += (p.ss*(p.ss-1))/2;
    }
    inp(n){
        int ans = sum - m[v[i]] + 1;
        cout << ans << '\n';
    }
}



Measured memory_bytes: 11008
#include <iostream>

using namespace std;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int max = min(a, b);
    int min;
    if(n <= a + b) min = a + b - n;
    else min = 0;
    cout << max << " " << min << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))

    ans=0
    for d in range(60,-1,-1):
        k=sum((a>>d)&1 for a in A)
        ans+=(k*(n-k))<<d
        ans%=MOD

    print(ans)
resolve()

Measured memory_bytes: 124568
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
V = read_ints()
C = read_ints()

# ans = -100
value = []
for v, c in zip(V, C):
    value.append(v-c)

value.sort(reverse=True)

ans = 0
for v in value:
    if v < 0:
        break
    ans += v

print(ans)


Measured memory_bytes: 3064
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;


int main() {
	ll x, k, d;
	//bool neg = false;

	cin >> x >> k >> d;
	x = abs(x);

	ll pasosnec = x / d;

	if (pasosnec >= k) cout << x - k * d << '\n';
	else {
		x = x - pasosnec * d;
		k = k - pasosnec;

		if (k % 2 == 0) cout << x << '\n';
		else cout << abs(x - d) << '\n';
	}

	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>

#define ll long long
using namespace std;
const int lim = 5e6;
int lp[lim + 10],pr[lim],cnt = 0;
vector <ll> V;
unordered_map <ll,int> mp;
ll n;
void sieve(){
    for (int i = 2; i <= lim; i++){
        if (lp[i] == 0) lp[i] = pr[++cnt] = i;
        int j = 1;
        while (j <= cnt && pr[j] <= lp[i] && i * pr[j] <= lim){
            lp[i * pr[j]] = pr[j];
            j++;
        }
    }
}
bool prime(long long x){
    if (x < 2) return false;
    for (long long i = 2; i * i <= x; i++)
        if (x % i == 0) return false;
    return true;
}
void add(){
    for (ll i = 2; i <= lim; i++)
        if (lp[i] == i)
            for (ll temp = i; temp <= (ll)1e13; temp *= i)
                V.push_back(temp);
}
int main(){
    /*sieve();
    add();
    sort(V.begin(),V.end());
    cin >> n;
    ll ans = 0 , tmp = 1;
    for (auto x : V)
        if (n % x == 0 && x <= n) n /= x , ans++ , tmp = x;
    if (prime(n) == true && n > tmp) ans++;
    cout << ans;*/
    ll ans = 0;
    cin >> n;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0){
            while (n % i == 0){
                n /= i;
                mp[i]++;
            }
            V.push_back(i);
        }
    if (n > 1) V.push_back(n) , mp[n]++;
    for (auto x : V){
        int sum = 1;
        while (mp[x] >= sum) mp[x] -= sum , ans++ , sum++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
char s[11];
int n,i,j,k,ans=0;
int main() {
    scanf("%s",s);
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        char S[21];
        scanf("%s",S);
        for (j=0; j<10; j++) {
            S[j+10]=S[j];
        }
        S[20]='\0';
        for (k=0; k<10; k++) {
            int f=0;
            j=0;
            while (S[k+j]==s[j]) {
                if (j==strlen(s)-1) {
                    ans++;
                    f=1;
                    break;
                }
                j++;
            }
            if (f) {
                break;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main()
{
    int A, B;
    string ope;

    cin >> A >> ope >> B;

    int uns;
    if (ope == "+") {
        uns = A + B;
    }
    else {
        uns = A - B;
    }

    cout << uns << endl;

    return 0;
}


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		
		if(a <= 9 && b <= 9) {
			System.out.println(a*b);
		}else {
			System.out.println(-1);
		}
		
		
	}

}


Measured memory_bytes: 21844
#include<iostream>

#include<stdio.h>

using namespace std;


int main(){

	
	double u,i,r;
	cin >> r;
	u = r*r*3.14159265359;
		i = r * 2 * 3.14159265359;
		printf("%.6lf  %.6lf\n", u, i);






	return 0;
}



Measured memory_bytes: 3192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int sx, sy, tx, ty;

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

    void run() {
        FastReader sc = new FastReader();
        sx = sc.nextInt();
        sy = sc.nextInt();
        tx = sc.nextInt();
        ty = sc.nextInt();
        solve();
    }

    void solve() {
        int xDiff = Math.abs(tx - sx);
        int yDiff = Math.abs(ty - sy);
        StringBuilder firstRight = new StringBuilder();
        StringBuilder firstLeft = new StringBuilder();
        StringBuilder firstUp = new StringBuilder();
        StringBuilder firstDown = new StringBuilder();
        for (int i = 0; i < xDiff; i++) {
            firstRight.append('R');
            firstLeft.append('L');
        }
        for (int i = 0; i < yDiff; i++) {
            firstUp.append('U');
            firstDown.append('D');
        }
        StringBuilder sb = new StringBuilder();
        sb.append(firstRight);
        sb.append(firstUp);
        sb.append(firstLeft);
        sb.append(firstDown);
        sb.append("DR");
        sb.append(firstRight);
        sb.append(firstUp);
        sb.append("ULU");
        sb.append(firstLeft);
        sb.append("LD");
        sb.append(firstDown);
        sb.append('R');
        System.out.println(sb);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 20948
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
v1 = [a1,b1]
d = a1*t1 + a2*t2 - b1*t1 - b2*t2
if d == 0:
  print("infinity")
  exit()
if d > 0:
  f = 0
  s = 1
else:
  f = 1
  s = 0
  d = -d
l = t1*(v1[s]-v1[f])
if l < 0:
  print(0)
  exit()
tm = int(l//d)
if int(l%d) == 0:
  print(2*tm)
else:
  print(1+2*tm)

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0 ; i < (n); ++i)
#define rrep(i,n) for(i  1; i <= (n); ++i)
#define drep(i,n) for(i  (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}
ll gcd(ll c, ll d) { return d ? gcd(d, c%d) : c;}
ll lcm(ll c, ll d) { return c / gcd(c,   d) * d;}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
ll a,b,c,d,n,e,f,l,h,i,j;
cin >> a >> b >> c >> d;
n = b-a+1;
if(a%c==0){
  e = b/c-a/c+1;
}
  else{
      e = b/c-a/c;
  }
if(a%d==0){
    f = b/d-a/d+1;
}
  else{
      f = b/d-a/d;
  }

l = lcm(c,d);
if(a%l==0){   
    h = b/l-a/l+1;
}
else{
    h = b/l-a/l;
}
i = e+f-h;
j = n-i;
cout << j << endl;







//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, M = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++){
    if (M <= K) M *= 2;
    else M += K;
  }
  
  cout << M << endl;
}

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

int main() {
	long h,w;
  	cin >> h >> w;
  	if(h==0 || w==0 || h==1 || w==1){
      cout << 1 << endl;
    }
  	else if(h*w%2==0){
      cout << h*w/2 << endl;
    }
  	else if(h*w%2==1){
      cout << h*w/2+1 << endl;
    }
  
  
}


Measured memory_bytes: 256
abcd = gets.chomp.chars
ans = ''
[true, false].repeated_permutation 3 do |b|
  h = []
  h << abcd[0]
  for i in 0..2
    h << '+' if b[i]
    h << '-' if !b[i]
    h << abcd[i + 1]
  end
  if eval(h.join) == 7
    ans = "#{h.join}=7"
    break
  end
end
puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  ll x,y;
  cin>>x>>y;
  if(x%y==0)cout<<-1<<endl;
  else cout<<x<<endl;
  return 0;
  }

Measured memory_bytes: 764
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#define watch(x) cout << (#x) << " is " << (x) << endl
 
typedef long long ll;
typedef long double ld;
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ld w, h;
    int x, y;
    cin >> w >> h >> x >> y;
    cout << (w * h) / 2 << ' ';
    if(x == w / 2 && y == h / 2)
    {
        cout << 1;
    }
    else
    {
        cout << 0;
    }
 
    return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
M=10**9+7
sum=pow(2,n,M)-1
def inverse(number,mod):
    m=mod-2
    mod2=""
    while m!=0:
        if m%2==0:
            mod2="0"+mod2
        else:
            mod2="1"+mod2
        m=m//2
    two=[]
    for i in range(len(mod2)):
        if mod2[len(mod2)-1-i]=="1":
            two.append(i)
    ret=1
    for i in two:
        v=i
        retsub=number
        while v>0:
            retsub=retsub**2
            retsub=retsub%mod
            v-=1
        ret*=retsub
    ret=ret%mod
    return ret
def cal(num,r,mod):
    ret1=1
    for i in range(0,r):
        ret1*=(num-i)
        ret1%=mod
    r_factorial=1
    for i in range(1,r+1):
        r_factorial*=i
        r_factorial%=M
    ret2=inverse(r_factorial,mod)
    ret=(ret1*ret2)%mod
    return ret

ans=sum-cal(n,a,M)-cal(n,b,M)
print(ans%M)


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

#define ull unsigned long long int
#define ll long long
#define vi vector<int>
#define mii map<int,int>
#define all(x) x.begin(),x.end()
#define endl "\n"
#define pb push_back
#define MOD 1e9+7
#define INF 0x3f3f3f3f

using namespace std;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main()
{
int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;

}


Measured memory_bytes: 3596
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug == false) {
            return;
        }
        System.out.println(str);
    }

    public static class Edge {
        int u;
        int v;
        int w;

        public Edge(int u, int v, int w) {
            this.u = u;
            this.v = v;
            this.w = w;

        }
    }

    public static void main(String[] args) {

        int N;
        HashMap<Integer,List<Edge>> set;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            set = new HashMap<>();
            for (int i = 0; i < N - 1; i++) {
                int u = sc.nextInt();
                int v = sc.nextInt();
                int w = sc.nextInt();
                Edge e = new Edge(u, v, w);
                setSet(set,e,u);
                setSet(set,e,v);
            }
        }
        int[] distans = new int[N];
        HashSet<Edge> visited = new HashSet<>();
        Deque<Integer> queue = new ArrayDeque<>();
        queue.push(1);
        distans[0] = 0;
        Integer target;
        while((target = queue.pollFirst()) != null){
            List<Edge> list = set.get(target);
            for(Edge e : list){
                if(visited.contains(e)){
                    continue;
                }else{
                    if(e.u != target && e.v == target){
                        queue.addLast(e.u);
                        distans[e.u  -1] = (distans[target-1] + e.w) %2;
                        debug(e.u+":" + distans[e.u  -1] );
                    }else if(e.v != target && e.u == target){
                        queue.addLast(e.v);
                        distans[e.v  -1] = (distans[target-1] + e.w)%2;
                        debug(e.v+":"+distans[e.v  -1]);
                    }
                    visited.add(e);
                }
            }
        }
        for(int i : distans){
            System.out.println(i%2);
        }
    }

    private static void setSet(HashMap<Integer,List<Edge>> set,Edge e, int i){
        List<Edge> list = set.get(i);
        if(list == null){
            list = new ArrayList<>();
        }
        list.add(e);
        set.put(i, list);
    }

}


Measured memory_bytes: 117896
x, y = map(int, input().split())

dic = {'A': [1, 3, 5, 7, 8, 10, 12], 'B': [4, 6, 9, 11], 'C': [2]}

gx = 0
gy = 0
for key, value in dic.items():
    if x in value:
        gx = key
    if y in value:
        gy = key
ans = 'Yes' if gx == gy else 'No'
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

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

    // 色が変わるところを示すテーブル
    // i番目のレート以上、i+1番目のレート以下で、i番の色
    // ただし3200を超えたら、好きな色をつけることができます。
    const std::vector<int> color_ranges = { 1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200 };

    // ただし便宜的に色が9色あることにする。
    // 最後の色は、実は色ではなくて、「好きな色を使える」ことなので注意。
    std::vector<bool> color_used = std::vector<bool>(8, false);  // 8色あって、初期値はfalseです。と言う指定

    // 自由な色を使って良いメンバーが何人いるか
    // 基本的に、みんな自由な色を使えることにしてしまう。
    // しかし、「使わなきゃいけない色」が見つかったら、ここから減らす。
    int free_color_members = N;

    // 入力しながら色を振り分けていく
    for( size_t i = 0; i < N; ++i ) {
        int rate;
        std::cin >> rate;

        // 上のテーブルを使って各メンバーを色に振り分けていきます。
        // もちろん配列を使わずにif文で地道に振り分けてもOKです。(大変ですけどね!)
        for( size_t j = 0; j < color_ranges.size() - 1; ++j ) {
            // この範囲がj番目の色になる範囲
            const int min = color_ranges[ j ];
            const int max = color_ranges[ j + 1 ];

            if( min <= rate && rate < max ) {
                // 指定の色が使われたことを指定しておく
                color_used[ j ] = true;
                // 使うべき色が見つかったので、自由な色は使えない。1つ減らす。
                free_color_members -= 1;
                break;
            }
        }
    }

    // 何種類の色が、決め打ちで使用済みなのか調べる
    int used_colors = 0;
    for( size_t i = 0; i < 8; ++i ) {
        if( color_used[ i ] > 0 ) {
            used_colors += 1;
        }
    }

    // さて、ここの条件は妙にややこしい。
    // 決め打ちの色の人が1人でもいるなら、
    //  最小値は、自由な色を指定できる人が、全員決め打ちの色の人の色を選ぶことになる。
    //  最大値は、自由な色を指定できる人が、誰も使っていない色だけを使うことになる
    // 決め打ちの色の人が1人もいないなら
    //  最小値は、自由な色を指定できる人が、全員同じ色を指定するということになる。
    //      しかしそもそも、自由な色を指定できる人が1人もいない場合と、そうでない場合で別れる。
    //          自由な色を指定できる人が1人もいない時は、0になる
    //          自由な色を指定できる人が1人でもいる場合は、1になる
    //  最大値は、自由な色を指定できる人が、全員異なる色を指定するということになる。

    if( used_colors == 0 && free_color_members == 0 ) {
        std::cout << 0 << " " << 0 << std::endl;
    } else if ( used_colors == 0 && free_color_members != 0 ) {
        std::cout << 1 << " " << free_color_members << std::endl;
    } else if ( used_colors != 0 && free_color_members == 0 ) {
        std::cout << used_colors << " " << used_colors << std::endl;
    } else if ( used_colors != 0 && free_color_members != 0 ) {
        std::cout << used_colors << " " << used_colors + free_color_members << std::endl;
    }

    return 0;
}

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

char buf[309];
const int INF = 1<<29;

int main(){
	scanf("%s", buf);

	//K, U, P, Cツづーツカツウツδ督トツつキツづゥ
	int K=0, U=0, P=0, C=0;
	for(int i=0; buf[i]; i++){
		char ch = buf[i];
		if( ch == 'K') K++;
		if( ch == 'U') U++;
		if( ch == 'P') P++;
		if( ch == 'C') C++;
	}

	int ans = INF;
	ans = min(ans, K);
	ans = min(ans, U);
	ans = min(ans, P);
	ans = min(ans, C);

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 1e5+5;
int dp[N];
int a[105];


signed main(){
	IOS
	int n,k;	cin >> n >> k;
	rep(i,n)	cin >> a[i];

	rep(i,k+1){
		dp[i] = 0;
		rep(j,n){
			if(a[j] > i)	break;
			if(dp[i-a[j]] == 0){
				dp[i] = 1;	break;
			}
		}
	}
	if(dp[k])	cout << "First\n";
	else		cout << "Second\n";


}


Measured memory_bytes: 1024
import sys
from collections import deque
from functools import lru_cache
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class Comb:
    def __init__(self, N):
        F = [1] * (N + 1)
        for i in range(N):
            F[i + 1] = (i + 1) * F[i] % mod

        self.d_inv = {}
        self.d_comb = {}
        self.F = F

    def inv(self, a):
        if a not in self.d_inv:
            self.d_inv[a] = pow(a, mod - 2, mod)
        return self.d_inv[a]

    def comb(self, a, b):
        if (a, b) not in self.d_comb:
            self.d_comb[(a, b)] = (self.F[a] * self.inv(self.F[a - b]) * self.inv(self.F[b])) % mod
            self.d_comb[(a, a - b)] = self.d_comb[(a, b)]
        return self.d_comb[(a, b)] 



def main():
    print(1 - int(input()))

if __name__ == "__main__":
    main()



Measured memory_bytes: 67980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);
		
		String a=input.nextLine();
	
		boolean ok=false;
		for(int i=1;i<3;i++)
			if(a.charAt(0)!=a.charAt(i))
				ok=true;
		
		if(ok)
			System.out.println("Yes");
		else
			System.out.println("No");
		
	
	}
	

}


Measured memory_bytes: 35676
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
      
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int k,x;
  cin>>k>>x;

  k--;
  for(int i=x-k;i<x+k;i++){
    cout<<i<<" ";
  }
  cout<<x+k<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=200005;
const int mod=998244353;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
struct pt{int x,y;}w[MAXN];int n;
struct bittree
{
	int s[MAXN];
	void clear(){memset(s,0,sizeof(s));}
	int lowbit(int x){return x&-x;}
	void modify(int x,int c){for(;x<=n;x+=lowbit(x))s[x]+=c;}
	int qry(int x){int ret=0;for(;x>=1;x-=lowbit(x))ret+=s[x];return ret;}
}bi;
bool cmp1(pt n1,pt n2){return n1.x<n2.x;}
bool cmp2(pt n1,pt n2){return n1.y<n2.y;}
int cnt;
int ls[MAXN],lslen;
bool cmp(int n1,int n2){return n1<n2;}
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)w[i].x=read(),w[i].y=read();
	for(int i=1;i<=n;i++)ad(cnt,4LL*(pow_mod(2,i-1)-1)%mod);
	for(int i=1;i<=n;i++)ls[++lslen]=w[i].x;sort(ls+1,ls+1+lslen);
	for(int i=1;i<=n;i++)w[i].x=lower_bound(ls+1,ls+1+lslen,w[i].x)-ls;
	lslen=0;
	for(int i=1;i<=n;i++)ls[++lslen]=w[i].y;sort(ls+1,ls+1+lslen);
	for(int i=1;i<=n;i++)w[i].y=lower_bound(ls+1,ls+1+lslen,w[i].y)-ls;
	sort(w+1,w+1+n,cmp1);
	for(int i=1;i<=n;i++)
	{
		int u1=bi.qry(w[i].y),u2=i-1-u1;
		dl(cnt,(pow_mod(2,u1)-1+mod)%mod);dl(cnt,(pow_mod(2,u2)-1+mod)%mod);
		bi.modify(w[i].y,1);
	}
	bi.clear();
	for(int i=n;i>=1;i--)
	{
		int u1=bi.qry(w[i].y),u2=n-i-u1;
		dl(cnt,(pow_mod(2,u1)-1+mod)%mod);dl(cnt,(pow_mod(2,u2)-1+mod)%mod);
		bi.modify(w[i].y,1);
	}
	cnt=(1LL*n*(pow_mod(2,n)-1)%mod-cnt+mod)%mod;
	pr2(cnt);
	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N, A, B, C, D;
	string S;

	cin >> N >> A >> B >> C >> D;
	cin >> S;
	S += "##";

	A--, B--, C--, D--;
	bool mvA = true, mvB = true;
	while(mvA | mvB) {
		// cerr << A << " " << B << endl;
		mvA = false;
		mvB = false;
		if (A < B) {
			if (C < D) {
				if (S[B+1] == '.' && B+1 <= D) {
					B += 1;
					mvB = true;
				} else if (S[B+2] == '.' && B+2 <= D) {
					B += 2;
					mvB = true;
				} else if (A+1 != B && S[A+1] == '.' && A+1 <= C) {
					A += 1;
					mvA = true;
				} else if (A+2 != B && S[A+2] == '.' && A+2 <= C) {
					A += 2;
					mvA = true;
				}
			} else {
				if (A+1 != B && S[A+1] == '.' && A+1 <= C) {
					A += 1;
					mvA = true;
				} else if (A+2 != B && S[A+2] == '.' && A+2 <= C) {
					A += 2;
					mvA = true;
				} else if (S[B+1] == '.' && B+1 <= D) {
					B += 1;
					mvB = true;
				} else if (S[B+2] == '.' && B+2 <= D) {
					B += 2;
					mvB = true;
				}
			}
		} else {
			if (S[A+1] == '.' && A+1 <= C) {
				A += 1;
				mvA = true;
			} else if (S[A+2] == '.' && A+2 <= C) {
				A += 2;
				mvA = true;
			} else if (B+1 != A && S[B+1] == '.' && B+1 <= D) {
				B += 1;
				mvB = true;
			} else if (B+2 != A && S[B+2] == '.' && B+2 <= D) {
				B += 2;
				mvB = true;
			}
		}
	}

	if (A == C && B == D)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
template<int mod>
struct ModInt {
    int x;
 
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
 
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
 
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
 
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
 
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};
 
using modint = ModInt<mod>;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> t(n),a(n);
    for(int i=0;i<n;i++)cin>>t[i];
    for(int i=0;i<n;i++)cin>>a[i];
    if(t[n-1]!=a[0]){
        cout<<0<<endl;
        return 0;
    }
    modint res=1;
    unordered_map<int,int> d,di;
    for(int i=0;i<n;i++){
        if(i==0||i==n-1)continue;
        if(t[i-1]<t[i]){
            if(t[i]>a[i])res*=0;
        }
        else if(a[i]>a[i+1]){
            if(a[i]>t[i])res*=0;
        }
        else res*=min(a[i],t[i]);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
ans=abs(a[0])+abs(a[n-1])
for i in range(n-1):
  ans+=abs(a[i]-a[i+1])
print(ans-abs(a[0])-abs(a[0]-a[1])+abs(a[1]))
for i in range(1,n-1):
  print(ans-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]))
print(ans-abs(a[n-2]-a[n-1])-abs(a[n-1])+abs(a[n-2])) 

Measured memory_bytes: 14168
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

void solution()
{
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] = s[k-1] - 'A' + 'a';
    cout << s << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split());
S = input();
check_AC = [];

char_prev = "0"
char_now = "0"
for i in S:
    if char_prev == "0":
        char_prev = i;
        check_AC.append(0);
    else:
        char_now = i;
        if(char_prev + char_now == "AC"):
            check_AC.append(check_AC[-1]+1);
        else:
            check_AC.append(check_AC[-1]);
        char_prev = i;

answer = []

for i in range(Q):
    left, right = map(int, input().split());
    answer.append(check_AC[right-1]-check_AC[left-1]);

for i in answer:
    print(i);


Measured memory_bytes: 10288
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n,k,a,b;
  cin >> n >> k >> a >> b;
  if (n>k) cout << k*a+(n-k)*b;
  else cout << n*a << endl;
}


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

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,int>> fs;
    for(ll i = 2; i * i <= n;i++){
        int x = 0;
        while(n % i == 0){
            n /= i;
            x++;
        }
        if(x != 0)fs.emplace_back(i,x);
    }
    if(n != 1) fs.emplace_back(n,1);
    int ans = 0;
    for(auto p: fs){
        int x = p.second;
        int b = 1;
        while( b <= x){
            x -= b;
            b++;
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3600
import collections

ORD_A = ord("a")


def count_chars(s):
    counter = [0 for _ in range(26)]
    for c in s:
        counter[ord(c) - ORD_A] += 1

    return counter


def main():
    n = int(input())
    anagram_counter = collections.Counter(tuple(count_chars(input())) for _ in range(n))

    combinations_times_2 = sum(v * (v - 1) for v in anagram_counter.values())
    print(combinations_times_2 // 2)


if __name__ == "__main__":
    main()


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

int c[16], x[20001];
int dp[20001][256];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, m)scanf("%d", &c[i]);
		rep(i, n)scanf("%d", &x[i]);
		memset(dp, 0x3f, sizeof(dp));
		dp[0][128] = 0;
		rep(i, n)rep(j, 256) {
			if (dp[i][j] == INF)continue;
			rep(k, m) {
				int a = min(255, max(0, j + c[k]));
				dp[i + 1][a] = min(dp[i + 1][a], dp[i][j] + (x[i] - a)*(x[i] - a));
			}
		}
		int Min = INF;
		rep(j, 256)Min = min(Min, dp[n][j]);
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 23276
#include <bits/stdc++.h>
using namespace std;
char s[3005], t[3005], ans[3005];
int dp[3005][3005], slen, tlen, alen;
int main(){
	char c;
	slen = 0;
	while (1){
		scanf("%c", &c);
		if (c == '\n') break;
		s[slen] = c;
		slen ++;
	}
	
	tlen = 0;
	while (1){
		scanf("%c", &c);
		if (c == '\n') break;
		t[tlen] = c;
		tlen ++;
	}
	
	for (int i=0;i<slen;i++){
		for (int j=0;j<tlen;j++){
			if (s[i] == t[j]){
				dp[i+1][j+1] = dp[i][j] + 1;
			} else {
				dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
			}
		}
	}
	
	alen = 0;
	int i = slen, j = tlen;
	while (i>0 && j>0){
		if (dp[i][j] == dp[i-1][j]){
			i--;
		} else if (dp[i][j] == dp[i][j-1]){
			j--;
		} else {
			ans[alen] = s[i-1];
			alen++;
			i--;
			j--;
		}
	}
	
	for (int i=alen-1;i>=0;i--){
		printf("%c", ans[i]);
	}
	printf("\n");
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cassert>
using namespace std;

const int MAXM = 1001;
const int INF = 1<<28;
int M, N;
map<string,int> id;
int px[MAXM], py[MAXM];
vector<int> G[MAXM];
pair<int,int> cost[4][MAXM];

struct State {
  int d, v;
  pair<int,int> cost;
  bool operator < (const State &s) const {
    return cost > s.cost;
  }
};

int getDir(int prev, int now) {
  int dx = px[now] - px[prev];
  int dy = py[now] - py[prev];
  assert(dx == 0 && dy != 0 || dx != 0 && dy == 0);
  if(dx >=  1) return 0;
  if(dy >=  1) return 1;
  if(dx <= -1) return 2;
  if(dy <= -1) return 3;
  assert(false);
  return -1;
}

int getDist(int prev, int now) {
  int dx = px[now] - px[prev];
  int dy = py[now] - py[prev];
  return abs(dx) + abs(dy);
}

int bfs(int src, int dst) {
  fill(cost[0], cost[4], make_pair(INF,INF));
  cost[0][src] = make_pair(0,0);
  cost[1][src] = make_pair(0,0);
  cost[2][src] = make_pair(0,0);

  cost[3][src] = make_pair(0,0);
  priority_queue<State> que;
  que.push((State){0,src,make_pair(0,0)});
  que.push((State){1,src,make_pair(0,0)});
  que.push((State){2,src,make_pair(0,0)});
  que.push((State){3,src,make_pair(0,0)});
  while(que.size()) {
    State s = que.top();
    que.pop();
    if(cost[s.d][s.v] != s.cost) continue;
    if(s.v == dst) return s.cost.second;
    for(int k = 0; k < G[s.v].size(); ++k) {
      int nv = G[s.v][k];
      int nd = getDir(s.v, nv);
      pair<int,int> ncost
        = make_pair(s.cost.first + getDist(s.v, nv), s.cost.second + 1);
      if((nd-s.d+4)%4 > 1) continue;
      if(cost[nd][nv] < ncost) continue;
      cost[nd][nv] = ncost;
      que.push((State){nd, nv, ncost});
    }
  }
  return INF;
}

int main() {
  while(cin >> M >> N && (M|N)) {
    fill(G, G+MAXM, vector<int>());
    id.clear();
    for(int i = 0; i < M; ++i) {
      string s;
      cin >> s >> px[i] >> py[i];
      id[s] = i;
    }
    for(int i = 0; i < N; ++i) {
      string s, t;
      cin >> s >> t;
      G[id[s]].push_back(id[t]);
      G[id[t]].push_back(id[s]);
    }
    string src, dst;
    cin >> src >> dst;
    int res = bfs(id[src], id[dst]);
    if(res == INF) cout << "impossible" << endl;
    else cout << res+1 << endl;
  }
  return 0;
}

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

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

int main(){
    int N;
    cin >> N;
    LL A[N];
    REP(i,N) cin >> A[i];
    sort(A,A+N);
    LL ans=0;
    REP(i,N) ans=gcd(ans,A[i]);
    cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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() {
  ll a, b, n;
  cin >> a >> b >> n;

  if (b - 1 > n) {
    cout << a * n / b << endl;
  } else {
    cout << a * (b - 1) / b << endl;
  }

  return 0;
}

Measured memory_bytes: 3640
#%%
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

x = factorization(n)
#print(x)
l = []
for i in range(len(x)):
    for j in range(x[i][1]):
        l.append(x[i][0])
#print(l)

import itertools
c = list(itertools.product(range(2), repeat=len(l)))

flag = False
for i in range(len(c)):
    a = 1
    b = 1
    for j in range(len(c[i])):
        if c[i][j] == 0:
            a *= l[j]
        else:
            b *= l[j]
    if a <= 9 and b <= 9:
        flag = True

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


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


int main() {
    int n;
    cin >> n;
    vector<int> l(n);

    for(int i = 0;i < n;i ++){
        cin >> l.at(i);
    }

    sort(l.begin(),l.end());

    int sum = 0;
    for(int i = 0;i < n-1;i ++){
        sum += l.at(i);
    }
    if(l.at(n-1) < sum){
        cout << "Yes"  << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 764
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  REP(i, 0, N) {
    ll a;
    cin >> a;
    A[i] = a;
  }

  ll a = 1;
  ll b = 1;
  REP(i, 0, N) {
    a *= 3;
    if(A[i] % 2 == 0) {
      b *= 2;
    }
  }
  cout << a - b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    char a;
    cin>>a;
    if(a=='A'){cout<<'T'<<endl;
    }else if(a=='G'){cout<<'C'<<endl;
    }else if(a=='C'){cout<<'G'<<endl;
    }else if(a=='T'){cout<<'A'<<endl;}


    return 0;
}


Measured memory_bytes: 256
k,n = map(int,input().split())
a = [int(i) for i in input().split()]
a += [a[0]+k]
sum = 0
max = 0

for i in range(n) :
    d = abs(a[i]-a[i+1])
    sum += d
    if max<d :
        max = d
#    print(sum,d,max)

print(sum-max)


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

int main() {
  string s, t;
  cin >> s >> t;
  t.erase(t.size() - 1);
  bool flag = false;
  if(s == t) flag = true;
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3604
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    N, *A = map(int, read().split())
    dic = defaultdict(lambda:0)
    for a in A:
        dic[a] += 1
    G = {}

    for key in sorted(list(dic.keys())):
        G[N] = key
        N -= dic[key]

    criteria = 0
    for key in G.keys():
        if G[key] % 2:
            criteria ^= key

    if not criteria:
        print('second')
    else:
        print('first')
if __name__ == "__main__":
    run()


Measured memory_bytes: 33108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a,b;
    a = count(all(s),'0');
    b = s.size() - a;
    cout << min(a*2,b*2) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define cy cout << "YES" << endl;
#define cn cout << "NO" << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{

    long long a,b,c,d,e;
    cin >> a;
     map<long long,long long>mp;
    vector<long long>vec;
    while(a--)
    {
        cin >> b;
        mp[b]++;
    }

    for(auto it=mp.begin();it!=mp.end();it++){
        if(it->second>=4)
        {
            vec.push_back(it->first);
            vec.push_back(it->first);
        }
        if(it->second>=2)

        {
            vec.push_back(it->first);
        }

    }
    sort(vec.begin(),vec.end());
    if(vec.size()>1)
    {
        long long x=vec[vec.size()-1]*vec[vec.size()-2];
        cout << x << endl;

    }
    else{
        cout << 0 << endl;
    }


}


Measured memory_bytes: 9640