akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[1010][1010];
vector<int> G[1000010];
int H[1000010];
int D[1000010];
set<int> U;

signed main(){
	cin>>N;
	REP(i,N){
		REP(j,N-1){
			cin>>A[i][j];
			A[i][j]--;
		}
	}
	REP(i,N){
		REP(j,N-2){
			int s=min(i,A[i][j]);
			int t=max(i,A[i][j]);
			int z=1000*s+t;
			s=min(i,A[i][j+1]);
			t=max(i,A[i][j+1]);
			int z2=1000*s+t;
			G[z].push_back(z2);
			H[z2]++;
			U.insert(z);U.insert(z2);
		}
	}
	stack<int> st;
	for(int x:U){
		if(H[x]==0){
			st.push(x);
		}
	}
	DEB(st.size())END
	vector<int> G2;
	while(!st.empty()){
		int p=st.top();
		st.pop();
		G2.push_back(p);
		for(auto x:G[p]){
			H[x]--;
			if(H[x]==0){
				st.push(x);
			}
			D[x]=max(D[x],D[p]+1);
		}
	}
	if(G2.size()!=U.size()){
		cout<<-1<<endl;
		return 0;
	}
	int ans=0;
	for(int x:U){
		ans=max(ans,D[x]);
	}
	ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 92016
temp=input().split(' ')
a,b,c,k=map(int,temp)
sum=0;
if(a>0):
  if(a<k):
    sum+=a
  else:
    sum+=k
  k-=sum
if(k>0):
  if(b<k):
    k-=b
  else:
    k=0
if k>0:
  sum-=k
print(sum)

Measured memory_bytes: 9100
#include<iostream>
#include<string>
#define MAX 64
using namespace std;
int main()
{
  while(true){
    long long int N;
    long long int K;
    bool tile[MAX+2][MAX+2];
    cin >> N >> K;
    if( N == 0 && K == 0 ) break;
    if( K>(1LL<<(N/2)) || N%2==1 ){ cout << "No\n" << endl; continue; }
    --K;
    for(long long int j = N-1; j >= 0; --j){
      tile[1][j+1]=(K&(1LL<<((N-1-j)/2)));
      tile[0][j+1]=!tile[1][j+1];
    }
    tile[1][0]=!tile[1][1];
    tile[1][N+1]=!tile[1][N];

    for(int i = 1; i < N; ++i){
      for(int j = 0; j < N; ++j){
	bool L=tile[i][j],C=tile[i][j+1],R=tile[i][j+2],T=tile[i-1][j+1];
	tile[i+1][j+1]=( (!T && !L && !C &&  R) ||
			 (!T && !L &&  C && !R) ||
			 (!T && !L &&  C &&  R) ||
			 (!T &&  L && !C && !R) ||
			 (!T &&  L &&  C && !R) ||
			 ( T && !L && !C && !R) ||
			 ( T && !L &&  C && !R) );
	//  0
	// 001 = 1

	//  0
	// 010 = 1

	//  0
	// 011 = 1

	//  0
	// 100 = 1

	//  0
	// 101 = 0
	
	//  0
	// 110 = 1
	
	//  0
	// 111 = 0
	
	//  1
	// 000 = 1

	//  1
	// 001 = 0

	//  1
	// 010 = 1

	//  1
	// 011 = 0
	
	//  1
	// 100 = 0

	//  1
	// 110 = 0
      }
      tile[i+1][0]=!tile[i+1][1];
      tile[i+1][N+1]=!tile[i+1][N];
    }
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N; ++j){
	cout << (tile[i+1][j+1]?'E':'.');
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod


int main(){
    ll N,M,K; cin>>N>>M>>K;
    vec A,B;
    A.pb(0); B.pb(0);
    rep(i,N){
        ll x; cin>>x;
        A.pb(A[i]+x);
    }
    rep(i,M){
        ll x; cin>>x;
        B.pb(B[i]+x);
    }
    ll ans=0;
    ll a=0, b=M;
    while(a<=N && b>=0){
        if(A[a]+B[b]>K) b--;
        else{
            ans=max(a+b,ans);
            a++;
        }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 7988
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

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

	bool flag = false;
	for (int i = A; i <= B; i++)
	{
		if (i % K == 0) {
			flag = true;
			break;
		}
	}

	if (flag) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
}




Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

string convi(string s) {
	char a[] = { '0','1','2','3','5','7','8','9' };
	string ret;
	for (auto c : s) {
		ret += a[c - '0'];
	}
	return ret;
}

int main() {
	int n;
	while (cin >> n && n) {
		stringstream ss;
		ss << oct << n;
		string s = ss.str();
		s = convi(s);
		Cout(s);
	}
}


Measured memory_bytes: 3112
from bisect import*
A,B=abs,bisect
a,b,q,*l=map(int,open(0).read().split())
f=2**60
s,t=[-f]+l[:a]+[f],[-f]+l[a:a+b]+[f]
for x in l[a+b:]:
  m=f
  i,j=B(s,x),B(t,x)
  for v in s[i-1:i+1]:
    for w in t[j-1:j+1]:
      m=min(m,A(x-v)+A(v-w),A(x-w)+A(w-v))
  print(m)

Measured memory_bytes: 38660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
char s[402][402];
bool vis[402][402];
int dir[4][2]={
    0,1,
-1,0,   1,0,
    0,-1
};
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,m,c1,c2;
    ll ans = 0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>s[i]+1;
	for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(!vis[i][j] && s[i][j] == '#'){
                c1 = c2 = 0;
                queue<pair<int,int> > Q;
                Q.push(make_pair(i,j));
                vis[i][j] = 1;
                while(!Q.empty()){
                    pair<int,int> t = Q.front(),tt;
                    Q.pop();
                    if(s[t.first][t.second] == '#')
                        c1++;
                    c2++;
                    for(int k=0;k<4;k++){
                        tt = make_pair(t.first+dir[k][0],t.second+dir[k][1]);
                        if(tt.first>0 && tt.first<=n && tt.second>0 && tt.second<=m )
                            if(!vis[tt.first][tt.second] && s[t.first][t.second]!=s[tt.first][tt.second])
                                Q.push(tt),vis[tt.first][tt.second] = 1;
                    }
                }
                ans += 1ll*c1*(c2-c1);
            }
        }
	}
	cout<<ans<<endl;

	return 0;
}


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

typedef long long ll;
const int INF = 1e9;

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

const int L = 1000001;

// iを作るのに必要な正四面体数
int dp[L] = {};
int odp[L] = {};
// 正四面体数: 1 4 10 20 35 ...
int x[L] = {};
int ox[L] = {};

int main() {

	int xsize = 0, oxsize = 0;
	for( int i = 1; i * ( i + 1 ) * ( i + 2 ) / 6 <= L; i++ ) {
		x[i] = i * ( i + 1 ) * ( i + 2 ) / 6;
		xsize++;
		if( x[i] % 2 == 1 ) {
			ox[oxsize++] = x[i];
		}
	}

	REP( i, L ) dp[i] = odp[i] = i;

	REP( i, L ) {
		REP( j, xsize ) {
			if( i < x[j] ) break;
			dp[i] = min( dp[i - x[j]] + 1, dp[i] );
		}
		REP( j, oxsize ) {
			if( i < ox[j] ) break;
			odp[i] = min( odp[i - ox[j]] + 1, odp[i] );
		}
	}

	int n;
	while( cin >> n, n ) {
		cout << dp[n] << " " << odp[n] <<  endl;
	}
	
}


Measured memory_bytes: 10816
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

r = float(input())

ans = math.pi*2*r
print(ans)






Measured memory_bytes: 10376
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int N,M; cin >> N >> M; //N桁,M個の条件
    vector <P> p(M);
    rep(i,M) cin >> p[i].first >> p[i].second;
    
    rep(i,1000){
        string S=to_string(i);
        int keta=S.length();
        if(keta!=N) continue;
        
        bool ans=true;
        rep(i,M){
            if((S[p[i].first-1])!=p[i].second+'0') ans=false;
        }
        
        if(ans){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;   
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a') {
  cout << "vowel" << endl;
  }
  else if (c == 'i') {
  cout << "vowel" << endl;
  }
  else if (c == 'u') {
  cout << "vowel" << endl;
  }
  else if (c == 'e') {
  cout << "vowel" << endl;
  }
  else if (c == 'o') {
  cout << "vowel" << endl;
  }
  else {
  cout << "consonant" << endl;
  }
}

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

int N, M, C;
vector<vector<int> > A(20, vector<int>(20));
int B[20];
int correct = 0;

int main(){
    cin >> N >> M >> C;
    for (int i = 0; i < M; i++) cin >> B[i];
    for (int i = 0; i < N; i++)
    {
        // printf("%d\n", i);
        int tmp = 0;
        for (int j = 0; j < M; j++)
        {
            cin >> A.at(i).at(j);
            tmp += A.at(i).at(j) * B[j];
            /* code */
        }
        if(tmp + C > 0){
            correct++;
        }    
    }
    cout << correct << endl;
    
    
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] s = new int[n];
        int[] t = new int[m];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            t[i] = sc.nextInt();
        }
        int mod = 1_000_000_007;
        long[][] dp = new long[n+1][m+1];
        long[][] sum = new long[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if(s[i-1] == t[j-1]) dp[i][j] = (sum[i-1][j-1] + 1) %mod;
                sum[i][j] = (sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j] +mod) %mod;
            }
        }
        System.out.println(sum[n][m] + 1);
        sc.close();

    }

}


