akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

N = int(input())
A = [int(input()) for _ in range(N)]
S = sum(A)

DP = [[0]*(S+1) for _ in range(2)]
DP[0][0] = 2
DP[0][A[0]] = 1

# R=G=S/2, B=0
DP2 = [[0]*(S+1) for _ in range(2)]
DP2[0][0] = 1
DP2[0][A[0]] = 1


max_A = A[0]
for i in range(1, N):
    a = A[i]
    max_A += a
    curr_dp = DP[i % 2]
    prev_dp = DP[(i+1) % 2]
    curr_dp2 = DP2[i % 2]
    prev_dp2 = DP2[(i+1) % 2]
    for r in range(max_A+1):
        if r >= a:
            curr_dp[r] = prev_dp[r]*2 + prev_dp[r-a]
            curr_dp2[r] = prev_dp2[r] + prev_dp2[r-a]
        else:
            curr_dp[r] = prev_dp[r]*2
            curr_dp2[r] = prev_dp2[r]
        curr_dp[r] %= 998244353
        curr_dp2[r] %= 998244353
# print(DP)
# print(DP2)

half_S = (S+1)//2
ans = pow(3, N, 998244353)
ans -= 3*sum(DP[(N-1) % 2][half_S:])
if S % 2 == 0:
    ans += 3*DP2[(N-1) % 2][S//2]

print(ans % 998244353)


Measured memory_bytes: 45688
#include <stdio.h>

int main(void)
{
    int a=0,b=0;
    scanf("%d %d",&a,&b);
    
    if(a>b){
        for(int i=0;i<a;i++) printf("%d",b);
    } else {
        for(int i=0;i<b;i++) printf("%d",a);
    }
    return 0;
}


Measured memory_bytes: 1724
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n;
vector< long long > arr( 3003 ), pref( 3003, 0 );
int ok[ 3003 ][ 3003 ];
long long dp[ 3003 ][ 3003 ];

long long solve( int l, int r )
{
	if( l == r )
	{
		return arr[ l ];
	}
	if( ok[ l ][ r ] != -1 )
	{
		return dp[ l ][ r ];
	}
	ok[ l ][ r ] = 1;
	dp[ l ][ r ] = max( arr[ l ] + pref[ r ] - pref[ l ] - solve( l + 1, r ), arr[ r ] + pref[ r - 1 ] - pref[ l - 1 ] - solve( l, r - 1 ) );
	return dp[ l ][ r ];
}

	
int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	memset( dp, -1, sizeof( dp ) );
	memset( ok, -1, sizeof( ok ) );
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> arr[ i ];
		pref[ i ] += pref[ i - 1 ] + arr[ i ];		
	}
	cout << 2 * solve( 1, n ) - pref[ n ] << "\n";
	return 0;
}

