akhauriyash/Code-Regression huggingface dataset:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  ll h = sqrt(n);
  ll ans = 0;
  for(ll i = 1;i <= h;i++)
  {
    if(n % i == 0)
    {
      ll tmp = n / i;
      ll size = 0;
      while(tmp)
      {
        size++;
        tmp /= 10;
      }
      ans = size;
    }
  }
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	char[] s, key;

	void run(){
		for(;;){
			StringBuffer lines=new StringBuffer();
			for(;;){
				String line=sc.nextLine();
				if(line.equals("")){
					break;
				}
				lines.append(line);
			}
			s=lines.toString().toCharArray();
			key=sc.nextLine().toCharArray();
			solve();
			if(sc.hasNext()){
				sc.nextLine();
			}else{
				break;
			}
		}
		System.out.flush();
	}

	void solve(){
		int i=0, j=0;
		int num=0;
		int n=s.length;

		int min=INF;
		int cMin=0, iMin=0, jMin=0;

		int nKey=0;
		boolean[] isKey=new boolean[256];
		for(char c : key){
			isKey[c]=true;
		}
		for(boolean b : isKey){
			nKey+=b?1:0;
		}
		int[] count=new int[256];

		for(;;){
			for(; j<n&&num<nKey; j++){
				if(isKey[s[j]]&&count[s[j]]++==0){
					num++;
				}
			}

			if(num<nKey){
				break;
			}

			if(j-i<min){
				iMin=i;
				jMin=j;
				min=j-i;
				cMin=1;
			}else if(j-i==min){
				cMin++;
			}

			if(isKey[s[i]]&&--count[s[i]]==0){
				num--;
			}
			i++;
		}

		println(cMin+"\n");
		if(cMin>0){
			String ans=new String(s, iMin, jMin-iMin);
			for(int k=0; k<(ans.length()-1)/72+1; k++){
				println(ans.substring(k*72, min((k+1)*72, ans.length())));
			}
			println("");
		}
		// debug(cmin, first);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		/*
		try{
			System.setIn(new FileInputStream("a.txt"));
		}catch(FileNotFoundException e){
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		new Main().run();
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    int N,A,B;
    cin>>N>>A>>B;
    int ans=0;

    for(int i=1;i<=N;i++){
        if(i/10000+(i%10000/1000)+(i%10000%1000/100)+(i%10000%1000%100/10)+(i%10000%1000%100%10)>=A&&i/10000+(i%10000/1000)+(i%10000%1000/100)+(i%10000%1000%100/10)+(i%10000%1000%100%10)<=B){
            ans+=i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
const int MAXN = (5042);

int n;
int a[MAXN];
vector<int> adj[MAXN];

void read()
{
	cin >> n;
	for(int i = 2; i <= n; i++) 
	{
		int p;
		cin >> p;
		adj[p].push_back(i);
	}
	
	for(int i = 1; i <= n; i++) cin >> a[i];
}

int sum[MAXN][2];

void dfs(int u)
{
	if(adj[u].size() == 0)
	{
		sum[u][0] = a[u];
		sum[u][1] = 0;
		return;	
	}

	bitset<MAXN> bs; bs[0] = 1;
	int sum_all = 0;
	
	for(int v: adj[u])
	{
		dfs(v);
		bs = (bs << sum[v][0]) | (bs << sum[v][1]);
		sum_all += sum[v][0] + sum[v][1];
	}
	
	int val = -1;
	for(int i = 0; i <= a[u]; i++)
		if(bs[i]) val = i;

	if(val == -1)
	{
		cout << "IMPOSSIBLE" << endl;
		exit(0);
	}

	sum[u][0] = a[u];
	sum[u][1] = sum_all - val;
}

void solve()
{
	dfs(1);
	cout << "POSSIBLE" << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long i,n,m,s;
int main()
{
    cin>>n;
    for (i=1;i<=n;i++) cin>>s,m+=s;
    if (m%2) cout<<"NO"<<endl;else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
class MyTest {

    protected $input;

    public function __construct() {
        // # 複数行
        while (!empty($input = fgets(STDIN))) {
            $this->input[] = trim($input);    
        }
    }

    public function run() {
        $n = $this->input[0];
        $s = $this->input[1];
        $k = $this->input[2];
        $arr = str_split($s);
      	
        $check = $arr[intval($k) - 1];
        $ret = '';
        foreach($arr as $val) {
            if ($val === $check) {
                $ret .= $val;
            } else {
                $ret .= '*';
            }
        }
        echo "{$ret}\n";
    }
    
}

$test = new MyTest();
$test->run();

Measured memory_bytes: 4728
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

template<class T>
T in(void){
  T tmp;
  cin >> tmp;
  return tmp;
}

int main(){
  auto K = in<int>();
  auto A = in<int>();
  int B; cin >> B;

  if((A/K) != (B/K) || (A/K)*K == A){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
N=int(input())
S=input()

a=['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','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']
anslist=[]

for i in range(len(S)):
    b=a.index(S[i])
    anslist.append(a[b+N])

ans="".join(anslist)
print(ans)

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

int main(){	

	int n;
	cin >> n;

	for (int i = 1; i <= n; i++) {

		if(i % 3 == 0){
			cout << " " << i;
			continue;
		}
		int x = i;

		while(x != 0){
			if (x % 10 == 3) {
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}
	cout << endl;
	return 0;

}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
 
#define pi 3.1415926535
 
int main()
{
  double a, b, h, m;
 
  cin >> a >> b >> h >> m;
 
  ld rad = pi * 2 * ((ld)h / 12.0 + (ld)m / 720.0 - (ld)m / 60.0);
 
  ld ans = (ld)(a * a + b * b) - (ld)(2 * a * b * cosl(rad));
  
  ans = sqrtl(ans);
 
  cout << fixed << setprecision(12) << ans << endl;
 
  return 0; 
}

Measured memory_bytes: 4168
#include <iostream>
#include <string>
using namespace std;
int exp();
int term();
int factor();
int number();
int digit();
int p=0;
string str;
int main(){
  int n,re;
  cin >> n;
  while(n){
    p=0;
    cin >> str;
    re=exp();
    cout << re << endl;
    n--;
  }
  return 0;
}
int exp(){
  int val=term();
  while(str[p]=='+'||str[p]=='-'){
    if(str[p]=='+'){
      p++;
      val+=term();
    }else if(str[p]=='-'){
      p++;
      val-=term();
    }
  }
  return val;
}
int term(){
  int val=factor();
  while(str[p]=='*'||str[p]=='/'){
    if(str[p]=='*'){
      p++;
      val*=factor();
    }else if(str[p]=='/'){
      p++;
      val/=factor();
    }
  }
  return val;
}
int factor(){
  int val;
  if(str[p]=='('){
    p++;
    val=exp();
    p++;
  }else{
      val=digit();
  }
  return val;
}
int number(){
  int val=digit();
  return val;
}
int digit(){
  int ret,cnt=0;
  while(1){
    if(cnt==0&&'0'<=str[p]&&str[p]<='9'){
      ret=str[p]-'0';
      p++;
      cnt=1;
    }
    else if(cnt==1&&'0'<=str[p]&&str[p]<='9'){
      ret=ret*10+(str[p]-'0');
      p++;
    }
    else{
      break;
    }
  }
  /*  if('0' <= str[p] && str[p] <= '9') {
    if(cnt==0){
      ret=str[p]-'0';
      cnt=1;
    }
    p++;
    if('0' <= str[p] && str[p] <= '9') {
      ret=ret*10+(str[p]-'0');
      digit();
    }
    return ret;
    }*/
  return ret;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF=10000000;
const int mod=1e9+7;
struct node
{
    int key;
    node *next,*prev;
};
node *nil;
node* listSearch(int key)
{
    node *cur=nil->next;
    while(cur!=nil&&cur->key!=key)
    {
        cur=cur->next;
    }
    return cur;
}
void init()
{
    nil=(node *)malloc(sizeof(node));
    nil->next=nil;
    nil->prev=nil;
}
void printList()
{
    node *cur=nil->next;
    int he=0;
    while(1)
    {
        if(cur==nil)
            break;
        if(he++>0)
            printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}
void deleteNode(node *t)
{
    if(t==nil)
        return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}
void deleteFirst()
{
    deleteNode(nil->next);
}
void deleteLast()
{
    deleteNode(nil->prev);
}
void deleteKey(int key)
{
    deleteNode(listSearch(key));
}
void ins(int key)
{
    node *x=(node *)malloc(sizeof(node));
    x->key=key;
    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}
int main()
{
    int key,n;
    int sz=0;
    char com[105];
    int np=0,nd=0;
    scanf("%d",&n);
    init();
    for(int i=0;i<n;i++)
    {
        scanf("%s %d",com,&key);
        if(com[0]=='i')
        {
            ins(key);
            np++;
            sz++;
        }
        else if(com[0]=='d')
        {
            if(strlen(com)>6)
            {
                if(com[6]=='F')
                    deleteFirst();
                else if(com[6]=='L')
                    deleteLast();
            }
            else
            {
                deleteKey(key);
                nd++;
            }
            sz--;
        }
    }
    printList();
    return 0;
}



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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<P> a(n),b(n);
    set<int> c;
    for (int i = 0;i < n;++i) cin >> b[i].first >> b[i].second;
    for (int i = 0;i < n;++i) cin >> a[i].first >> a[i].second;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int j = 0;
    int ans = 0;
    for (int i = 0;i < n;++i) {
        while (j < n && a[i].first >= b[j].first) {
            c.insert(-b[j].second);
            j++;
        }
        auto it = c.lower_bound(-a[i].second);
        if (it != c.end()) {
            ans++;
            c.erase(it);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//2017-11-3
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define N (1000000+5)

char chr;
inline void Read(int &x){
	chr = getchar();
	while(chr < '0' || chr > '9') chr = getchar();
	x = 0;
	while(chr >= '0' && chr <= '9'){
		x = (x<<1) + (x<<3) + (chr^'0');
		chr = getchar();
	}
}

int a[N];
vector<int> G[N];
bool flag[N];

#define v G[now][i]

bool Dfs(int now, int F){
	if(!a[now]) return false;
	if(G[now].size() == 1 && F) return false;
	
	For(i, 0, G[now].size()-1) if(a[v] < a[now]){
		if(!Dfs(v, now)) return flag[now] = true;
	}
	return false;
}

#undef v

int main(){
	int n, u, v;

	Read(n);
	For(i, 1, n) Read(a[i]);

	For(i, 1, n-1){
		Read(u); Read(v);
		G[u].pb(v); G[v].pb(u);
	}
	if(n == 1) return 0;

	bool fir = true;
	For(i, 1, n)
		if(flag[i] || Dfs(i, 0)){
			if(!fir) printf(" ");
			printf("%d", i);
			fir = false;
		}
	if(!fir) puts("");

	return 0;
}

Measured memory_bytes: 23936
#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 oi(int a){
    int b;
    b=1;
    rep(i,a){
        b*=10;
    }
    return b;
}

int main(){
    int n;
    cin >> n;
    int n2;
    n2=n;
    int k;
    k=1;
    while(n>=10){
        n/=10;
        ++k;
    }
    ll ans;
    ans=0;
    if(k%2==0){
        k/=2;
        rep(i,k){
            ans=ans+9*oi(2*i);
            
        }
    }
    else{
        
        rep(i,k/2){
            ans+=9*pow(10,2*i);
        }
        ans+=n2-pow(10,k-1)+1;

    }

    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 256
def count(t):
    uniqued_t = [t[0]]
    cnt = [1]
    for ti in t[1:]:
        if ti == uniqued_t[-1]:
            cnt[-1] += 1
        else:
            cnt.append(1)
            uniqued_t.append(ti)
    return sum(i // 2 for i in cnt)

s = input()
k = int(input())

if all(i == s[0] for i in s):
    print(len(s) * k // 2)
else:
    t1 = count(s)
    t2 = count(s * 2)
    print(t1+(t2-t1)*(k-1))

Measured memory_bytes: 3064
n=int(input())
a=[-1]+[int(x) for x in input().split()]
b=[-1]+[0]*n
for i in range(n,0,-1):
  #print(b[::i][1:],a[::i][1:])
  if sum(b[::i][1:])%2!=a[i]:
    b[i]=int(not b[i])
    #print(b[::i][1:],a[::i][1:])
    if sum(b[::i][1:])%2!=a[i]:
      print(-1)
      exit()

ans=[n for n,x in enumerate(b) if x==1]
print(len(ans))
print(*ans)

Measured memory_bytes: 79712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int max1=-1*INF,max2=-1*INF;
    vint a(n);
    map<int,int,greater<int>> map;
    rep(i,n){
        cin>>a[i];
        map[a[i]]++;
    }
    if((*map.begin()).S>=2){
        rep(i,n) cout<<(*map.begin()).F<<endl;
    }else{
        int max1=(*map.begin()).F;
        int max2=(*next(map.begin())).F;
        rep(i,n){
            if(a[i]==max1) cout<<max2<<endl;
            else cout<<max1<<endl;
        }
    }
}

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

int a[100001];
int b[100001];
int n,k,q;

void solve(){
    cin>>n>>k>>q;
    for(int i=1; i<=n; i++){
        b[i]=k-q;
    }
    for(int i=0; i<q; i++){
        cin>>a[i];
    }
    for(int i=0; i<q; i++){
        b[a[i]]+=1;
    }
    for(int i=1; i<=n; i++){
        if(b[i]<=0){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
A, B, K = map(int, input().split())

if B-A < K*2 :
  for i in range(A, B+1) :
    print (str(i))
else :
  for i in range(A, A+K) :
    print (str(i))
  for i in range(B-K+1, B+1) :
    print (str(i))
  
  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int a, b;
    cin >> a >> b;
    if (a+b >= 10) {
        cout << "error" << endl;
    } else {
        cout << (a+b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>

int main(){
    int count[1201];
    for(int i = 0; i < 1201; i++){
        count[i] = 0;
 	}
    char ch;
    while(scanf("%c",&ch) != EOF){
        if(ch >= 'a' && ch <= 'z'){
            count[ch - 'a']++;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            count[ch - 'A']++;
        }
    }
    for(int j = 0;j < 26; j++){
        printf("%c : %d\n",j + 'a',count[j]);
    }
    return 0;
}


Measured memory_bytes: 2760
import java.util.*;
import java.util.stream.*;

class Main {
	Scanner sc;
	int N, M;
	String S;
	Deque<Integer> d;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		S = sc.next();
		d = new ArrayDeque<>();
		
		int p = N;
		while (p > 0) {
			int dice = Math.min(M, p);
			for (; dice > 0; dice--) if (S.charAt(p-dice) == '0') break;
			if (dice == 0) break;
			p -= dice;
			d.addFirst(dice);
		}
		if (p > 0) System.out.println(-1);
		else {
			System.out.println(d.stream().map(String::valueOf).collect(Collectors.joining(" ")));
		}
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


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

int main() {
  int dp[110][10010];
  int w[110], v[110];
  int N,W,i,j;

  cin >> N >> W;

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

  for (i = 0; i <= W; ++i) {
    dp[0][i] = 0;
  }

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

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

  return 0;
}


Measured memory_bytes: 7080
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000009LL
#define MOD 1000000007LL

double dp[3005][3005];
int H, W;

int main() {
  int N; cin >> N;
  vector<double> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  
  dp[0][0] = 1;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= N; j++) {
      if (j == 0) dp[i+1][j] = dp[i][j] * p[i];
      else dp[i+1][j] = dp[i][j] * p[i] + dp[i][j-1] * (1 - p[i]);
    }
  }
  
  double ans = 0;
  for (int i = 0; i < N / 2 + 1; i++) {
    ans += dp[N][i];
  }
  
  cout << setprecision(10) << ans << endl;
  return 0;
}



Measured memory_bytes: 70656
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string S1, S2, S3;

  cin >> S1 >> S2 >> S3;

  cout << S1[0] << S2[1] << S3[2] << endl;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define endl "\n"
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define com(a, b) a ## b
#define scv(a, b, c) #a#b#c
#define db(x) cerr << "[" << #x << ": " << (x) << "] " << endl;
#define run cerr << 1 << endl; 
template<class T> void printvec(vector<T>& x, int a, int b) {foru (i, a, b) cout << x[i] << " "; cout << endl;}

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const ld PI = acos((ld) -1);
const ld EPS = 1e-6;
const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;
const int BASE = 10000;

void solve() {
    int n;
    cin >> n;
    vector<int> cnt(n + 1);
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << cnt[i] << endl;
    }
}

int main() {
    #ifdef DEBUG
        com(fre, open) (scv(solve, ., inp), "r", stdin);
        com(fre, open) (scv(solve, ., out), "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
} 

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define INF (1e9)
#define MAX_V 2010
#define MAX_N 1010
using namespace std;
int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v] = true;
  for(int i=0; i<G[v].size(); i++){
    int u = G[v][i], w = match[u];
    if(w<0 || !used[w] && dfs(w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  memset(match, -1, sizeof(match));
  for(int v=0; v<V; v++){
    if(match[v] < 0){
      memset(used,0,sizeof(used));
      if(dfs(v)) res++;
    }
  }
  return res;
}

int main(){
  int n,m,l;
  while(1){
    cin>>n>>m>>l;
    if(!n&&!m&&!l)break;
    vector<vector<int> >g(n,vector<int>(n,INF));
    for(int i=0;i<n;i++) g[i][i]=0;
    for(int i=0;i<l+l+2;i++)G[i].clear();
    
    for(int i=0,a,b,c;i<m;i++)cin>>a>>b>>c,g[a][b]=g[b][a]=c;
    
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
    
    vector<int>idx(l),tl(l);
    for(int i=0,a,b;i<l;i++)cin>>a>>b,tl[i]=b,idx[i]=a;
    
    for(int i=0;i<l;i++)
      for(int j=0;j<l;j++)
	if(i!=j&&tl[i]+g[idx[i]][idx[j]]<=tl[j])add_edge(i,l+j);
    
    V=l+l;
    cout <<l-bipartite_matching()<<endl;
  }
  return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, d, a; cin >> n >> d >> a;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        int x, h; cin >> x >> h;
        h = (h + a - 1) / a;
        p[i] = make_pair(x, h);
    }

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

    queue<pair<int, ll>> q;
    ll ans = 0;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        int x, h;
        tie(x, h) = p[i];
        while (!q.empty() && q.front().first < x) {
            sum -= q.front().second; q.pop();
        }
        h -= sum;
        if (h > 0) {
            ans += h;
            sum += h;
            q.emplace(x + 2 * d, h);
        }
    }
    cout << ans << endl;
    return 0;
}

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

 template<class T> inline bool chmax(T&a,T&b){if(a<b){a=b;return true;}return false;}
 template<class T> inline bool chmin(T&a,T&b){if(a>b){a=b;return true;}return false;}
 const ll INF = 1LL<<60;
 const ll M = 1000000007;
 ll mpow(ll a,ll b) {ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
 ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
ll a[200020];

int main(){
    ll n;cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=0,sum=0;
    for(ll i=n-1;i>=0;i--){
        if(i==n-1){
            ans+=a[i];
            sum++;
        }else{
            if(sum+1==n-1){
                ans+=a[i];
                break;
            }else if(sum+2==n-1){
                ans+=2*a[i];
                break;
            }else{
                ans+=2*a[i];
                sum+=2;
            }
        }
    }
    if(n==1)ans=0;
    if(n==2)ans=a[n-1];
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    int m,d;
    cin >>m>>d;
    int countt=0;

    for(int i=1;i<=d;i++)
    {
        int d1=i%10;
        int d2=i/10;
        if(d1>=2 && d2>=2){
            if(d1*d2>=1 && d1*d2<=m){
                countt++;
            }
        }
    }
    cout<<countt<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)

int main() {
    string S; cin >> S;
    set<char> s;
    rep(i, S.size()) s.insert(S[i]);
    if(s.count('N') == s.count('S') and
       s.count('W') == s.count('E')) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n, ac=0,rt=0,tl=0,wa=0;
    cin >> n;
    while(n--){
        string a;
        cin >> a;
        if(a=="AC")
            ac++;
        else if(a=="RE")
            rt++;
        else if(a=="TLE")
            tl++;
        else if(a=="WA")
            wa++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tl << endl;
    cout << "RE x " << rt << endl;
    
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int r = sc.nextInt();
		int s = sc.nextInt();
		int p = sc.nextInt();
		int sum = 0;
		String t = sc.next();

		for (int i = 0; i < k; i++) {
			char l = 0;
			for (int j = i; j < n; j += k) {
				if(t.charAt(j) != l) {
					if(t.charAt(j) == 'r') {
						sum += p;
						l = 'r';
					}else if(t.charAt(j) == 's'){
						sum += r;
						l = 's';
					}else {
						sum += s;
						l = 'p';
					}
				}else {
					l = 0;
				}
			}
		}
		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 26156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[100005];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[100005],R[100005],rui[100005];
void make(){
	F[0] = 1;
	for(int i=1;i<100005;i++) F[i] = F[i-1]*i%mod;
	for(int i=1;i<100005;i++) R[i] = modpow(i,mod-2);
	for(int i=1;i<100005;i++) rui[i] = (rui[i-1]+R[i])%mod;
}
int main(){
	cin>>n;
	make();
	ll ans = 0;
	repn(i,n){
		cin>>a[i];
		ll coef = rui[i]+rui[n-i+1];
		coef = (coef%mod+mod-1)%mod;
		ans += coef*a[i]%mod;
		//cout << coef << endl;
		ans %= mod;
	}
	cout << ans*F[n]%mod << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll k,n;
    cin >> k >> n;
    vector<ll> a(n), v(n + 1, 0);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        // v[i + 1] = v[i] + a[i];
    }
    ll _min = LLONG_MAX;
    for (ll i = 0; i < n - 1; i++)
    {
        _min = min(_min, k - abs(a[i + 1] - a[i]));
    }
    _min = min(_min, k - abs(a[0] + (k - a.back())));

    cout << _min << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int H,W,h,w;
	scan(H);scan(W);scan(h);scan(w);
	if(H%h==0&&W%w==0){
		prin("No");
	}
	else if(W%w!=0){
		prin("Yes");
		int s[501];
		int a[500];
		s[0]=0;
		for(int i=w;i<=W;i+=w){
			s[i]=s[i-w]-1;
		}
		for(int i=W;i>=1;i--){
			if(i%w==0) continue;
			if(i+w>W){
				s[i]=1;
			}
			else{
				s[i]=s[i+w]+1;
			}
		}
		rep(i,W){
			a[i]=s[i+1]-s[i];
		}
		rep(i,H){
			rep(j,W){
				printf("%d ",a[j]);
			}
			kaigyo;
		}
	}
	else{
		prin("Yes");
		swap(h,w),swap(H,W);
		int s[501];
		int a[500];
		s[0]=0;
		for(int i=w;i<=W;i+=w){
			s[i]=s[i-w]-1;
		}
		for(int i=W;i>=1;i--){
			if(i%w==0) continue;
			if(i+w>W){
				s[i]=1;
			}
			else{
				s[i]=s[i+w]+1;
			}
		}
		rep(i,W){
			a[i]=s[i+1]-s[i];
		}
		rep(i,W){
			rep(j,H){
				printf("%d ",a[i]);
			}
			kaigyo;
		}
	}
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
int t,j,cs=0,n,a,b,i;
string s;

int main()
{
    cin>>n;
    if(n<30) cout<<"No";
    else cout<<"Yes";
    cout<<endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll inf = 1000000007;


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}



int main() {
    ll x, y;
    cin >> x >> y;

    if((x+y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }

    ll idou_kaisu = (x+y) / 3;

    ll x_kaisu = x - idou_kaisu;
    ll y_kaisu = y - idou_kaisu;

    ll num = min(x_kaisu, y_kaisu);

    if(x_kaisu < 0 || y_kaisu < 0){
        cout << 0 << endl;
        return 0;
    }

    ll bunshi = 1;
    ll bunbo = 1;
    rep(i,num){
        bunshi = (bunshi * (idou_kaisu - i)) % inf;
    }
    rep(i,num){
        bunbo = (bunbo * (i+1)) % inf;
    }

    bunshi %= inf;
    cout << bunshi * modinv(bunbo, inf) % inf << endl;

}


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

int main() {

	int N;
	cin >> N;
	vector<int> a;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	vector<string> ope_log;

	// 全てを正または負にするための数値のindexを取得
	int max_idx = distance(a.begin(), max_element(a.begin(), a.end()));
	int min_idx = distance(a.begin(), min_element(a.begin(), a.end()));
	int fix_idx, all_positive;
	if (abs(a[max_idx]) < abs(a[min_idx])) {
		fix_idx = min_idx;
		all_positive = false;
	}
	else {
		fix_idx = max_idx;
		all_positive = true;
	}
	// 全ての数にfix_idxの値を足す
	for (int i = 0; i < N; i++) {
		if (i != fix_idx) {
			a[i] += a[fix_idx];
			ope_log.push_back(to_string(fix_idx+1) + " " + to_string(i+1));
		}
	}
	// 累積和を取っていく
	if (all_positive) {
		for (int i = 1; i < N; i++) {
			a[i] += a[i - 1];
			ope_log.push_back(to_string(i) + " " + to_string(i+1));
		}
	}
	else {
		for (int i = N-2; i >= 0; i--) {
			a[i] += a[i+1];
			ope_log.push_back(to_string(i+2) + " " + to_string(i+1));
		}
	}
	// 答えの出力
	cout << ope_log.size() << endl;
	for (vector<string>::iterator it = ope_log.begin(); it != ope_log.end(); it++)
		cout << *it << endl;

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i=1;i<=N;i++){
        int n = i;
        int cnt = 0;
        while(n>0){
            n /= 10;
            cnt++;
        }
        ans += (cnt%2);
    }
    cout << ans << endl;
}

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

int main(){
  int i,j,k,cnt;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  int sum=0;
  for(i=0;i<n;i++){
    sum+=a[i]-1;
  }
  cout<<sum;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

sm = 1
for i in range(K):
    sm += A[i]

before = sm
for i in range(K, N):
    sm -= A[i-K]
    sm += A[i]
    if sm > before:
        print('Yes')
    else:
        print('No')
    before = sm

Measured memory_bytes: 31612
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)

//  Scc Puzzle.cpp
//
//  Created by WinnieJt on 2019/3/21.
//
//  Copyright © 2019 金天. All rights reserved.

//åß∂ƒ∆Ω≈µç∫πø∑¢∞§¶

#include<bits/stdc++.h>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
typedef double db;
typedef long long ll;
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
using namespace std;
ll n,m,cnt=0;
int main(void)
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    if(2*n<=m)
    {
        cnt+=n;
        m-=2*n;
        if(m>=4) cnt+=m/4;
    }
    else
    {
        if(m>=2) cnt+=m/2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX+1];

void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;
	
// 左の子、自分、右の子で値が最大のノードを選ぶ
	if ( l <= H && A[l] > A[i] ) largest = l;
	else largest = i;
	if ( l <= H && A[r] > A[largest] ) largest = r;
	
	if ( largest != i ){
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}


int main() {
	cin >> H;
	
	for ( int i = 1; i <= H; i++ ) cin >> A[i];
	
	for ( int i = H / 2; i >= 1; i-- ) maxHeapify(i);
	
	for ( int i = 1; i <= H; i++ ) {
		cout << " " << A[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 5008
n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = pow(2, n, mod) - 1

#nCx % mod
def f(x):
  N = 1
  D = 1
  for i in range(x):
    N *= n - i
    N %= mod
    D *= i + 1
    D %= mod
  return N * pow(D, mod-2, mod) % mod

print((ans-f(a)-f(b))%mod)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(){
 	int a,b,b2,x,cnt,flag,i;
  
  	scanf("%d",&a);
	scanf("%d",&b);
  	
  	b2=b;
  	cnt=0;
  
	while(b2!=0){
        	cnt+=1;
    		b2=b2/10;
    }
  	
  	a=a*pow(10,cnt);

    
    x=a+b;
    //printf("%d\n",x);
  	flag=0;
  	for(i=2;i<=sqrt(100100);i++){
    	if(x==(i*i)){
          flag=1;
        }
    }
  
  	if(flag==1){
    	printf("Yes\n");
    }else{
      printf("No\n");
    }

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
public class Aprob {
    public static void Main() {
        string[] readSome = new string[2];
        readSome = Console.ReadLine().Split(' ');
        int[] N = new int[2];
        for (int i = 0; i < 2; i++) {
            N[i] = int.Parse(readSome[i]);
        }
        Console.WriteLine(N[1]*Math.Pow(N[1]-1,N[0]-1));
    }
}

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

int main() {
    int N, P; cin >> N >> P;
    long long A[N];
    long long odd = 0, even = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if(A[i] % 2 == 1) odd++;
    }

    long long ans = 0;
    if(odd == 0){
        if(P == 0) ans = 1LL<<N;
        else ans = 0;
    }
    else ans = 1LL<<(N-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	cout<<max(0,b+c-a)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
    int n, m, x;
    scanf("%d %d %d", &n, &m, &x);
    int a[n+1];
    fill(a, a + n + 1, 0);
    for(int i = 0; i < m; i++){
        int c;
        scanf("%d", &c);
        a[c] = 1;
    }
    int forward = 0;
    for(int i = x + 1; i <= n; i++){
        forward += a[i];
    }
    int backward = 0;
    for(int i = x - 1; i >= 0; i--){
        backward += a[i];
    }
    if (forward < backward) printf("%d\n", forward);
    else printf("%d\n", backward);
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N,K,i,ans;
    cin>>N>>K;
    i=N%K;
    if(i==0){
        ans=0;
    }
    else{
        ans=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
class BIT: #0-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
        self.depth = n.bit_length()
        self.n0 = 1<<self.depth
#        self.element = [0]*(n+1)
    def get_sum(self, i): #a_0 + ... + a_{i} #閉区間
        s = 0; i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    def query(self,l,r): #a_l + ... + a_r 閉区間
        return self.get_sum(r) - self.get_sum(l-1) 
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        # self.element[i] += x
    #def get(self,i): return element[i]        
    def bisect_left(self,w):
        #和が w 以上になる最小の index
        #w が存在しない場合 self.size を返す
        if w <= 0: return 0
        x,k = 0,self.n0
        for _ in range(self.depth):
            k >>= 1
            if x+k <= self.size and self.tree[x+k] < w:
                w -= self.tree[x+k]
                x += k
        return x
    
###########################################
import sys
readline = sys.stdin.readline

n,q = map(int, readline().split())
*a, = map(int, readline().split())

b = BIT(n)
for i in range(n):
    b.add(i,a[i])

for _ in range(q):
    v,p,x = map(int, readline().split())
    if v==0:
        b.add(p,x)
    else:
        print(b.query(p,x-1))






Measured memory_bytes: 143848
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a)) 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define EXIT exit(0)
#define all(a) (a).begin(),(a).end()
//loop 
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define cFor(i,a,b) for(int i=(a);i>(b);i--)
#define cFOR(i,a,b) for(int i=(a);i>=(b);i--)
#define lFor(i,a,b) for(ll i=(a);i<(b);i++)
#define lFOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define lcFor(i,a,b) for(ll i=(a);i>(b);i--)
#define lcFOR(i,a,b) for(ll i=(a);i>=(b);i--)
//debug
#define dbg(a) cout<<#a<<"="<<a<<endl
#define inthis cout<<"--------this\n"
//operator
#define pb push_back
#define ins insert
#define era erase
#define fin find 
//pair
#define pr pair
#define mkp(a,b) make_pair(a,b)
#define fi first
#define se second
//vector
#define vec vector
#define vi vector<int>
#define vii vector<vector<int>>
//map
#define mp map
////map int
#define mpii map<int,int>
#define mpib map<int,bool>
#define mpic map<int,char>
#define mpis map<int,string>
#define mpil map<int,long long>
////map long long 
#define mpll map<long long,long long>
#define mplb map<long long,bool>
#define mplc map<long long,bool>
#define mpls map<long long,string>
#define mpli map<long long,int>
////map char
#define mpci map<char,int>
#define mpcb map<char,bool>
#define mpcl map<char,long long>
////map string
#define mpsi map<string,int>
#define mpsb map<string,bool>
#define mpsl map<string,long long>
//iterator
#define ivec(a) vector<a>::iterator
#define iset(a) set<a>::iterator 
#define imp(a,b) map<a,b>::iterator

using namespace std;
/*
const int maxsize=
struct edge{
	int nod,nxt;
			
}e[maxsize<<1];
int nume=0,pa[maxsize],head[maxsize];
void add(int u,int v){
	e[++nume].nod=v;
	e[nume].nxt=head[u];
	head[u]=nume;
}
void init(){
	
}
bool vis[maxsize];
void bfs(){
	
}
void dfs(){

}
*/

int main(){
	fio;
	int n,k;
	cin>>n>>k;
	int ans=0;
	while(n){
		ans++;
		n/=k;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                             it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

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

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        vector<int> V(3600*24+60*60+60);
        int n;
        cin >> n;
        if(n==0) break;
        rep(i,n){
            int hh,mm,ss;
            char c;
            cin >> hh >> c >> mm >> c >> ss;
            int gh,gm,gs;
            cin >> gh >> c >> gm >> c >> gs;
            int from = 3600*hh+60*mm+ss;
            int to = 3600*gh+60*gm+gs;
            for(int s=from;s<to;s++){
                V[s] += 1;
            }
        }
        cout << *max_element(all(V)) << endl;
    }
    return 0;
}

Measured memory_bytes: 1544
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String s = br.readLine();
		br.close();

		String s1 = s.substring(0, n);
		String s2 = new StringBuilder(s.substring(n)).reverse().toString();
		Map<String, Integer> map1 = new HashMap<>();
		Map<String, Integer> map2 = new HashMap<>();

		int end = 1 << n;
		for (int i = 0; i < end; i++) {
			StringBuilder r1 = new StringBuilder();
			StringBuilder b1 = new StringBuilder();
			StringBuilder r2 = new StringBuilder();
			StringBuilder b2 = new StringBuilder();
			for (int j = 0; j < n; j++) {
				if ((i >> j & 1) == 1) {
					r1.append(s1.charAt(j));
					r2.append(s2.charAt(j));
				} else {
					b1.append(s1.charAt(j));
					b2.append(s2.charAt(j));
				}
			}
			addCntMap(map1, r1.append('-').append(b1).toString());
			addCntMap(map2, r2.append('-').append(b2).toString());
		}

		long ans = 0;
		for (String key : map1.keySet()) {
			if (map2.containsKey(key)) {
				ans += (long) map1.get(key) * map2.get(key);
			}
		}
		System.out.println(ans);
	}

	static void addCntMap(Map<String, Integer> map, String key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
}


Measured memory_bytes: 164668