akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    long[] A;
    long[][] memo;
    long calc(int l, int r, bool turn)
    {
        if (memo[l][r] != long.MaxValue)
        {
            return memo[l][r];
        }
        if (turn)
        {
            if (r == l)
            {
                return memo[l][r] = A[l];
            }
            return memo[l][r] = Math.Max(A[l] + calc(l + 1, r, false), A[r] + calc(l, r - 1, false));
        }
        else
        {
            if (r == l)
            {
                return memo[l][r] = -A[r];
            }
            return memo[l][r] = Math.Min(-A[l] + calc(l + 1, r, true), -A[r] + calc(l, r - 1, true));
        }
    }
    void solve()
    {
        int N = cin.nextint;
        A = cin.scanlong;
        memo = new long[N][];
        for (int i = 0; i < N; i++)
        {
            memo[i] = new long[N];
            for (int j = 0; j < N; j++)
            {
                memo[i][j] = long.MaxValue;
            }
        }

        WriteLine(calc(0, N - 1, true));
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 85824
#define rep(i,n) for (int i = 0; i < n; i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n; cin >> n;
	vector<ll> a(n),b(n+1,0);
	rep(i, n) cin >> a[i];
	rep(i, n) b[i + 1] = b[i] + a[i];
	sort(b.begin(), b.end());
	ll cnt = 1,ans=0;
	rep(i, n) {
		if (b[i] == b[i + 1]) cnt++;
		else {
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}
	ans += cnt * (cnt - 1) / 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

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

    public static void solve2440() {
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(0 == n){
                break;
            }
            int[] s = new int[n];
            int sum = 0;
            int max = 0;
            int min = 1000;
            int avg = 0;
            for(int i=0; i<n; i++){
                s[i] = sc.nextInt();
                if(s[i]>max){
                    max = s[i];
                }
                if(s[i]<min){
                    min = s[i];
                }
                sum += s[i];
            }
            sum -= (max + min);
            avg = sum /(n-2);
            System.out.println(avg);
        }
    }
}


Measured memory_bytes: 29824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,c;
  string S;
  cin >> N;
  cin >> S;
  for(int i = 0; i < N - 2; i++){
  	string s = S.substr(i, 3);
    if("ABC" == s){
      c++;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n, a, b; cin >> n >> a >> b;
  int d = b - a - 1;
  if (n == 2) outl("Borys"); // ok
  else if (d % 2 == 1) outl("Alice");
  else outl("Borys");
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

void bubbleSort(int* mat,int n);

int main(void){
	int* mat;
	int i,n;

	scanf("%d",&n);
	mat=(int* )malloc(n*sizeof(int));

	for(i=0;i<n;i++) scanf("%d",&mat[i]);
	
	bubbleSort(mat,n);

	free(mat);
	return 0;
}

void bubbleSort(int* mat,int n){
   	int flag = 1;
   	int j;
   	int temp,count=0;
   	                    // ????????£??\????´?????????¨??????
   	while(flag){
     	flag = 0;
     	for(j=n-1;j>0;j--){
       		if(mat[j] < mat[j-1]){
	        	temp=mat[j];
	        	mat[j]=mat[j-1];
	        	mat[j-1]=temp;
   			 	flag = 1;
   			 	count++;
	   		}
     	}
    }
    printf("%d",mat[0]);
	for(j=1;j<n;j++)  printf(" %d",mat[j]);
	printf("\n");
   printf("%d\n",count);

}

Measured memory_bytes: 604
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = Integer.parseInt(sc.next());
  int k = Integer.parseInt(sc.next());
  if (k>=n){
  System.out.println(0);
  }
  int[] m = new int[n];
  long turn = 0;
  if(k<n){
      for (int i = 0; i < n; i++){
  	m[i] = Integer.parseInt(sc.next());
  }
    Arrays.sort(m);
   
    for (int i = 0; i<n-k; i++){
        	turn += m[i];
    }
    System.out.println(turn);
  }
}
}