Measured memory_bytes: 106240
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(prob,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<prob[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=100005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
lld dp[301][301][301];
int n;

lld solve(int x, int y, int z)
{
    if(x<0||y<0||z<0)
    return 0.0;
    if(x==0&&y==0&&z==0)
    return 0.0;
    if(dp[x][y][z]>0)
    return dp[x][y][z];
    lld den=x+y+z;
    lld ans=n+x*solve(x-1, y, z)+y*solve(x+1, y-1, z)+z*solve(x, y+1, z-1);
    ans/=den;
    return dp[x][y][z]=ans;
}

int32_t main()
{
    IOS;
    cin>>n;
    lld den=(lld)n+0.0;
    int x=0,y=0,z=0;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        if(a==1)
        x++;
        else if(a==2)
        y++;
        else
        z++;
    }
    cout<<solve(x, y, z);
}


Measured memory_bytes: 426240
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

struct edge {int to, cost;};

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

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

// 単一始点最短経路
// 始点 s
int V, E, s; cin >> V >> E >> s;
vector<vector<edge>> G(V); //有向グラフ
rep(i, 0, E){
    int v, to, cost; 
    edge e;
    cin >> v >> e.to >> e.cost;
    G[v].push_back(e);
}
VI d(V, INF); // d[i] = 頂点 s から i への最短距離
d[s] = 0;

// 最悪計算量 O(ElogV) ．0≤E≤O(V²)。全て正の距離の場合．
priority_queue<PII, VP, greater<PII>> q; //firstは最短距離，secondは頂点番号
q.emplace(0, s);

while(!q.empty()){
    PII p = q.top(); q.pop();
    int v = p.second;
    if (d[v] < p.first) continue; 
    for (edge e: G[v])
        if (chmin(d[e.to], d[v] + e.cost))
            q.emplace(d[e.to], e.to);
}

for (int i : d) {
    if (i == INF) cout << "INF\n";
    else cout << i << "\n";
}

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり




Measured memory_bytes: 14400
s = raw_input()
z = 0
for i in range(len(s)):
	t = 0
	for j in range(len(s) - i):
		t = t * 10 + [1, 2 ** (j - 1)][j > 0]
	z += int(s[i]) * 2 ** i * t
print z

Measured memory_bytes: 2568
package main

import (
  "fmt"
)

func main() {
  var n int 
  fmt.Scan(&n)
  for i := 0; i < 1e6; i++ {
    if n == 1 || n == 2 || n == 4 {
      fmt.Println(i + 4)
      return
    }
    if n & 1 == 1 {
      n = 3*n + 1
    } else {
      n /= 2
    }
  }
}

Measured memory_bytes: 512
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s, t;
  cin >> s >> t;
  int a = 0;
  for(int i = 0; i < s.size(); i++) a += s[i] == t[i];
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    a = sum(A) / len(A)
    f, m = 0, abs(A[0] - a)
    for i, j in enumerate(A[1:], 1):
        t = abs(j - a)
        if t < m:
            f, m = i, t
    print(f)

main()


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

char ca[305][305];
int n,m;

int round(int a){
    if(a<0)a+=n;
    if(a>=n)a%=n;
    return a;
}

bool check(int t){
    int i,j;
    int x1,y1,x2,y2;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            x1=round(t+i),y1=j;
            x2=round(t+j),y2=i;
            if(ca[x1][y1]!=ca[x2][y2])return false;
        }
    }
    return true;
}

int main(){
    int i,j,k;
    int a,b,c;
    bool flag=false;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>ca[i];
    }
    a=0;
    for(i=-n+1;i<n;i++){
        if(check(i))a+=n-abs(i);
    }
    cout<<a<<endl;
}

Measured memory_bytes: 512
N = int(input())
c = (N + (4 - N%4)) / 4
d = (N + (7 - N%7)) / 7
flag = False
 
for i in range(int(c)):
  for j in range(int(d)):
    total = 4*i + 7*j
    if total == N:
      flag = True
      
if flag:
  print("Yes")
else:
  print("No")

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

