akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define A first
#define B second
#define MOD 1000000007

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;
}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res,x);
        y = y>>1;
        x = mulmd(x,x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a-b;
    if(ret<0){
        ret+=MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int phi(int n){
    int result = n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                n=n/i;
            }
            result-=result/i;
        }
    }
    if(n>1) result-=result/n;
    return result;
}

const int N = 1e5 + 5;

int arr[N];
vector<string> a(N);

/**
    Check out for boundary cases, (n = 1 or n = 0)
    check for integer overflow

**/

map<map<char, int>, int> mp;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    FOR(i, 0, n - 1) {
        cin >> a[i];
        map<char, int> m;
        FOR(j, 0, a[i].size() - 1) m[a[i][j]]++;
        mp[m]++;
    }
    ll ans = 0;
    for(auto it: mp){
        ans += (ll)it.second * (it.second - 1)/2;
    }
    cout << ans;


}



Measured memory_bytes: 54656
num = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる

N=num[2]/num[1]

if(N==int(N)):
    N=int(N)-1
else:
    N=int(N)

if(N*num[3]<num[0]):
    print("Yes")
else:
    print("No")


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

int main()
{
    int a[3],ans;cin>>a[0]>>a[1]>>a[2];
    
    sort(a,a+3);
    int b1 = a[1]-a[0];
    int b2 = a[2]-a[1];
    
    if     (b1 % 2 == 0) ans = b1/2 + b2;
    else if(b2 % 2 == 0) ans = 1 + (b1+1)/2 + b2;
    else                 ans = 2 + (b1-1)/2 + b2;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
A = list(map(int,input().split()))
if N == 0:
    if A[0] == 1:
        print(1)
    else:
        print(-1)
elif A[0] != 0:
    print(-1)
else:
    band1 = deque([[A[N],A[N]]])
    for i in range(N):
        x = A[N-1-i]
        MIN = band1[0][0]
        MAX = band1[0][1]
        vmin = x+(MIN+1)//2
        vmax = MAX + x
        band1.appendleft([vmin,vmax])
    band1 = list(band1)
    band2 = [[1,1]]
    for i in range(1,N+1):
        p = A[i-1]
        MIN = band2[i-1][0] - p
        MAX = band2[i-1][1] - p
        vmin = MIN
        vmax = 2*MAX
        band2.append([vmin,vmax])
    c = 0
    ans = 0
    for i in range(N+1):
        li1 = band1[i]
        li2 = band2[i]
        if li1[1] < li2[0] or li1[0] > li2[1]:
            c = 1
            break
        else:
            ans += min(li1[1],li2[1])
    if c == 0:
        print(ans)
    else:
        print(-1)


        



Measured memory_bytes: 705404
#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
using namespace std;
typedef pair<LL,int>P;
typedef vector<int>V;
typedef vector<P>VP;
typedef queue<P>Q;
typedef priority_queue<P,VP,greater<P>>PQ;
int flg[100001];
LL d[100001];
V v[100001];
int main(void){
	int n,m,nn,mm;
	int s,o;
	int out;
	int a,b;
	
	Q que1;
	PQ que2;
	int i;
	P pp;
	int x,y;
	LL cost;
	int plus;
	
	LL ans;
	for(i=1;i<n;i++)	flg[i]=0;
	cin>>n>>m>>nn>>mm;
	cin>>s>>o;
	for(i=0;i<nn;i++){
		cin>>out;
		flg[out]=2;
		que1.push(make_pair(0,out));
	}
	for(i=0;i<m;i++){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	
	
	while(!que1.empty()){
		pp=que1.front();	que1.pop();
		cost=pp.F;
		x=pp.S;
		if(cost==mm)	break;
		for(i=0;i<v[x].size();i++){
			y=v[x][i];
			if(flg[y]==0){
				flg[y]=1;
				que1.push(make_pair(cost+1,y));
			}
		}
	}
	//for(i=1;i<=n;i++)	cout<<i<<" "<<flg[i]<<endl;
	for(i=1;i<=n;i++)	d[i]=LLONG_MAX;
	que2.push(make_pair(0,1));
	while(!que2.empty()){
		pp=que2.top();		que2.pop();
		cost=pp.F;
		x=pp.S;
		if(cost<d[x]){
			d[x]=cost;
			if(x==n)	break;
			for(i=0;i<v[x].size();i++){
				y=v[x][i];
				if(flg[y]!=2){
					if(flg[y]==1)	plus=o;
					else			plus=s;
					que2.push(make_pair(cost+plus,y));
				}
			}
		}
	}
	if(flg[n]==1)	plus=o;
	else			plus=s;
	cout<<d[n]-plus<<endl;
	return 0;
}
	
	
		
		


Measured memory_bytes: 11016
import java.io.*;
import java.lang.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;
		byte states[] = new byte[10];
		int n, s, i, count;
		try {
			for(;;){
				buf = br.readLine();
				if(buf == null){
					break;
				}
				Scanner scanner = new Scanner(buf);
				if(!scanner.hasNext()){
					break;
				}
				n = scanner.nextInt();
				s = scanner.nextInt();
				if(n == 0 && s == 0){
					break;
				}
				count = Main.getCount(0, n, s, 0);
				for(i = 1; i <= n; i++){
					count /= i;
				}
				System.out.println(count);
			}
		}
		catch(IOException e) {
			System.out.println("Read error.");
			return;
		}
	}
	public static int getCount(int used, int remCount, int targetSum, int parentSum){
		int i, count = 0;
		if(parentSum > targetSum){
			return 0;
		}
		if(remCount == 0){
			if(parentSum == targetSum){
				/*
				for(i = 0; i < 10; i++){
					if((used & (1 << i)) != 0){
						System.out.print(i + " ");
					}
				}
				System.out.println();
				*/
				return 1; 
			}
			return 0;
		}
		for(i = 0; i < 10; i++){
			if((used & (1 << i)) == 0){
				count += Main.getCount(used | (1 << i), remCount - 1, targetSum, parentSum + i);
			}
		}
		return count;
	}
}

