akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[]d = new int[N];

    for(int i=0; i<N; i++){
        d[i] = sc.nextInt();
}
    ArrayList<Integer>D = new ArrayList<>();    
    for(int i=0; i<N; i++){
        if(!D.contains(d[i])){
            D.add(d[i]);
        }    
    }
		System.out.println(D.size());
    }
}


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

int main() {

	int n, m;
	int* a;
	map<int, int> sum;
	int tmp;
	
	cin >> n;
	a = new int[n];

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

	for (int bit = 0; bit < (1 << n); bit++) {
		tmp = 0;
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				tmp += a[i];
			}
		}
		sum[tmp]++;
	}
	
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		if (sum[tmp] == 0) {
			cout << "no"<<endl;
		}
		else {
			cout << "yes"<<endl;
		}
	}

	
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    int q;
    cin >> q;
    vector<ll> t(q);
    for(int i = 0; i < q; i++){
        cin >> t[i];
    }
    //sort(s.begin(), s.end(), greater<ll>());
    int ans = 0;
    for(int i = 0; i < q; i++){
        if(binary_search(s.begin(), s.end(), t[i]))ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3784
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
// splitで文字列を分ける。("")まで必要
//splitを使うために文字列型にする
    String[] N = sc.next().split("");
//０から数えて何個目にあるかを指定する
//文字列は＝＝じゃなく.equals()
      if (N[0].equals("9") || N[1].equals("9")){
      System.out.println("Yes") ;
      }
      else {
      System.out.println("No") ;
      }
  }
}


