akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<math.h>
typedef struct point{
	int x,y;
}POINT;
char f[5005][5005];
int main(){
	int n,i,j,r,s,t,u,ans=0;
	POINT a[3005],v,m,o;
	while(1){
		scanf("%d",&n);
		if(n==0)break;ans=0;
		memset(f,0,sizeof(f));
		for(i=0;i<n;i++){
			scanf("%d%d",&a[i].x,&a[i].y);
			f[a[i].x][a[i].y]=1;
		}
		//for(i=0;i<n;i++)
		//	printf("%d %d\n",a[i].x,a[i].y);
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(i!=j){
					v.x=a[j].x-a[i].x;v.y=a[j].y-a[i].y;
					m.x=a[i].x+v.y;   m.y=a[i].y-v.x;
					o.x=a[j].x+v.y;   o.y=a[j].y-v.x;
					if(o.x>=0 && o.y>=0 && o.x<=5000 && o.y<=5000 &&
					   m.x>=0 && m.y>=0 && m.x<=5000 && m.y<=5000 && f[o.x][o.y]==1 && f[m.x][m.y]==1){
						if((abs(v.x)+abs(v.y))*(abs(v.x)+abs(v.y))-abs(v.x)*abs(v.y)*2>ans)
								ans=(abs(v.x)+abs(v.y))*(abs(v.x)+abs(v.y))-abs(v.x)*abs(v.y)*2;
					}
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int left=0;
  int right=n;
  int mid=(left+right)/2;
  while(left<=right&&(int)((double)mid*1.08)!=n){
    if((int)((double)mid*1.08)<n){
      left=mid+1;
    }else if((int)((double)mid*1.08)>n){
      right=mid-1;
    }
    mid=(left+right)/2;
  }
  if(right<left){
    cout<<":("<<endl;
  }else{
    cout<<mid<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int s, w;
  cin >> s >> w;
  cout << (s <= w ? "unsafe" : "safe") << endl;
}

Measured memory_bytes: 3584
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi b(n);
    rep(i,n)cin>>b[i];
    vi ans;
    rep(i,n){
        rev(j,b.size()){
            if(j+1==b[j]){
                ans.pb(j+1);
                b.erase(b.begin()+j);
                break;
            }
        }
    }
    if(b.size()){
        cout<<-1<<endl;
        return;
    }
    reverse(all(ans));
    rep(i,n)cout<<ans[i]<<endl;
}

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

int a,b,c,d;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b>>c>>d;
    int k=1;
    while(a>0 && c>0){
        if (k%2==1) c-=b;
        else a-=d;
        k++;
    }
    if (a>0) cout<<"Yes";
    else cout<<"No";
    
    
    
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

int main(){
    lli n,k,a,ans=0,b=0;
    lli i,j;
    vector<lli> vec;
    cin>>n>>k;
    rep(i,0,n){
        cin>>a;
        vec.push_back(a);
    }
    rep(i,0,n-1){
        rep(j,i+1,n){
            if(vec[i]>vec[j]){
                ans++;
                ans%=N;
            }
        }
    }
    rep(i,0,n){
        rep(j,0,n){
            if(vec[i]>vec[j]){
                b++;
            }
        }
    }
//    cout<<ans<<" "<<b<<endl;
    ans*=k;
    ans%=N;
    k=(((k-1)*k)/2)%N;
//    cout<<b*(k/2)<<endl;
    ans+=((b*k)%N);
    ans%=N;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
dic = {}
for i in range(n):
    dic.setdefault(a[i],0)
    dic[a[i]] += 1
ans = []
for item in dic.items():
    if item[1]>=2:
        ans.append(item[0])
if len(ans)<=1:
    print(0)
else:
    ans.sort()
    if dic[ans[-1]]>=4:
        print(ans[-1]**2)
    else:
        print(ans[-1]*ans[-2])


Measured memory_bytes: 22124
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e6 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 2e5 + 17;

int n, m;
string s[maxn];

bool read() {
    if (scanf("%d %d", &n, &m) != 2)
        return false;

    for (int i = 0; i < n; ++i)
        scanf("%s", buff), s[i] = buff;

    return true;
}

void solve() {
    forn (i, n) {
        forn (j, m)
            if (s[i][j] == '#')
                cout << '#';
            else {
                int res = 0;

                for (int a = -1; a <= 1; ++a)
                    for (int b = -1; b <= 1; ++b)
                        if (0 <= i + a && i + a < n && 0 <= j + b && j + b < m)
                            res += (s[i + a][j + b] == '#');

                cout << res;
            }

        cout << endl;
    }
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<queue>

using namespace std;

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

string masu[1000];
int visit[1000][1000];

class T{
	public:
	int y,x,num;
	T(int y,int x,int num):y(y),x(x),num(num){}
};

int main(){
	int h,w,n;
	cin>>h>>w>>n;
	
	rep(i,h){
		cin>>masu[i];
		rep(j,w){
			if(masu[i][j]=='S')masu[i][j]='0';
		}
	}
	
	int ans = 0;
	
	for(int p=0;p<n;p++){
		rep(i,1000)rep(j,1000)visit[i][j]=0;
		
		int sty,stx;
		rep(i,h)rep(j,w)if(masu[i][j]==('0'+p)){
			sty = i;
			stx = j;
		}
		
		queue<T> que;
		que.push(T(sty,stx,0));
		while(1){
			if(que.empty())break;
			
			T u = que.front();
			que.pop();
			
			if(u.x<0 || u.y<0 || u.x>=w || u.y>=h)continue;
			if(visit[u.y][u.x]==1)continue;
			visit[u.y][u.x]=1;
			if(masu[u.y][u.x]=='X')continue;
			
			if(masu[u.y][u.x]==('1'+p)){
				ans += u.num;
				break;
			}
			
			int dx[4]={1,0,-1,0};
			int dy[4]={0,1,0,-1};
			rep(i,4){
				que.push(T(u.y+dy[i], u.x+dx[i], u.num+1));
			}
		}
	}
	
	printf("%d\n",ans);
	
}

Measured memory_bytes: 6172
#include<bits/stdc++.h>
using namespace std;
const int MAX=200005;
int n,p[MAX],u[MAX],fin;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&p[i]);
    for(int i=1;i<=n;i++) u[p[i]]=i;
    int i,j;
    for(i=1;i<=n;i++){
        for(j=i+1;u[j-1]<=u[j];j++);
        fin=max(fin,j-i);
        i=j-1;
    }
    printf("%d\n",n-fin);
}


Measured memory_bytes: 1792
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (Array(n, m) <- in if n != 0) {
        println(in.take(n).toList.transpose.zipWithIndex.sortWith((a, b) => a._1.sum > b._1.sum).map(_._2+1).mkString(" "))
    }
}

Measured memory_bytes: 91572
#include <iostream>
#include <vector>
#include <algorithm>


using ll = long long int;
using namespace std;

int H, W;
vector<string> S;

int yoko[2002][2002];
int tate[2002][2002];


int main() {
  cin >> H >> W;

  for (int i = 0; i < H; i++) {
    string str;
    cin >> str;
    S.push_back(str);
  }

  for (int y = 0; y < H; y++) {
    int torch = 0;
    int x = 0;
    int torchstart = -1;
    int torchend = -1;
    while (x < W) {
      torchstart = x;
      while (torchstart < W && S[y][torchstart] == '#') {
        torchstart++;
      }

      for (torchend = torchstart; torchend < W && S[y][torchend] == '.'; torchend++) {
      }

      for (int i = torchstart; i < torchend; i++) {
        yoko[y][i] = (torchend - torchstart);
      }

      x = torchend;
    }
  }

  for (int x = 0; x < W; x++) {
    int torch = 0;
    int y = 0;
    int torchstart = -1;
    int torchend = -1;
    while (y < H) {
      torchstart = y;
      while (torchstart < H && S[torchstart][x] == '#') {
        torchstart++;
      }

      for (torchend = torchstart; torchend < H && S[torchend][x] == '.'; torchend++) {
      }

      for (int i = torchstart; i < torchend; i++) {
        tate[i][x] = (torchend - torchstart);
      }

      y = torchend;
    }
  }

  int max = 0;

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      max = std::max(max, tate[y][x] + yoko[y][x] - 1);
    }
  }

  cout << max << endl;

  return 0;
}

