akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
 
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
 
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
 
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int n;
int main(){
 
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
  	cin>>n;
  	int x,y;
  	x = 800*n;
  	y = (n/15) * 200;
  	cout<<x-y<<newl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>

const int MAXN = 50 + 10;
char s[MAXN];

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    getchar();
    fgets(s, n + 1, stdin);
    s[k - 1] = tolower(s[k - 1]);
    puts(s);
    return 0;
}

Measured memory_bytes: 1652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;


int main() {
	ll a,b, v,w,t;

	cin >> a >> v >> b >> w >> t;

	ll d = abs(a - b);

	if (v <= w) {
		cout << "NO" << endl;
		return 0;
	}

	ll dd = v - w;

	if (d <= dd * t) {
		cout << "YES" << endl;		
		return 0;
	}

	cout << "NO" << endl;



	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int now = 0;
	int ans = n;
	for(int i=1;i<n;i++)
	{
		if(s[i]=='E')now++;
	}	
	ans = now;

	for(int i=1;i<n;++i)
	{
		if(s[i-1]=='W')now++;
		if(s[i]=='E')now--;
		ans = min(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const int mod = 1000000007;

int cal(ll m, ll l){
    return l * pow(l - 1, m - 1);
}
int main() {
   ll n,k; cin >> n >> k;
   ll ans = cal(n,k);
   print(ans);
}

Measured memory_bytes: 256
N = gets.chomp.to_i
X = gets.chomp.split(" ").map(&:to_i)

min = Float::INFINITY
(1..100).each do |i|
  sum = 0
  X.each do |x|
    sum += (i - x) ** 2
  end
  min = [min, sum].min
end

puts min

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

int main(){
  int N, C[4] = {};
  std::string S;
  std::cin>>N;
  
  for(int i = 0; i < N; ++i){
    std::cin >> S;
    
    if(S == "AC")++ C[0];
    else if(S == "WA")++ C[1];
    else if(S == "TLE")++ C[2];
    else if(S == "RE")++ C[3];
  }
  std::cout << "AC x " << C[0] << std::endl;
  std::cout << "WA x " << C[1] << std::endl;
  std::cout << "TLE x " << C[2] << std::endl;
  std::cout << "RE x " << C[3] << std::endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2;

}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

l = 0
flag = 1
count = 0
while l < N:
  while h[l] == 0:
    l += 1
    if l == N:
      flag = 0
      break
  if flag == 1:
    if l == N-1:
      r = N-1
    else:
      r = l+1
      while h[r] != 0:
        r += 1
        if r == N:
          break
      r -= 1
    for k in range(l,r+1):
      h[k] -= 1
    count += 1
    #print(h)
  elif flag == 0:
    break
print(count)
  

Measured memory_bytes: 9144
N = int(input())
X=[0]*N
for i in range(N):
    X[i] = list(map(int, input().split()))
X.sort(key=lambda x:x[1])
def check():
    now = 0
    for i in range(N):
        now += X[i][0]
        if now > X[i][1]:
            return 'No'
    return 'Yes'
print(check())

Measured memory_bytes: 53612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
}
inline void putll(ll x){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 200005
int n,a[maxn],b[maxn];
queue <int> que;
inline int nei_sum(int pos){
  return b[(pos + n - 1) % n] + b[(pos + 1) % n];
}
ll solve(){
  for(int i = 0;i < n;i++){
    if(a[i] > b[i]) return -1;
    if(b[i] > nei_sum(i) && b[i] > a[i]){
      que.push(i);
    }
  }
  ll ans = 0;
  while(!que.empty()){
    int i = que.front(); que.pop();
    int dif = b[i] - a[i];
    if(dif < nei_sum(i)) return -1;
    ans += dif / nei_sum(i);
    b[i] -= dif / nei_sum(i) * nei_sum(i);
    int lef = (i - 1 + n) % n, rig = (i + 1) % n;
    if(b[lef] > nei_sum(lef) && b[lef] > a[lef]){
      que.push(lef);
    }
    if(b[rig] > nei_sum(rig) && b[rig] > a[rig]){
      que.push(rig);
    }
  }
  for(int i = 0;i < n;i++) if(b[i] > a[i]) return -1;
  return ans;
}
int main(){
  n = getint();
  for(int i = 0;i < n;i++) a[i] = getint();
  for(int i = 0;i < n;i++) b[i] = getint();
  putll(solve());
  bufo.flush();
  return 0;
}


Measured memory_bytes: 2304
w, h, n = map(int, input().split())
nums_list=[list(map(int, input().split())) for i in range(n)]
minX = 0
maxX = w
minY = 0
maxY = h
for nums in nums_list:
	x, y, a = map(int, nums)
	if a == 1:
		minX = minX if (minX > x) else x
	elif a == 2:
		maxX = maxX if (maxX < x) else x
	elif a == 3:
		minY = minY if (minY > y) else y
	else:
		maxY = maxY if (maxY < y) else y
width = maxX-minX
width = width if (width > 0) else 0
height = maxY-minY
height = height if (height > 0) else 0
v = width*height
print(v)

Measured memory_bytes: 38384
import java.util.*;

public class Main {

    static <T extends Comparable<? super T>> boolean nextPermutation(T[] sequence) {
        int first = getFirst(sequence);
        if (first == -1) return false;
        int toSwap = sequence.length - 1;
        while (sequence[first].compareTo(sequence[toSwap]) >= 0) --toSwap;
        swap(sequence, first++, toSwap);
        toSwap = sequence.length - 1;
        while (first < toSwap) swap(sequence, first++, toSwap--);
        return true;
    }

    static <T extends Comparable<? super T>> int getFirst(T[] sequence) {
        for (int i = sequence.length - 2; i >= 0; --i)
            if (sequence[i].compareTo(sequence[i + 1]) < 0) return i;
        return -1;
    }

    static <T extends Comparable<? super T>> void swap(T[] sequence, int i, int j) {
        T tmp = sequence[i];
        sequence[i] = sequence[j];
        sequence[j] = tmp;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] p = new Integer[n];
        Integer[] q = new Integer[n];
        for (int i = 0; i < n; ++i) p[i] = sc.nextInt();
        for (int i = 0; i < n; ++i) q[i] = sc.nextInt();

        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; ++i) arr[i] = i + 1;
        int P = 0, Q = 0, cnt = 1;
        do {
            if (Arrays.equals(arr, p)) P = cnt;
            if (Arrays.equals(arr, q)) Q = cnt;
            ++cnt;
        } while (nextPermutation(arr));

        System.out.println(Math.abs(P - Q));
    }
}

Measured memory_bytes: 24844
#include <cstdio>
#include <cstring>

char s[20];

int main(){
	scanf("%s",s);
	if(strlen(s)<4) printf("No");
	else{
		if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I')
			printf("Yes");
		else printf("No");
	}
	return 0;
}

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

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fir first
#define sec second

#define fo0(i,a,b) for(int i=(a);i<(b);i++)
#define fo1(i,a,b) for(int i=(a);i<=(b);i++)
#define fd0(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define fd1(i,a,b) for(int i=(a);i>=(b);i--)
#define mset(a,b) memset(a,(b),sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))

template<typename T> inline void in(T &x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9')
{if(ch=='-')fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T> void out(T x){if(x<0){putchar('-');x=-x;}if(x/10)out(x/10);putchar(x%10+'0');}
template<typename T> inline void outln(T x){out(x);putchar(10);}
template<typename T> inline void outsp(T x){out(x);putchar(' ');}
template<typename T> inline T gcd(T a, T b){T t;if(a>b){while(b){
t=b;b=a%b;a=t;}return a;}else{while(a){t=a;a=b%a;b=t;}return b;}}
template<typename T> inline T lcm(T a, T b){return a/gcd(a,b)*b;}

int n, m;

int main(){
	in(n); in(m);
	fo1(i, 1, sqrt(m)){
		if(m % i)	continue;
		if(i >= n){
			outln(m / i);
			return 0;
		}
	}
	fd1(i, sqrt(m), 1){
		if(m % i)	continue;
		if(m / i >= n){
			outln(i);
			return 0;
		}
	}
	return 0;
}

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

int main() {
	int max = 1, min = 1000;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int num;
		cin >> num;
		if (num < min) {
			min = num;
		}
		if (num > max) {
			max = num;
		}
	}

	cout << max - min << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cctype>
#include <vector>
#include <utility>
using namespace std;

typedef pair<int, int> pii;
const int INF = 1 << 28;
char board[510][510];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main() {
    int H, W; scanf("%d%d", &H, &W);
    int rest = 0;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            scanf(" %c", &board[i][j]);
            if(isupper(board[i][j])) rest++;
        }
    }

    int ans = 0;
    while(1) {
        bool ok = false;
        pii INIT = make_pair(-INF, -INF);
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                vector<pii> rec(26, INIT);
                if(isupper(board[i][j])) continue;
                for(int k=0; k<4; k++) {
                    int x = i, y = j;
                    while(1) {
                        x += dx[k], y += dy[k];
                        if(x < 0 || x >= H || y < 0 || y >= W) break;
                        if(isupper(board[x][y])) {
                            int c = board[x][y] - 'A';
                            if(rec[c] == INIT) rec[c] = make_pair(x, y);
                            else {
                                int u = rec[c].first, v = rec[c].second;
                                // printf("found: (%d, %d) and (%d, %d): %c (%d, %d)\n", u, v, x, y, 'A' + c, i, j);
                                board[u][v] = board[x][y] = '.';
                                rec[c] = INIT;
                                ok = true;
                                ans += 2;
                            }
                            break;
                        }
                    }
                }
            }
        }
        if(!ok) break;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2940
fn main() {
    let mut inputs: Vec<(i32, i32)> = Vec::new();
    loop {
        let input: Vec<i32> = read_vec();
        if input[0] == 0 && input[1] == 0 {
            break;
        }
        inputs.push((input[0], input[1]));
    }

    let mut counts: Vec<i32> = Vec::new();

    for input in inputs.iter() {
        let n = input.0 + 1;
        let x = input.1;

        let mut count = 0;

        for i in 1..(n - 2) {
            for j in (i + 1)..(n - 1) {
                for k in (j + 1)..n {
                    if x == i + j + k {
                        count += 1;
                        break;
                    }
                }
            }
        }

        counts.push(count);
    }

    for r in counts.iter() {
        println!("{}", r);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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



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

template<typename T> 
map<T,int> factorize(T x){
    map<T,int> mp;
    for (T i = 2; i*i <= x; i++){
        while (x%i == 0) {
            x /= i;
            mp[i]++;
        }
        if (x == 1) break;
    }
    if (x != 1) mp[x]++;
    return mp;
}


int main(void){
    ll n;
    cin >> n;
    auto primes = factorize(n);
    int res = 0;
    for (auto itr : primes) {
        int r = itr.second;
        int e = 1;
        while (e <= r) {
            res++;
            r -= e;
            e++;
        }
    }
    cout << res << endl;
    return 0;
}


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



int main(){
 int a[10];
 for(int i=0;i<10;i++){
  cin>>a[i];
 }
 sort(a,a+10);
 for(int i=9;i>6;i--)
  cout<<a[i]<<endl;
return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{
int D;
	cin >> D;
	vec(C);
	vec(Las);
	fx(26) {
		vecp(C);
		Las.push_back(0);
	}

	fx(D) {
		fy(26) {
			cin >> table[x][y];
		}
	}

	vec(T);
	fx(D) {
		pb(T, x % 26 + 1);
	}
	ll sum = 0;
	vector<int> S(D);

	srand((time(NULL)));
	fx(200000) {
		int d, q;
		 q = rand() % 26 + 1;
		 int dif = INT_MAX, ind = 0;
		 fw(D-1) {
			 if (S[w+1]-S[w]<dif) {
				 ind = w + 1;
				 dif = S[w + 1] - S[w];
			 }
		 }
		 d = ind;

		int pre = T[d - 1];
		T[d - 1] = q;
		ll ans = 0;

		fy(26) {
			Las[y] = 0;
		}
		fw(D) {

			ans += table[w][T[w] - 1];
			Las[T[w] - 1] = w + 1;
			fz(26) {
				ans -= C[z] * (w + 1 - Las[z]);
			}
			S[w] = ans;
		}
		if (ans>sum) {
			sum = ans;
		}
		else {
			T[d - 1] = pre;
		}
	}

	fx(D) {
		ce(T[x])
	}

	
    return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;
constexpr int MOD = 1000000007;

int mod(ll x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(ll x,ll m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    constexpr int N = 1e5;
    constexpr int M = 13;
    
    string s; cin >> s;
    int dp[N+10][M];
    memset(dp,0,sizeof dp);
    dp[0][0] = 1;

    int l = s.size();
    REP(i,l) {
        REP(j,M) {
            REP(k,10) {
                if (s[i] - '0' == k || s[i] == '?') {
                    dp[i+1][(j*10 +k) % M] = mod(0LL + dp[i+1][(j*10 +k) % M] + dp[i][j]);
                }
            }
        }
    }

    cout << dp[l][5] << endl;

    return 0;
}

Measured memory_bytes: 5584
#include <string.h>
#include <stdio.h>
int main(void)
{
	int i , j , n , l;
	int k[110]={0};
	int num[110]={0};
	scanf ("%d",&n);
	
	for (i=0 ; i < n ; i++)
	{
		scanf ("%d",&k[i]);
	}

	for (i=0 ; i < n ; i++)
	{
		num[k[i]]++;
	}	

	j=0;
	for (i = 0 ; i <= 100 ; i++)
	{
		if(num[i]>0)
		j++;
	}

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


Measured memory_bytes: 128
<?php
  $n = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));
  $e = 0;
  for($i=0; $i<$n; $i++){
      if($s[$i] == "E"){
          $e++;
      }
  }
  
  $right = $e;
  $left = 0;
  $min = PHP_INT_MAX;
  for($i=0; $i<$n+1; $i++){
      $ans = $right+$left;
      if($s[$i] == "W"){
          $left++;
      }else{
          $right--;
      }
      $min = min($min, $ans);
  }
  echo $min;

Measured memory_bytes: 4604
// 2011/07/01 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int cnt[101] = {0};

	while(true){
		int num;
		cin >> num;
		if(cin.eof())
			break;

		cnt[num]++;
	}

	int max = 0;
	for(int i=1; i<=100; i++)
		if(cnt[i]>max)
			max = cnt[i];

	for(int i=1; i<=100; i++)
		if(cnt[i]==max)
			cout << i << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main() {
  while( 1 ) {
    string line;
    getline( cin, line );
    vector<int> cards;
    istringstream iss(line);
    string item;
    while( iss >> item ) {
      cards.push_back( atoi( item.c_str() ) );
    }
    if( !cards[ 0 ] ) { return EXIT_SUCCESS; }
    sort( cards.begin(), cards.end() );
    int one_num = 0;
    for( ; cards[ one_num ] == 1; one_num++ ); // counts '1' cards
      
    int len = cards.size();
    int sum = 0;
    for( int i = 0; i < len; i++ ) {
      sum += min( cards[ i ], 10 );
    }
    sum = ( sum > 21 ? 0 : sum ); 
    while( sum != 0 && one_num > 0 ) {
      if( sum + 10 > 21 ) break;
      sum += 10;
      one_num--;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        String Input = stdIn.nextLine();
        String inputs[] = Input.split(" ");
        int x = Integer.parseInt(inputs[0]);
        int y = Integer.parseInt(inputs[1]);

        if(x > 0 && x < 101 && y > 0 && y < 101){
            int result = x*y;
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 35752
#include <vector>
#include <iostream>
#include <set>
#include <cmath>

#define FOR(i,n) for(int i=0; i<n; i++)
#define FORI(i,z,n) for(int i=z; i<n; i++)

using namespace std;

int main () {
    int n, m;
    cin >> n >> m;

    set<int> coins;
    vector<int> dyn(n);
    dyn[0] = 1;

    FOR(i, m) {
        int c;
        cin >> c;
        coins.insert(c);
    }

    FORI(i, 1, n) {
        int coinVal = i+1;
        if (coins.find(coinVal) != coins.end()) {
            // There is an exact coin for the value i
            dyn[i] = 1;
        } else {
            // We need to combine previous value e.g: (n-1, 1), (n-2, 2), ...
            int minVal = 0;
            int inf = 0;
            int sup = i-1;
            FOR(j, ceil(i/2) + 1)
            while (sup >= inf) {
                if (minVal == 0 || dyn[inf] + dyn[sup] < minVal)
                    minVal = dyn[inf] + dyn[sup];
                inf++;
                sup--;
            }
            dyn[i] = minVal;
        }
    }

    cout << dyn[n-1] << endl;
}



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

public class Main {
	public static void main(String[] args) {
		execute();
	}

	private static void execute() {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int X = sc.nextInt();
          	int Y = sc.nextInt();

			if(a == X) {
              System.out.println(0);
            } else {
              System.out.println(1);
            }
				
		}
	}
}

Measured memory_bytes: 25172
from collections import defaultdict
N, K = [int(x) for x in input().split()]
P = [0] + [int(x) for x in input().split()]
C = [0] + [int(x) for x in input().split()]

max_score = max(C[1:])

for init in range(1, N + 1):   # 初めの場所をiとする
    score = defaultdict(int)  # int/bool/list....
    visited = [-1] * (N + 1)
    visited[init] = 0  # 何回移動後に着いたか？
    i = init
    for k in range(1, K + 1):
        prev = i
        i = P[i]    # k回移動後に着くところ

        if visited[i] < 0:  # まだ訪れてなかった
            visited[i] = k
            score[i] = score[prev] + C[i]
            max_score = max(max_score, score[i])
            continue

        loop_score = (score[prev] + C[i]) - score[i]
        loop_len = k - visited[i]

        score[i] = score[prev] + C[i]
        # max_score = max(max_score, score[i])

        # if k == K:
        #     break # これ以上移動できない

        start = i   # ループを開始するノード
        loop_num = (K - k) // loop_len # ループをあと何回回れるか
        loop_rem = (K - k) % loop_len

        if loop_num > 0 and loop_rem == 0:
            loop_num -= 1
            loop_rem = loop_len

        jj = start
        temp = 0
        temp_max = 0
        for l in range(loop_rem):
            jj = P[jj]
            temp += C[jj]
            temp_max = max(temp_max, temp)

        loop_max = temp_max + loop_num * loop_score
        max_score = max(max_score, score[start] + loop_max)
        break

print(max_score)

Measured memory_bytes: 169468
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
char s[N];

int main()
{
	int n;
	scanf("%s",s);
	n = strlen(s);
	int p = 0;
	for (int i = 0;i < n;i++)
	{
		if (s[i] == 'p') p++;
	}
	n /= 2;
	int ans = n - p;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int n, win, lose, draw;
	string team;
	
	bool first = true;
	
	while (cin >> n, n)
	{
		vector<pair<pair<int, int>, string> > v;
		rep(i, n)
		{
			cin >> team >> win >> lose >> draw;
			v.push_back(mp(mp(win * 3 + draw, -i), team));
		}
		
		sort(v.rbegin(), v.rend());
		
		if (first)
		{
			first = false;
		} else {
			cout << endl;
		}
		
		rep(i, v.size())
		{
			cout << v[i].second << "," << v[i].first.first << endl;
		}
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

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

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1220
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) { }
    bool unionSet(ll x, ll y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) {
        return root(x) == root(y);
    }
    ll root(ll x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(ll x) {
        return -data[root(x)];
    }
};

int main()
{
    unordered_set<int> m;
    int a,b,c;
    cin >> a >> b >> c;
    m.insert(a);
    m.insert(b);
    m.insert(c);
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

MOD = 10 ** 9 + 7
a = []
flag = True
for i in range(M):
  tmp = int(input())
  if i != 0 and tmp == a[-1] + 1:
    print(0)
    flag = False
    break
  a.append(tmp)

if flag:
  max_dis = 0
  dis = []
  for i in range(len(a)):
    if i == 0:
      dis.append(a[i])
    else:
      dis.append(a[i] - a[i - 1] - 1)
    max_dis = max(max_dis, dis[-1])
  if M == 0:
    max_dis = N
    a.append(-1)
  else:
    max_dis = max(max_dis, N - a[-1])
  
  fib = [1, 1]
  for _ in range(max_dis):
    fib.append((fib[-1] + fib[-2]) % MOD)
  ans = 1
  for d in dis:
    ans = (ans * fib[d - 1]) % MOD
  ans *= fib[N - a[-1] - 1] % MOD
  
  print(ans % MOD)

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  bool ans=true;
  rep(i,n){
    if(a[i]%2==0){
      if(a[i]%3==0||a[i]%5==0){
      }else{
        ans=false;
        break;
      }
    }
  }
  if(ans){
    cout<<"APPROVED"<<endl;
  }else{
    cout<<"DENIED"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int tmp, maxN = -1000000, minN = 1000000;
  ll sumN = 0;
  REP(i, N){
    cin >> tmp;
    maxN = max(maxN, tmp);
    minN = min(minN, tmp);
    sumN += tmp;
  }
  cout << minN << " " << maxN << " " << sumN << endl;
}



Measured memory_bytes: 3184
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)

INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
L = LI() + [-1]
ans = 0
cnt = 0
for i in range(n + 1):
    if L[i] == i + 1:
        cnt += 1
    else:
        ans += (cnt + 1) // 2
        cnt = 0


print(ans)

Measured memory_bytes: 53232
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if(par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y)
            return false;
        if(par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};
// Kruskal 法で使用する枝
using pint = pair<int, int>;
using Edge = pair<long long, pint>; //<cost,<u,v>>の形
vector<Edge> edges;
int N, M;

int main() {
    cin >> N;
    M = 0;
    vector<pair<int, int>> xy(N);
    vector<pair<int, int>> xi(N);
    vector<pair<int, int>> yi(N);
    rep(i, 0, N) {
        cin >> xy[i].first >> xy[i].second;
        xi[i] = make_pair(xy[i].first, i);
        yi[i] = make_pair(xy[i].second, i);
    }
    sort(xi.begin(), xi.end());
    sort(yi.begin(), yi.end());
    rep(i, 0, N - 1) {

        long long u, v, w;
        u = xi[i].second;
        v = xi[i+1].second;
        w = abs(xi[i].first - xi[i+1].first);
        edges.push_back(make_pair(w, (make_pair(u, v))));
        M++;
    }
    rep(i, 0, N - 1) {
        long long u, v, w;
        u = yi[i].second;
        v = yi[i+1].second;
        w = abs(yi[i].first - yi[i+1].first);
        edges.push_back(make_pair(w, (make_pair(u, v))));
        M++;
    }
    //クラスカル法（Kruskal）
    sort(edges.begin(), edges.end()); // costが小さい順にソート
    UnionFind uf(N);
    long long res = 0LL;
    // rep(i, 0, M) {
    //     cout << edges[i].first << "," << edges[i].second.first << ","
    //          << edges[i].second.second << endl;
    // }
    rep(i, 0, M) {
        Edge e = edges[i];
        int a = e.second.first;
        int b = e.second.second;
        if(!uf.issame(a, b)) {
            uf.merge(a, b);
            res += e.first;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 8816
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

N = gets_i
a_list = []
N.times do
  a_list.push gets_i
end

a2_list = a_list.sort.reverse

max1 = a2_list[0]
max2 = a2_list[1]

a_list.each do |a|
  if a == max1
    puts max2
  else
    puts max1
  end
end

Measured memory_bytes: 8468
#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, cnt = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
    }


    while (1)
    {
        rep(i,n) {
            if (a[i] % 2 != 0)
            {
                cout << cnt << endl;
                return 0;
            }
            a[i] /= 2;
        }
        cnt++;
    }
}

Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
ans = 1e20
s = gets.chomp
ga = na(n,0)
gb = na(n,0)
(s.size-1).times do |i|
  if s[i] == "W"
    ga[i+1] = ga[i] + 1
  else
    ga[i+1] = ga[i]
  end
end
(1..(s.size-1)).each do |i|
  if s[-i] == "E"
    gb[-i-1] = gb[-i] + 1
  else
    gb[-i-1] = gb[-i]
  end
end
s.size.times do |i|
  ans = [ga[i]+gb[i],ans].min
end
p ans

Measured memory_bytes: 7196
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	
	int N;
	
	cin >> N;
	
	vector<pair<string,pair<int,int>> > v(N);
	
	for(int i=0;i<N;i++){
		cin >> v[i].first >> v[i].second.first;
		v[i].second.first = 100 - v[i].second.first;
		v[i].second.second = i+1;
	}
	
	sort(v.begin(),v.end());
	
	for(int i=0;i<N;i++){
		cout << v[i].second.second << endl;
	}
	
	
	return 0;
}

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

int main() {
  string s;
  int q;
  cin >> s >> q;
  int reversed = 0;
  string sf = "", sb = "";
  rep(qi, q) {
    int t;
    cin >> t;
    if (t == 1) reversed = 1 - reversed;
    else {
      int f;
      char c;
      cin >> f >> c;
      if (reversed % 2 == f % 2) sb += c;
      else sf += c; 
    }
  }
  reverse(sf.begin(), sf.end());
  string ans = sf + s + sb;
  if (reversed) reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4328
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

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

long long MOD = 1000000007;
long long dp[100005][4];

long long Calc(long long count) {
	return (count*(count - 1)) / 2LL;
}

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

	vector<string>S(N);
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		S[i] = s;
	}
	sort(S.begin(), S.end());

	string before = S[0];
	long long count = 1;
	long long ans = 0;
	for (int i = 1; i < N; ++i) {
		if (before == S[i])count++;
		else {
			ans += Calc(count);
			count = 1;
		}
		if (i == N - 1 && 2 <= count) {
			ans += Calc(count);
		}
		before = S[i];
	}
	cout << ans << endl;
}
	

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

using namespace std;

typedef long long ll;

struct Base
{
	ll d[65];
	const ll mx;

	Base(ll mx = 60) : mx(mx)
	{
        for(ll i = 0; i <= mx; i++)    d[i] = 0;
	}

	void insert(ll x)
	{
	    for(ll i = mx; ~i; --i)
        {
            if(x & (1LL << i))
            {
                if(!d[i])
                {
                    d[i] = x;
                    break;
                }

                x ^= d[i];
            }
        }
	}

	bool Can(ll x, ll j)
	{
	    for(ll i = mx; ~i; --i)
            if(x & (1LL << i))
                x ^= d[i];

        x &= ((1LL << mx) - (1LL << j));

	    return x == 0;
	}
};

ll Get(ll Mask, ll j)
{
    return (Mask & (1LL << j)) ? 1LL : 0LL;
}

int main()
{
    ll n;  cin >> n;

    ll Xor = 0;
    vector <ll> a(n);

    for(ll& x : a)  scanf("%lld", &x), Xor ^= x;

    vector <ll> Even;

    for(ll k = 0; k < 60; k++)
        if(!(Xor & (1LL << k)))
            Even.push_back(k);

    Base B(Even.size());

    for(ll i = 0; i < n; i++)
    {
        ll x = 0;

        for(ll j = 0; j < Even.size(); j++) x ^= (Get(a[i], Even[j]) << j);

        B.insert(x);
    }

    ll Ans = 0;

    for(ll j = (ll) Even.size() - 1, Mask = 0; ~j; --j)
    {
        if(B.Can(Mask | (1LL << j), j))
        {
            Mask |= (1LL << j);
            Ans += 2LL * (1LL << Even[j]);
        }
    }

    cout << Ans + Xor << endl;
}


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

int main(){

	int n;
	string s;
	cin >> n;
	cin >> s;
	if(n%2==1){cout << "No" << endl;return 0;}
	else{if(s.substr(0,n/2)==s.substr(n/2,n/2)){cout << "Yes" << endl;return 0;}
         else{cout << "No" << endl;return 0;}
	}

	return 0;
}


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

long long int x;
long long int power(long long int a, int p)
{
    if (p == 0)
        return 1;
    long long int ans = power(a, p / 2);
    ans = ans * ans;
    if (p % 2 == 1)
        ans = ans * a;
    return ans;
}
long long int tst(int f)
{
    for (long long int b = 1; b <= 1e+3; b++)
    {
        // cout << power(b + f, 5) - power(f, 5) << " ";
        if (power(b + f, 5) - power(b, 5) == x)
            return b;
    }
    for (long long int b = -1e+3; b <= -1; b++)
    {
        // cout << power(b + f, 5) - power(f, 5) << " ";
        if (power(b + f, 5) - power(b, 5) == x)
            return b;
    }
    return -1e+18;
}
int main()
{
    long long int A, B;
    cin >> x;
    for (int f = 1; f * f <= x; f++)
    {
        if (x % f == 0)
        {
            // cout<<f<<"\n";
            B = tst(f);
            if (B != -1e+18)
            {
                // cout<<f;
                A = B + f;
                break;
            }
            B = tst(x / f);
            if (B != -1e+18)
            {
                // cout<<f;
                A = B + x / f;
                break;
            }
        }
    }
    cout << A << " " << B;
}

Measured memory_bytes: 3636
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    A = {}
    for i in range(N):
        if int(input_raw[i]) not in A:
            A[int(input_raw[i])] = 1
        else:
            A[int(input_raw[i])] += 1
    A_val = A.values()

    A_val.sort(reverse = True)

    count = 0L
    for i in range(K, len(A_val)):
        count += A_val[i]
    print count


if __name__ == '__main__':
    main()


Measured memory_bytes: 42944
import sys
from heapq import heappush, heappop

readline = sys.stdin.readline


def solve():
    N = int(readline())

    left = [[] for _ in range(N)]
    right = [[] for _ in range(N)]
    ans = 0
    for _ in range(N):
        K, L, R = map(int, readline().split())
        if L > R:
            ans += R
            left[K - 1].append(L - R)
        else:
            ans += L
            if 0 <= N - K - 1:
                right[N - K - 1].append(R - L)

    for vec in (left, right):
        hq = []
        n = len(vec)

        for i in range(n):
            for p in vec[i]:
                heappush(hq, p)
            while len(hq) > i + 1:
                heappop(hq)

        for i in range(n, N):
            for p in vec[i]:
                heappush(hq, p)
            while len(hq) > n:
                heappop(hq)

        ans += sum(hq)

    return ans


def main():
    T = int(readline())

    ans = [0] * T
    for i in range(T):
        ans[i] = solve()

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int dx = c - a;
    int dy = d - b;
    cout << c - dy << ' ' << d + dx << ' ';
    cout << a - dy << ' ' << b + dx;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   String A = sc.next();
   String B = sc.next();
   
   int a = hexToNum(A);
   int b = hexToNum(B);
 
   if(a<b) System.out.println("<");   
   else if(a==b)System.out.println("=");
   else System.out.println(">");
 }
  static int hexToNum(String s)
  {
    if(s.equals("A")) return 10;
    else if(s.equals("B")) return 11;
    else if(s.equals("C")) return 12;
    else if(s.equals("D")) return 13;
    else if(s.equals("E")) return 14;
    else return 15;
  }
}

Measured memory_bytes: 21716
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};


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

    ll a,b,c,d,n,maxi=0,f=0,mini=INF,sum=0;
    ll h,w;
    ll m;
    cin>>n;
    n*=3;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(all(v));
    for(ll i=n/3;i<n;i=i+2){
        //cout<<i<<endl;
        sum+=v[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 5452
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string t;
	cin >> t;
	int i, len;
	len = t.length();
	for (i = 0; i < len; i++) {
		if (t[i] == '?') {
			cout << "D";
		}
		else {
			cout << t[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>b(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        b[i] = a[i];
            
    }
    
    sort(a.begin(),a.end());
    
    for(int i=0;i<n;i++){
        if(b[i] == a[n-1]){
            cout << a[n-2] << endl;
        }
        else cout << a[n-1] << endl;

    }    
}

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

using namespace std;

#define fastio ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;

void multof3(int n)
{

}

int main()
{
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("output.txt", "w", stdout); 
	#endif	
	
	fastio;

	int n, sum = 0;
	cin >> n;
	int arr[n][2];
	bool flag = false;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i][1];
		cin >> arr[i][2];
	}
	for(int i = 0; i < n-2; i++)
	{
		if(arr[i][1] == arr[i][2] && arr[i+1][1] == arr[i+1][2] && arr[i+2][1] == arr[i+2][2])
		{
			flag = true;
			break;
		}
	}
	if(flag)
		cout << "Yes";
	else
		cout << "No";

	return 0;

}

Measured memory_bytes: 3608
from numba import njit, int32
import numpy as np


@njit(int32(int32[:], int32[:]))
def main(A, B):
    ans = 0

    for a in A:
        B[a] += 1

    for a in set(A):
        v = 2*a
        while v <= 10**6:
            B[v] += 1
            v += a

    for a in A:
        if B[a] == 1:
            ans += 1

    return ans


if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0]*(10**6+1)
    ans = main(np.array(A, dtype=np.int32), np.array(B, dtype=np.int32))
    print(ans)


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

int main() {
    int c[3][3];
    for (int i = 0; i < 3; i++) {
        cin >> c[i][0] >> c[i][1] >> c[i][2];
    }

    string ret = "No";
    int b1,b2,b3;
    for (int a1 = 0; a1 <= 100; a1++) {
        for (int a2 = 0; a2 <= 100; a2++) {
            for (int a3 = 0; a3 <= 100; a3++) {
                b1 = c[0][0] - a1;
                b2 = c[0][1] - a1;
                b3 = c[0][2] - a1;
                
                // b1
                if (c[1][0] - a2 == b1 && c[2][0] - a3 == b1) {
                    // b2
                    if (c[1][1] - a2 == b2 && c[2][1] - a3 == b2) {
                        // b3
                        if (c[1][2] - a2 == b3 && c[2][2] - a3 == b3) {
                            ret = "Yes";
                            break;
                        }
                    }
                }
            }
        }
    }

    cout << ret << endl;
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	bool flag = true;
	
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			flag = false;
			break;
		}
	}

	printf("%s", flag ? "Yes" : "No");


	return 0;
}



Measured memory_bytes: 3692