akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main()
{
    int N;
    int K;
    std::cin >> N >> K;
    std::vector<long long> H(N, 0);
    for(int i=0; i<N; ++i)
        std::cin >> H[i];

    std::sort(H.begin(), H.end(), std::greater<long long>());

    long long ans = 0;
    for(int i=K; i<N; ++i)
        ans += H[i];

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1792
N = int(input())
X=list(map(int, input().split()))
MaxX = max(X)

ans = 10 ** 7
for i in range(1,MaxX+1):
    cost = 0
    for j in range(len(X)):
        cost += abs(X[j] - i) ** 2
    
    ans = min(ans, cost)

print(ans)

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


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

	vector<long long> a(n+1);
	vector<long long> b(n);

	for(long long i=0;i<n+1;i++){
		cin >> a[i];
	}
	for(long long i=0;i<n;i++){
		cin >> b[i];
	}

	long long sum = 0;
	for(long long i=0;i<n;i++){
		sum += min(a[i], b[i]);
		b[i] -= min(a[i], b[i]);
		sum += min(a[i+1], b[i]);
		a[i+1] -= min(a[i+1], b[i]);
	}	
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1792
M,D = map(int,input().split())

cnt = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        d1 = d % 10
        d2 = d // 10
        if d1 >= 2 and d2 >= 2 and d1 * d2 == m:
            cnt += 1
    
print(cnt)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#define inf 1e9

using namespace std;

// range-add, range-min query

struct SegTree{
	int size;
	vector<int> seg, delay;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
		delay.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++){
			seg[i] = inf;
			delay[i] = 0;
		}
	}
	
	void eval(int l, int r, int k)
	{
		if(delay[k]){
			seg[k] += delay[k];
			if(l < r){
				delay[k*2] += delay[k];
				delay[k*2+1] += delay[k];
			}
			delay[k] = 0;
		}
	}
	
	void update(int i, int val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}
	
	void add(int a, int b, int k, int l, int r, int val)
	{
		eval(l, r, k);
		
		if(b < l || r < a) return;
		if(a <= l && r <= b){
			delay[k] += val;
			eval(l, r, k);
			return;
		}
		add(a, b, k*2, l, (l+r)/2, val);
		add(a, b, k*2+1, (l+r)/2+1, r, val);
		seg[k] = min(seg[k*2], seg[k*2+1]);
	}
	void add(int a, int b, int val){
		if(a > b) return;
		add(a, b, 1, 0, (1<<size)-1, val);
	}

	int query(int a, int b, int k, int l, int r)
	{
		eval(l, r, k);
		
		if(b < l || r < a) return inf;
		if(a <= l && r <= b) return seg[k];
		int lval = query(a, b, k*2, l, (l+r)/2);
		int rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	int query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

int n;
int p[20005];
int Rank[20005];
SegTree segA(15), segB(15);

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> p[i];
	for(int i = 1; i <= n; i++) Rank[p[i]] = i;
	
	segA.init();
	segB.init();
	for(int i = 1; i <= n; i++){
		segB.update(i, n-i+1);
	}
	for(int i = 1; i <= n; i++){
		segA.update(i, Rank[i]+n - (n-i+1));
	}
	
	for(int i = 1; i < n; i++){
		int mn = segA.query(i+1, n);
		int val = segA.query(i, i);
		if(mn > val) continue;
		segA.add(i+1, n, val - mn + 1);
		segB.add(1, i, val - mn + 1);
	}
	
	for(int i = 1; i <= n; i++) cout << segA.query(i, i) << " "; cout << endl;
	for(int i = 1; i <= n; i++) cout << segB.query(i, i) << " "; cout << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x;
  cin>>n>>x;
  int m[n];
  for (int i=0; i<n; i++) cin>>m[i];
  sort(m, m + n);
  for (int i=0; i<n; i++) x-= m[i];
  cout<<n + x / m[0]<<endl;
}

Measured memory_bytes: 256
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
    
        print()#改行
    print()


Measured memory_bytes: 7004
#include<iostream>
#include<algorithm>
#include<string>
#define int long long
using namespace std;
signed main() {
	int n, m, a, ans = 0; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a > m)ans++;
	}cout << ans << endl;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
 
#define ll long long int 
#define endl '\n'
#define PI  3.14159265358979323846
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MAX 1000
using namespace std;
//vector<vector<int> > vec( n , vector<int> (m, 0));   vec[n][m] 