Measured memory_bytes: 129688
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int m,d,i,cnt=0,t,d1=0,j,d10=0;
    cin>>m>>d;
    for(i=1;i<=m;i++)
    {
    	for(j=1;j<=d;j++)
    	{
    		if(j>=10)
    		{
    			t=j;
    			d1=t%10;
    			t/=10;
    			d10=t%10;
    			if((d1>=2&&d10>=2)&&((d1*d10)==i))
    			cnt++;
			}
		}
	}
	cout<<cnt;
	return 0;
}

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

int main(void){
  int n;
  scanf("%d", &n);
  int k;
  scanf("%d", &k);
  int key = 0;
  double lg2 = log2(k);
  double area = ceil(lg2);
  int a = area;
  double sum = 0;
  int i = 0;
  int now = 0;
  int count = 0;
  for(i=1; i<n+1; i++){
    now = i;
    while (now<k){
      now = now*2;
      count++;
    }
    sum = sum + (double)1/n * pow(0.5, count);
    count = 0;
  }
  printf("%.15lf", sum);
  return 0;
}

Measured memory_bytes: 128
<?php

fscanf(STDIN, "%d %d", $n, $m);
$A = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d %d", $a, $b);
    $A[$m - $a][] = $b;
}

$pq = new SplPriorityQueue();
$sum = 0;
for ($i = $m - 1; $i >= 0; --$i) {
    if (isset($A[$i])) {
        foreach ($A[$i] as $job) {
            $pq->insert($job, $job);
        }
    }

    if ($pq->valid()) {
        $sum += $pq->extract();
    }
}

