akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
long long n,m,v,p,a[100005],i,j,l,r,mid,ans;
bool check(long long x)
{
	if(x<=p) return 1;
	long long i,val=a[x]+m;
	fz1(i,n) if(i>=p&&a[i]>val) return 0;
	long long sum=m*max(0ll,v-p);
	fz1(i,n) if(i>=p&&i!=x){
		sum-=min(val-a[i],m);
	}
	return sum<=0;
}
int main()
{
	cin>>n>>m>>v>>p;
	fz1(i,n) cin>>a[i];
	sort(a+1,a+n+1,greater<long long>());
	l=1;r=n+1;
	while(l<r){
		mid=(l+r)/2;
		if(check(mid)){
			l=mid+1;
			ans=mid;
		}
		else r=mid;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    if(n == 3){
        cout << "2 5 63" << endl;
        return 0;
    }
    for(int i = 1; i <= min(n - 1, 15000); i++){
        if((i % 3 == 0 || i % 3 == 2) && (n - i) % 2 == 0 && 6 * (n - i) - 3 <= 30000){
            for(int j = 1; j <= i; j++) cout << j * 2 << " ";
            for(int j = 1; j <= (n - i); j++) cout << j * 6 - 3 << " ";
            break;
        }
    }
    cout << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include<algorithm>

using namespace std;

char minC(string& str) {
    char c = str[0];
    for(int i = 1; i < str.size(); ++i) {
        c = min(c, str[i]);
    }
    return c;
}

char maxC(string& str) {
    char c = str[0];
    for(int i = 1; i < str.size(); ++i) {
        c = max(c, str[i]);
    }
    return c;
}

int matchC(string& str, char c) {
    int cnt = 0;
    for(int i = 0; i < str.size(); ++i) {
        if(str[i] == c) cnt++;
    }
    return cnt;
}

int main() {
    string s, t;
    cin >> s >> t;
    char minS = minC(s);
    char maxT = maxC(t);
    if(minS < maxT) {
        cout << "Yes" << endl;
    } else if(minS > maxT || s.size() >= t.size()) {
        cout << "No" << endl;
    } else {
        int c1 = matchC(s, minS);
        int c2 = matchC(t, maxT);
        if(c1 < c2 && c1 == s.size()) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	FOR(i, 1, 10) {
		int x = i + 10 * i + 100 * i;
		if (x >= N) {
			print(x);
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LLI long long int
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    LLI A;
    char B[7] = {};

    scanf("%lld %s", &A, &B);
    LLI a = B[0] - '0';
    LLI b = B[2] - '0';
    LLI c = B[3] - '0';
    LLI ans = ( A * a * 100 + A * b * 10 + A * c ) / 100;
    printf("%lld\n", ans);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 3816
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    char ch;
    while(1){
        scanf("%c", &ch);
        if(isalpha(ch)){
            if(islower(ch))printf("%c", toupper(ch));
            else printf("%c", tolower(ch));
        }
        else printf("%c", ch);
        if (ch == '\n')break;
    }
    return 0;
}


Measured memory_bytes: 2592
import static java.lang.System.*;
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
		
        out.println(s.substring(0,k-1) + (char)(s.charAt(k-1)-'A'+'a') + s.substring(k));
    }
}


Measured memory_bytes: 21844
// ABC063_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    
    // calculation
    if (N+M >= 10) cout << "error" << "\n";
    else cout << N+M << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

int main()
{
    long long l;
    long long  r;
    long long min = 2019;
    std::cin>>l>>r;
    for(long long i=l;i<=r&&i<l+2019;i++){
        for(long long j=i+1;j<=r&&j<l+2019;j++){
            min = std::min(i*j%2019,min);
        }
    }
    std::cout<<min<<std::endl;

}

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

#define LL long long

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n,k;
	cin >> n >> k;
	vector<LL> h(n);
	LL res = 0;
	for (LL i = 0; i < n; i++){
		cin >> h[i];
		if (h[i] >= k)
			res++;
	}
	cout << res << "\n";
}


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

#define TC int n;scanf("%d",&n);while(n--)
#define lld long long int

int main()
{
    int n=0,i=0;
    cin>>n;
    int k=sqrt(n);
    for(i=2;i<=k;i++)
    {
        if(n%i==0)
        {
            ++n;
            k=sqrt(n);
            i=1;
        }
    }
    cout<<n;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int cnt = 0;
	int ans = 0;
	REP(i, SZ(S)) {
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
			cnt++;
		}
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int minn,a[100001],n,k;
int gcd(int a,int b)
{
	int tmp;
	while(b){
		tmp=a%b; a=b; b=tmp;
	}
	return a;
}
int read()
{         
	int val=0; char ch=getchar();
	while(ch<'0' || ch>'9') ch=getchar();
	while(ch>='0' && ch<='9') {
		val=val*10+ch-'0'; ch=getchar();
	}     
	return val;
}         
int main()
{         
	n=read(); k=read();
	int i;
	for(i=1;i<=n;++i) a[i]=read();
    sort(a+1,a+n+1); minn=a[n];
	for(i=n-1;i;--i) minn=gcd(minn,a[i]);
	if( (k>a[n]) || (k%minn) ) printf("IMPOSSIBLE"); else printf("POSSIBLE");
	return 0;
}            

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();

		int a, b;

		while ((a = sc.nextInt()) != 0 | (b = sc.nextInt()) != 0) {
			h.add(a);
			w.add(b);
		}

		for(int i = 0; i < h.size(); i++) {

			for(int j = 0; j < h.get(i); j++) {

				for(int k = 0; k < w.get(i); k++){

					System.out.print("#");

				}
				System.out.println();

			}
			System.out.println();

		}

	}

}





Measured memory_bytes: 37804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=105;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
#define int ll
int N;
int a[maxn];

struct edge{
	int to,cap,rev;
	edge(int _,int __,int ___):to(_),cap(__),rev(___){}
};

vector<edge> G[maxn];

void add_edge(int u,int v,int c){
	//cout<<u<<' '<<v<<' '<<c<<'\n';
	G[u].pb(edge(v,c,SZ(G[v])));
	G[v].pb(edge(u,0,SZ(G[u])-1));
}

int lvl[maxn];
int iter[maxn];

vector<int> q;
int pt;
void bfs(int u){
	REP(i,N) lvl[i]=-1;
	lvl[u]=0;
	q.clear();
	q.pb(u);
	pt=0;
	while(pt<SZ(q)){
		int cur=q[pt++];
		for(edge &e:G[cur]){
			if(lvl[e.to]!=-1||e.cap<=0) continue;
			lvl[e.to]=lvl[cur]+1;
			q.pb(e.to);
		}
	}
}
int dfs(int s,int t,int f){
	if(s==t) return f;
	for(int &i=iter[s];i<SZ(G[s]);i++){
		edge &e=G[s][i];
		if(e.cap>0&&lvl[e.to]>lvl[s]){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int dinic(int s,int t){
	int flow=0;
	while(1){
		bfs(s);
		REP(i,N) iter[i]=0;
		if(lvl[t]==-1) return flow;
		int f;
		while((f=dfs(s,t,INF))>0) flow+=f;
	}
}

int32_t main()
{
	int n;
	cin>>n;
	N=n+2;
	REP(i,n) cin>>a[i];
	int ans=0;
	REP(i,n) ans+=max(a[i],0LL);
	REP(i,n){
		if(a[i]<0) add_edge(n,i,-a[i]);
		if(a[i]>0) add_edge(i,n+1,a[i]);
	}
	for(int i=1;i<=n;i++) for(int j=2*i;j<=n;j+=i){
		add_edge(i-1,j-1,INF);
	}
	cout<<ans-dinic(n,n+1);
}




Measured memory_bytes: 256
#include <stdio.h>

int m[3][3];

int main(void){
	int i, j, sum;
	
	scanf("%d %d %d", &m[0][0], &m[0][1], &m[1][1]);
	
	sum = m[1][1]*3;
	
	m[0][2] = sum - m[0][0] - m[0][1];
	m[2][2] = sum - m[1][1] - m[0][0];
	m[2][1] = sum - m[1][1] - m[0][1];
	
	m[1][2] = sum - m[0][2] - m[2][2];
	m[1][0] = sum - m[1][1] - m[1][2];
	m[2][0] = sum - m[1][0] - m[0][0];
	
	for (i = 0; i < 3; i++){
		for (j = 0; j < 3; j++){
			if (j) printf(" ");
			printf("%d", m[i][j]);
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
//CCW??¨///////////////////////////////////
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONELINE_BACK = 2;
static const int ONELINE_FRONT = -2;
static const int ON_SEGMENT = 0;
/////////////////////////////////////////
class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}

  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
  }
};
/*class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};*/
typedef Point vect;
struct seg{Point p1,p2;};
//????????´???
double norm(Point p){return p.x*p.x+p.y*p.y;}
//??¶??????
double abs(Point p){return sqrt(norm(p));}
//??????
double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}
//??????
double cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
//??´?????????
bool C90(seg s1,seg s2){
  return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}
bool C0(seg s1,seg s2){
  return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}
//?°???±
Point projec(seg s,Point p){
  Point base = s.p2-s.p1;
  double r=dot(p-s.p1,base) / norm(base);
  return s.p1+base*r;
}
//????°?
Point reflec(seg s,Point p){
  return  p+(projec(s,p)-p)*2.0;
}
//2???????????¢
double getDistancePP(Point a,Point b){
  return abs(a-b);
}
//??´??????????????¢(????°?)
double getDistanceLP(seg l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}
//?????????????????¢
double getDistanceSP(seg s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}
//????????????????????¢
/*double getDistance(seg s1,seg s2){
  if(intersect(s1,s2))return 0.0;
  return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
    min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}*/
//????¨?????????????????¨??????????
int CCW(Point p0,Point p1,Point p2){
  Point a=p1-p0;
  Point b=p2-p0;
  if(cross(a,b)>EPS)return COUNTER_CLOCKWISE;
  if(cross(a,b)<-EPS)return CLOCKWISE;
  if(dot(a,b)<-EPS)return ONELINE_BACK;
  if(norm(a)<norm(b))return ONELINE_FRONT;
  return ON_SEGMENT;
}
main(){
  int n;
  seg a,b;
  cin>>a.p1.x>>a.p1.y>>a.p2.x>>a.p2.y;
  cin>>n;
  while(n--){
    Point c;
    cin>>c.x>>c.y;
    int p=CCW(a.p1,a.p2,c);
    if(p==1)cout<<"COUNTER_CLOCKWISE";
    if(p==-1)cout<<"CLOCKWISE";
    if(p==2)cout<<"ONLINE_BACK";
    if(p==-2)cout<<"ONLINE_FRONT";
    if(!p)cout<<"ON_SEGMENT";
    cout<<endl;
  }
}

Measured memory_bytes: 3236
f (x:[]) num
   |x < 6     = num + x
   |otherwise = num + (11 -x)

f (x:xs:xss) num
   |x==5&&xs>4= f ((xs+1):xss) (num + 10 -x) 
   |x < 6     = f (xs:xss) (num + x)
   |otherwise = f ((xs+1):xss) (num + 10 -x)

countBill n = f (reverse n) 0

main = do
   n <- map (\x -> fromEnum x - 48) <$> getLine
   putStrLn $ show $ countBill n


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

const ll INF = 1001001001;
const ll mod = 1000000007;

int solve(map<int, int> map, const vector<vector<int>> &vec, int nc){
    int ret = 0;
    for(auto p : map){
        int color = p.first;
        int num = p.second;
        ret += num * vec[color][nc];
    }
    return ret;
}

int main(){
    int n, c; cin >> n >> c;
    vector<vector<int>> cost(c, vector<int>(c)), mp(n, vector<int>(n));
    for(int i = 0; i < c; i++){
        for(int j = 0; j < c; j++){
            cin >> cost[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> mp[i][j];
            mp[i][j]--;
        }
    }
    map<int, int> mp1, mp2, mp0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if((i + j) % 3 == 0){
                mp0[mp[i][j]]++;
            }
            if((i + j) % 3 == 1){
                mp1[mp[i][j]]++;
            }
            if((i + j) % 3 == 2){
                mp2[mp[i][j]]++;
            }
        }
    }
    int ans = INF;
    for(int i = 0; i < c; i++){
        for(int j = 0; j < c; j++){
            for(int k = 0; k < c; k++){
                if(i == j || j == k || k == i) continue;
                int tmp = 0;
                tmp += solve(mp0, cost, i);
                tmp += solve(mp1, cost, j);
                tmp += solve(mp2, cost, k);
                //cout << i << ", " << j << ", " << k << ", " << tmp << endl;
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4604
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int N; cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P[i];

  int ans = 0;
  int min = 300000;
  for (int i = 0; i < N; i++) {
    if (P[i] < min) {
      ans++; 
      min = P[i];
    }
  }

  cout << ans << endl;
}


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

using namespace std;

#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


void solve(){
    string s;
    cin>>s;
    int n = (int)s.size();
    int i = 0;
    int maxi = 0;
    while(i<n){
        if(s[i]=='R'){
            int j = i;
            while(j<n && s[j]=='R')
                j++;
            j--;
            maxi = max(maxi,j-i+1);
            i = j;
        }
        i++;
    }
    cout<<maxi<<endl;
}

int main()
{
    FASTIO
    int t = 1;
//    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}





Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

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


int main()
{
	// Sunny, Cloudy, or Rainy.
	string s; cin >> s;

	if (s == "Sunny")
		cout << "Cloudy";
	if (s == "Cloudy")
		cout << "Rainy";
	if (s == "Rainy")
		cout << "Sunny";

	return 0;

}

Measured memory_bytes: 3396
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main()
{
	int a, b, c,x=1;
	cin >> a >> b >> c;
	string yn[2] = { "Yes","No" };
	if (a <= c&&b >= c) x = 0;
	cout << yn[x] << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int X = scan.nextInt();
        int[] m = new int[N];
        int sum = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            m[i] = scan.nextInt();
            sum += m[i];
            min = Math.min(m[i], min);
        }
        int answer = N;
        answer += (X - sum) / min;
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH RANJAN******************************************************
***********************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<(int)n;i++)
#define frs(i,a,b) for(int i = a;i<b;i++)
#define meme(a,b,c) memset(a,b,sizeof(c)); //works only for 0 and -1
int main(){
  fast();
  int n;
  cin>>n;
  vector<ll> v(n);
  fr(i,n)cin>>v[i];
  vector<ll> prefix(n+1,0);
  for(int i=n-1;i>=0;i--){
  prefix[i] = prefix[i+1] + v[i];
  }
  ll ans = 0;
  fr(i,n){ans += (v[i]*(prefix[i+1]%mod))%mod;ans %=mod;}
  cout<<ans;
 return 0;
  
}




Measured memory_bytes: 6376
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def det(a,b):
        return a[0]*b[1]-a[1]*b[0]

    def minus(a,b):
        return (a[0]-b[0],a[1]-b[1])

    def convex_hull(ps):
        n = len(ps)
        ps.sort()
        k = 0
        qs = [0]*(n+2)
        for i in range(n):
            while k > 1 and det(minus(qs[k-1], qs[k-2]), minus(ps[i], qs[k-1])) < 0:
                k -= 1
            qs[k] = ps[i]
            k += 1
        t = k
        for i in range(n-1)[::-1]:
            while k > t and det(minus(qs[k-1], qs[k-2]), minus(ps[i], qs[k-1])) < 0:
                k -= 1
            qs[k] = ps[i]
            k += 1
        qs = qs[:min(n,k-1)]
        return qs
    n = I()
    ps = LIR(n)
    qs = convex_hull(ps)
    if len(qs) == n:
        print(1)
    else:
        print(0)
    return

#Solve
if __name__ == "__main__":
    solve()



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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		int change =0;
		int num[] = new int[count];
		for(int i=0; i<count; i++) {
			num[i]=sc.nextInt();
		}

		for(int i=0; i<num.length-1; i++) {
			int min=i;
			for(int j=i+1; j<num.length; j++) {
				if(num[min]>num[j]) {
	  				min=j;
				}
			}
			 if (i == min) {
	                continue;
	            }

			int tmp =num[i];
					num[i]=num[min];
					num[min]=tmp;
	  				change ++;
		}
		  System.out.println(Arrays.toString(num)
	                .replaceAll("[\\[\\],]", ""));
		  System.out.println(change);
	}

}


Measured memory_bytes: 26412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

vector<int> ans(0);

signed main(){
    ll n;cin>>n;
    vector<int> a(n,0);
    rep(i,n)cin>>a[i];

    ll cnt=n-1;
    while(cnt>=0){
        cout<<a[cnt]<<" ";
        cnt-=2;
    }
    cnt=(-cnt-1);
    while(cnt<n-1){
        cout<<a[cnt]<<" ";
        cnt+=2;
    }
    cout<<endl;
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;

int main(){
    ll N;
    vector<ll> count(100001,0);
    cin>>N;
    ll sum=0;
    for(ll i=0;i<N;i++){
        ll temp;
        cin>>temp;
        count[temp]++;
        sum+=temp;
    }
    ll Q;
    cin>>Q;
    for(ll i=0;i<Q;i++){
        ll B,C;
        cin>>B>>C;
        sum+=(C-B)*count[B];
        count[C]+=count[B];
        count[B]=0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, D; cin >> N >> D;
  D = 2*D+1;
  cout << (N+D-1) / D << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF = (1LL<<60)-1;
const int maxN = 1000001;
int32_t main()
{
    FLASH;
    int n,m,c;
    cin>>n>>m>>c;
    int b[m],a[n][m];
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int temp=c;
        for(int j=0;j<m;j++)
        {
            temp+=(a[i][j]*b[j]);
           
        }

        if(temp>0)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void) {

	int x, y;
	int xs[3000], ys[3000];
	int i = 0;
	int elm = 0;
	
	do {
		scanf("%d %d", &x, &y);
		xs[i] = x;
		ys[i] = y;
		i++;
	} while(!(x == 0 && y == 0));
	
	elm = i;
	
	for (i=0; i < elm-1; i++) {
		if (xs[i] > ys[i]) {
			printf("%d %d\n", ys[i], xs[i]);
		} else {
			printf("%d %d\n", xs[i], ys[i]);
		}
	}
	
	return 0;
	
}

Measured memory_bytes: 620
#include <iostream>

int five_count = 0;
int seven_count = 0;

int main() {
    int lines[3];

    for (int i = 0; i < 3; i++) {
        std::cin >> lines[i];
        if (lines[i] == 5) five_count++;
        else if (lines[i] == 7) seven_count++;
    }

    if (five_count == 2 && seven_count == 1) std::cout << "YES" << std::endl;
    else std::cout << "NO" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	int sum = 0;
	int max_num = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		sum += tmp;
		max_num = max(max_num, tmp);
	}

	if (max_num < sum - max_num)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  
  int ans = 0;
  rep(i,n-1){
    if(s[i] == s[i+1])ans++;
  }
  cout << min(ans+2*k,n-1) << endl;
  return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define db double
#define ls x << 1
#define rs x << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int 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;
}
int n, a[110], x;
ll f[60][60][2600];
int main()
{
	n = read();
	x = read();
	rep(i, 1, n)
		a[i] = read();
	f[0][0][0] = 1ll;
	rep(i, 1, n)
	{
		rep(j, 0, i - 1)
			rep(k, 0, 2500)
				f[i][j][k] += f[i - 1][j][k];

		rep(j, 1, i)
			rep(k, 0, 2500)
				f[i][j][k + a[i]] += f[i - 1][j - 1][k];
	}
    ll ans = 0;
	rep(i, 1, n)
		ans += f[n][i][i * x];
	cout << ans;
	return 0;
}


Measured memory_bytes: 61696
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int count =0;
    for (int i=0; i<S.length()/2; i++) {
      if(S.charAt(i) == S.charAt(S.length()-1-i)) {
        count++;
      }
    }
    System.out.println(S.length()/2 - count);
  }
}
    

Measured memory_bytes: 22740
#include<stdio.h>
#define NOT_FREE 1
#define FREE 0
#define N 8

void putqueen(int);
void printboard(void);

int row[N], col[N], dpos[2*N-1], dneg[2*N-1], Q[N][N];

int main(){
  int k, i, r, c, j;

  scanf("%d", &k);

  for(i = 0; i < k; i++){
    scanf("%d%d", &r, &c);
    Q[r][c] = NOT_FREE;
  }

  putqueen(0);

  return 0;
}

void putqueen(int i){
  int j;

  if(i == N){
    printboard();
    return;
  }

  for(j = 0; j < N; j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE)
      continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    putqueen(i+1);
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

void printboard(){
  int i, j;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(Q[i][j] == NOT_FREE && row[i] != j)
	  return;
    }
  }

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(row[i] == j)
	printf("Q");
      else
	printf(".");
    }
    printf("\n");
  }
}

