akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
#include<vector>
#include<queue>
#include<bits/stdc++.h>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<x<<" "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 366666, maxn = 1666666;
void FAST(){ios::sync_with_stdio(false);cin.tie(0);}
const ll mod = 7;

int n;

void solve()
{
    scanf("%d", &n);
    ll sum = 0;
    for(int i = 1; i <= n; ++i)
        if(i%3&&i%5) sum += i;
    printf("%lld\n", sum);
}
int main()
{

//    int _;scanf("%d", &_);while(_--)
//    while(~scanf("%d", &n))
    solve();
	return 0;
}


Measured memory_bytes: 3760
n,m=map(int,input().split())
A=0
W=0
ANS=[[0]*2 for _ in range(n+1)]
for _ in  range(m):
  i,s=input().split()
  if ANS[int(i)][0]==0:
    if s=='AC':
      ANS[int(i)][0]+=1
    else:
      ANS[int(i)][1]+=1
wa=0
for i in ANS:
  if i[0]==1:
    wa+=i[1]
print(sum([row[0] for row in ANS]),wa)

Measured memory_bytes: 14708
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let _n = i.read::<usize>();
    let s = i.read_line().to_string();
    let q = i.read::<usize>();
    let k = i.read_vec::<usize>(q);
    for k in k {
        writeln!(o, "{}", solve(&s, k)).unwrap();
    }
}
pub fn solve(s: &str, k: usize) -> usize {
    let s = s.as_bytes();
    let mut d = 0;
    let mut m = 0;
    let mut dm = 0;

    let mut result = 0;

    for i in 0..s.len() {
        if i >= k {
            match s[i - k] {
                b'D' => {
                    d -= 1;
                    dm -= m;
                }
                b'M' => {
                    m -= 1;
                }
                _ => {}
            }
        }
        match s[i] {
            b'D' => {
                d += 1;
            }
            b'M' => {
                m += 1;
                dm += d;
            }
            b'C' => {
                result += dm;
            }
            _ => {}
        }
    }
    result
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 6396
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll mod2 = 228661337;
const ll N = 2e5 + 2;

#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define F first
#define S second

void shift()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
void include_file(bool a)
{
    if (!a) return;
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

int dp[N][13];


int32_t main()
{
    shift();
    srand(time(0));
    include_file(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<int>mult(n, 0);
    int st = 1;
    for(int i = n - 1; i >= 0; --i, st *= 10)
    {
        st %= 13;
        mult[i] = st;
    }
    for(int i = 0; i < n; ++i)
    {
        if (s[i] != '?' && i == 0)
        {
            int k = (s[i] - '0');
            int md = (k * mult[i]) % 13;
            dp[i][md] += 1;
            continue;
        }
        if (s[i] == '?' && i == 0)
        {
            for(int j = 0; j < 10; ++j)
                dp[i][(j * mult[i]) % 13] += 1;
                continue;
        }
        if (s[i] != '?')
        {
            int k = (s[i] - '0') * mult[i];
            k %= 13;
            for(int j = 0; j < 13; ++j)
            {
                dp[i][(j + k) % 13] += dp[i - 1][j];
                dp[i][(j + k) % 13] %= mod;
            }
            continue;
        }
        if (s[i] == '?')
        {
            for(int j = 0; j < 10; ++j)
            {
                int x = j * mult[i];
                x %= 13;
                for(int k = 0; k < 13; ++k)
                {
                    dp[i][(x + k) % 13] += dp[i - 1][k];
                    dp[i][(x + k) % 13] %= mod;
                }
            }
            continue;;
        }
    }
    cout << dp[n - 1][5];
    return 0;
}


Measured memory_bytes: 11472
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int[]a = new int[5];
    
    for(int i=0; i<5; i++) {
    	a[i] = sc.nextInt();
    	if(a[i] == 0){
    	System.out.println(i+1);
       }
}
}
}

Measured memory_bytes: 35716
// start 2019/8/9 19:53
#include<iostream>
using namespace std;

long pow10(int n){
    long ans;
    ans=1;
    for(int i=1; i<n+1; i++){
        ans= ans*10;
    }
    return ans;
}

int main(){
    long N;
    long ans;

    cin >> N;
    ans=0;
    for(long i=1; i<6; i++){

        //cout << "i " << i << " " << "ans " << ans << endl;

        if( i%2 == 0 ){
            if( N > pow10(i) - 1){
                continue;
            }else{
                break;
            }
        }

        if( N > pow10(i) - 1 ){
            ans += (pow10(i) -1) - (pow10(i-1) -1);
        }else{
            ans += N - (pow10(i-1)-1);
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')
const output = (x: any) => console.log(x)
// debug(input)
const K = +input[0]
const [A, B] = input[1].split(' ').map(n => parseInt(n, 10))

for (let i = A; i <= B; ++i) {
    if (i % K == 0) {
        console.log('OK')
        break
    }
    if (i === B) {
        console.log('NG')
    }
}



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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read();
	vi a(n);
	REP(i,n)
		a[i]=read();
	{
		bool ok=true;
		FOR(i,1,n)
			if(a[i-1]>=a[i])
				ok=false;
		if(ok){
			print(1);
			return 0;
		}
	}
	int l=1,r=1000000000;
	while(r-l>1){
		const int mid=(l+r)/2;
		bool ok=true;
		vector<pi> waf;
		int cur=a[0];
		FOR(i,1,n){
			int nx=a[i];
			if(cur<nx){
				cur=nx;
			}else{
				while(!waf.empty()&&waf.back().first>=nx)
					waf.pop_back();
				int j=nx-1;
				while(!waf.empty()&&waf.back()==pi(j,mid-1)){
					j--;
					waf.pop_back();
				}
				if(j<0){
					ok=false;
					break;
				}
				if(waf.empty()||waf.back().first<j)
					waf.EB(j,0);
				waf.back().second++;
				cur=nx;
			}
		}
		if(ok){
			r=mid;
		}else{
			l=mid;
		}
	}
	print(r);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    int first = b/c - a/c;
    int second = b/d - a/d;
    int lcm = c*d / __gcd(c,d);
    int both = b/lcm - a/lcm;
    int count = first + second;
    count = count - both;
    // cout<<count<<endl;
    int total = b - a;
    // cout<<total<<endl;
    cout<<total-count<<endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int count = 0;
	char s[101];

	scanf("%s", s);

	for (i = 0; s[i] != '\0'; i++) {
		count++;
	}

	for (i = 0; i < count; i++) //偶数文字目にLが含まれる場合
	{
		if (i % 2 == 0 && s[i] == 'L') {
			printf("No\n");
			return 0;
		}
	}

	for (i = 0; i < count; i++) //奇数文字目にRが含まれる場合
	{
		if (i % 2 != 0 && s[i] == 'R') {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAX_N = 1 << 18;
struct BIT{
  int bit[MAX_N+1],n;
  //1-indexed
  BIT(){init();}
  BIT(int n):n(n){init();}
  void init(){
    memset(bit,0,sizeof(bit));
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum0(int i){
    return sum(i+1);
  }
  void add0(int i,int x){
    add(i+1,x);
  }
};
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int b[n];
  for(int i=0;i<n;i++) b[i]=a[i];
  sort(b,b+n);
  map<int,int> m;
  for(int i=0;i<n;i++) m[b[i]]=i+1;
  BIT bit(n);
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=i-bit.sum(m[a[i]]);
    bit.add(m[a[i]],1);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 20816
#include <bits/stdc++.h>
#define rep(i,n) for (long i=0;i<n;i++)
using namespace std;
 
int main() {
	int x, a, b;
	string ans;
	cin >> x >> a >> b;
	if (a >= b) ans = "delicious";
	else if (b - a <= x) ans = "safe";
	else ans = "dangerous";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  ll H, N;
  cin >> H >> N;
  vector<ll> minMag(H * 2, INT_MAX);
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  ll ans = INT_MAX;
  minMag[0] = 0;
  for (ll h = 0; h < H; h++) {
    for (ll spell = 0; spell < N; spell++) {
      if (h + A[spell] >= H) {
        ans = min(ans, minMag[h] + B[spell]);
      } else {
        minMag[h + A[spell]] = min(minMag[h + A[spell]], minMag[h] + B[spell]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int r; cin >> r;
	double pi = M_PI;
	double res = pi * r * 2;

	cout << setprecision(20) << res;
}


Measured memory_bytes: 3816
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int k=in();
	int n=50;
	int r=k%n;
	cout<<n<<"\n";
	for(int i=0;i<r;i++)
	{
		cout<<(n-1)+(k/n)+1<<" ";
	}
	for(int i=r;i<n;i++)
	cout<<(n-1-r)+(k/n)<<" ";
}

Measured memory_bytes: 3744
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
A = [sr() for _ in range(H)]
B = []
for a in A:
    if '#' in a:
        B.append(a)

B = zip(*[b for b in zip(*B) if '#' in b])
for b in B:
    print(*b, sep='')


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

int main() {
  string S;
  cin >> S;
  int s[S.size()] = {0};
  int R_count = 0;
  int L_count = 0;
  int flag = 0;
  int RtoL;
  for (int i=0; i<S.size(); i++){
    if (S[i] == 'R'){
      if (flag == 1){
        flag = 0;

        if ((R_count + L_count)%2 == 0){
          s[RtoL] = (R_count + L_count)/2;
          s[RtoL+1] = (R_count + L_count)/2;
        }else{
          int max;
          max = (R_count>L_count) ? R_count : L_count;
          if(max%2 == 0){
            if(R_count>L_count){
              s[RtoL] = (R_count + L_count)/2;
            s[RtoL+1] = (R_count + L_count)/2+1;
            }else{
              s[RtoL] = (R_count + L_count)/2+1;
            s[RtoL+1] = (R_count + L_count)/2;
            }
          }else{
              if(R_count>L_count){
              s[RtoL] = (R_count + L_count)/2+1;
            s[RtoL+1] = (R_count + L_count)/2;
            }else{
              s[RtoL] = (R_count + L_count)/2;
            s[RtoL+1] = (R_count + L_count)/2+1;
            }
          }
        }
        R_count = 0;
        L_count = 0;
      }
      R_count++;
    }
    if (S[i] == 'L'){
      L_count++;
      if (flag == 0){
        flag = 1;
        RtoL = i-1;
      }

      if (i== S.size()-1){
        if ((R_count + L_count)%2 == 0){
          s[RtoL] = (R_count + L_count)/2;
          s[RtoL+1] = (R_count + L_count)/2;
        }else{
          int max;
          max = (R_count>L_count) ? R_count : L_count;
          if(max%2 == 0){
            if(R_count>L_count){
              s[RtoL] = (R_count + L_count)/2;
            s[RtoL+1] = (R_count + L_count)/2+1;
            }else{
              s[RtoL] = (R_count + L_count)/2+1;
            s[RtoL+1] = (R_count + L_count)/2;
            }
          }else{
              if(R_count>L_count){
              s[RtoL] = (R_count + L_count)/2+1;
            s[RtoL+1] = (R_count + L_count)/2;
            }else{
              s[RtoL] = (R_count + L_count)/2;
            s[RtoL+1] = (R_count + L_count)/2+1;
            }
          }
        }
        R_count = 0;
        L_count = 0;
      }
    }

  }
  for (int i=0; i<S.size(); i++){
    cout << s[i];
    if(i!=S.size()-1){
      cout << " ";
    }
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvi a;

int main(){
	cin>>m>>n;
	a=vvi(n,vi(n));
	for(int i=0;i<n;i++) for(int j=0;j<n;j++){
		char c;
		cin>>c;
		if(c=='1') a[i][j]++;
	}
	int t=0,N=n/2,res=0;
	for(int i=0;i<N;i++) for(int j=0;j<N;j++){
		int sum=a[i][j]+a[n-i-1][j]+a[i][n-j-1]+a[n-i-1][n-j-1];
		if(0<sum&&sum<4) t++;
	}
	if(!t) res++;
	for(int i=1;i<m;i++){
		int A;
		cin>>A;
		for(int j=0;j<A;j++){
			int x,y;
			cin>>x>>y;
			x--;y--;
			int sum=a[x][y]+a[n-x-1][y]+a[x][n-y-1]+a[n-x-1][n-y-1];
			if(0<sum&&sum<4) t--;
			a[x][y]^=1;
			sum=a[x][y]+a[n-x-1][y]+a[x][n-y-1]+a[n-x-1][n-y-1];
			if(0<sum&&sum<4) t++;
		}
		if(!t) res++;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 6828
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}

Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 1000000007;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[m + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
        }
        for (int i = 1; i <= m; i++) {
            b[i] = in.nextInt();
        }
        long[][] dp = new long[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1]) % mod + mod;
                if (a[i] == b[j]) {
                    dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] + 1) % mod;
                }
            }
        }
        out.println((dp[n][m] + 1) % mod);
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

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

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

}


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

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int H, W, N, sr, sc; cin >> H >> W >> N >> sr >> sc;
    string S, T; cin >> S >> T;

    int B[4] = {0, W+1, 0, H+1};
    int s[4] = {W+1, 0, H+1, 0};
    int l[4] = {0, W+1, 0, H+1};
    unordered_map<char, int> mp1 = {{'L', 0}, {'R', 1}, {'U', 2}, {'D', 3}};
    unordered_map<char, int> mp2 = {{'L', 1}, {'R', 0}, {'U', 3}, {'D', 2}};

    for(int i=N-1;0<=i;i--){
        int j = mp1[S[i]], k = mp2[T[i]];
        if(T[i]=='L' or T[i]=='U') B[k] = min(l[k], B[k]+1);
        else B[k] = max(l[k], B[k]-1);
        if(S[i]=='L' or S[i]=='U') B[j] = min(s[j], B[j]+1);
        else B[j] = max(s[j], B[j]-1);
        if(B[1]-B[0]<2 or B[3]-B[2]<2) {cout << "NO" << endl; return 0;}
    }

    if(B[0]<sc and sc<B[1] and B[2]<sr and sr<B[3]) {cout << "YES" << endl; return 0;}
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

string s;
int main() {
    cin >> s;
    int n = s.length();
    for (char c = 'a'; c <= 'z'; ++c) {
        int l = 0;
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (s[i] == c) {
                ++cnt;
            }
            while (cnt * 2 < i - l + 1 && l <= i) {
                if (s[l++] == c)
                    --cnt;
            }
            if (cnt * 2 > i - l + 1 && i - l + 1 >= 2) {
                cout << l + 1 << ' ' << i + 1 << endl;
                exit(0);
            }
        }
    }
    cout << -1 << ' ' << -1 << endl;
    return 0;
}


Measured memory_bytes: 3772
#include <stdio.h>
#define HMAX 52
#define WMAX 52
int main(void) {
    char grid[HMAX][WMAX];
    int h, w, i, j, cnt=0;
    char newline[HMAX];
    scanf("%d %d", &h, &w);
    scanf("%c", &newline[0]);
    for(i=1; i<=h; i++) {
        for(j=1; j<=w; j++) {
            scanf("%c", &grid[i][j]);
        }
        scanf("%c", &newline[i]);
    }
    
    for(i=1; i<=h; i++) {
        for(j=1; j<=w; j++) {
            if(grid[i][j]=='#') {
                if(grid[i][j]!=grid[i][j-1] && grid[i][j]!=grid[i-1][j]
                   && grid[i][j]!=grid[i][j+1] && grid[i][j]!=grid[i+1][j])
                    cnt++;
            }
        }
    }
    if(cnt>0)
        printf("No");
    else
        printf("Yes");
    return 0;
}


Measured memory_bytes: 128
from itertools import accumulate
from collections import defaultdict


def main():
    n = int(input())
    prime_counter = defaultdict(int)  # key ^ value
    # 10 because 2^39 < 10^12 < 2^40 and accum[9] = 45
    accum = tuple(accumulate(range(10)))

    def facs(n):
        yield 2
        max_prime = int(pow(n, 0.5)) + 1
        for x in range(3, max_prime, 2):
            yield x

    for fac in facs(n):
        while n % fac == 0:
            n //= fac
            prime_counter[fac] += 1
    if n != 1:
        prime_counter[n] += 1

    ans = 0
    for c in prime_counter.values():
        for accum_count, accum_value in enumerate(accum):
            if c < accum_value:
                ans += accum_count - 1
                break
    print(ans)


if __name__ == '__main__':
    main()


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000005);

mint g(int r, int c) {
  return comb(r+c+2, r+1) - 1;
}

int main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  --r1; --c1;

  mint ans = g(r2,c2);
  ans -= g(r1,c2);
  ans -= g(r2,c1);
  ans += g(r1,c1);
  cout << ans.x << endl;
  return 0;
}

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

int main(){
  int n, q; cin >> n >> q;
  string s; cin >> s;
  int d[100010];
  for (int i = 0; i <= n; i++) d[i] = 0;
  for (int i = 2; i <= n; i++) {
    d[i] += d[i-1];
    if (s.substr(i-2, 2) == "AC") d[i]++;
  }
  int ans[100010];
  for (int i = 0; i < q; i++) {
    int l, r; cin >> l >> r;
    ans[i] = d[r] - d[l];
  }
  for (int i = 0; i < q; i++){
    cout << ans[i] << endl;
  }
  return 0;
} 

Measured memory_bytes: 1792
/*
Author: Rishabh Agarwal
Nationality: Indian
*/
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define MOD 1000000007
#define vpi vector<pair<int, int>>
#define ll long long int
#define inf 1000000000
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Cases int testCases; cin>>testCases; while(testCases--) 
#define MOD 1000000007
#define pb push_back
//---------------------------------------------------
int main() {
    FIO
    double R; cin>>R;

    double d = 3.14159265358979;
    double c = 2*d*R;
    cout.precision(17);
    cout<<c<<endl;
}



Measured memory_bytes: 3796
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
#define BLACK 0
#define WHITE 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    string s;
    cin >> s;
    
    if(s.size()==2) {
        cout << s << endl;
    }else {
        cout << s[2] << s[1] << s[0] << endl;
    }
    
    
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    
    int height,width,number;
    
    while(1){
        scanf("%d%d",&height,&width);
        if (height + width ==0) break;
        
        while(height -- > 0){
            number = width;
                while(number -- > 0) {
                    printf("#");
                }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2072
N,K = [int(i) for i in input().split()]
if N % 2 == 0:
    if (N//2) >= K:
        print('YES')
        exit()
    else:
        print("NO")
        exit()
else:
    if (N+1)//2 >= K:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<ll> A(n);
    ll mod = 1e9 + 7;
    ll sum = 0;
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int d = 0; d < 60; d++) {
        ll n0 = 0, n1 = 0;
        for (int i = 0; i < n; i++) {
            if ((A[i] >> d) & 1)
                n1++;
            else
                n0++;
        }
        ll tmp = (1LL << d) % mod;
        long long n = n0 * n1 % mod;
        tmp = (tmp * n) % mod;
        sum = (sum + tmp) % mod;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";
}

Measured memory_bytes: 3624
/*
 * Ankit Raj, NIT Agartala
 */
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define MAX_RANGE 10000007
#define BOOST ios_base::sync_with_stdio(0) 
#define NITRO cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int main()
{
	BOOST;
	NITRO;
	/*
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	*/ 
	//Main Code
		int n;
		cin>>n;
		int A[n];
		int B[n];
		int C[n];
		int dp[3][n];
		for(int i=0;i<n;i++)
		{
			cin>>A[i]>>B[i]>>C[i];
		}
		dp[0][0]=A[0];
		dp[1][0]=B[0];
		dp[2][0]=C[0];
		for(int i=1;i<n;i++)
		{
			//A
			dp[0][i] = A[i] + max(dp[1][i-1],dp[2][i-1]);
			//B
			dp[1][i] = B[i] + max(dp[0][i-1],dp[2][i-1]);
			//C
			dp[2][i] = C[i] + max(dp[0][i-1],dp[1][i-1]);
		}
		cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]))<<"\n";
	
}
	


Measured memory_bytes: 2560
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int a = sc.nextInt();
            int b = sc.nextInt();
        	if(a == 0 && b == 0) {
        		break;
        	}
        	if(a < b) {
        		System.out.printf("%d %d\n", a, b);
        	}
        	else{
        		System.out.printf("%d %d\n", b, a);
        	}
        }
    }
}