Measured memory_bytes: 50692
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
     int n, k; cin >>n >> k;
     vector<ll> a(10); 
     for(int i = 0; i < k; ++i){
       int d;cin >>d;;
       a[d]=-1;
     }
     set<int> num;
     for(int i = 0; i < 10; ++i){
       if(a[i]==0)num.insert(i);
     }
  
     int ans = n;
     while(true){
           bool flag = true;
           for(int i = 10; i >=0; --i){
             int keta=pow(10,i);
             if(ans%keta==ans){continue;}
             int tmp = (ans/keta)%10;
             if(num.count(tmp)==0){
               flag =false;
               break;
             }
           }
           if(flag){break;}
           ++ans;   
     }     
     cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  ll N,count=0;
  cin>>N;
  string str;
  cin>>str;
  for(ll i=0;i<N-2;i++){
    if(str.at(i)=='A'){
      if(str.at(i+1)=='B'){
        if(str.at(i+2)=='C'){
          count++;
        }
      } 
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
path = [set() for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    path[a-1].add(b-1)
    path[b-1].add(a-1)

for i in path[0]:
    if n-1 in path[i]:
        print('POSSIBLE')
        exit(0)
print('IMPOSSIBLE')


Measured memory_bytes: 67640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    int x, a;
    cin >> x >> a;
    if (x < a)cout << 0 << endl;
    else cout << 10 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         long A=gl();
         long B=gl();

         long a=f(A-1);
         long b=f(B);
         System.out.print(a^b);



         //System.out.print(sb);
     }

     public static long f(long n) {
    	 if(n<=0)return 0;
    	 if(n==1)return 1;
    	 if(n==2)return 3;
    	 if(n==3)return 0;
    	 long i=2;
    	 while(i<=n) {
    		 i=i*2;
    	 }
    	 i=i/2;

    	 long ret=0;
    	 if((n-i)%2==0) {
    		 ret+=i;
    	 }
    	 ret= ret + f(n-i);
    	 return ret;
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35644
#include<stdio.h>
int main(void){
	int a,b,c;
	int t;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		t = a;
		a = b;
		b = t;
	}
	if(b>c){
		t = b;
		b = c;
		c = t;
	}
		if(a>b){
		t = a;
		a = b;
		b = t;
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}


Measured memory_bytes: 2132
#include <cstdio>
#define s(i) ((int)S[i] - (int)'0')

int main(){
    char S[11];
    scanf("%s", S);
    if(s(5)<1 && s(6)<5) printf("Heisei\n");
    else printf("TBD\n");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()
ans = N

W = []
w = 0
for si in S:
    if si == 'W':
        w += 1
    W.append(w)

e = 0
for i, si in enumerate(S[::-1]):
    if si == 'E':
        e += 1
    ans = min(ans, W[-1 * i - 1] + e - 1)

print(ans)

Measured memory_bytes: 15440
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################


'''
https://img.atcoder.jp/arc101/editorial.pdf
https://atcoder.jp/contests/abc107/submissions/5375441

l → r の順：|xl| + |xr-xl|
r → l の順：|xr| + |xr-xl|
'''


N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = float('inf')
for i in range(N-K+1):
    left = X[i]
    right = X[i+K-1]
    ans = min(ans, abs(left)+abs(right-left), abs(right)+abs(left-right))

print(ans)


Measured memory_bytes: 14168
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
long long n, k, sum;

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

    for (int i = k; i <= n + 1; i++) {
        sum += i * (n - i + 1) + 1;
        if (sum >= MOD)
            sum %= MOD;
    }

    cout << sum;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define REV(i,a,b) for(i=a-1;i>=b;i--)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define mp make_pair
#define ord(v) sort(v.begin(),v.end());
const ll MAXN=2*1e6+10;
#define MAX 2*1e9
#define fi first
#define se second
#define pi 3.141592653589793238
#define rem 1000000007
#define eps 1e-9

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ll k,i;
    cin>>k;
    ll a=7;
    bool b=0;
    rep(i,MAXN)
    {
        if(a%k==0)
        {b=1;
            break;
            
        }
        a*=10;
        a+=7;
        a%=k;
    }
    
    if(b)
        cout<<i+1<<endl;
    else cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second

const int p[22] = { 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,3,9,15,21,5,7 };
//const int q[4] = { 13,14,15,16 };

int main(){
	int N;
	ll a[102] = {};
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&a[i]);
	}
	for(int i = N/2+1 ; i <= N ; i ++){
		a[i] = max( a[i] , 0LL );
	}
	
	ll ret = 0;
	for(int s = 0 ; s < (1<<21) ; ++s){
		ll A[102];
		for(int i = 1 ; i <= N ; ++i){
			A[i] = a[i];
		}
		for(int i = 0 ; i < 21 ; ++i){
			if((s>>i)&1){
				for(int j = p[i] ; j <= N ; j += p[i]){
					A[j] = 0;
				}
			}
		}
		
		for(int i = N/2 ; i >= 1 ; --i){
			ll sum = 0;
			for(int j = i ; j <= N ; j += i){
				sum += A[j];
			}
			if(i == 1){
				ret = max( ret , sum );
				break;
			}
			if(sum < 0){
				for(int j = i ; j <= N ; j += i){
					A[j] = 0;
				}
			}
			/*for(int j = 0 ; j < 2 ; j ++){
				if(i == 2*q[j]){
					sum = A[2*q[j]]+A[3*q[j]]+A[6*q[j]];
					if(sum < 0){
						A[2*q[j]] = 0;
						A[3*q[j]] = 0;
						A[6*q[j]] = 0;
					}
				}
			}*/
		}
		
		
	}
	cout << ret << endl;
}



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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   string s;
   int a;
   cin >> s;
   a = s.size();
   rep(i, a)
   {
      cout << "x";
   }
   cout << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 2010
#define HMAX 2010
#define NMAX 1002
#define SORT(a) sort((a).begin(), (a).end())
#define ALL(a) (a).begin(), (a).end()


//??????????????¢??????????????¨debug()??????????????????
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
	int to,cost;
};

int N,W,H,x1[NMAX],x2[NMAX],y1[NMAX],y2[NMAX],dp[HMAX][WMAX] = {},h,w,ans = 0;
static const int dx[4] = {0,1,0,-1},
dy[4] = {1,0,-1,0};

void compress(vector<ll> &xs, map<ll,ll> &mp){
	SORT(xs);
	xs.erase(unique(ALL(xs)),xs.end());
	for (int i = 0; i < xs.size(); ++i)
	{
		mp[xs[i]] = i;
	}
}

void dfs(int a, int b){
	dp[a][b] = 1;
	for (int i = 0; i < 4; ++i)
	{
		if(a+dx[i] < h && a+dx[i] >= 0 && b+dy[i] < w && b+dy[i] >= 0 && !dp[a+dx[i]][b+dy[i]]){
			dfs(a+dx[i],b+dy[i]);
		}
	}
}

void bfs(ll a,ll b){
	queue<P> que;
	que.push(P(a,b));
	dp[a][b] = 1;
	while(!que.empty()){
		ll j = que.front().first, k = que.front().second;
		que.pop();
		for (int i = 0; i < 4; ++i)
		{
			if(j+dx[i] < h && j+dx[i] >= 0 && k+dy[i] < w && k+dy[i] >= 0 && !dp[j+dx[i]][k+dy[i]]){
				que.push(P(j+dx[i],k+dy[i]));
				dp[j+dx[i]][k+dy[i]] = 1;
			}
		}
	}
}

void dye(int X1, int X2, int Y1, int Y2){
	for (int i = Y1; i < Y2; ++i)
	{
		for (int j = X1; j < X2; ++j)
		{
			dp[j][i] = 1;
		}
	}
}

void solve(){
	vector<ll> xs,ys;
	map<ll,ll> xmp,ymp;
	for (int i = 0; i < N; ++i)
	{
		xs.push_back(x1[i]);
		xs.push_back(x2[i]);
		ys.push_back(y1[i]);
		ys.push_back(y2[i]);
	}
	xs.push_back(0);
	ys.push_back(0);
	xs.push_back(H);
	ys.push_back(W);
	compress(xs,xmp);
	compress(ys,ymp);
	for (int i = 0; i < N; ++i)
	{
		x1[i] = xmp[x1[i]];
		x2[i] = xmp[x2[i]];
		y1[i] = ymp[y1[i]];
		y2[i] = ymp[y2[i]];
		dye(x1[i],x2[i],y1[i],y2[i]);
	}
	h = xmp[H];
	w = ymp[W]; 
	// for (int i = 0; i < h; ++i)
	// {
	// 	for (int j = 0; j < w; ++j)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if(!dp[i][j]){
				ans++;
				// printf("i: %d, j: %d\n",i,j);
				bfs(i,j);
			}
		}
	}

	Fill(dp,0);
	Fill(x1,0);
	Fill(x2,0);
	Fill(y1,0);
	Fill(y2,0);
}