echo $sum;


Measured memory_bytes: 55800
#include<stdio.h>
#define MAX 100
#define INF (1<<21)
#define RED 0
#define YELLOW 1
#define BLUE 2

int n,A[MAX][MAX];

int prim()
{
  int i,j,t,min;
  int a[MAX],b[MAX],color[MAX];

  for(i=0;i<n;i++)
    {
      a[i]=INF;
      b[i]=-1;
      color[i]=RED;
    }
  a[0]=0;

  while(1)
    {
      min=INF;
      t=-1;
      for(i=0;i<n;i++)
	{
	  if(min>a[i]&&color[i]!=BLUE)
	    {
	      t=i;
	      min=a[i];
	    }
	}
      if(t==-1) break;
      color[t]=BLUE;
      for(j=0;j<n;j++)
	{
	  if(color[j]!=BLUE && A[t][j]!=INF)
	    {
	      if(a[j]>A[t][j])
		{
		  a[j]=A[t][j];
		  b[j]=t;
		  color[j]=YELLOW;
		}
	    }
	}
    }
  int total=0;
  for(i=0;i<n;i++)
    {
      if(b[i]!=-1) total+=A[i][b[i]];
    }
  return total;
}

int main()
{
  scanf("%d",&n);

  int i,j,num;
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  scanf("%d",&num);
	  if(num==-1)A[i][j]=INF;
	  if(num!=-1)A[i][j]=num;
	}
    }
  printf("%d\n",prim());
  return 0;
}
	    

