akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import math,sys

n = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split()))
#n = int(input())
#a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
acc = a[0]
for i in range(n):
    acc = math.gcd(acc,a[i])
if acc != 1:
    print("not coprime")
    exit()

LIMIT=max(a)
minPrime = [0]*(LIMIT+1)
minPrime[1] = 1
def make():
    for i in range(2,LIMIT+1):
        if minPrime[i] == 0:
            minPrime[i] = i
            #print(i)
            for j in range(i+i,LIMIT+1,i):
                #print(i,j)
                if minPrime[j] == 0:
                    minPrime[j] = i
make()
def factrial(N):
     ret = []
     while minPrime[N] != N:
         ret.append(minPrime[N])
         N = N//minPrime[N]
     if N != 1:
         ret.append(N)
     return ret

judge = set([])

for e in a:
    asf = set(factrial(e))
    if judge & asf != set():
        print("setwise coprime")
        exit()
    judge |= asf
    #judge = judge | asf #too slow
print("pairwise coprime")

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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

void Main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;



int main(){
    int h,w,ch,cw,dh,dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    char s[h+2][w+2];
    int mp[h+2][w+2];
    int lf[h+2][w+2];
    for(int i = 0; i < h+2; i++){
        for(int j = 0; j < w+2; j++){
            if(i == 0 || i == h+1 || j == 0 || j == w+1){
                s[i][j] = '#';
            } else {
                cin >> s[i][j];
            }
            mp[i][j] = 999999999;
            lf[i][j] = 0;
        }
    }

    queue<pair<int, int>> q_walk;
    queue<pair<int,int>> q_walked;

    q_walk.push(make_pair(ch,cw));

    int dir_x[] = {1,0,-1,0};
    int dir_y[] = {0,1,0,-1};
    int ans = -1;
    int wrp_num = 0;
    do{
        while(q_walk.size() != 0){
            int x, y;
            auto pos = q_walk.front();
            x = pos.first;
            y = pos.second;
            q_walk.pop();

            //cout << "x:" << x << " y:" << y << " wrp:" << wrp_num << endl;
            if(mp[x][y] < wrp_num) continue;
            q_walked.push(make_pair(x,y));
            if(x == dh && y == dw){
                ans = wrp_num;
                break;
            }
            mp[x][y] = wrp_num;
            lf[x][y] = 1;


            for(int i = 0; i < 4; i++){
                if(s[x+dir_x[i]][y+dir_y[i]] == '.' && lf[x+dir_x[i]][y+dir_y[i]] == 0){
                    q_walk.push(make_pair(x+dir_x[i],y+dir_y[i]));
                    lf[x+dir_x[i]][y+dir_y[i]] = 1;
                }
            }
        }
        if(ans != -1) break;

        while(q_walked.size() > 0){
            auto pos = q_walked.front();
            int x = pos.first;
            int y = pos.second;
            q_walked.pop();
            for(int i = -2; i < 3; i++){
                for(int j = -2; j < 3; j++){
                    if(x+i < 0 || x+i > h+1 || y+j < 0 || y+j > w+1) continue;
                    if(s[x+i][y+j] == '.' && lf[x+i][y+j] == 0){
                        //cout << "x_i:" << x+i << " y_j:" << y+j << endl;
                        q_walk.push(make_pair(x+i,y+j));
                        lf[x+i][y+j] = 1;
                    }
                }
            }
        }
        wrp_num++;
        if(q_walk.size() == 0) break;
    } while(true);

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

Measured memory_bytes: 12412
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {
  int n;
  while(cin >> n){
    if( n == 0 ) break;
    vector< vector<int> > a(n, vector<int>(n, -1));
    int cnt = 0;
    int x = n/2;
    int y = x + 1;
    while( cnt < n*n ){
      if( a[y][x] == -1 ){
        a[y][x] = cnt + 1;
        x += 1; y += 1;
        cnt++;
      }else{
        x -= 1; y += 1;
      }
      if( x >= n ) x = 0;
      else if( x < 0 ) x = n-1;
      if( y >= n ) y = 0;
      else if( y < 0 ) y = n-1;

    }
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        printf("%4d", a[i][j]);
      }
      cout << endl;
    }

  }

  return 0;
}

// EOF

Measured memory_bytes: 3108
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;

using namespace std;