void debug(){

}


int main(){
	while(true){
		cin >> H >> W;
		if(H == 0 && W == 0){
			break;
		}
		cin >> N;
		for (int i = 0; i < N; ++i)
		{
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		}
		solve();
	#ifdef DEBUG
		debug();
	#endif
		cout << ans << "\n";
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 18936
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
ll d;
int main()
{
    //IOS
    while(cin>>d)
    {
        cout<<"Christmas ";
        for(int i=1;i<=25-d;i++)
        {
            cout<<"Eve ";
        }
        cout<<"\n";
    }
}


Measured memory_bytes: 256
/*input
3 5 7
*/
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int const mod = 1e9+7;
int power(int x, int y, int mod = 2e18){ int ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
int gcd(int a , int b){if(a==0)return b;return gcd(b%a,a);}

signed main() {
  IOS;
  int a,b,t;
  cin>>a>>b>>t;
  int ans;
  for(int i=a;i<=t;i+=a){
    ans+=b;
  }
  cout << ans  ;
  
return 0;
}

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

const int N=20,M=2e3;

int n,m,k,ans=INT_MAX;
char a[N][M];

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++) scanf(" %s",a[i]);

	for(int mask=0;mask<(1<<(n-1));mask++)
	{
		int rows=__builtin_popcount(mask)+1,cuts=rows-1;
		vector <int> dp(rows,0);
		bool invalid=false;
		for(int j=0;j<m and not invalid;j++)
		{
			bool ok=true;
			for(int i=0,ptr=0;i<n and ok;i++)
			{
				if(a[i][j]=='1') dp[ptr]++;
				if(dp[ptr]>k) ok=false;
				if(mask&(1<<i)) ptr++;
			}

			if(not ok)
			{
				cuts++;
				for(int i=0;i<rows;i++) dp[i]=0;
				ok=true;
				for(int i=0,ptr=0;i<n and ok;i++)
				{
					if(a[i][j]=='1') dp[ptr]++;
					if(dp[ptr]>k) ok=false;
					if(mask&(1<<i)) ptr++;
				}
				if(not ok)
				{
					invalid=true;
					break;
				}
			}
		}

		if(not invalid) ans=min(ans,cuts);
	}

	printf("%d",ans);
}


Measured memory_bytes: 3732
import sys
sys.setrecursionlimit(10**6)

N,M = map(int,input().split())
p = [list(map(int,input().split())) for _ in range(M)]
dp = [-1]*N
ip = [[] for _ in range(N)]
for i in range(M):
  ip[p[i][1]-1].append(p[i][0]-1)

#閉路がないため同じ頂点は通らない
#i番目の頂点に到達するまでの最長手数をメモ化再帰で求める

def maxpath(i):
  if dp[i] != -1:
    return dp[i]
  a = 0
  for el in ip[i]:
    a = max(a,maxpath(el)+1)
  dp[i] = a
  return a
  
for i in range(N):
  maxpath(i)

print(max(dp))

Measured memory_bytes: 123964
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

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

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

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

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	if N >= 30 {
		out("Yes")
		return
	}
	out("No")
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K,Q;
string S,T;
vector<int> A;
vector<int> B;
vector<vector<int>> ab;
vector<pii> px;
//=============================
void input()
{
    cin>>N>>Q;
    ab.resize(N);
    px.resize(Q);
    rep(i,0,N-1-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        ab[a].push_back(b);
        ab[b].push_back(a);
    }
    rep(i,0,Q-1){
        int p,x;
        cin>>p>>x;
        p--;
        px[i] = make_pair(p,x);
    }

}
//=============================
void func(){}

int anss[200005] = {};
int visited[200005] = {};

void dfs(int cur, int prv){
    visited[cur] = true;
    //
    if (prv != -1){
    anss[cur] += anss[prv];
    }

    for(auto x : ab[cur]){
        if (!visited[x]){
            visited[x] = true;
            dfs(x,cur);
        }
    }


}
//=============================
void solve()
{

    for(auto x : px){
        anss[x.first] += x.second;
    }
    dfs(0,-1);

    // queue<int> q;
    // visited[0] = true;
    // q.push(0);
    // while(!q.empty()){
    //     int cur = q.top();q.pop();

    //     for (auto x : ab[cur]){
    //         if (!visited[x]) {
    //             visited[x] = true;
    //             q.push(x);
    //         }
    //     }
    // }

    rep(i,0,N-1){
        cout<<anss[i] << " ";
    }
    cout<<endl;






}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 25856
def main():
    a, b, k = map(int, input().split())
    for i in range(min(a, b), 0, -1):
        if a % i != 0 or b % i != 0:
            continue
        k -= 1
        if k == 0:
            print(i)
            break


if __name__ == "__main__":
    main()


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

int main(void)
{
    int x, y;

    scanf("%d %d" ,&x, &y);

    for(int i=0; i<=x; i++)
        if((i*2+(x-i)*4)==y)
        {
            printf("Yes");
            return 0;
        }

    printf("No");
    return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint H, W; cin >> H >> W;
    lint ans = (H == 1 or W == 1 ? 1 : (H % 2 == 0 or W % 2 == 0 ? H * W / 2 : H * W / 2 + 1));
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream> 
#include<string>
using namespace std;
int main() 
{
	string s,t;
	cin>>s>>t;
	for(int i=0,l=s.size()-1;i<s.size();i++,l--)
	{
		if(s[i]!=t[l])
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
n,m,c = map(int,input().split())
B = list(map(int,input().split()))

ans = 0
for _ in range(n):
    temp = c
    A = list(map(int,input().split()))
    for i in range(m):
        temp += B[i]*A[i]
    
    if temp > 0:
        ans += 1

print(ans)


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	int T;	cin >> T;
	if (T >= 30)
		cout << "Yes" << '\n';
	else
		cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 3636
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;



int main(void){

    ll N; cin>>N;
    ll ans = 0;
    if(N%2!=0) {
        cout<<0<<endl;
        return 0;
    }
    
    N /= 2;
    for (ll i = 5; i <= N; i*=5) {
        ans += N / i;
        
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int d = Integer.parseInt(br.readLine());
        
        if (d == 25) {
            System.out.println("Christmas");
        }
        if (d == 24) {
            System.out.println("Christmas Eve");
        }
        if (d == 23) {
            System.out.println("Christmas Eve Eve");
        }
        if (d == 22) {
            System.out.println("Christmas Eve Eve Eve");
        }
        
    }
}


Measured memory_bytes: 22612
import queue
class Dinic:
    def __init__(self, v, inf = 1000000007):
        self.V = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [0 for _ in range(v)]
        self.iter = [0 for _ in range(v)]
    def add_edge(self, from_, to, cap):
        self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
        self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})
    def bfs(self, s):
        self.level = [-1 for _ in range(self.V)]
        self.level[s] = 0;
        que = queue.Queue()
        que.put(s)
        while not que.empty():
            v = que.get()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e['cap'] > 0 and self.level[e['to']] < 0:
                    self.level[e['to']] = self.level[v] + 1
                    que.put(e['to'])
    def dfs(self, v, t, f):
        if v == t: return f
        for i in range(self.iter[v], len(self.G[v])):
            self.iter[v] = i
            e = self.G[v][i]
            if e['cap'] > 0 and self.level[v] < self.level[e['to']]:
                d = self.dfs(e['to'], t, min(f, e['cap']))
                if d > 0:
                    e['cap'] -= d
                    self.G[e['to']][e['rev']]['cap'] += d
                    return d
        return 0
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t] < 0 : return flow
            self.iter = [0 for _ in range(self.V)]
            f = self.dfs(s, t, self.inf)
            while f > 0:
                flow += f
                f = self.dfs(s,t, self.inf)

n = int(input())
red=[list(map(int,input().split())) for i in range(n)]
blue=[list(map(int,input().split())) for i in range(n)]

dinic = Dinic(2600)

for i in range(n):
    bx,by = blue[i]
    for j in range(n):
        rx,ry = red[j]
        if rx<bx and ry<by:
            dinic.add_edge(i,j+1000,1)

for i in range(n):
    dinic.add_edge(2000,i,1)
    dinic.add_edge(i+1000,2500,1)

print(dinic.max_flow(2000,2500))

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long D, std::vector<std::vector<long long>> X){
    set<LL> memo;
    REP(i, 1000000) {
        memo.insert((LL)i * i);
    }

    int ans = 0;
    REP(i, N) {
        REP2(j, i+1, N) {
            LL tmp = 0LL;

            REP(k, D) {
                tmp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }

             ans += memo.count(tmp);
        }
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < D ; j++){
            scanf("%lld",&X[i][j]);
        }
    }
    solve(N, D, std::move(X));
    return 0;
}



Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int m_o_4 = 0,un_m_o_4 = 0,m_o_2 = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] % 4 == 0)m_o_4++;
        else if(a[i] % 2 == 0)m_o_2++;
        else un_m_o_4++;
    }
    string ans;
    if(m_o_2 == 0)
    {
        if(m_o_4 + 1 >= un_m_o_4)ans = "Yes";
        else ans = "No";
    }
    else
    {
        if(m_o_4 >= un_m_o_4)ans = "Yes";
        else ans = "No";
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    cin >> s;
    
    map<char, int> mp;
    mp['a'] = 0;
    mp['b'] = 0;
    mp['c'] = 0;
    for(int i = 0; i < s.size(); i++) {
        mp[s[i]] ++;
    }

    if (abs(mp['a']-mp['b']) <= 1 && abs(mp['b']-mp['c']) <= 1  && abs(mp['c']-mp['a']) <= 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
        
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cout << ((i<B)==(j<A)?1:0) << (j==W-1?"\n":"");
		}
	}

	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, K, ans;
	ans = 1;

	cin >> N >> K;

	for (int i = 0; i < N; i++)
	{
		ans = min(ans * 2, ans + K);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		String[] str = new String[100];
		int[][] result = new int[100][2];
		int index = 0;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			
			while( stdIn.hasNext() ){
				str[index] = stdIn.next();
				index++;
			}
			
			int count = 0;
			for(int i = 0; i < index; i++){
				for(int j = 0; j < str[i].length()-2; j++){
					if( str[i].charAt(j) == 'J' ){
						if( str[i].charAt(j+1) == 'O' && str[i].charAt(j+2) == 'I' ){
							result[i][0]++;
						}
					}else if( str[i].charAt(j) == 'I' ){
						if( str[i].charAt(j+1) == 'O' && str[i].charAt(j+2) == 'I' ){
							result[i][1]++;
						}
					}
				}
			}
			for(int i = 0; i < index; i++){
				System.out.println(result[i][0]);
				System.out.println(result[i][1]);
			}
		}finally{
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

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

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

  for (int i =0; true; i++){
    cin >> m >> f >> r;

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

  }

  return 0;
}