Measured memory_bytes: 636
#include<stdio.h>
int main()
{
	int i,u,a0,a1=0,a2=0,kioku[28];
	for(i=0; i<28; i++)
	{
		scanf("%d",&kioku[i]);
	}
	for(u=1; u<=30; u++)
	{
		a0=0;
		for(i=0; i<28; i++)
		{
			if(kioku[i]==u)
				a0=1;
		}
		if(a0==0)
		{
			if(a1==0)
			{
				a1=u;
			}
			else
			{
				a2=u;
				break;
			}
		}
	}

	if(a1<a2)
	{
		printf("%d\n%d\n",a1,a2);
	}
	else
	{
		printf("%d\n%d\n",a2,a1);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>



using namespace std;




int main(){
    int N;
    int M;
   
    cin>>N>>M;
    
    int A[M];
    
    for(int i=0;i!=M;++i){
        cin>>A[i];
    }
    
    
    
    for(int i=0;i!=M;++i){
        N= N-A[i];
        if(N<0){
            break;
        }
    }
    
    if(N>=0){
        cout<<N<<endl;
    }else{
        cout<<-1<<endl;
    }
    

    
}



Measured memory_bytes: 3660
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    ll n,x[60],y[60];
    cin>>n;
    ll ans=n;
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    rep(i,n){
        rep2(j,i+1,n){
            ll p=x[i]-x[j],q=y[i]-y[j];
            ll ans1=n;
            rep(k,n){
                rep(l,n){
                    if(k!=l){
                        ll p0=x[k]-x[l],q0=y[k]-y[l];
                        if(p0==p &&  q0==q){
                            ans1--;
                        }
                    }
                }
            }
            ans=min(ans,ans1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    long long h, w;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1 << endl;
    }
    else if( h%2 == 0 || w%2 == 0 ){
        cout << h*w/2 << endl;
    }
    else{
        cout << h*w/2 + 1 << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

string s1,s2;
int dp[3005][3005];
stack <char>res;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>s1>>s2;
    int n=s1.size();int m=s2.size();
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i!=0 && j!=0){
                if(s1[i-1]==s2[j-1])dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    int i=n;int j=m;
    while(i>0 && j>0){
        if(s1[i-1]==s2[j-1]){
            res.push(s1[i-1]);
            i--;j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1])i--;
            else j--;
        }
    }
    while(!res.empty()){
        cout<<res.top();
        res.pop();
    }
}

Measured memory_bytes: 35456
n = int(input())
k = int(input())
x = list(map(int,input().split()))
sum=0
for i in range(n):
  if abs(x[i])<=abs(k-x[i]):
    sum += 2*abs(x[i])
  else:
    sum += 2*abs(k-x[i])
print(sum)

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

#define fi first
#define se second
#define ll long long

const int N = 303;
const int mod = 998244353;

using namespace std;

int n, k;
int d[N][N];
int f[N][N];
int rem;
string s;

void add(int &x, int y)
{
        x += y;
        if(x >= mod){
                x -= mod;
        } else if(x < 0){
                x += mod;
        }
}

void make(int x)
{
        rem -= x;
        for(int i = 0; i <= k; i++){
                for(int j = 0; j <= i; j++){
                        for(int h = min(x, i - j); h >= 0; h--){
                                add(f[i][j + h], d[i][j]);
                        }
                        for(int h = min(rem, k - i); h > 0; h--){
                                add(f[i + h][j], d[i][j]);
                        }
                }
        }
        for(int i = 0; i <= k; i++){
                for(int j = 0; j <= k; j++){
                        d[i][j] = f[i][j];
                        f[i][j] = 0;
                }
        }
}

int main()
{
        ios_base::sync_with_stdio(0);

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

        cin >> s >> k;
        n = s.size();
        k = min(k, n);
        rem = n;

        vector < int > a = {0};
        for(int i = 0; i < n; i++){
                if(s[i] == '0'){
                        a.push_back(0);
                } else{
                        a.back() += 1;
                }
        }
        n = a.size();
        d[0][0] = 1;
        for(int x: a){
                make(x);
        }
        int res = 0;
        for(int i = 0; i <= k; i++){
                add(res, d[i][i]);
        }

        cout << res << "\n";
}


Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
string station(string s)
{
  int a=0,b=0;
  string res;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='A')
      a++;
    else
      b++;
  }
  if(a==3||b==3)
    res="No";
  else
    res="Yes";
  return res;
}
int main()
{
  string s,res;
  getline(cin,s);
  res=station(s);
  cout<<res;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
bool f0,f1,f2,f3;
int main()
{
	cin>>s;
	for (int i=0;i<s.size();i++)
	{
		if (s[i]=='N')
		{
			f0=true;
		}
		else if (s[i]=='S')
		{
			f1=true;
		}
		else if (s[i]=='W')
		{
			f2=true;
		}
		else
		{
			f3=true;
		}
	}
	if ((f0^f1) || (f2^f3))
	{
		puts("No");
	}
	else
	{
		puts("Yes");
	}
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    h,w = I2()
    s = [S() for _ in range(h)]
    for i in range(1,h-1):
        for j in range(1,w-1):
            if(s[i][j] == "#" and s[i][j-1]!="#" and s[i][j+1]!="#" and s[i-1][j]!="#" and s[i+1][j] != "#"):
                print("No")
                exit()
    print("Yes")

Measured memory_bytes: 9228
using System;
using System.Linq;

namespace agc014_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] n = new int[x[0]];
            for (int i = 0; i < x[1]; i++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                n[a[0] - 1]++; n[a[1] - 1]++;
            }
            bool ok = true;
            for (int i = 0; i < x[0]; i++)
            {
                if (n[i] % 2 == 1) ok = false;
            }
            Console.WriteLine(ok ? "YES" : "NO");
        }
    }
}

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