int main() {
	string s,t;
	cin>>s>>t;
	int l=s.size(),m=t.size(),i,j;
	int dp[l+1][m+1];
	
	for(i=0;i<=l;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(i==0 || j==0)
			dp[i][j]=0;
			else if(s[i-1]==t[j-1])
			dp[i][j]=dp[i-1][j-1]+1;
			else
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int val=dp[l][m];
	string ans="";
	i=l,j=m;
	while(val!=0)
	{
		if(s[i-1]==t[j-1])
		{
			ans+=s[i-1];
			val--;
			i--;
			j--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
			i--;
			else
			j--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
}

Measured memory_bytes: 35456
import itertools

N = input()
L = input().split()
count = 0

for v_s in itertools.combinations(L, 3):
    v = [int (vv) for vv in v_s]
    if (v[0] != v[1]) and (v[1] != v[2]) and (v[2] != v[0]): 
        if (v[0]+v[1]>v[2]) and (v[1]+v[2]>v[0]) and (v[2]+v[0]>v[1]):
            count += 1

print(count)

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

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

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

int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};

int main() {
  int h, w;
  cin >> h >> w;

  char s[h][w];
  rep(i, h) rep(j, w) { cin >> s[i][j]; }

  int ans = 0;
  rep(i, h) rep(j, w) {
    if (s[i][j] == '#') continue;

    const int INF = 1001001001;
    vector<vector<int>> d(h, vector<int>(w, INF));
    d[i][j] = 0;

    queue<P> q;
    q.push({i, j});

    while (!q.empty()) {
      P u = q.front();
      q.pop();

      ans = max(ans, d[u.first][u.second]);

      rep(dir, 4) {
        int ni = u.first + di[dir];
        int nj = u.second + dj[dir];

        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        if (d[ni][nj] != INF) continue;
        d[ni][nj] = d[u.first][u.second] + 1;
        q.push({ni, nj});
      }
    }
  }

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


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

x = int(input())
xx = list(reversed(range(1,x+1)))
xxx = set()

for i in range(1, 32):
    for j in range(2, 11):
        if i**j <= 1000:
            xxx.add(i**j)

for i in xx:
    if i in xxx:
        print(i)
        break




Measured memory_bytes: 2940
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while(n-->0){

        int a=0, b=0, t=0;
        boolean flag=true;
        for(int i=0; i<10; i++){
        	t=sc.nextInt();
        	if(a<t)	a=t;
        	else if(b<t) b=t;
        	else flag=false;
        	}

        if(true==flag) System.out.println("YES");
        else System.out.println("NO");

    }
    }
}

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

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

int main() {
    int N = 0;
    int K = 0;
    int d = 0;
    int N_s = 0;
    int count = 0;
    cin >> N >> K;
    vector<int> sunuke(N, 0);
    

    for (int i = 0; i < K; i++) {
        cin >> d;
        for (int j = 0;j < d; j++) {
            cin >> N_s;
            sunuke[N_s - 1] = 1;
        }
    }

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

    return 0;
}

Measured memory_bytes: 3136
#include <cstring>
#include <iostream>

using namespace std;
int n;
string s;
int r,g,b;
long long ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='R') r++;
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
    }
    ans=r*g;
  ans=ans*b;
    if(!ans){cout<<0;return 0;}
    for(int a=0;a<n-2;a++)
        for(int b=a;b<n-1;b++){
            int c=b+(b-a);
            if(c>=n) continue;//若k超过了字符串的范围则不执行
            if(s[a]!=s[b]&&s[a]!=s[c]&&s[b]!=s[c]) ans--;
        }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << ((B-1) + (A-2))/(A-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    int N,X,T;
    cin >> N >> X >> T;

    int kai;
    if(N % X == 0)
        kai = N / X;
    else
        kai = N / X + 1;

    cout << T * kai << endl;


    return 0;

}





    

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

struct Point{
  int tx,ty,kx,ky,time;
};