int main() {
	int n, a = 0;
	cin >> n;
	for(int i = 0; i < 28; i++){
		for(int j = 0; j < 20; j++){
			if(i * 4 + j * 7 == n){
				a++;
				break;
			}
		}
	}
	if(a != 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// Last Change: 01/07/2019 13:33:22.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

class Cal {
private:
  int N, K;
  vector<int> h;
  vector<ll> dp;

  ll Cost(int, int);

public:
  Cal();
  ll DP(int);
  void Main();
};

ll Cal::Cost(int prev, int next) {
  ll ans = prev - next;
  return abs(ans);
}

Cal::Cal() {
  cin >> N >> K;
  h.resize(N + 1);
  dp.resize(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> h[i];
    dp[i] = -1; // dp初期化
  }
  dp[1] = 0;
}

ll Cal::DP(int index) {
  if (dp[index] == -1) {
    ll curDP = 3000000000;
    for (int i = max(index - K, 1); i < index; i++) {
      curDP = min(curDP, DP(i) + Cost(h[index], h[i]));
    }
    dp[index] = curDP;
  }
  return dp[index];
}

void Cal::Main() {
  ll ans = DP(N);
  cout << ans << endl;
}

int main() {
  Cal *cal = new Cal();
  cal->Main();
  delete cal;

  //LoopUntilZeroInpput();
}


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

typedef complex<double> P;

double cross(P a,P b){
	return imag(a*conj(b));
}

P in(stringstream &cin){
	double x,y;
	if(cin >> x >> y) return P(x,y);
	exit(0);
}

int main(){
	string l;
	while(getline(cin,l)){
		for( auto &&c : l )
			if( c == ',' )
				c = ' ';
		stringstream ss(l);
		P p[6];
		for(int i = 0 ; i < 4 ; i++)
			p[i] = in(ss);
		p[4] = p[0];
		p[5] = p[1];
		int bit = 0;
		for(int i = 0 ; i < 4 ; i++){
			bit |= 1<<(cross(p[i+1]-p[i],p[i+2]-p[i])>0);
		}
		if( bit == 3 ){
			cout << "NO" << endl;
		}else{
			cout << "YES" << endl;
		}
			
		
	}
	
	
}

Measured memory_bytes: 3176
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter};
use std::collections::{VecDeque, BinaryHeap, BTreeMap};
use std::f32::MAX;

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn step(mut num: usize) -> usize {
    let mut digits = Vec::with_capacity(4);
    while num != 0 {
        digits.push(num % 10);
        num /= 10;
    }
    for _ in digits.len() .. 4 {
        digits.push(0);
    }
    digits.sort();
    let mut l = 0;
    let mut s = 0;
    for i in 0 .. 4 {
        l = l * 10 + digits[3 - i];
        s = s * 10 + digits[i];
    }
    l - s
}
fn solve(num: usize, memo: &mut Vec<i32>) -> i32 {
    match memo[num] {
        -1 => {
            let res = solve(step(num), memo) + 1;
            memo[num] = res;
            res
        }
        cache => cache
    }
}
fn main() {
    let mut memo = vec![-1; 10000];
    memo[6174] = 0;
    loop {
        let_all!(n: usize);
        if n == 0 {
            return
        }
        if step(n) == 0 {
            println!("NA");
        }else {
            println!("{}", solve(n, &mut memo));
        }
    }
}



Measured memory_bytes: 5036
n, m = map(int, input().split())
list_A = list(map(int, input().split()))

l = 1/(4*m)*sum(list_A)
cnt = 0
for c in list_A:
    if c >= l:
        cnt += 1

ans = "No"
if cnt >= m:
    ans = "Yes"

print(ans)

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500*i+100*j+50*k == x) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int64_t h, w, mod = 1000000007;
	cin >> h >> w;
	vector<string> ss(h);
	for (auto &s : ss)
	{
		cin >> s;
	}
	vector<vector<int64_t>> dp(h, vector<int64_t>(w, 0));
	dp[0][0] = 1;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (i + 1 < h && ss[i + 1][j] == '.')
			{
				(dp[i + 1][j] += dp[i][j]) %= mod;
			}
			if (j + 1 < w && ss[i][j + 1] == '.')
			{
				(dp[i][j + 1] += dp[i][j]) %= mod;
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 9216
#include <iostream>

using namespace std;

char s[110] = {};

int main() {
	cin >> s;
	for (int i = 0; i < 110; i++) {
		if (s[i] == NULL) {
			cout << s[0] << i-2 << s[i - 1] << endl;
			return 0;
		}
	}
}

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

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if(a > c) {
        swap(c, a);
        swap(b, d);
    }
    
    if(a <= c && d <= b) cout << d - c << endl;
    else cout << max(b - c, max(0, a - d)) << endl;
    return (0);
}


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