Measured memory_bytes: 3064
a,b,n = map(int, input().split())
te = n // b
if b == 1:
    print(0)
else:
    tes = n - (te * b)
    test = te * b - 1
    if  tes > test:
        print(int(a*n/b) - a*int(n/b))
    else:
        print(int(a*test/b) - a*int(test/b))

Measured memory_bytes: 9196
# -*- coding: utf-8 -*-

trial_num = int(input())
stones = list(input())

left_black_stone = 0
right_white_stone = stones.count(".")
min_turn_stones = right_white_stone

for i in range(trial_num):
    if(stones[i] == "#"):
        left_black_stone += 1
    else:
        right_white_stone -= 1

    tmp_min = left_black_stone + right_white_stone
    if(tmp_min < min_turn_stones):
        min_turn_stones = tmp_min


print(min_turn_stones)

Measured memory_bytes: 4840
num = int(input())

count_max = 0
num_max = 0
for i in range(1, num+1):
  tmp = i
  count = 0
  while tmp % 2 == 0:
    tmp = tmp / 2
    count += 1
  if count >= count_max:
    count_max = count
    num_max = i

if num == 1:
  print(1)
else:
  print(num_max)

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

using namespace std;

#define INF 210000000
#define int long long

bool cmp(int a,int b){
		return a > b;
}