Measured memory_bytes: 572
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        if(d == 25){
            System.out.println("Christmas");
        }else if(d == 24){
            System.out.println("Christmas Eve");
        }else if(d == 23){
            System.out.println("Christmas Eve Eve");
        }else{
            System.out.println("Christmas Eve Eve Eve");
        }
    }
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ll)(1e9)+7)

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

	vector<int> b(n, 0), c(n, 0);
	for(int i=0; i<n; i++){
		for(int j=0; j<i; j++){
			if(a[i]>a[j]) b[i]++;
		}
		for(int j=i+1; j<n; j++){
			if(a[i]>a[j]) c[i]++;
		}
	}

	ll ans=0;
	for(int i=0; i<n; i++){
		ans+=b[i]*(((k-1)*k/2)%mod);
		ans%=mod;
		ans+=c[i]*((k*(k+1)/2)%mod);
		ans%=mod;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    string s;
    cin >> s;
    int q;
    cin >> q;
    char a;
    int cnt = 0;
    vector<char> v[3];
    while (q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            cnt++;
            //reverse(ans.begin(), ans.end());
        }
        else
        {
            int f;
            cin >> f;
            cin >> a;
            if (f == 1)
            {
                if (cnt % 2 == 0)
                    v[1].push_back(a);
                else
                    v[2].push_back(a);
            }
            else
            {
                if (cnt % 2 == 0)
                    v[2].push_back(a);
                else
                    v[1].push_back(a);
            }
        }
    }
    string ans = "";
    for (int i = v[1].size() - 1; i >= 0; i--)
    {
        ans += v[1][i];
    }
    ans += s;
    for (char c : v[2])
        ans += c;
    if (cnt % 2)
        reverse(ans.begin(), ans.end());
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1448
//  ----- + ------ + + ------ JAI SHREE RAM ----- +------ + ------ + ------ + ------
/* ＿人人人人人人人人人人人人人人人＿
＞　S H U B H A M    A N A N D　＜
 ￣Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y￣   */

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define int long long
const int N=1e5+10;
vector<pair<int,int>>adj[N];
vector<int>vis(N);
vector<int>color(N);