Measured memory_bytes: 512
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String W = scan.next().toLowerCase();
		String str;
		int count = 0;
		while (true) {
			str = scan.next();
			if (str.equals("END_OF_TEXT")) break;
			str = str.toLowerCase();
			if (str.equals(W)) count++;
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 26140
#include <stdio.h>
#include <math.h>

int main(void) {
    long int quantity, amount, i, ave, sum = 0;
    
    scanf("%ld", &quantity);
    
    for(i = 0; i < quantity; i++) {
        scanf("%ld", &amount);
        
        sum += amount;
    }
    
    ave = floor(sum / quantity);
    
    printf("%ld\n", ave);
    
    return(0);
}

Measured memory_bytes: 592
#include<stdio.h>
int main(){
    int a,b,k,p;
    
    scanf("%d%d",&a,&b);
    
    k=b-a;
    
    p=((1+k)*k)*0.5-b;
    
        
        printf("%d\n",p);
   
        


    
    return 0;
    
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    double k;
    cin >> n  >> k;
    double ans=0.0;
    for(int i=1; i<=n; i++){
        double tmp = i;
        int p=0;
        while(tmp<=k-1){
            p++;
            tmp*=2;
        }
        // cout << p << endl;
        ans+=1.0/n * (pow(1.0/2, p));
    }
    cout <<setprecision(16) << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
    sort(rng(s[i]));
  }
  map<string, int > M;
  rep(i,n)M[s[i]]++;
  ll ans = 0;
  rep(i,n){
    ans+=max(M[s[i]]-1,0);
    M[s[i]]--;
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 14020
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>

int is_equal(char a[],char b[]){
	for(int i=0;i<105;i++){
		if(a[i]<'a'||a[i]>'z')break;
		if(a[i]!=b[i])return 0;
	}
	return 1;
}

int main(){
	char s[105],t[105];
	scanf("%s %s",s,t);
	int num = strlen(s);

	for(int i=0;i<105;i++){
		int a = s[0];
		for(int i=1;i<num;i++){
			s[i-1]=s[i];
		}
		s[num-1]=a;
		if(is_equal(s,t)){
			printf("Yes\n");
			return 0;
		}
	}
	
	
	printf("No\n");	
	return 0;
}

Measured memory_bytes: 128
let () = Scanf.scanf "%d" @@ fun n ->
  try
    Printf.printf "%d\n" @@
    List.find (fun i -> i * 108 / 100 = n) @@
    Array.to_list @@
    Array.init (n + 1) @@ fun i -> i
  with Not_found -> print_endline ":("


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;

	vector<string> vs ={"dream", "dreamer", "erase", "eraser"};
	rep(i,4) reverse(all(vs[i]));
	reverse(all(s));
	
	int i=0;
	while(i < sz(s)){
		bool ok = false;
		rep(j, 4){
			if(vs[j] == s.substr(i, sz(vs[j]))){
				i += sz(vs[j]); ok=true; break;
			}
		}
		if(!ok){ puts("NO"); return 0;}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    bool c1 = false,c2=false,c3=false;
    string s,sr;
    cin >> s;
    lli n = s.size();
    sr = s;
    reverse(all(sr));
    if(s==sr){
        c1 = true;
    }
    string ss1, ssr1;
    ss1 = s.substr(0,(n-1)/2);
    ssr1 = ss1;
    reverse(all(ssr1));
    if(ssr1==ss1){
        c2 = true;
    }
    string ss2, ssr2;
    ss2 = sr.substr(0, (n - 1) / 2);
    ssr2 = ss2;
    reverse(all(ssr2));
    if(ssr2==ss2){
        c3 = true;
    }
    YN(c1 && c2 && c3);
}

Measured memory_bytes: 3640
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    int n,k;
    cin>>n>>k;
    int ar[n+1],last[n+1];
    for(int i=1;i<=n;i++)
    {
        last[i]=-1;
        cin>>ar[i];
    }
    int cur=1,f,t=-1,next=1;
    last[1]=0;
    for(int i=1;i<=k;i++)
    {
        next=ar[next];
        if(last[next]==-1)
        last[next]=i;
        else
        {
            t=(k-i)%(i-last[next]);
            f=next;
            break;
        }
    }
    for(int i=0;i<t;i++)
    f=ar[f];
    if(t!=-1)
    cout<<f;
    else
    cout<<next;
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;cin>>n;
    int prd=1;
    int inf=1e18;
    v a(n);in(a,n);
    f(i,n)
    {
    	if(a[i]==0)
    	{
    		cout<<0<<endl;
    		return 0;
    	}
    }
    f(i,n)
    {
    	int val=a[i];
    	if(prd  > (inf/val))
    	{
    		cout<<-1<<endl;
    		return 0;
    	}
    	prd*=val;
    }
    cout<<prd<<endl;
    return 0;
}

Measured memory_bytes: 3960
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        Set<String> types = new HashSet<>();
        for (int i=0; i<N; i++) {
            types.add(scanner.next());
        }
        System.out.println(types.size());
    }
}

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