int main(){
  int i,j,k,l,X,Y,G[51][51],ans;
  bool D[51][51][51][51];
  while(1){
    Point p;
    queue <Point> Q;
    cin >> X >> Y;
    if(X == 0 && Y == 0) break;
    cin >> p.tx >> p.ty;
    cin >> p.kx >> p.ky;

    for(i=1;i<=Y;i++){
      for(j=1;j<=X;j++){
	cin >> G[j][i];
	for(k=1;k<=X;k++){
	  for(l=1;l<=Y;l++) D[j][k][i][l] = false;
	}
      }
    }

    p.time = 0;
    Q.push(p);
    D[p.tx][p.kx][p.ty][p.ky] = true;
    ans = 0;

    while(!Q.empty()){
      p = Q.front();
      Q.pop();
      if(p.tx == p.kx && p.ty == p.ky || p.time >= 100){
	ans = p.time;
	break;
      }

      int x[4] = {1,0,-1,0};
      int y[4] = {0,1,0,-1};
      Point v;

      for(i=0;i<4;i++){
	int ntx = p.tx + x[i];
	int nty = p.ty + y[i];
	int nkx = p.kx + x[(i+2)%4];
	int nky = p.ky + y[(i+2)%4];
	if(ntx > 0 && nkx > 0 && ntx <= X && nkx <= X && nty > 0 && nky > 0 && nty <= Y && nky <= Y && !G[ntx][nty] && !G[nkx][nky] && !D[ntx][nkx][nty][nky]){
	  D[ntx][nkx][nty][nky] = true;
	  v.tx = ntx;
	  v.ty = nty;
	  v.kx = nkx;
	  v.ky = nky;
	  v.time = p.time + 1;
	  Q.push(v);
	}
	else if(nkx > 0 && nkx <= X && nky > 0 && nky <= Y && !G[nkx][nky] && (ntx <= 0 || ntx > X || nty <= 0 || nty > Y || G[ntx][nty]) && !D[p.tx][nkx][p.ty][nky]){
	  D[p.tx][nkx][p.ty][nky] = true;
	  v.tx = p.tx;
	  v.ty = p.ty;
	  v.kx = nkx;
	  v.ky = nky;
	  v.time = p.time + 1;
	  Q.push(v);
	}
	else if(ntx > 0 && ntx <= X && nty > 0 && nty <= Y && !G[ntx][nty] && (nkx <= 0 || nkx > X || nky <= 0 || nky > Y || G[nkx][nky]) &&  !D[ntx][p.kx][nty][p.ky]){
	  D[ntx][p.kx][nty][p.ky] = true;
	  v.tx = ntx;
	  v.ty = nty;
	  v.kx = p.kx;
	  v.ky = p.ky;
	  v.time = p.time + 1;
	  Q.push(v);
	}
      }
    }

    if(ans > 0 && ans < 100) cout << ans << endl;
    else cout << "NA" << endl;
    
  }
  return 0;
}

Measured memory_bytes: 7648
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++){
		    p[i] = sc.nextInt() - 1;
		}
		UnionFind uf = new UnionFind(n);
		for(int i = 0; i < m; i++){
		    int x = sc.nextInt() - 1;
		    int y = sc.nextInt() - 1;
		    uf.union(x, y);
		}
		
		// 計算
		int result = 0;
		TreeSet<String> ts = new TreeSet<String>();
		for(int i = 0; i < n; i++){
		    if(uf.same(i, p[i])) result++;
		}
		
		// 出力
		System.out.println(result);
	}
}

class UnionFind {
    int[] parent;
    int[] rank;
    
    UnionFind(int n){
        this.parent = new int[n];
        this.rank = new int[n];
        for(int i = 0; i < n; i++){
            parent[i] = i;
            rank[i] = 0;
        }
    }
    
    public int find(int i){
        if(i == parent[i]) return i;
        parent[i] = find(parent[i]);
        return parent[i];
    }
    
    public void union(int x, int y){
        int xRoot = find(x);
        int yRoot = find(y);
        if(rank[xRoot] < rank[yRoot]){
            parent[xRoot] = yRoot;
        }else if(rank[xRoot] > rank[yRoot]){
            parent[yRoot] = xRoot;
        }else{
            parent[yRoot] = xRoot;
            rank[xRoot]++;
        }
    }
    
    public boolean same(int x, int y){
        return find(x) == find(y);
    }
}


Measured memory_bytes: 90692
#include <stdio.h>

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

   scanf("%d %d\n", &r, &c);
   int a[r+1][c+1];

   for (i = 0; i <= r; i++) {
       for (j = 0; j <= c; j++) {
           a[i][j] = 0;
       }
   }

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

   for (j = 0; j < c; j++) {
       for (i = 0; i < r; i++) {
           a[r][j] += a[i][j], a[r][c] += a[i][j];
       }
   }

   for (i = 0; i <= r; i++) {
       for (j = 0; j <= c; j++) {
           if (j != c)
           printf("%d ", a[i][j]);
           else
           printf("%d",a[i][j]);
       }
       putchar('\n');
   }
   return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<int, int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