signed main() {
		int n;
		cin >> n;
		vector<int> a;
		int cnt = 0;
		int f=0;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				if(tmp == i+1){
						f++;
						if(f != 2){
								cnt++;
						}else f = 0;
				}else f = 0;
		}
		cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ll N;
	cin >>  N;
	int num1,num2,num3;
	string sex1,sex2,sex3;
	bool flag=true;
	num1=0;
	num2=N-1;
	cout << num1 << endl;
	cin >> sex1;
	cout << num2 << endl;
	cin >> sex2;
	if(sex1=="Vacant" or sex2 == "Vacant") flag=false;
	while(flag){
		num3=(num2+num1)/2;
		cout << num3 << endl;
		cin >> sex3;
		if(sex3=="Vacant") flag=false;
		if((num3 - num1 + 1)%2==0){
			if(sex1==sex3){
				num2=num3;
				sex2=sex3;
			}
			else{
				num1=num3;
				sex1=sex3;
			}
		}
		else{
			if(sex1==sex3){
				num1=num3;
				sex1=sex3;
			}
			else{
				num2=num3;
				sex2=sex3;
			}
		}
	}
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

std::vector<long long> binomial_coefficient(long long N){
    /*
    Copyright (c) 2020 0214sh7
    https://github.com/0214sh7/library/
    */
    //const long long MOD = 998244353;
    std::vector<long long> fac;
    std::vector<long long> facIE;
    std::vector<long long> comb;
    for(int i=0;i<=N;i++){
        if(i==0){
            fac.push_back(1);
        }else{
            fac.push_back(i*fac[i-1]%MOD);
        }
    }
    for(int i=0;i<=N;i++){
        long long r=1,b=fac[i],e=MOD-2;
        while(e){
            if(e&1){
                r=(r*b)%MOD;
            }
            b=(b*b)%MOD;
            e >>=1;
        }
        facIE.push_back(r);
    }
    for(int i=0;i<=N;i++){
        long long r=fac[N];
        r = (r*facIE[i])%MOD;
        r = (r*facIE[N-i])%MOD;
        comb.push_back(r);
    }
    return comb;
}

