akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll>h(n),a(m),b(m),ans(n,1);
  for(int i=0; i<n; i++) cin >> h[i];
  for(int i=0; i<m; i++) cin >> a[i] >> b[i];
  
  for(int i=0; i<m; i++){
   if(h[a[i]-1]>=h[b[i]-1]) ans[b[i]-1]=0;
   if(h[a[i]-1]<=h[b[i]-1]) ans[a[i]-1]=0;
   
  }
  
  ll count=0;
  for(int i=0; i<n; i++){
   if(ans[i]==1) count++;
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
#define NMAX 101
#define REP(a, b) for(int a=0;a<b;a++)
int main(void){
  int N, T, L, B;
  while(cin >> N >> T >> L >> B, N | T | L | B){
    vector<bool> Lose(N+1, false), Back(N+1, false);
    for(int i=0; i < L; i++){
      int k; cin >> k;
      Lose[k] = true;
    }
    for(int i=0; i < B; i++){
      int k; cin >> k;
      Back[k] = true;
    }
    vector< vector< double > >dp(N+7, vector<double>(T+3, 0));
    dp[0][0] = 1;
    REP(j, T){
      REP(i, N+1){
	if(i == N){dp[i][j+1] += dp[i][j]; continue;}
	for(int k=1; k <=6; k++){
	  int n = i + k;
	  if(i+k > N){
	    n = N-(k-(N-i));
	  }
	  if(Lose[n]){
	    dp[n][j+2] += 1/6.0 * dp[i][j];
	  }else if(Back[n]){
	    dp[0][j+1] += 1/6.0 * dp[i][j];
	  }else{
	    dp[n][j+1] += 1/6.0 * dp[i][j];
	  }
	  
	}
      }
    }
    printf("%.10lf\n", dp[N][T]);
  }
}
















  /*
  for(int i=1; i <= 6; i++){
    p[i] = 1;
  }
  for(int i = 7; i <= NMAX; i++){
    p[i] = 0;
  }
  for(int i = 7; i <= NMAX; i++){
    for(int j=1; j < 6; j++){
      p[i] += p[i-j];
    }
  }
  cout << p[100] << endl;
  */

Measured memory_bytes: 1328
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;


int main()
{
    int n;
    cin >>n;
    vector<int> count(n, 0);
    int x=1, y=1, z=1;
    int a;

    for (x = 1;; x++) {
        for (y = 1;; y++) {
            for (z = 1;; z++) {
                a = (x + y + z) *(x + y + z) - x * y - y * z - z * x;
                if (a <= n) {
                    count[a - 1]++;
                }
                else {
                    break;
                }
            }
            if (a > n&&z == 1) break;
        }
        if (a > n&&y == 1) break;
    }


    for (int i = 0; i < n; i++) {
        cout << count[i]<<endl;
    }


    return 0;
}



Measured memory_bytes: 3552
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)
#define eps 0.3

using namespace std;
typedef double db;
typedef long long ll;
const double pi=acos(-1);
const ll N=54e5,K=32000,mo=1e9+7;

ll jc[N],ny[N];
int bits[N];
int B,W,mm,ss;
ll ans[N],ko[N];

inline ll ksm(ll o,ll t)
{
	ll y=1;
	for(;t;t>>=1,o=o*o%mo)
	if(t&1)y=y*o%mo;
	return y;
}

struct Z{
    db x,y;
    Z(db _x=0,db _y=0){x=_x;y=_y;}
}a[N],b[N],c[N],d[N],t[N];

Z operator +(Z a,Z b){return Z(a.x+b.x,a.y+b.y);}
Z operator -(Z a,Z b){return Z(a.x-b.x,a.y-b.y);}
Z operator *(Z a,Z b){return Z(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);}

void dft(Z *a,int sig)
{
    fo(i,0,mm-1)if(bits[i]<i)swap(a[i],a[bits[i]]);
    for(int m=2;m<=mm;m<<=1){
        int half=m/2;
        fo(i,0,half-1){
            Z w(cos(i*pi*sig/half),sin(i*pi*sig/half));
            Z v;
            for(int j=i;j<mm;j+=m){
            	v=w*a[j+half];
            	a[j+half]=a[j]-v;
            	a[j]=a[j]+v;
            }
        }
    }
    if(sig==-1)fo(i,0,mm-1)a[i].x=a[i].x/mm;
}

inline ll C(int a,int b)
{return (a<b||b<0)?(0):(jc[a]*ny[b]%mo*ny[a-b]%mo);}