int main(){
  string a, b;
  cin >> a >> b;
  
  if(a.size() > b.size()){
    cout << "GREATER";
    return 0;
  }else if(a.size() < b.size()){
    cout << "LESS";
    return 0;
  }else{
    for(int i=0; i<a.size(); i++){
      if(a[i]==b[i]) continue;
      if(a[i] > b[i]) {
        cout << "GREATER";
        return 0;
      }else if(a[i] < b[i]){
        cout << "LESS";
        return 0;
      }
    }
  }
  cout << "EQUAL";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, k;
int main() {
  cin >> n >> k;
  lli ans = 0;
  for (lli b=k+1; b<=n; ++b) {
    lli m = n/b;
    ans += m*(b-k);
    lli rest = n-m*b;
    ans += max(0ll, rest==0 ? 0 : (k==0 ? rest-k : rest-k+1));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

n,h = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    ta,tb = map(int,input().split())
    a[i] = ta
    b[i] = tb

a.sort()
to_swing = a[-1]
b.sort()

thr = np.searchsorted(b,a)[0]

# print(to_swing)
# print(thr)

if h % to_swing == 0:
    sw = h // to_swing
else:
    sw = h // to_swing+1

m = sw
for i in range(1,n+1-thr):
    h -= b[-i]
    if h > 0:
        if h%to_swing == 0:
            sw = h//to_swing
        else:
            sw = h//to_swing+1
        temp = i+sw
        if temp < m:
            m = temp
    else:
        temp = i
        if temp < m:
            m = temp
        

print(m)


Measured memory_bytes: 22504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1e9+7;
// const ll INF = 1000000000000000000LL;

 int main() {
	 string s;
	 cin >> s;
	 int cnt =0;
	 int ans;
	 if(s=="RRR") ans = 3;
	 else if(s=="SRR") ans = 2;
	 else if(s=="RRS") ans = 2;
	 else if(s=="SSS") ans = 0;
	 else ans = 1;
	 cout << ans << endl;
	 return 0;
 }

Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            String s = sc.next();

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        }

    }
}



Measured memory_bytes: 26196
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    int n = s.length();
    rep(i,n) {
        if (i%2==0) {
            if (s[i]=='L') {
                cout << "No" << '\n';
                return 0;
            }
        }
        else {
            if (s[i]=='R') {
                cout << "No" << '\n';
                return 0;
            }
        }
    }

    cout << "Yes" << '\n';
    return 0;
}

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

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

    vector<int> A(M);
    for (int i  = 0; i < M; i++){
        cin >> A.at(i);
    }

    int sum = 0;
    for (int i = 0; i < M; i++){
        sum += A.at(i);
    }

    if (N > sum){
        cout << N - sum << endl;
    }
    else if (N == sum){
        cout << 0 << endl;
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
} node;

node *root,*NIL;


node *getMinimum(node *x);
node *find(node *u,int k);
node *getSuccessor(node *x);
void delete(node *z);
void insert(int k);
void inorder(node *p);
void preorder(node *p);