signed main(void){
    int N,M,K;
    cin >> N >> M >> K;
    
    vector<int> nC = binomial_coefficient(N-1);
    
    //REP(i,nC.size()){cout << nC[i] << " ";}cout << endl;
    
    int Ans=0;
    
    int m=1;
    for(int s=N-1;s>=0;s--){
        if(s<=K){
            int num=1;
            num *= nC[s];num%=MOD;
            num *= M;num%=MOD;
            num *= m;num%=MOD;
            
            //cout <<s MM num << endl;
            Ans=(Ans+num)%MOD;
        }
        m = (m * (M-1))%MOD;
    }
    cout << Ans << endl;
    return 0;
}




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

int main(void) {
	char s[100000];
	scanf("%s", &s);
	int len = strlen(s);
	int ans = 0;
	for (int i = 1; i < len; ++i) {
		if (s[i - 1] == s[i]) {
			++ans;
			s[i] = s[i] == '0' ? '1' : '0';
		}
	}
	printf("%d", ans);

	return 0;
}


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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int n;cin>>n;
    vint a(n);vin(a);
    //vint s(n+1,0);
    map<int,int> s;
    rfor(x,a)s[x]++;
    int sum=0;
    repi(i,1,n+1){
        int cnt=s[i];
        sum+=cnt*(cnt-1)/2;
    }
    rep(i,n){
        cout << sum-(s[a[i]]-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
  
long long fact(int);
long long fact(int n) {
  if (n == 0) {
    return 1;
  };
  return n * fact(n - 1);
}
  
int main() {
  int n;
  scanf("%d", &n);
  printf("%lld\n", fact(n));
  
  return 0;
}

Measured memory_bytes: 592
#!/usr/bin/env python3


def next_line():
    return input()


def next_int():
    return int(input())


def next_int_array_one_line():
    return list(map(int, input().split()))


def next_int_array_multi_lines(size):
    return [int(input()) for _ in range(size)]


def next_str_array(size):
    return [input() for _ in range(size)]


def main():
    print((10000 - next_int()) % 1000)


if __name__ == '__main__':
    main()


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

using namespace std;

void insertSort(vector<int> v, int n) {

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

		int k = v[i];
		int j = i-1;

		while (j>=0 && (v[j] > k)) {
			v[j+1] = v[j];
			j--;
		}
		v[j+1] = k;

		for (int ii=0; ii<n; ii++) {
			char c = (ii == n-1) ? '\n' : ' ';
			cout << v[ii] << c;
		}
	}

}

int main() {

	int n, s;
	vector<int> v;

	cin >> n;

	for (int i=0; i<n; i++) {
		cin >> s; 
		v.push_back(s);
	}

	insertSort(v, n);
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <utility>
#include <set>
#include <vector>
#include <queue>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)

int usagi[100002];

int main(){

    int n,a,res=0;
    cin>>n;
    loop(i,n)usagi[i]=-1;
    loop(i,n){
        cin>>a;a--;
        usagi[i]=a;
        if(usagi[a]==i)res++;
    }
    cout<<res<<endl;
    
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int k,x;
    cin >> k >> x;
    if(500*k >= x)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

using namespace std;

long long a, b, v, w, t;

int main() {
	cin >> a >> v >> b >> w >> t;
	if ((v - w) * t >= abs(a - b)) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 3636
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;



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

ll fact(int i) {       
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      
    return a / gcd(a, b) * b ;
}
int keta(ll n) {       
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {   
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

#pragma endregion

signed main() {
    int n;cin >> n;
    vi v(n);rep(i, n) cin >> v[i];
    int p = 0;
    int right = 0;
    int sum = 0;
    rep(left,n) {
        while(right<n&&((p+v[right])==(p^v[right]))) {
            p^=v[right];
            right++;
        }
        sum+=right-left;
        if(right==left) right++;
        else p^=v[left];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4816