Measured memory_bytes: 29608
#include <bits/stdc++.h>
#define MAX 200005

using namespace std;

int n, _n, ans = MAX;
int a[MAX], arcrk[MAX], tot;
struct lisan {
	int id, rg;
}tmp[MAX];

inline int Rd() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}
bool cmp(lisan aa, lisan bb) {
	return aa.rg < bb.rg;
}

void init() {
	n = Rd(), _n = n * 2 - 1;
	for(int i = 1; i <= _n; ++i) {
		tmp[i].rg = Rd(), tmp[i].id = i;
	} sort(tmp + 1, tmp + 1 + _n, cmp);
	tmp[0].rg = INT_MAX;
	for(int i = 1; i <= _n; ++i) {
		if(tmp[i].rg != tmp[i - 1].rg) {
			++tot;
			arcrk[tot] = tmp[i].rg;
		}
		a[tmp[i].id] = tot;
	}
//	for(int i = 1; i <= _n; ++i) cout << a[i] << ' ' ; cout << endl;
	return;
}

bool check(int lsk) {
	int lp_0, lp_1, rp_0, rp_1;
	lp_0 = lp_1 = 0, rp_0 = rp_1 = n << 1;
	for(register int i = 1; i < n; ++i) {
		if(a[i] <= lsk && a[i + 1] <= lsk) {
			lp_0 = i;
		} else {
			if(a[i] > lsk && a[i + 1] > lsk) {
				lp_1 = i;
			}
		}
	}
	for(register int i = _n; i > n; --i) {
		if(a[i] <= lsk && a[i - 1] <= lsk) {
			rp_0 = i;
		} else {
			if(a[i] > lsk && a[i - 1] > lsk) {
				rp_1 = i;
			}
		}
	}
	if(lp_0 == 0 && lp_1 == 0 && rp_0 == (n << 1) && rp_1 == (n << 1)) {
		if(n & 1) {
			return a[n] <= lsk;
		} else {
			return a[n] > lsk;
		}
	} else {
		return min(n - lp_0, rp_0 - n) < min(n - lp_1, rp_1 - n);
	}
}
void solve() {
	int l = 1, r = tot, mid;
	while(l <= r) {
		mid = l + r >> 1;
		if(check(mid)) {
			if(ans > mid) ans = mid;
			r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
	return;
}

int main() {
//	freopen("triangle.in", "r", stdin);
//	freopen("triangle.out", "w", stdout);
	init();
	solve();
	cout << arcrk[ans] << endl;
	return 0;
}

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

using namespace std;
 
typedef long long ll;
 
const int N = 100009;

ll a[N];
ll sum[N];
ll pref[N];
ll suff[N];

int n;
int k;
 
int main () { 
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	sum[0] = 0;
	for (int i = 0; i < n; i++)
		sum[i + 1] = sum[i] + a[i];
	pref[0] = 0;
	for (int i = 0; i < n; i++)
		pref[i + 1] = pref[i] + max(0LL, a[i]);
	suff[n] = 0;
	for (int i = n - 1; i >= 0; i--)
		suff[i] = suff[i + 1] + max(0LL, a[i]);
	ll ans = 0;
	for (int i = 0; i + k <= n; i++)
		ans = max(ans, pref[i] + suff[i + k] + max(0LL, sum[i + k] - sum[i]));
	printf("%lld\n", ans); 
	return 0;
}

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

}

Measured memory_bytes: 23764
// https://atcoder.jp/contests/abc178/tasks/abc178_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;

// 参考
// https://atcoder.jp/contests/s8pc-1/submissions/15772604
template <int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using modint = ModInt<MOD>;

void solve() {
    int N;
    cin >> N;
    if (N == 1) {
        cout << 0 << endl;
    } else {
        modint t = 10;
        modint ans = t.pow(N);
        t = 9;
        ans -= t.pow(N) * 2;
        t = 8;
        ans += t.pow(N);
        cout << ans << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  vstr days = {
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday",
  };
  vi32 months = {
    31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
  };

  while (true) {
    int m, d; cin >> m >> d;
    if (m == 0) return;
    int cnt = d;
    rep(i, m - 1) cnt += months[i];
    cout << days[(cnt + 2) % 7] << '\n';
  }
}



Measured memory_bytes: 3084
N, K = map(int, input().split())
num = [0 for _ in range(K)]
for i in range(1, N + 1):
    num[i % K] += 1
ans = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K == 0:
        ans += num[a] * num[b] * num[c]
print(ans)




Measured memory_bytes: 4632
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
//#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;



int main(){
  int n = 0;
  cin >> n;
  set<int>s;
  rep(i,n){
    int tmp = 0;
    cin >> tmp;
    s.insert(tmp);
  }
  if(s.size()==n) cout <<"YES";
  else cout << "NO";


}

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

int main(){
  int n,odd=0; cin>>n;
  long long a[100000]; 
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==1)
      odd++;
  }
  if(odd%2==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=100+5;

int main(){
    GO();
    ll x,k,d;
    cin>>x>>k>>d;
    x= llabs(x);
    ll mi=x+d;
      ll F= x/d;
      if(k>F){
        k-=F;
        x= x%d;
        if(k%2==0){
        mi=min(mi,x);
        x-=d;
        x-=d;
        mi=min(mi,llabs(x));
        }
        else{
        x-=d;
        mi=min(mi,llabs(x));
        }
      }
      else if(k==F){
        k-=F;
        x%=d;
        mi=min(mi,x);
      }
      else{
        x= x- k*d;
        mi=min(mi,x);
      }
    cout<<mi<<"\n";

}
































































































































































































































































































Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int n,x;cin>>n>>x;
  vector<int> a;
  a.push_back(x);
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  vector<int> b;
  int mn = a[a.size()-1];
  for(int i = 0; a.size() > i+1; i++){
    b.push_back(a[i+1]-a[i]);
    mn = min(mn,a[i+1]-a[i]);
  }
  for(int i = mn; 0 < i; i--){
    bool ok =true;
    for(int j = 0; b.size() > j; j++){
      if(b[j]%i != 0){
        ok = false;
        break;
      }
    }
    if(ok){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1400
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	long long  neg_cnt = 0, s = 0, min_ele = LLONG_MAX;
	for (int i = 1; i <= n; i++) {
		long long  a; cin >> a;
		if (a < 0) neg_cnt++;
		s += abs(a);
		min_ele = min(min_ele, abs(a));
	}

	cout << s - 2 * min_ele*(neg_cnt % 2);


	return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=2000005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

ll qmult(ll X, ll Y, ll M) {    
    return X * Y % M;
}

ll qexp(ll A, ll B, ll M) {
    if (B == 0) return 1; 
    ll half = qexp(A, B/2, M);
    half = qmult(half, half, M); 
    half %= M;
    if (B%2==1) half *= A%M; 
    return half%M;
}


int dp[MAXN],f[MAXN],invf[MAXN];

int choose(int n, int r){
	int res = (f[n] * invf[r]) %MOD;
	res *= invf[n-r];
	return res % MOD;
}
int N,K,L;
string S;
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>K>>S;
	L = S.length();
	N = K + L;
	int ans = 0;
	f[0] = 1;
	FOR(i,1,MAXN-1) f[i] = (f[i-1] * i) %MOD;
	invf[MAXN-1] = qexp(f[MAXN-1], MOD-2, MOD);
	DEC(i,MAXN-2,0){
		invf[i] = (invf[i+1] * (i+1)) % MOD;
	}
	FOR(i,L,N){
		int tmp = choose(i-1, L-1);
		tmp = (tmp * qexp(25, i-L, MOD)) % MOD;
		tmp = (tmp * qexp(26, N-i, MOD))%MOD;
		ans = (ans + tmp) % MOD;
	}
	cout<<ans;
}


Measured memory_bytes: 35624
#include <bits/stdc++.h>
#define EB emplace_back

typedef long long ll;
typedef std::pair <ll, ll> pr;
typedef std::vector <pr> vector;
const int mod = 1000000007;

int q;
ll A, B, f[89];
vector G[89];

int main() {
	int i; ll ans = 0;
	for (f[1] = f[2] = 1, i = 3; i < 89; ++i) f[i] = f[i - 1] + f[i - 2];
	G[2].EB(2, 3), G[2].EB(3, 4);
	for (i = 3; i < 87; ++i) {
		G[i].reserve(i);
		for (const pr &p : G[i - 1]) G[i].EB(p.second, p.first + p.second);
		G[i].EB(f[i + 2], f[i + 2] + f[i]);
	}
	for (scanf("%d", &q); q; --q) {
		scanf("%lld%lld", &A, &B), ans = 0;
		if (A > B) std::swap(A, B);
		if (A == 1 || B == 2) {printf("1 %d\n", int(A * B % mod)); continue;}
		for (i = 2; f[i + 1] <= A && f[i + 2] <= B; ++i); --i;
		for (const pr &p : G[i]) {
			if (p.first <= A && p.second <= B) ans += ((B - p.second) / p.first + 1) % mod;
			if (p.first <= B && p.second <= A) ans += ((A - p.second) / p.first + 1) % mod;
		}
		printf("%d %d\n", i, int(ans % mod));
	}
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

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

    return 0;
}

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

int main() {
    char b;
    cin >>b;
    //cout <<a << c;
    if (b=='a' || b=='e' || b=='i' || b== 'o' || b== 'u'){
        cout << "vowel";
    }else{
        cout << "consonant";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int a[200010];
int b[200010];
int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];a[i]--;
        b[a[i]]=i;
    }
    int l=1;
    int ans=0;
    for(int i=0;i<n;i++){
        if(i&&b[i]>b[i-1]){
            l++;
        }else{
            l=1;
        }
        ans=max(l,ans);
    }
    cout<<n-ans<<endl;

}


Measured memory_bytes: 1792
#include<iostream>
#define ll long long
#include<algorithm>
#include<string>
#include<vector>
#include<unordered_set>
using namespace std;
ll ans = 0;
vector<vector<ll>> adj_list(100000+1);


ll check(ll i,vector<ll> &maximum)
{
    if(ans >= adj_list.size() - 1)return 0;
    if(adj_list[i].size() == 0)
    {
        maximum[i] = 0;
        return 0;
    }
    else
    {
        if(maximum[i] != -1)
        {
            return maximum[i];
        }
        else
        {
            //int total = length;
            ll y = 0;
            for(auto x: adj_list[i])
            {
                y = max(y, 1  + check(x, maximum));
            }

            maximum[i] = y;
            ans = max((ll)y , ans);
            return y;
        }

    }


}

int main()
{
    ll n, m;
    cin>>n>>m;
    vector<ll> maximum(n+1, -1);
    vector<ll> s(n+1, -1);
    ll parent, child;
    for(ll i=0; i<m; ++i )
    {
        cin>>parent>>child;
        adj_list[parent].push_back(child);
        s[child] = 1;
    }





    for(ll i=1; i<=n; ++i)
    {
        if(ans >= adj_list.size() - 1)
        {
            break;
        }
        if(s[i] == -1)
        {

            check(i, maximum);
        }
    }


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


Measured memory_bytes: 11904
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int A;
    bool flag=true;
    cin >> A;
    vector<int> N(A);
    for(int i=0;i<A;i++){
        cin >> N[i];
    }
    for(int i=0;i<A;i++){
        if(N[i]%2==0&&!(N[i]%3==0||N[i]%5==0)){
            flag=false;
            break;
        }
    }
    if(flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 2005
using namespace std;

int n, m, q, c, d, z, t, a[N][N], pre[N][N], x[N][N], y[N][N];
char xx;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d %d",&n ,&m ,&q);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++){
			scanf(" %c",&xx);
			a[i][j] = xx - '0';
			pre[i][j] = pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1] + a[i][j];
		}
	for(int i = 1; i <= n + 1; i++)
		for(int j = 1; j <= m; j++)
			y[i][j] = y[i - 1][j] + y[i][j - 1] - y[i - 1][j - 1] + (a[i][j] and a[i - 1][j]);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m + 1; j++)
			x[i][j] = x[i - 1][j] + x[i][j - 1] - x[i - 1][j - 1] + (a[i][j] and a[i][j - 1]);
	while(q--){
		scanf("%d %d %d %d",&c ,&d ,&z ,&t);
		int mavi = pre[z][t] - pre[c - 1][t] - pre[z][d - 1] + pre[c - 1][d - 1];
		int yyy = y[z][t] - y[c][t] - y[z][d - 1] + y[c][d - 1];
		int xxx = x[z][t] - x[c - 1][t] - x[z][d] + x[c - 1][d];
		printf("%d\n", mavi - yyy - xxx);
	}
	return 0;
}

