akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

#define mp make_pair
#define fi first
#define se second
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) (((a) * (b)) / (__gcd((a), (b))))
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define setbits(x) __builtin_popcountll(x)
#define unsetend(x) __builtin_ctzll(x)
#define unsetfront(x) __builtin_clzll(x)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define ll long long
#define endl "\n"
#define Endl "\n"

// long long expo(long long a, long long b, long long mod)
// {
//     ll ret = 1;
//     while (b > 0)
//     {
//         if (b % 2 == 1)
//             ret = (((ret)%mod) * ((a)%mod))%mod;
//
//         a = ((a)%mod) * ((a)%mod)%mod;
//         b = b / 2;
//     }
//     return (ret%mod);
// }

// vector<long long> seive()
// {
//    long long i,j;
//    vector<long long> hash(1000001,1);
//    vector<long long> primes;
//
//    for(i=2;i*i<=1000000;i++)
//    {
//        if(hash[i])
//        {
//            for(j=i*i;j<=1000000;j+=i)
//            hash[j]=0;
//        }
//    }
//    for(i=2;i<1000001;i++)
//    {
//        if(hash[i])
//        primes.pb(i);
//    }
//    return primes;
// }

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

    ll n, ded, cost, i, k, sum;
    cin >> n >> sum;
    vector<pair<ll, ll>> arr(n + 1);

    for (i = 1; i <= n; i++) // first = weight , second = value
    {
        cin >> arr[i].first >> arr[i].second;
    }
    sort(arr.begin() + 1, arr.end());
    // for (i = 1; i <= n; i++)
    //     cout << arr[i].first << " " << arr[i].second << endl;

    ll dp[n + 1][sum + 1];
    for (i = 0; i <= n; i++)
    {
        for (k = 0; k <= sum; k++)
            dp[i][k] = 0;
    }
    dp[0][0] = 0;

    ll op1, op2;
    for (i = 1; i <= n; i++)
    {
        for (k = 1; k <= sum; k++)
        {
            if (i == 1)
            {
                if (k - arr[i].first >= 0)
                    op1 = arr[i].second;
                else
                    op1 = 0;
                op2 = 0;
            }

            else
            {
                if (k - arr[i].first >= 0)
                    op1 = arr[i].second + dp[i - 1][k - arr[i].first];
                else
                    op1 = 0;
                op2 = dp[i - 1][k];
            }
            dp[i][k] = max(dp[i][k], max(op1, op2));
        }
    }
    cout << dp[n][sum];
    // for (i = 1; i <= n; i++)
    // {
    //     for (k = 1; k <= sum; k++)
    //         cout << dp[i][k] << " ";
    //     cout << endl;
    // }
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;
    char prec = s[0];
    for (int i=1; i<n; i++) {
        if (prec != s[i]) ans++;
        prec = s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
require 'prime'

N, K = gets.chomp.split.map(&:to_i)

A = gets.chomp.split.map(&:to_i)

gcd = A.inject(:gcd)
max = A.max

if K % gcd == 0 && K <= max
  puts 'POSSIBLE'
else
  puts 'IMPOSSIBLE'
end



Measured memory_bytes: 10012
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const int MAX_P = 1e6 + 5;
int sieve [MAX_P];
vector<int> smallp;

vector<int> factorcs (ll x) {
  vector<int> ans;
  for (int p : smallp) {
    if (x % p == 0) {
      int cnt = 0;
      while (x % p == 0) {
        cnt++;
        x /= p;
      }
      ans.push_back(cnt);
    }
  }
  if (x != 1) {
    ans.push_back(1);
  }
  return ans;
}

int main () {
  for (int i = 2; i < MAX_P; i++) {
    if (!sieve[i]) {
      smallp.push_back(i);
      for (int j = i; j < MAX_P; j += i) {
        sieve[j] = 1;
      }
    }
  }

  ll n;
  cin >> n;

  auto fs = factorcs(n);
  int ans = 0;
  for (int k : fs) {
    for (int i = 1; true; i++) {
      if (k < i) break;
      k -= i;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7652
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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 int INF = 100000; 

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

    if(b - a == c - b) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> ks(k, 0);
    for (int i = 0; i < n; ++i) {
        ks[i % k]++;
    }
    sort(ks.begin(), ks.end());
    cout << abs(ks.front() - ks.back()) << endl;
    return 0;
}


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

typedef long long ll;
const ll mod = 1e8+7;

ll mod_pow(ll x,ll n){
  ll res=1;
  while(n){
    if(n%2) res=res*x%mod;
    x=x*x%mod;
    n/=2;
  }
  return res;
}

ll divi(ll a,ll b){
  return a * mod_pow(b,mod-2) % mod;
}

ll factorial(int i){
  static vector<ll> k(1e6);
  if(!k[0]){k[0]=1;for(int i=1;i<(int)k.size();i++)k[i]=i*k[i-1]%mod;}
  return k[i];
}

ll nCr(ll n,ll r){
  ll a = mod_pow( factorial(r) * factorial(n-r) % mod ,mod-2);
  return factorial(n) * a % mod;
}

typedef pair<int,int> P;

int h, w, sy, sx, ty, tx;

P cal(int y, int x){
  
  int Y = abs(y - sy);
  int X = abs(x - sx);
  
  return P( Y + X, nCr( Y + X, X ));
}

void solve(){
  
  map<int,int> ans;

  for(int i=-1;i<=1;i++){
    
    for(int j=-1;j<=1;j++){
      
      P tmp = cal( ty + i * h, tx + j * w );

      ans[tmp.first] += tmp.second;
      
      ans[tmp.first] %= mod;
    }
    
  }
  
  auto p = ans.begin();
  
  cout<<(*p).second<<endl;
}

signed main(){
  
  cin>>h>>w;
  
  cin>>sy>>sx>>ty>>tx;
  
  solve();  
  
  return 0;
}



Measured memory_bytes: 10760
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,i,j,m,sum=0;
  cin>>k;
  for(i=1;i<=k;i++)
  {
    for(j=1;j<=k;j++)
    {
      for(m=1;m<=k;m++)
      {
        int a=__gcd(j,m);
        int b=__gcd(a,i);
        sum+=b;
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#include<map>
#define MEM(var,val) memset(var,(val),sizeof(var))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define nitro   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define inf 10000000000
ll dp[101][100001];
bool vis[101][100001];
ll wajan[101],val[101];
ll n;

ll rec(ll i,ll v)
{
    if(v<=0)
    return 0;
    if(i>n)
    return inf;

   if(vis[i][v])
    return dp[i][v];
    vis[i][v]=1;
    dp[i][v]=rec(i+1,v);
    if(v>=val[i])
    dp[i][v]=MIN(dp[i][v],wajan[i]+rec(i+1,v-val[i]));
   return dp[i][v];
}
int main()
{
    ll w;
    cin>>n>>w;
    for(int i=1;i<=n;i++)
        cin>>wajan[i]>>val[i];
        //minimum weight required to buy items worth value v is denoted by rec(i,v);
       ll i;
       for(i=100000;i>=0;i--)
        if(rec(1,i)<=w)
       {cout<<i;return 0;}

}


Measured memory_bytes: 91168
#include <iostream>
#include <cmath>

int main() {
  int A, B, C, K;
  std::cin >> A >> B >> C >> K;

  int m = std::max(A, std::max(B, C));

  std::cout << A + B + C + 2 * std::pow(2, K-1) * m - m << std::endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define int long long
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    for (int i = 0; i < v.size(); ++i)
      os << v[i] << " ";
    os << '\n';
  }
  return os;
}
#define mod 998244353
int bit[200005];
void add(int idx, int val) {
    while(idx < 200005)
        bit[idx] = (bit[idx] + val)%mod, idx+=(idx&-idx);
}
void range_add(int l, int r, int val) {
    add(l, val);
    add(r + 1, -val);
}
int point_query(int idx) {
    int ret = 0;
    while(idx)
        ret = (ret + bit[idx])%mod, idx-=(idx&-idx);
    return ret;
}
signed main() {
    int n, k;
    cin >> n >> k;
    int arr[k][2];
    int i;
    for(i=0;i<k;i++)
        cin >> arr[i][0] >> arr[i][1];
    int dp[n+1] = {0};
    dp[1] = 1;
    for(i=1;i<n;i++)
    {
        for(int j = 0; j < k ; j++)
            range_add(i+arr[j][0], i+arr[j][1], dp[i]);
        dp[i+1] = point_query(i+1);
    }
    dp[n] = (dp[n] + mod)%mod;
    cout << dp[n];
}

Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char b;
  cin >> b;
  if (b == 'A'){
    cout << 'T' << endl;
  } else if (b == 'T'){
    cout << 'A' << endl;
  } else if (b == 'G'){
    cout << 'C' << endl;
  } else if (b == 'C'){
    cout << 'G' << endl;
  } 
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
A = [int(i) for i in input().split()]
p = deque()
m = deque()

A.sort(reverse=True)
for i in A:
    if i > 0:
        p.append(i)
    else:
        m.append(i)

ans = []
for _ in range(N-2):
    if p and m:
        if len(p) < len(m):
            tt = p.popleft()
            zz = m.pop()
            p.appendleft(tt-zz)
            ans.append([tt,zz])
        else:
            tt = m.pop()
            zz = p.popleft()
            m.append(tt-zz)
            ans.append([tt,zz])
    elif p:
        tt = p.pop()
        zz = p.popleft()
        m.append(tt-zz)
        ans.append([tt,zz])

    else:
        tt = m.popleft()
        zz = m.pop()
        p.append(tt-zz)
        ans.append([tt,zz])

if p and m:
    tt = p.pop()
    zz = m.pop()
    ans.append([tt,zz])
    print(tt-zz)

elif p:
    tt = p.popleft()
    zz = p.pop()
    ans.append([tt,zz])
    print(tt-zz)

else:
    tt = m.popleft()
    zz = m.pop()
    ans.append([tt,zz])
    print(tt-zz)

for i in range(N-1):
    tt,zz = ans[i]
    print(tt,zz)


Measured memory_bytes: 72476
#include<ctype.h>
#include<stdio.h>
int main(void){
  char s[10],t[10],u[10];
  scanf("%s %s %s",s,t,u);
  printf("%c%c%c\n",toupper(s[0]),toupper(t[0]),toupper(u[0]));
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main() {
	while (true) {
		int referee;
		std::cin >> referee;
		if (referee == 0) {
			break;
		}

		int max, min;
		std::cin >> max >> min;
		if (max < min) {
			std::swap(min, max);
		}
		int total = 0;
		for (int i = 2; i < referee; ++i) {
			int score;
			std::cin >> score;
			if (max < score) {
				total += max;
				max = score;
			} else if (min > score) {
				total += min;
				min = score;
			} else {
				total += score;
			}
		}
		std::cout << (total / (referee - 2)) << std::endl;
	}
}

Measured memory_bytes: 3048
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var date = new string[] { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };

        var today = ReadLine();

        var ans = 7 - Array.IndexOf(date, today);

        WriteLine(ans);
    }
}


Measured memory_bytes: 25852
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;

ll mod(ll x,ll m){
  return (m+x%m)%m;
}

void extgcd(ll a,ll b,ll &x,ll &y){
  x=1,y=0;
  if(b!=0)extgcd(b,a% b,y,x),y-=(a/b)*x; 
}

ll mod_inv(ll a,ll m){
  ll x,y;
  extgcd(a,m,x,y);
  return mod(x,m);
}

ll m1=999979,m2=999983;

ll calc(ll x,int o,ll y){
  ll a=0,b=0,p,q;

  if(o==1)a=mod(x+y,m1),b=mod(x+y,m2);
  if(o==2)a=mod(x-y,m1),b=mod(x-y,m2);
  if(o==3)a=mod(x*y,m1),b=mod(x*y,m2);
  if(o==4)a=mod(x*mod_inv(y,m1),m1),b=mod(x*mod_inv(y,m2),m2);
  
  extgcd(m1,m2,p,q);
  
  return (b*m1*p+a*m2*q)%(m1*m2);
}

int main(void){
  ll n,o,x=0,y;

  cin >> n;

  while(n--){
    cin >> o >> y;
    x=calc(x,o,y);
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 1156
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s,t string
    fmt.Scan(&s,&t)
    ans := "No"
    for i:=0; i<len(s); i++{
        u := s[i:] + s[:i]
        if t == u{
            ans = "Yes"
        }
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


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

int main()
{
	int h,w;
	cin >> h >> w;
	vector<string> m(h);
	for(int i = 0;i<h;i++)cin >> m[i];
	m.insert(m.begin()+0,string(w,'.'));
	m.push_back(string(w,'.'));
	for(int i = 0;i<h+2;i++)
	{
		m[i].insert(m[i].begin(),'.');
		m[i].push_back('.');
	}
	for(int i = 1;i<h+1;i++)
	{
		for(int j = 1;j<w+1;j++)
		{
			if(m[i][j]=='#'&&m[i][j-1]=='.'&&m[i][j+1]=='.'
			&&m[i+1][j]=='.'&&m[i-1][j]=='.')
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

#define forn(i, a, b) for (int i = a; i <= b; ++i)

using namespace std;

const int N = (int)2e5 + 1;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

string s, t;
int main (){
  cin >> s >> t;
  int ok = 0;
  string cur = s;
  if (s == t){
    cout << "Yes\n";
    return 0;
  }
  int timer = 0;
  while (1){
    if (timer == cur.size()){
      break;
    }
    string s2;
    s2 += s[s.size() - 1];
    forn (i, 0, s.size() - 2){
      s2 += s[i];
    }
    timer++;
    if (s2 == t){
      ok = 1;
      break;
    }
    s = s2;
  }
  if (ok){
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
import heapq
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
heapq.heapify(a)
ans=0
cnt=0
x=0
while len(a)>0:
    d=heapq.heappop(a)
    #print(d)
    if cnt!=d:
        cnt=d
        ans+=1
        x=1
    elif cnt==d and x%2==1:
        ans-=1
        x+=1
    elif cnt==d and x%2==0:
        ans+=1
        x+=1
print(ans)

Measured memory_bytes: 7116
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>

#define debug(x) cout << #x << "==" << x << endl;

const int INF = 1e+9 + 7;

using namespace std;

//入力
#define MAX_N 100000
string S;

vector<string> strs = {"dream", "dreamer", "erase", "eraser"};

void cut_string(string &s) {

  for(string str : strs) {
    if( str.length() <= s.length() ) {
      if ( S.substr( s.length() - str.length() ) == str ) {
        s = s.substr(0, s.length() - str.length());
        return;
      }
    }
  }

  s = "-1";

}

int main() {
  ios::sync_with_stdio(false);

  cin >> S;

  while(S != "" && S != "-1") {
    cut_string(S);
  }

  if(S == "") {
    cout << "YES" << endl;
  }
  if(S == "-1") {
    cout << "NO" << endl;
  }


  return 0;
}


Measured memory_bytes: 512
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include<cstring>
//#include<cstdio>
//#include<stdio.h>
//#include<cmath>
//#include<math.h>
//#include<vector>
//#include<set>
//#include<queue>
//#include<map>
//#include<sstream>
//#include<iomanip>
//#define forn(i,n) for(int (i)=0;i<(n);i++)
//#define pb push_back
//#define mp make_pair
//using namespace std;
//typedef pair<int,int>pii;
//typedef long long ll;
//typedef pair<ll,ll> pll;
//const int MAXN=100005;
//const int INF=2147483647;
//const ll LINF=9223372036854775807;
//const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
//string s="1";
//int n; 
//int main()
//{
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cin>>n;
//	while(--n)
//	{
////		cout<<s<<endl;
//		int x=s.size()-1;
//		while(x>0&&(s[x]==s[x-1]+1||(s[x-1]=='9'&&s[x]=='9')))x--;
//		if(s[x]=='9')
//		{
//			int y=s.size();
//			s="1";
//			while(y--)s+='0';
//		}
//		else
//		{
//			s[x]++;
//			for(int i=x+1;i<s.size();i++)
//			{
//				s[i]=s[i-1]-1;
//				if(s[i]<'0')s[i]='0';
//			}
//		}
//	}
//	cout<<s<<endl;
//	return 0;
//}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>vec;
void dfs(int i,ll x)
{
	vec.push_back(x);
	if(i>=9)return;
	if(x%10!=0)dfs(i+1ll,x*10ll+x%10ll-1ll);
	dfs(i+1,x*10+x%10);
	if(x%10!=9)dfs(i+1ll,x*10ll+x%10ll+1ll);
}
int main()
{
	int n;
	cin>>n;
	for(ll i=1ll;i<=9ll;i++)dfs(0,i);
	sort(vec.begin(),vec.end());
	cout<<vec[n-1];
	return 0;
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        String[] str = br.readLine().split(" ");
        String s = br.readLine();

        if (s.length() == 2) {
            if(s.charAt(0) == s.charAt(1))
                System.out.println("1 2");
            else
                System.out.println("-1 -1");
            System.exit(0);
        }

        HashSet set;
        for (int i = 0; i < s.length() - 2; i++) {
            set = new HashSet();
            set.add(s.charAt(i));
            set.add(s.charAt(i+1));
            set.add(s.charAt(i+2));

            if(set.size() != 3){
                System.out.println((i+1) + " " +(i+3));
                System.exit(0);
            }
        }

        System.out.println("-1 -1");
    }

}


Measured memory_bytes: 39124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++) cin>>h[i];
    int dp[n];
    dp[0] = 0;
    for(int i=1;i<=k and i<n;i++)
        dp[i] = abs(h[i]-h[0]);
    for(int i=k+1;i<n;i++){
        int ans = INT_MAX;
        for(int j=i-k;j<i;j++)
            ans = min(ans, dp[j]+abs(h[i]-h[j]));
        dp[i] = ans;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 4392
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int MAX_PRIME = 100000;


int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;

void erats(){
	// primeツδ環スツトツづーツ渉可甘コツ可サ
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;

		// ツづ督づゥツつ「ツづ可つゥツつッツづゥ
		for(int j = 2*i; j <= MAX_PRIME; j+=i)
			isPrime[j] = false;
	}
}


int main(){

    erats();
    int n;
    while(cin>>n&&n!=0){
        int cnt=0;
        for(int i = 0; i < MAX_PRIME; i++){
            int a=prime[i];
            int b=n-prime[i];
            if(n-prime[i]<prime[i])
                break;
            if(isPrime[a]&&isPrime[b])
                cnt++;
        }
        cout<<cnt<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <queue>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,h,w;
  int a[LIMIT2]={0};
  ll now[2],dst[2];
  string s[1010];
  deque<pair<ll,P> > que;
  ll dist[1010][1010];
  
  cin >> h >> w;
  cin >> now[0] >> now[1];
  now[0]--;now[1]--;
  cin >> dst[0] >> dst[1];
  dst[0]--;dst[1]--;
  rep(i,h){
    cin >> s[i];
  }
  rep(i,h){
    rep(j,w){
      if(i==now[0] && j==now[1]){
        dist[i][j]=0;
      }else dist[i][j]=1LL<<60;
    }
  }
  que.push_front({0,{now[0],now[1]}});
  while(!que.empty()){
    auto p = que.front();
    que.pop_front();
    auto d = p.first;
    auto x = p.second.first;
    auto y = p.second.second;
    for(j=max(0,x-2);j<=min(h-1,x+2);j++){
      for(k=max(0,y-2);k<=min(w-1,y+2);k++){
        if(s[j][k]=='#' || (j==x&&k==y)) continue;
        else if(dist[j][k]<=d) continue;
        if(llabs(j-x)+llabs(k-y)<=1){//歩いて移動
          dist[j][k] = d;
          que.push_front({d,{j,k}});//01BFS
        }else{
          dist[j][k] = d+1;
          que.push_back({d+1,{j,k}});
        }
      }
    }
  }
  result = dist[dst[0]][dst[1]];
  cout << (result==1LL<<60 ? -1 : result) << endl;
  return 0;
}

Measured memory_bytes: 14344
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#define ll long long
using namespace std;
 
const int N=300005;
const int inf=1000000000;
 
struct seg{
	int x,id;
	seg(){}
	seg(int x,int id):x(x),id(id){}
	friend bool operator<(seg a,seg b){
		if (a.x!=b.x) return a.x<b.x;
		return a.id<b.id;
	}
};
struct node{
	int l,r;
	node(){}
	node(int l,int r):l(l),r(r){}
}a[N];
int n,l,r,now,cnt,l1,l2,r1,r2,d1,d2,nx1,nx2,fir;
ll ans,sum;
bool vis[N];
multiset<seg> s1,s2;
multiset<seg>::iterator it;
 
ll solve(){
	int i;ll sum=0;
	s1.clear(); s2.clear();
	for (i=1;i<=n;i++){
		s1.insert(seg(a[i].r,i));
		s2.insert(seg(-a[i].l,i));
		vis[i]=0;
	}
	for (i=1;i<=n;i++){
		if ((i&1)!=(fir&1)){
			it=s1.begin();
			while (vis[(*it).id]){
				s1.erase(s1.find(*it));
				it=s1.begin();
			}
			vis[(*it).id]=1;
			l=a[(*it).id].l; r=a[(*it).id].r;
			if (now<l) sum+=1ll*abs(l-now),now=l;
			if (now>r) sum+=1ll*abs(now-r),now=r;
			s1.erase(it);
		}
		else{
			it=s2.begin();
			while (vis[(*it).id]){
				s2.erase(s2.find(*it));
				it=s2.begin();
			}
			vis[(*it).id]=1;
			l=a[(*it).id].l; r=a[(*it).id].r;
			if (now<l) sum+=1ll*abs(l-now),now=l;
			if (now>r) sum+=1ll*abs(now-r),now=r;
			s2.erase(it);
		}
	}
	sum+=1ll*abs(now);
	return sum;
}

int main(){
	int i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++){
		scanf("%d%d",&l,&r);
		a[i]=node(l,r);
	}
	fir=0; now=0;
	ans=solve();
	fir=1; now=0;
	ans=max(ans,solve());
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12160
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <random>
using namespace std;
typedef pair<int,int> ii;
const int INF=1000000005;
int n;
vector<ii> range;
multiset<int> mina,maxa,minb,maxb;
int main(){
    scanf("%d",&n);
    int a,b;
    int ans=0;
    for (int x=0;x<n;x++){
        scanf("%d%d",&a,&b);
        range.push_back(ii(a,b));
        mina.insert(a);
        maxa.insert(b);
    }

    for (vector<ii>::iterator it=range.begin();it!=range.end();it++){
        mina.erase(mina.find((*it).first));
        maxa.erase(maxa.find((*it).second));
        ans=max(ans,(*it).second-(*it).first+1+max(0,*maxa.begin()-*mina.rbegin()+1));
        mina.insert((*it).first);
        maxa.insert((*it).second);
    }

    sort(range.begin(),range.end(),[](ii i,ii j){
        return i.first+i.second<j.first+j.second;
    });

    while (range.size()!=1){
        minb.insert(range.back().first);
        maxb.insert(range.back().second);
        mina.erase(mina.find(range.back().first));
        maxa.erase(maxa.find(range.back().second));
        range.pop_back();
        ans=max(ans,max(0,*maxa.begin()-*mina.rbegin()+1)+max(0,*maxb.begin()-*minb.rbegin()+1));
    }

    printf("%d\n",ans);
}


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

long long N;
long long A[100005];
long long D[100005];
long long num;

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		cin >> A[i];
		num += A[i];
	}
	long long tmp = (N) * (N + 1) / 2;
	if(num % tmp != 0){
		cout << "NO" << endl;
		return 0;
	}
	num /= tmp;

	for(long long i = 0; i < N; i++){
		D[i] = A[(i + 1) %N] - A[i];
		D[i] -= num;
		D[i] = -1 * D[i];
	}

	long long cur = 0;
	for(long long i = 0; i < N; i++){
		if(D[i] < 0 || D[i] % N != 0){
			cout << "NO" << endl;
			return 0;
		}
		cur += D[i] / N;
	}
	if(cur == num){
		cout << "YES" << endl;
		return 0;
	}
	return 1;
}


Measured memory_bytes: 1792
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

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

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


#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  vector<int> t(n + 2, 0);
  vector<double> v(n + 2, 0);
  int sum = 0;
  REP(i, n) {
    cin >> t[i + 1];
    sum += t[i + 1];
    t[i + 1] += t[i];
  }
  t[n + 1] = sum;
  REP(i, n) { cin >> v[i + 1]; }

  vector<double> ans(2 * sum + 1, 0.0);
  FOR(j, 1, 2 * sum + 1) {
    double tmp = 2 * sum;
    double time = (double)j / 2;

    FOR(i, 1, n + 1) {
      if (time < t[i - 1]) {
        chmin(tmp, t[i - 1] - time + v[i]);
        // cout << "top: " MM t[i - 1] - time + v[i] << endl;

      } else if (t[i] < time) {
        chmin(tmp, time - t[i] + v[i]);
        // cout << "middle: " MM time - t[i] + v[i] << endl;
      } else {
        chmin(tmp, v[i]);
        // cout << "bottom: " MM v[i] << endl;
      }
    }
    chmin(tmp, time);
    chmin(tmp, sum - time);
    ans[j] = tmp;
    // cout << time MM ans[j] << endl;
  }

  double val = 0;
  FOR(i, 1, 2 * sum + 1) { val += (ans[i] + ans[i - 1]) / 4; }
  coutd(5) << val << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int n, k, q, tmp, a[100001]; 
  cin >> n >> k >> q;
  for(int i=1; i<=n; i++)a[i] = 0;
  for(int i=0; i<q; i++){
    cin >> tmp;
    a[tmp] += 1;
  }
  for(int i=1; i<=n; i++){
    cout << (k-q+a[i] > 0?"Yes":"No") << endl;
  }
  return 0;
}
    
    
  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;

int countDivisibles(int A, int B, int M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 







signed main(){
    int t=1;
    // cin>>t;
    while(t--){
        string s;
        cin>>s;
        if(s=="ARC")
            cout<<"ABC\n";
        else cout<<"ARC\n";
    }
    return 0;
}

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

int main() {
  int long long a,b,n,ans;
  n=0;
  cin >> a>>b;
  ans = max(a,b);
 vector<int> X(min(a,b));
 for(int i=1;i<min(a,b)+1;i++){
   if(min(a,b) % i==0){
     X.at(n) =i;
     //cout <<X.at(n);
     n++;
   }
 }
    for(int i=0;i<a*b;i++){
     if((ans%a == 0) && (ans%b == 0)){
         cout <<ans;
         break;
      }
       else {
         ans =max(a,b)*X.at(i);
                   }
     }

  
}



Measured memory_bytes: 640
import numpy as np
N = int(input())
proof_list=np.array([[None]*N for i in range(N)])
check_list=[True]*N
for i in range(N):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        proof_list[i][x-1] = y
ans = 0
for i in range(2**N):
    honests = []
    for j in range(N):
        if((i>>j)&1):
            honests.append(j)
    flag = True
    for l in honests:
        for k in range(N):
            if (k in honests) and proof_list[l][k] == 0:
                flag = False
            elif(k not in honests) and proof_list[l][k] ==1:
                flag = False
    if flag:
        ans = max(ans,len(honests))
print(ans)

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

using namespace std;

int main()
{
  string s;
  bitset<30> f;
  f.reset();
  cin >> s;
  bool ans=true;
  for(int i=0; i<s.size(); ++i)
  {
    int id = s[i]-'a';
    if (f[id]) ans=ans&(false);
    else 
    {
      f[id]=1;
      ans=ans&(true);
    }
  }
  if (ans) cout << "yes"; else cout << "no";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int dp[3005][3005];

int main() 
{
    fastio();

    string s,t;
    cin>>s>>t;
    int ns = s.size(), nt = t.size();
    for(int i=0;i<=ns;i++)for(int j=0;j<=nt;j++) dp[i][j] = 0;

    //dp[i][j] = length of lcs with indexes till i in first, and j in second

    for(int i=0;i<ns;i++)
    {
        for(int j=0;j<nt;j++)
        {
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
            if( s[i] == t[j] ) max_self(dp[i+1][j+1], 1+dp[i][j]);
        }
    }

    int now = dp[ns][nt];
    // cout<<now,nl;
    int x = ns, y = nt;
    string ans = "";
    while( now )
    {
        int nop = dp[x-1][y-1];
        int up = dp[x-1][y];
        int left = dp[x][y-1];
        if( up == now )
        {
            x--;
        }
        else if( left == now )
        {
            y--;
        }
        else
        {
            x--,y--;
            ans += s[x];
        }
        now = dp[x][y];
    }
    reverse(all(ans));
    cout<<ans,nl;
    return 0;
}

Measured memory_bytes: 35456
n=int(input())
peoplelist=[]
for i in range(5):
  num=int(input())
  peoplelist.append(num)
bottle=min(peoplelist)
bottleindex=peoplelist.index(bottle)
if n<=bottle:
  print(5)
else:
  totaltime=0
  if n%bottle==0:
    totaltime+=int(n/bottle)
  else:
    totaltime+=int(n/bottle)+1
  totaltime+=4
  print(totaltime)

Measured memory_bytes: 3060
// 簡易競プロテンプレ
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, a[114514];
int main(void){
 cin >> n;
 for(int i=0;i<n;i++) cin >> a[i];
 ll ans = 0;
 for(int i=0;i<n;i++){
  ans += a[i]/2; a[i] %= 2;
  if (i+1<n && a[i]==1 && a[i+1]>0) {a[i+1]--; ans++;}
 }
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

typedef long long ll;
ll n, s, k, a;
map<ll, ll> v;
int main()
{
	ll i, t;
	cin >> n;
	v[0]++;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a);
		k += a;
		v[k]++;
	}
	map<ll, ll>::iterator it;
	for (it = v.begin(); it != v.end(); it++) {
		t = it->second;
		s += t * (t - 1) / 2;
	}
	cout << s;
    return 0;
}


Measured memory_bytes: 12800
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.nextInt();
        int[] a = new int[N];
        for (int n = 0; n < N; n++)
            a[n] = in.nextInt();

        int all = 0;
        for (int n = 0; n < N; n++)
            all ^= a[n];
        out.print(all ^ a[0]);
        for (int n = 1; n < N; n++)
            out.print(" " + (all ^ a[n]));
        out.println();

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 71356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  ll sum = 0;
  ll small = 1000000007;
  ll nega = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    small = min(small,abs(A[i]));
    sum += abs(A[i]);
    if (A[i] < 0) {
      nega++;
    }
  }
  if (nega % 2 == 0) {
    cout << sum << endl;
  } else {
    cout << sum - (small * 2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
        int main(){
          int H,N,i;
          int z;
          scanf("%d %d",&H,&N);
          int list[N];
          for(i=0;i<N;i++){
            scanf("%d",list+i);
          }
          for(i=0;i<N;i++){
            z+=list[i];
          }
          if(H-z>0) printf("No");
          else printf("Yes");


        return 0;}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int sum =0;
    int a=n;
    while(a>0){
        sum += a % 10;
        a = a / 10;
    }   
    if (n%sum ==0){
        cout <<"Yes" <<endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;
using ll = long long;

string s;
int n;
ll buf[3][100000];
ll pow3[100001];
const int MOD = 1000000007;

void dumpbuf() {
    for (int k = 0; k < 3; ++k) {
    for (int i = 0; i < n; ++i) {
        cout << setw(3) << buf[k][i];
    }
    cout << endl;
    }
}

ll count(string pat) {
    ll sm = 0;
    for (int i = 0; i < n; ++i) {
        if (pat[0] == s[i]) {
            sm++;
        }
        buf[0][i] = sm;
    }
    sm = 0;
    for (int i = 1; i < n; ++i) {
        if (pat[1] == s[i]) {
            sm += buf[0][i - 1];
            sm %= MOD;
        }
        buf[1][i] = sm;
    }
    sm = 0;
    for (int i = 2; i < n; ++i) {
        if (pat[2] == s[i]) {
            sm += buf[1][i - 1];
            sm %= MOD;
        }
        buf[2][i] = sm;
    }
    //dumpbuf();
    return buf[2][n - 1];
}

int q;
int main(){
    cin >> s;
    n = (int)s.size();
    for (int i = 0; i < n; ++i) {
        if (s[i] == '?') q++;
    }
    pow3[0] = 1;
    for (int i = 1; i <= q; ++i) {
        pow3[i] = (pow3[i - 1] * 3) % MOD;
    }

    ll ans = 0;
    for (int bit = 0; bit < (1 << 3); ++bit) {
        string pat = "ABC";
        int wild = 0;
        for (int k = 0; k < 3; ++k) {
            if ((bit >> k) & 1) {
                pat[k] = '?';
                wild++;
            }
        }
        if (wild > q) continue;
        //cout << pat << " count = " << count(pat) << endl;

        ans += (count(pat) * pow3[q - wild]) % MOD;
        ans %= MOD;
   }
   cout << ans << endl;
    // cout << count("A??") << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
     ll n,k,i,ans=0;
     cin>>n>>k;
     vector <ll> v(n);
     for(auto &u:v)
       cin>>u;
     sort(v.begin(),v.end());
     for(i=0;i<k;i++)
       ans+=v[i];
     cout<<ans;
   }
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(){
  int N,i,a,sum;
  while(1){
    sum = 0;
    scanf("%d",&N);
    if(N == 0){ break; }
    for(i = 0 ; i < N/4 ; i++){
      scanf("%d",&a);
      sum += a;
    }
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,t ;
	cin >> n >> t ;
	ll ans = 0 ;
	ll a,b ;
	cin >> a ;
	for(int i=1;i<n;i++){
		cin >> b ;
		ans += min(t,b-a) ;
		a = b ;
	}
	ans += t ;
	cout << ans << endl ;
}


Measured memory_bytes: 256
X = int(input())
flg = 0
for i in range(1000):
  for j in range(-1000, 1000):
    a5 = i ** 5
    b5 = j ** 5
    if a5 - b5 == X:
      print('{} {}'.format(i, j))
      flg = 1
  if flg == 1:
    break
  
      

Measured memory_bytes: 9112
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt(), N = sc.nextInt(), t=0;
    for(int i=0; i<N; i++) {
    t+=sc.nextInt();
    }
    if(H<=t) System.out.println("Yes");
    else System.out.println("No");
  }
}

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

int main() {
	int n;
	cin >> n;
	int max = 0;
	int count = 0;
	long long int h[n];
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	
	for(int i=0;i<n-1;i++){
		if(h[i]>=h[i+1]){
			count ++;
			if(max < count) max = count;
		}
		else count = 0;
	}
	
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  K, X = readInts()
  left = X - K + 1
  right = X + K - 1
  ans = " ".join([str(x) for x in range(left, right + 1)])
  print(ans)

if __name__ == "__main__":
  main()


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

double A, B;

void solve() {
    cin >> A >> B;
    int i = ceil(A / 0.08);
    while (A == floor(i * 0.08)) {
        if (floor(i * 0.1) == B) {
            cout << i;
            return;
        }
        i++;
    }

    cout << -1;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n), cnt(n, 0);
    for (int i=0; i<n; i++) {
        cin >> a[i];
        a[i]--;
        cnt[a[i]]++;
    }

    long long ans = 0;
    for (auto ci : cnt)
        ans += ci * (ci-1) / 2;

    for (auto ai : a)
        cout << ans - (cnt[ai]-1) << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007;
const ll MAX = 100000000000;
int main(){
    ll n, m, x;
    cin >> n >> m >> x;
    ll c[15];
    ll a[15][15];
    ll ans = MAX;
    for (ll i = 0; i < n;i++){
        cin >> c[i];
        for (ll j = 0; j < m;j++){
            cin >> a[i][j];
        }
    }
    for (ll bit = 0;bit<(1<<n);bit++){
        ll mn = 0;
        ll sc[15] ={0};
        for (int i = 0; i < m; i++)
        {
            sc[i] = 0;
        }
        for (ll i = 0; i < n; i++)
        {
            if (bit & (1 << i))
            {
                
                mn += c[i];
                for (ll j = 0; j < m; j++)
                {
                    sc[j] += a[i][j];
                    
                }
            }
        }
        bool b = true;
        for (int i = 0; i < m;i++){
            if(sc[i] < x){
                b = false;
            }
        }
        if(b == true){
            if(mn < ans){
                ans = mn;
            }
        }

        
    }
    if(ans==MAX){
        cout << "-1";
    }else{
        cout << ans;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 2505;
const int MAX_M = 5005;
const ll INF = 1e15;
ll d[MAX_N];
ll N,M;
bool update[MAX_N];

struct edge
{
	int from,to,cost;
};

edge es[MAX_M];

int main()
{
	ll P;
	cin >> N >> M >> P;
	rep(i,M)
	{
		int a,b;
		ll c;
		cin >> a >> b >> c;
		a--; b--;
		c -= P;
		c *= -1;
		es[i].from = a;
		es[i].to = b;
		es[i].cost = c;
	}

	rep(i,N)
	{
		d[i] = INF;
	}
	d[0] = 0;
	rep(j,N)
	{
		rep(i,M)
		{
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost)
			{
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}

	rep(j,N)
	{
		rep(i,M)
		{
			edge e = es[i];
			if (update[e.from] || (d[e.from] != INF && d[e.to] > d[e.from] + e.cost))
			{
				update[e.to] = true;
			}
		}
	}

	//cout << dN << " " << d[N-1] << endl;
	if (update[N-1]) cout << "-1" << endl;
	else cout << max(ll(0),-1*d[N-1]) << endl;
	return 0;
}

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

Measured memory_bytes: 61884