int main()
{
	scanf("%d%d",&B,&W);
	int n=B+W;
	jc[0]=ny[0]=1;
	fo(i,1,n)jc[i]=jc[i-1]*i%mo;
	ny[n]=ksm(jc[n],mo-2);
	fd(i,n-1,1)ny[i]=ny[i+1]*(i+1)%mo;
	fo(i,0,W-1)a[i].x=ny[i]/K,b[i].x=ny[i]%K;
	fo(i,0,B-1)c[i].x=ny[i]/K,d[i].x=ny[i]%K;
	mm=1,ss=0;
	while(mm<=n*2)mm<<=1,++ss;
	fo(i,1,mm-1)bits[i]=(bits[i>>1]>>1)|((i&1)<<ss-1);
	dft(a,1); dft(b,1); dft(c,1); dft(d,1);
	fo(i,0,mm-1)t[i]=a[i]*c[i];
	fo(i,0,mm-1)a[i]=a[i]*d[i]+b[i]*c[i];
	fo(i,0,mm-1)d[i]=d[i]*b[i];
	dft(a,-1); dft(t,-1); dft(d,-1);
	fo(i,1,n){
		ll xs=ksm((mo+1)>>1,i);
		ans[i]=((ll)(t[i-1].x+eps)%mo)*K%mo*K%mo;
			ans[i]=ans[i]+((ll)(a[i-1].x+eps))%mo*K%mo;
			ans[i]=(ans[i]+(ll)(d[i-1].x+eps))%mo;
		//	ans=(ans)%mo;
			ans[i]=ans[i]*jc[i-1]%mo*xs%mo;
	}
	fo(i,1,n)ko[i]=(C(i,W)-C(i-1,W)+mo)*ksm((mo+1)>>1,i)%mo;
	fo(i,1,n)ko[i]=(ko[i-1]+ko[i])%mo;
	fo(i,1,n){
		ans[i]=(ans[i]+ko[i-1])%mo;
		printf("%lld\n",ans[i]);
	}
}

Measured memory_bytes: 440448
#include <stdio.h>
#define M_MAX 1000000
#define CAVE_WIDTH 1002
#define CAVE_HEIGHT 1002

typedef struct point{ int x; int y; } Point;  /* 座標を表す構造体 */
typedef struct result{ int num; int last; } Result;  /* 探索の戻り値のための構造体 */

/* 洞穴関連 */
int prime[M_MAX+1];  /* 素数か判定する配列 */
int cave[CAVE_WIDTH][CAVE_HEIGHT];  /* 洞穴番号 */
Point origin = {CAVE_WIDTH / 2, CAVE_HEIGHT / 2};  /* 原点の座標 */

/* 探索関連 */
Result dp[CAVE_WIDTH][CAVE_HEIGHT];  /* 探索のメモ */

/* 入力関連 */
int m;
int n;


/* 初期化する */
int init(){
	int i, j, x, y, l;

	/* i が素数か判定する配列 prime[i] を生成する */
	prime[0] = 0;
	prime[1] = 0;
	for (i = 2; i <= M_MAX; i++){
		prime[i] = 1;
	}
	for (i = 2; i <= M_MAX; i++){
		if (prime[i] == 1){
			for (j = i + i; j <= M_MAX; j += i){
				prime[j] = 0;
			}
		}
	}

	/* 縦横に並んだ洞穴に番号をふる */
	for (i = 0; i < CAVE_WIDTH; i++){
		for (j = 0; j < CAVE_HEIGHT; j++){
			cave[i][j] = 0;
		}
	}
	x = origin.x;
	y = origin.y;
	cave[x][y] = 1;
	x++;
	/* 渦巻きの一辺の長さは一周するごとに 2 ずつ増える */
	for (i = 2, l = 2; i <= M_MAX; l += 2){
		for (j = 0; j < l-1 && i <= M_MAX; j++, i++, y--) cave[x][y] = i;
		for (j = 0; j < l   && i <= M_MAX; j++, i++, x--) cave[x][y] = i;
		for (j = 0; j < l   && i <= M_MAX; j++, i++, y++) cave[x][y] = i;
		for (j = 0; j < l+1 && i <= M_MAX; j++, i++, x++) cave[x][y] = i;
	}
}

/* 指定された番号の洞穴の座標を返す */
Point toXY(int i){
	int x, y;
	if (i == 1) return origin;

	/* とりあえず探索 */
	for (x = 0; x < CAVE_WIDTH; x++){
		for (y = 0; y < CAVE_HEIGHT; y++){
			if (cave[x][y] == i){
				Point p = {x, y};
				return p;
			}
		}
	}
}

