akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    K=ii()

    i = 1
    x = 7 % K
    if x == 0:
        print(1)
        exit()

    for i in range(10**6+10):
        x = x*10+7
        x %= K
        if x == 0:
            print(i+2)
            exit()
    
    print(-1)


    # i = 1
    # while True:
    #     x = (7**i) * K
    #     if x % 7 == 0:
    #         y = x // 7
    #         f = True
    #         for s in str(y):
    #             if s != "1":
    #                 f = False
    #                 break
            
    #         if f:
    #             print(len(str(y)))
    #             exit()
                
    #     i+=1


if __name__ == "__main__":
    main()

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

int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k)
		cout << ":(";
	else
	{
		cout << "Yay!";
	}
	
	return 0;

}

Measured memory_bytes: 256
/*
 © 2020-09-26 07:00:12 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n ;cin >> n;
  fore(i, 0, n) cout << "ACL";
  cout << ENDL;
  return 0;
}


Measured memory_bytes: 3604
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)

	A, B, C, X, Y := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	if A > B {
		A, B = B, A
		X, Y = Y, X
	}

	a := A * X + B * Y
	b := 2 * C * max(X, Y)
	c := 0
	if X < Y {
		c = 2 * C * X + B * (Y - X)
	} else {
		c = 2 * C * Y + A * (X - Y)
	}

	fmt.Println(min(min(a, b), c))
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  int n,m,d;
  scanf("%d %d %d",&n,&m,&d);
  int count=0;
  for(int i=n;i<=m;i++)
  {
    if(i%d==0)
    {
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define mo 1000000007
#define ny 499122177
#define maxn 1000000000000000000LL
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1; 
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,K,m,i,j,k,f[305][305],sum[305][305],C[305][305];
int main(){
//	freopen("number.in","r",stdin);
//	freopen("number.out","w",stdout);
	n=read();K=read();m=read();
	for(i=0;i<=n;i++){
		C[i][0]=1;
		for(j=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%m;
	}
	for(i=0;i<=K;i++){
		f[1][i]=1;
		sum[1][i]=K-i+1;
	}
	for(i=2;i<=n+1;i++){
        for(j=0;j<=K;j++)
            for(k=1;k<i;k++)
                f[i][j]=(f[i][j]+f[i-k][j]*sum[k][j+1]%m*C[i-2][k-1])%m;
        for(j=K;j>=0;j--)
            sum[i][j]=(f[i][j]+sum[i][j+1])%m;
    }
    pus(f[n+1][0],2);
	return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>

int bubblesort(int n,int A[]){
	int i,j;
	int N=0;
	int a;
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(A[j-1]>A[j]){
				a=A[j-1];
				A[j-1]=A[j];
				A[j]=a;
				N++;
			}
		}
	}
	for(i=0;i<n-1;i++){
		printf("%d ",A[i]);
	}
	printf("%d",A[i]);
	return N;
}

int main(){
	int i,n,A[100];
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	printf("\n%d\n",bubblesort(n,A));

	return 0;
}

Measured memory_bytes: 600
// at_dp_d.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define FOR(i,a) for(int i=0;i<a;i++)
typedef long long ll;
const int MAXN = 1e+5;
int main()
{
	//dp[i][a] -> if maximum weight was a, and we used first i weights

	ll dp[MAXN]; ll value[MAXN]; int weight[MAXN]; 
	int n, maxw; cin >> n >> maxw;
	memset(dp, 0, sizeof(dp));

	for(int i=1;i<=n;i++){
		cin >> weight[i] >> value[i];
		for (int a = maxw; a >= 0; a--) {
			if (a >= weight[i]) {
				dp[a] = max((ll)dp[a], (ll)dp[a - weight[i]] + value[i]);
			}
		}
	}
	cout << (ll)dp[maxw] << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 1024
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//auto start=high_resolution_clock::now();
//auto end=high_resolution_clock::now();
// cout<<duration_cast<milliseconds>(end-start).count()<<endl;
// variable type var=numeric_limits<variable type>::max()/min();
//#define _GLIBCXX_DEBUG//only for debugging
/*BISMILLAH UR RAHMAN*/ 
/* AUTHOR -CARLOSRAMIREZ *///Perfection is achieved only on the point of collapse
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) int(x.size())
#define INF INT_MAX;
using namespace std;
using namespace std::chrono;
typedef long long int ll;
ll arr[int(1e5+10)];
ll store[int(1e5+10)];
int main()
{
  fast
  memset(store,0x3f3f3f,sizeof(store));
  int n;cin>>n;int k;cin>>k;
  for(int i=1;i<=n;++i)
  cin>>arr[i];
  store[1]=0;
  for(int i=2;i<=n;++i)
  {
    for(int j=i-1;j>0&&j>=i-k;--j)
    {
      store[i]=min(store[j]+abs(arr[i]-arr[j]),store[i]);
    }
  }
cout<<store[n]<<endl;

}
   