int main() 
{
    map<int, int> a;
    irep(i, 3) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }

    for(auto ans : a) {

        if(ans.second == 1) {
            cout << ans.first << endl;
        }
    }
    return 0;
}
    



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
int mapp[100010];
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        memset(mapp,0,sizeof(mapp));
        for(int i=2; i<=N; i++)
        {
            int x=i;
            for(int j=2; j<=x; j++)
            {
                while(x%j==0)
                {
                    mapp[j]++;
                    x/=j;
                }
            }
               if(x!=1)
            mapp[x]++;
        }
        long long sum=1;
        for(int i=1;i<=N;i++)
        {
            if(mapp[i]!=0)
                sum = (sum*(mapp[i]+1))%1000000007;
        }
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 640
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, W) = scan!(usize, i64);
    let items = scan!(i64, usize;n);
    let mut dp = vec![vec![1 << 60; n * 1_000 + 1]; n + 1];

    dp[0][0] = 0;
    for i in 0..items.len() {
        for j in 0..dp[i].len() {
            dp[i + 1][j] = if j >= items[i].1 {
                min(dp[i][j], dp[i][j - items[i].1] + items[i].0)
            } else {
                dp[i][j]
            }
        }
    }

    println!(
        "{}",
        dp[n]
            .iter()
            .enumerate()
            .filter(|&(_, &w)| w <= W)
            .map(|(v, _)| v)
            .max()
            .unwrap()
    )
}


Measured memory_bytes: 106748
import sys
import queue

H,W = map(int,input().split())


white = 0
	
maze = []

for y in range(H):
	li = list(input())
	white += li.count('.')
	maze.append(li)

if maze[0][0] == '#' or maze[H-1][W-1] == '#':
	print (-1)
	sys.exit()

	
maze[H-1][W-1] = 'g'
	
q = queue.Queue()
q.put([0,0,0])

def check(x,y,n):
	if 0 <= x < W and 0 <= y < H:
		if maze[y][x] == 'g':
			print (white - n - 1)
			sys.exit()
		elif maze[y][x] == '.':
			maze[y][x] = n
			q.put([x-1,y,n+1])
			q.put([x+1,y,n+1])
			q.put([x,y-1,n+1])
			q.put([x,y+1,n+1])
		else:
			return
	else:
		return


while not q.empty():
	x,y,n = q.get()
	check(x,y,n)
	
print(-1)