/* 探索関連の変数を初期化する */
int reset(){
	int i, j;
	for (i = 0; i < CAVE_WIDTH; i++){
		for (j = 0; j < CAVE_HEIGHT; j++){
			dp[i][j].num = -1;
		}
	}
}

/* 指定された座標から降下したときに通過できる素数洞穴の最大数を返す */
Result search(int x, int y){
	Result max = {0, 0};
	Result r;
	int  i;

	/* 探索終了 */
	if (x < 0 || x >= CAVE_WIDTH || y < 0 || y >= CAVE_HEIGHT || cave[x][y] > m) return max;
	if (dp[x][y].num != -1) return dp[x][y];

	if (prime[cave[x][y]]) max.last = cave[x][y];

	/* 次の洞穴を探索する */
	for (i = -1; i <= 1; i++){
		r = search(x + i, y + 1);
		/* 素数洞穴の最大数を保持する */
		if (r.num > max.num) max = r;
		else if (r.num == max.num && r.last > max.last) max.last = r.last;
	}

	max.num += prime[cave[x][y]];
	return dp[x][y] = max;
}

int main(void){
	Point p;
	Result r;

	init();  /* プログラムの初期化 */

	while (scanf("%d%d", &m, &n) == 2){
		if (m < 1 || m > 1000000 || n < 1 || n > m) break;

		reset();  /* このデータセットについての初期化 */

		p = toXY(n);
		r = search(p.x, p.y);  /* 探索 */
		printf("%d %d\n", r.num, r.last);  /* 出力 */
	}

    return 0;
}

Measured memory_bytes: 16348
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
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;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long A, long long B){
  set<ll> s;
  s.insert(A);s.insert(B);
  FOR(i,1,4){
    if(s.count(i)==0){
      cout<<i<<endl;
      return;
    }
  }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
    }
    int mn = INF;
    vector<int> vertices;
    for (int i = 0; i < n; ++i) {
        vector<int> visited(n, 0), p(n), dist(n);
        queue<int> q;
        visited[i] = 1;
        q.push(i);
        dist[i] = 0;
        p[i] = -1;
        bool exit = false;
        while (!q.empty()) {
            int cur = q.front();
            q.pop();
            for (int ngb : g[cur]) {
                if (ngb == i) {
                    if (dist[cur] + 1 < mn) {
                        mn = dist[cur] + 1;
                        vector<int> new_verts;
                        new_verts.reserve(mn);
                        int v = cur;
                        while (v != -1) {
                            new_verts.push_back(v);
                            v = p[v];
                        }
                        vertices = new_verts;
                        exit = true;
                        break;
                    }
                }
                if (visited[ngb]) {
                    continue;
                }
                q.push(ngb);
                p[ngb] = cur;
                dist[ngb] = dist[cur] + 1;
                visited[ngb] = 1;
            }
            if (exit) {
                break;
            }
        }
    }
    if (mn == INF) {
        cout << "-1\n";
        return;
    }
    cout << mn << '\n';
    for (int i = 0; i < mn; ++i) {
        cout << vertices[i] + 1 << '\n';
    }
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}