Measured memory_bytes: 35584
#include<iostream>

using namespace std;

int main(){
	int N, M, Q;
	int abcd[50][4];
	int A[10];
	bool flag = false;
	int maxpoint = 0;
	int nowmaxpoint = 0;

	cin >> N >> M >> Q;

	for(int i = 0; i < Q; ++i){
		cin >> abcd[i][0] >> abcd[i][1] >> abcd[i][2] >> abcd[i][3];
	}

	for(int j = 0; j < N; ++j){
		A[j] = 1;
	}

	while(!flag){
		for(int k = 0; k < Q; ++k){
			if(A[abcd[k][1] - 1] - A[abcd[k][0] - 1] == abcd[k][2]){
				maxpoint += abcd[k][3];
			}
		}

		// 最大値更新
		if(maxpoint > nowmaxpoint){
			nowmaxpoint = maxpoint;
		}

		//数列更新 末尾から
		if(A[N-1] < M){
			++A[N-1];
		}else if(N-2 >= 0 &&
			 A[N-2] < A[N-1]){
				 ++A[N-2];
				 A[N-1] = A[N-2];
		}else if(N-3 >= 0 &&
			A[N-3] < A[N-2]){
				++A[N-3];
				A[N-2] = A[N-3];
				A[N-1] = A[N-3];
		}else if(N-4 >= 0 &&
			A[N-4] < A[N-3]){
				++A[N-4];
				A[N-3] = A[N-4];
				A[N-2] = A[N-4];
				A[N-1] = A[N-4];
		}else if(N-5 >= 0 &&
			A[N-5] < A[N-4]){
				++A[N-5];
				A[N-4] = A[N-5];
				A[N-3] = A[N-5];
				A[N-2] = A[N-5];
				A[N-1] = A[N-5];
		}else if(N-6 >= 0 &&
			A[N-6] < A[N-5]){
				++A[N-6];
				A[N-5] = A[N-6];
				A[N-4] = A[N-6];
				A[N-3] = A[N-6];
				A[N-2] = A[N-6];
				A[N-1] = A[N-6];
		}else if(N-7 >= 0 &&
			A[N-7] < A[N-6]){
				++A[N-7];
				A[N-6] = A[N-7];
				A[N-5] = A[N-7];
				A[N-4] = A[N-7];
				A[N-3] = A[N-7];
				A[N-2] = A[N-7];
				A[N-1] = A[N-7];
		}else if(N-8 >= 0 &&
			A[N-8] < A[N-7]){
				++A[N-8];
				A[N-7] = A[N-8];
				A[N-6] = A[N-8];
				A[N-5] = A[N-8];
				A[N-4] = A[N-8];
				A[N-3] = A[N-8];
				A[N-2] = A[N-8];
				A[N-1] = A[N-8];
		}else if(N-9 >= 0 &&
			A[N-9] < A[N-8]){
				++A[N-9];
				A[N-8] = A[N-9];
				A[N-7] = A[N-9];
				A[N-6] = A[N-9];
				A[N-5] = A[N-9];
				A[N-4] = A[N-9];
				A[N-3] = A[N-9];
				A[N-2] = A[N-9];
				A[N-1] = A[N-9];
		}else if(N-10 >= 0 &&
			A[N-10] < A[N-9]){
				++A[N-10];
				A[N-9] = A[N-10];
				A[N-8] = A[N-10];
				A[N-7] = A[N-10];
				A[N-6] = A[N-10];
				A[N-5] = A[N-10];
				A[N-4] = A[N-10];
				A[N-3] = A[N-10];
				A[N-2] = A[N-10];
				A[N-1] = A[N-10];
		}else{
			flag = true;
		}
		maxpoint = 0;
	}

	cout << nowmaxpoint << endl;

}