int main(void)
{
  int x;
  int i,n;
  char com[100];

  scanf("%d",&n);

  for(i = 0;i < n;i++){
      scanf("%s",com);

      if(com[0] == 'f'){
	  scanf("%d",&x);
	  
	  node *t = find(root,x);

	  if(t != NIL){
	      puts("yes");
	    } else {
	      puts("no");
	    }
	  
	} else if(strcmp(com,"insert") == 0){
	  scanf("%d",&x);
	  insert(x);
	  
	} else if(strcmp(com,"print") == 0){
	  inorder(root);
	  puts("");
	  
	  preorder(root);
	  puts("");
	  
	} else if(strcmp(com,"delete") == 0){
	  scanf("%d",&x);
	  delete(find(root,x));
	}
    }

  return 0;
}




node *getMinimum(node *x){
  while(x->left != NIL){
    x = x->left;
  }
  
  return x;
}

node *find(node *u,int k)
{
  while(u != NIL && k != u->key)
    {
      if(k < u->key)
	{
	  u = u->left;
	} else {
	u = u->right;
      }
    }
  
  return u;
}

node *getSuccessor(node *x){
  if(x->right != NIL){
    return getMinimum(x->right);
  }
  
  node *y = x->parent;
  
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  
  return y;
}

void delete(node *z)
{
  node *x,*y;

  if(z->left == NIL || z->right == NIL){
      y = z;
    } else {
      y = getSuccessor(z);
    }

  if(y->left != NIL){
      x = y->left;
    } else {
      x = y->right;
    }

  if(x != NIL){
      x->parent = y->parent;
    }

  if(y->parent == NIL){
      root = x;
    } else {
    
      if(y == y->parent->left){
	  y->parent->left = x;
	} else {
	  y->parent->right = x;
	}
      
    }

  if(y != z)
    {
      z->key = y->key;
    }

  free(y);
}



