akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, 0, 1, -1 , 1,  1, -1, -1 };
static const char Move[] = { 'E', 'W', 'N', 'S' };

int n, m, x, y, many, a, b;
char d;
vector<PII> gems;

int gcd( int m, int n ) {
	if ( n == 0 ) return m;
	return gcd( n, m % n );
}

int main() {
	while ( !!(cin >> n) && n ) {
		gems.resize( n );
		for ( int i = 0; i < n; i++ ) {
			cin >> a >> b;
			gems[ i ] = make_pair( a, b );
		}
		x = y = 10;
		cin >> m;
		for ( int i = 0; i < m; i++ ) {
			cin >> d >> many;
			for ( int j = 0; j < 4; j++ ) {
				if ( d == Move[ j ] ) {
					for ( int k = 0; k < many; k++ ) {
						x += dx[ j ];
						y += dy[ j ];
						for ( int l = 0; l < gems.size(); l++ ) {
							if ( gems[ l ] == PII( x, y ) ) {
								swap( gems[ l ], gems[ gems.size() - 1 ] );
								gems.pop_back();
							}
						}
					}
				}
			}
		}
		if ( gems.size() ) {
			printf( "No\n" );
		}
		else {
			printf( "Yes\n" );
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long int
#define MOD 1000000007

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<ll> ans(N+1);
    ans[0]=2;
    ans[1]=1;
    for(int i=2;i<=N;i++){
        ans[i]=ans[i-1]+ans[i-2];
    }
    cout << ans[N] << endl;
    return 0;
}


Measured memory_bytes: 256
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;
#include<string>
#include<cmath>
const int N = 1e5 + 7;
const int mod = 1e9 + 7;


int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    string o, e;
    cin>>o>>e;

    int n = o.size()+e.size();
    int j = 0, k = 0;
    int turn = 1;
    string r = "";
    for(int i = 0; i<n && j<o.size()&& k <e.size();i++)
    {
        if(turn == 1){
          r += o[j];
          j++;
          turn = 0;
        }
        else if(turn == 0){
      r += e[k];
      k++;
      turn = 1;
        }


    }

    if(  j < o.size())
    {
      r += o[j];
      j++;
    }
    else if(k < e.size())
    {
      r += e[k];
      k++;
    }

    cout<<r<<endl;






    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


n = int(input())
d = defaultdict(int)
for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      fx = x ** 2 + y ** 2 + z ** 2 + x * y + x * z + y * z
      if fx > n:
        break
      d[fx] += 1
    if x ** 2 + y ** 2 >= n:
      break
  if x ** 2 >= n:
    break
for i in range(1, 1 + n):
  print(d[i])


Measured memory_bytes: 10068
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,i,j,k,f[3010][3010][2],p=1e9+7,ans;
int main(){
	scanf("%d%d",&n,&m);
	f[0][0][1]=1;
	for(i=1;i<=n;i++)f[0][i][0]=1;
	for(i=0;i<m;i++)
	 for(j=0;j<=n;j++)
	  for(k=0;k<=1;k++){
	  	if(j)(f[i+1][j-1][k|(j==1)]+=f[i][j][k])%=p,(f[i+1][j][k|(j==1)]+=f[i][j][k])%=p;
	  	if(n-j)(f[i+1][j][k]+=f[i][j][k])%=p,(f[i+1][j+1][k]+=f[i][j][k])%=p;
	  }
	for(i=0;i<=n;i++)ans=(ans+f[m][i][1])%p;
	printf("%d",ans);
}

Measured memory_bytes: 70784
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    REP(i, n){
        cin >> S[i];
    }
    string res = "";
    for(char c='a'; c<='z'; c++){
        int min_cnt = 1<<20;
        REP(i, n){
            int cnt = count(ALL(S[i]), c);
            min_cnt = min(min_cnt, cnt);
        }
        res += string(min_cnt, c);
    }
    cout << res << endl;
    return 0;
}

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

//struct edge {
//    int to;
//    int weight;
//};

//void dijkstra ( int a, vector<vector<edge>>& g, vector<int>& cost ) {
//    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
//    cost[a] = 0;
//    que.push(make_pair(0, a));
//    while(!que.empty()) {
//        pair<int, int> now = que.top();
//        que.pop();
//        int now_p = now.second;
//        if ( cost[now_p] < now.first ) {
//            continue;
//        }
//        for ( auto v : g[now_p] ) {
//            edge e = v;
//            if ( cost[e.to] > cost[now_p] + e.weight ) {
//                cost[e.to] = cost[now_p] + e.weight;
//                que.push(make_pair(cost[e.to], e.to));
//            }
//        }
//    }
//}

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    rep(i, 10) rep(j, 10) {
        int tmp_c;
        cin >> tmp_c;
        c[i][j] = tmp_c;
    }
    rep(k, 10) rep(i, 10) rep(j, 10) {
        if ( c[i][j] > c[i][k] + c[k][j] ) {
            c[i][j] = c[i][k]+c[k][j];
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) {
        int a;
        cin >> a;
        if ( a == -1 || a == 1 ) {
            continue;
        }
//        dijkstra(0, g, cost);
//        ans += cost[1];
        ans += c[a][1];
//        cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s;
    cin>>s;
    ll i,a=s.size();
    if(s[a-1]=='s'){
       cout<<s;
       cout<<"es";
    }
    else{
        cout<<s;
        cout<<'s';
    }
    
    return 0;
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    unordered_map<int, int> mp;
    for(int i = 1; i < n; i++) {
        int x;
        cin >> x;
        mp[x]++;
    }
    for(int i = 1; i <= n; i++) cout << mp[i] << endl;

    return 0;
}


Measured memory_bytes: 11464
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

extension Int {
    var digits: [Int] {
        String(describing: self).compactMap { Int(String($0))! }
    }
}

func main() {
  let numbers: [Int] = readInts()
  var sum = 0
  for i in 1...numbers.first! {
    let sumOfDigits = i.digits.reduce(0) { $0 + $1 }
    if sumOfDigits >= numbers[1] && sumOfDigits <= numbers[2] {
      sum += i
    }
  }
  print(sum)
}

main()

Measured memory_bytes: 8268
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;

int main(){
  int A, B, C; cin >> A >> B >> C;
  if(A == B) cout << C;
  else if(B == C) cout << A;
  else if(C == A) cout << B;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
module Main where

import Debug.Trace
import Control.Monad

import Data.Set (Set)
import qualified Data.Set as Set

import Data.Map (Map)
import qualified Data.Map as Map

data Status = AC
            | WA
            deriving (Show, Eq)

readSubmission :: [String] -> (Int, Status)
readSubmission s = (read (head s), status)
  where
    status =
      case last s of
        "AC" -> AC
        "WA" -> WA

-- | fuck!!!
-- The wrong answer only count when there exists an AC for that problem
checkSubmission :: (Set Int, Map Int Int, Int) -> (Int, Status) -> (Set Int, Map Int Int, Int)
checkSubmission (passed, wamap, wa) (id, status)
  | id `Set.member` passed = (passed, wamap, wa)
  | otherwise =
      -- traceShow (mconcat [show (id `Set.member` passed), " ", show id, " ", show wa, " ", show wamap, " ", show wa_count]) $
      case status of
        AC -> (id `Set.insert` passed, wamap, wa + wa_count)
        WA -> case wa_count of
                0 -> (passed, Map.insert id 1 wamap, wa)
                _ -> (passed, Map.adjust (+1) id wamap, wa)
  where
    wa_count = case Map.lookup id wamap of
                 Nothing -> 0
                 Just x -> x

main =
  (map (read :: String -> Int) . words) <$> getLine >>= \[n, m]->
  replicateM m ((readSubmission . words) <$> getLine) >>= \submissions ->
  -- traceIO (show submissions) >>
  let
    (passed, _, wa) = foldl checkSubmission (Set.empty :: Set Int, Map.empty :: Map Int Int, 0) submissions
  in
    -- traceIO (show passed) >>
    putStrLn (mconcat [show (Set.size passed), " ", show wa])


Measured memory_bytes: 96636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define cu continue
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second
#define vll vector <ll>
#define dbg(n) cout<<n<<' ';

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


    ll n,m;
    cin>>n>>m;
    cout<<ceil(1.0*n/m)<<'\n';
}       


Measured memory_bytes: 256
#include <stdio.h>
int sign;
char line[100000],line1[100000];
void set(char target[],char setline[]){
    int i=-1,t=0,sum=1;
    while(i++,target[i]){
        if(target[i] == target[i+1])
            sum++;
        else{
            t+=sprintf(setline+t,"%d%c",sum,target[i]);
            sum=1;
        }
    }
    sign=1-sign;
    setline[t]=0;
}
int main(void){
    int num,sum,n,i;
    for(;i=0,sign=1,scanf("%d",&num),num;){
        scanf("%c",&line[0]);
        fgets(line,1000000,stdin);
        while(line[i++])
            if(line[i] == '\n'){
                line[i]=0;
                break;
            }
        for(sum=0;sum!=num;sum++)sign?set(line,line1):set(line1,line);
        printf("%s\n",sign?line:line1);
    }
    return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

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

int num[1000004];
vector<int> sum = {0,1,3,6,10,15,21,28,36,45,55};
int main()
{
    ll n;cin >> n;
    if(n==1)
    {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 2; i<1000004; i++)
    {
        // cout << i << endl;
        while(n%i==0)
        {
            num[i]++;
            n=n/(ll)i;
        }
    }
    int ans = 0;

    if (n != 1)
    {
        ans++;
    }
    for (int i = 2; i<1000004; i++)
    {
        int add = upper_bound(sum.begin(), sum.end(), num[i])-sum.begin()-1;
        ans+=add;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int n;
    cin >> n;
    vi as;
    as.resize(n);
    for(int i=0; i<n; i++) cin >> as.at(i);
    vi bs;
    bs.resize(n);
    for(int i=0; i<n; i++) cin >> bs.at(i);

    vi nums(n);
    for(int i=0; i<n; i++) nums.at(i) = i+1;

    int cnt = 1;
    int ia = -1;
    int ib = -1;
    do
    {
        bool a = true;
        bool b = true;
        for(int i=0; i<n; i++)
        {
            if(nums.at(i) != as.at(i)) a = false;
            if(nums.at(i) != bs.at(i)) b = false;
        }
        if(a) ia = cnt;
        if(b) ib = cnt;
        cnt++;
    }while(next_permutation(nums.begin(), nums.end()));

    cout << abs(ia-ib) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

struct Item {
	int w, v;
};

int main(void) {
	int N, W;
	cin >> N >> W;
	vector<Item> items(N);
	REP(i, N) {
		cin >> items[i].w >> items[i].v;
	}

	LONG dp[110][310];
	REP(i, 304) REP(j, 101) dp[j][i] = 0;
	for (int i = 0; i < N; i++) {
		int idx = items[i].w - items[0].w;
		for (int k = 100; k >= 1; k--) {
			for (int j = 303; j >= 0; j--) {
				if (j - idx >= 0) {
					dp[k][j] = max(dp[k][j], dp[k - 1][j - idx] + items[i].v);
				}
			}
		}
	}
	LONG ans = 0;
	REP(j, 3 * N) REP(k, N + 1) {
		LONG cost = (LONG)k * items[0].w + j;
		if (cost > W) continue;
		ans = max(dp[k][j], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
from functools import reduce
N, X = [int(a) for a in input().strip().split()]
x = [int(a) for a in input().split()]
y = [a - X for a in x]
y.sort()

if len(y) == 1:
    print(abs(y[0]))
    exit()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

ydiff = []
for i in range(0, len(y)-1):
    if y[i+1] * y[i] < 0:
        ydiff.append(abs(y[i]))
        ydiff.append(abs(y[i+1]))
    else:
        ydiff.append(y[i+1] - y[i])
y = list(set(y)) 

if len(ydiff) == 1:
    ydiff.append(ydiff[0])

print(reduce(gcd, ydiff))

Measured memory_bytes: 22300
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func solve(n, m, k int) {
	for i := 0; i <= n; i++ {
		for j := 0; j <= m; j++ {
			x := n*m - i*j - (n-i)*(m-j)
			// out(n*m, i*j, (n-i)*(m-j))
			// out("-->", i, j, x)
			if x == k {
				out("Yes")
				return
			}
		}
	}
	out("No")
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M, K := getInt(), getInt(), getInt()

	solve(N, M, K)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main () {
    int H, W;
    cin >> H >> W;

    for (int i = 0; i < H; i++) {
        vector<string> S_i(W);
        for (int j = 0; j < W; j++) {
            cin >> S_i[j];
            
            if (S_i.at(j) == "snuke") {
                cout << char('A' + j) << i + 1 << endl;
                break;    
            }
        }
    }

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
main(){
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0) break;
		if(x < y)
			printf("%d %d\n",x,y);
		else
			printf("%d %d\n",y,x);
	}
	return 0;
}

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

using namespace std;

int main(){
    char s[11];
    scanf("%s", s);
    bool flag1 = false;
    bool flag2 = false;
    bool flag3 = false;
    if (s[0] == 'A')
        flag1 = true;
    int len = strlen(s);
    int cnt = 0;
    for (int i = 2; i <= len - 2; i++ ){
        if (s[i] == 'C')
            cnt++;
    }
    if (cnt == 1)
        flag2 = true;
    cnt = 0;
    for (int i = 0; i < len; i++){
        if (s[i] >= 'a' && s[i] <= 'z')
            cnt++;
    }
    if (cnt == len - 2)
        flag3 = true;
    if (flag1 && flag2 && flag3)
        puts("AC");
    else
        puts("WA");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int n; cin >> n;
    vector<int> a(n); rep(i, n) cin >> a[i];

    // pattern 1 -1 1 -1
    int sum = 0;
    ll cnt_a = 0;
    rep(i, n) {
        sum += a[i];
        // 偶数番目で正の整数ではない場合
        if (i % 2 == 0 && sum < 1) {
            cnt_a += 1 - sum; // ギリギリ正の整数(1)にするために必要な数を加算
            sum = 1;
        }
        // 奇数番目で負の整数ではない場合
        if (i % 2 == 1 && sum > -1) {
            cnt_a += sum + 1; // ギリギリ負の整数(-1)にするために必要な数を加算
            sum = -1;
        }
    }

    // pattern -1 1 -1 1
    sum = 0;
    ll cnt_b = 0;
    rep(i, n) {
        sum += a[i];
        // 偶数番目で負の整数ではない場合
        if (i % 2 == 0 && sum > -1) {
            cnt_b += sum + 1; // ギリギリ負の整数(-1)にするために必要な数を加算
            sum = -1;
        }
        // 奇数番目で正の整数ではない場合
        if (i % 2 == 1 && sum < 1) {
            cnt_b += 1 - sum; // ギリギリ正の整数(1)にするために必要な数を加算
            sum = 1;
        }
    }

    cout << min(cnt_a, cnt_b) << endl;
    return 0;
}


Measured memory_bytes: 640
/**
 * @author karayuu
 */

fun main(args: Array<String>) {
    val s = readLine()!!
    var count = 0
    
    for (i in 0..3) {
        if (s[i] == '+') {
            count++
        } else if (s[i] == '-'){
            count--
        }
    }
    
    print(count)
}

Measured memory_bytes: 29860
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=33;
int a[N],b[N],c[N];
int main(){
	int ans=0,n;
	rd(n);
	for(int i=1;i<=n;++i) rd(a[i]);
	for(int i=1;i<=n;++i) rd(b[i]),ans+=b[i];
	for(int i=1;i<n;++i) rd(c[i]);
	for(int i=1;i<n;++i) if(a[i+1]==a[i]+1) ans+=c[a[i]];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A, B;
    cin >> A >> B;
    int C = A + B;
    if(C >= 24) {
        C -= 24;
    }
    cout << C << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
const int MAXN = 4000100;
const ll MOD = 998244353;

int N, M;
ll ninv[MAXN];
ll fac[MAXN];
ll finv[MAXN];
ll npow[MAXN], mpow[MAXN];

ll rchoose (int x, int y)
{
    ll res = (fac[x] * finv[y]) % MOD;
    return (res * finv[x-y]) % MOD;
}

ll distro (int K)
{
    if (K < 0) return 0;
    return rchoose (N + K - 1, K);
}

int main()
{
    ios_base::sync_with_stdio(0);
    ninv[1] = 1;
    for (int i = 2; i < MAXN; i++)
    {
        int K = MOD % i;
        ll r = ((ninv[K] * (K - MOD)) / i) % MOD + MOD;
        ninv[i] = r % MOD;
    }

    fac[0] = finv[0] = npow[0] = mpow[0] = 1;
    for (int i = 1; i < MAXN; i++)
    {
        fac[i] = (fac[i-1] * i) % MOD;
        finv[i] = (finv[i-1] * ninv[i]) % MOD;
    }
    
    cin >> N >> M;

    ll ans = 0;
    for (int i = 0; i <= N; i++)
    {
        int K = i;
        if ((i + M) % 2 != 0) continue;
        if (i > M) continue;
        ll l = rchoose (N, i);
        ll r = (distro ((3 * M - K) / 2) - (K * distro ((M - K) / 2)) % MOD - ((N - K) * distro ((M - K) / 2 - 1)) % MOD) % MOD;
        ll v = (l * r) % MOD;
        //cout << K << " " << l << " " << r << " " << v << "\n";
        ans = (ans + v) % MOD;
    }
    cout << ((ans % MOD + MOD) % MOD) << "\n";
}

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

int main() {
  char a, b;
  cin >> a >> b;
  string sa, sb;
  rep(i, (int)(b-'0')) sa += a;
  rep(i, (int)(a-'0')) sb += b;
  cout << min(sa, sb) << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


int main()
{
	int N;

	cin >> N;

	vector<pair<int, int> > As;

	int a;
	for (int ni = 1; ni <= N; ni++){
		cin >> a;
		As.push_back(make_pair(a, ni));
	}

	sort(As.begin(), As.end());

	for (int ni = 0; ni < N; ni++) {
		std::cout << As[ni].second << " ";
	}


	//printf("%.9f", ans);
	//std::cout << ans;

	return 0;
}



Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 200100;
int n, m;
vector<int>g[maxn];

bool visited[maxn];
int maxgr;

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

	int a, b;
	for(int i=0;i<m;i++) {
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}

	for(int i=1;i<=n;i++) {
		if(visited[i]) continue;

		queue<int>q;
		q.push(i);

		visited[i] = true;

		int br = 0;
		while(!q.empty()) {
			int curr = q.front();
			q.pop();

			br++;
			maxgr = max(maxgr, br);

			for(int i:g[curr]) {
				if(!visited[i]) {
					visited[i] = true;
					q.push(i);
				}
			}
		}
	}
	cout<<maxgr<<"\n";
}

Measured memory_bytes: 15280
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;


int main() {

    int A, B, C;
    cin >> A >> B >> C;

    vector<int> vs = {A, B, C};

    sort(vs.rbegin(), vs.rend());

    cout << (vs[0] * 10 + vs[1] + vs[2]) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <functional>

using namespace std;

long int A[200005];

long int  SUM[200005], X[200005];

long int N, I;

long int BINARY(void) {

	long int min, max, med;

	min = I; max = N;

	while (min < max) {

		med = (min + max) / 2;

		//cout << "check" << endl;

		if (((X[med]^X[I - 1]) == SUM[med] - SUM[I - 1]) && ((X[med + 1]^X[I - 1]) < SUM[med + 1] - SUM[I - 1])) { return med; }

		if ((X[med]^X[I - 1]) < SUM[med] - SUM[I - 1]) { max = med; }
		else { min = med+1; }

		//cout << "min= " << min <<"  med= " << med<< " max= " << max << endl;

		if (min == max) { return min; }
	}

	return min;

}

int main(void)
{
	cin >> N;

	long int count = 0;

	long int temp;
	for (long int i = 1; i <= N; i++) {
		cin >> temp; A[i] = temp;
	}

	SUM[0] = 0;
	for (int i = 1; i <= N; i++) { SUM[i] = SUM[i - 1] + A[i]; }

	X[0] = 0;
	for (int i = 1; i <= N; i++) { X[i] = X[i - 1] ^ A[i]; }

	//cout << "CHECK" << endl;
	long int K=-999;
	for (int i = 1; i <= N; i++) {
		I = i;
		//cout << SUM[i] - SUM[i - 1] << "  " << (X[i]^X[i - 1]) << endl;
		K = BINARY();
		//cout << "I= " << I << "  K= " << K << endl;
		count += K - I + 1;
	}

	

	cout << count << endl;

	//system("pause");
	return 0;
}

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


using namespace std;

int n,a[105];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	int ans=0;
	for(int i=2;i<=n;++i)
		if(a[i]==a[i-1])
			ans++,i++;
	printf("%d",ans);
} 

Measured memory_bytes: 256
#include<cstdio>
int n,minn=2147483640,maxp;
int main()
{
	int i,pos,num;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&pos,&num);
		if(minn>num) minn=num;
		if(maxp<pos) maxp=pos;
	}
	printf("%d",minn+maxp);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(all(d));
    int ans = d[n/2]-d[n/2-1];
    cout << ans << endl;

}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n, x;

int main()
{
    cin >> n >> x;
    if(n < 10) x += 100*(10-n);
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import exit

N = int(input())

# 動的計画法
dp = [[[[0 for i in range(4)] for j in range(4)] for k in range(4)] for length in range(N + 1)]

# A = 0, C = 1, G = 2, T = 3
for i in range(4):
    for j in range(4):
        for k in range(4):
            dp[3][i][j][k] = 1

# AGC, GAC, ACGは禁止
dp[3][0][2][1] = 0
dp[3][2][0][1] = 0
dp[3][0][1][2] = 0

for length in range(4, N + 1):
    # 最後から3ばんめ
    for c1 in range(4):
        # 最後から2ばんめ
        for c2 in range(4):
            # 最後から1ばんめ
            for c3 in range(4):
                if dp[length - 1][c1][c2][c3] == 0:
                    continue
                # 追加する文字
                for s in range(4):
                    if [c2, c3, s] not in ([0, 2, 1], [2, 0, 1], [0, 1, 2]):
                        if [c1, c3, s] != [0, 2, 1] and [c1, c2, s] != [0, 2, 1]:
                            dp[length][c2][c3][s] += dp[length - 1][c1][c2][c3]

ans = 0

for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][i][j][k]
print(ans % (10 ** 9 + 7))


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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = n;
	for (int i = 1; i < n; i++) {
		if (s[i-1] == s[i]) continue;
		int now = max(i, n-i);
		ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3272
i = list(map(int, input().split()))
N = i[0]
M = i[1]
AB = [list(map(int, input().split())) for l in range(N)]
AB.sort(key=lambda x:(x[0]))

total = 0
count = 0

for i in range(N):
  if (M - AB[i][1]) >= 0:
    total = total + (AB[i][0] * AB[i][1])
    M = M - AB[i][1]
  else:
    total = total + (AB[i][0] * M)
    count = count + 1
    if count == 1:
      break

print(total)

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

int main()
{
  int n;
  cin>>n;
  int h[n];
  for(int i=0 ; i<n ; i++)
    cin>>h[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2 ; i<n ; i++){
      dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n, m, s = 0;
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        s += a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    if(a[m-1]*4*m >= s) puts("Yes");
    else puts("No");
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin >> s;

    if(s.size() % 2 == 0){
        int middle = s.size() / 2 ;
        int end = s.size() - 1;
        int matchEvenCount = 0;
        for (int i = 0; i < middle; i++)
        {
            if (s[i] != s[end - i])
            {
                matchEvenCount++;
            }
        }

        cout << matchEvenCount << endl;
    }
    else if(s.size() % 2 != 0){
        int middle = s.size()/ 2 + 1;
        int end = s.size() -1;
        int matchOddCount = 0;
         for (int i = 0; i < middle ; i++)
        {
            if(s[i] != s[end -i]){
                matchOddCount++;
            }
        }

        cout << matchOddCount << endl;
        
    }

  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5, maxP = 1e4 + 1; int n, p;
char s[maxN + 1];
lli cnt[maxP]; int acc[maxN + 1];

int main()
{
  while (scanf("%d %d", &n, &p) != EOF)
  {
    memset(cnt, 0, sizeof(cnt));

    scanf(" %s", s);

    if (p == 2 || p == 5)
    {
      lli ans = 0;
      for (int i = 0; i < n; i++)
      {
        int value = 10 + (s[i] - '0');
        if (value % p == 0) ans += i + 1;
      }
      printf("%lld\n", ans);
      continue;
    }

    acc[n] = 0;
    for (int i = n - 1, pot = 1; i >= 0; i--, pot = (pot * 10) % p)
      acc[i] = (acc[i + 1] + (s[i] - '0') * pot) % p;

    DEBUG
      for (int i = 0; i <= n; i++)
        printf("%d%c", acc[i], i < n ? ' ' : '\n');

    cnt[0] = 1;
    for (int i = 0; i < n; i++)
      cnt[acc[i]]++;

    lli ans = 0;
    for (int i = 0; i < p; i++)
      ans += cnt[i] * (cnt[i] - 1) >> 1LL;

    printf("%lld\n", ans);
  }
  return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n+2);

    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());

    int i = 0;
    int alice=0, bob=0;
    while(a[i]) {
        if (i % 2 == 0) {
            alice += a[i];
        }else{
            bob += a[i];
        }
        i ++;
    }

    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	while(cin>>n,n){
		bool dia[41][41]={};
		for(int i=0,x,y;i<n;i++){
			cin>>x>>y;
			dia[y][x]=1;
		}
		int mo;
		cin>>mo;
		string di="NESW";
		int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
		for(int i=0,num,x=10,y=10;i<mo;i++){
			char direction;
			cin>>direction>>num;
			for(int j=0;j<4;j++){
				if(direction==di[j]){
					for(int k=0;k<num;k++){
						x+=dx[j];
						y+=dy[j];
						if(dia[y][x]==1){
							dia[y][x]=0;
							n--;
						}
					}
				}
			}
		}
		if(n==0)cout<<"Yes\n";
		else cout<<"No\n";
	}
}

Measured memory_bytes: 1180
class UnionFind:
    def __init__(self, N):
        # negative value: represents the root of a tree; its absolute value is the size of the tree
        # positive value: the parent's index
        self.vertices = [-1 for _ in range(N)]
        self.rank = [0] * N
        
    def find(self, v):
        if self.vertices[v] < 0: # v is a root
            return v
        else:
            # path compression: reconnect v to the root
            self.vertices[v] = self.find(self.vertices[v])
            return self.vertices[v]
        
    def union(self, u, v):
        s1 = self.find(u) # the root of the tree including vertex u
        s2 = self.find(v) # the root of the tree including vertex v
        
        if s1 == s2: # u and v is in the same tree
            return False
        
        if self.rank[s1] > self.rank[s2]: # the tree including u is taller
            self.vertices[s1] += self.vertices[s2] # update the size of the bigger tree
            self.vertices[s2] = s1
        else: # the tree including v is taller
            self.vertices[s2] += self.vertices[s1] # update the size of the bigger tree
            self.vertices[s1] = s2
            if self.rank[s1] == self.rank[s2]:
                self.rank[s2] += 1
        return True
        
    def is_connected(self, u, v):
        return self.find(u) == self.find(v)
    
    def size(self, v):
        return -self.vertices[self.find(v)]

n, q = map(int, input().split())
uf = UnionFind(n)
for _ in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        uf.union(x, y)
    else:
        print(1 if uf.is_connected(x, y) else 0)


Measured memory_bytes: 5824
#include<stdio.h>
#define min(a,b) (a<b?a:b)
int main()
{
	int a,b,c,x,y,sum;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	c*=2;
	if((float)(a+b)/2<=(float)c/2)
	{
		printf("%d",a*x+b*y);
	}
	else
	{
		if(x>=y)
			printf("%d",c*y+min(a,c)*(x-y));
		else
			printf("%d",c*x+min(b,c)*(y-x));
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void) {
  
  int  A, B, C, X;
  scanf("%d %d %d %d", &A, &B, &C, &X);
  
  int num = 0;
  for(int i = 0; i < A+1; i++) {
    for(int j = 0; j < B+1; j++) {
      for(int k = 0; k < C+1; k++) {
        if ( X == 500*i+100*j+50*k) {
          num++;
        }
      }
    }
  }
  
  printf("%d\n", num);
  
  return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)

def main0(n,g,xyuv):
  # LCAを求める。自作する。
  # 各頂点の深さ。根は深さ0
  depth=[0]*n
  tour=[]
  hatsu=[0]*n
  dist=[0]*n
  tmp=0
  def et(p,v,tour,tmp,pc,pd):
    hatsu[v]=len(tour)-1
    for nv,c,d in g[v]:
      if nv==p:continue
      depth[nv]=depth[v]+1
      tmp+=d
      dist[nv]=tmp
      tour.append((nv,c,d))
      tour=et(v,nv,tour,tmp,c,d)
      tmp-=d
      tour.append((v,c,-d))
    return tour
  tour.append((0,0,0))
  tour=et(-1,0,tour,0,0,0)
  class SegmentTree():
    def __init__(self,size,f=lambda x,y:x+y,default=0):
      self.size=pow(2,(size-1).bit_length())
      self.f=f
      self.default=default
      self.data=[default]*(self.size*2)
    def update(self,i,x):
      i+=self.size
      self.data[i]=x
      while i:
        i>>=1
        self.data[i]=self.f(self.data[i*2],self.data[i*2+1])
    # 区間[l,r)へのクエリ
    def query(self,l,r):
      l,r=l+self.size,r+self.size
      lret,rret=self.default,self.default
      while l<r:
        if l&1:
          lret=self.f(self.data[l],lret)
          l+=1
        if r&1:
          r-=1
          rret=self.f(self.data[r],rret)
        l>>=1
        r>>=1
      return self.f(lret,rret)

  def func(x,y):
    if x[0]<y[0]:return x
    return y
  st=SegmentTree(len(tour),func,(n+1,0))
  for i,x in enumerate(tour):
    v=x[0]
    st.update(i,(depth[v],v))
  def lca(u,v):
    x,y=hatsu[u],hatsu[v]
    if x<y:
      y+=1
    else:
      x,y=y,x
      y+=1
    return st.query(x,y)[1]
  dc={}
  dcary={}
  for i,(v,c,d) in enumerate(tour):
    if c in dc:
      ci=1 if d>0 else -1
      dc[c].append((dc[c][-1][0]+ci,dc[c][-1][1]+d))
      dcary[c].append(i)
    else:
      dc[c]=[(0,0),(1,d)]
      dcary[c]=[0,i]
  ret=[]
  from bisect import bisect_right as bl
  for x,y,u,v in xyuv:
    u,v=u-1,v-1
    w=lca(u,v)
    uvlen=dist[u]+dist[v]-dist[w]*2
    if x not in dc:
      ret.append(uvlen)
      continue
    widx=bl(dcary[x],hatsu[w])-1
    wnum,wsum=dc[x][widx]
    uidx=bl(dcary[x],hatsu[u])-1
    vidx=bl(dcary[x],hatsu[v])-1
    unum,usum=dc[x][uidx]
    vnum,vsum=dc[x][vidx]
    uvsum=usum+vsum-wsum*2
    uvnum=unum+vnum-wnum*2
    #print(uvlen-uvsum+uvnum*y,uvlen,usum,vsum,wsum,uvnum,w)
    ret.append(uvlen-uvsum+uvnum*y)
  return ret

if __name__=='__main__':
  n,q=map(int,input().split())
  abcd=[list(map(int,input().split())) for _ in range(n-1)]
  xyuv=[list(map(int,input().split())) for _ in range(q)]
  g=[[] for _ in range(n)]
  for a,b,c,d in abcd:
    a,b=a-1,b-1
    g[a].append((b,c,d))
    g[b].append((a,c,d))
  ary0=main0(n,g,xyuv)
  print(*ary0,sep='\n')


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

int main() {
  int k,s;
  int ans=0;
  cin>>k>>s;
  
  for (int i = 0; i <=k; i++) {
    for (int j = 0; j <= k; j++) {
      int l=s-i-j;
        if(0<=l && l<=k)ans++;
       }
    }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int k,m,n,i,j,q,c[1001][1001],max=0;
  char X[1000],Y[1000];
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s %s",X,Y);
    m=strlen(X);
    n=strlen(Y);
    for(j=m;j>=1;j--){
      X[j]=X[j-1];
    }
    X[0]=' ';
    X[m+1]='\0';
    for(j=n;j>=1;j--){
      Y[j]=Y[j-1];
    }
    Y[0]=' ';
    Y[n+1]='\0';
    for(j=1;j<=m;j++)c[j][0]=0;
    for(j=1;j<=n;j++)c[0][j]=0;
    for(j=1;j<=m;j++){
      for(k=1;k<=n;k++){
	if(X[j]==Y[k])c[j][k]=c[j-1][k-1]+1;
	else{
	  if(c[j][k-1]>c[j-1][k])c[j][k]=c[j][k-1];
	  else c[j][k]=c[j-1][k];
	}
	if(max<c[j][k])max=c[j][k];
      }
    }
    printf("%d\n",max);
    max=0;
  }
  return 0;
}
  



Measured memory_bytes: 6592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {


    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long n = in.nextLong();
        out.println(dfs(n));
    }

    private long dfs(long n) {
        if (n == 1) {
            return 1;
        }
        return 2 * dfs(n / 2) + 1;
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer      tokenizer;

    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 22740
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
using myui = uint64_t;
using myint = int64_t;

template<typename T>
T diff(const T& a, const T& b) {
    return a > b ? a - b : b - a;
}

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

    {
        myui k, n;
        cin >> n >> k;

        //vector<myui> as;
        //as.reserve(n);

        for(myui i = 0; i < n; i++) {
            myui a;
            cin >> a;
        //    as.push_back(a);
        }

        myui tail = 1;
        myui cnt = 0;
        while(tail < n) {
            tail += k-1;
            cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define NMAX 2005
using namespace std;

int n, k, q;
int nr[NMAX];
vector <int> tot, aux;

int check(int x) /// pana unde crestem daca x e minimul
{
    tot.clear();
    int curent = 0;
    for (int i = 1; i <= n + 1; i++)
    {
        if (nr[i] >= x) /// poate fi luat
            curent++;
        else /// nu mai poate fi luat
        {
            if (curent >= k) /// destule numere a.i. avem de unde elimina
            {
                aux.clear(); /// numerele din secventa

                for (int j = i - curent; j < i; j++) /// adaugam nr in secventa
                    aux.push_back(nr[j]);

                sort(aux.begin(),aux.end()); /// sortam secventa
                for (int j = 0; j < curent - k + 1; j++) /// a.i. raman k - 1 nr.
                    tot.push_back(aux[j]);
            }
            curent = 0;
        }
    }


    sort(tot.begin(),tot.end()); /// sortam toate
    if (tot.size() < q) /// nu avem destule
        return 2000000000;
    else /// al q-lea nr.
        return tot[q - 1];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> k >> q;
    for (int i = 1; i <= n; i++)
        cin >> nr[i];

    //cout << check(1);
    //return 0;

    int rez = 1000000000;
    for (int i = 1; i <= n; i++)
    {
        /// asta e minimul
        rez = min(rez, check(nr[i]) - nr[i]);
    }
    cout << rez;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  int n;
  string s;
  cin >> n >> s;
  vector<string> v(n, "a");
  for (int i = 0; i < n; i++)
  {
    v[i] = s[i];
  }
  // set<string> se(v.begin(), v.end());
  // vector<string> vec2(se.begin(), se.end());
  int maxv = 0, count = 0;
  bool isAdd = true;
  for (int i = 0; i < n-1; i++)
  {
    vector<string> tmp;
    vector<string> done;
    for (int j = 0; j <= i; j++)
    {
      tmp.push_back(v[j]);
    }
    for (int j = i+1; j < n; j++)
    {
      for(string hoge : tmp){
        for (string d : done)
        {
          if (d == v[j])
          {
            isAdd = false;
          }
        }
        if (hoge == v[j] && isAdd)
        {
          count++;
          done.push_back(hoge);
        }
        isAdd = true;
      }
      set<string> se(done.begin(), done.end());
      maxv = max(maxv, int(se.size()));
      count = 0;
      isAdd = true;
    }
    // for(string d : done) cout << d << endl;
    // cout << "========================" << endl;
  }

  cout << maxv << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
//	Table is the complete reverse of dp
//	Always think of the pattern (LCM, GCD)
//	Be careful of unsigned
//	double epsilon = FLT_EPSILON;
//	Think of a solution that gets TLE and optimize it

int main()
{
    cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1, x; i <= n; i++)
    {
    	cin >> x;
    	if((i & 1) && (x & 1))
    		cnt++;
    }
    cout << cnt;
}


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

typedef long long ll;

int main()
{
    ll n, t;
    cin>>n>>t;
    ll time[n];

    for(int i=0;i<n;i++)
    {
        cin>>time[i];
    }
    ll ans =0;
    ll extra = t;
    for(int i=1;i<n;i++)
    {
        if( extra +time[i-1] <= time[i]) {
            ans += extra;
            extra = t;
        }
        else
        {
            ans += time[i] -time[i-1];
            extra = t;
        }
    }
    cout<<ans + extra;
}

Measured memory_bytes: 5168
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        p: [f64; n]
    }
    let mut a = vec![0.0; n];
    for i in 0..n {
        a[i] = (p[i] + 1.0) / 2.0;
    }
    let mut sum = a.iter().take(k).sum::<f64>();
    let mut ans = sum;
    for j in k..n {
        sum += a[j] - a[j - k];
        if ans < sum {
            ans = sum;
        }
    }
    println!("{}", ans)
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

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



int main() {
  string n;cin>>n;
  int p=n.size();
  if(n[p-1]=='3')cout<<"bon";
  else if(n[p-1]=='0'||n[p-1]=='1'||n[p-1]=='6'||n[p-1]=='8')cout<<"pon";
  else cout<<"hon";
}



Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int N;
    cin >>N;
    double x[N];
    string u;
    for(int i=0;i<N;i++){
        cin >>x[i]>>u;
        if(u[0]=='B'){
            x[i]=x[i]*380000;
        }
    }
    double  Y=0;
for(int i=0;i<N;i++){
    Y+=x[i];
}
    cout << Y<<endl;


  return 0;
}

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

int main(){
    long long N,M;
    cin >> N >> M;
    vector<long long> H(N);
    vector<vector<long long>> A(N);
    for(int i = 0;i < N;i++){
        cin >> H.at(i);
    }
    for(int i = 0;i < M;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        A.at(a).push_back(b);
        A.at(b).push_back(a);
    }

    int cnt = 0;
    for(int i = 0;i < N;i++){
        bool ju = true;
        for(int j = 0;j < A.at(i).size();j++){
            if(H.at(i) <= H.at(A.at(i).at(j))){
                ju = false;
            }
        }
        if(ju){
            cnt++;
        }
    }

    cout << cnt;
}

Measured memory_bytes: 9824
S = input()
str = list(S)
n = len(str)
for i in range(n):
  str.pop(-1)
  if len(str)%2 == 1:
    pass
  else:
    x = len(str)/2
    X = int(x)
    str1 = str[:X]
    str2 = str[X:]
    if str1 == str2:
      break
y = len(str1)*2
print(y)

  

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define ri(a,b,c) for(int a=(b);a<(c);++a)
#define ll long long
#define rll(a,b,c) for(ll a=(b);a<(c);++a)

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

    int 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;
    cin>>a>>b;








    cout<<((a<9&&b<9)?"Yay!":":(")<<endl;

    return 0;
}



Measured memory_bytes: 256