Measured memory_bytes: 41324
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}
	}
	for(int i=0;i<s.size()-2;i++)
	{
		if(s[i]==s[i+2])
		{
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}
	cout<<"-1"<<" "<<"-1"<<endl;

	
	
}

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

ll N, K;

int keta(ll n, ll k) {
    int cnt = 0;
    while (n != 0) {
        cnt++;
        n /= k;
    }
    return cnt;
}

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

    cout << keta(N, K) << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner; 
public class Main { 
    public static void main(String[] args) { 
        try (Scanner sc = new Scanner(System.in)) { 
            int w = sc.nextInt(); 
            int n = sc.nextInt(); 
            int[] values = new int[w]; 
            for (int i = 0; i < values.length; i++) { 
                values[i] = i + 1; 
            } 
            for (int i = 0; i < n; i++) { 
                String str = sc.next(); 
                String[] ab = str.split(","); 
                int a = Integer.parseInt(ab[0]) - 1; 
                int b = Integer.parseInt(ab[1]) - 1; 
                int c=0;
                c = values[a];
                values[a] = values[b];
                values[b] = c;
            } 
            for (int j = 0; j < n; j++){
                System.out.printf("%d\n",values[j]);
            } 
        } 
    } 
}



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

const int N = 200005;

int dp[N];
int n, pw[2][N], cnt[2], r[2];
char s[N];