void dfs(int x,int par,int clr)
{
    vis[x]=1; int tempclr=1;
    for(auto i : adj[x])
    {
        if(!vis[i.first]) 
        {
            if(tempclr==clr) tempclr++;
            color[i.second]=tempclr; 
            dfs(i.first,x,tempclr); 
            tempclr++; 
        }
    }
}


int32_t main() 
{
    int n; cin>>n; int ans=0;
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y; adj[x].push_back({y,i}); adj[y].push_back({x,i});
    }
    dfs(1,-1,-1);
    for(int i=1;i<=n;i++) ans=max(ans,(int)adj[i].size());
    cout<<ans<<endl;
    for(int i=1;i<n;i++) cout<<color[i]<<endl; 
    return 0;
}




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



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

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

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

int main(void){
  int s;
  scanf("%d",&s);
  int a[1000000];
  for(int i=0;i<1000000;i++){
    a[i]=0;
  }
  int n=s;
  a[0]=n;
  int ans=1;
  for(int i=1;i<300;i++){
    ans++;
    if(n%2==0){
      n=n/2;
    }else{
      n=3*n+1;
    }
    a[i]=n;
    for(int j=0;j<1000000;j++){
      if(j<i&&a[i]==a[j]){
        printf("%d\n",ans);
        return 0;
      }
    }
  }
}

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

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