Measured memory_bytes: 21844
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    string s, t;
    cin >> s >> t;
    rep(i, s.size()){
        if(s[i] != t[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
	long long int n, i;
	scanf("%lld", &n);
	long long int a[n], dp[n+1];
	memset(dp,-1,sizeof(dp));
	for (i = 0; i < n; ++i)
		scanf("%lld", a+i);
	dp[0]=0;
	dp[1] = fabs(a[1] - a[0]);
	for (i = 2; i < n; ++i)
	{
		dp[i] = fmin(dp[i-2] + fabs(a[i] - a[i-2]), fabs(a[i] - a[i-1]) + dp[i-1]);
	}
//	for(i=0;i<n;i++)
//		printf("%lld ", dp[i]);
//	printf("\n");
	printf("%lld\n", dp[n-1]);
	return 0;
}

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

int main() {
  long long a, b, x;
  cin >> a >> b >> x;
  
  if (b==0){
    cout << 1 << endl;
  }
  else if (a==0){
    cout << b/x +1 << endl;
  }
  else{
    cout << b/x - (a-1)/x << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int N;
  cin >> N;
  priority_queue<pair<int, int>> Q;
  rep(i, N) {
    int a;
    cin >> a;
    Q.push(make_pair(a, i));
  }

  auto x = Q.top(); Q.pop();
  auto y = Q.top();
  int max1 = x.first, max1i = x.second;
  int max2 = y.first;

  rep(i, N) {
    cout << (i != max1i ? max1 : max2) << endl;
  }
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll ND(long n, ll base)
{

    ll dig = (ll)(floor(log(n) /log(base)) +1); 
    return dig;
} 
int main()
{    
    ll n ,b; 
    cin>>n>>b; 
    cout<<ND(n,b);

    return(0);
}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.next();
		char[] C = N.toCharArray();
		int len = C.length;
		int[] c = new int[len];
		Arrays.fill(c,0);
		
		ArrayList<Integer> point = new ArrayList<Integer>();
		point.add(0);
		for(int i = 0; i < len-1; i++) {
			if(C[i] == 'R' && C[i+1] == 'L') point.add(i);
			else if(C[i] == 'L' && C[i+1] == 'R') point.add(i+1);
		}
		point.add(len);
		
		for(int i = 1; i < point.size(); i += 2) {
			if((point.get(i)-point.get(i-1)+1)%2 == 0) {
				c[point.get(i)] += (point.get(i)-point.get(i-1)+1)/2;
				c[point.get(i)+1] += (point.get(i)-point.get(i-1)+1)/2;
			}
			else {
				c[point.get(i)] += ((point.get(i)-point.get(i-1)+1)/2)+1;
				c[point.get(i)+1] += (point.get(i)-point.get(i-1)+1)/2;
			}
			
			if((point.get(i+1)-point.get(i)-1)%2 == 0) {
				c[point.get(i)] += (point.get(i+1)-point.get(i)-1)/2;
				c[point.get(i)+1] += (point.get(i+1)-point.get(i)-1)/2;
			}
			else {
				c[point.get(i)] += (point.get(i+1)-point.get(i)-1)/2;
				c[point.get(i)+1] += ((point.get(i+1)-point.get(i)-1)/2)+1;
			}
		}
		
		for(int i = 0; i < len; i++) {
			System.out.println(c[i]);
		}
	}

}

Measured memory_bytes: 48400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		int num = 0;

		ArrayList<Integer> set = new ArrayList<>();
		ArrayList<Integer> setC = new ArrayList<>();

		if (m == 0) {
			num = (int) Math.pow(10, n - 1);
			if (n == 1)
				System.out.println("0");
			else
				System.out.println(num);
		} else {
			for (int i = 0; i < m; i++) {
				str = br.readLine().split(" ");
				int s = Integer.parseInt(str[0]);
				int c = Integer.parseInt(str[1]);

				if (s == 1 && c == 0 && n > 1) {
					System.out.println("-1");
					return;
				}

				for (int j = 0; j < set.size(); j++) {
					if (set.get(j) == s && setC.get(j) != c) {
						System.out.println("-1");
						return;
					}
				}
				if (set.indexOf(s) == -1) {
					num += (int) Math.pow(10, n - s) * c;
					set.add(s);
					setC.add(c);
				}

			}
			if (set.indexOf(1) == -1)
				System.out.println(num + (int) Math.pow(10, n - 1));
			else
				System.out.println(num);
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,k;
    cin >> n >>k;
    int h[n];
    REP(i,n) cin >> h[i];

    int dp[n];
    REP(i,n) dp[i] = INF;
    dp[0] = 0;
    FOR(i,1,n){
        FOR(j,1,k+1){
            if(i - j < 0){
                break;
            }
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));


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

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
string s[55];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,n)cin>>s[i];
		bool ok=false;
		repl(k,1,51){
			set<string> st;
			rep(i,n){
				string a;
				rep(j,s[i].length()){
					if(j==0)a+=s[i][j];
					if((s[i][j]=='a'||s[i][j]=='i'||s[i][j]=='u'||s[i][j]=='e'||s[i][j]=='o')&&j+1<s[i].length())a+=s[i][j+1];
					//dbg(a);
					if(a.length()==k)break;
				}
				if(a.length()>k)a=a.substr(0,k);
				st.insert(a);
			}
			if(st.size()==n){
				cout<<k<<endl;
				ok=true;
				break;
			}
		}
		if(!ok)cout<<-1<<endl;
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define dupli(a)     unique(all(a)),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;

bool pali(string s){
	int n=s.size(),c=1;
	loop(i,n){
		if(s[i]!=s[n-1-i]){c=0; break;}
	}
	if(c) return 1;
	else return 0;
}


int main(){

 //    #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
 //    fast

    string s;
    cin>>s;
    int m=s.size();
    int p=(m+3)/2; 
    if(pali(s) && pali(s.substr(0,(m-1)/2)) && pali(s.substr(p-1,m-p+1)))
    	pt("Yes");
    else pt("No");
    
    

}


/*

// 

*/

Measured memory_bytes: 3628
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    double W = sc.nextInt();
    double H = sc.nextInt();
    double x = sc.nextInt();
    double y = sc.nextInt();
    double ans = W * H / 2;
    int check;
    if(x == W / 2 && y == H / 2) check = 1;
    else check = 0;
    out.println(ans + " " + check);
  }

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

Measured memory_bytes: 23760
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

int main(){
	int n;cin>>n;
	VI h(n);
	rep(i,n){
		cin>>h.at(i);
	}
	int tmp=0;
	rep(i,n){
		chmax(tmp,h.at(i));
		if(tmp-h.at(i)>1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 640
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return (this- 1) >> 1; };
    Number.prototype.leftIdx = function() { return (this << 1) + 1; };
    Number.prototype.rightIdx = function() { return (this << 1) + 2; };
  }

  insert(key) { this.heapIncrease(this.keys.push(key) - 1); }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx())
      keys[p] = [keys[i], keys[i] = keys[p]][0];
  }

  extract() {
    const res = this.keys[0];
    this.keys[0] = this.keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const keys = this.keys, n = keys.length;
    const innerMaxHeapify = (i) => {
      let left, right, largest = i;
      left = i.leftIdx();
      right = i.rightIdx();
      if (left < n && keys[left] > keys[largest]) largest = left;
      if (right < n && keys[right] > keys[largest]) largest = right;
      if (largest != i) {
        keys[largest] = [keys[i], keys[i] = keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n').slice(0, -1);
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()}\n`; break;
    }
  });
  process.stdout.write(str);
})();




Measured memory_bytes: 203992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  int n=1;
  int count=0;
  int plus=A-1;
  while(n<B){
    count++;
    n+=plus;
  }
  cout << count;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <deque>
#include <map>
using namespace std;
int main() {
	int n, x;
	cin >> n >> x;
	if (n * 500 >= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll N;
  cin>>N;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  ll M = 0;
  ll ans = 0;
  rep(i,N){
    if(M>v[i]) ans+=M-v[i];
    else M = v[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4820
using System;

namespace abc161_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] product = Console.ReadLine().Split(' ');
            int n = int.Parse(product[0]);
            int m = int.Parse(product[1]);

            string[] input = Console.ReadLine().Split(' ');
            int[] vote = new int[n];
            double sum = 0;
            for(int i=0; i<n; i++)
            {
                vote[i] = Convert.ToInt32(input[i]);
                sum += vote[i];
            }

            int choose = 0;
            for(int i=0; i<n; i++)
            {
                if (vote[i] < sum/(4*m))
                {
                    
                }
                else
                {
                    choose++;
                }
            }

            if (choose >= m)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 27576
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a[1000000]={},b[1000000]={};
  int x[300100],y[300100],q,z=0,rt=0,nk=0,baka=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>x[i]>>y[i];
  }
  sort(b,b+(n+1));
  for(int i=1;i<=n;i++){
    if(a[i]!=b[i]) break;
    z++;
  }
  if(z==n){
    cout<<"0\n";
  }
  else{
    for(int i=0;i<q;i++){
      swap(a[x[i]],a[y[i]]);
      rt++;
      z=0;
      if(baka==0){
	for(int j=1;j<=n;j++){
	  if(a[j]!=b[j]){
	    z++; break;
	  }
	  if(a[n+1-j]!=b[n+1-j]){
	    z++;  break;
	  }
	}
	if(z==0){
	  nk=rt;
	  baka++;
	}
      }
    }
    if(nk>=1) cout<<nk<<'\n';
    else  cout<<-1<<'\n';
  }
  return 0;
}



Measured memory_bytes: 13324
#include<bits/stdc++.h>
using namespace std;
long long dp[1100];
const long long inf=1e18;
int u[2200],v[2200],w[2200],n,m;
long long bell_man()
{
    for(int i=1; i<=n; i++)dp[i]=-inf;
    dp[1]=0;
    int f=0;
    while(true)
    {
        bool ff = true;
        for(int j=0; j<m; j++)
            if(dp[v[j]]<dp[u[j]]+w[j])
            {
                dp[v[j]]=dp[u[j]]+w[j];
                if(v[j]==n)
                {
                    f++;
                    ff = false;
                    if(f==n)
                        return inf;
                }
            }
        if(ff) break;
    }
    return dp[n];
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++)
        scanf("%d%d%d",&u[i],&v[i],&w[i]);
    long long ans=bell_man();
    if(ans==inf)
        puts("inf");
    else
        printf("%lld\n",ans);
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  long x,y;
  scanf("%ld %ld", &x, &y);
  if (y < x*2 || y > x*4 || y%2 != 0) {
    printf("No\n");
    return 0;
  }
  printf("Yes\n");

  return 0;
}

Measured memory_bytes: 1660
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];
		long[] b=new long[n+1];
		long ans=0;
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[a[i]]++;
		}

		for(int m=0;m<n+1;m++) {
			ans+=(b[m])*(b[m]-1)/2;
		}
		for(int i=0;i<n;i++) {
			if(b[a[i]]>1) {
			ans=ans-b[a[i]]+1;
			}
			System.out.println(ans);
			if(b[a[i]]>1) {
				ans=ans+b[a[i]]-1;
				}
		}
	}
}


Measured memory_bytes: 93576
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
char ch[maxn];
int a[maxn];
int main()
{
     int i,j,k=0,n,d,p=0,r=0;
     scanf("%d%d",&n,&d);
     while(p<n){
       // if(p==0&&k==0) r=1;
        r+=d*2+1;
        p=r;k++;
     }
     printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <time.h>
using namespace std;

int main() {
  int n, k; std::cin >> n >> k;
  long long cnt = 0;
  if ((k%2) != 0) {  // k is odd.
    for (int i = 1; i <= n; i++) if(i%k==0) ++cnt;
    cnt = cnt * cnt * cnt;
  } else {  // k is even.
    long long cnt1 = 0, cnt2 = 0;
    for (int i = 1; i <= n; i++) if(i%k==0) ++cnt1;
    for (int i = 1; i <= n; i++) if((i%(k/2))==0) ++cnt2;
    cnt2 -= cnt1;
    cnt = (cnt1*cnt1*cnt1) + (cnt2*cnt2*cnt2);
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define SIZE 1000000

//announce function
void merge_sort(int array[], int first_term, int last_term);

int main(void){
    int num, length[SIZE];
    double max=0;

    scanf("%d", &num);

    for(int i=0; i<num; i++){
        scanf("%d", &length[i]);
    }

    merge_sort(length, 0, num-1);

    if(num % 2 == 0){
        for(int i=num - num/2; i<num; i++){
            max += length[i];
        }
        for(int i=num - num/2; i<num-1; i++){
            max += length[i];
        }
    }
    else{
        for(int i=num - num/2 - 1; i<num; i++){
            max += length[i];
        }
        for(int i=num - num/2; i<num-1; i++){
            max += length[i];
        }
    }

    printf("%.f\n", max);

    return 0;
}

//define function
void merge_sort (int array[], int first_term, int last_term) {
    int i, j, mid_term;
    int temporary[SIZE];

    if (first_term < last_term){
        mid_term = (first_term + last_term)/2;
        //recursion merge_sort
        merge_sort(array, first_term, mid_term);
        merge_sort(array, mid_term+1, last_term);

        //append left terms of array
        for (i = first_term; i <= mid_term; i++){
            temporary[i] = array[i];
        }
        //append right terms of array in reverse order
        for (j = mid_term+1; j <= last_term; j++) {
            temporary[last_term-(j-(mid_term+1))] = array[j];
        }

        i = first_term;
        j = last_term;
        for (int k = first_term; k <= last_term; k++) {
            //return smaller one to array
            if (temporary[i] < temporary[j]) {
                array[k] = temporary[i];
                i++;
            }
            else{
                array[k] = temporary[j];
                j--;
            }
        }
    }
}


Measured memory_bytes: 16660
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>

using namespace std;

int expression(void);

string str;
int pos;

int factor(void){

  int num = 0;
  if( isdigit( str[pos] ) ){ // '0' <= str[pos] && str[pos] <= '9' 
    while( isdigit( str[pos] ) ){
      num *= 10;
      num += str[pos] - '0';
      pos++;
    }
    return num;
  }else if( str[pos] == '(' ){
    pos++;
    int res = expression();
    pos++; // ')' テ」ツ?ョテ・ツ按?
    return res;
  }

}

int term(void){

  int res = factor();
  while(1){

    if( str[pos] == '*' ){
      pos++;
      res *= factor();
    }else if( str[pos] == '/' ){
      pos++;
      res /= factor();
    }else break;

  }
  return res;
}

int expression(void){

  int res = term();
  while(1){

    if( str[pos] == '+' ){
      pos++;
      res += term();
    }else if( str[pos] == '-' ){
      pos++;
    res -= term();
    }else break; // '=' テ」ツ?禿」ツ?禿」ツ?ァテ」ツつケテ」ツδォテ」ツδシ
  }
  return res;
}

int main(void){

  int dn;
  cin >> dn;

  while(dn--){
    pos = 0;
    cin >> str;
    cout << expression() << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define M 1000000000000000000
using namespace std;
int main()
{
	int n,flag=0;
	cin>>n;
	long long a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	unsigned long long res=1;
	sort(a,a+n);
	if(a[0]==0)
	cout<<0;
	else
	{
		for(int i=0;i<n;i++)
	{
		double x=M/res;
		if(x>=a[i])
		{
			res*=a[i];
		}
		else
		{
			flag=1;
			break;
		}
//		cout<<(long long)res<<endl;
	}
	if(flag==0)
	{
		cout<<(long long)res;
	}
	else
	cout<<-1;
	}
	
}

Measured memory_bytes: 4372
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>

int64_t count (int64_t x, int rank){
	//1以上x以下の整数のうち, (2 << rank)で割ると(1 << rank)以上余る整数の数(の偶奇)
	int64_t q = x / (2ULL << rank);
	int64_t p = x % (2ULL << rank);
	int64_t ret = q << rank;
	if(p >= (1ULL << rank)){
		ret += p - (1ULL << rank) + 1;
	}
	return ret;
}
int main(void){
	int64_t a, b;
	std::cin >> a >> b;
	int64_t ans = 0;
	int i = 0;
	while(b >= (1ULL << i)){
		int64_t cnt = count(b, i) - count(a, i);
		if(cnt % 2 != 0)ans |= 1ULL << i;
		i++;
	}
	ans ^= a;
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool isMM(string s) {
    int n = stoi(s);
    return 1 <= n && n <= 12;
}

int main() {
    string s;
    cin >> s;
    pair<bool, bool> pa = make_pair(isMM(s.substr(0, 2)), isMM(s.substr(2,2)));
    if(pa.first && pa.second) cout << "AMBIGUOUS";
    else if(pa.first && !pa.second) cout << "MMYY";
    else if(!pa.first && pa.second) cout << "YYMM";
    else if(!pa.first && !pa.second) cout << "NA";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static int count = 0;
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int[] nums  =new int[n];
		for(int i=0;i<n;i++){
			nums[i] = sc.nextInt();
		}
		selectionSort(nums);
		for(int i=0;i<nums.length;i++){
			if(i>0)System.out.print(" ");
			System.out.print(nums[i]);
		}
		System.out.println();
		System.out.println(count);
	}
	public static void selectionSort(int[] nums){
		for(int i=0;i<nums.length;i++){
			int min = i;
			for(int j=i;j<nums.length;j++){
				if(nums[j]<nums[min]){
					min  = j;
				}
			}
			if(min!=i){
				count++;
				swap(nums,min,i);
			}
		}
	}
	public static void swap(int[] A,int i ,int j){
		int t = A[j];
		A[j] = A[i];
		A[i] = t;
	}
}

Measured memory_bytes: 26140
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<long long int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MB 1000000007
#define NB 1000000000
#define ll long long int
int H,A;


int main()
{

	cin >> H >> A;


	cout << ceil((double)H/(double)A);
}




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

using namespace std;

typedef long long ll;
int n;
const int MAX = 1e5;

ll dp[MAX][2];

ll solve(vector<ll> &nums) {

    dp[0][0] = nums[0] + nums[1];
    dp[0][1] = -nums[0] - nums[1];

    for (int i = 1; i < n - 1; ++i) {
        dp[i][0] = max(dp[i - 1][0] + nums[i + 1], dp[i - 1][1] + nums[i + 1]);
        dp[i][1] = max(dp[i - 1][0] - (2 * nums[i]) - nums[i + 1],
                       dp[i - 1][1] + (2 * nums[i]) - nums[i + 1]);
    }

    return max(dp[n - 2][0], dp[n - 2][1]);
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;

    vector<ll> nums(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }

    ll ret = solve(nums);
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 2560
while True:
    a = input()
    if a == "END OF INPUT": break
    ans=[]
    cnt=0
    for i in range(len(a)):
        if a[i]== ' ':
            ans.append(cnt)
            cnt=0
        else: 
            cnt+=1
    ans.append(cnt)
    for x in ans:
        print(x, end='')
    print()

Measured memory_bytes: 7312
#editorial参照
import sys
from collections import deque
input = sys.stdin.readline
n,m = map(int, input().split( ))
Ad = [[[] for _ in range(3)] for i in range(n)]

#移動回数込みで移動可能かの情報をグラフの接続として記録
for i in range(m):
    ui,vi = map(int,input().split( ))
    ui -= 1
    vi -= 1
    Ad[ui][0].append((vi,1))
    Ad[ui][1].append((vi,2))
    Ad[ui][2].append((vi,0))


s,t = map(int, input().split( ))
s -= 1
t -= 1
Q = deque()
Q.append((s,0))
Visit = [[-1 for _ in range(3)] for i in range(n)]
Visit[s][0] = 0
while Q:
    v,i = Q.popleft()
    for u,j in Ad[v][i]:
        if Visit[u][j]<0:
            Visit[u][j] = Visit[v][i] + 1
            Q.append((u,j))
        if u==t and j==0:
            Q.clear()
            break
#print(Visit)
print(Visit[t][0]//3)

Measured memory_bytes: 105564
n=int(input())
l=[0]+list(map(int,input().split()))+[0]
ans=sum(abs(l[i+1]-l[i]) for i in range(n+1))
for i in range(1,n+1):
  if l[i-1]<=l[i]<=l[i+1] or l[i-1]>=l[i]>=l[i+1]:
    print(ans)
  else:
    print(ans-2*min(abs(l[i-1]-l[i]),abs(l[i+1]-l[i])))


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}


int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    int a = (s[0] - '0') * 10 + (s[1] - '0'), b = (s[2] - '0') * 10 + (s[3] - '0');

    if(12 >= a && a >= 1){
        if(12 >= b && b >= 1)
            cout << "AMBIGUOUS";
        else
            cout << "MMYY";
    } else {
        if(12 >= b && b >= 1)
            cout << "YYMM";
        else
            cout << "NA";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
    int x,x1,x2;
    cin>>x>>x1>>x2;
    if(x==x1 && x1!=x2 && x!=x2) cout<<"Yes\n";
    else if(x1==x2 && x!=x1 && x!=x2) cout<<"Yes\n";
    else if(x==x2 && x!=x1 && x1!=x2) cout<<"Yes\n";
    else cout<<"No\n";


    return 0;
}


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

int main()
{ 
    int m=0,f=0,r=0;

    while (true)
    {
        cin>>m>>f>>r;
        if(m ==-1 && f == -1 && r == -1)break;

        int total = m+f;
        if(m ==-1 || f == -1){
            cout<< 'F' << endl;
        }else if(total>=80){
            cout<< 'A' << endl;
        }else if(total>=65){
            cout<< 'B' << endl;
        }else if(total>=50 || r>=50){
            cout<< 'C' << endl;
        }else if(total>=30){
            cout<< 'D' << endl;
        }else{
            cout<< 'F' << endl;
        }
    }

    return 0;
}

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

using namespace std;

int count( vector<int> &h, int l, int r)
{
  if( l==r )
    return h[l];
  
  int m_h = 1000;
  for( int i=l;i<=r;i++ )
    {
      if( m_h > h[i] )
	m_h = h[i];
    }

  for( int i=l;i<=r;i++ )
    h[i] -= m_h;

  int ans = m_h;
  int ll = l;
  while( ll<=r )
    {
      if(h[ll] == 0)
	{
	  ll+=1;
	  continue;
	}
      else
	{
	  int rr = ll;
	  while( rr<=r && h[rr]!=0 )
	    rr ++;
	  if(rr==r && h[rr] != 0)
	    {
	      ans += count(h, ll, rr);
	      break;
	    }
	  else
	    ans += count(h, ll, rr-1);
	  ll = rr;
	}
    }
  return ans;
}

int main()
{
  int N;
  cin >> N;
  vector <int> h(N, 0);
  for( int i=0;i<N;i++ )
    cin >> h[i];


  cout << count(h, 0, N-1) << endl;
}


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

int main()
{
    int N;
    scanf("%d", &N);
    int S[N], res = 0;
    for(int i = 0; i < N; ++i) {
        scanf("%d", &S[i]); res += S[i];
    }
    sort(S, S + N);
    if(res%10) { printf("%d\n", res); return 0; }
    if(res%10 == 0) {
        for(int i = 0; i < N; ++i)
            if(S[i]%10){
                res -= S[i];
                printf("%d\n", res);
                return 0;
            }
    }
    printf("0\n");
    return 0;
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

int n;
int a[100010],b[100010];
int gcdleft[100010],gcdright[100010];

int gcd(int a,int b){
  if(a<b){
    swap(a,b);
  }
  int r;
  while(b>0){
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}

int main(){
  cin >> n;
  rep(i,n){
    cin >> a[i];
    b[n-1-i] = a[i];
  }

  gcdleft[0] = a[0];
  reps(i,1,n){
    gcdleft[i] = gcd(gcdleft[i-1],a[i]);
  }

  gcdright[0] = b[0];
  reps(i,1,n){
    gcdright[i] = gcd(gcdright[i-1],b[i]);
  }

  int ans = 0;
  rep(i,n){
    if(i==0){
      ans = max(ans,gcdright[n-2]);
      continue;
    }
    if(i==n-1){
      ans = max(ans,gcdleft[n-2]);
      continue;
    }
    ans = max(ans,gcd(gcdleft[i-1],gcdright[n-i-2]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			int N = (int)inputArray[0];
			var Aarray = new List<long>();
			var Barray = new List<long>();

			for (int i = 0; i < N; i++) {
				var input = retreiveLongArray();
				Aarray.Add(input[0]);
				Barray.Add(input[1]);
			}

			var Asorted = Aarray.OrderBy(x => x).ToList();
			var Bsorted = Barray.OrderBy(x => x).ToList();

			var Amid = getMedian(N, Asorted);
			var Bmid = getMedian(N, Bsorted);

			//答えの出力

			var ans = N %2==0 ? (Bmid- Amid)*2+1: (Bmid - Amid) + 1;
			Console.WriteLine(ans);
		}


		private static double getMedian(int N,List<long> sorted) {

			if (N % 2 == 0) {
				return (sorted[N / 2 - 1] + sorted[N / 2]) / 2.0;
			}
			else {
				return sorted[N / 2];
			}

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


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

const int P = 1000000007;
int n, m, A[16], fac[1 << 16 | 1], ifac[1 << 16 | 1], dp[1 << 16];

int power(int a, int x) {
	int ans = 1;
	for (; x; x >>= 1, a = 1ll * a * a % P)
		if (x & 1) ans = 1ll * ans * a % P;
	return ans;
}
int binom(int n, int m) {
	return 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i)
		scanf("%d", A + i);
	reverse(A, A + m);
	for (int i = fac[0] = 1; i <= 1 << n; ++i)
		fac[i] = 1ll * fac[i - 1] * i % P;
	ifac[1 << n] = power(fac[1 << n], P - 2);
	for (int i = 1 << n; i; --i)
		ifac[i - 1] = 1ll * ifac[i] * i % P;
	dp[0] = 1;
	for (int i = 0; i < m; ++i)
		for (int j = (1 << n) - 1; j >= 0; --j)
			if (dp[j])
				for (int k = 0; k < n && (1 << k) - 1 <= (1 << n) - A[i] - j; ++k)
					if (!(j >> k & 1))
						dp[j | 1 << k] = (dp[j | 1 << k] + 1ll * dp[j] * binom((1 << n) - A[i] - j, (1 << k) - 1) % P * fac[1 << k]) % P;
	int ans = 0;
	for (int i = 0; i < 1 << n; ++i)
		ans = (ans + (__builtin_parity(i) ? -1ll : 1ll) * dp[i] * fac[(1 << n) - 1 - i]) % P;
	ans = (1ll << n) * ans % P;
	printf("%d\n", (ans + P) % P);
	return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
AB = []
for _ in range(N):
    AB.append(input())
count = 0
for string in sorted(AB, key = lambda x: int(x.split()[0])):
    a = int(string.split()[0])
    b = int(string.split()[1])
    count += b
    if count >= K:
        print(a)
        break

Measured memory_bytes: 15832
def kaibun(S):
    lenS = len(S)
#    print()
#    print(S)
#    print(S[:lenS//2])
#    print(S[:(lenS-1)//2:-1])
    if S[:lenS//2] == S[:(lenS-1)//2:-1]:
        return 1
    else:
        return 0
S = input()
lenS = len(S)
if  kaibun(S) and kaibun(S[:lenS//2]) and kaibun(S[lenS//2+1:]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	string w, AF = "qwertyuiopasdfghjklzxcvbnm";
	int c=0;
	cin >> w;
	for(int i=0;i<26;i++){
		if(count(w.begin(),w.end(),AF[i])%2!=0){
			c++;
			break;
		}
	}
	if(c==0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, Q;
    cin >> N >> Q;

    auto comp = [](vll& l, vll& r){
        if(l[0]>r[0]) return true;
        else if(l[0]==r[0] && l[2]>r[2]) return true;
        else return false;
    };
    priority_queue<vll, vvll, decltype(comp)> exq(comp);

    rep(i, N){
        ll s, t, x;
        cin >> s >> t >> x;
        exq.push({s-x, x, 1});
        exq.push({t-x, x, -1});
    }

    priority_queue<vll, vvll, decltype(comp)> dq(comp);
    rep(i, Q){
        ll d;
        cin >> d;
        dq.push({d, i});
    }

    multiset<ll> sx;
    vll ans(Q);

    while(!dq.empty()){
        auto dv = dq.top();
        ll d = dv[0], idx = dv[1];
        dq.pop();
        while(!exq.empty()){
            auto exv = exq.top();
            ll e = exv[0], x = exv[1], etype = exv[2];
            if(e<=d){
                if(etype==1) sx.insert(x);
                else sx.erase(x);
                exq.pop();
            }
            else break;
        }
        if(sx.size()==0){
            ans[idx] = -1;
        }
        else{
            ll x = *sx.begin();
            ans[idx] = x;
        }
    }

    rep(i, Q) cout << ans[i] << endl;
}


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

using namespace std;

int main() 
{
    int h, w;
    cin >> h >> w;
    string *a;
    a = new string[h];
    int i, j;
    for (i = 0; i < h; i++)
        cin >> a[i];

    bool **b;
    b = new bool*[h];
    for (i = 0; i < h; i++) 
    {
        b[i] = new bool[w];
        for (j = 0; j < w; j++)
            b[i][j] = true;
    }
    
    for (i = 0; i < h; i++)
    {
        bool c = false;
        for (j = 0; j < w; j++) 
        {
            if (a[i][j] == '#')
                c = true;
        }

        if (c == false)
        {
            for (j = 0; j < w; j++)
                b[i][j] = false;
        }
    }

    for (i = 0; i < w; i++) {
        bool c = false;
        for (j = 0; j < h; j++)
        {
            if (a[j][i] == '#')
                c = true;
        }
        if (c == false)
        {
            for (j = 0; j < h; j++)
                b[j][i] = false;
        }
    }

    for (i = 0; i < h; i++) {
        bool c = false;
        for (j = 0; j < w; j++) {
            if (b[i][j] == true) {
                cout << a[i][j];
                c = true;
            }
        }
        if (c)
            cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[100005], b[100005], c[100005], d[100005][3];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 1; i <= n; i++) {
    d[i][0] = max(d[i - 1][1], d[i - 1][2]) + a[i];
    d[i][1] = max(d[i - 1][0], d[i - 1][2]) + b[i];
    d[i][2] = max(d[i - 1][0], d[i - 1][1]) + c[i];
  }
  cout << max({d[n][0], d[n][1], d[n][2]}) << '\n';
}

Measured memory_bytes: 5492
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[123456];
signed main() {
    int n, k, r, s, p, ans = 0; cin >> n >> k >> r >> s >> p; string t; cin >> t;
    for (int h = 0; h < t.size(); h++) {
        if (t[h] == 'r') {
            if (h - k >= 0 && t[h - k] == 'r') {
                if (test[h - k] == 0) { test[h]++; }
                else { ans += p; }
            }
            else { ans += p; }
        }
        if (t[h] == 's') {
            if (h - k >= 0 && t[h - k] == 's') {
                if (test[h - k] == 0) { test[h]++; }
                else { ans += r; }
            }
            else { ans += r; }
        }
        if (t[h] == 'p') {
            if (h - k >= 0 && t[h - k] == 'p') {
                if (test[h - k] == 0) { test[h]++; }
                else { ans += s; }
            }
            else { ans += s; }
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define pb push_back

int main(){
    fast;
    ll n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
        return 0;
    }
    ll ans=r+100*(10-n);
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
    string s,c;
    int n,i,j,k;
    cin>>n>>s;
    int maxsz=n;
    if(n>s.size()){maxsz=s.size();}
    else{maxsz=n;}
    for(i=0;i<maxsz;i++){cout<<s[i];}
    if(s.size()>n){cout<<"...";}

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(0, C - (A - B)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 200200;
int n;
vector<int> g[N];
vector<int> a[2];
vector<int> b[3];
int ans[N];

void printAns() {
	for (int i = 1; i <= n; i++)
		printf("%d ", ans[i]);
	printf("\n");
}

void dfs(int v, int par, int t) {
	a[t].push_back(v);
	for (int u : g[v]) {
		if (u == par) continue;
		dfs(u, v, t ^ 1);
	}
}

int main()
{
	startTime = (double)clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int v, u;
		scanf("%d%d", &v, &u);
		g[v].push_back(u);
		g[u].push_back(v);
	}
	for (int i = 1; i <= n; i++)
		b[i % 3].push_back(i);

	dfs(1, 0, 0);

	/*
	for (int k = 0; k < 2; k++) {
		for (int v : a[k])
			printf("%d ", v);
		printf("\n");
	}
	for (int k = 0; k < 3; k++) {
		for (int v : b[k])
			printf("%d ", v);
		printf("\n");
	}
*/


	for (int t = 0; t < 2; t++) {
		if ((int)a[t].size() <= (int)b[0].size()) {
			for (int v : a[t]) {
				ans[v] = b[0].back();
				b[0].pop_back();
			}
			for (int v : a[t ^ 1]) {
				int k = 0;
				while(b[k].empty()) k++;
				ans[v] = b[k].back();
				b[k].pop_back();
			}
			printAns();
			return 0;
		}
	}
	for (int t = 0; t < 2; t++) {
		for (int v : a[t]) {
			int k = t + 1;
			if (b[k].empty()) k = 0;
			ans[v] = b[k].back();
			b[k].pop_back();
		}
	}
	printAns();

	return 0;
}


Measured memory_bytes: 22296
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let r = read::<u32>();
    println!("{}", 3 * r * r);

    /* vec input
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    */

    /* loop pattern
    let mut count = 0;
    loop {
        if  { break; }
        count += 1;
    }
    println!("{}", count);
    */

    /* yes/no pattern
    yn(a == b);
    */
}


Measured memory_bytes: 4352
import java.util.*;
import java.math.*;

public class Main {
  private static final int BASE = 30000;
  private static final int MAX_N = 20000;

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int[] p = new int[n];
    for (int i = 0; i < n; i++) {
      p[i] = s.nextInt();
    }
    int[] a = new int[n];
    int[] b = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = 1 + BASE * i;
      b[i] = BASE * (n - i);
    }
    for (int i = 0; i < n; i++) {
      a[p[i]-1] += i;
    }

    System.out.print(a[0]);
    for (int i = 1; i < n; i++) {
      System.out.print(" ");
      System.out.print(a[i]);
    }
    System.out.println();

    System.out.print(b[0]);
    for (int i = 1; i < n; i++) {
      System.out.print(" ");
      System.out.print(b[i]);
    }
    System.out.println();
  }
}


Measured memory_bytes: 30656