int calc(int x) {
	return dp[x];
}

int main() {
	dp[0] = 0;
	for (int i = 1; i < N; i ++) dp[i] = dp[i%(__builtin_popcount(i))] + 1;
	cin >> n >> s;
	int c = 0;
	for (int i = 0; i < n; i ++) c += (s[i] == '1');
	cnt[0] = c + 1, cnt[1] = c - 1;
	for (int i = 0; i < 2; i ++) {
		pw[i][0] = 1;
		for (int j = 1; j < n; j ++) {
			pw[i][j] = pw[i][j-1] << 1;
			if (pw[i][j] >= cnt[i]) pw[i][j] -= cnt[i];
		}
		r[i] = 0;
		for (int j = 0; j < n; j ++) {
			r[i] = r[i] * 2 + (s[j] - '0');
			if (r[i] >= cnt[i]) r[i] -= cnt[i];
		}
	}
	for (int i = 0; i < n; i ++) {
		if (s[i] == '1') {
			int c = cnt[1];
			if (!c) cout << 0 << endl;
			else {
				int R = r[1] - pw[1][n-1-i];
				if (R < 0) R += cnt[1];
				cout << calc(R) + 1 << endl;
			}
		}
		else {
			int R = r[0] + pw[0][n-1-i];
			if (R >= cnt[0]) R -= cnt[0];
			cout << calc(R) + 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
 
#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<
 
typedef long long ll;
typedef long double ld;

const int MaxN = 2e5 + 10;
int n, a[MaxN], b[MaxN];
string s;

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

    cin >> n >> s;
    reverse(s.begin(), s.end());

    for (int i = 0; i < n; i++) {
        a[i + 1] = a[i] + (s[i] == '.');
    }

    for (int i = n - 1; i >= 0; i--) {
        b[i] = b[i + 1] + (s[i] == '#');
    }

    int sol = 1e9;
    for (int i = 0; i <= n; i++) sol = min(sol, a[i] + b[i]);

    cout << sol;


    return 0;
}



Measured memory_bytes: 2196
#include <stdio.h>
int main(void){
  int A,B,K,i,j=1,x[100];
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&K);
  for(i=100;i>0;i--){
    if(A%i==0){
      if(B%i==0){
        x[j]=i;
        j=j+1;}
      else{}
    }
    else{}
  }
  printf("%d",x[K]);
  return 0;
}
      


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

int main() {
  int n;
  cin>>n;
  vector<string>w(n);
  for(int i=0;i<n;i++) cin>>w[i];
  string ans="Yes";
  for(int i=0;i<n-1;i++){
    int x=w[i].size();
    if(w[i][x-1]!=w[i+1][0]) ans="No";
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(w[i]==w[j]) ans="No";
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for(int i = 0;i <= 100;i += 4)
	{
		for(int j = 0;j <= 100;j += 7)
		{
			if(i + j == n)
			{
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    vector<ll> v(n);
    REP(i,n)cin>>v[i];
    cout<<MAX(v)-MIN(v)<<endl;
    return 0;
}


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

int main()
{
    int a[3];
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    sort(a, a+3);
    printf("%d\n", abs(a[2] - a[1]) + abs(a[1] - a[0]));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if(s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba"){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

set<pair<int, int>> veze;

void connect(int n)
{
    for(int i = 1; i < n; i++)
        for(int j = i + 1; j <= n; j++)
            veze.insert(mp(i,j));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    connect(n);
    int S = n*(n+1)/2;
    if(n % 2 == 0)
        for(int i = 1; i <= n / 2; i++) veze.erase(mp(i, n - i + 1));
    else
        for(int i = 1; i <= n / 2; i++) veze.erase(mp(i, n - i));
    cout << veze.size() << "\n";
    for(set<pair<int,int>>::iterator it = veze.begin(); it != veze.end(); it++)
        cout << it->first << " " << it->second << "\n";

    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }

        for (int i = k; i < n; i++) {
            if (a[i] > a[i-k]) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 59644
/*input

*/
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
//gcc 1.cpp -lstdc++ -o main.o
#define ull                 unsigned long long
#define ll                         long long
#define M                         1000000007
#define pb                         emplace_back
#define p_q                 priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define all(a)      (a).begin(),(a).end()
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b))/__gcd((a),(b))
#define ios                    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp                         make_pair
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define F first
#define S second
#define N 200005
using namespace std;


int main(void)
{
        ios
        ll n;
        cin>>n;
        ll t1 = lcm((ll)360 , n);
        cout<<t1/n<<"\n";
}

Measured memory_bytes: 3600
import math
a, b = map(int, input().split())
g = math.gcd(a, b)

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

lst = factorization(g)
if lst[0][0] == 1:
  print(1)
  exit()
else:
  print(len(lst) + 1)

Measured memory_bytes: 9256
#include <iostream>
#include <string>

int main()
{
	using namespace std;
	int a, b;
	char s;
	cin >> a;
	cin >> s;
	cin >> b;
	if (s == '+') {
		cout << a + b;
	}
	if (s == '-') {
		cout << a - b;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100007][3];

int main(){
	ll n;
	cin>>n;
	ll v[n][3];
	memset(dp, 0, sizeof(dp));
	for(int i=0;i<n;i++){
		cin>>v[i][0]>>v[i][1]>>v[i][2];
	}
	for(int i=0;i<3;i++) dp[0][i]=v[0][i];
	for(int i=1;i<n;i++){
		dp[i][0] = v[i][0]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = v[i][1]+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = v[i][2]+max(dp[i-1][0], dp[i-1][1]);
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int kuru[10];
bool solve(int l,int r,int co,int now);
int main(){
  int n;
  cin>>n;
  while(n--){
    for(int i=0;i<10;i++){
      cin>>kuru[i];
    }
    if(solve(0,0,0,0))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}
bool solve(int l,int r,int co,int now){
  if(co==10)return true;
  if(l<kuru[now]){
    if(solve(kuru[now],r,co+1,now+1))return true;
    else return false;
  }
  if(r<kuru[now]){
    if(solve(l,kuru[now],co+1,now+1))return true;
    else return false;
  }
  else if(r>kuru[now] && l>kuru[now])return false;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair <int, int>;

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

int main()
{
  int n;
  cin >> n;
  int counter = 0;
  for (;;) {
    n -= 1000;
    counter++;
    if (n <= 0) {
      break;
    }
  }
  ll ans = abs(n);
  cout << ans << endl;

  return 0;
}


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

int main() {
  string a;
  cin>>a;
  string x="Yes";
  int N=a.size();
  for(int i;i<(N-1)/2;i++){
    if(a.at(i)!=a.at((N-1-i))){
      x="No";
      break;
    }
  }
  for(int i;i<((N-1)/2)/2;i++){
    if(a.at(i)!=a.at((N-3)/2-i)){
      x="No";
      break;
    }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
S = input()

if "keyence" == S[0:7]:
    print("YES")
elif "keyence" == S[-7:]:
    print("YES")
elif "keyenc" == S[:6] and "e" == S[-1:]:
    print("YES")
elif "keyen" == S[:5] and "ce" == S[-2:]:
    print("YES")
elif "keye" == S[:4] and "nce" == S[-3:]:
    print("YES")
elif "key" == S[:3] and "ence" == S[-4:]:
    print("YES")
elif "ke" == S[:2] and "yence" == S[-5:]:
    print("YES")
elif "k" == S[:1] and "eyence" == S[-6:]:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;



int main(){
    int s, w;
    cin >> s >> w;

    if(s - w > 0){
        printf("safe\n");
    }
    else{
        printf("unsafe\n");
    }

    return 0;
    
}

Measured memory_bytes: 3636
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

H, W = l_inpl()
field = [ l_inpl() for _ in range(H) ]
ans = []
for i in range(H-1):
    for j in range(W):
        if field[i][j] % 2 == 1:
            ans.append([i+1, j+1, i+2, j+1])
            field[i+1][j] += 1
            field[i][j] -= 1

for i in range(W-1):
    if field[H-1][i] % 2 == 1:
        ans.append([H, i+1, H, i+2])
        field[H-1][i+1] += 1
        field[H-1][i] -= 1

print(len(ans))

for a in ans:
    print(" ".join([str(i) for i in a]))

Measured memory_bytes: 64476
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,k;
    cin >> n >> k;
    Vi a(n);
    rp(i,n) cin >> a[i];
    ll mid, ok = 1000000002, ng = 0;
    while(abs(ok-ng)>1){
        mid = (ok+ng)/2;
        ll ctr=0;
        rp(i,n) ctr+=(a[i]-1)/mid;
        if(ctr<=k)ok = mid;
        else ng = mid;
    }//midではなくokを使わないとバグる!
    print(ok);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 4748
INF = float('inf')

def solve():
    N, Ma, Mb = map(int, input().split())
    l = []
    for _ in range(N):
        a, b, c = map(int, input().split())
        l.append((a, b, c))
 
    dp = [[[INF] * 401 for _ in range(401)] for _ in range(N + 1)]
    dp[0][0][0] = 0
    
    for i in range(N):
        for ca in range(401):
            for cb in range(401):
                if dp[i][ca][cb] != INF:
                    dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb])
                    dp[i + 1][ca + l[i][0]][cb + l[i][1]] = min(dp[i + 1][ca + l[i][0]][cb + l[i][1]], dp[i][ca][cb] + l[i][2])
 
    ans = INF
    for i in range(len(dp)):
        for ca in range(1, 401):
            for cb in range(1, 401):
                if dp[i][ca][cb] != INF:
                    if Ma * cb == Mb * ca:
                        ans = min(ans, dp[i][ca][cb])
 
    print(-1 if ans == INF else ans)
 
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 60780