akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void FuncQuickSortArray(int sample[], int left, int right);
void FuncSwap(int *x, int *y);
void FuncShowArray(int array[], int head, int tail);

void FuncQuickSortArray(int sample[], int left, int right)
{
  int pivot;
  int i, j;

  pivot = sample[(left + right) / 2];
  i = left;
  j = right;

  while (1) {
    while (sample[i] < pivot)
      i++;
    while (sample[j] > pivot)
      j--;

    if (i >= j)
      break;

    FuncSwap(&sample[i], &sample[j]);
    i++;
    j--;
  }

  if (left < (i - 1))
    FuncQuickSortArray(sample, left, i - 1);
  if ((j + 1) < right)
    FuncQuickSortArray(sample, j + 1, right);
}

void FuncSwap(int *x, int *y)
{
  int temp = *x;
  *x = *y;
  *y = temp;
}

void FuncShowArray(int array[], int head, int tail)
{
  int i;

  for (i = head; i <= tail; i++){
    if (i != tail) {
      printf("%d ", array[i]);
    } else {
      printf("%d\n", array[i]);
    }
  }
}

int main(void)
{
  int height[10];
  int i;

  for (i = 0; i < 10; i++) {
    scanf("%d", &height[i]);
  }

  FuncQuickSortArray(height, 0, 10 - 1);

  for (i = 9; i >= 7; i--) {
    printf("%d\n", height[i]);
  }

  return 0;
}

Measured memory_bytes: 600
def main():
    X = int(input())
    for a in range(int(X**0.2)+1):
        for b in range(int(X**0.2)+1):
            if a**5 + b**5 == X:
                print(a, b*(-1))
                return
    for b in range(1, int(X**0.25)+1):
        temp = (X + b**5)**0.2
        if abs(temp - int(temp)) < 0.0001:
            print(int(temp), b)
            break
main()