vector<intl> dp(1e5+3,-1);

intl fun(intl i,intl n,vector<intl>&ar,intl k){
    if(dp[i]!=-1){
        return dp[i];
    }
    if(i==n-1){
        dp[i]=0;
    }
    else{
        intl mn1=1e9;
        for(intl j=1;j<=k;j++){
            if(j+i<n){
                dp[j+i]=fun(j+i,n,ar,k);
                intl x=abs(ar[i]-ar[i+j]);
                x+=dp[j+i];
                mn1=min(mn1,x);
            }
        }
        dp[i]=mn1;
    }
    return dp[i];
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    intl i,j,n,k;
    cin>>n>>k;
    vector<intl> ar(n);
    for(i=0;i<n;i++){
        cin>>ar[i];
    }
    cout<<fun(0,n,ar,k)<<"\n";
}

Measured memory_bytes: 12700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=32;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r;
	scanf("%d",&r);
	double pi=acos(-1.0);
	printf("%.6f\n",2*pi*r);
	return 0;
}

Measured memory_bytes: 3816
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(){
	int a, b;
	scanf("%d %d\n", &a, &b);
	if(a%2 == 0 || b%2 == 0) {
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int width = sc.nextInt();
			calcArea(width);
		}
	}

	public static void calcArea(int width) {
		int sum = 0, d = width;

		for (int i = 1; d * i <= 600 - d; i++) {
			sum += Math.pow(d * i, 2) * d;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, D;
  cin >> N >> D;
  int ans = 0;
  for(int i=0; i<N; i++){
    int64_t x, y;
    cin >> x >> y;
    if(x*x + y*y <= D*D){
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3632
import java.util.Scanner;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine(); // String Sを受け取る
		sc.close(); // 標準入力を終了

		if (S.endsWith("s")) {
			// sで終わる
			System.out.println(S + "es");
		} else {
			System.out.println(S + "s");
		}
	}

}

Measured memory_bytes: 38488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string s;
  cin >> s;
  
  int co = 0;
  
  if(s[0]=='1') co += 1;
  if(s[1]=='1') co += 1;
  if(s[2]=='1') co += 1;
  cout << co << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
   int a, b, c, d, low, low1;
   scanf("%d", &a);
   scanf("%d", &b);
   scanf("%d", &c);
   scanf("%d", &d);

   if (a < b) {
      low = a;
   } else {
       low = b;
   }
   if (c < d) {
      low1 = c;
   } else {
       low1 = d;
   }

   printf("%d", low + low1);
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    VI a(2); cin >> a;
    FOR(i, 1, 4) {
        bool ng = false;
        FOR(j, 0, 2)ng |= a[j] == i;
        if (!ng) {
            cout << i << "\n";
            return 0;
        }
    }
}

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

int main() {
  int H, W;

  cin >> H >> W;

  string str[H];
  vector<vector<char>> output(H+2, vector<char>(W+2, '#'));

  for (int i=0; i<H; i++) {
    cin >> str[i];
  }

  for (int j=0; j<H; j++) {
    for (int k=0; k<W; k++) {
      output.at(j+1).at(k+1) = str[j][k];
    }
  }

  for (int l=0; l<H+2; l++) {
    for (int m=0; m<W+2; m++) {
      cout << output.at(l).at(m);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int h,w;
char maze[1010][1010];
int d[1010][1010];
int dh[4] = {0,0,1,-1};
int dw[4] = {1,-1,0,0};
int main() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      d[i][j] = -1;
    }
  }
  for (int i = 0; i < h; i++) {
    cin >> maze[i];
  }
  queue<pair<int,int>> que;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (maze[i][j] == '#') {
        d[i][j] = 0;
        que.push({i,j});
      }
    }
  }
  int ans = 0;
  while (!que.empty()) {
    pair<int,int> tp = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int th = tp.first + dh[i];
      int tw = tp.second + dw[i];
      if (th < 0 || th >= h || tw < 0 || tw >= w) continue;
      if (d[th][tw] != -1) continue;
      d[th][tw] = d[tp.first][tp.second] + 1;
      ans = max(ans, d[th][tw]);
      que.push({th,tw});
    }
  }
  cout << ans << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/