Measured memory_bytes: 64640
#include <cstdio>
using namespace std;
int n,i,ans,a[100050];
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);int ans=0;
	for (i=1;i<=n;i++) if (a[i]==i) ans++,i++;printf("%d\n",ans);
	return 0;
}

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

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i = (a); i != (b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int) (v).size())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int maxn = 2e5;
int n,A[maxn];

// while using x characters, can we reach the end?
bool test(int x)
{
	if (n == 1) return x > 0;

	// cerr << "TESTING " << x << endl;

	vii chmap; // < pos, char >
	for (int i = 1; i < n; i++) {
		if (A[i] > A[i - 1]) continue; // append a's silently

		while (!chmap.empty() && chmap.back().x > A[i])
			chmap.pop_back(); // don't need this

		int pos = A[i];
		while (pos > 0) {
			int curch = chmap.empty() || chmap.back().x < pos ? 0 : chmap.back().y;
			int nxtch = curch + 1;
			if (nxtch != x) {
				if (!chmap.empty() && chmap.back().x == pos) chmap.back().y = nxtch;
				else chmap.eb(pos, nxtch);
				break;
			}

			if (!chmap.empty() && chmap.back().x == pos) chmap.pop_back();
			pos--;
			// continue with:
			// aabbba
			// aabbCa -> aabCaa -> aaCaaa -> abaaaa
			continue;
		}
		if (pos <= 0) return false;

		/*
		cerr << i << ": ";
		for (auto x : chmap) cerr << x.x << "," << x.y << " ";
		cerr << endl; */
	}
	return true;
}

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

	cin>>n;
	REP(i,n)cin>>A[i];

	int lo = 0, hi = n + 1;
	while (hi - lo > 1) {
		int mi =(hi+lo)/2;
		if (test(mi)) hi=mi;
		else lo=mi;
	}
	cout<<hi<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int res = 0;
  for (int i = 0; i < n; i += 2) {
    if (a[i] & 1) ++res;
  }
  cout << res << endl;
  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<pr, ut> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;

