akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define N 50

int n;
int a[N];

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

	int ma = a[0];
	int ma_idx = 0;
	int mi = a[0];
	int mi_idx = 0;
	for( int i = 1; i < n; i++ ) {
		if( a[i] > ma ) {
			ma = a[i];
			ma_idx = i;
		}
		if( a[i] < mi ) {
			mi = a[i];
			mi_idx = i;
		}
	}
	if( ma == mi ) {
		cout << 0 << endl;
	}
	else {
		typedef pair< int, int > P;
		vector<P> v;
		if( abs(ma) > abs(mi) ) {
			for( int i = 1; i < n; i++ ) {
				a[i] += ma * 2;
				v.push_back( make_pair( ma_idx+1, i+1 ) );
				v.push_back( make_pair( ma_idx+1, i+1 ) );
				ma = a[i];
				ma_idx = i;
			}
		}
		else {
			for( int i = n - 2; i >= 0; i-- ) {
				a[i] += mi * 2;
				v.push_back( make_pair( mi_idx+1, i+1 ) );
				v.push_back( make_pair( mi_idx+1, i+1 ) );
				mi = a[i];
				mi_idx = i;
			}
		}

		cout << v.size() << endl;
		for( int i = 0; i < v.size(); i++ ) {
			cout << v[i].first << " " << v[i].second << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

res = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if (500 * a  + 100 * b + 50 * c) == X: 
        res+=1
        
print(res)

Measured memory_bytes: 9072
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define REVE(x) reverse(ALL(x))
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
#define INF 999999999

typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;


int main() {
	int ans = 0;
	string s;
	cin >> s;
	REP(i, SZ(s) - 1) {
		if (s[i] != s[i + 1])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def judge(k:int, a:list):
    mi = ma = 2
    for ai in a[::-1]:
        # miをaiの倍数に切り上げる
        if mi%ai:
            mi += ai - mi%ai
            
        ma += (ai - 1) - (ma % ai)
        
        if ma < mi:
            return False, (-1,-1)
        
    return True, (mi,ma)

k = ni()
a = list(li())

tf, (mi,ma) = judge(k,a)
if tf:
    print(mi,ma)
else:
    print(-1)

Measured memory_bytes: 14168
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int n;
long long m,a,r,c,h;
vector<long long> D(5);
string s;
//10通りの組み合わせを全て用意
int P[10] = {0,0,0,0,0,0,1,1,1,2};
int Q[10] = {1,1,1,2,2,3,2,2,3,3};
int R[10] = {2,3,4,3,4,4,3,4,4,4};

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
    for (int i = 0; i < n; ++i) {
        cin >> s;
        //先頭文字がMARCHである数をカウントする
        if (s[0] == 'M') m++;
        if (s[0] == 'A') a++;
        if (s[0] == 'R') r++;
        if (s[0] == 'C') c++;
        if (s[0] == 'H') h++;
    }
    D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
    long long ans = 0;
    for (int i = 0; i < 10; ++i) {
        //10通りの組み合わせを全てカウント
        ans += (D[P[i]] * D[Q[i]] * D[R[i]]);
    }
    cout << ans << endl;
    return;
}

int main() {
    cin >> n;
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int s,a[200001];
bool fj(int k){
	if ((s^k)!=(s+k))return false;
	s^=k;
	return true;
}
int main(){
	int n,t;
	long long ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int j=1;
	for(int i=1;i<=n;i++){
		while ((j<=n)&&(fj(a[j])))j++;
		ans=ans+j-i;
		s^=a[i];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 896
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    x = [0] * N
    y = [0] * N
    h = [0] * N

    for i in range(N):
        x[i], y[i], h[i] = MI()

    for cx in range(101):
        for cy in range(101):
            H = set()
            ZH = set()
            for i in range(N):
                if h[i] == 0:
                    ZH.add(abs(x[i] - cx) + abs(y[i] - cy))
                else:
                    H.add(h[i] + abs(x[i] - cx) + abs(y[i] - cy))

            if len(H) == 1 and len(ZH) == 0:
                print(cx, cy, H.pop())
                return
            elif len(H) == 1 and len(ZH) > 0:
                ans = H.pop()
                if ans > min(ZH):
                    continue
                print(cx, cy, ans)
                return
            elif len(H) == 0 and len(ZH) > 0:
                a = ZH.pop()
                for i in list(ZH):
                    a = min(a, ZH.pop())
                print(cx, cy, a)
                return


if __name__ == '__main__':
    main()


Measured memory_bytes: 68568
N = int(input())
A = [int(e) for e in input().split()]

S = [0]
sum =0
for i in range(0, N):
    S.append(S[i] + A[i])
for i in range(N):
    sum = sum + (S[i+1]-A[i]) * A[i]
print(sum%1000000007)

Measured memory_bytes: 107084
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main() {
	double l;
	cin >> l;
	l /= 3.0;
	cout << fixed << setprecision(10) << l*l*l << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int t='z'-'a'+1;

int calc(char a){return 'z'-a+1;}

int main(){
  string str;
  cin>>str;
  int n;
  cin>>n;

  int i=0;
  while(n){
    while(i<str.size()&&(str[i]=='a'||calc(str[i])>n))i++;
    if(i==str.size()){
      str[i-1]='a'+(str[i-1]-'a'+n)%t;
      break;
    }
    n-=calc(str[i]);
    str[i]='a';
  }
  cout<<str<<endl;
  return 0;
}


Measured memory_bytes: 640
import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque

MOD = 10 ** 9 + 7

N = int(input())
T, A = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]

B = [T - h * 0.006 for h in H]

min_diff = 99999999999999999
min_idx = 0
for i in range(N):
    diff = abs(B[i] - A)
    if min_diff > diff:
        min_diff = diff
        min_idx = i

print(min_idx+1)


sys.exit(0)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
int32_t main()
{


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, d;
	cin >> n >> d;
	d = 2 * d;
	d++;

	cout << ceil(n * 1.0 / d);

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long gcd(long long a, long long b)
{
	return b == 0 ? a : gcd(b, a % b);
}

int main()
{
	long long A, B;
	cin >> A >> B;

	long long ans = A / gcd(A, B) * B;
	cout << ans << endl;
}


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

using namespace std;

const int DIM = 87;

bitset <DIM * DIM * 5> dp[DIM][DIM];

int v[DIM][DIM];

main()
{
	int n, m;
	cin >> n >> m;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> v[i][j];
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			int x;
			cin >> x;
			
			v[i][j] -= x;
			v[i][j] = abs(v[i][j]);
		}
	
	dp[1][1][v[1][1]] = true;
	
	for(int x = 1; x <= n; x++)
		for(int y = 1; y <= m; y++)
			for(int k = 0; k < 5 * DIM * DIM; k++)
				if(dp[x][y][k] == true)
				{
					int nx = x;
					int ny = y;
					
					nx++;
					
					if(nx <= n)
					{
						int d1 = k + v[nx][ny];
						int d2 = abs(k - v[nx][ny]);
						
						dp[nx][ny][d1] = true;
						dp[nx][ny][d2] = true;
					}
					
					nx--;
					ny++;
					
					if(ny <= m)
					{
						int d1 = k + v[nx][ny];
						int d2 = abs(k - v[nx][ny]);
						
						dp[nx][ny][d1] = true;
						dp[nx][ny][d2] = true;
					}
				}
	
	for(int i = 0; i < 5 * DIM * DIM; i++)
		if(dp[n][m][i] == true)
		{
			cout << i;
			return 0;
		}
}

Measured memory_bytes: 32512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    for(int i=0;i<3;i++)
    {
        char cc;
        cc=getchar();
        if(cc=='7'){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    return 0;
}


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

int main(){
    int n ;
    cin>>n;
    vector <double> p(n + 1);

    
    double phead;

    
    vector < vector <double> > dp (n + 1, vector <double> (n+1 , 0.0));
    
    cin >> phead;
    dp[1][0] = 1.0 - phead;
    dp[1][1] = phead;
    
    for ( int i = 2 ; i <= n ; i++){
        cin >> phead;
        for(int j = 0 ; j <= n ; j++){
            dp[i][j] = dp[i-1][j-1]*phead + dp[i-1][j]*(1.0 - phead);
        }
    }
    
    double ans = 0.0;
    
    
        for(int j = 0 ; j <= n ; j++){
            if(j > n - j){
            ans += dp[n][j];
            }
        }
    
    
    // dp[i][j] : i throws , j heads = dp[i-1][j-1]*Pi + dp[i-1][j]*(1-Pi);
    
    cout << showpoint << fixed << setprecision(10);
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 70784
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var a = IO.RSInt;

            var cnt = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[a[i] - 1] - 1 == i) cnt++;
            }
            WriteLine(cnt / 2);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

int a(int y,int m,int d){
  return (y-1)*20*10-(y-1-(y-1)/3)*5 +(m-1)*20+((y%3==0)?(0):(-(m-1)/2))+d;
}

int main(){
  int n;
  cin>>n;
  int nd=a(1000,1,1);
  while(n--){
    int y,m,d;
    cin>>y>>m>>d;
    int dd=a(y,m,d);
    cout<<nd-dd<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
  for i in range(N-1, -1, -2):
    print(A[i], end = "")
    print(" ", end = "")
  for i in range(0, N, 2):
    print(A[i], end = "")
    if i != N - 2:
      print(" ", end = "")
    else:
      print("")
else:
  for i in range(N-1, -2, -2):
    print(A[i], end = "")
    print(" ", end = "")
  for i in range(1, N, 2):
    print(A[i], end = "")
    if i != N - 2:
      print(" ", end = "")
    else:
      print("")

Measured memory_bytes: 104616
import java.util.*;

public class Main{
  public static void main(String[] args){
    /*
    int a = 101;
    */
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = 0;
    int[] s;
    s = new int[3];
    s[0] = a / 100;
    s[1] = (a % 100) / 10;
    s[2] = a % 10;
    for(int i = 0; i < 3; i++){
      if(s[i] == 1){
        b++;
      }
    }
    System.out.println(b);
  }
}


Measured memory_bytes: 21844
package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	n := readInt()
	A := make([]int, n)
	for i := 0; i < n; i++ {
		A[i] = readInt()
	}

	xi := make(map[int]int)
	xj := make(map[int]int)
	for i := 0; i < n; i++ {
		xi[i+A[i]]++
		xj[i-A[i]]++
	}

	cnt := 0
	for k, v := range xi {
		cnt += v * xj[k]
	}
	fmt.Fprintln(w, cnt)
}


Measured memory_bytes: 24636
void main() {
	auto N = ri;
	auto T = readAs!(int[]);
	auto M = ri;
	auto S = T.sum;
	foreach(i; 0..M) {
		auto ip = readAs!(int[]), P = ip[0], X = ip[1];
		writeln(S - T[P-1] + X);
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int main() {
	double N,K;
    cin >> N >> K;  
    vector<double>p(N);
    vector<double>X(N+1);
    X[0] = 0;
    for(int i = 0; i < N; i++) {
        cin >> p[i];
        X[i+1]=X[i]+p[i];
    }
    double cnt = 0;
    for(int i = K; i <= N; i++) {
        cnt = max(cnt,X[i]-X[i-K]);
    }
    cout <<fixed<<setprecision(10)<<(cnt+K)/2 << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=b-1;i>=a;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A[15][15],B,C[15],K,ma=INF;

int main(){
  ll N,M,X;
  cin >>  N >> M >> X;
  rep(i,N){
    cin >> C[i];
    rep(j,M){
      cin >> A[i][j];
    }
  }
  rep (bit,1<<N) {  // 0~2^N-1 までのbit 全探索
    ll Z[15],COS=0;
    rep(i,N){
      rep(j,M){
        Z[j]=0;
      }
    }
    rep (i, N){
      if (bit & (1<<i)) { // i が bit に入るかどうか
        COS+=C[i];
        rep(j,M){
          Z[j]+=A[i][j];
        }
      }
      ll K=0;
      rep(i,M){
        if(Z[i]<X){
          K=1;
        }
      }
      if(K==0){
        ma=min(ma,COS);
      }
    }
  }
  if(ma!=INF){
    cout << ma << endl;
  }
  else{
    cout <<-1 << endl;
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#define pi acos(-1)
using namespace std;
double aabs(double x)
{
	if(x<0)return -x;
	return x;
}
struct Dice{
	int q1,q2,q3,q4,q5,q6;
};

int main(){
	Dice d;
	char od;
	
	scanf("%d %d %d %d %d %d", &d.q1, &d.q2, &d.q3, &d.q4, &d.q5, &d.q6);
	
	while( scanf("%c", &od) != EOF ){
		if(od=='N'){
			int tmp=d.q1;
			d.q1=d.q2;
			d.q2=d.q6;
			d.q6=d.q5;
			d.q5=tmp;
		}
		else if(od=='E'){
			int tmp=d.q1;
			d.q1=d.q4;
			d.q4=d.q6;
			d.q6=d.q3;
			d.q3=tmp;
		}
		else if(od=='W'){
			int tmp=d.q1;
			d.q1=d.q3;
			d.q3=d.q6;
			d.q6=d.q4;
			d.q4=tmp;
		}
		else if(od=='S'){
			int tmp=d.q1;
			d.q1=d.q5;
			d.q5=d.q6;
			d.q6=d.q2;
			d.q2=tmp;
		}
	}
	
	printf("%d\n", d.q1);
	
	return 0;
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
int main(){
    int k;
    int ans=0;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,n)cin>>h.at(i);
    rep(i,n)if(h.at(i)>=k){ans++;}
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    long X = scn.nextLong();
    long Y = scn.nextLong();

    long count = 0;
    while (X <= Y) {
      X *= 2;
      count++;
    }

    System.out.println(count);

  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int S;
    cin >> S;
    
    int h,m,s;
    
    h = S/3600;
    m = (S%3600)/60;
    s = S%60;
    
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3100
def pcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c
    
print(pcnt(int(input(),2)))


Measured memory_bytes: 8936
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int Q = scanner.nextInt();
    int[] a = new int[Q];
    int[] b = new int[Q];
    int[] c = new int[Q];
    int[] d = new int[Q];
    for (int i = 0; i < Q; i++) {
      a[i] = scanner.nextInt() - 1;
      b[i] = scanner.nextInt() - 1;
      c[i] = scanner.nextInt();
      d[i] = scanner.nextInt();
    }
    List<List<Integer>> lists = rec(1, M, N);
    int max = 0;
    for (List<Integer> list : lists) {
      int score = 0;
      for (int i = 0; i < Q; i++) {
        if (list.get(b[i]) - list.get(a[i]) == c[i]) score += d[i];
      }
      max = Math.max(max, score);
    }
    System.out.println(max);
  }

  private static List<List<Integer>> rec(int last, int M, int remain) {
    if (remain == 0) {
      ArrayList<List<Integer>> ret = new ArrayList<>();
      ret.add(new ArrayList<>());
      return ret;
    }
    List<List<Integer>> ret = new ArrayList<>();
    for (int i = last; i <= M; i++) {
      List<List<Integer>> tail = rec(i, M, remain - 1);
      for (List<Integer> t : tail) {
        Collections.reverse(t);
        t.add(i);
        Collections.reverse(t);
        ret.add(t);
      }
    }
    return ret;
  }
}


Measured memory_bytes: 56868
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

x = int(input())

ans = 1

for i in range(2,x+1):
    for j in range(2,11):
        if (ans < i ** j):
            if (i**j <= x):
                ans = i ** j
print(ans)






Measured memory_bytes: 9032
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn main() {
    let nums: Vec<_>  = read_line().chars().to_owned().map(|c| c as u8 - '0' as u8).collect();
    let b = nums.windows(2).all(|w| w[0] != w[1]);

    println!("{}", if b { "Good" } else { "Bad" });
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B && B == C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    lint ans=0;
    map<lint, lint> mp;
    lint num = n;
    while (num % 2 == 0)
    {
        ++mp[2];
        num = num / 2;
    }
    for (lint i = 3; i <= n; i++)
    {
        while (num % i == 0)
        { 
            lint aaa = mp[i];
            mp[i] = mp[i] + 1;
            num /= i;
        }
        if (i > 1e7&& (i*i)>n)
        {
            break;
        }
        if (num == 1){
            break;
        }
    }
    if (n == 1)
    {
        cout << 0 << "\n";
        return 0;
    }
    if(n==num){
        cout << 1 << "\n";
        return 0;
    }
    if(num!=1){
        ans++;
    }

    for (auto m:mp)
    {
        lint c = m.second;
        //cout << c<< "\n";
        lint x = 0;
        lint i = 1;
        while(true){
            if(c>=i){
                x++;
                c -= i;
            }else{
                break;
            }
            i++;
        }
        ans += x;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var p = new int[N];
        for (int i = 0; i < N; i++)
        {
            p[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(p);
        p[N-1] /= 2;
        Console.WriteLine(p.Sum());
    }
}

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

int main(){
    int N, K;
    cin >> N >> K;
    
    int ans = 0;
    bool flag = false;
    int i = 0, j = 0;

    while(flag == false){
        j = i + K - 1;
        if(j > N - 1){
            flag = true;
        }else{
            ans++;
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}


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

void dfs(int node, std::vector<std::vector<int>>& v, int& time, std::vector<std::vector<int>>& log) {
    log[node].push_back(++time);
    for (int i=0; i<v[node].size(); i++) {
        if (node != v[node][i] and log[v[node][i]].size() == 0) {
            dfs(v[node][i], v, time, log);
        }
    }
    log[node].push_back(++time);
} 

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, u, k, vi, time=0;
    std::cin >> n;
    std::vector<std::vector<int>> v(n+1), log(n+1);
    for (int i=0; i<n; i++) {
        std::cin >> u >> k;
        for (int j=0; j<k; j++) {
            std::cin >> vi;
            v[u].push_back(vi);
        }
    }
    for (int i=1; i<=n; i++) {
        if (log[i].size() == 0) {
            dfs(i, v, time, log);
        }
    }
    for (int i=1; i<=n; i++) {
        std::cout << i << " " << log[i][0] << " " << log[i][1] << "\n";
    }

    return 0;
}


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

const int N = 190;

int h, w, cnt[N][N], xdt[N][N][N], ydt[N][N][N], ans;

char ipt[N][N];

bool sq_test (int XS, int XE, int YS, int YE) {
	int C = (XE - XS + 1) * (YE - YS + 1);
	int T = cnt[XE][YE] - cnt[XS-1][YE] - cnt[XE][YS-1] + cnt[XS-1][YS-1];
	return T == 0 || T == C;
}

int main()
{
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++) {
		scanf("%s",ipt[i]+1);
		for(int j=1;j<=w;j++) {
			cnt[i][j] = cnt[i-1][j] + cnt[i][j-1] - cnt[i-1][j-1] + (ipt[i][j] == '#');
		}
	}
	for(int XS=1;XS<=h;XS++) {
		for(int XE=XS;XE<=h;XE++) {
			for(int YS=1;YS<=w;YS++) {
				int S = YS-1, E = w;
				while(S<E) {
					int M = (S+E)/2+1;
					sq_test(XS, XE, YS, M) ? S = M : E = M-1;
				}
				xdt[XS][XE][YS] = S;
			}
		}
	}
	for(int YS=1;YS<=w;YS++) {
		for(int YE=YS;YE<=w;YE++){
			for(int XS=1;XS<=h;XS++) {
				int S = XS-1, E = h;
				while(S<E) {
					int M = (S+E)/2+1;
					sq_test(XS, M, YS, YE) ? S = M : E = M-1;
				}
				ydt[YS][YE][XS] = S;
			}
		}
	}
	while(xdt[1][h][1] < w) {
		ans++;
		for(int XS=1;XS<=h;XS++) {
			for(int XE=XS;XE<=h;XE++) {
				for(int YS=1;YS<=w;YS++) {
					if(xdt[XS][XE][YS] == w) continue;
					xdt[XS][XE][YS] = xdt[XS][XE][xdt[XS][XE][YS]+1];
				}
			}
		}
		for(int YS=1;YS<=w;YS++) {
			for(int YE=YS;YE<=w;YE++){
				for(int XS=1;XS<=h;XS++) {
					if(ydt[YS][YE][XS] == h) continue;
					ydt[YS][YE][XS] = ydt[YS][YE][ydt[YS][YE][XS]+1];
				}
			}
		}
		for(int XS=1;XS<=h;XS++) {
			for(int XE=XS;XE<=h;XE++) {
				for(int YS=1;YS<=w;YS++) {
					int S = xdt[XS][XE][YS], E = w;
					while(S<E) {
						int M = (S+E)/2+1;
						ydt[YS][M][XS] >= XE ? S = M : E = M-1;
					}
					xdt[XS][XE][YS] = S;
				}
			}
		}
		for(int YS=1;YS<=w;YS++) {
			for(int YE=YS;YE<=w;YE++){
				for(int XS=1;XS<=h;XS++) {
					int S = ydt[YS][YE][XS], E = h;
					while(S<E) {
						int M = (S+E)/2+1;
						xdt[XS][M][YS] >= YE ? S = M : E = M-1;
					}
					ydt[YS][YE][XS] = S;
				}
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 53504
import java.util.*;

class Main{
	static int mod=1000000007;

	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();
		int m=s.nextInt();

		StringBuilder sb=new StringBuilder();
		for(int i=m-n+1;i<=m+n-1;++i) {
			sb.append(i).append(' ');
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
llint a[25][25];
llint dp[25][1<<21];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	
	llint S = 1<<n;
	dp[0][0] = 1;
	for(int j = 0; j < S; j++){
		int i = 0;
		for(int k = 0; k < n; k++) if(j & (1<<k)) i++;
		for(int k = 0; k < n; k++){
			if(j & (1<<k)) continue;
			if(a[i+1][k] == 0) continue;
			dp[i+1][j|(1<<k)] += dp[i][j];
			dp[i+1][j|(1<<k)] %= mod;
		}
	}
	cout << dp[n][S-1] << endl;
	return 0;
}

Measured memory_bytes: 311552
#include <stdio.h>
int main(void)
{
  int n, i, now=0, ans=0;
  char s[102];
  scanf("%d", &n); 
  scanf("%s", s);

  for(i = 0; i < n; i++){
    if(ans < now) ans = now;
    if(s[i] == 'I') now++;
    else now--;
  }
  if(ans < now) ans = now;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(b-1, n);
  ll ans = a*(x%b)/b;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3568
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using GraphC = vector<vector<char>>;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i, 0, M) cin >> B[i];

  int ans = 0;
  rep(i, 0, N) {
    int a = 0, tot = 0;
    rep(j, 0, M) {
      cin >> a;
      tot += a * B[j];
    }
    if (tot + C > 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{   
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        double x1, y1, x2, y2;
        double distance;
        x1 = double.Parse(str[0]);
        y1 = double.Parse(str[1]);
        x2 = double.Parse(str[2]);
        y2 = double.Parse(str[3]);

        distance = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));

        Console.WriteLine("{0}", distance);
    }
}


Measured memory_bytes: 19992
q,h,s,d = map(int,input().split())
n = int(input())

L2 = [8*q,4*h,2*s,d]
L2.sort()
L1 = [4*q,2*h,s]
L1.sort()
L5 = [2*q,h]
L5.sort()
L25 = [q]

ans = 0
if n >= 2:
    ans += n//2*L2[0]
    n = n%2
    if n == 1:
        ans += L1[0]
elif n == 1:
    ans = L1[0]
elif n == 0:
    ans = 0
    
print(ans)

Measured memory_bytes: 3064
/**
*
* Author: MARC
* Lang: GNU C++14
*
**/

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

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/** /////////// ** Code ** /////////// **/

const int N=100100;
bool vis[N];

int main()
{
    ll ans=0;
    int a,b,c,d; cin>>a>>b>>c>>d;
    for(int i=a ; i<b ; i++) vis[i]=1;
    for(int i=c ; i<d ; i++) if(vis[i]) ans++;

    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
void ABC162A()
{
	int N;
	cin >> N;
	string s = to_string(N);
	for (int i = 0; i < 3; ++i)
	{
		if(s[i] == '7')
		{
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}
int main()
{
	ABC162A();
	return 0;
}


Measured memory_bytes: 3696
from operator import itemgetter
n,m=map(int,input().split())
L=[]
for i in range(m):
    l=[i]+list(map(int,input().split()))+[0]
    L.append(l)
LS=sorted(L,key=itemgetter(1,2))
LS[0][3]=1
for i in range(m-1):
    if LS[i+1][1]==LS[i][1]:
        LS[i+1][3]=LS[i][3]+1
    else:
        LS[i+1][3]=1
LSS=sorted(LS,key=itemgetter(0))
for i in range(m):
    print(str(LSS[i][1]).zfill(6)+str(LSS[i][3]).zfill(6))

Measured memory_bytes: 41332
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

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

    ll d = llabs(a - b);
    ll s = v - w;

    if (d <= s * t) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


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

const int N = 4e6 + 5, Mod = 1e9 + 7;

int n, k;
ll p[N], inv[N], P[N];

ll Pow(ll x, ll y) {
	ll cur = 1;
	while (y) {
		if (y & 1) cur = cur * x % Mod;
		x = x * x % Mod;
		y >>= 1;
	}
	return cur;
}

void Pre() {
	p[0] = 1; for (int i = 1; i < N; ++ i) p[i] = p[i - 1] * (ll)i % Mod;
	inv[N - 1] = Pow(p[N - 1], Mod - 2);
	for (int i = N - 2; i >= 0; -- i) inv[i] = inv[i + 1] * (ll)(i + 1) % Mod;
}

ll Calc(int x, int y) {
	return p[x] * inv[x - y] % Mod * inv[y] % Mod;
}

void Mul(ll &x, ll y) {
	x *= y; x %= Mod;
}

ll f[2005][2005];

int main(void) {
	Pre();
	scanf("%d%d", &n, &k);
	if (k == 1) return 0 * puts("1");

	f[0][1] = 1;
	for (int i = 2; i <= n; ++ i) {
		f[0][i] = f[0][i - 1] * Calc(i*(k-1)-1, k - 2) % Mod;	
	}
	for (int i = 1; i <= n; ++ i) {
		for (int j = i; j <= n; ++ j) {
			f[i][j] = f[i][j - 1] * Calc(i + j * (k - 1) - 1, k - 2) % Mod;
			if (f[i][j] >= Mod) f[i][j] -= Mod;
			f[i][j] += f[i - 1][j];
			if (f[i][j] >= Mod) f[i][j] -= Mod;
		}
	}
	printf("%lld\n", f[n][n] * p[n] % Mod);
	return 0;
} 

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

int main(){
  int n,point[100002],i,sum=0;
  cin>>n;
  point[0]=0;
  point[n+1]=0;
  for(i=1;i<n+1;i++){
    cin>>point[i];
    sum+=abs(point[i]-point[i-1]);
  }
  sum+=abs(point[n+1]-point[n]);
  for(i=1;i<n+1;i++){
    cout<<sum+abs(point[i-1]-point[i+1])-(abs(point[i-1]-point[i])+abs(point[i]-point[i+1]))<<endl;
  }
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int X,A,B;
    cin >> X >> A >> B;
    if(A >= B) cout << "delicious" << endl;
    else if(A+X >= B) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
using namespace std;
int main()
{
    int K,S,z,x,y,ans;
    while(scanf("%d %d",&K,&S)!=EOF)
    {
       ans=0;
        for(x = 0; x <= K; ++x)
        {
            for(y = 0; y <= K; y++)
            {
                z = S - x - y;
                if(z>=0 && z <= K)
                {
                    ans++;
                }
            }
        }
        printf("%d\n",ans);

    }
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<25);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string s,t;
int n,m,db[575575],ufr[575575],ufp[575575];
bool match[575575];

void ufinit(){
	int i;
	for(i=0; i<n; ++i){
		ufp[i] = i;
		ufr[i] = 1;
	}
}

int ufind(int x){
	if(ufp[x] == x){
		return x;
	}
	return ufp[x] = ufind(ufp[x]);
}

bool unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return false;
	}
	if(ufr[x]<ufr[y]){
		swap(x,y);
	}
	ufp[y] = x;
	ufr[x] += ufr[y];
	return true;
}

int main(void){
	int i,j,ans=0,k;
	cin >> s >> t;
	n = s.l_ength();
	m = t.l_ength();
	db[0] = -1; db[1] = 0;
	i = 2; j = 0;
	t.push_back('@');
	while(i<=m){
		if(t[i-1] == t[j]){
			++j;
			db[i] = j;
			++i;
		}else if(j > 0){
			j = db[j];
		}else{
			db[i] = 0;
			++i;
		}
	}
	i = 0; j = 0;
	while(i<=n){
		if(s[(i+j)%n]==t[j]){
			++j;
			if(j==m){
				match[i] = true;
				i += j;
				i -= db[j];
				j = db[j];
			}
		}else{
			i += j;
			i -= db[j];
			if(j>0){
				j = db[j];
			}
		}
	}
	ufinit();
	for(i=0; i<n; ++i){
		if(match[i]){
			if(!unionf(i,(i+m)%n)){
				cout << "-1" << endl;
				return 0;
			}
		}
	}
	for(i=0; i<n; ++i){
		if(i==ufind(i)){
			ans = max(ans,ufr[i]-1);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8328
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int N, L;
	int tura[100010] = {};
	ll res[100010] = {};
	ll plus[100010] = {};

	cin >> N >> L;
	REP(i, N){
		cin >> tura[i+1];
	}
	int cnt = 1;
	while(cnt){
		cnt = 0;
		FOR(i, 1, N+1){
			if(tura[i-1] < tura[i] && tura[i+1] < tura[i]){
				if(tura[i-1])
					plus[i-1] = max(plus[i-1], L-tura[i]+plus[i]);
				if(tura[i+1])
					plus[i+1] = max(plus[i+1], L-tura[i]+plus[i]);
				res[i] += plus[i]+L-tura[i];
				plus[i] = 0;
				tura[i] = 0;
				cnt++;
			}
		}
	}
	ll ans = 0;
	REP(i, N+1){
		ans = max(ans, res[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n,m;
  string s;
  while(cin>>n,n){
    cin>>s;
    while(n--){
      stringstream t;
      m=1;
      if(s.size()==1){
	t<<m;t<<s;s=t.str();
      }
      else{
	for(string::iterator it=s.begin()+1;it!=s.end();++it){
	  if(*it==*(it-1)){
	    ++m;
	  }
	  else{
	    t<<m;t<<*(it-1);m=1;
	  }
	  if(it==s.end()-1){
	    t<<m;t<<*it;
	  }
	}
	s=t.str();
      }
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1380
import sys
H, W = [int(x) for x in input().split()]
if(H==1)or(W==1):
  print(1)
  sys.exit()
if(H%2)==0:
  h = -(-H//2)
  print(h*W)
  sys.exit()
elif(W%2)==0:
  w = -(-W//2)
  print(H*w)
  sys.exit()
else:
  print(-(-(H*W)//2))
  sys.exit()

Measured memory_bytes: 9088
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[410][410];
ll dp2[410][410];

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  for(int len=1;len<=n;len++){
    for(int i=0;i+len<=n;i++){
      int j=i+len;
      dp[i][j]=min(a[i]+dp[i+1][j],dp[i][j-1]+a[j-1]);
      if(len>=2){
        dp2[i][j]=1e18;
        for(int k=i+1;k<j;k++){
          chmin(dp2[i][j],dp2[i][k]+dp2[k][j]+dp[i][j]);
        }
      }
    }
  }
  cout << dp2[0][n] << endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    set<int >s;
    int n,a,cont=0;
    cin>>n;
    for( int i=1;i<=n;i++){
        cin>>a;
        if(i%2!=0 and a%2!=0)
            cont++;
    }
    cout<<cont;
}

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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  ll n, a[200000] = {}, ans = 1145141919810, l = 0, r = 0;
  cin >> n;
  rep(i, 0, n) cin >> a[i], r += a[i];
  rep(i, 0, n - 1) {
    l += a[i];
    r -= a[i];
    ans = min(ans, abs(l - r));
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
int main (void) {
    int N;
    int ans = 0;

    cin >> N;

    for (int i = 0; pow(2, i) <= 100; i++) {
        if (pow(2, i) <= N) ans = pow(2, i);
        else break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

public class Hello{
    public static void Main(){
        string[] str = Console.ReadLine().Split();
       int a = int.Parse(str[0]);
       int b = int.Parse(str[1]);
       
        if(a<b){
           Console.WriteLine("a < b");
        }   
      if(a>b){
           Console.WriteLine("a > b");
      }
        if(a==b){
           Console.WriteLine("a == b");
       }
      
    }
}



Measured memory_bytes: 15960
#include<stdio.h>
int main()
{
    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);
    int i;
    for (i = 0; i < k; i++)
    {
        if (i % 2 == 0)
        {
            if (a % 2 == 1)
                a--;
            a /= 2;
            b += a;
        }
        else
        {
            if (b % 2 == 1)
                b--;
            b /= 2;
            a += b;
        }
    }
    printf("%d %d\n", a, b);
    return 0;
}

Measured memory_bytes: 128