using namespace std;
const ll inf = 1e9 + 5;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

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

    vector<int> dp(n, inf);
    dp[0] = 0;
    for (int i=0; i<n; i++)
        for (int j = i+1; j <= i+k; j++)
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
    cout << dp[n-1] << '\n';
    return 0;
}


Measured memory_bytes: 1024
import sys;input=sys.stdin.readline
H, W = map(int, input().split())
cx, cy = map(int, input().split())
dx, dy = map(int, input().split())
cx-=1;cy-=1;dx-=1;dy-=1
B = []
for _ in range(H):
    B.append(input().strip())

D = [0]*(H*W)
bb = -1
t = 0
t2c = dict()
for i in range(H):
    for j in range(W):
        if B[i][j] == "#":
            D[i*W+j] = bb
            continue
        if D[i*W+j]>0:
            continue
        t += 1
        t2c[t] = set()
        stack = [(i, j)]
        while stack:
            u, v = stack.pop()
            D[W*u+v] = t
            t2c[t].add((u, v))
            for x, y in [(u+1, v), (u-1, v), (u, v-1), (u, v+1)]:
                if x >= H or x<0:
                    continue
                if y >= W or y<0:
                    continue
                if B[x][y] == "#":
                    D[x*W+y] = bb
                    continue
                if D[x*W+y]:
                    continue
                stack.append((x, y))
depth = 0
cs = [D[cx*W+cy]]
tt = D[dx*W+dy]
vs = set([cs[0], -1])
if tt in vs:
    print(0)
    sys.exit()
while True:
    depth += 1
    nexts = []
    for c in cs:
        for i, j in t2c[c]:
            for ii in range(max(0, i-2), min(i+3, H)):
                for jj in range(max(0, j-2), min(j+3, W)):
                    if D[ii*W+jj] in vs:
                        continue
                    vs.add(D[ii*W+jj])
                    nexts.append(D[ii*W+jj])
                    if D[ii*W+jj] == tt:
                        print(depth)
                        sys.exit()
    cs = nexts
    if not cs:
        break
print(-1)


Measured memory_bytes: 162912
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl N;

static vector<sl> Ai;
static vector<sl> Bi;
static vector<sl> Ci;

void solve(void) {
  sl res = 0;
  sl prev = N, cur = 0;
  FOR0(i, N) {
    cur = Ai[i];
    res += Bi[cur];
    if (cur == prev + 1) {
      res += Ci[prev];
    }
    prev = cur;
  }
  cout << res << endl;
}

int main(void) {
  cin >> N;
  Ai.resize(N);
  Bi.resize(N);
  Ci.resize(N);
  FOR0(i, N) {
    cin >> Ai[i];
    Ai[i] -= 1;
  }
  FOR0(i, N) {
    cin >> Bi[i];
  }
  FOR0(i, N) {
    cin >> Ci[i];
  }
  solve();
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

llong N;
vector<pair<llong, llong>> P;

bool ope1(pair<llong, llong>x, pair<llong, llong>y) {
	if (x.second == y.second) return x.first > y.first;
	else return x.second > y.second;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		llong a, b;
		cin >> a >> b;
		pair<llong, llong> p = make_pair(a, b);
		P.push_back(p);
	}

	sort(P.begin(), P.end(), ope1);
	llong T = P[0].second;

	for (int i = 0; i < P.size(); i++) {
		T = min(T, P[i].second);
		T -= P[i].first;
	}

	if (T < 0) cout << "No";
	else cout << "Yes";

	return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  ll q, h, s, d;
  cin >> q >> h >> s >> d;
  ll N;
  cin >> N;
  ll S = min(4 * q, min(2 * h, s));
  ll D = min(2 * S, d);

  ll ans = D * (N / 2) + S * (N % 2);
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
xy=[]
ans=0
for i in range(n):
  a=int(input())
  xy.append([list(map(int,input().split())) for _ in range(a)])
for i in range(2**n):
  cnt=[]
  k=0
  for j in range(n):
    if (i >> j) & 1:
      cnt.append(1)
    else:
      cnt.append(0)
  for p,j in enumerate(cnt):
    e=0
    if j==0:
      for o in xy[p]:
        if cnt[o[0]-1]==o[1]:
          break
        e+=1
      if e==len(xy[p]):
        k+=1
      else:
        k=0
        break
  if ans < k:
    ans=k
print(ans)

Measured memory_bytes: 3064
n, s = map(int, input().split())
a = list(map(int, input().split()))

mod = 998244353

dp = [[0] * 4000 for _ in range(4000)]

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x % mod
        x *= x % mod
        n //= 2

    return K * x % mod

inv2 = pow_k(2, mod - 2)
pow2n = pow_k(2, n)

dp[0][0] = pow2n
for i in range(1, n + 1):
    for j in range(s + 1):
        if j >= a[i - 1]:
            dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - a[i - 1]] * inv2 % mod) % mod
        else:
            dp[i][j] = dp[i - 1][j]