int main() {
	string s;
	cin >> s;
	int ans = 0;
	REP(i,s.size()){
		if(i % 2){
			if(s[i] == 'g')
				ans++;
		}
		else{
			if(s[i] == 'p')
				ans--;
		}
	}
	cout << ans << endl;
    return 0;	
}


Measured memory_bytes: 512
/* ***********************************************
Author        :yang12138
Created Time  :2017年06月03日 星期六 20时12分57秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=100;
int dp[N][10];
int a[N];

void solve(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],ans+=a[i];

	if(ans%10==0){
		sort(a+1,a+n+1);
		for(int i=1;i<=n;i++){
			if(a[i]%10) {ans-=a[i];break;}
		}
	}
	
	if(ans%10==0) ans=0;
	cout<<ans<<endl;

}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	solve(); 
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll rec(ll a){
  if(a==1)return 1;
  else return 2*rec(a/2)+1;
}

int main(){

  ll h;
  cin >> h;
  cout << rec(h) << endl;

}

Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
int main(){
    int n;
    scanf("%d",&n);
    int l[n];
    for(int i = 0;i<n;i++){
        scanf("%d",&l[i]);
    }

    int tmp;
    for(int i = 0;i < n;i++){
        for(int j = 1;j < n;j++){
            if(l[j] < l[j - 1]){
                tmp = l[j];
                l[j] = l[j - 1];
                l[j - 1] = tmp;    
            }
        }
    }
    int ind;
    int count = 0;
    for(int i = 0;i<(n - 2);i++){
        for(int j = (i+1);j<(n - 1);j++){
            ind = j + 1;
            while(1){
                if(ind == n){
                  count += (ind - j - 1);
                    break;
                }
                if(l[ind] >= (l[i] + l[j])){
                    count += (ind - 1 - j);
                    //printf("%d %d %d %d \n",l[i],l[j],l[ind],(n - ind));
                    break;
                }
                ind++;
            }
        }

    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import dijkstra,floyd_warshall
from scipy.sparse import csr_matrix
from  itertools import permutations

N,M,R=map(int,input().split())
r=[int(x)-1 for x in input().split()]
dist=[[0 for _ in range(N)] for _ in range(N)]
for i in range(M):
    x,y,z=map(int,input().split())
    dist[x-1][y-1]=z
    dist[y-1][x-1]=z
tr=floyd_warshall(dist)
ans=10**12
for tmp in permutations(r):
    cnt=0
    for i in range(R-1):
        cnt+=tr[tmp[i]][tmp[i+1]]
    ans=min(ans,cnt)

print(int(ans))




Measured memory_bytes: 18708
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define PI 3.14159265358979

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R; cin >> R;
    cout << fixed << setprecision(12) << 2 * R * PI << endl;

    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,z,w;
int a[2010];

int main(){
	cin>>n>>z>>w;
	REP(i,n)
		cin>>a[i];
	if(n==1){
		cout<<abs(a[0]-w)<<endl;
		return 0;
	}
	cout<<max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]))<<endl;
	return 0;
}

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

int main(){
    int64_t n;
    cin>>n;
    //we need to find factors;
    int64_t x=1,y=0;
    for(int64_t i=2;i*i<=n;i++){
        if(n%i==0) x=i; 
    }
    y=n/x;
    cout << x+y-2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

class UnionFind {
public:
    vector <int> par; // 各元の親を表す配列
    vector <int> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(int sz_): par(sz_), siz(sz_, 1) {
        for (int i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (int i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    int root(int x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(int x, int y) { // 連結判定
        return root(x) == root(y);
    }

    int size(int x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
  int n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,0,m) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    uf.merge(a,b);
  }
  int ans = 0;
  rep(i,0,n) {
    ans = max(ans,uf.size(i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4840
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	string s;
	cin >> s;
	int n = sz(s);
	int ans = 0;
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - 1 - i]) ans++;
	}
	cout << ans << "\n";
}



Measured memory_bytes: 256
from sys import stdin


def main():
    _ = int(stdin.readline().rstrip())
    Vs = [int(x) for x in stdin.readline().rstrip().split()]
    Cs = [int(x) for x in stdin.readline().rstrip().split()]
    VCs = [x[0] - x[1] for x in zip(Vs, Cs) if x[0] > x[1]]
    print(sum(VCs))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import collections
N = int(input())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
use_list = []
cnt = 0
while True:
    flag = 0
    div_list = make_divisors(N)
    if len(div_list) == 1:
        break
    for i in range(1,len(div_list)):
        if (len(collections.Counter(prime_factorize(div_list[i]))) == 1) and (div_list[i] not in use_list):
            use_list.append(div_list[i])
            N = N //div_list[i]
            cnt +=1
            flag = 1
            break
    if flag == 0:
        break
print(cnt)

Measured memory_bytes: 9596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define  pb push_back
#define sort1(v) sort(v.begin(),v.end())
ll a[3002][3002];
void upd(int i,int j,int n)
{
    a[i+1][j+1]++;
    a[j][j+1]--;
    a[i+1][n+1]--;
    a[j][n+1]++;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int d,t,s;
    cin>>d>>t>>s;
    int x=ceil(1.0*d/s);
    if(x<=t)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}








Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cassert>

using namespace std;
typedef long long ll;

ll range_sum(const vector<ll>& cs, ll i, ll j){
    assert(i <= j);
    return cs.at(j) - cs.at(i);
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }

    vector<ll> cs(n + 1, 0);
    for(int i = 0; i < n; ++i){
        cs.at(i + 1) = a.at(i) + cs.at(i);
    }

    ll ans = cs.back();
    ll left = 1, right = 3;
    for(int i = 2; i < n - 1; ++i){
        while(left + 1 < i){
            ll diff = abs(range_sum(cs, 0, left) - range_sum(cs, left, i));
            ll diff2 = abs(range_sum(cs, 0, left + 1) - range_sum(cs, left + 1, i));
            if(diff > diff2){
                left++;
            }else{
                break;
            }
        }
        right = max(right, i + 1LL);
        while(right + 1 < n){
            ll diff = abs(range_sum(cs, i, right) - range_sum(cs, right, n));
            ll diff2 = abs(range_sum(cs, i, right + 1) - range_sum(cs, right + 1, n));
            if(diff > diff2){
                right++;
            }else{
                break;
            }
        }

        ll x1 = range_sum(cs, 0, left);
        ll x2 = range_sum(cs, left, i);
        ll x3 = range_sum(cs, i, right);
        ll x4 = range_sum(cs, right, n);
        ans = min(ans, abs(max({x1, x2, x3, x4}) - min({x1, x2, x3, x4})));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

long long n, dp[402][402], v[402], sum[402];


int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    sum[i] = sum[i - 1] + v[i];
  }
  for (int i = 1; i <= n; i++)
    dp[i][i] = 0;
  for (int l = 2; l <= n; l++) {
    for (int i = 1; i <= n - l + 1; i++) {
      int j = i + l - 1;
      dp[i][j] = (1ll << 60);
      for (int k = i; k < j; k++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + sum[j] - sum[i - 1]);
      }
    }
  }
  cout << dp[1][n];
  return 0;
}


Measured memory_bytes: 1536
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> p(n), q(n);
    for(int i=0; i<n; i++){cin>>p[i]; p[i]--;}
    for(int i=0; i<n; i++){cin>>q[i]; q[i]--;}

    vector<int> v(n);
    iota(v.begin(), v.end(), 0);

    int a = -1, b = -1;
    int cnt = 0;
    do{
        cnt++;
        bool isP = true, isQ = true;

        for(int i=0; i<n; i++){
            if(v[i] != p[i]) isP = false;
            if(v[i] != q[i]) isQ = false;
        }

        if(isP) a = cnt;
        if(isQ) b = cnt;
    }while(next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++, i++) cout << s[i];
}


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

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

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const int INF = 100001;

int n, k;

int main()
{
    cin >> n >> k;
    cout << min(1,n % k) << endl;
}

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

vector<pair<long long,long long>> prime_factorize(long long N){
  vector<pair<long long,long long>> A;
  for(long long i=2;i*i<=N;i++){
    if(N%i!=0){
      continue;
    }
    long long ex=0;
    while(N%i==0){
      ex++;
      N/=i;
    }
    A.push_back(make_pair(i,ex));
  }
  if(N!=1){
    A.push_back(make_pair(N,1));
  }
  return A;
}
 
int main(){
  long long N,count=0;
  cin >> N;
  vector<pair<long long,long long>> A=prime_factorize(N);
  for(long long i=0;i<A.size();i++){
    long long B=A.at(i).second;
    long long C=1;
    while(B-C>=0){
      count++;
      B-=C;
      C++;
    }
  }
  cout << count << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b, c, ans = 3;
  cin >> a >> b >> c;

  if (a == b) ans--;
  if (a == c) ans--;
  if (b == c) ans--;
  if (ans == 0) ans++;

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


Measured memory_bytes: 256
using System;
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            int count = 0;
            for (int i = 1 ; i < K; i++)
            {
                for(int j = i + 1; j <= K; j++)
                {
                    if ((i + j) % 2 != 0) count++;
                }
            }

            Console.WriteLine(count);
        }
    }

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int X;
	cin >> X;

	Int temp = 1;
	Int sum = 0;

	while (sum < X) {
		sum += temp;
		temp++;
	}

	cout << temp - 1 << "\n";
}

Measured memory_bytes: 256