Measured memory_bytes: 3612
c = [list(map(int,input().split())) for x in range(3)]

a = [0]*3
b = [0]*3

for i in range(3):
    b[i] = c[0][i] - a[0]
a[1] = c[1][1] - b[1]
a[2] = c[2][2] - b[2]

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i]+b[j]:
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<int> a(N);rep(i,N)cin >> a[i];
    map<int,int> m;
    rep(i,N){
        m[a[i]]++;
        m[a[i]-1]++;
        m[a[i]+1]++;
    }
    int ans = 0;
    for(auto t : m){
        ans = max(ans,t.S);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5120
#include <stdio.h>
int main(void)
{
	int i, get;
	int max=0, cnt[100]={0};
	while(scanf("%d", &get) != EOF)
	{
		if(0<=get && get<100)
			cnt[get]++;
	}
	for(i=0; i<100; i++) // Check ModeValue
	{
		if(max<cnt[i])
			max = cnt[i];
	}
	for(i=0; i<100; i++)
	{
		if(cnt[i] == max)
			printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
int main(){
	int N,K,X,Y;
	scanf("%d %d %d %d",&N,&K,&X,&Y);
	if (N <= K) 
	{
		printf("%d\n",N*X);
		}
	else 
	{
		printf("%d\n",K*X+(N-K)*Y);
		}
	return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 100005
using namespace std;

int main()
{
    FLASH
    for(int i = 0; i < 5; i++)
    {
        int x;
        cin >> x;
        if(x == 0)
        {
            cout << i + 1 ;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[100000];
int u[100000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,w;
  cin >>a>>s;
  int ans=0;
  for(int n=0;n<a-2;n++){
    if(s[n]=='A'&&s[n+1]=='B'&&s[n+2]=='C') ans++;
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(double N){
    for(double h=1;h<=3500;h++){
        for(double n=1; n<=3500; n++){
            if((4*h*n-N*n-N*h)==0)continue;
            double w = (N*h*n)/(4*h*n-N*n-N*h);
            if(w>0 && (LL)(N*h*n)%(LL)(4*h*n-N*n-N*h)==0 && 4/N == 1/h+1/n+1/w){
                cout<<(LL)h<<" "<<(LL)n<<" "<<(LL)w<<endl;
                return;
            }
        }
    }
    return;

}

int main(){
    double N;
    scanf("%lf",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
int solve1(int n,int k)
{
	if(n%k==0) return n/k;
	return solve1(n-n/k-1,k);
}
int solve2(int n,int k)
{
	if(n%k==0) return n/k;
	int d=n/k*k,go=(n-d)/(n/k+1);
	if(!go) return solve2(n-n/k-1,k);
	return solve2(n-go*(n/k+1),k);
}
signed main()
{
	int n=read(),ans=0;
	for(int i=1;i<=n;i++)
	{
		int a=read(),b=read();
		if(b<=10000) ans^=solve1(a,b);
		else ans^=solve2(a,b);
	}
	if(ans) cout<<"Takahashi\n";
	else cout<<"Aoki\n";
	return 0;
}




Measured memory_bytes: 3612
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <cmath>
# include <functional>
# include <utility>
# define MOD 1000000007
# define INF 2000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll sum = 0, ans = 0, pass = 0, counter = 0;
	ll  a = 0, b = 0, c = 0, k = 0, n = 0, m = 0;
	//newdefine
	vector<ll> height;
	cin >> a>>c;
	rep(i, a) {
		cin >> b;
		if (b >= c)counter++;
	}
	cout << counter << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main(){
char a[4];
int cnt=0;
for(int i=0;i<4;i++){
cin >> a[i];
if(a[i]=='+'){
    cnt++;
}else{
  cnt--;
}
}
cout << cnt << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6;
int arr[maxn];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n; cin>>n;
    memset(arr,0,sizeof(arr));
    int temp;
    for(int i=1;i<=n;i++){
    	cin>>temp; arr[temp]++;
    }
    int ans=0;
    for(int i=0;i<(maxn-2);i++){
    	ans=max(ans,arr[i]+arr[i+1]+arr[i+2]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4224
#pragma GCC optimize ("O3")
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
 
int Parent(int n, vector<int> & p) {
	if (p[n] == n)
		return n;
	return p[n] = Parent(p[n], p);
}
 
int main(void) {
	int num, i, m, k, a, b;
	cin >> num >> m >> k;
	vector<int> p(num + 1), s(num + 1, 1);
	vector<map<int, int>> x(num + 1);
	rep(i, num + 1) {
		p[i] = i;
	}
	rep(i, m) {
		cin >> a >> b;
		x[a][b]++;
		x[b][a]++;
		a = Parent(a, p);
		b = Parent(b, p);
		if (a != b) {
			p[b] = a;
			s[a] += s[b];
		}
	}
	rep(i, k) {
		cin >> a >> b;
		if (Parent(a, p) == Parent(b, p)) {
			x[a][b]++;
			x[b][a]++;
		}
	}
	for (i = 1; i <= num; i++) {
		a = Parent(i, p);
		cout << s[a] - x[i].size() - 1 << " ";
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 25472
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int a,b,c;

    scanf("%d %d %d", &a, &b, &c);

    if( a+b+c >=22)
        printf("bust\n");
    else
        printf("win\n");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
static int max(int x,int y,int z){
	int max=-10001;
	if(x>max)max=x;
	if(y>max)max=y;
	if(z>max)max=z;
	return max;
}
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b =sc.nextInt();
	System.out.println(max((a-b), (a+b), (a*b)));
	sc.close();
}
}


Measured memory_bytes: 23764
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int AB = input[0];
            int BC = input[1];
            Console.WriteLine(BC * AB / 2);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

const ll MOD=(ll)1e9+7;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll a,b;cin>>a>>b;
    if(max(a,b)<10ll)cout<<a*b<<"\n";
    else cout<<"-1\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define INF 1000000007
#define MOD 998244353
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const ll mod = 1000000007;

struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

void Main(){

    int n;
    cin >> n;
    mint a = 10;
    mint b = 9;
    mint c = 8;
    a = a.pow(n);
    b = b.pow(n);
    c = c.pow(n);
    mint ans = a - b*2 + c;
    cout << ans << endl;
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





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

int main() {
	int n;
	cin >> n; 
	long long int l, r;
	n--;
	cin >> l >> r;
	while(n--) {
		long long int a, b;
		cin >> a >> b;
		long long int mini = max(l / a + (l % a != 0), r / b + (r % b != 0));
		l = mini * a;
		r = mini * b;
	}
	cout << l + r << endl;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())


def oto(num,yen):
    for x in range(num+1):
        for y in range(num+1):
            z = num - x -y
            if yen - (10000*x + 5000*y + 1000*z) == 0 and \
                    x + y + z == num and \
                    0 <= z <=num:
                print(x,y,z)
                return

    print('-1 -1 -1')

oto(N,Y)

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)


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

    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int tmins = (H2 - H1)*60 + (M2 - M1);
    int ans = tmins - K;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,n_updated, sum;
  cin >> n;
  n_updated = n;
  sum = 0;

  for (int i = 0; i < 8; i++) {
    sum += n_updated % 10;
    n_updated /= 10;
  }
  
  if (n % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int N,C;
int field[10][10];
bool visited[10][10];

int dx[]={-1, 0,-1, 1,0,1};
int dy[]={-1, -1, 0, 0, 1, 1};

void dfs(int x, int y, int n, bool& flg, int& cnt)
{
	if(field[x][y] == n) cnt++;
	if(field[x][y] == 0) {
		flg = true;
		return;
	}

	visited[x][y] = true;

	for(int i=0; i<6; i++) {
		int tx = x+dx[i];
		int ty = y+dy[i];
		
		if(tx<0||ty<0||tx>ty||ty>=N) continue;
		if(visited[tx][ty]) continue;
		if(field[tx][ty]!=0 && field[tx][ty] != n) continue;

		dfs(tx,ty,n,flg,cnt);
	}
}

int solve(int M)
{
	memset(visited, 0, sizeof(visited));

	int res = 0;
	for(int i=0; i<N; i++)
	for(int j=0; j<=i; j++) {

		int n = field[j][i];
		if(n==0) continue;

		if(!visited[j][i]) {
			bool flg = false;
			int cnt = 0;
			dfs(j,i,n,flg,cnt);

			if(!flg) {
				if(n==C) res -= cnt; else res += cnt;
			}
		}
	}

	return res;
}

int main()
{
	while(cin >> N >> C, (N||C)) {
		
		int M=0, cnt=0;
		for(int i=0; i<N; i++)
		for(int j=0; j<=i; j++) {
			cin >> field[j][i];
			M = max(M, field[j][i]);
			if(field[j][i]==C) cnt++;
		}

		int res = -(1<<24);
		for(int i=0; i<N; i++)
		for(int j=0; j<=i; j++) {
			if(field[j][i]==0) {
					field[j][i] = C;
					res = max(res, solve(M));
					field[j][i] = 0;
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 0
import sys
N, Y = map(int, input().split())

for x in range(N+1):
  for y in range(N+1):
    z = N-(x+y)
    if z < 0: break
    elif 10000*x + 5000*y + 1000*z == Y:
      print(x,y,z)
      sys.exit()

print(-1,-1,-1)

Measured memory_bytes: 3060
package main
import (
  "fmt"
  "sort"
)
var(
  N int
  a int
  b int
  c int
  l []int
)
func main(){
  fmt.Scan(&N)
  a=0
  b=1
  l=make([]int,N)
  for a:=0;a<N;a++{
    fmt.Scan(&b)
    l[a]=b
  }
  sort.Ints(l)
  a=0
  if l[0]==0{
    fmt.Println(0)
    goto L
  }
  c=1
  for a:=0;a<N;a++{
    if l[a]<=1000000000000000000/c{
      c*=l[a]
    }else{
      fmt.Println(-1)
      goto L
    }
  }
  fmt.Println(c)
  L:
}

Measured memory_bytes: 6324
import Data.List
main=print.f=<<readLn
f n=length.group.sort$a++filter(g n)b where
  [a,b]=map(d[]2)[n-1,n]
g n i=case n`mod`i of
  0 -> g(n`div`i)i
  1 -> True
  _ -> False
d r i m
  |i*i>m=if m>1 then m:r else r
  |m`mod`i==0=d(m`div`i:i:r)(i+1)m
  |otherwise=d r(i+1)m

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

int matrix[10][10];

int main()
{
  int c = 1;
  int n;

  while (cin >> n)
  {
    if (n==0) return 0;
    printf("Case %d:\n", c); c++;

    int label = 1;
    for (int s=0;s<=2*(n-1);s++)
    {
      if (s%2 == 1)             // s????\???°?????????????????????
      {
        for (int i=max(s-n+1, 0);i<=min(s, n-1);i++)
        {
          int j = s-i;
          matrix[i][j] = label;
          label++;
        }
      }
      else                      // s?????¶??°?????????????????????
      {
        for (int i=min(s, n-1);i>=max(s-n+1, 0);i--)
        {
          int j = s-i;
          matrix[i][j] = label;
          label++;
        }
      }
    }
    for (int i=0;i<n;i++)
    {
      for (int j=0;j<n;j++)
      {
        printf("%3d", matrix[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1164
S=input()

l = len(S)
ans = True

while(l>0):
    if l<=4:
        ans=False
        break
    if l>=5:
        if S[-5:] == "erase" or S[-5:]=="dream":
            S = S[:-5]
            l = l-5
            continue
    if l>=6:
        if S[-6:] == "eraser":
            S = S[:-6]
            l = l-6
            continue
    if l>=7:
        if S[-7:] == "dreamer":
            S = S[:-7]
            l = l-7
            continue
    ans = False
    break

if not ans:
    print("NO")
else:
    print("YES")



Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,C,D;cin>>A>>B>>C>>D;
  cout << (A+B==C+D?"Balanced":A+B<C+D? "Right":"Left")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll; 
const int maxn=1e6+5;
const int mod=998244353;
int p[maxn],q[maxn],r[maxn];
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
    int x,y,a,b,c;
    scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
    for(int i=1;i<=a;i++) scanf("%d",&p[i]);
    for(int i=1;i<=b;i++) scanf("%d",&q[i]);
    for(int i=1;i<=c;i++) scanf("%d",&r[i]);
    sort(p+1,p+a+1,cmp);
    sort(q+1,q+b+1,cmp);
    sort(r+1,r+c+1,cmp);
    int f1,f2,f3;
    f1=f2=f3=1;
    ll ans=0;
    while(f1<=x||f2<=y)
    {
        int ma=max(p[f1],q[f2]);
        ma=max(ma,r[f3]);
        if(p[f1]==ma)
        {
            ans+=p[f1++];
        }
        else if(q[f2]==ma)
        {
            ans+=q[f2++];
        }
        else
        {
            ans+=r[f3++];
            int mi=min(p[x],q[y]);
            if(mi==p[x])
            {
                x--;
            }
            else
            {
                y--;
            }
        }
        if(f1>x) {p[f1]=0;p[x]=1e9+5;};
        if(f2>y) {q[f2]=0,q[y]=1e9+5;};
    }
    printf("%lld\n",ans);
    return 0;
}                           

Measured memory_bytes: 8832
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL H,W,N;
LL A[10001];

vector<vector<LL>> ans;

void solve(){
	int color = 1;
	auto paint = [&](int h,int w){
		ans[h][w] = color;
		A[color]--;
		if(A[color]==0) color++;
	};
	for(int h=0;h<H;h++){
		if(h%2==0){
			for(int w=0;w<W;w++){
				paint(h,w);
			}
		}else{
			for(int w=W-1;w>=0;w--){
				paint(h,w);
			}
		}
	}
}

int main(){
    cin >> H >> W >> N;
    ans = vector<vector<LL>>(H,vector<LL>(W,0));
    for(int i=1;i<=N;i++) cin >> A[i];

    solve();

	for(int i=0;i<ans.size();i++){
		for(int j=0;j<ans[i].size();j++) cout  << ans[i][j] << " ";
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 764
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0

for i in range(N):
	A = list(map(int, input().split()))
	sum = C
	for j in range(M): sum += A[j] * B[j]
	if sum > 0: ans += 1

print(ans)


Measured memory_bytes: 2940
#include <iostream>

int main(void)
{
    int n, a, b, sum = 0;
    std::cin >> n >> a >> b;
    for (int i = 1; i <= n; ++i)
    {
        int p = (i % 100000) / 10000;
        int q = (i % 10000) / 1000;
        int r = (i % 1000) / 100;
        int s = (i % 100) / 10;
        int t = (i % 10) / 1;
        int d = p + q + r + s + t;
        if ((a <= d) && (d <= b))
        {
            sum += i;
        }
    }
    std::cout << sum << std::endl;
}


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

int main(int argc, char *argv[]){

  int k;
  scanf("%d", &k);

  char s[101];
  scanf("%s", s);

  int n;
  if(strlen(s)>k){
    n = k;
  }else{
    n = strlen(s);
  }
  for(int i=0; i<n; i++){
    printf("%c", s[i]);
  }
  if(strlen(s)>k){
    //for(int i=n; i<strlen(s); i++){
      //printf(".");
    //}
    printf("...");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int a, b, c; cin >> a >> b >> c;

	cout << a * b / 2 << '\n';





}

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

#define IL inline 
IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f; 
}

int n, x, y, z;

const int mod = 1e9 + 7;

IL int pls(int x, int y) { x += y; return x >= mod ? x - mod : x; }
IL int dec(int x, int y) { x -= y; return x < 0 ? x + mod : x; }
IL int mul(int x, int y) { return 1ll * x * y % mod; }
IL int mul(int x, int y, int z) { return mul(mul(x, y), z); }
IL int mul(int a, int b, int c, int d) { return mul(mul(a, b), mul(c, d)); }

IL int fpw(int x, int y) {
	int r = 1;
	for (; y; y >>= 1, x = mul(x, x)) 
		if (y & 1) r = mul(r, x);
	return r;
}

int f[50][(1 << 18)];
int main() {

	n = read(), x = read(), y = read(), z = read();
	int ans = fpw(10, n);
	int tot = (1 << x - 1) | (1 << x + y - 1) | (1 << x + y + z - 1);
	int MAX = (1 << x + y + z) - 1;
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= MAX; ++j) {
			if (!f[i - 1][j]) continue;
			for (int k = 1; k <= 10; ++k) {
				int cur = ((j << k) | (1 << k - 1)) & MAX;
				if ((cur & tot) != tot) f[i][cur] = pls(f[i][cur], f[i - 1][j]);
			}
		}
	}
	for (int i = 0; i <= MAX; ++i) ans = dec(ans, f[n][i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 41216
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 4e3 + 5;
const int MOD = 1e9 + 7;

void iadd(int &dp, int val) {
    dp += val;
    if (dp >= MOD) {
        dp -= MOD;
    }
}

int dp[N][N], sum[N][N];

int main() {
    int n = read();
    int m = read() - 1;
    int k = read() - 1;

    dp[0][0] = 1;
    fill(sum[0], sum[0] + n + 1, 1);
    int ans = 0;
    for (int i = 1; i <= n + m; ++i) {
        for (int s1 = 0; s1 <= n; ++s1) {
            int s2 = k * i - s1;
            if (s2 < 0 || s2 > m) continue;
            if (s1) dp[i][s1] = sum[i - 1][s1 - 1];
            if (s1 >= k + 1) {
                iadd(dp[i][s1], MOD - sum[i - 1][s1 - k - 1]);
            }
            if ((s1 - n) % k == 0 && (s2 - m) % k == 0) {
                iadd(ans, dp[i][s1]);
            }
            iadd(dp[i][s1], dp[i - 1][s1]);
        }
        int cur = 0;
        for (int j = 0; j <= n; ++j) {
            iadd(cur, dp[i][j]);
            sum[i][j] = cur;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 124800
#include<iostream>
using namespace std;
char a[200005];

int main(){
	int k;
	int total=0;
	int count=0;
	cin>>k;
	for(int i=1;i<=k;i++){
		cin>>a[i];
		if(a[i]=='R'){
			count++;
		}
	}
	for(int i=1;i<=count;i++){
		if(a[i]!='R'){
			total++;
		}
	}
	cout<<total<<endl;
}

Measured memory_bytes: 3824
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979
int main()
{
    double a, b, h, m, hour_ang, sec_ang, ang;
    cin >> a >> b >> h >> m;
    hour_ang = 2 * pi * h / 12 + 2 * pi * m / 720;
    sec_ang = 2 * pi * m / 60;
    if (hour_ang > sec_ang) ang = hour_ang - sec_ang;
    else ang = hour_ang - sec_ang;
    printf("%.19lf", sqrt(a * a + b * b - 2 * a * b * cos(ang)));
    return 0;
}

Measured memory_bytes: 4224
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000


N,X = map(int,input().split())
L = [int(i) for i in input().split()]

cnt = 1
now = 0
for i in range(N):
    now += L[i]
    if now <= X:
        cnt += 1
    else:
        break

print(cnt)


Measured memory_bytes: 7876
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def ceil(x,y):
  return (x-1)//y+1


def solve_binary(mid,k):
    return k < XH[mid][0]

def binary_search(s,n,k):
    ok=n
    ng=s
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve_binary(mid,k):
            ok=mid
        else:
            ng=mid
    return ok

n,D,A=map(int,input().split())
XH=[tuple(map(int,input().split())) for i in range(n)]
XH.sort(key=lambda tup: tup[0])
XH.append((inf,0))
data=[0]*(n+1)
# if D==0:
#     for xi,hi in XH:
#         count += ceil(hi,A)
#     print(count)
#     exit()
for i in range(n):
    xi,hi = XH[i]
    hi-=data[i]
    K=max(0,ceil(hi,A)*A); count += max(0,ceil(hi,A))
    data[i]+=K; data[binary_search(i,n,xi+2*D)]-=K
    data[i+1]+=data[i]
print(count)

Measured memory_bytes: 77788
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	vector<int> a;
	int g,m[10];
	g=1;
	rep(i,10)m[9-i]=g<<i;
	while(~scanf("%d",&g)){
		a.clear();
		rep(i,10)if(m[i]<=g){
			g-=m[i];
			a.push_back(m[i]);
		}
		sort(a.begin(),a.end());
		rep(i,a.size())printf("%d%c",a[i],i<a.size()-1?' ':'\n');
	}
	return 0;
}

Measured memory_bytes: 1212
//#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	cout<<(n+m-1)/m;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

const double Eps = 1e-8;

int main()
{
	int n, m;
	while (scanf("%d %d", &n, &m), n | m)
	{
		double g[100][100];
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				scanf("%lf", &g[i][j]);
		double rates[2][100];
		for (int i = 0; i < n; ++i)
			rates[0][i] = 1;

		for (int c = 1; c < m; ++c)
		{
			for (int i = 0; i < n; ++i)
			{
				rates[c & 1][i] = -1;
				for (int j = 0; j < n; ++j)
					rates[c & 1][i] = max(rates[c & 1][i], rates[(c+1) & 1][j] * g[j][i]);
			}
		}
		double ans = -1;
		for (int i = 0; i < n; ++i)
			ans = max(ans, rates[(m+1) & 1][i]);
		printf("%.2f\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
n = gets.to_i
arr = []
5.times{arr << gets.to_i}
arr2 = [n, 0, 0, 0, 0, 0]
5.times{
    4.downto(0){|i|
        arr2[i + 1] += [arr2[i], arr[i]].min
        arr2[i] -= [arr2[i], arr[i]].min
    }
}
puts (n.to_f / arr2[5]).ceil + 4

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    while(y > 0) {
        ll tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

bool is_prime(ll x) {
    if (x == 1) return false;
    else if (x == 2) return true;
    else if (x % 2 == 0) return false;
    else {
        for (ll i = 3; i*i <= x; i += 2) {
            if (x % i == 0) return false;
        }
    }
    return true;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll n = gcd(a, b);

    vector<ll> divisor;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            divisor.push_back(i);
            if (i * i != n) divisor.push_back(n / i);
        }
    }
    sort(all(divisor));

    int ans = 1;
    for (auto i : divisor) {
        if (is_prime(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

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

int main() {
    ll N, Q;
    cin >> N >> Q;
    vector<vector<ll>> Tree(N,vector<ll>());
    for(int i=0;i<N-1;i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        Tree[a].push_back(b);
        Tree[b].push_back(a);
    }
    vector<ll> pos(N,0);
    for(int i=0;i<Q;i++){
        ll p,x;
        cin >> p >> x;
        p--;
        pos[p]+=x;
    }
    ll s = 0;
    queue<ll> que;
    que.push(s);
    vector<ll> seen(N,0);
    while(!que.empty()){
        ll s = que.front();
        que.pop();
        seen[s]=1;
        for(auto e : Tree[s]){
            if(seen[e]==1)continue;
            else{
                pos[e]+=pos[s];
                que.push(e);
            }
        }
    }
    for(int i=0;i<N;i++){
        cout << pos[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 19440
import numpy as np
from collections import deque

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#': continue
        q = deque()
        q.append([i, j, 0])
        visited = np.zeros((h + 5, w + 5), dtype = bool)
        visited[i][j] = True
        dirr = [[1, 0], [0, 1], [-1, 0], [0, -1]]
        mx = 0
        while len(q) != 0:
            x, y, z = q[0]
            for p in range(4):
                nx, ny = x + dirr[p][0], y + dirr[p][1]
                if 0 <= nx < h and 0 <= ny < w:
                    if not visited[nx][ny] and s[nx][ny] == '.':
                        q.append([nx, ny, z + 1])
                        visited[nx][ny] = True
                        ans = max(ans, z + 1)
            q.popleft()
print(ans)


Measured memory_bytes: 14404
n = int(input())
h = list(map(int,input().split()))

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(1,n-1):
    dp[i+1] = min(dp[i-1] + abs(h[i+1] - h[i-1]),dp[i] + abs(h[i+1] - h[i]))
print(dp[-1])

Measured memory_bytes: 13980