print(dp[n][s])


Measured memory_bytes: 805168
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while(a >= b){
		ans++;
		b *= 2;
	}
	while(b >= c){
		ans++;
		c *= 2;
	}
	if (ans <= k) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	//cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main() {
	string s;
	cin>>s;
	int ans = 0;
	for(int i = 0 ; i < s.size() ; i++){
		int j = i;
		while(j < s.size() && s[i] == s[j])
		{
			j++;
		}
		if(s[i] == 'R')
		ans = max(ans, j - i);
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main(void) {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector< vector<int> > A(N, vector<int>(M));
    for(int i=0; i<N; i++) {
        cin >> C[i];
        for(int j=0; j<M; j++) {
            cin >> A[i][j];
        }
    }

    int ans = numeric_limits<int>::max();
    for(int bit=0; bit<(1<<N); bit++) {
        int price = 0;
        vector<int> v(M);
        for(int i=0; i<N; i++) {
            if(bit>>i & 1) {
                price += C[i];
                for(int j=0; j<M; j++) {
                    v[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        for(int j=0; j<M; j++) {
            if(v[j] < X) ok = false;
        }
        if(ok) {
            ans = min(ans, price);
        }
    }

    if(ans == numeric_limits<int>::max()) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////



int main(){fastio;
    ll h,w;cin>>h>>w;
    string s[h];rep(i,0,h-1)cin>>s[i];
    string a[h],b[h];
    rep(i,0,h-1){
        rep(j,0,w-1){
            a[i]+='.';
            b[i]+='.';
        }
    }
    rep(j,0,h-1){
        a[j][0]='#';
        b[j][w-1]='#';
    }
    rep(i,0,h-1){
        if(i%2==0){
            rep(j,0,w-2)a[i][j]='#';
        }else{
            rep(j,1,w-1)b[i][j]='#';
        }
    }
    rep(i,0,h-1)rep(j,0,w-1){
        if(s[i][j]=='#')a[i][j]=b[i][j]='#';
    }
    rep(i,0,h-1)cout<<a[i]<<endl;cout<<endl;
    rep(i,0,h-1)cout<<b[i]<<endl;
    
    return 0;
}





Measured memory_bytes: 1536
N, M = map(int,input().split())
X = list(map(int,input().split()))

def main():
  x = sorted(X)
  costs = []
  for i in range(M-1):
    costs.append(abs(x[i] - x[i+1]))
  costs.sort()
  ans = sum(costs[:(-(N-1) if N != 1 else M)])
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 13960
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String X = sc.next();

		sc.close();

		Deque<Character> stack = new ArrayDeque<>();

		for(int i=0;i<X.length();i++) {
			char c = X.charAt(i);

			if(c == 'T' && (stack.peek() != null && stack.peek() == 'S')) {
				stack.pop();
			}else {
				stack.push(c);
			}
		}

		out.println(stack.size());
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 28220
from sys import stdin

n, k, s = map(int, stdin.readline().rstrip().split())
flag = 0

for i in range(n):
    if flag < k:
        print(s)
        flag += 1
    else:
        if s == 10 ^ 9:
            print(s-1)
        else:
            if s == 1:
                print(2)
            else:
                print(s-1)

Measured memory_bytes: 46808
//TakandCards.cpp (C)
#include <iostream>
#include <string>
using namespace std;

int main(){
  int N,A;
  cin >> N >> A;
  int x[N];
  for(int i = 1; i <= N; i++) cin >> x[i];
  long long dp[N+1][N+1][3000] = {0};
  dp[0][0][0] = 1;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= i; j++){
      for(int k = 0; k <= 50*j; k++){
        if(k-x[i] >= 0&&j >= 1&&i >= 1) dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]];
        else if(i >= 1)dp[i][j][k] = dp[i-1][j][k];
        // if(dp[i][j][k]!=0){
          // printf("%d %d %d\n",i,j,k );
          // cout << dp[i][j][k] << endl;
        // }
      }
    }
  }
  long long Ans = 0;
  for(int i = 1; i <= N; i++) Ans += dp[N][i][A*i];
  printf("%lld\n", Ans );
  return 0;
}


Measured memory_bytes: 60800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> vec(N, 0);
  
  for (int i = 0; i < M; i++){
    int a,b;
    cin >> a >> b;
    vec.at( a - 1 )++;
    vec.at( b - 1 )++;
  }
  
  for (int i = 0; i < N; i++){
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
import heapq

N = int(input())
d = [0] * N
INF = float('inf')

class Info:
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost
        
G = [[] for i in range(N)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    G[a - 1].append(Info(b - 1, c))
    G[b - 1].append(Info(a - 1, c))
    
def dijkstra(s):
    for i in range(N):
        d[i] = INF
    d[s] = 0
    h = []
    heapq.heappush(h, [0, s])
    
    while h != []:
        p = heapq.heappop(h)
        v = p[1]
        if d[v] < p[0]:
            continue
        for i in range(len(G[v])):
            e = G[v][i]
            if d[e.to] > d[v] + e.cost:
                d[e.to] = d[v] + e.cost
                heapq.heappush(h, [d[e.to], e.to])

Q, K = map(int, input().split())

dijkstra(K - 1)

for _ in range(Q):
    ans = 0
    x, y = map(int, input().split())
    ans += d[x - 1]
    ans += d[y - 1]
    print(ans)

Measured memory_bytes: 69444
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
	io;
	ll n;
	cin>>n;
	ll prd=0;
	for(ll i=1;i<=1000000;i++){
		prd*=10;
		prd+=7;
		if(prd%n==0){
			cout<<i;
			return 0;
		}
		prd%=n;
	}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 3636
import sys
import math
N = int(sys.stdin.readline().strip())

def calc(xa, ya, ra, xb, yb, rb):
    dist = math.sqrt((yb - ya) **2 + (xb - xa) **2)
    if dist > (ra + rb):
        return 0
    elif abs(ra - rb) <= dist <= (ra + rb):
        return 1
    elif dist < abs(ra - rb):
        if ra > rb:
            return 2
        else:
            return -2

for i in xrange(N):
    line = sys.stdin.readline().strip()
    xa, ya, ra, xb, yb, rb = map(float, line.split())
    print calc(xa, ya, ra, xb, yb, rb)

Measured memory_bytes: 5396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long K = in.nextLong();
            long a = in.nextLong();
            long b = in.nextLong();
            if (a + 1 >= b) {
                out.println(K + 1);
            } else {
                K -= (a - 1);
                long now = a;
                now += (K / 2) * (b - a);
                K -= (K / 2) * 2;
                if (K != 0) ++now;
                out.println(now);
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 22612
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n = int(input())

result = n

tmp = make_divisors(n)

for i in range(-(-len(tmp) // 2)):

   num0 = tmp[i]
   num1 = n // num0

   result = min(result, num0 + num1 - 2)

print(str(result))

Measured memory_bytes: 3268
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define chmin(x, a) do { x = min(x, a); } while(0)

using namespace std;

ll T, A, B, C, D;
map<ll, ll> memo;

ll f(ll N) {
  // cout << "N = " << N << endl;
  if (N == 0) {
    return 0;
  }

  auto it = memo.find(N);
  if (it != memo.end())
    return it->second;

  ll res = 1e18;
  if (N * D < res && N * D >= 0) // overflow 対策
    res = N * D;

  ll a = N % 2, b = N % 3, c = N % 5;

  if ((N - a)/2 < N) chmin(res,      a * D + A + f((N - a)/ 2));
  if ((N + a)/2 < N) chmin(res, (2 - a)* D + A + f((N + a)/ 2));

  if ((N - b)/3 < N) chmin(res,      b * D + B + f((N - b)/ 3));
  if ((N + b)/3 < N) chmin(res, (3 - b)* D + B + f((N + b)/ 3));

  if ((N - c)/5 < N) chmin(res,      c * D + C + f((N - c)/ 5));
  if ((N + c)/5 < N) chmin(res, (5 - c)* D + C + f((N + c)/ 5));

  return memo[N] = res;
}

int main() {
  cin >> T;
  while (T--) {
    memo.clear();
    ll N;
    cin >> N >> A >> B >> C >> D;
    cout << f(N) << endl;
  }
  return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    ll sm=0;
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
        A[i]-=i+1;
        sm+=A[i];
    }
    sort(A.begin(),A.end());
    ll ab=A[N/2],bb=A[N/2+1];
    ll ana=0,anb=0;
    rep(i,N){
        ana+=abs(A[i]-ab);
        anb+=abs(A[i]-bb);
    }
    cout << min(ana,anb) <<endl;
    return (0);
}

Measured memory_bytes: 1024
import sys

h, w = [int(i) for i in input().split()]
s = [input() for _ in range(h)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            continue
        else:
            for d in range(4):
                if (0 <= i+dy[d] < h) and (0 <= j+dx[d] < w):
                    if s[i+dy[d]][j+dx[d]] == '#':
                        break
            else:
                print("No")
                sys.exit()
else:
    print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    ll cnt = 0;
    cnt += V[0] / 2;
    V[0] %= 2;
    rep(i,1,N){
        cnt += min(V[i-1], V[i]);
        if(V[i-1] < V[i])V[i] -= V[i-1];
        else V[i] = 0;
        cnt += V[i] / 2;
        V[i] %= 2;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
vector <string> ve;
int main(){
    string s0="AKIHABARA";
    string s;
    cin>>s;

    int l=0;
    int r=0;
    bool flag=0;

    if (s.length()>s0.length())
    {
        puts("NO");
        exit(0);
    }
    while (l<s0.length() && r<s.length())
    {

        if (s0[l]==s[r])
        {
            l++;
            r++;
        }
        else
        {
            if (s0[l]!='A')
            {
                puts("NO");
                exit(0);
            }
            l++;
        }
    }
    if (r<s.length())
    {
        puts("NO");
    }
    else
    {
        if (l<(s0.length()-1)) puts("NO");
        else puts("YES");
    }
}


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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
string s,t;
signed main(void)
{
	ios::sync_with_stdio(false);cin.tie(0);
	reg int res=0;
	cin>>s>>t;
	if(s[0]==t[0])
		++res;
	if(s[1]==t[1])
		++res;
	if(s[2]==t[2])
		++res;
	cout<<res<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
static const ll MAX_L = (ll)1 << 62;

static const ll FACT_SIZE = 1000000;
ll fact[FACT_SIZE] = {};

ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	else return t * t % MOD;
}
void factorial(ll f) {
	fact[0] = fact[1] = 1;
	rep(i, 1, FACT_SIZE) fact[i] = fact[i - 1] * i % MOD;
}

ll nCr(ll n, ll r) {
	if (fact[0] == 0)	factorial(FACT_SIZE);
	return ((fact[n] * (Pow(fact[r], MOD - 2) % MOD)) % MOD * Pow(fact[n - r], MOD - 2)) % MOD;
}

static const ll prime_max = 100001;
bool prime_check[prime_max] = {};
ll prime[prime_max] = {};
ll primeNum = 0;

void eratosthenes() {
	rep(i, 2, prime_max) prime_check[i] = true;
	rep(i, 2, prime_max) {
		if (prime_check[i]) {
			prime[primeNum++] = i;
			rep(j, 2, prime_max) {
				if (j*i >= prime_max)break;
				prime_check[j*i] = false;
			}
		}
	}
}

map<ll, ll> factor;
//void factorization(ll x) {
//	ll n = x;
//	repe(i, 0, primeNum) {
//		while (prime[i] && n != 0 && !(n % prime[i])) {
//			n /= prime[i];
//			factor[prime[i]]++;
//		};
//	}
//}

void factorization(ll m) {
	ll t = m;
	for (int i = 2; t != 1; i++) {
		while (!(t % i)) {
			factor[i]++;
			t /= i;
		}
	}
}
int main() {
	ll n, m; cin >> n >> m;

	//eratosthenes();
	factorization(m);

	ll ans = 1;
	for (map<ll, ll>::iterator it = factor.begin(); it != factor.end(); it++) {
		ans = (ans* nCr(it->second + n - 1, it->second) % MOD);
	}

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

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int H, W; cin >> H >> W;
  vector<string> a(H);
  REP (i, H) cin >> a[i];
  VVI dp(H + 1, VI(W + 1));
  dp[1][1] = 1;
  REP (i, H) {
    REP (j, W) {
      if (i == 0 && j == 0) continue;
      dp[i + 1][j + 1] = a[i][j] == '#' ? 0 : dp[i + 1][j] + dp[i][j + 1];
      dp[i + 1][j + 1] %= MOD;
    }
  }
  cout << dp[H][W] << endl;
}


Measured memory_bytes: 9216
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class A {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        string S;
        Input(out S);
        if(S[2] == S[3] && S[4] == S[5]) {
            Print("Yes");
        } else {
            Print("No");
        }
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void Inputs<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a = 0;
  int b = 0;
  cin >> a >> b;
  if( 1 == (a * b % 2)  )
  {
    cout << "Odd" << endl;
  }
  else
  {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
input_line = input().split()
total_cake = int(input_line[0])
select_cake = int(input_line[1])

cake_scores = []

for i in range(0, total_cake):
    input_line = input().split()
    beauty = int(input_line[0])
    yummy = int(input_line[1])
    common = int(input_line[2])

    cake_scores.append((beauty, yummy, common))

# + beauty + yummy + common score_p_p_p
# + beauty + yummy - common score_p_p_n
# + beauty - yummy + common score_p_n_p
# - beauty + yummy + common score_n_p_p
# - beauty - yummy + common score_n_n_p
# + beauty - yummy - common score_p_n_n
# - beauty + yummy - common score_n_p_n
# - beauty - yummy - common score_n_n_n

scores_p_p_p = []
scores_p_p_n = []
scores_p_n_p = []
scores_n_p_p = []
scores_n_n_p = []
scores_p_n_n = []
scores_n_p_n = []
scores_n_n_n = []

for i in range(0, total_cake):
    beauty, yummy, common = cake_scores[i]
    scores_p_p_p.append(beauty + yummy + common)
    scores_p_p_n.append(beauty + yummy - common)
    scores_p_n_p.append(beauty - yummy + common)
    scores_n_p_p.append(-beauty + yummy + common)
    scores_n_n_p.append(-beauty - yummy + common)
    scores_p_n_n.append(beauty - yummy - common)
    scores_n_p_n.append(-beauty + yummy - common)
    scores_n_n_n.append(-beauty - yummy - common)

scores_p_p_p.sort(reverse=True)
scores_p_p_n.sort(reverse=True)
scores_p_n_p.sort(reverse=True)
scores_n_p_p.sort(reverse=True)
scores_n_n_p.sort(reverse=True)
scores_p_n_n.sort(reverse=True)
scores_n_p_n.sort(reverse=True)
scores_n_n_n.sort(reverse=True)

score_p_p_p = sum(scores_p_p_p[0:select_cake])
score_p_p_n = sum(scores_p_p_n[0:select_cake])
score_p_n_p = sum(scores_p_n_p[0:select_cake])
score_n_p_p = sum(scores_n_p_p[0:select_cake])
score_n_n_p = sum(scores_n_n_p[0:select_cake])
score_p_n_n = sum(scores_p_n_n[0:select_cake])
score_n_p_n = sum(scores_n_p_n[0:select_cake])
score_n_n_n = sum(scores_n_n_n[0:select_cake])

print(max(score_p_p_p, score_p_p_n, score_p_n_p, score_n_p_p, score_n_n_p, score_p_n_n, score_n_p_n, score_n_n_n))



Measured memory_bytes: 3572
char s[];main(){double*q=s+9,b;for(;~scanf("%s",s);getchar()<14&&printf("%f\n",*q))!sscanf(s,"%lf",q+1)?b=*q--,*q=*s-47?*s-42?*s-45?*q+b:*q-b:*q*b:*q/b:*++q;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 200005;
const int D = 60;
/* global variables */
// to[i][j] = j -> 2^i 個先の頂点
vector<vector<int> > to(D, vector<int>(MAX));
/* function */
/* main */
int main(){
    int N;
    ll K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> to[0][i];
        to[0][i]--;
    }
    // Doublingでの解法
    for (int i = 0; i < D - 1; i++) for (int j = 0; j < N; j++)
        to[i+1][j] = to[i][to[i][j]];

    int v = 0;
    for (int i = D - 1; i >= 0; i--) {
        ll l = 1LL << i;
        if (l <= K) {
            v = to[i][v];
            K -= l;
        }
    }

    cout << v + 1 << '\n';

}


Measured memory_bytes: 50852