L,R = [A[0]],[A[-1]]
Lg = A[0]
Rg = A[-1]
for i in range(N-1):
    Lg = gcd(Lg,A[i+1])
    L.append(Lg)
for i in range(N-1,0,-1):
    Rg = gcd(Rg,A[i-1])
    R.append(Rg)
L.append(A[-1])
R.append(A[0])

res = 0
for i in range(N):
    if i == 0:
        res = max(res,R[-3])
    elif i == N-1:
        res = max(res,L[-3])
    else:
        res = max(res,gcd(L[i-1],R[-i-3]))
        
print(res)

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

int a,b,c,ans;
string s;
int d,m;

int main(){
    cin>>m>>d;
    for(int i=1;i<=m;i++){
        for(int u=1;u<=d;u++){
            a=u/10;
            b=u%10;
            if(a*b==i&&a>=2&&b>=2){ans++;}
        }
    }
    cout<<ans<<endl;
}



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

typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) return gcd(b,a);
    ll r;
    while(r=a%b){
        a = b; b = r;
    }
    return b;
}

int main(){
    int N;
    cin >> N ;
    vector<int> v(N);
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    cout << v[v.size() -1] - v[0] << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

int main() {
	ll n, t;
	cin >> n >> t;
	vector<vector<ll> > dp(n+1, vector<ll>(t+1, 0));
	vector<vector<ll> > best(n + 1, vector<ll>(t + 1, 0));
	vector<ll> a(n+1), b(n+1);
	for (ll i = 1; i < n+1; i++)
	{
		cin >> a[i] >> b[i];
	}

	for (ll i = 1; i < n+1; i++)
	{
		for (ll j = 0; j < t; j++)
		{
			// i番目まで、j分間で
			if (a[i] > j) {
				dp[i][j] = dp[i - 1][j];
				best[i][j] = max(best[i - 1][j], b[i]);
			}
			else if (dp[i - 1][j] < dp[i - 1][j - a[i]] + b[i]) {
				// 改善されるとき
				dp[i][j] = dp[i - 1][j - a[i]] + b[i];
				best[i][j] = best[i - 1][j - a[i]];
			}
			else if (dp[i - 1][j] > dp[i - 1][j - a[i]] + b[i]) {
				// 改善されないとき
				dp[i][j] = dp[i - 1][j];
				best[i][j] = max(best[i - 1][j], b[i]);
			}
			else {
				// 等しいとき
				dp[i][j] = dp[i - 1][j];
				best[i][j] = max(max(best[i - 1][j], b[i]), best[i - 1][j - a[i]]);
			}
		}
	}

	cout << dp[n][t - 1] + best[n][t - 1] << endl;



	return 0;
}


Measured memory_bytes: 141184
n,k,i=int(input()),1,2
p=print
if-n&n==n:p("No");exit()
p("Yes",v:=n+1,3)
while i<n:p(1,i,i,i+1,1,v+i,v+i,n+i);i+=2;k<<=k*2<v
if~n&1:p(n,v+k,n+n,n^k)

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

using namespace std;
typedef long long int ll;
const int maxv=1e5+5;

vector<int> arr[maxv];
vector<int> indeg(maxv);
vector<int> vis(maxv);
vector<int> dis(maxv);


void dfs(int i){
   vis[i]=1;
   for(auto v:arr[i]){
     --indeg[v];
       dis[v]=max(dis[v],1+dis[i]);
       if(indeg[v]==0){
          dfs(v);
       }
   }
}

int main(){

   int v,e;
   cin>>v>>e;
   
   int x,y;
   for(int i=0;i<e;i++){
      cin>>x>>y;
      arr[x].push_back(y);
      ++indeg[y];
   }

   for(int i=1;i<=v;i++){
      if(vis[i]==0&&indeg[i]==0){//start with vertices with indegree 0
         dfs(i);
      }
   }
   int ans=0;
   for(auto v:dis){
      //cout<<v<<" ";
      ans=max(ans,v);
   }
   cout<<ans<<"\n";
   
}

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int main() {
	// cin.tie(0); // tie
	// ios::sync_with_stdio(false); // sync
	int n;
	while (cin >> n, n) {
		int ans = 0;
		for (int i = 1; i < n; ++i) {
			int tmp = n;
			for (int j = i; tmp > 0; ++j) tmp -= j;
			if (tmp == 0) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#coding:utf-8
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
n,m = map(int,input().split())
s=input()
t=input()
lcm = lcm(n,m)
a = int(lcm/n)
b = int(lcm/m)
for i in range(fractions.gcd(n,m)):
    if s[i*b]==t[i*a]:
        pass
    else:
        print (-1)
        exit()
print (lcm)


Measured memory_bytes: 5436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Programminng
{
    class AOJ_Volume0014
    {
        public static void Main(string[] args)
        {

            while (true)
            {
                string input = Console.ReadLine(); ;
                if (string.IsNullOrEmpty(input)) break;

                int d = int.Parse(input);
                int value = 0, s = 0;

                while (value != 600 - d)
                {
                    value += d;
                    int line = value * value;
                    s += line * d;
                }
                Console.WriteLine(s);

            }
        }
    }
}

Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    VL x(3); cin >> x[0] >> x[1] >> x[2];
    sort(x.begin(), x.end());
    Ans(x[2]==x[0]+x[1]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a[4][4],b;
	cin>>a[1][1]>>a[1][2]>>a[2][2];
	b=a[2][2]*3;
	a[1][3]=b-a[1][1]-a[1][2];
	a[3][1]=b-a[1][3]-a[2][2];
	a[3][3]=b-a[1][1]-a[2][2];
	a[2][1]=b-a[1][1]-a[3][1];
	a[2][3]=b-a[2][1]-a[2][2];
	a[3][2]=b-a[1][2]-a[2][2];
	for(int i=1; i<=3; i++) {
		for(int j=1; j<=3; j++) {
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	int n;
	cin >> n;
	vector<int> a(n+1), b(n+1), c(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	int x = 0, y = 0;
	for (int i = 1; i <= n; i++) {
		if (abs(b[i] - x + c[i] - y) % 2 != (a[i] - a[i-1]) % 2) {cout << "No"; return 0;}
		int dist = abs(b[i] - x) + abs(c[i] - y);
		if (dist > a[i] - a[i-1]) {cout << "No"; return 0;}
		x = b[i]; y = c[i];
	}
	cout << "Yes";
	
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<char,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

ll INF=100000000000000;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N+1,0);
    vector<P> B(N);
    for(ll i=0;i<N;i++){
        cin>>A[i+1];
        B[i]=P(A[i+1],i+1)
    ;}
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    vector<vector<ll>> dp(N+1, vector<ll>(N+1, 0));
    for(ll j=1;j<=N;j++){
        dp[0][j]=dp[0][j-1]+B[j-1].first*(N-j+1-B[j-1].second);
        for(ll i=1;i<=j-1;i++){
            dp[i][j-i]=max(dp[i-1][j-i]+B[j-1].first*(B[j-1].second-i)
            ,dp[i][j-i-1]+B[j-1].first*(N-(j-i)+1-B[j-1].second))
        ;}
        dp[j][0]=dp[j-1][0]+B[j-1].first*(B[j-1].second-j);
    ;}
    ll ans=0;
    for(ll i=0;i<=N;i++){
        ans=max(ans,dp[i][N-i])
    ;}
    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 34684
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    1 2
    /2 = 1.5

    1 2 3 4
    /4 = 2.5

    1 2 3 4 5
    /5 = 3
    """
    N, K = read_ints()
    expectations = [(p+1)/2 for p in read_ints()]
    max_e = current = sum(expectations[:K])
    for i in range(1, N-K+1):
        # remove i-1 add i+K
        current = current-expectations[i-1]+expectations[i+K-1]
        max_e = max(max_e, current)
    return max_e


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 104064