void insert(int k){
  node *x = root;
  node *y = NIL;
  node *z;

  z = (node *)malloc(sizeof(node));
  
  z->left = NIL;
  z->right = NIL;
  z->key = k;

  while(x != NIL){
    y = x;
    
    if(z->key  <   x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;

  if(y == NIL){
    root = z;
  }
  if (y != NIL){
    if(y->key  >  z->key){
      y->left = z;
    } else {
      y->right = z;
    }
  }
  
}


void inorder(node *p){
  if(p != NIL){
    inorder(p->left);
    printf(" %d",p->key);
    inorder(p->right);
  } else {
    return;
  }
}


void preorder(node *p){
  if(p != NIL){
    printf(" %d",p->key);
    preorder(p->left);
    preorder(p->right);
  } else {
    return;
  }
}






Measured memory_bytes: 20444
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

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

int main() {
  int N, M;
  cin >> N >> M;
  string S, T;
  cin >> S >> T;
  int64_t g = gcd(N, M);
  bool flag = true;
  for (int k = 0; k < g; k++) {
    if (S.at(k * N / g) != T.at(k * M / g)) {
      flag = false;
    } 
  }
  if (flag) cout <<  N / g * M << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 640
using System;

namespace pro
{




    class MainClass
    {
        public static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if (a == b || (a + b) % 2 == 0)
            {
                Console.WriteLine((a + b) / 2);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }


}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

bool is(string &s)
{
    int n = s.length();
    
    for(int i=0;i<n;i++)
        if(s[i] != s[n-i-1]) return 0;
        
        return 1;
}

void solve()
{
   string s;
    cin >> s;
    
    int flag = 1;
    
    if(is(s) == 0) flag = 0;
    
    int len = (s.length());
    len/=2;
    
    string t;
    f(i,len) t+=s[i];
    
    if(is(t) == 0) flag = 0;
    
    t = "";
    f(i,len) t+=s[len-1-i];
    
    if(is(t) == 0) flag = 0;
    
    if(flag) cout <<"Yes";
    else cout <<"No";
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 256
using System;
using System.Linq;

class name
{
    static void Main()
    {
        char[] a = Console.ReadLine().Split().Select(char.Parse).ToArray();

        if (char.IsUpper(a[0]))
        {
            Console.WriteLine('A');

        }
        else
        {
            Console.WriteLine('a');
        }



    }





}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s;
  cin>>s;
  int n = s.size();
  REP(i,n/2)if(s[i]!=s[n-1-i]){
    puts("No");
    return 0;
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();

		if (X-A <= B && X-A >= 0) System.out.println("YES");
		else System.out.println("NO");
	}
}


Measured memory_bytes: 23764
from fractions import gcd
from functools import reduce

def solve():
  n, k = list(map(int, input().split()))
  a = list(map(int, input().split()))

  l = reduce(gcd, a)
  max_a = reduce(max, a)
  if k % l == 0 and max_a >= k:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")

  return
 
if __name__ == "__main__":
  solve()

Measured memory_bytes: 16092
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}



int main()
{
    weewoo;
    ll a;;
    cin >> a;
    cout << a*a*3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
 
int main (){
    int x,y,z;
    cin >> x >> y >> z;
    for(int i=1;i<x;i++){
        if(i*(y+z)+z>x){
            cout << i-1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int d = scan.nextInt();
    int e = scan.nextInt();
    int k = scan.nextInt();

    if (e - a > k || d - a > k || c - a > k || b - a > k) {
      System.out.println(":(");
      return;
    }
    System.out.println("Yay!");
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	const int M = 1'000'000;
	vector<int> c(M + 1);
	
	IN(int, n);
	inc(i, n) {
		IN(int, a);
		c[a]++;
	}
	
	int ans = 0;
	inc1(i, M) {
		if(c[i] != 0) {
			if(c[i] == 1) { ans++; }
			for(int j = i; j <= M; j += i) { c[j] = 0; }
		}
	}
	OUT(ans);
}


Measured memory_bytes: 7040
#include<iostream>
#include<cmath>
#include<climits>

using namespace std;

int main(){
  int n,m; 
  cin >> n >> m;
  long long students[n][2] {};
  long long checkpoint [m][2] {};
  int counter = 0;
  while(counter < n){
  	long long x, y;
    cin >> x >> y;
    students[counter][0] = x;
    students[counter][1] = y;
    counter++;
  }
  counter = 0;
  while(counter < m){
  	long long x, y;
    cin >> x >> y;
    checkpoint[counter][0] = x;
    checkpoint[counter][1] = y;
    counter++;
  }
  for(int i=0;i<n;++i){
  long long min = LONG_MAX;
  int index = -1;
  	for(int j=0;j<m;++j){
    	long long manhattan=abs(students[i][0] - checkpoint[j][0]) + abs(students[i][1] - checkpoint[j][1]);
      	if(manhattan<min){
        	min = manhattan;
            index = j+1;
        }
    }
    cout << index << endl;
  }
return 0;
}

Measured memory_bytes: 256
from collections import Counter as c
from itertools import permutations as p

def fact(n):
    d=[]
    for i in range(2,int(n**0.5)+2):
        while n%i==0:
            n//=i
            d.append(i)
    if n!=1:d.append(n)
    return c(d)

n=int(input())
d=c()
for i in range(1,n+1):
    d+=fact(i)

f=lambda n,x:sum(1 for i in p(d.values(),n) if all(map(lambda x,y:x>=y,i,x)))
print(f(3,(2,4,4))//2+f(2,(2,24))+f(2,(4,14))+f(1,(74,)))

Measured memory_bytes: 3436
import sys

A, B, K = map(int, input().split())
ans = 0
count = 0

for i in range(100):
    if A % (100 - i) == 0 and B % (100 - i) == 0:
        ans = 100 - i
        count += 1
        if count == K:
            print(ans)
            sys.exit()


Measured memory_bytes: 2940