Measured memory_bytes: 3952
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    for(;;){
        int ans[10024] = {0};
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        if(a == 0 && b == 0 && c == 0)break;

        for(int i = 1;i < 1024; i++)ans[i] = 2;

        int n;
        scanf("%d",&n);

        int x[1002],y[1002],z[1002],r[1002];//r check
        for(int i = 0;i < n; i++){
            scanf("%d%d%d%d",&x[i],&y[i],&z[i],&r[i]);
            if(r[i] == 1){
                ans[x[i]] = 1;
                ans[y[i]] = 1;
                ans[z[i]] = 1;
                }
        }

        for(int i = 0;i < n; i++){
            if(r[i] == 0){
                if(ans[x[i]] == 1 && ans[y[i]] == 1 && ans[z[i]] != 1)ans[z[i]] = 0;
                else if(ans[x[i]] == 1 && ans[y[i]] != 1 && ans[z[i]] == 1)ans[y[i]] = 0;
                else if(ans[x[i]] != 1 && ans[y[i]] == 1 && ans[z[i]] == 1)ans[x[i]] = 0;
            }
        }

        for(int i = 1;i < a+b+c+1; i++)printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1248
(defun solver ()
  (let ((a (read)) (b (read)) (c (read))
        (x (read))
        (count 0))
    (loop for i from 0 to a do
          (loop for j from 0 to b do
                (loop for k from 0 to c do
                      (when (= (+ (* 500 i) (* 100 j) (* 50 k)) x)
                        (incf count)))))
    (format t "~a~%" count)))

(solver)


Measured memory_bytes: 4328
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a, b;
  scanf("%d %d",&a,&b );
  if (a>9 || a<1 || b>9 || b<1)
    printf("-1\n");
  else
    printf("%d\n",a*b );
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  for(long n=1;n<=3500;n++)for(long w=1;w<=3500;w++){
    long a=N*n*w,b=4*n*w-N*n-N*w;
    if(b>0&&a%b==0){cout<<a/b<<" "<<n<<" "<<w;return 0;}
  }
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 

def main():
    n = getN()
    S = getS()
    dp = [0] * (11*11*11)
    dp[0] = 1
    for c in S:
        tmp = [0] * (11*11*11)
        for i, d in enumerate(dp):
            if d == 1:
                tmp[i] = 1
                tmp[(i%121) * 11 + int(c) + 1] = 1

        dp = tmp
        # print(dp[-999:])
        # print(sum(dp[-999:]))

    print(sum(dp[(11*11):]))


 
if __name__ == "__main__":
    main()
   

Measured memory_bytes: 77612
h, w = map(int, input().split())
s = [[c for c in str(input())] for i in range(h)]
#print(s)
cando = True
for i in range(h):
  for j in range(w):
    if s[i][j] == '.': continue
    adj = False
    if i > 0 and s[i-1][j] == '#': adj = True
    if i < h-1 and s[i+1][j] == '#': adj = True
    if j > 0 and s[i][j-1] == '#': adj = True
    if j < w-1 and s[i][j+1] == '#': adj = True
    if not adj:
      cando = False
      break
  if not cando: break
if cando: print('Yes')
else: print('No')

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

int main()
{
    ll x,w,i,j,k;
    cin>>x;
    ll a[x],v[x];
    cin>>w;
    for(i=0;i<x;i++)
        cin>>a[i]>>v[i];
    ll dp[x+1][w+1];
    for(i=0;i<=x;i++){
        for(j=0;j<=w;j++){
            if(j==0 || i==0)
                dp[i][j]=0;
        }
    }
    for(i=1;i<=x;i++){
            ll ans=0;
        for(j=1;j<=w;j++){
            if(a[i-1]<=j)
                dp[i][j]=max(v[i-1]+dp[i-1][j-a[i-1]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[x][w]<<endl;
}


Measured memory_bytes: 79104
#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() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s == u) --a;
  else --b;
  printf("%d %d\n", a, b);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define INF 10000000;
using namespace std;
int n,m;
long long dp[100][100];
int a[1000],b[1000],c[1000];

void initialize(void){
	for(int lp1=0;lp1<100;lp1++){
		for(int lp2=0;lp2<100;lp2++){
			if(lp1==lp2){
				dp[lp1][lp2]=0;
			}else{
				dp[lp1][lp2]=INF;
			}
		}
	}
}

void input(void){
	int edge_a,edge_b,edge_c;
	scanf("%d %d",&n,&m);
	for(int lp1=0;lp1<m;lp1++){
		scanf("%d %d %d",&edge_a,&edge_b,&edge_c);
		a[lp1]=edge_a;
		b[lp1]=edge_b;
		c[lp1]=edge_c;
		dp[edge_a-1][edge_b-1]=edge_c;
		dp[edge_b-1][edge_a-1]=edge_c;
	}
}

void shortestpath(void){
	for(int lp1=0;lp1<n;lp1++){
		for(int lp2=0;lp2<n;lp2++){
			for(int lp3=0;lp3<n;lp3++){
				dp[lp2][lp3]=std::min(dp[lp2][lp3],dp[lp2][lp1]+dp[lp1][lp3]);
			}
		}
	}
} 

void pathprint(void){
	printf("pathprint called\n");
	for(int lp1=0;lp1<n;lp1++){
		for(int lp2=0;lp2<n;lp2++){
			printf("%d to %d is %d\n",lp1,lp2,dp[lp1][lp2]);
		}
	}
}

int solve(void){
	bool shortest=false;
	int answer=0;
	for(int lp1=0;lp1<m;lp1++){
		if(c[lp1]>dp[a[lp1]-1][b[lp1]-1]) answer++;
	}
	return answer;
}

int main(void){
	initialize();
	input();
	//pathprint();
	shortestpath();
	//printf("going to call pathprint2\n");
	//pathprint();
	printf("%d\n",solve());
	return 0;
}
	


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
using namespace std;



int main() {
	int n;
	char s[114];
	bool flg = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == 'Y') {
			flg = false;
			break;
		}
	}
	if (flg) {
		cout << "Three";
	}
	else {
		cout << "Four";
	}
	return 0;
}





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

int main(){
	int s;
	double h,w;
	char cnm[2];
	double BMI;
	
	while(cin>>s>>cnm[0]>>w>>cnm[1]>>h){
		BMI = w/pow(h,2);
		
		if(BMI>=25.0){
			cout<<s<<endl;
		}
	}

}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl;})

int main(){
	cin.sync_with_stdio(0);

	string s,t;
	cin >> s >> t;

	vvl m(sz(s) + 1, vl(sz(t) + 1));

	FOR(i,1,sz(s)+1){
		FOR(j,1,sz(t)+1){
			if(s[i - 1] == t[j - 1]){
				m[i][j] = m[i - 1][j - 1] + 1;
			}else{
				m[i][j] =  max(m[i][j - 1], m[i - 1][j]);
			}
		}
	}

	string out;

	ll i = sz(s);
	ll j = sz(t);

	while(i > 0 && j > 0){
		if(s[i - 1] == t[j - 1]){
			out = s[i - 1] + out;
			i--;
			j--;
		}else if(m[i - 1][j] > m[i][j - 1]){
			i--;
		}else{
			j--;
		}
	}

	cout << out << endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};
// other libs
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)
				continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};