Measured memory_bytes: 13456
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int  i = 0; i < n; i++)
    {
        cin >> l.at(i);
    }
    
    sort(l.begin(),l.end());
    
    int count =0;
    for (int  i = 0; i < n-2; i++)
    {
        for (int  j = i; j < n-1; j++)
        {
            for (int  k = j; k < n; k++)
            {
                if(l.at(i)+l.at(j)>l.at(k) && l.at(i)!=l.at(j) && l.at(j)!=l.at(k)){
                    count++;
                }
            }
            
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long[] ab = new long[2];
        ab[0] = sc.nextLong();
        ab[1] = sc.nextLong();
        Arrays.sort(ab);
        if (ab[0] >= 3) {
            System.out.println((ab[0] - 2) * (ab[1] - 2));
            return;
        }
        if (ab[0] == 2) {
            System.out.println(0);
            return;
        }
        if (ab[1] == 1) {
            System.out.println(1);
        } else {
            System.out.println(ab[1] - ab[0] - 1);
        }
    }

}


Measured memory_bytes: 21844
S = input()


def yymm(S):
    yy = int(S[:2])
    mm = int(S[2:])
    return yy >= 0 and (mm >= 1 and mm <= 12)


def mmyy(S):
    mm = int(S[:2])
    yy = int(S[2:])
    return yy >= 0 and (mm >= 1 and mm <= 12)


if yymm(S) and mmyy(S):
    print("AMBIGUOUS")
elif yymm(S):
    print("YYMM")
elif mmyy(S):
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        n: usize
    };
    let mut ans = 0;
    for i in 1..=n {
        if !(i % 3 == 0 || i % 5 == 0) {
            ans += i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2116
#include<stdio.h>
#include<stdlib.h>
int compare_int(const void *a,const void *b){
  return *(int *)b-*(int *)a;
}
int main (void)
{
  int n;//配列のサイズ
  int i=0,ans=0;
  scanf("%d",&n);
  int data[n];
  for(int i=0;i<n;i++){
    scanf("%d",&data[i]);
  }

  qsort(data,n,sizeof(int),compare_int);
  for(int i=0;i<n;i++){
    if(i%2==0){
      ans+=data[i];
    }else{
      ans-=data[i];
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
/*
 * FILE: ABC 128A.cpp
 *
 * @author: Piyush Kanti Das <piyush123kantidas[at]gmail[dot]com>
 *
 * LINK:
 *
 * DATE CREATED: 03.06.2019 00:05:04 +06
 *
 * DESCRIPTION:
 *
 * DEVELOPMENT HISTORY:
 * Date         Version     Description
 * --------------------------------------------------------------
 * 03-06-2019	1.0         File Created
 *
 */


/*
// _______________________________________________________________/\\\_________
//  ______________________________________________________________\/\\\_________
//   ___/\\\\\\\\\___/\\\____/\\\__/\\\____________________________\/\\\_________
//    __/\\\/////\\\_\///____\//\\\/\\\___/\\\____/\\\__/\\\\\\\\\\_\/\\\_________
//     _\/\\\\\\\\\\___/\\\____\//\\\\\___\/\\\___\/\\\_\/\\\//////__\/\\\\\\\\\\__
//      _\/\\\//////___\/\\\_____\//\\\____\/\\\___\/\\\_\/\\\\\\\\\\_\/\\\/////\\\_
//       _\/\\\_________\/\\\__/\\_/\\\_____\/\\\___\/\\\_\////////\\\_\/\\\___\/\\\_
//        _\/\\\_________\/\\\_\//\\\\/______\//\\\\\\\\\___/\\\\\\\\\\_\/\\\___\/\\\_
//         _\///__________\///___\////_________\/////////___\//////////__\///____\///__
//
*/

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

typedef long long           ll;
typedef double              lf;
typedef unsigned long long  ull;
typedef pair<int, int>      pii;
typedef vector<pii>         vpii;
typedef vector<int>         vi;
typedef vector<long long>   vll;

#define __FastIO        ios_base::sync_with_stdio(false); cin.tie(0)

#define forr(i, a, b)   for (__typeof (a) i=a; i<=b; i++)
#define rof(i, b, a)    for (__typeof (a) i=b; i>=a; i--)
#define rep(i, n)       for (__typeof (n) i=0; i<n; i++)
#define forit(i, s)     for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define all(ar)         ar.begin(), ar.end()

#define fill(ar)   		memset(ar, -1, sizeof(ar))
#define clr(a)          memset(a, 0, sizeof(a))

#define nl              cout << '\n';
#define sp              cout << ' ';
#define ckk             cout << "##########\n"

#define pb              push_back
#define MP 				make_pair

#define debug1(x)       cerr << #x << ": " << x << endl
#define debug2(x, y)    cerr << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl

#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define MAX             100005

int Set(int N,int pos){return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}


ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;
    
    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}

//Auto-format --> ctrl+shift+a
/********************* Code starts here ************************/

int main() {
    __FastIO;   //Be aware to use it!
  
  ll a, p;
  
  cin >> a >> p;
  
  ll sum = a*3 + p;
  cout << sum/2LL << endl;
	
    return 0;
}


Measured memory_bytes: 256
n = int(input())
import itertools
res = []
A = ['', '3', '5', '7']
for p in itertools.product(A, repeat=10):
    p = list(p)
    p = ''.join(p)
    if p.count('3') == 0 or p.count('5') == 0 or p.count('7') == 0:
        continue
    p = int(p)
    res.append(p)
res = list(set(res))
#print(res[0:10])
cnt = 0
for i in res:
    if i <= n:
        cnt += 1
print(cnt)


Measured memory_bytes: 144888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String input=new Scanner(System.in).nextLine();
		if(input.equals("Sunny")) {
			System.out.println("Cloudy");
		}else if(input.equals("Cloudy")) {
			System.out.println("Rainy");
		}else {
			System.out.println("Sunny");
		}
	}
}

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

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> a(N);

    rep(i,N) {
        string S;
        cin >> S;
        a.at(i) = S; 
    }

    string lib;
    rep (i, N) {
        sort(a.begin(), a.end());
        lib += a.at(i);
    }
    cout << lib << endl;

    return 0;
}

Measured memory_bytes: 3644
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b] <- readInts
  print . ceiling $ fromIntegral (a + b) / 2

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine


Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;