Measured memory_bytes: 1792
#pragma GCC target("avx")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a%m<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,ans=0,S,W;
  cin>>S>>W;
  if(W>=S)cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
}


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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

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

	if (A == B) {
		cout << "EQUAL" << endl;
		return 0;
	}

	if (A.size() > B.size()) {
		cout << "GREATER" << endl;
	}
	else if (A.size() < B.size()){
		cout << "LESS" << endl;
	}
	else {
		for (int i = 0; i < A.size(); ++i) {
			if (A[i] > B[i]) {
				cout << "GREATER" << endl;
				break;
			}
			else if (A[i] < B[i]) {
				cout << "LESS" << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
signed main(){
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	multiset<pii> p;
	for(int i = 0; i < a; ++i){
		int x;
		cin >> x;
		p.insert({x, 1});
	}
	for(int i = 0; i < b; ++i){
		int x;
		cin >> x;
		p.insert({x, 2});
	}
	for(int i = 0; i < c; ++i){
		int x;
		cin >> x;
		p.insert({x, 3});
	}
	int res = 0;
	int ncol = 0;
	int red = 0;
	int green = 0;
	
	while(!p.empty()){
		pii q = *p.rbegin();
		p.erase(--p.end());
		if(q.S == 1){
			if(red + 1 <= x && red + 1 + green + ncol <= x + y){
				red++;
				res += q.F;
			}
		}
		else if(q.S == 2){
			if(green + 1 <= y && red + 1 + green + ncol <= x + y){
				green++;
				res += q.F;
			}
		}
		else{
			if(ncol + green + red + 1 <= x + y){
				ncol++;
				res += q.F;
			}
		}
	}
	cout << res << "\n";
}

Measured memory_bytes: 18944
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(ll a=b;a<=c;a++)
#define PER(a,b,c) for(ll a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<ll,ll>
#define pii pair<pair<ll,ll>,ll>
using namespace std;
const ll MAXN=1e6+5;
ll n,m,t;
ll v[MAXN];
char s[MAXN];
int main(){
    cin>>n>>m>>s+1;
    ll mod=0,pow=1;
    ll ans=0;
    v[0]=1;
    if(m==2){
        REP(i,1,n){
            if((s[i]-'0')%2==0)ans+=i;
        }
    }
    else if(m==5){
        REP(i,1,n){
            int tmp=s[i]-'0';
            if(tmp==5||tmp==0)ans+=i;
        }
    }
    else
    PER(i,n,1){
        mod=(mod+(s[i]-'0')*pow)%m;
        pow=pow*10%m;
        ans+=v[mod];
        v[mod]++;
    }
    cout<<ans;
}

Measured memory_bytes: 512
#include <iostream>

int main(int argc, char const* argv[])
{
    int n, k;
    std::string in_str;
    std::cin >> n >> k >> in_str;

    auto c = in_str[k - 1];

    switch (c)
    {
        case 'A':
            in_str[k - 1] = 'a';
            break;
        case 'B':
            in_str[k - 1] = 'b';
            break;

        case 'C':
            in_str[k - 1] = 'c';
            break;

    }
    std::cout << in_str << std::endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import functools
INF = float("inf")

MOD = 1000000007  # type: int


@functools.lru_cache(maxsize=None)
def f(x):
    if x <= 0:
        return 1
    elif x == 1:
        return 2
    else:
        return f(x-1) + f(x-2)


def solve(H: int, W: int, K: int):

    dp = [0]*(W+2)
    dp[1] = 1                   # スタート地点
    for h in range(H):
        buf = [0]*(W+2)
        for i in range(1, W+1):
            # 左からくる奴
            buf[i] += dp[i-1]*f(i-3)*f(W-i-1)
            buf[i] %= MOD
            # 真上から来る奴
            buf[i] += dp[i]*f(i-2)*f(W-i-1)
            buf[i] %= MOD
            # 右から来る奴
            buf[i] += dp[i+1]*f(i-2)*f(W-i-2)
            buf[i] %= MOD
        for i in range(1, W+1):
            dp[i] = buf[i]
    print(dp[K])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(H, W, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 310
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int f[N][N],n,K,mdn,C[N][N],s[N][N];
void init()
{
	C[0][0]=1;
	for(int i=1;i<N;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)	C[i][j]=(C[i-1][j-1]+C[i-1][j])%mdn;
	}
}
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
void solve()
{
	for(int i=0;i<=K;i++)	f[1][i]=1,s[1][i]=K-i+1;
	for(int i=2;i<=n+1;i++)
	{
		for(int j=0;j<=K;j++)	for(int k=1;k<=i-1;k++)
			upd(f[i][j],1ll*C[i-2][k-1]*f[i-k][j]%mdn*s[k][j+1]%mdn);
		for(int j=K;~j;j--)	s[i][j]=(s[i][j+1]+f[i][j])%mdn;
	}
}
int main()
{
	n=read(),K=read(),mdn=read(); init(); solve();
	printf("%d\n",f[n+1][0]);
	return 0;
}

Measured memory_bytes: 1280
M, D = map(int, input().split())
ans = 0


for i in range(4, M+1):
    for j in range(22, D+1):
        d1 = j % 10
        d10 = j // 10
        if d1 > 1 and d1*d10 == i:
            ans += 1

print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
vector<bool> func(string a, string b, string c) {
  vector<bool> ab;
  int na = a.size(), nb = b.size(), nc = c.size();
  rep(i,nc+1) ab.push_back(1);
  for(int d = nb-1; d >= 0; --d) {
    bool f = true;
    rep(i,min(nb - d, na)) {
      if(a[i] != b[i+d] && a[i] != '?' && b[i+d] != '?') f = false;
    }
    ab.push_back(f);
  }

  for(int d = 1; d < na; ++d) {
    bool f = true;
    rep(i,min(na - d, nb)) {
      if(a[i+d] != b[i] && a[i+d] != '?' && b[i] != '?') f = false;
    }
    ab.push_back(f);    
  }
  rep(i,nc+1) ab.push_back(1);  
  return ab;
}

int main()
{
  string a,b,c; cin >> a >> b >> c;
  int na = a.size(), nb = b.size(), nc = c.size();
  
  vector<bool> ab = func(a, b, c);
  vector<bool> bc = func(b, c, a);
  vector<bool> ac = func(a, c, b);

  int res = 1e+9;
  rep(i,ab.size()) {
    rep(j,ac.size()) {
      int aloc = 0;
      int bloc = i - nb - nc;
      int cloc = j - nb - nc;
      bool fbc = (0 <= j - i + na + nc && j - i + na + nc < bc.size() ? bc[j - i + na + nc] : 1);
      if(ab[i] && ac[j] && fbc) {
	int maxi = max({na, bloc + nb, cloc + nc});
	int mini = min({aloc, bloc, cloc});
	chmin(res, maxi - mini);
      }
    }
  }

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


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

template<typename T> T gcd(T a, T b) {
  if(!b) return a;
  return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
  return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned long long uInt;
typedef unsigned uint;

const int MAX_R = 3003;
const int MAX_USE = 4;

// vector<pair<int, int> > rows[MAX_R];
int value[MAX_R][MAX_R];
long long dp[MAX_R][MAX_R][MAX_USE];

int main(void) {
  int R, C, K;

  cin >> R >> C >> K;

  for (int i = 0; i < K; i++) {
    int ri, ci, vi;

    cin >> ri >> ci >> vi;

    ri -= 1;
    ci -= 1;

    value[ri][ci] = vi;

    //rows[ri].push_back(make_pair(ci, vi));
  }

  dp[0][0][1] = value[0][0];

  for (int i = 0; i < R; i++) {
    for (int j = 0; j < C; j++) {
      for (int k = 0; k < MAX_USE; k++) {
        if (i - 1 >= 0) {
          chmax(dp[i][j][k], dp[i - 1][j][0]);
          chmax(dp[i][j][1], dp[i - 1][j][k] + value[i][j]);
        }

        if (j - 1 >= 0) {
          chmax(dp[i][j][k], dp[i][j - 1][k]);

          if (k - 1 >= 0) {
            chmax(dp[i][j][k], dp[i][j - 1][k - 1] + value[i][j]);
          }
        }
      }
    }

    // vector<int> col_val(C + 1);

    // for (int j = 0; j < rows[i].size(); j++) {
    //   int col = rows[i][j].first;
    //   int val = rows[i][j].second;

    //   col_val[col] = val;
    // }

    // for (int j = 1; j <= C; j++) {
    //   for (int k = 0; k < min(j, MAX_USE); k++) {
    //     dp[j][k] = max(dp[j][k], dp[j - 1][k - 1] + col_val[j]);
    //   }
    // }
    // for (int j = 1; j <= C; j++) {
    //   for (int k = 0; k < min(j, MAX_USE); k++) {
    //     dp[j]
    // }
  }

  cout << *max_element(dp[R - 1][C - 1], dp[R - 1][C - 1] + MAX_USE) << "\n";

  return 0;
}


Measured memory_bytes: 320304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long base = sc.nextLong(), K = sc.nextLong();
        long next;
        int ans = 1;
        while (base >= 1) {
            long low = 0, high = base;
            while (high - low > 1) {
                long willNext = (low + high) / 2;
                if(willNext <= K*(base - willNext)) {//OK
                    low = willNext;
                } else {
                    high = willNext;
                }
            }
            next = low;

            if (next > 0) {
                base = next;
                ans++;
            } else {
                break;
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 26412
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    N := nextInt()
    fmt.Println(N*(N+1)/2)

}
 
/* templates */
 
func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e6+7;

int32_t main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	fast;

	int a,b;
	cin>>a>>b;
	int ans = max(a,b) + max(max(a,b)-1,min(a,b));
	cout<<ans;
	return 0;
}

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

int main(int argc, char** argv)
{
	vector<vector<int>> c;
	for (int i = 0; i < 3; i++)
	{
		vector<int> v(3, 0);
		c.push_back(v);
	}

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
			scanf("%d", &c[i][j]);
	}

	bool ans = true;
	for (int i = 0; i < 2; i++)
	{
		if (c[0][i] - c[1][i] != c[0][i + 1] - c[1][i + 1] || c[1][i] - c[2][i] != c[1][i + 1] - c[2][i + 1])
		{
			ans = false;
			break;
		}
	}

	if (ans)
		printf("Yes");
	else
		printf("No");

	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in(),K=in();
	cout << (N%K ? 1 : 0) <<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

inline ll read()
{
	ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
ll A,B;
int main()
{
	// freopen("read.in","r",stdin);
	A=read(); B=read(); int x=61;
	if(A>B) swap(A,B);
	if(A==B){cout << 1 << endl; return 0;}
	while(x>=0&&(A&(1ll<<x))==(B&(1ll<<x))) x--;
	A&=((1ll<<x+1)-1); B&=((1ll<<x+1)-1);
	int k=0; while((1ll<<k)+(1ll<<x)-1<B) k++;
	ll l1=A,r1=(1ll<<k)+(1ll<<x)-1;
	ll l2=(1ll<<x)+A,r2=(1ll<<x+1)-1;
	r1=min(r1,l2-1);
	cout << r1-l1+r2-l2+2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  REP(i, H) { cin >> S[i]; }
  vector<vector<int>> tate(H, vector<int>(W));
  vector<vector<int>> yoko(H, vector<int>(W));

  REP(y, W) {
    if(S[0][y] == '#') {
      tate[0][y] = 0;
    } else {
      tate[0][y] = 1;
    }
  }
  REP(y, W) {
    FOR(x, 1, H) {
      if(S[x][y] == '#') {
        tate[x][y] = 0;
      } else {
        tate[x][y] = tate[x - 1][y] + 1;
      }
    }
    FORR(x, H - 1, 0) {
      if(tate[x - 1][y] != 0 && tate[x - 1][y] < tate[x][y]) {
        tate[x - 1][y] = tate[x][y];
      }
    }
  }

  REP(x, H) {
    if(S[x][0] == '#') {
      yoko[x][0] = 0;
    } else {
      yoko[x][0] = 1;
    }
  }
  REP(x, H) {
    FOR(y, 1, W) {
      if(S[x][y] == '#') {
        yoko[x][y] = 0;
      } else {
        yoko[x][y] = yoko[x][y - 1] + 1;
      }
    }
    FORR(y, W - 1, 0) {
      if(yoko[x][y - 1] != 0 && yoko[x][y - 1] < yoko[x][y]) {
        yoko[x][y - 1] = yoko[x][y];
      }
    }
  }
  int ans = 0;
  REP(x, H) {
    REP(y, W) {
      ans = max(ans, tate[x][y] + yoko[x][y] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35968
using System;

namespace Application
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    if (i * j == n)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }

            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using Mat = vector<vector<int>>;

// /*
int main(){
    int n;
    cin >> n;
    vi a(n);
    Mat x(n),y(n);
    rep(i,n){
        cin >> a[i];
        rep(j,a[i]){
            int x_,y_;
            cin >> x_ >> y_;
            x[i].push_back(x_);
            y[i].push_back(y_);
        } 
    }

    int max_honest = 0; 
    for(int t=0; t<(1<<n); ++t){
        bitset<16> s(t);
        int num_honest = 0;
        bool can = true;
        rep(i,n){//N人を検証
            rep(j,a[i]){//一人当たりの証言
                //正直者だと仮定した人の証言検証
                if(s.test(i)&&(s.test(x[i][j]-1)!= y[i][j])){
                    can = false;
                    break;
                }
                //嘘つきだと仮定した人の証言検証
                // if(!(s.test(i))&&(s.test(x[i][j]-1) == y[i][j])){
                //     can = false;
                //     break;
                // }
            }
            if(can && s.test(i)) num_honest += 1;
            if(can==false) break;
        }
        if(can && num_honest>max_honest) max_honest = num_honest;
    }
    cout(max_honest);
    
    return 0;
}
// */


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)
 
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
 
int main() {
    int h, w; cin>> h >> w;
    int si, sj; cin>> si >> sj;
    int ti, tj; cin>> ti >> tj;
    si--; sj--; ti--; tj--;
    vector<string> s(h);
    forin(s);
    const int INF=1e+9;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pair<int, int>> q;
    dist[si][sj]=0;
    q.emplace_back(si, sj);
    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        int d = dist[i][j];
        rep(v, 4){
            int ni = i + di[v], nj = j + dj[v];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni, nj);
        }
        for(int ei = -2; ei <= 2; ei++){
            for(int ej = -2; ej <= 2; ej++){
                int ni = i+ei, nj=j+ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') continue;
                if(dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if(ans == INF) ans = -1;
    cout<< ans << endl;
}

Measured memory_bytes: 9472
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

x,k,d = inpm()

ans = 0
if abs(x) >= k*d:
    ans = abs(x) - k*d
else:
    kk = abs(x) // d
    if (kk - k) % 2 == 0:
        ans = abs(x) - kk*d
    else:
        ans = abs(abs(x) - (kk+1)*d)
print(ans)

Measured memory_bytes: 31196
#include<iostream>
#include<algorithm>
int main(){
    using namespace std;
    int n, k;
    std::cin >> n >> k;
    bool moratta[n];
    fill(moratta, moratta+n, false);
    for(int i=0; i<k; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int a;
            cin >> a;
            moratta[a-1] = true;
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(!moratta[i])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
 
int main(void)
{
  char S[102];
  int i,ans = 0;
  fgets(S,sizeof(S),stdin);
  for (i = 0;i < sizeof(S);i++) {
    if (ans == 0) {
      if (S[i] == 'C') {
        ans = 1;
      }
    } else {
      if (S[i] == 'F') {
        ans = 2;
      }
    }
  }
  if (ans == 2) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  ll N; cin >> N;
  vector<ll> a(3*N); REP(i, 3*N) cin >> a[i];

  sort(ALL(a), greater<ll>());

  ll ans = 0;
  for (ll i = 1; i < 2*N; i+=2) {
    ans += a[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <cstdio>

const int N = 500;

int a[N][N];

int main() {
	int K; scanf("%d", &K);
	if( K <= N ) {
		printf("%d\n", K);
		for(int i=1;i<=K;i++) {
			for(int j=1;j<=K;j++)
				printf("%d%c", i, (j == K ? '\n' : ' '));
		}
	}
	else {
		printf("%d\n", N);
		int cnt = 0;
		for(int i=0;i<2*N-K;i++) {
			int x = 0, y = i, b = (++cnt);
			do {
				a[x][y] = b;
				x = (x + 1 == N ? 0 : x + 1);
				y = (y + 1 == N ? 0 : y + 1);
			}while( x );
		}
		for(int i=2*N-K;i<N;i++) {
			int x = 0, y = i, b[2] = {};
			b[0] = (++cnt), b[1] = (++cnt);
			do {
				a[x][y] = b[x & 1];
				x = (x + 1 == N ? 0 : x + 1);
				y = (y + 1 == N ? 0 : y + 1);
			}while( x );
		}
		for(int i=0;i<N;i++) {
			for(int j=0;j<N;j++)
				printf("%d%c", a[i][j], (j + 1 == N ? '\n' : ' '));
		}
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll modpow(ll a, ll b){
  ll ans=1;
  while(b){
    if(b&1) ans=ans*a%MOD;
    a=a*a%MOD;
    b/=2;
  }
  return ans;
}
ll comb(ll a, ll b){
  ll ans=1;
  for(ll i=a; i>a-b; i--){
    ans=ans*i%MOD;
  }
  for(ll i=1;i<=b;i++){
    ans=(ans*modpow(i,MOD-2))%MOD;
  }
  return ans;
}
  
int main(){
  int n;
  ll m;
  cin >> n >> m;
  vector<pair<int,int>>soinsu;
  int base=2, exp=0;
  while(base*base<=m){
    while(m%base==0){
      m/=base;
      exp++;
    }
    if(exp) soinsu.push_back(make_pair(base,exp));
    base++;
    exp=0;
  }
  if(m>1)soinsu.push_back(make_pair(m,1));
  ll ans=1;
  rep(i,soinsu.size()){
    ans=(ans*comb(soinsu[i].second+n-1,soinsu[i].second))%MOD;
  }
  
  cout << ans << endl;
    
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    long long int ans = 0;
    int bnum = 0;
    for(int i = 0; i+1 < s.length(); i++){
        if(s[i] == 'B') bnum++;
        if(s[i] == 'B' && s[i+1] == 'W'){
            ans += bnum;
            s[i+1] = 'B';
            bnum--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second


int main(){
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int n , a , b;
    cin>>n>>a>>b;
    ll cost = n*min(a,b);
   // if(min(a,b)==a){
        if(cost<b){
            cout<<cost;
        }
        else {
            cout<<b;
        }
   // }
	return 0;
}

Measured memory_bytes: 256
/*
 * akeomekotoyoro~~~
 */

#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<ll(n);i++)

int n,m;
int x[2015], y[2015];
int main(){
    while(~scanf("%d%d", &n,&m) && n){
        x[0] = y[0] = 0;
        rep(i,n){
            int w; scanf("%d", &w);
            x[i+1] = x[i]+w;
        }
        rep(i,m){
            int h; scanf("%d", &h);
            y[i+1] = y[i]+h;
        }
        map<int,int> ws;
        rep(i,n+1)rep(j,i) ws[x[i]-x[j]]++;
        int ans = 0;
        rep(i,m+1)rep(j,i) ans += ws[y[i]-y[j]];
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 18684
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;

int N;
ull b[200001];
set<int> pos;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> N;
    for(int i=1; i<=N; i++) {
        int a;
        cin >> a;
        b[a] = i;
    }
    pos.insert(0);
    pos.insert(N+1);

    ull res = 0;
    ull l, r;
    for(ull i=1; i<=N; i++){
        auto itr = pos.upper_bound(b[i]);
        r = *itr;
        itr--;
        l = *itr;
        itr++;

        res += i * (b[i]-l) * (r-b[i]);
        pos.insert(itr, b[i]);
    }
    cout << res << endl;
	return 0;
}


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

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

long long MOD = 1000000000 + 7;

ll mpow(ll x, ll n){
  if(n == 0)
    return 1;

  if(n % 2 == 0)
    return mpow(x * x % MOD, n / 2);
  else
    return x * mpow(x, n - 1) % MOD;
}

int main(){
  cout << setprecision(10);
  vector<ll> v(70, 0); // i桁目が1である数
  int N;
  cin >> N;

  for(int i = 0; i < N; i++){
    ll tmp;
    cin >> tmp;
    
    int digit = 0;
    while(tmp > 0){
      v.at(digit) += tmp % 2;
      tmp /= 2;
      digit++;
    }
  }
  ll ans = 0;
  for(ll i = 0; i < v.size(); i++){
    ll tmp = v.at(i) * ((ll)N - v.at(i));
    tmp %= MOD;
    tmp *= mpow(2,i);
    tmp %= MOD;

    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     int a,b,c,d,e,f,g,h,i,j;
     vector<int>v;
     string s;
     cin>>s;

     int ans=0;
     for(i=0;i<s.size()-1;i++)
     {
         if(s[i]==s[i+1])
         {
             if(s[i]=='0')
             {
                 s[i+1]='1';
             }
             else{
                s[i+1]='0';
             }

             ans++;

         }

     }


     cout<<ans<<endl;
 }


Measured memory_bytes: 512
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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 INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);

//番号ズレ注意！！
int main() {
    int N, K;
    cin >> N >> K;
    int balls[N + 1];
    REP(i, N + 1) {
        balls[i] = 0;
    }
    REP(i, N) {
        int a;
        cin >> a;
        balls[a] += 1;
    }
    sort(balls, balls + N + 1, greater<int>());
    REP(i, K) {
        N -= balls[i];
    }
    print(N);
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
int fun(int a, int b);
int main()
{
	int i,j,k,n;
	long long int sum = 0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			for (k = 1; k <= n; k++)
			{
				sum += fun(i, fun(j, k));
			}
		}
	}
	printf("%lld", sum);
	return 0;
}
int fun(int a, int b)
{
	int r;
	do
	{
		r = a % b;
		a = b;
		b = r;
	} while (r != 0);
	return a;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int a,b;
cin >> a >> b;

string s;
ostringstream oss;

oss << a << b << flush;
s = oss.str();

int N = stoi(s);

for(int i=1; i*i <= N;i++) {
    if(i*i == N) {
        cout << "Yes" << endl;
        return 0;
    }
}

cout << "No" << endl;

return 0;
}

Measured memory_bytes: 256
use proconio::*;

fn run() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let ans = a.into_iter().fold(1u64, |s, a| s.saturating_mul(a));
    if ans > 10u64.pow(18) {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

fn main() {
    run();
}

Measured memory_bytes: 4516
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s.find("AC") != string::npos) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    string n;
    cin >> n;
    int cnt = 0;
    rep(i, 4)
    {
        if (n[i] == '2')
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3596
N,K = map(int,input().split())
A = map(int,input().split())
L = [0]*(N+1)
uniq = set()

for i in A:
    L[i] += 1
    uniq.add(i)

if len(uniq) <= K:
    print(0)
else:
    L = sorted(L)
    count = 0
    ans = 0
    for i in L:
        if i != 0:
            count += 1
            ans += i
        if count == len(uniq)-K:
            break
    print(ans)

Measured memory_bytes: 85072
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n;
int a[N],b[N];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) 
    {
    	scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++) {
		int ans=0,sum=0;
		for (int j=1;j<=n;j++) 
		 if (a[j]) {
		 	sum++;
		 	if (a[j]==sum) ans=j;
		 }
		 if (!ans) {
		 	printf("%d\n",-1); exit(0);
		 }
		 else 
		 b[i]=a[ans],a[ans]=0;
	}
	for (int i=n;i>=1;i--) printf("%d\n",b[i]);
} 

Measured memory_bytes: 256
if __name__ == '__main__':
    N, M, X, Y = list(map(int, input().split()))
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    mx = max(x)
    my = min(y)

    lx = max(mx, X)
    ly = min(my, Y)
    if lx < ly:
        print("No War")
    else:
        print("War")

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

using namespace std;

using ll = long long;

ll f(ll a, ll b){
    ll ans = 0;
    ll n = max(a,b);

    while(n != 0){
        ans++;
        n/=10;
    }

    return ans;
}

int main(void){
    ll n;
    ll ans = 10;

    cin >> n;

    for(ll i=1; i*i<=n; i++){
        if(n%i != 0)
            continue;

        ans = min(f(i,n/i), ans);
    }
    if(n==1){
        ans = 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[209], b[209], e[209], ret[209];
int main() {
	for (int i = 0; i < 200; i++) {
		a[i] = (i % 5 == 1 ? 5 : 2);
		b[i] = 17 * (i % 2) + 3 * (i % 3) + 19;
	}
	int h = 0;
	fill(e, e + 200, -1);
	vector<int> s(17, -1);
	for (int i = 0; i < 1000; i++) {
		for (int j = 0; j < h; j++) {
			if (e[j] + b[j] == i) {
				for (int k = 0; k < 17; k++) {
					if (s[k] == j) s[k] = -1;
				}
			}
		}
		while (h <= i / 5) {
			bool ok = false;
			for (int k = 0; k <= 17 - a[h]; k++) {
				bool flag = true;
				for (int l = k; l < k + a[h]; l++) {
					if (s[l] != -1) flag = false;
				}
				if (flag) {
					fill(s.begin() + k, s.begin() + k + a[h], h);
					ret[h] = i - h * 5;
					e[h++] = i;
					ok = true;
					break;
				}
			}
			if (!ok) break;
		}
	}
	while (cin >> n) cout << ret[n] << endl;
	return 0;
}

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

int main() {
	int a,b,c,d,e;
  	cin>>a>>b>>c;
  e=0;d=0;
  if(a==7)
  	e++;
  if(a==5)
    d++;
  if(b==7)
    e++;
  if(b==5)
    d++;
  if(c==7)
    e++;
  if(c==5)
    d++;
  
  if(e==1&&d==2)
      cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CColoringColorfully {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int nbChanges = solve0(s);
            out.println(nbChanges);
        }

        private int solve0(String s) {
            int[][] dp = new int[s.length()][2];
            dp[0][0] = s.charAt(0) == '0' ? 0 : 1;
            dp[0][1] = s.charAt(0) == '1' ? 0 : 1;
            for (int i = 1; i < s.length(); i++) {
                dp[i][0] = dp[i - 1][1] + (s.charAt(i) == '0' ? 0 : 1);
                dp[i][1] = dp[i - 1][0] + (s.charAt(i) == '1' ? 0 : 1);
            }
            int N = s.length();
            return Math.min(dp[N - 1][0], dp[N - 1][1]);
        }

    }
}



Measured memory_bytes: 29396
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int M,D;
    cin >> M >> D;
    if(D < 21){
        cout << 0 << "\n";
    }else{
        vector<int> A(0);
        REP(i,D/10 - 2){
            REP(l,8)A.push_back((i+2)*(l+2));
        }
        if(D%10-1 > 0)REP(l,D%10-1)A.push_back((D/10)*(l+2));
        sort(all(A));
        int count = 0;
        REP(i,A.size()){
            if(A[i]<=M){
                count++;
            }
        }
        cout << count << "\n";
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		while(true){
			int n =in.nextInt();
			long m = in.nextInt();
			if(n+m==0)break;
			ArrayList<Data> list = new ArrayList<Data>();
			for(int i=0;i<n;i++)list.add(new Data(in.nextInt(), in.nextInt()));
			Collections.sort(list);
//			for(int i=0;i<n;i++)System.out.println(list.get(i).d+" "+list.get(i).p);
			long all = 0;
			for(int i=0;i<n;i++)all+=(list.get(i).d*list.get(i).p);
//			System.out.println(m);
			long remove = 0;
			int index = 0;
			for(index=0;m>0&&index<n;index++){
//				System.out.println(m+" "+remove);
				if(list.get(index).d<=m){
					int a = list.get(index).d*list.get(index).p;
					remove+=a;
					m-=list.get(index).d;
				}else{
					remove+=(list.get(index).p*m);
//					System.out.println(m+" "+remove);
					m=0;break;
				}
			}
			System.out.println(all-remove);
			
		}
	}
}
class Data implements Comparable<Data>{
	int d,p;
	public Data(int d,int p) {
		this.p = p;
		this.d = d;
	}
	public int compareTo(Data o) {
		if(this.p<o.p)return 1;
		else if(this.p>o.p)return -1;
		return 0;
	}
}

Measured memory_bytes: 77636
#include <iostream>
using namespace std;
int n;
int main()
{
	long long i,j,k,ans=0;
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=i;j<=n;j+=i){
            ans+=j;
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    string S;
    cin>>S;

    bool res = true;
    rep(i, S.size()) {
        if (i % 2 == 0 && S[i] != 'h') {
            res = false;
            break;
        }
        if (i % 2 == 1 && S[i] != 'i') {
            res = false;
            break;
        }
    }
    if (S.size() % 2 == 1) res = false;

    if (res) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
  int N;
  cin >> N;

  // int型の2次元配列(3×4要素の)の宣言
  vector<int> data(N),dataB(N);
  
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
    dataB.at(i) = i+1;
  }
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    if (data.at(i) != dataB.at(i)) {
      count++;
    }
  }
  
  if (count >= 3) {
    cout <<"NO"<<endl;
  }
  else {
    cout << "YES" <<endl;
  }
  
  

}


Measured memory_bytes: 256