Measured memory_bytes: 384
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }

  getChildrenNumber() {return Number(this.left !== null) + Number(this.right !== null);}

  isLeftChild() {
    if (this.parent === null) return null;
    return this.parent.left === this;
  }

  getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

  getSuccessor() {
    let n;
    if (this.right !== null) {
      n = this.right;
      while (n.left !== null) n = n.left;
    } else {
      n = this.parent;
      while (!n.isLeftChild && n.parent != null) n = n.parent;
    }
    return n;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    if (this.root === null) {
      this.root = new BinaryTree.Node(key);
      return;
    }
    let x = this.root, y;
    let newNode = new BinaryTree.Node(key);
    while (x !== null) {
      y = x;
      x = x[key < x.key ? 'left' : 'right'];
    }
    newNode.parent = y;
    y[key < y.key ? 'left' : 'right'] = newNode;
  }

  find(key, n = this.root) {
    if (n === null || n.key === key) return n;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  delete(key) {
    const n = this.find(key);
    const leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      const skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.map(l => l.split(' ')).forEach(function(cmd) {
    switch (cmd[0].charAt(0)) {
    case 'i': tree.insert(Number(cmd[1])); break;
    case 'f': console.log(tree.find(Number(cmd[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd[1])); break;
    default: tree.print();
    }
  });
})();



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

using namespace std;


int main() {
    string S;
    cin >> S;

    auto ans = "No";
    int idxC = S.find("C");
    int idxF = S.rfind("F");
    if (idxC != -1 && idxF != -1 && idxC < idxF) {
        ans = "Yes";
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
H, N = map(int, input().split())
mahou = []
a_max = 0
for _ in range(N):
    a, b = map(int, input().split())
    mahou.append([a, b])
    a_max = max(a_max, a)

dp = [[10 ** 9 for _ in range(H + a_max)] for _ in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0

for i in range(1, N + 1):
    for j in range(H + a_max):
        if j >= mahou[i - 1][0]:
            dp[i][j] = min(dp[i][j - mahou[i - 1][0]] + mahou[i - 1][1], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(min(dp[N][H:]))


Measured memory_bytes: 133896
#include <stdio.h>
int main(){
  int i,N,A[100],flag=1,tmp,count=0;
  scanf("%d",&N);
  for(i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }
  while(flag){
    flag = 0;
    for(i = N-1; i >= 1; i--){
      if(A[i] < A[i-1]){
	tmp = A[i];
	A[i] = A[i-1];
	A[i-1] = tmp;
	count++;
	flag = 1;
      }
    }
  }
  for(i = 0; i < N-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
/*
*/

#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 500;

int n, m;
char board[N][N];

int dp[N][N];
int cost[N][N];
int pen[N][N];

int solve(int ps)
{
	for (int i = 0; i <= m; i++)
	{
		for (int j = 0; j <= m; j++)
		{
			dp[i][j] = 1e9;
			pen[i][j] = 0;
		}
	}
	
	for (int ps1 = m; ps1 >= 0; --ps1)
	{
		for (int ps2 = m; ps2 >= 0; --ps2)
		{
			int in1 = ps1 + 1;
			int in2 = ps2 + 1;
			if (in1 == m + 1 || in2 == m + 1)
			{
				pen[ps1][ps2] = 0;
				continue;
			}
			else
			{
				pen[ps1][ps2] = pen[ps1 + 1][ps2 + 1] + (board[ps][in1] == board[ps + 1][in2]);
			}
		}
	}

	dp[0][0] = 0;

	for (int i = 0; i <= m; i++)
	{
		for (int j = 0; j <= m; j++)
		{
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + pen[i][j]);
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + pen[i][j]);
		}
	}
	return dp[m][m];

}

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> m>>n;
	for (int i = m; i >=1; i--)
	{
		string st;
		cin >> st;
		for (int j = 1; j <= n; j++)
		{
			board[j][i] = st[j - 1];
		}
	}
	
	int res = 0;

	for (int i = 1; i < n; i++)
	{
		res += solve(i);
	}

	cout << res << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, x, y, w, ans, xx, yy;
	cin >> n >> m;
	vector<string> s(n);
	for (i = 0; i < n; i++) cin >> s[i];
	int v[4][2] = { 1, 0, 0, 1, -1,0,0,-1 };
	vector<vector<int>> a(n, vector<int>(m, 10000000));
	queue<pair<int, int>> q;

	if (s[0][0] == '.') {
		a[0][0] = 0;
		q.push({ 0,0 });
	}
	while (!q.empty()) {
		x = q.front().first;
		y = q.front().second;
		q.pop();

		for (i = 0; i < 4; i++) {
			xx = x + v[i][0];
			yy = y + v[i][1];

			if ((xx >= 0) && (xx < n) && (yy >= 0) && (yy < m) && (s[xx][yy] == '.') && (a[x][y] + 1 < a[xx][yy])) {
				a[xx][yy] = a[x][y] + 1;
				q.push({ xx, yy });
			}
		}
	}

	if (a[n - 1][m - 1] == 10000000) ans = -1;
	else {
		w = 0;
		for (i = 0; i < n; i++) {
			for (auto ch : s[i]) {
				if (ch == '.')w++;
			}
		}
		ans = w - (a[n - 1][m - 1] + 1);
	}
	cout << ans << "\n";

	return 0;
}



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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;

    int x=800*n,y=200*(n/15);

    cout << x-y << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i <n; i++)
using namespace std;

int main() {
  long long n,a,b;
  cin >> n >> a >> b;

  long long div = n/(a+b);

  long long plus = n%(a+b);

  if(plus > a){
      cout << a*div + a << endl;
  }

  else{
      cout << a*div + plus << endl;
  }










}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#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;

#define _int64 long long

_int64 a[110000];

int main()
{
  _int64 now;
  int n,left,right,mid,b1;
  int i,j;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    scanf("%lld",&a[i]);
  sort(a,a+n);
  left=-1;right=n-1;
  while (right-left>1)
  {
    mid=(left+right)/2;
    now=a[mid];
    b1=1;
    for (i=0;i<n;i++)
    {
      if (i==mid) continue;
      if (now+now>=a[i]) now+=a[i];
      else b1=0;
    }
    if (b1==1) right=mid;
    else left=mid;
  }
  printf("%d\n",n-right);
  return 0;
}

Measured memory_bytes: 1024
N=int(input())
H_tmp=input().split()
H=[]
for val in H_tmp:
    H.append(int(val))

for i in range (N-1):
    if ( H[i] - H[i+1] < 1 ):
        continue
    elif ( H[i] - H[i+1] == 1 ):
        H[i+1] = H[i+1] + 1
    else:
        print ('No')
        quit()

print ('Yes')        

Measured memory_bytes: 14396
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[] a = nextInts();

		long sum = 0;
		for(int i=0;i<N;i++){
			sum+=a[i]-1;
		}
		long ans = sum;
		System.out.println(ans);

	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

bool solve(){
  ll n;std::cin >> n;
  if(n==0) return false;

  bool l = false, r = false;
  ll cnt = 0;
  for(int i=0;i<n;i++){
    string s;std::cin >> s;
    if(s=="lu"||s=="ld") l ^= 1;
    else r ^= 1;

    if(cnt%2==0&&(l==r&&r==1)) cnt++;
    else if(cnt%2&&(l==r&&r==0)) cnt++;
  }
  std::cout << cnt << '\n';
  return true;
}
int main(int argc, char const *argv[]) {
  while(true) if(!solve()) break;
  return 0;
}



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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

vector<pair<int,int>> v;

int main() {
    int n,a;

    scanf("%d", &n);

    for(int i = 1; i <= n; i++) {
    	scanf("%d", &a);
    	v.push_back(mp(a,i));
    }

    sort(v.begin(), v.end());

    for(int i = 0; i < n; i++) {
    	printf("%d%c", v[i].ss, " \n"[i==n-1]);
    }
}


Measured memory_bytes: 1780
import math

a = [float(input()) for _ in range(5)]
a_ceil = [math.ceil(0.1*a[n])*10 for n in range(len(a))]
a_p10 = [a[n] % 10 for n in range(len(a))]

for i in range(len(a)):
    if a_p10[i] == 0:
        a_p10[i] += 10
last = a_p10.index(min(a_p10))
total = int(sum(a_ceil) - a_ceil[last] + a[last])
print(total)

Measured memory_bytes: 3064
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

//#define pb push_back
//#define mp make_pair
//
//#define F first
//#define S second

typedef long long ll;

#define rept(_i,iv,n,type) for(type _i=(type)(iv);_i<(type)(n);++_i)
//#define repi(_i,iv,n) rept(_i,iv,n,int)
//#define repl(_i,iv,n) rept(_i,iv,n,ll)

#define rept0(_i,n,type) rept(_i,0,n,type)
#define repi0(_i,n) rept(_i,0,n,int)
#define repl0(_i,n) rept(_i,0,n,ll)

//#define repst(_i,iv,n,type) for(type _i=iv;_i<=(type)(n);++_i)
//#define repsi1(_i,n) repst(_i,1,n,int)

#define REPT(_i,iv,_l,n,type) for(type _i=(type)(iv),_l=(type)(n);_i<_l;++_i)
//#define REPI(_i,iv,_l,n) REPT(_i,iv,_l,n,int)
//#define REPL(_i,iv,_l,n) REPT(_i,iv,_l,n,ll)
//
#define REPT0(_i,_l,n,type) REPT(_i,0,_l,n,type)
#define REPI0(_i,_l,n) REPT(_i,0,_l,n,int)
#define REPL0(_i,_l,n) REPT(_i,0,_l,n,ll)


//#define rrept(_i,x,e,type) for(type _i=((type)(x)-1);_i>=e;--_i)
//
//#define rrept0(_i,x,type) rrept(_i,x,0,type)
//
//#define RREPT(_i,x,_e,e,type) for(type _i=((type)(x)-1),_e=(type)(e);_i>=_e;--_i)
//
//#define RREPT0(_i,x,_e,type) RREPT(_i,x,_e,0,type)
//
//#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;


//typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
//typedef vector<ll> vll;
//typedef vector<vll > vvll;

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    int zoro=0;
    bool flg=false;
    repi0(i, N){
        int d1,d2;
        cin>>d1>>d2;
        if(flg){
            continue;
        }
        if(d1==d2){
            ++zoro;
            if(zoro>=3){
                flg=true;
            }
        }else{
            zoro=0;
        }
    }
    cout<<(flg?"Yes":"No")<<endl;
    
    return 0;
}


Measured memory_bytes: 3092
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double r = input.nextDouble();
        double a = (r * 2) * Math.PI;
        double b = r * r * Math.PI;
        System.out.println(String.format("%.6f %.6f", b, a));
    }
}

Measured memory_bytes: 18956
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
struct Job{
    ll a;
    ll b;
};
int main() {
    ll N;cin>>N;
    vector<Job> abn(N);
    for(auto&& j:abn){
        cin>>j.a>>j.b;
    }
    sort(abn.begin(),abn.end(),[](auto& a,auto& b){ return (a.b < b.b); });
    ll t=0;
    bool ans=true;
    for(auto&& j:abn){
        t += j.a;
        if(t>j.b){
            ans=false;
            break;
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

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

long long a[20005]= {0};

int main() {
    long long n,ans=0,t;
    scanf("%lld",&n);
    for(long long i=1; i<105&&i<=n; i++) {
        //printf("hhh");
        for(long long j=1; j<105&&j<=n; j++) {
            for(long long k=1; k<105&&k<=n; k++) {
                t=i*i+j*j+k*k+i*j+i*k+j*k;
                if(t<10005)
                    a[t]++;
            }
        }
    }
    for(int i=1; i<=n; i++) {
        printf("%lld\n",a[i]);
    }
}


Measured memory_bytes: 3768
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region MODint
template<int MOD> struct Fp
{
	long long val;
	constexpr Fp(long long v = 0) noexcept : val(v % MOD)
	{
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr Fp operator - () const noexcept
	{
		return val ? MOD - val : 0;
	}
	constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
	constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
	constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
	constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
	constexpr Fp& operator += (const Fp& r) noexcept
	{
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr Fp& operator -= (const Fp& r) noexcept
	{
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr Fp& operator *= (const Fp& r) noexcept
	{
		val = val * r.val % MOD;
		return *this;
	}
	constexpr Fp& operator /= (const Fp& r) noexcept
	{
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b)
		{
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const Fp& r) const noexcept
	{
		return this->val == r.val;
	}
	constexpr bool operator != (const Fp& r) const noexcept
	{
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept
	{
		return os << x.val;
	}
	friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
	{
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};

const int MOD = 1000000007;
using mint = Fp<MOD>; 
#pragma endregion

int main()
{
	int n; cin >> n;
	vector<int> a(n); rep(i, n)cin >> a[i];
	vector<int> era(1001001);
	era[0] = era[1] = -1;
	for (int i = 2; i <= 1e6; ++i)
	{
		if (!era[i])
		{
			for (int j = i + i; j <= 1e6; j += i)
			{
				if (!era[j])era[j] = i;
			}
		}
	}
	map<int, int> mp;
	rep(i, n)
	{
		int now = a[i];
		vector<pair<int, int>> fac;
		fac.emplace_back(1, 0);
		while (era[now] > 0)
		{
			if (fac.back().first == era[now])++fac.back().second;
			else fac.emplace_back(era[now], 1);
			now /= era[now];
		}
		if (!era[now])
		{
			if (fac.back().first == now)++fac.back().second;
			else fac.emplace_back(now, 1);
		}
		for (auto p : fac)mp[p.first] = max(mp[p.first], p.second);
	}
	mint lcm = 1;
	for (auto p : mp)rep(i, p.second)lcm *= p.first;
	mint res = 0;
	rep(i, n)res += lcm / a[i];
	cout << res << endl;
}

Measured memory_bytes: 4608
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    K,A,B = reads(Int,Int,Int)
    for i in A:B
        if i % K == 0
            println("OK")
            return
        end
    end
    println("NG")
end

main()


Measured memory_bytes: 190704
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

vll searched;

vector<vll> graph;

void dfs(ll i, ll g){
    searched[i] = g;
    for (auto &&j : graph[i])
        if(searched[j] == -1)
            dfs(j,g);
}

void Main(){
    ll N,M;
    cin >> N >> M;
    vll A(M),B(M);
    rep(i,M) cin >> A[i] >> B[i];

    searched.resize(N,-1);
    graph.resize(N);
    rep(i,M){
        graph[A[i]-1].push_back(B[i]-1);
        graph[B[i]-1].push_back(A[i]-1);
    }

    ll g = 0;
    for (ll i = 0; i < N; i++)
    {
        if(searched[i]==-1){
            g++;
            dfs(i,g);
        }
    }
    g++;

    vll gsize(g);
    for (ll i = 0; i < N; i++){
        gsize[searched[i]]++;
    }

    ll ans = 0;
    for (ll i = 0; i < g; i++)
        if(ans < gsize[i])
            ans = gsize[i];
    
    cout << ans <<endl;
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

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

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

int main() {
  int n;
  cin >> n;
  n %= 10;
  n %= 10;
  if(n == 3) cout << "bon" << endl;
  else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3636
def main():
  a,b= list(map(int,input().split()))
  a_str=""
  b_str=""
  for i in range(0,b):
    a_str+=str(a)
  for i in range(0,a):
    b_str+=str(b)
  
  if a_str<b_str:
    print(a_str)
  else:
    print(b_str)
main()

Measured memory_bytes: 9172
n,m = map(int,input().split())

if abs(n-m) >= 2:
    print(0)
    
elif abs(n-m) == 1:
    x = max(n,m)
    for i in range(1,min(n,m)+1):
        x = x*i**2 % (10**9 + 7)
    print(x)
else:
    x = 2
    for i in range(1,n+1):
        x = x*i**2 % (10**9 + 7)
    print(x)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int bubbleSort(int a[], int n){
	int count = 0;
	bool flag = true;
	for(int i = 0; flag; i++){
		flag = false;
		for(int j = n-1; j >= i+1; j--){
			if(a[j-1] > a[j]){
				swap(a[j-1], a[j]);
				flag = true;
				count++;
			}
		}
	}
	return count;
}

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

	int count = bubbleSort(a, n);

	for(int i = 0; i < n; i++){
		if(i) cout << " ";
		cout << a[i];
	}
	cout << endl;
	cout << count << endl;
}

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

using namespace std;

int main()
{
    unsigned int x;
    cin >> x;
    unsigned int m = x / 500;
    unsigned long long c = m * 1000;
    unsigned r = x % 500;
    r -= r % 5;
    c +=  r;
    cout << c;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    bool fi = 0;
    REP(i,N){
        int a; cin >> a;
        if(a%2==1) fi = 1;
    }
    if(fi) cout << "first" << endl;
    else cout << "second" << endl;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


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

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XY):
    X, Y = [], []
    for x, y in XY:
        X.append(x+y)
        Y.append(x-y)
    X.sort()
    Y.sort()

    return max(X[-1]-X[0], Y[-1]-Y[0])


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()


Measured memory_bytes: 135596
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	ll n,m,k;
	cin >> n >> m >> k;
	ll a[n],b[m];
	forn(i,0,n) cin >> a[i];
	forn(i,0,m) cin >> b[i];

	ll dp1[n+1],dp2[m+1];
	dp1[0] = 0;
	dp2[0] = 0;
	forn(i,1,n+1){
		dp1[i] = dp1[i-1]+a[i-1];
	}
	forn(i,1,m+1)
		dp2[i] = dp2[i-1] + b[i-1];
	int ans = 0;
	for(int i =0;i<=n;i++){
		ll taken = dp1[i];
		ll left = k-taken;
		if(left<0)
			break;
		ll l = 0;
		ll r = m;
		while(l<=r){
			ll mid= (l+r)/2;
			// cout << mid << " " << dp2[mid] << " " << i << endl;
			if(dp2[mid]<=left)
				l = mid+1;
			else
				r = mid-1;
		}
		int cur = (i + r);
		ans = max(cur,ans);
		// cout << ans << " " << i << " " << r  << " " << left << endl;
	}
	cout << ans << endl;
}

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

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 9868
#include<bits/stdc++.h>
using namespace std;
int a[]{0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
	int x,y;
	cin>>x>>y;
	if(a[x]==a[y])cout<<"Yes";
	else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
 
typedef long long ll;
typedef std::pair<int,int> pii;
 
using namespace std;
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,k;
    cin >> n >> k;
    vector<ll> h(n),dp(n,INF);
    REP(i,n)cin >> h[i];

    dp[0] = 0;
    for(int i = 1;i < n;i++){
        ll minCost = INF;
        for(int j = 1;j <= k;j++){
            if(i-j < 0) continue;
            ll pre = dp[i-j] + abs(h[i-j] - h[i]);
            if(minCost > pre){
                minCost = pre;
            }
        }
        dp[i] = minCost;
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
def read_data():
    nV, nE = map(int, input().split())
    C = [dict() for v in range(nV)]
    for e in range(nE):
        u, v, c = map(int, input().split())
        C[u][v] = c
    return C, nV, 0, nV - 1

def dinic_ap(C, nV, s, t):
    '''allow antiparallel C[u][v] > 0 and C[v][u] > 0
    '''
    Cpp, nVpp = resolve_antiparallel(C, nV)
    return dinic(Cpp, nVpp, s, t)

def resolve_antiparallel(C, nV):
    Cpp = [dict() for i in range(nV)]
    new_v = nV
    for u in range(nV):
        for v, capacity in C[u].items():
            if capacity:
                if (u not in C[v]) or (u not in Cpp[v]):
                    Cpp[u][v] = capacity
                else:
                    Cpp.append(dict())
                    Cpp[u][new_v] = capacity
                    Cpp[new_v][v] = capacity
                    new_v += 1
    return Cpp, new_v

def dinic(C, nV, s, t):
    cf = [dict() for i in range(nV)]
    for u in range(nV):
        if u == t:
            continue
        for v, capacity in C[u].items():
            if capacity:
                cf[u][v] = capacity
                cf[v][u] = 0
    dist = get_distance(cf, s, t)
    while dist[t] > 0:
        df = dfs(dist, cf, s, t, float('inf'))
        while df:
            df = dfs(dist, cf, s, t, float('inf'))
        dist = get_distance(cf, s, t)
    return sum(cf[t].values())

def get_distance(cf, s, t):
    dist = [-1] * len(cf)
    dist[s] = 0
    frontiers = [s]
    while frontiers:
        new_frontiers = []
        for u in frontiers:
            for v, capacity in cf[u].items():
                if dist[v] == -1 and capacity > 0:
                    dist[v] = dist[u] + 1
                    new_frontiers.append(v)
        frontiers = new_frontiers
    return dist

def dfs(dist, cf, u, t, df):
    if u == t:
        return df
    for v, capacity in cf[u].items():
        if dist[v] > dist[u] and capacity > 0:
            new_df = dfs(dist, cf, v, t, min(df, capacity))
            if new_df > 0:
                cf[u][v] -= new_df
                cf[v][u] += new_df
                return new_df
    return 0

if __name__ == '__main__':
    C, nV, s, t = read_data()
    print(dinic_ap(C, nV, s, t))

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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define int long long
#define maxn 101
#define maxh 1000
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

int w, h;
int c[50][50];

void dfs(int x, int y) {
    c[y][x] = 0;
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            int nx = x + i;
            int ny = y + j;
            if (nx >= 0 && nx < w && ny >= 0 && ny < h && c[ny][nx] == 1) {
                dfs(nx, ny);
            }
        }
    }
}

signed main() {
    while (true) {
        cin >> w >> h;
        if (w == 0 && h == 0)break;
        rep(i, h) {
            rep(j, w) {
                cin >> c[i][j];
            }
        }
        int ans = 0;
        rep(i, w) {
            rep(j, h) {
                if (c[j][i] == 1) {
                    dfs(i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3300
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from collections import*\n"
"input=open(0).readline\n"
"n=int(input())\n"
"e=[[]for _ in range(n)]\n"
"for _ in range(n-1):\n"
"    a,b,c=map(int,input().split())\n"
"    e[a-1].append((b-1,c))\n"
"    e[b-1].append((a-1,c))\n"
"q,k=map(int,input().split())\n"
"d=[0]*n\n"
"f=[0]*n\n"
"f[k-1]=1\n"
"s=deque([(k-1,0)])\n"
"while s:\n"
"    t,c=s.pop()\n"
"    f[t]=1\n"
"    d[t]=c\n"
"    for i,v in e[t]:\n"
"        if not f[i]:\n"
"            s.append((i,v+c))\n"
"for _ in range(q):\n"
"    x,y=map(int,input().split())\n"
"    print(d[x-1]+d[y-1])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 48312
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string s = to_string(N);
    ll keta = s.size();
    if(N < 10){
        print(N);
        return 0;
    }
    if(pow(10, keta-1) - 1 == N % (ll)pow(10, keta-1)){
        print(9*(keta-1) + (s[0] - '0'));
    }else{
        print(9 * (keta-1) + (s[0] - '0' - 1));
    }

 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
typedef long double ld;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];

    sort(ALL(H));
    ll ans = 0;
    rep(i, N-K) ans += H[i];
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	ll n;
	ll ans=0;
	cin>>n;
	ans=(1LL+n-1)*(n-1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using in = int64_t;
 
int main(){
int n,k;
  cin >>n>>k;
  vector<int> a(n);
  rep(i,n) cin >>a.at(i);
  int ans=0;
  
  rep(i,n){
  if(a.at(i) >=k) ans++;
    
  }
  cout <<ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t=0,n,a,b,s=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a==b)
		s++;
		else
		{
			if(s>=3)t=1;
			s=0;
		}
	}
	if(t||s>=3)cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3632