Measured memory_bytes: 9456
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1);
	for (int i = 0; i <= N; ++i) {
		cin >> A[i];
	}
	int g = A[N] - 1;
	for (int i = N - 1; i >= 0; --i) {
		g = g / 2 + A[i];
	}
	if (g >= 1) {
		cout << -1 << endl;
	}
	else {
		vector<long long> dp(N + 1);
		dp[0] = 1;
		for (int i = 1; i <= N; ++i) {
			dp[i] = min(dp[i - 1] * 2 - A[i], 1LL << 60);
		}
		long long s = 0, ans = 0;
		for (int i = N; i >= 0; --i) {
			s += A[i];
			ans += min(s, dp[i] + A[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;
const int N = 1e5 + 3;
int n, a[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	scanf("%d", &n);
	multiset<int> st;
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	st.insert(a[n - 1]);
	for (int i = n - 2; i >= 0; --i) {
		auto it = st.lower_bound(a[i] + 1);
		if (it != st.end()) {
			st.erase(it);
			st.insert(a[i]);
		}else {
			st.insert(a[i]);
		}
	}
	printf("%d\n", st.size());
	return 0;
}

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

#define fori( tt,aa)      for(long long i= tt; i<aa; i++)
#define forj( yy,bb)      for(long long j=yy; j<bb; j++)
#define fork( uu,cc)      for(long long k=uu; k<cc; k++)
#define sz(v)    v.size()
#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define EPS 1e-7
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE; fast();

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string String;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;


void accuSum2D(vector<vector<int>>&a){
    //accumulate each row
    fori(1, 101)
     forj(1, 101)
        a[i][j] +=a[i][j-1];

    //accumulate each col
    forj(1, 101)
     fori(1, 101)
        a[i][j] +=a[i-1][j];
}

int sum_range(int i, int j, int k, int l, vector<vector<int>>&s){
    return s[k][l] - s[k][j-1] - s[i-1][l] + s[i-1][j-1];
}

void fast(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
}

ld pow (ll a, ll b);
ll numOfDigits(ll n);
int main()
{
    THINK_TWICE_CODE_ONCE;
    //freopen("great Vova Wall1.txt", "r", stdin);
    ll n; cin>>n;
    ll sq = sqrt(n);
    ll mn = n-1;
    fori(1, sq+1){
        if(!(n%i)){
            ll div = n/i;
            ll mn2 = min(div, i), mx2 = max(div, i);
            mn = min(mn, mx2 + mn2 -2);
        }
    }
    cout<<mn;
    return 0;
}
ld pow (ll a, ll b){
    ld pow = 1;
    fori(0,b)
        pow *=a;
    return pow;
}

ll numOfDigits(ll n){
    if(!n) return 1;
    return (ll)(log10(n)+1);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

const long long INF = 1LL << 60;

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1

int N, W;
ll w[105], v[105];
ll dp[105][100005] = {0};

int main() {
    cin >> N >> W;
    rep(i, N) { cin >> w[i] >> v[i]; }

    rep(i, N) {
        rep(j, W + 1) {
            if(j >= w[i]) {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    // repp(i, 1, N + 1) {
    //     rep(j, W + 1) {
    //         if(j)
    //             cout << " ";
    //         cout << dp[i][j];
    //     }
    //     cout << endl;
    // }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
#!/usr/bin/ruby
class TLLI
	def initialize
		@trianies=[nil,[0,0,0]]
	end
	def root_triany
		1
	end
	def allocate_triany
		siz=@trianies.size
		@trianies[siz]=[0,0,0]
		return siz
	end
	def set_a(id,value)
		return if !@trianies[id]
		@trianies[id][0]=value
	end
	def set_b(id,value)
		return if !@trianies[id]
		@trianies[id][1]=value
	end
	def set_c(id,value)
		return if !@trianies[id]
		@trianies[id][2]=value
	end
	def get_a(id)
		return if !@trianies[id]
		@trianies[id][0]
	end
	def get_b(id)
		return if !@trianies[id]
		@trianies[id][1]
	end
	def get_c(id)
		return if !@trianies[id]
		@trianies[id][2]
	end
end

class SETI <TLLI # a=>key, b=>left, c=>right
	def set_entry(key)
		x=root_triany
		y=0
		while x!=0&&!(x==root_triany&&get_a(x)==0) #fixme
			y=x
			if key<get_a(x)
				x=get_b(x)
			else
				x=get_c(x)
			end
		end
		if y==0
			set_a(root_triany,key)
		else
			leaf=allocate_triany
			set_a(leaf,key)
			if key<get_a(y)
				set_b(y,leaf)
			else
				set_c(y,leaf)
			end
		end
	end
	def find_entry(key)
		t=root_triany
		loop{
			return true if key==get_a(t)
			if key<get_a(t)
				t=get_b(t)
				return false if t==0
			else
				t=get_c(t)
				return false if t==0
			end
		}
	end
	def delete_entry(key)
		left=false
		prev=nil
		t=root_triany
		loop{
			break if key==get_a(t)
			prev=t
			if key<get_a(t)
				t=get_b(t)
				left=true
				return false if t==0
			else
				t=get_c(t)
				left=false
				return false if t==0
			end
		}
		if get_b(t)>0&&get_c(t)>0
			children=inorder_internal(get_c(t))+[t]
			set_a(t,get_a(children[0]))

			prev=children[1]
			#left of parent of t
			if prev!=t
				set_b(prev,0)
				left=true
			else
				left=false
			end
			t=children[0]
		end
		if t==root_triany
			if get_b(root_triany)>0
				set_a(root_triany,get_a(get_b(root_triany)))
				set_c(root_triany,get_c(get_b(root_triany)))
				set_b(root_triany,get_b(get_b(root_triany)))
			elsif get_c(root_triany)>0
				set_a(root_triany,get_a(get_c(root_triany)))
				set_b(root_triany,get_b(get_c(root_triany)))
				set_c(root_triany,get_c(get_c(root_triany)))
			end
		else
			raise if !prev
			if get_b(t)+get_c(t)>0
				n=get_b(t)+get_c(t)
				if left
					set_b(prev,n)
				else
					set_c(prev,n)
				end
			else
				if left
					set_b(prev,0)
				else
					set_c(prev,0)
				end
			end
		end
	end
	def inorder_internal(t)
		t==0 ? [] : inorder_internal(get_b(t))+[t]
	end
	def print_preorder(t)
		return if t==0
		Kernel.print " #{get_a(t)}"
		print_preorder(get_b(t))
		print_preorder(get_c(t))
	end
	def print_inorder(t)
		return if t==0
		print_inorder(get_b(t))
		Kernel.print " #{get_a(t)}"
		print_inorder(get_c(t))
	end
	def print_postorder(t)
		return if t==0
		print_postorder(get_b(t))
		print_postorder(get_c(t))
		Kernel.print " #{get_a(t)}"
	end
	def print
		print_inorder(root_triany);puts
		print_preorder(root_triany);puts
	end
end

seti=SETI.new
gets
$<.each{|l|
	a=l.split
	if a[0]=='insert'
		seti.set_entry(a[1].to_i)
	elsif a[0]=='find'
		puts seti.find_entry(a[1].to_i) ? :yes : :no
	elsif a[0]=='delete'
		seti.delete_entry(a[1].to_i)
	elsif a[0]=='print'
		seti.print
	end
}

Measured memory_bytes: 53576
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
using namespace std;

#define N 100001

int sum[N];

int main()
{
	int a, b, c;
	int x, y;
	int ans;

	cin >> a >> b >> c >> x >> y;

	int n = x;
	if( y > n ) {
		n = y;
	}

	for( int i = 0; i <= n; i++ ) {
		int xx = x - i;
		if( xx < 0 ) {
			xx = 0;
		}
		int yy = y - i;
		if( yy < 0 ) {
			yy = 0;
		}
		sum[i] = a*xx + b*yy + c*i*2;
	}

	sort(sum, sum + n+1);
	ans = sum[0];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
class RollingHash():
    def __init__(self, s):
        self.length = len(s)
        self.base1 = 1009
        self.base2 = 1000
        self.mod1 = 10**9 + 7
        self.mod2 = 10**9 + 9
        self.hash1 = [0] * (self.length + 1)
        self.hash2 = [0] * (self.length + 1)
        self.pow1 = [1] * (self.length + 1)
        self.pow2 = [1] * (self.length + 1)

        for i in range(self.length):
            self.hash1[i+1] = (self.hash1[i] + ord(s[i])) * self.base1 % self.mod1
            self.hash2[i+1] = (self.hash2[i] + ord(s[i])) * self.base2 % self.mod2
            self.pow1[i+1] = self.pow1[i] * self.base1 % self.mod1
            self.pow2[i+1] = self.pow2[i] * self.base2 % self.mod2
        
    def get(self, l, r):
        t1 = ((self.hash1[r] - self.hash1[l] * self.pow1[r-l]) % self.mod1 + self.mod1) % self.mod1
        t2 = ((self.hash2[r] - self.hash2[l] * self.pow2[r-l]) % self.mod2 + self.mod2) % self.mod2
        return (t1, t2)

t_tmp = input().rstrip()
s = input().rstrip()

# Same character goes to infinity
if t_tmp.count(t_tmp[0]) == len(t_tmp) and s.count(s[0]) == len(s) and s[0] == t_tmp[0]:
    print(-1)
    exit()

t = ""
while len(t) <= len(s):
    t += t_tmp
max_ans = (len(t) * 3) // len(s)
t = t * 4
lent = len(t)
lens = len(s)

RHt = RollingHash(t)
RHs = RollingHash(s)
s_hash = RHs.get(0, lens)

match = [0] * (lent - lens + 1)
for i in range(lent - lens + 1):
    if RHt.get(i, i+lens) == s_hash:
        match[i] = 1
ans = max(match[:lens])
for i in range(len(match) - lens):
    if match[i+lens] != 0:
        match[i+lens] += match[i]
        ans = max(ans, match[i+lens])

if ans > max_ans:
    print(-1)
else:
    print(ans)

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

int main(int argc, char const *argv[])
{
	int k,q;
	cin>>k>>q;
	long long d[k];
	for (int i = 0; i < k; ++i)
	{
		cin>>d[i];
	}
	for (int i = 0; i < q; ++i)
	{
		long long n,x,m;
		cin>>n>>x>>m;
		long long a[k],z=0LL,s=0LL;
		for (int j = 0; j < k; ++j)
		{
			a[j]=d[j]%m;
			if (a[j]==0)
			{
				++z;
			}
			s+=a[j];
		}
		s*=(n-1LL)/(long long)k;
		s+=x%m;
		z*=(n-1LL)/(long long)k;
		for (int j = 0; j < (int)(n-1)%k; ++j)
		{
			if (a[j]==0)
			{
				++z;
			}
			s+=a[j];
		}
		z+=s/m;
		cout<<n-z-1LL<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

int n;
int abc[100005][4];
int dp[100005][4];  
int vac(int pos,int prec){
  if(dp[pos][prec]!=-1)return dp[pos][prec];
  if(pos==n)return 0;
  
  if(prec==1){
    return dp[pos][prec]=max(vac(pos+1,2)+abc[pos][2],vac(pos+1,3)+abc[pos][3]);
  }else if(prec==2){
    return dp[pos][prec]=max(vac(pos+1,1)+abc[pos][1],vac(pos+1,3)+abc[pos][3]);
  }else if(prec==3){
    return dp[pos][prec]=max(vac(pos+1,1)+abc[pos][1],vac(pos+1,2)+abc[pos][2]);
  }else{
    return dp[pos][prec]=max(max(vac(pos+1,1)+abc[pos][1],vac(pos+1,2)+abc[pos][2]),vac(pos+1,3)+abc[pos][3]);
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=1;j<=3;j++){
      cin>>abc[i][j];
    }
  }

  memset(dp,-1,sizeof(dp));
  cout<<vac(0,0)<<"\n";
  
  return 0;
}
  


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

using namespace std;

int a[200005];

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

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);

    bool ok = 1;

    for (int i = 1; i < n; i++) {
        if (a[i] == a[i - 1]) ok = 0;
    }

    if (ok) printf("YES\n");
    else printf("NO\n");
}


Measured memory_bytes: 4356
def main():
    a, b, c = map(int, input().split())
    x = b*c*((a-a//2)-a//2)
    y = a*c*((b-b//2)-b//2)
    z = a*b*((c-c//2)-c//2)
    print(min(x, y, z))

if __name__ == "__main__":
    main()

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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define endl "\n"
#define precise std::cout << std::fixed;std::cout << std::setprecision(6); 
#define zerobits(x) __builtin_ctzll(z)
#define F first
#define S second  
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

int binexpo(int x, int y, int p) {    
    int res = 1;     // Initialize result  
    x = x % p; // Update x if it is more than or  
                // equal to p  

    while (y > 0)  {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;
}
// --------------------------template ends here------------------------------

void solve() {
    int n;
    cin >> n;

    int sum = 0;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            for(int k=1;k<=n;k++) {
                sum += __gcd(i, __gcd(j, k));
            }
        }
    } 

    cout << sum;
    return;
}

int32_t main() {
    FO;
    solve();
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  for (int i = 0; i < s.size(); ++i) {
    if (i % n == 0) cout << s[i];
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d, need, i = 0, count = 0;
    d = Integer.parseInt(sc.next());
    need = Integer.parseInt(sc.next());
    while(true) {
      if(i * (d - 1) + 1 >= need) break;
      i++;
    }
    System.out.println(i);
  }
}


Measured memory_bytes: 23124
#include <stdio.h>

int main()
{
	char a[100], b[100], c[100];
	int i, j;
	scanf("%s %s %s", a, b, c);
	for(i=0; a[i]!='\0'; i++);
	for(j=0; b[j]!='\0'; j++);
	if(a[i-1]==b[0] && b[j-1]==c[0])
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

Measured memory_bytes: 128
from collections import deque

INF = float("inf")

H, W, K = map(int, input().split())
A = [list(input()) for _ in range(H)]

Si, Sj = (0, 0)
for i, a in enumerate(A):
    if "S" in a:
        Si, Sj = (i, a.index("S"))
        break

distance = INF

Q = deque([(0, Si, Sj)])
while Q:
    cnt, i, j = Q.popleft()

    distance = min(distance, i, j, H - i - 1, W - j - 1)

    if cnt >= K:
        continue

    for ni, nj in ((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1)):
        if 0 <= ni < H and 0 <= nj < W and A[ni][nj] == ".":
            A[ni][nj] = "#"
            Q.append((cnt + 1, ni, nj))

print(-(-distance // K) + 1)


Measured memory_bytes: 9204
import sys
input = sys.stdin.readline
import math
def print_ans(N, K, ar):
    """Test Case
    >>> print_ans(3, 1, [4, 1, 5])
    5
    >>> print_ans(8, 9, [7, 9, 3, 2, 3, 8, 4, 6])
    0
    >>> print_ans(3, 0, [1000000000, 1000000000, 1000000000])
    3000000000
    """
    if K >= len(ar):
        print(0)
    elif K == 0:
        print(sum(ar))
    else:
        ar = sorted(ar)
        print(sum(ar[:-K]))

if __name__ == '__main__':
    N, K = map(int, input().rstrip().split())
    ar = list(map(int,input().rstrip().split()))
    print_ans(N, K, ar)




Measured memory_bytes: 27300
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
    int p[100]={0};
  for(int i=1;i<=9;i++)
    for(int j=i;j<=9;j++)p[i*j]=1;
  if(p[n])puts("Yes");else puts("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std;

int a , b , c , n;
int ans;
void work () {
	int i , j;
	scanf ( "%d%d%d%d" , &a , &b , &c , &n );
	for ( i = 0 ; i <= n ; i++ ) {
		for ( j = 0 ; j <= n ; j++ ) {
			if ( i * a + j * b > n ) break;
			if ( (n-i*a-j*b) % c == 0 ) ans++;
		}
	}
	printf ( "%d\n" , ans );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 128
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = std::uint32_t;
using ll = std::int64_t;
using ull = std::uint64_t;
using ld = long double;

template<typename T, size_t H, size_t W>
using matrix = std::array<std::array<T, W>, H>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(all(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(all(c)); }

template<typename T>
inline void unique(T &c){ std::sort(c); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

vector<int> ds[200010];

int n;
int a[21];
double dp[21][200010];

int main()
{
	rep(i, 200010){
		for (int j = 1; j * j <= i; j++){
			if (i % j == 0){
				ds[i].pb(j);
				ds[i].pb(i / j);
			}
		}
	}

	cin >> n;
	loop(i, 1, n + 1) cin >> a[i];

	fill_n(*dp, 21 * 200010, 1e18);
	dp[0][1] = 0.0;
	loop(i, 1, n + 1) rep(j, 200010){
		double c = (double)abs(a[i] - j) / a[i];
		for (int d : ds[j]){
			chmin(dp[i][j], max(dp[i - 1][d], c));
		}
	}

	double res = 1e18;
	rep(i, 200010) chmin(res, dp[n][i]);
	printf("%.20lf\n", res);
}

Measured memory_bytes: 55808
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
const long long MOD = 1000000007;
typedef long long ll;

int n,k;
string s,t;
int a[100005];

int main() {
  cin >> s;
  int cnt=0;
  rep(i,3)if(s[i]=='A') cnt++;
  cout << (cnt==3 || cnt==0 ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N, M;

  cin >> N >> M;

  int a[N], b[N];
  int c[M], d[M];
  int point[N];

  for (int i=0;i<N;i++) {
    cin >> a[i] >> b[i];
  }

  for (int j=0;j<M;j++) {
    cin >> c[j] >> d[j];
  }

  for (int i=0;i<N;i++) {
    int min_id = M-1;
    int min = 1e+8;
    for (int j=M-1;j>=0;j--) {
      int manhattan_d = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (manhattan_d <= min) {
        min = manhattan_d;
        min_id = j;
      }
    }
    point[i] = min_id;
  }

  for (int i=0;i<N;i++) {
    cout << point[i]+1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 1e5 + 5;
int n, k;
int a[maxn][3];

void ReadInput()
{
    cin >> n >> k;
}

void Solve()
{
    for(int i = 0; i < n; ++i)
    {
        a[i][2] = k + 3 * n - i - 1;
        if(2 * i < n)
        {
            a[i][0] = k + n / 2 + i;
            a[i][1] = k + 2 * n - 1 - 2 * i;
        }
        else
        {
            int p = (2 * i - n) / 2;
            a[i][0] = k + p;
            a[i][1] = k + 2 * n - 2 - 2 * p;
        }
    }

    for(int i = 0; i < n; ++i)
        if(a[i][0] + a[i][1] > a[i][2])
        {
            cout << "-1\n";
            return;
        }

    for(int i = 0; i < n; ++i)
        cout << a[i][0] << ' ' << a[i][1] << ' ' << a[i][2] << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>N>>K;
    mat dp(N + 1, vec(K + 1, 0));
    dp[0][0] = 1;
    vec a(N + 1);
    rep(i,N) cin>>a[i + 1];
    reps(i,1,N + 1){
        rep(j, K + 1){
            dp[i][j] = dp[i-1][j];
            if(j >= a[i]) (dp[i][j] += (j == a[i] ? i : 1LL) * dp[i-1][j - a[i]])%=MOD;
            //cout<<dp[i][j]<<' ';
        }
        //cout<<endl;
    }
    ll ans = 0;
    reps(i,1,N + 1) (ans += ((MOD + dp[i][K] - dp[i-1][K])%MOD) * (N + 1 - i))%=MOD;
    cout<<ans<<endl;
}

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

int main(void) {
  ll N, X;
  cin >> N >> X;
  vector<ll> x(N);
  REP(i, 0, N) cin >> x[i];
  reverse(x.begin(), x.end());

  vector<ll> sum(N + 1);
  REP(i, 0, N) sum[i + 1] = sum[i] + x[i];

  ll ans = 1LL << 60;
  REP(k, 1, N + 1) {
    ll cost = k * X + N * X;
    for (ll i = 0; i * k < N; i++) {
      ll t = i + 1;
      ll l = k * i, r = min(l + k, N);
      if (t == 1) {
        cost += (sum[r] - sum[l]) * 5;
      } else {
        cost += (sum[r] - sum[l]) * (2 * t + 1);
      }
      if (cost > ans) break;
    }
    ans = min(ans, cost);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);

//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		int n = Integer.parseInt(st.nextToken());
	 		int m = Integer.parseInt(st.nextToken());
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		for(int j=0;j<n;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 		}
	 		Collections.sort(array);
	 		int sum = 0;
	 		for(int i = 0;i<m;i++){
	 			sum+= array.get(i);
	 		}
 		
 		out.println(sum);
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 26072
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd);
#endif
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    for(uint i = 0; i < s.size(); i++){
        if((i & 1) == 0){
            cout << s[i];
        }
    }
    return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll x, a, b;
  cin >> x;
  vector<ll> soinsu;
  for (ll i = 1; i < (ll)sqrt(x) + 1; i++) {
    if (x % i == 0) soinsu.push_back(i);
  }
  for (ll i = -1000; i < 1000;i++) {
    b = i;
    REP(j, soinsu.size()) { 
      ll s=soinsu.at(j);
      a = b + s;
      if(pow(a,5)-pow(b,5)==x){
        cout << a << " " << b << "\n";
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4172
//我是菜鸡
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1e2 + 5;
const ll MOD = 1e9 + 7;
const double ext = 1e-6;
void deprint() {
	//ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
	//ifstream cin("E:\\acm dream\\in.txt");
	//ofstream cout("E:\\acm dream\\out.txt");
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int a[3];
	while (cin >> a[0] >> a[1] >> a[2]) {
		sort(a, a + 3);
		if ((a[0] == a[1] && a[1] != a[2]) || (a[1] == a[2] && a[0] != a[1]))cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] Depth = new int[MAX];
    public static int[] Height = new int[MAX];
    public static Tree[] Node = new Tree[MAX];
    public static int n;

    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            Node[i] = new Tree(NIL, NIL, NIL);
        }
        int v, l, r;
        for (int i = 0; i < n; i++) {
            v = sc.nextInt();
            l = sc.nextInt();
            r = sc.nextInt();
            Node[v].left = l;
            Node[v].right = r;
            if(l != NIL) Node[l].parent = v;
            if(r != NIL) Node[r].parent = v;
        }

        int root = 0;
        for(int i = 0; i < n; i++) {
            if(Node[i].parent == NIL) root = i;
        }

        setDepth(root, 0);
        setHeight(root);
        // ??????
        for(int i = 0; i < n; i++) print(i);
    }

    public static void setDepth(int u, int d) {
        Depth[u] = d;
        if(Node[u].right != NIL) setDepth(Node[u].right, d + 1);
        if(Node[u].left != NIL) setDepth(Node[u].left, d + 1);
    }

    public static int setHeight(int u) {
        int h1 = 0, h2 = 0;
        if(Node[u].left != NIL) h1 = setHeight(Node[u].left) + 1;
        if(Node[u].right != NIL) h2 = setHeight(Node[u].right) + 1;
        return Height[u] = Math.max(h1, h2);
    }

    public static int degree(int u) {
        int deg = 0;
        if(Node[u].left != NIL) deg++;
        if(Node[u].right != NIL) deg++;
        return deg;
    }

    public static int sibling(int u) {
        if(Node[u].parent == NIL) return NIL;
        int p = Node[u].parent;
        if(Node[p].left == u) return Node[p].right;
        return Node[p].left;
    }

    public static void print(int u) {
        System.out.printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u, Node[u].parent, sibling(u), degree(u), Depth[u], Height[u]);
        if(Node[u].parent == NIL) System.out.print("root");
        else if(Node[u].left == NIL && Node[u].right == NIL) System.out.print("leaf");
        else System.out.print("internal node");
        System.out.println();
    }
}

class Tree {
    int parent;
    int left;
    int right;
    Tree(int p, int l, int r) {
        parent = p;
        left = l;
        right = r;
    }
}

Measured memory_bytes: 26492
#include <iostream>

using namespace std;

int main(){
	int N;
	int *T = NULL;
	int M;
	class Drink{
	public:
		int *P = NULL;
		int *X = NULL;
		int *sum = NULL;
	};

	Drink drink;

	cin >> N;

	T = new int[N];

	for(int i = 0; i < N; i++){
		cin >> T[i];
	}

	cin >> M;

	drink.P = new int[M];
	drink.X = new int[M];
	drink.sum = new int[M];

	for(int i = 0; i < M; i++){
		cin >> drink.P[i];
		cin >> drink.X[i];
		drink.sum[i] = 0;
	}

	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			if(drink.P[i] == j + 1){
				drink.sum[i] += drink.X[i];
			}else{
				drink.sum[i] += T[j];
			}
		}
		cout << drink.sum[i] << endl;
	}

	delete[] T;
	delete[] drink.P;
	delete[] drink.X;
	delete[] drink.sum;

	return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    bool isZero = false;
    for (int i = 0; i < N; i++) if (a[i] == 0) isZero = true;
    if (isZero) {
        cout << 0 << '\n';
        return 0;
    }

    ll prod = 1;
    ll MX = 1e+18;
    for (int i = 0; i < N; i++) {
        if (a[i] <= MX / prod) {
            prod *= a[i];
        }
        else {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << prod << '\n';
}


Measured memory_bytes: 4048
// Smit_mangukiya

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
int dp[102][5][2];
int n,k;
vector<int> v;

int solve(int id , int tot , int ok)
{
	if(tot > k) return 0;
	if(id == n) return (tot == k);
	
	int ans = dp[id][tot][ok];
	if(ans != -1)
		return ans;
		
	ans = 0;
	int l = 0;
	int r = 9;
	
	if(ok) r = v[id];
	
	for(int i=l ; i<=r ; i++)
	{
		if(ok && i == v[id])
		{
			ans += solve(id + 1 , tot + (i != 0) , 1);
		}
		else
			ans += solve(id + 1 , tot + (i != 0) , 0);
	}

	dp[id][tot][ok] = ans;
	return ans;
}
int32_t main(){
	fast;
	memset(dp , -1 , sizeof(dp));
	
	string s;
	cin >> s;
	
	 n = s.length();
	v.resize(n);
	
	f(i,0,n)    v[i] = s[i] - '0';
	
	cin >> k;
	
	cout << solve(0,0,1);
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner scanner;

	public static void main(String[] args) {

		scanner = new Scanner(System.in);

		int height = scanner.nextInt();
		int length = scanner.nextInt();	
		while(height < 1 );
		while(length > 100);

		int round = 2*height + 2*length;
		int area = length * height;

		System.out.println(area + " " + round);
	}
}



Measured memory_bytes: 26132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
void chmin(int &a, int b) {if(a > b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;

int n, A, B, C;
vi l;

int dfs(int i, int a, int b, int c){
    if(i == n){
        if(!a || !b || !c) return inf;
        return abs(A-a)+abs(B-b)+abs(C-c);
    }

    int p1 = dfs(i+1, a+l[i], b, c) + (a? 10:0);
    int p2 = dfs(i+1, a, b+l[i], c) + (b? 10:0);
    int p3 = dfs(i+1, a, b, c+l[i]) + (c? 10:0);
    int p4 = dfs(i+1, a, b, c);

    return min(p1, min(p2, min(p3, p4)));
}


int main(){
    cin >> n >> A >> B >> C;
    l.resize(n);
    rep(i,0,n){cin >> l[i];}
    cout << dfs(0,0,0,0);
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <conio.h>

char a[10],b[10],c[10];
char x,y,z;

int main(){
	scanf("%s %s %s",&a,&b,&c);
	x=a[0]-32;
	y=b[0]-32;
	z=c[0]-32;
	printf("%c%c%c",x,y,z);
	//getch();
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static char[][] f;;

	public static void main(String[] arg) {
		int M = sc.nextInt();
		int N = sc.nextInt();
		f = new char[M][N];
		for (int i = 0; i < M; ++i) {
			f[i] = sc.next().toCharArray();
		}
		int[][] r = new int[26][2];
		int[][] c = new int[26][2];
		for (int i = 0; i < 26; ++i) {
			r[i][0] = r[i][1] = c[i][0] = c[i][1] = -1;
		}
		boolean[] used = new boolean[26];
		Arrays.fill(used, true);
		for (int i = 0; i < M; ++i) {
			for (int j = 0; j < N; ++j) {
				if (f[i][j] == '.') continue;
				int ch = f[i][j] - 'A';
				used[ch] = false;
				if (r[ch][0] >= 0) {
					r[ch][1] = i;
					c[ch][1] = j;
				} else {
					r[ch][0] = i;
					c[ch][0] = j;
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < 26; ++i) {
			for (int j = 0; j < 26; ++j) {
				if (used[j]) continue;
				if (remove(r[j][0], c[j][0], r[j][1], c[j][1])) {
					ans += 2;
					used[j] = true;
					f[r[j][0]][c[j][0]] = '.';
					f[r[j][1]][c[j][1]] = '.';
				}
			}
		}
		System.out.println(ans);
	}

	static boolean remove(int r1, int c1, int r2, int c2) {
		if (r1 == r2) {
			if (Math.abs(c1 - c2) <= 1) return false;
			for (int i = Math.min(c1, c2) + 1; i < Math.max(c1, c2); ++i) {
				if (f[r1][i] != '.') return false;
			}
			return true;
		} else if (c1 == c2) {
			if (Math.abs(r1 - r2) <= 1) return false;
			for (int i = Math.min(r1, r2) + 1; i < Math.max(r1, r2); ++i) {
				if (f[i][c1] != '.') return false;
			}
			return true;
		} else {
			if (r1 > r2) {
				int tmp = r1;
				r1 = r2;
				r2 = tmp;
				tmp = c1;
				c1 = c2;
				c2 = tmp;
			}
			{
				boolean ok = true;
				for (int i = r1 + 1; i <= r2; ++i) {
					if (f[i][c1] != '.') {
						ok = false;
						break;
					}
				}
				int move = c1 < c2 ? 1 : -1;
				for (int i = c1; i != c2; i += move) {
					if (f[r2][i] != '.') {
						ok = false;
						break;
					}
				}
				if (ok) return true;
			}
			{
				boolean ok = true;
				for (int i = r2 - 1; i >= r1; --i) {
					if (f[i][c2] != '.') {
						ok = false;
						break;
					}
				}
				int move = c1 < c2 ? -1 : 1;
				for (int i = c2; i != c1; i += move) {
					if (f[r1][i] != '.') {
						ok = false;
						break;
					}
				}
				if (ok) return true;
			}
			return false;
		}
	}
}

Measured memory_bytes: 25160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  //cout << A << B << C << X << endl;
  int a;
  int count = 0;
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B;j++){
      for(int k = 0; k <= C;k++){
        if(X  == ((500 * i) + (100 * j) + (50 * k))){
         count++;
        }
      // cout << "i:" << i << ", j:" << j << ", k:" << k << endl;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#pragma warning(disable : 4996)
int n, a[101];
const char c[11][8] = { "0000000", "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111" };
int main() {
	a[0] = -1;
	while (true) {
		scanf("%d", &n);
		if (n == -1) break;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			for (int j = 0; j < 7; j++) {
				if (c[a[i - 1] + 1][j] != c[a[i] + 1][j]) {
					printf("1");
				}
				else {
					printf("0");
				}
			}
			printf("\n");
		}
	}
	return 0;
}

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

#define ld          long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t)       scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii         cout << "hii" << endl
#define okay        cout << "okay" << endl
#define hey         cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int inf = 1e18;
const int mod = 1e9+7;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int N = 2e5+5;
int arr[N];

void solve()
{
    int n;
    cin >> n;

    rep(i, 1, n+1){
        cin >> arr[i];
    }
    mi mp;
    int ans = 0;
    rep(i, 1, n+1){
        int curr = i-arr[i];
        ans += mp[curr];
        mp[i+arr[i]]++;
    }

    cout << ans << endl;
}                                   

int32_t main(){
    fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }
    starboy1299();
}

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

int func(int x){
    if(x<10) return x;
    return x%10 + func(x/10);
}

int main(){
    int N;
    cin >> N;
    
    if(N%func(N)==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map> 
#include<vector>
#include<queue>
#include<set>
//#include<bits/stdc++.h>
#include<deque> 
#include<bitset>
#include<string>
#define N 40
#define K 300005
#define MOD 1e9+7
#define int long long 
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
//these are prefic kind of stuff..




int32_t main(){
	string s;
	cin>>s;
	int a = 0,b = 0;
	for(int i=0;i<s.length();i++){
		if(s[i] == 'A')
			a++;
		else
			b++;
	}
	if(a >0 && b >0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		
	
	
	
	
	
	
			
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let (n, t) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut ct = Vec::new();
    for _ in 0..n {
        let i = read::<usize>();
        ct.push((i[0], i[1]));
    }

    let ans = ct.iter()
        .filter(|x| x.1 <= t)
        .map(|x| x.0)
        .min();

    match ans {
        Some(x) => println!("{}", x),
        None => println!("TLE"),
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    A.insert(A.begin(), 0);
    A.push_back(0);
    ll all = 0;
    for (ll i = 1; i <= N + 1; i++) {
        all += abs(A[i] - A[i - 1]);
    }

    for (ll i = 1; i <= N; i++) {
        ll d1 = A[i] - A[i - 1];
        ll d2 = A[i + 1] - A[i];
        if (d1 * d2 >= 0) {
            cout << all << endl;
        } else {
            cout << all - abs(d1) - abs(d2) + abs(d1 + d2) << endl;
        }
    }
}

Measured memory_bytes: 2032
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}



int main(){
    int d;
    cin >> d;
    ll ans=0;
    int c[26]; // 満足度の下がりやすさ、（d-最終日）* cだけその日の終わりに引かれる。
    int last[26] = {0};
    int s[365][26]; // d日目にタイプiのコンテストを開いた時の上昇量
    rep(i, 26) cin >> c[i];
    rep(i,d) rep(j,26) cin >> s[i][j];

    int day=1;
    int t;
    rep(i,d){
        cin >> t;
        t--;
        ans += s[i][t];
        last[t] = day;
        rep(j,26){
            ans -= c[j] * (day - last[j]);
        }
        day++;
        cout << ans << endl;
    }
}



Measured memory_bytes: 3676
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long max = 1L << n;
		StringBuilder sb = new StringBuilder();
		for (long i = 0; i < max; i++) {
		    if (!check(i, k)) {
		        continue;
		    }
		    sb.append(i).append(":");
		    long x = i;
		    for (int j = 0; j <= 18 && x > 0; j++) {
		        if (x % 2 == 1) {
		            sb.append(" ").append(j);
		        }
		        x >>= 1;
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
	
	static boolean check(long x, int count) {
	    long cnt = 0;
	    while (x > 0) {
	        cnt += x % 2;
	        x >>= 1;
	    }
	    return cnt == count;
	}
}



Measured memory_bytes: 44896
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N, K;
	cin >> N >> K;
	int A;
	for (int i = 0; i < N; ++i) {
		cin >> A;
	}
	int ans;
	for (int i = 1; i < N; ++i) {
		if (N <= (i - 1)*(K - 1) + K) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
 int a[100006];
 int main()
 {
     int n,x,y,i,j;
     cin>>n;
         for(i=4;i<=100005;i=i+2)
    {
        a[i]=1;
    }
    for(i=3;i*i<=100005;i=i+2)
    {
        if(a[i]==0)
        {
            for(j=i*i;j<=100005;j+=i*2)
            {
                a[j]=1;
            }
        }

    }
    for(i=n;i<=100005;i++)
    {
      if(a[i]==0)
      {
        cout<<i<<endl;
        return 0;
      }
    }
 }

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

int main() {
	int n;
	cin >> n;
	map<int,int> m;
	for(int i=0;i<n;i++)
	{
		int a;
		cin >> a;
		m[a]++;
	}
	int k = 0;
	for(auto i=m.begin();i!=m.end();i++)
	{
		if(i->second % 2 == 1)
		{
			k++;
		}
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 4864