template<typename Type>
class RMQ {
private:
	int size_; std::vector<Type> dat;
public:
	RMQ() : size_(0), dat(std::vector<Type>()) {};
	RMQ(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat.resize(size_ << 1, std::numeric_limits<Type>::max());
	}
	template<class T>
	RMQ(T begin_, T end_) {
		int n = end_ - begin_;
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
		for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
		for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
	}
	inline unsigned size() { return size_; }
	inline void update(int i, Type x) {
		i += size_; dat[i] = x;
		while (i > 1) {
			i >>= 1;
			dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	inline Type query(int l, int r) {
		Type ret = std::numeric_limits<Type>::max();
		l += size_; r += size_;
		while (l != r) {
			if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1;
			if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1;
		}
		return ret;
	}
};

int n, q, b[200009], l[200009], r[200009], dp[200009], sum; vector<int>V[200009];

int main() {
	cin >> n; for (int i = 1; i <= n; i++) { cin >> b[i]; sum += b[i]; if (b[i] == 0) b[i] = -1; else b[i] = 1; }
	for (int i = 1; i <= n; i++) { b[i] += b[i - 1]; }
	cin >> q;
	for (int i = 1; i <= q; i++) {
		cin >> l[i] >> r[i];
		V[l[i]].push_back(r[i]);
	}
	RMQ<int>X(n + 3);
	for (int i = 1; i <= n; i++) { X.update(i, (1 << 30)); dp[i] = (1 << 30); }
	X.update(0, 0);
	int V1 = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < V[i].size(); j++) {
			int p1 = i, p2 = V[i][j];
			dp[p2] = min(dp[p2], X.query(p1, p2 + 1) - b[p2]);
			dp[p2] = min(dp[p2], V1 + (b[p1 - 1] - b[p2]));
			X.update(p2, dp[p2] + b[p2]);
		}
		V1 = min(V1, dp[i]);
	}
	int minx = 0; for (int i = 1; i <= n; i++) minx = min(minx, dp[i]);
	cout << sum + minx << endl;
	return 0;
}

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

using namespace std;

#define INF 100

int main(){
  int n;
  cin >> n;
  
  vector<string> s(n);
  for(int i = 0; i < n; i++) cin >> s[i];
  
  int ch[n][26];
  for(int i = 0; i < n; i++) for(int j = 0; j < 26; j++) ch[i][j] = 0;
  
  for(int i = 0; i < n; i++) for(char c : s[i]) ch[i][c - 'a']++;
  
  for(int j = 0; j < 26; j++){
    int min_ch = INF;
    for(int i = 0; i < n; i++) min_ch = min(ch[i][j], min_ch);
    
    for(int i = 0; i < min_ch; i++) cout << (char)('a' + j);
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();

      if (a == b && b == c) {
         System.out.println("Yes");
      } else {
         System.out.println("No");
      }
   }
}