template<typename T>
class Union_Find {
  private:
	vector<T> t, s;

  public:
	Union_Find(T max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(T x, T y) {
		if (same(x, y))
			return;
		T tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	T Find(T n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(T x, T y) {
		return Find(x) == Find(y);
	}

	T get_Size(size_t a) {
		return s[a];
	}
};
bool ifPrime(int n) {
	if (n == 1)
		return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)
			return false;
	}
	return true;
}

set<int> prime_num_factor(int n){
    if(n<2)return set<int>();
    set<int> prime;
    prime.insert(2);
    for(int i=3;i<=n;i++){
        for(int it:prime){
            if(it*it>i){
                prime.insert(i);
                break;
            }
            if(i%it==0)break;
        }
    }
    return prime;
}
vector<int> makeDivisors(int n){
    vector<int> re;
    REP(i,1,sqrt(n)+1){
        if(n%i==0){
            re.push_back(i);
            if(i!=n/i)re.push_back(n/i);
        }
    }
    return re;
}
signed main(signed argc, char* argv[]) {
    int a,b,ans=0;
    cin>>a>>b;
    int n=gcd(a,b);
    vector<int> re;
    REP(i,1,((int)sqrt(n))+1){
        if(n%i==0){
            re.push_back(i);
            if(i!=n/i)re.push_back(n/i);
        }
    }
    for(int it:re){
        if(ifPrime(it))ans++;
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

int main(void) {
  int n, x, i;
  int *l;
  scanf("%d %d", &n, &x);
  l = (int*)malloc(n * sizeof(int));
  for(i=0; i<n; i++) {
    scanf("%d", &l[i]);
  }
  int d=0;
  for(i=0; d<=x && i<n; i++) {
    d += l[i];
  }
  if(d<=x) {
    i++;
  }
  printf("%d\n", i);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
/*-------------------Basis Functions----------------------*/
template<class T> inline void dmin(T& x,T y){ y<x?x=y:0; }
template<class T> inline void dmax(T& x,T y){ y>x?x=y:0; }
template<class T> inline void dmin(T& x,vector<T> y){ 
	for(auto t:y) t<x?x=t:0;
}
template<class T> inline void dmax(T& x,vector<T> y){
	for(auto t:y) t>x?x=t:0;
}
int to_min(pair<int,int> a){
	return a.first*60+a.second;
}
pair<int,int> to_pair(int x){
	return make_pair(x/60,x%60);
}
int main(){
	string s; cin>>s;
	for(int i=0;i<s.length();++i)
		if(s[i]=='?') s[i]='D';
	cout<<s<<endl;
	return 0;
}

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

int main(){
	int n;cin>>n;
	vector<long long> v(n);
	long long M=1e9+7;
	for(int i=0;i<n;i++) cin>>v[i];
	vector<long long> s(n,0);
	s[n-1]=v[n-1];
	for(int i=n-2;i>=0;i--){
		s[i]=(s[i+1]+v[i])%M;
	}
	long long p=0;
	for(int i=0;i<n-1;i++){
		p=(p + v[i]*s[i+1])%M;
	}
	cout<<p<<endl;
}

Measured memory_bytes: 6416
macro_rules! read {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

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

fn main() {
    let val: Vec<i32> = read_to_vec();
    let (n, mut x) = (val[0], val[1]);
    let val: Vec<i32> = read_to_vec();

    for (i, l) in val.iter().enumerate() {
        x -= *l;
        if x < 0 {
            println!("{}", i+1);
            return;
        }
    }

    println!("{}", n+1)
}

Measured memory_bytes: 4352
/*
 * 2428.cc: Lost Number
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 5;
const int MIN_D = 0;
const int MAX_D = (1 << 10) - 1;

const int CN = 7;
const char chs[CN] = { '0', '1', '+', '-', '*', '(', ')' };

/* typedef */

/* global variables */

int ps[MAX_N], cnts[MAX_N];

/* subroutines */

int num(string &s, int &pos);
int coef(string &s, int &pos);
int term(string &s, int &pos, bool &opf);
int expr(string &s, int &pos, bool &opf);

int num(string &s, int &pos) {
  if (pos >= s.size() || (s[pos] != '0' && s[pos] != '1')) return -1;
  int num = 0;
  while (pos < s.size() && s[pos] >= '0' && s[pos] <= '1') {
    num = 2 * num + s[pos++] - '0';
    if (num > MAX_D) return -1;
  }
  return num;
}

int coef(string &s, int &pos) {
  if (pos >= s.size()) return -1;

  if (s[pos] == '(') {
    pos++; // '('

    bool ok = false;
    for (int i = pos; i < s.size() && s[i] != ')'; i++)
      if (s[i] != '0' && s[i] != '1') {
	ok = true;
	break;
      }
    if (! ok) return -1;

    bool opf = false;
    int e = expr(s, pos, opf);
    if (pos >= s.size() || s[pos] != ')' || ! opf) return -1;
    pos++; // ')'
    return e;
  }

  return num(s, pos);
}

int term(string &s, int &pos, bool &opf) {
  if (pos >= s.size()) return -1;
  int c0 = coef(s, pos);
  if (c0 < 0) return -1;

  while (pos < s.size() && s[pos] == '*') {
    pos++; // '*'
    int c1 = coef(s, pos);
    opf = true;
    if (c1 < 0) return -1;

    c0 *= c1;
    if (c0 < MIN_D || c0 > MAX_D) return -1;
  }

  return c0;
}

int expr(string &s, int &pos, bool &opf) {
  if (pos >= s.size()) return -1;
  int t0 = term(s, pos, opf);
  if (t0 < 0) return -1;

  while (pos < s.size() && (s[pos] == '+' || s[pos] == '-')) {
    char opc = s[pos++]; // '+' || '-'
    int t1 = term(s, pos, opf);
    opf = true;
    if (t1 < 0) return -1;

    t0 = (opc == '+') ? t0 + t1 : t0 - t1;
    if (t0 < MIN_D || t0 > MAX_D) return -1;
  }

  return t0;
}

/* main */

int main() {
  string s;
  cin >> s;
  int l = s.size();

  int n = 0;
  for (int i = 0; i < l; i++)
    if (s[i] == '.') ps[n++] = i;
  //printf("n=%d\n", n);

  int maxd = -1;

  for (;;) {
    for (int i = 0; i < n; i++)
      s[ps[i]] = chs[cnts[i]];

    int pos = 0;
    bool opf;
    int d = expr(s, pos, opf);
    if (pos == l && maxd < d) {
      maxd = d;
      //cout << s; printf(" = %d\n", d);
    }
    
    int k = 0;
    while (k < n) {
      if (++cnts[k] < CN) break;
      cnts[k++] = 0;
    }
    if (k >= n) break;
  }

  printf("%d\n", maxd);
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  cout << "ABC" << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main() {
  ll X,K,D;
  cin >> X >> K >> D;
  X = abs(X);
  ll cnt = min(K,X/D);
  K -= cnt;
  X -= D * cnt;
  if(K % 2 == 0) cout << X << endl;
  else cout << D - X << endl;
  
}



Measured memory_bytes: 3232
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

one = r*g*b
not_two = 0

for i in range(0,n-1,1):
    for j in range(i+1,n,1):
        k = j+(j-i)
        if k < n and s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
            not_two += 1

ans = one - not_two
print(str(ans))

Measured memory_bytes: 67992
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
using Interval = pair<i64, bool>;
int main() {
    const bool L = false, R = true;
    const i64 INVALID = -1e18;
    i64 N, X, D;
    cin >> N >> X >> D;
    if(D == 0) {
        if(X == 0) {
            cout << 1 << endl;
        } else {
            cout << N + 1 << endl;
        }
        return 0;
    }
    if(D < 0) D *= -1, X *= -1;
    // i -> [[l:r]...]
    // TがDで割った商の範囲が[l:r]で余りがiとなる場合
    map<i64, multiset<Interval>> I;
    for(i64 M = 0; M <= N; M++) {
        i64 l = (M * (M - 1)) / 2;
        i64 r = (M * (2 * N - M - 1)) / 2;
        i64 rem = ((M * X) % D + D) % D;
        i64 quo = (M * X - rem) / D;
        I[rem].insert({quo + l, L});
        I[rem].insert({quo + r, R});
    }
    i64 ans = 0;
    for(auto &s : I) {
        int num = 0;
        i64 p = INVALID;
        for(auto i : s.second) {
            if(num == 0) {
                p = i.first - 1;
            } else {
                ans += i.first - p;
                p = i.first;
            }
            if (i.second == L) num++;
            if (i.second == R) num--;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 44032
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;

int main() {
    int N, C;
    cin >> N >> C;
    int d[C][C], c[N][N];
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> d[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    int color[3][C];
    for (int i = 0; i < 3; i++) {
        fill(color[i], color[i] + C, 0);
    }
    for (int k = 0; k < C; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                color[(i + j) % 3][k] += d[c[i][j]][k];
            }
        }
    }
    int ans = INF;
    for (int i = 0; i < C; i++) {
        for (int j = i + 1; j < C; j++) {
            for (int k = j + 1; k < C; k++) {
                int x[] = {0, 1, 2};
                do {
                    ans = min(ans, color[x[0]][i] + color[x[1]][j] + color[x[2]][k]);
                } while (next_permutation(x, x + 3));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int DIM = 2e5 + 5;

vector<int> stk;
int arr[DIM], lef[DIM], rig[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    stk.assign( 1, 0 );
    for( int i = 1; i <= n; i ++ ) {
        while( arr[i] <= arr[stk.back()] )
            stk.pop_back();
        
        lef[i] = stk.back() + 1;
        stk.push_back( i );
    }
    
    stk.assign( 1, n + 1 );
    for( int i = n; i >= 1; i -- ) {
        while( arr[i] <= arr[stk.back()] )
            stk.pop_back();
        
        rig[i] = stk.back() - 1;
        stk.push_back( i );
    }
    
    long long ans = 0;
    for( int i = 1; i <= n; i ++ )
        ans += 1LL * arr[i] * ( i - lef[i] + 1 ) * ( rig[i] - i + 1 );
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int NMAX = 100005;

vector<pair<int, int>> G[NMAX];
int cnt[3], cntAll = 0;
int cntEdges = 0;
bool used[NMAX];
int values[NMAX];

bool complete;

void dfs(int node) {
    used[node] = true;
    cnt[values[node]]++;
    cntAll++;
    cntEdges += SZ(G[node]);
    for (const pair<int, int>& p: G[node]) {
        int to = p.first;
        int add = p.second;
        if (!used[to]) {
            values[to] = (values[node] + add) % 3;
            dfs(to);
        } else {
            if (values[to] != (values[node] + add) % 3) {
                complete = true;
            }
        }
    }
}

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(make_pair(y, 1));
        G[y].push_back(make_pair(x, 2));
    }
    int64_t ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (!used[i]) {
            memset(cnt, 0, sizeof cnt);
            cntAll = 0;
            cntEdges = 0;
            complete = false;
            dfs(i);
            cntEdges /= 2;
            if (complete) {
                ans += (int64_t) cntAll * cntAll;
            } else if (cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0) {
                ans += (int64_t) cnt[0] * cnt[1] +
                    (int64_t) cnt[1] * cnt[2] +
                    (int64_t) cnt[2] * cnt[0];
            } else {
                ans += cntEdges;
            }
        }
    }
    cout << ans << '\n';
}

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

const int maxN = 2e3; int n;
lli a[maxN];
vector<pair<lli, int>> all;

lli memo[maxN][maxN];
lli solve(int i = 0, int lo = 0, int hi = n - 1)
{
  if (i == n) return 0;
  if (memo[lo][hi] != -1) return memo[lo][hi];

  lli ans = max
  (
    solve(i + 1, lo + 1, hi) + a[all[i].second] * abs(all[i].second - lo),
    solve(i + 1, lo, hi - 1) + a[all[i].second] * abs(all[i].second - hi)
  );
  return memo[lo][hi] = ans;
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    all.clear();
    for (int i = 0; i < n; i++)
      scanf("%lld", &a[i]);

    
    for (int i = 0; i < n; i++)
    {
      int left = i, right = n - i - 1;
      all.push_back({a[i], i});
    }
    sort(all.begin(), all.end());
    reverse(all.begin(), all.end());

    memset(memo, -1, sizeof(memo));
    lli ans = solve();
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 35280
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if (a == 0 & b == 0)
                break;
            for (int i = 0; i < a; i++) {
                for (int j = 0; j < b; j++) {
                    if (i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1)
                        System.out.print("#");
                    else
                        System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}





Measured memory_bytes: 34676
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    TA=LLIN(N)
    C=1
    D=1
    for t,a in TA:
        n = max((C+t-1)//t , (D+a-1)//a)
        # n = (max(int(ceil(C/t)),int(ceil(D/a))))
        C,D = n*t,n*a
    ans = C+D
    print(int(ans))
if __name__ == '__main__':
    main()

Measured memory_bytes: 39792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll A, B;
  cin >> A >> B;

  ll ans = max({(A + B), (A - B), (A * B)});

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
            using namespace std;
         
            int main(){
              int n,k,temp;
              cin>>n>>k;
              int dp[n];
              vector<int> v;
              for(int i=0;i<n;i++){
              	cin>>temp;
                v.push_back(temp);
                dp[i]=INT_MAX;
              }
              dp[0]=0;
              for(int i=0;i<n;i++)
            	for(int j=1;j<=k;j++)
            		if((i+j)<n)
            			dp[i+j]=min(dp[i+j],dp[i]+abs(v[i+j]-v[i]));
              cout<<dp[n-1]<<endl;
              return 0;
            }

Measured memory_bytes: 1148
# abc103_a.py
# https://atcoder.jp/contests/abc103/tasks/abc103_a

# A - Task Scheduling Problem /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 3個のタスクがあり、あなたは全てのタスクを完了させなければなりません。
# はじめ、任意の 1個のタスクをコスト 0で完了できます。
# また、i番目のタスクを完了した直後にコスト |Aj−Ai| で j番目のタスクを完了できます。
# ここで |x|は xの絶対値を表します。
# 全てのタスクを完了するのに要する合計コストの最小値を求めてください。

# 制約
#     入力は全て整数である
#     1≤A1,A2,A3≤100

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A1 A2 A3

# 出力
# 全てのタスクを完了するのに要する合計コストの最小値を出力せよ。

# 入力例 1
# 1 6 3

# 出力例 1
# 5

# 以下の順番でタスクを完了させたとき、合計コストは 5となり最小です。

#     1番目のタスクをコスト 0で完了させます
#     3番目のタスクをコスト 2で完了させます
#     2番目のタスクをコスト 3で完了させます

# 入力例 2
# 11 5 5

# 出力例 2
# 6

# 入力例 3
# 100 100 100

# 出力例 3
# 0


def calculation(lines):
    values = list(map(int, lines[0].split()))
    mi = min(values)
    ma = max(values)
    return [ma - mi]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['1 6 3']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['11 5 5']
        lines_export = [6]
    if pattern == 3:
        lines_input = ['100 100 100']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9244
//***___********* ___*****___****___***___*********//
/*  |   \  |   | |   |   |   \  |     |     |   |  **
/*  |   |  |   | |___|   |   _  |__   |___  |___|  **
/*  |   |  |   | |   \   |  | | |         | |   |  **
/*  |___/  |___| |    \  |__| | |___  ____| |   |  **
//*************************************************/
#include<bits/stdc++.h>
#define ff double
#define endl "\n"
#define M 1000000007
#define forever while(1)
#define ll long long
#define pb push_back
#define vi vector<long long>
#define mii map<int,int>
#define pii pair<int,int>
#define set_zero(arr) memset(arr,0,sizeof(arr))
#define test ll t;cin>>t;while(t--)
#include <ext/pb_ds/tree_policy.hpp>
#define REP(i,n) for(int i=0;i<(n);i++)
#include <ext/pb_ds/assoc_container.hpp>
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;

int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
bool comp(string a,string b){return a<b;}

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

    cout<<endl;



return 0;
}




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

int main()
{
  int h,w;
  scanf("%d%d",&h,&w);
  static char M[1000][1001];
  for(int i=0;i<h;i++){
    scanf("%s",M[i]);
  }
  static int K[1000][1001]={0};
  int dx[8]={1,1,1,0,0,-1,-1,-1},dy[8]={-1,0,1,-1,1,-1,0,1};
  queue<pair<int,int> > Q[2];
  bool b=0;
  for(int i=1;i<h-1;i++){
    for(int j=1;j<w-1;j++){
      for(int v=0;v<8;v++){
	int x=i+dx[v],y=j+dy[v];
	if(M[x][y]=='.'){
	  K[i][j]++;
	}
      }
      if(M[i][j]!='.'&&K[i][j]>=M[i][j]-'0'){
	Q[b].push(make_pair(i,j));
      }
    }
  }
  int t=0;
  while(!Q[b].empty()){
    while(!Q[b].empty()){
      pair<int,int> p=Q[b].front();
      Q[b].pop();
      int i=p.first,j=p.second;
      for(int v=0;v<8;v++){
	int x=i+dx[v],y=j+dy[v];
	K[x][y]++;
	if(M[x][y]!='.'&&K[x][y]==M[x][y]-'0'){
	  Q[!b].push(make_pair(x,y));
	}
      }
    }
    t++;
    b=!b;
  }
  printf("%d\n",t);
  return 0;
}

Measured memory_bytes: 7664
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A[3][3];
	rep(i, 0, 3)rep(j, 0, 3)
	{
		cin >> A[i][j];
	}

	int N;
	cin >> N;
	int B;
	rep(i, 0, N)
	{
		cin >> B;
		rep(i, 0, 3)rep(j, 0, 3)
		{
			if (A[i][j] == B)A[i][j] = 0;
		}
	}

	bool ans = false;
	rep(i, 0, 3)
	{
		bool ok = true;
		rep(j, 0, 3)
		{
			if (A[i][j] != 0)ok = false;
		}
		if (ok)ans = true;
	}
	rep(i, 0, 3)
	{
		bool ok = true;
		rep(j, 0, 3)
		{
			if (A[j][i] != 0)ok = false;
		}
		if (ok)ans = true;
	}

	if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0)ans = true;
	if (A[2][0] == 0 && A[1][1] == 0 && A[0][2] == 0)ans = true;

	if (ans)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	char num[4][13]={0};
	int i, j, n, l;
	char Mark;
	int Num;
	char mark[4] ={'S','H','C','D'};

	
		scanf("%d",&n);
		
		for(l=1; l<=n; l++){
			scanf("%*c%c %d", &Mark, &Num);
			for(i=0; i<4; i++){			
					if(Mark == mark[i]){	
							num[i][Num-1]=1;
						break;
					}
		    }
		}
	
	for(i=0; i<4; i++){
		for(j=0; j<13; j++){
			if(num[i][j]==0)
				printf("%c %d\n", mark[i], j+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll x; cin >> x;
    ll t = 0;
    ll n = 1;
    while(t < x){
        t += n;
        n++;
    }
    prt(n-1);
}

Measured memory_bytes: 256
import sys


def __find_combination(bill_num, remained_amount) -> tuple:
    return next((
        (n10000, n5000, n1000)
        for n10000 in range(0, bill_num + 1)
        for n5000 in range(0, bill_num - n10000 + 1)
        for n1000 in [bill_num - n10000 - n5000]
        if n10000 * 10000 + n5000 * 5000 + n1000 * 1000 == remained_amount), (-1, -1, -1))


def main():
    input_str = sys.stdin.readline().split(" ")
    bill_num = int(input_str[0])
    total_amount = int(input_str[1])
    combination = __find_combination(bill_num, total_amount)
    print('%d %d %d\n' % combination)



if __name__ == '__main__':
    main()


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

int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if (m2 == m1 + 1) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

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

int main(){
    int N, ans=0;
    cin >> N;
    for(int i=1; i<=N;i++){
        int cnt=0;
        if(i%2==1){
            for(int j=1;j<=i;j++){
                if(i%j==0) cnt++;
            }
        }
        if(cnt == 8){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
s = input()

flg = 0

for i in range(len(s)):
  if i % 2 == 1:
    if s[i] == 'R':
      flg = 1
  else:
    if s[i] == 'L':
      flg = 1

if flg == 1:
  print('No')
else:
  print('Yes')

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

#define INF 1e9+5
int main(){
    int n;
    int a;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;++i){
        cin>>a;
        ar[a-1]=i+1;
    }
    for(int i=0;i<n;++i){
        cout<<ar[i]<<" ";
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 1152