Measured memory_bytes: 23124
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 1000000007
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    m, n = LI()

    # print(pow(m, n, MOD))
    def f(m, n, p):
        if n==1:
            return m
        else:
            if n%2==0:
                return (f(m, n//2, p)**2) % p
            else:
                return (f(m, n//2, p)**2*m) % p
    print(f(m, n, MOD))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 6000
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,a,b;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Twinkle Twinkle Little Star
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCanYouSolveThis solver = new BCanYouSolveThis();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCanYouSolveThis {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int c = in.nextInt();
            int B[] = new int[m];
            int A[] = new int[m];
            for (int i = 0; i < m; i++) {
                B[i] = in.nextInt();
            }
            int count = 0;
            while (n-- != 0) {
                int sum = 0;
                for (int i = 0; i < m; i++) {
                    A[i] = in.nextInt();
                    sum += A[i] * B[i];
                }
                if (sum + c > 0) count++;
            }
            out.println(count);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21332
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 87;
const LL MOD = (LL)1e9 + 7;
int G[MAXN][MAXN];
LL dp[MAXN][MAXN][MAXN][2];
bool visit[MAXN][MAXN][MAXN][2];
map<LL, int> mp;
int idx = 0;
LL N, K;

LL add(LL cur, LL x) {
   return (cur + x) % MOD;
}

LL dfs(int f, int t, LL dis) {
   LL offs = dis % 2;
   dis = (dis / 2) * 2;
   if (!mp.count(dis)) mp.insert(make_pair(dis, idx++));
   int cur = mp[dis];
   if (visit[f][t][cur][offs]) return dp[f][t][cur][offs];
   visit[f][t][cur][offs] = 1;
   if (dis + offs == 1) return dp[f][t][cur][offs] = G[f][t];
   LL ans = 0;
   if (offs) {
      for (int i = 0; i < N; i++) {
          if (G[f][i]) {
             ans = add(ans, dfs(i, t, dis));
          }
      }
   } else {
      for (int i = 0; i < N; i++) {
          LL tmp = (dfs(f, i, dis / 2) * dfs(i, t, dis / 2)) % MOD;
          ans = add(ans, tmp);
      }
   }
   return dp[f][t][cur][offs] = ans;
}

int main() {
    scanf("%lld %lld", &N, &K);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            scanf("%d", &G[i][j]);
        }
    }
    LL ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ans = add(ans, dfs(i, j, K));
        }
    }
    // for (int i = 0; i < N; i++) {
    //     for (int j = 0; j < N; j++) {
    //         for (LL d = 0; d <= K; d++) {
    //             int offs = d % 2;
    //             LL tmpd = (d / 2) * 2;
    //             int cur = mp[tmpd];
    //             printf("i = %d j = %d dis = %lld ans = %lld\n", i + 1, j + 1, tmpd + offs, dp[i][j][cur][offs]);
    //         }
    //     }
    // }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 7552
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	string w; cin >> w;
	if ( !(1 <= w.size () && w.size () <= 100) ) cout << "No" << endl;
	map<char,int> hashset;
	for (int i = 0; i < w.size (); i++) {
		if( !('a' <= w[i] && w[i] <= 'z') ) {
			cout << "No" << endl;
		}
		hashset[w[i]]++;
	}
	for (auto c = hashset.begin(); c != hashset.end(); c++) {
		if (c->second % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main() 
{
	string s;

	cin >> s;

	int i;
	if (s.size() != 26)
	{
		for (char moji = 'a'; moji <= 'z'; moji++)
		{
			for (i = 0; i < s.size(); i++)
			{
				if (s[i] == moji)
				{
					break;
				}
			}
			if (i == s.size())
			{
				cout << s + moji << endl;
				return 0;
			}
		}
	}
	else
	{
		for (i = s.size() - 1; i >= 1; i--)
		{
			if (s[i - 1] < s[i])
			{
				char moji = s[i - 1], min = 'z';
				for (int j = i; j < s.size(); j++)
				{
					if (s[j] > moji && min > s[j])
					{
						min = s[j];
					}
				}
				for (int k = 0; k < i - 1; k++)
				{
					cout << s[k];
				}
				cout << min << endl;
				return 0;
			}
		}
	}
		cout << -1 << endl;
}


Measured memory_bytes: 256