akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

typedef long long LL;

#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)

const int MAX = 600000;
const int LIM = 100000000;
const LL MOD = 1000000007;
const int INF = 2147483647/2;
const LL LINF = 9223372036854775807/3;

int ucmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a>*(int*)b?1:-1));}
int dcmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a<*(int*)b?1:-1));}

int ucmpll(const void *a, const void *b){return(*(LL*)a==*(LL*)b?0:(*(LL*)a>*(LL*)b?1:-1));}
int dcmpll(const void *a, const void *b){return(*(LL*)a==*(LL*)b?0:(*(LL*)a<*(LL*)b?1:-1));}

void SORT(int*a, int n){qsort(a,n,sizeof(int),ucmpii);}
void SORTR(int*a, int n){qsort(a,n,sizeof(int),dcmpii);}
void LSORT(LL*a, int n){qsort(a,n,sizeof(LL),ucmpll);}
void LSORTR(LL*a, int n){qsort(a,n,sizeof(LL),dcmpll);}

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


int H,W;
LL ans=0;
int sx,sy,gx,gy;
char S[1010][1010];
int cnt[1010][1010] = {0};
int qxbeg=0,qxend=0, quex[100000000];
int qybeg=0,qyend=0, quey[100000000];

void dfs(int a, int b){
  cnt[a][b] = ans+1;
  REP(i,4){
    int x = a+dx[i];
    int y = b+dy[i];
    if(x<0||H<=x||y<0||W<=y) continue;
    if(S[x][y] == '#') continue;
    if(cnt[x][y]) continue;
    dfs(x,y);
  }
  REP(i,5)REP(j,5){
    int x = a-2+i;
    int y = b-2+j;
    if(x<0||H<=x||y<0||W<=y) continue;
    if(S[x][y] == '#') continue;
    if(cnt[x][y]) continue;
    quex[qxend++] = x;
    quey[qyend++] = y;
  }
}

void solve(){
  dfs(sx,sy);
  while(!cnt[gx][gy]){
    ans++;
    int N = qxend-qxbeg;
    int tmp=0;
    REP(i,N){
      int x = quex[qxbeg++], y = quey[qybeg++];
      if(cnt[x][y]==0){
        dfs(x,y);
        tmp++;
      }
    }
    if(!tmp && !cnt[gx][gy]){
      ans = -1;
      break;
    }
  }
}

int main(){
  
  scanf("%d%d%d%d%d%d",&H,&W,&sx,&sy,&gx,&gy);
  sx--;sy--;gx--;gy--;
  REP(i,H) scanf("%s",S[i]);

  solve();

  printf("%lld",ans);
}

Measured memory_bytes: 15644
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,x,a[30];
int main()
{
	scanf("%d",&n);
	int L=1;
	ll ans=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		int NewL=L;
		for (int j=0;j<=19;j++)
		if ((x>>j)&1)
		{
			NewL=max(NewL,a[j]+1);
			a[j]=i;
		}
		if (NewL!=L) L=NewL;
		ans+=i-L+1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private static final byte MASK_RIGHT = 0x0F;
	private static int[][] paper = new int[10][10];

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 128);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	private static void droppingInk(int x, int y, int size) {
		staining(x, y - 1);
		staining(x - 1, y);
		staining(x, y);
		staining(x + 1, y);
		staining(x, y + 1);
		if (size == 1) {
			return;
		}

		staining(x - 1, y - 1);
		staining(x + 1, y - 1);
		staining(x - 1, y + 1);
		staining(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		staining(x, y - 2);
		staining(x - 2, y);
		staining(x + 2, y);
		staining(x, y + 2);
	}

	private static void staining(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			paper[x][y]++;
		}
	}

	private static void calcResult() {
		int white = 0;
		int maxnoud = 0;
		for (int[] row : paper) {
			for (int colum : row) {
				if (colum == 0) {
					white++;
				} else if (colum > maxnoud) {
					maxnoud = colum;
				}
			}
		}
		System.out.println(white);
		System.out.println(maxnoud);
	}
}

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

// study

int main(){
    int n, x[16][16], y[16][16], a[16];
    cin >> n;
    rep(i, n){
        cin >> a[i+1];
        rep(j, a[i+1]){
            cin >> x[i+1][j+1];
            cin >> y[i+1][j+1];
        }
    }

    int ans = 0;
    for (int bit = 1; bit < (1<<n); bit++) {
        bool flag = true;
        for (int i = 1; i <= n; i++){
            if (!(bit & (1 << (i - 1)))) continue;
            for (int j = 1; j <= a[i]; j++){
                if((1 & (bit >> (x[i][j] - 1))) ^ y[i][j]) flag = false;
            }
        }
        if(flag) ans = max(ans, __builtin_popcount(bit));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int B[] = new int[N - 1];
		int sum = 0;
		
		for (int i  = 0; i < N - 1; i++) {
			B[i] = scanner.nextInt();
		}
		/*
		System.out.println(N);
		for (int k = 0; k < N - 1; k++) {
			System.out.println(B[k]);
		}*/
		sum += B[0];
		sum += B[0];
		for (int j = 1; j < N - 1; j++) {
			sum += B[j];
			if (B[j - 1] > B[j]) {
				sum -= B[j - 1];
				sum += B[j];
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// Binary Indexed Tree / Fenwick tree
// can calculate partial sum in O(logN)
// can update single datum in O(logN)
// lower_bound is binary search O(logN)
// 0-indexed!!!
template <typename T = int>
struct BinaryIndexedTree {
    int n;
    vector<T> bit;
    BinaryIndexedTree(int n_, T init = 0) : n(n_), bit(n_ + 1, init) {}
    BinaryIndexedTree(vector<T> init) : n(init.size() + 1), bit(init.size() + 1) {
        for (int i = 1; i < init.size() + 1; ++i) {
            bit[i] = init[i - 1];
        }
    }
    T sum(int i) {
        i++;
        T s = bit[0];
        for (int x = i; x > 0; x -= (x & -x))
            s += bit[x];
        return s;
    }
    void add(int i, T a) {
        i++;
        if (i == 0)
            return;
        for (int x = i; x <= n; x += (x & -x))
            bit[x] += a;
    }
    int lower_bound(int w) {
        if (w <= 0)
            return 0;
        int x = 0, r = 1;
        while (r < n)
            r <<= 1;
        for (int k = r; k > 0; k >>= 1) {
            if (x + k <= n && bit[x + k] < w) {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }
    int upper_bound(int w) {
        if (w < 0)
            return 0;
        int x = 0, r = 1;
        while (r < n)
            r <<= 1;
        for (int k = r; k > 0; k >>= 1) {
            if (x + k <= n && bit[x + k] <= w) {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }
    T query(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

int main() {
    ll n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    auto check = [&](ll mid) {
        vl b(n, 0);
        for (int i = 0; i < n; ++i) {
            if (a[i] >= mid)
                b[i] = 1;
            else
                b[i] = -1;
        }
        for (int i = 1; i < n; ++i) {
            b[i] += b[i - 1];
        }
        BinaryIndexedTree<ll> bit(2 * n + 2);
        bit.add(n, 1); // n == 0
        ll sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += bit.query(0, n + b[i] + 1);
            bit.add(n + b[i], 1);
        }
        return sum >= (n * (n + 1) / 2 + 1) / 2;
    };
    ll ok = 0;
    ll ng = 1e9 + 1;
    while (abs(ok - ng) != 1) {
        ll mid = (ng + ok) / 2;
        if (check(mid))
            ok = mid;
        else
            ng = mid;
    }
    cout << ok << "\n";

    return 0;
}

Measured memory_bytes: 3420
#include<stdio.h>

int main(){
	char ch;
	while((ch = getchar()) != EOF){
			if(ch >= 97 && ch <= 122)
				printf("%c",ch-32);
			else if(ch >= 65 && ch <= 90)
				printf("%c",ch+32);
			else
				printf("%c",ch);
	}
}


Measured memory_bytes: 2476
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)

int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}

using namespace std;

signed main() {
	int N,x;
    string S;
	cin >> N >> S;
    x = N;
    rep(i, N-1) {
        if (S[i] == S[i + 1])
            x--;
    }
    cout << x;
}

Measured memory_bytes: 760
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int N;
int* A, * B;

//////////一般化した二分探索

const bool LEFT = false;
const bool RIGHT = true;
bool judgeLR(int x);// 左に属するか右に属するかを判断する関数。下で定義する。

int nibutanL(int size) {// LEFTグループに属するうち最も右側のindexを得る
	int L = -1;
	int R = size;
	while (abs(R - L) > 1) {
		int mid = (L + R) / 2;
		if (judgeLR(mid) == RIGHT) R = mid;
		else L = mid;
	}
	return L;
}
int nibutanR(int size) {//RIGHTグループに属するうち最も左側のindexを得る
	return nibutanL(size) + 1;
}

const int N_MAX = 200000;
ll bit[N_MAX];

int sum(int i) {
	int s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void add(int i, int x) {
	while (i <= N_MAX - 1) {
		bit[i] += x;
		i += i & -i;
	}
}

bool judgeLR(int x) {
	ll M = (ll)N * (ll)(N + 1) / 2;
	M = (M + 1) / 2;

	int offset = 100;
	for (int i = 0; i < N; i++) {
		if (A[i] >= x) {
			B[i] = 1;
		}
		else {
			B[i] = -1;
		}
		if (i > 0) {
			B[i] += B[i - 1];
		}

		offset = min(offset, B[i]);
	}

	offset -= 2;

	for (int i = 0; i < N_MAX; i++) {
		bit[i] = 0;
	}

	ll ans = 0;
	add(0 - offset, 1);
	for (int i = 0; i < N; i++) {
		B[i] -= offset;
		ans += (ll)sum(B[i]);
		add(B[i], 1);
	}

	if (ans >= M) { return LEFT; }
	else { return RIGHT; }
}

int main() {
	cin >> N;
	A = new int[N];

	multimap<int, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mp.insert({ A[i], i });
	}

	// if (N == 1) { cout << A[0] << endl; return 0; }

	B = new int[N];
	for (int i = 0; i < N; i++) {
		B[i] = 0;
	}

	cout << nibutanL(1000000007) << endl;

	return 0;
}

Measured memory_bytes: 7296
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; vl numsum(100001,0); ll count = 0;
  
  for(ll i=0; i < n; i++){
    ll x; cin >> x; 
    if(x >= 100001) count++;
    else numsum[x]++;
  }
  
  for(ll i=0; i < 100001; i++){
    if(numsum[i] < i && numsum[i] > 0) count += numsum[i];
    else if(numsum[i] > i && numsum[i] != 0) count += numsum[i] - i;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a, b;
	char op;
	
	while(1) {
		scanf("%d %c %d", &a, &op, &b);
		
		if (op == '?') break;
		
		if (op == '+')
		printf("%d\n", a + b);
	
		if (op == '-')
		printf("%d\n", a - b);
	
		if (op == '*')
		printf("%d\n",a * b);
	
		if (op == '/')
		printf("%d\n", a / b);
	}
	
	return 0;
}

Measured memory_bytes: 600
/*I wanna be the very best, like no one ever was...*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int x; cin >> x;
	cout << (x ^ 1);	
	
	return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int A[N][3];
    // memset(A, -1, )
    for(int i =0;i<N;i++)
        for(int j = 0;j<3;j++){
            cin >> A[i][j];
        }
    // cout << "Hello" << endl;
    int tot = 0;
    int max_ind_prev_row = -1;
    int dp[N][3];
    dp[0][0] = A[0][0];
    dp[0][1] = A[0][1];
    dp[0][2] = A[0][2];
    for(int i = 1;i<N;i++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + A[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + A[i][1];
        dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + A[i][2];
    }
    cout << max(max(dp[N-1][0], dp[N-1][1]), dp[N-1][2]);
}

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

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

    int n, total = 0;
    cin >> n;
    vector<int> T(n);
    for(int i = 0; i < n; i++){
        cin >> T[i];
        total += T[i];
    }
    int m;
    cin >> m;
    vector<int> P(m), X(m);
    for(int i = 0; i < m; i++){
        cin >> P[i] >> X[i];
        P[i]--;
    }

    for(int i = 0; i < m; i++){
        cout << total - T[P[i]] + X[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque
H,W = list(map(int, input().split()))
s = [input().split() for i in range(H)]
for i in range(H):
    s[i] = list(s[i][0])
black = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            black += 1
queue = deque([])
dist = [[-1 for i in range(W)] for j in range(H)]
dist[0][0] = 0
queue.append([0,0])
place_w = [0, 1, 0, -1]
place_h = [1, 0, -1, 0]
Flag = False
while len(queue) > 0:
    vh,vw = queue.popleft()
    for m in range(4):
        nvh = vh+place_h[m]
        nvw = vw+place_w[m]
        if 0<=nvh<H and 0<=nvw<W and dist[nvh][nvw] == -1 and s[nvh][nvw] == ".":
            queue.append([nvh,nvw])
            dist[nvh][nvw] = dist[vh][vw]+1
if dist[H-1][W-1] == -1:
    print(-1)
else:
    print(W*H-dist[H-1][W-1]-black-1)
    




Measured memory_bytes: 3316
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

ll digit(ll x){
    ll cnt=0;
    while(x>0){
        x/=10;
        cnt++;
    }
    return cnt;
}
int main(){
    ll n; cin>>n;
    ll ans;
    for(ll i=sqrt(n);1<=i;i--){
        //cout<<i<<endl;
        if(n%i!=0)continue;
        ans=max(i,n/i);
        break;
    }
    cout<<digit(ans)<<endl;
}



















































Measured memory_bytes: 256
from collections import Counter
n=int(input())
s=input()
r=g=b=0
for i in range(len(s)):
    if s[i]=='R':r+=1
    elif s[i]=='G':g+=1
sum=r*g*(n-r-g)

for i in range(len(s)):
    r=i
    for j in range(1,len(s)):
        g=i+j
        b=i+j+j
        if g<len(s) and b<len(s):
            if s[r]!=s[b] and s[g]!=s[b] and s[r]!=s[g]:sum-=1
print(sum)














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

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

    int cnt = 0;
    for(int i = 0; i < N-1; ++i) {
        if( (H[i] - H[i+1]) > 1) { cout << "No" << endl; return 0; }
        else if( (H[i] - H[i+1]) == 1 ) ++cnt;
        else if( H[i] < H[i+1] ) cnt = 0; // reset
        else ;//do nothing

        if(cnt > 1) {cout << "No" << endl; return 0; }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;
#define MAX 500000
#define SENTINEL 2000000000

int n;
int cnt;
int L[MAX/2+2], R[MAX/2+2];

void merge(int A[],int left, int mid, int right){
  int n1=mid-left;
  int n2=right-mid;
  for(int i=0;i<n1;i++) L[i]=A[left+i];
  for(int i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1] = R[n2] = SENTINEL;
  int i=0,j=0;
  for(int k=left;k<right;k++) {
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(int A[], int left, int right){
  if(left +1 < right ) {
    int mid =(left +right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid ,right);
    merge(A, left, mid, right);
  }
}

int main (){
  cin >> n;
  int A[500002];
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  mergeSort(A, 0, n);

  for(int i=0;i<n;i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

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

signed main() {
  int a, b;
  cin >> a >> b;
  printf("%.10f\n", 0.1*a/b*10);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    int h,w;
    cin>>h>>w;
ll sum = 0;
    rep(i, h) {
        auto m = i+1;
        rep(j, w) {
            auto d = j +1;
            auto d1 = d % 10;
            auto d10 = d / 10;
            if(d1 > 1 && d10 > 1 && d1 * d10 == m)  sum++;
        }
    }
    pr(sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

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

  if(N == 1){
    cout << "Hello World" << endl;
    return 0;
  } else {
    int A,B; cin >> A >> B;
    cout << A+B << endl;
  }
}

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

using namespace std;
typedef long long ll;
const int N = 200'010;
vector<int> g[N];
int n, c[N], sz[N], cnt[N];
ll ans[N];

ll get(ll a) { return a * (a + 1) / 2; }

void dfs(int v, int p = -1) {
    auto tmp = cnt[c[v]];
    for (auto to : g[v]) {
        if (to == p) continue;
        cnt[c[v]] = 0;
        dfs(to, v);
        sz[v] += sz[to];
        ans[c[v]] -= get(sz[to] - cnt[c[v]]);
    }
    cnt[c[v]] = tmp + sz[v];
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
    for (int i = 1; i <= n; i++) sz[i] = 1;
    int a, b;
    for (int i = 1; i < n; i++) {
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1);
    for (int i = 1; i <= n; i++) printf("%lld\n", get(n) + ans[i] - get(n - cnt[i]));
}


Measured memory_bytes: 37176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin>>s;
    if(s.at(0)==s.at(1)&&s.at(2)==s.at(1)&&s.at(0)==s.at(2)){
        cout << "No"<<endl;
    } else {
        cout <<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    ll N; cin >> N;
    if(N % 2 == 1 || N <= 8){
        cout << 0 << endl;
        return 0;
    }
    N /= 2;
    ll now = 5;
    ll ans = 0;
    while(now <= N){
        ll k = N;
        ans += N/now;
        now *= 5;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  string str = "zabcdefghijklmnopqrstuvwxy";
  string ans = "";
  while (n > 0) {
    ll a = n % 26;
    ll b = n / 26;
    ans = ans + str[a];
    if (a == 0) b--;
    n = b;
  }
  reverse(ALL(ans));
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,x,y; cin>>x>>n;
	set<ll> s;
	for(ll i=0;i<n;i++) cin>>y,s.insert(y);
	for(ll d=0;;d++){
	//	cout<<d<<" "<<x+d<<" "<<x-d<<endl;
		if(!s.count(x-d)) {
			cout<<x-d; break;
		}
		if(!s.count(x+d)) {
			cout<<x+d; break;
		}
	}
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Lesson6A　与えられた数列を逆順に出力するプログラム
 *
 * @author 前島佑介
 * @version 2014/12/1
 */
class Main {

	/**
	 * プログラムのエントリポイント
	 * @param args
	 */
	public static void main(String[] args) {

		// 1行目読み込む
		try {
			BufferedReader insBR = new BufferedReader(new InputStreamReader(
					System.in));

			String strNum = insBR.readLine();

			// 数値化
			int intNum = Integer.parseInt(strNum);

			// 2行目読み込む
			String strLine = insBR.readLine();

			// 2行目をばらけさせる
			String[] strAry = strLine.split(" ");

			// intにキャストして配列にいれる
			int[] intAry = new int[intNum];

			for (int i = 0; i < intNum; i++) {
				intAry[i] = Integer.parseInt(strAry[i]);
			}

			// 反転させる
			for (int i = 0; i < intNum / 2; i++) {

				int intChage = 0;
				intChage = intAry[i];
				intAry[i] = intAry[intNum - 1 - i];
				intAry[intNum - 1 - i] = intChage;

			}

			// 出力
			for (int i = 0; i < intNum; i++) {
				if(i ==0) {
					System.out.print(intAry[i]);
				} else {
					System.out.print(" " + intAry[i]);
				}
			}
			System.out.println("");


		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}

	}
}

Measured memory_bytes: 16916
#include<stdio.h>
int main(){
  long long n,d[100010],i,m=1e18;
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld",&d[i]);
  for(i=0;i<n;i++){
    if(d[i]==0){
      printf("0\n");
      return 0;
    }
  }
  for(i=0;i<n;i++){
    if(m<d[i])goto END;
    m=(m-1)/d[i]+1;
  }
  m=1;
  for(i=0;i<n;i++)m*=d[i];
  if(m>(long long)1e18)goto END;
  printf("%lld\n",m);
  return 0;
 END:;
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 2516
// ConsoleApplication15.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
int hn[200500];
int main()
{
	double n, k,ci;
	int i;
	while (cin>>n>>k)
	{
		ci = 0;
		for ( i = 0; i < n; i++)
		{
			cin >> hn[i];
		}
		sort(hn, hn + i, [](double a, double b) {return a > b; });
		for (int p = k; p <n; p++)
		{
			ci += hn[p];
		}
		cout <<fixed<<setprecision(0)<< ci << "\n";
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int ans = 0;

    cin >> n;

    for (int i = 1; i <= n; i++) {
        if (to_string(i).size()%2) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
memo = [0] * 87
def luca(n):

  if n == 0:
    return 2
  elif n == 1:
    return 1

  if not memo[n]:
    memo[n] = luca(n - 2) + luca(n - 1)
  return memo[n]

print(luca(N))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N ;
  cin >> N;
  int A[110];
  int P= 0;
  int Q= 0;
  for(int i= 0; i<N; i++) {
    cin >> A[i];
  }
  sort(A,A+N);
  reverse(A,A+N);

  for(int i = 0; i<N; i++){
    int k = i;
    if(k%2 ==0) P+= A[i];
    else Q+= A[i];
  }
  cout << P-Q << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        abs: [(i64, i64); n],
        cds: [(i64, i64); m],
    }

    for (a, b) in abs {
        let j = (0..m)
            .min_by_key(|&j| {
                let (c, d) = cds[j];
                (a - c).abs() + (b - d).abs()
            })
            .unwrap();
        println!("{}", j + 1);
    }
}

Measured memory_bytes: 2184
#include<stdio.h>

main(){

  int x,y,r;

  scanf("%d%d",&x,&y);
/*
  if (x < y){
    swap(x, y);
  }
  */
  while (y > 0){
    r = x % y;
    x = y;
    y = r;
  }
printf("%d\n",x);
  return 0;
}

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

int main() {
  char a,b;
  cin >> a >> b;
  if(a==b){
    cout << 'H' << endl;
  }else{
    cout << 'D' << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, L: int):
    T = [L+i for i in range(N)]

    min_abs = float("inf")
    st = float("inf")
    for t in T:
        if min_abs > abs(t):
            min_abs = abs(t)
            st = t

    print(sum(T) - st)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    solve(N, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
string s;
ll memo[100100][14];
ll dp(int i, int j){
    if(i == s.size()) return j == 5?1:0;
    if(memo[i][j] != -1) return memo[i][j];

    ll res = 0;
    if(s[i] != '?'){
        int now = s[i] - '0';
        res += dp(i + 1, (j * 10 + now) % 13);
        res %= MOD;
    } else {
        for(int d = 0; d < 10; d++){
            res += dp(i + 1, (j * 10 + d) % 13);
            res %= MOD;
        }
    }

    return memo[i][j] = res;
    
}

int main(void){
    cin >> s;

    for(int i = 0; i <= s.size(); i++){
        for(int j = 0; j < 14; j++){
            memo[i][j] = -1;
        }
    }

    cout << dp(0, 0) % MOD << endl;
}

Measured memory_bytes: 19200
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

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

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll i,j;
  vec d(2);
  mat v(4,vec(2));
  rep(i,2)rep(j,2)cin>>v[i][j];
  For(i,2,4){
    rep(j,2)d[j]=v[i-1][j]-v[i-2][j];
    d[1]*=-1;
    swap(d[0],d[1]);
    rep(j,2)v[i][j]=v[i-1][j]+d[j];
    cout<<v[i][0]<<" "<<v[i][1]<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[100005],d=0,ans=0;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
}
d=0;
for(ll i=1;i<n;i++)
if(a[i]<=a[i-1]){
    d++;
}else{
ans=max(ans,d);
d=0;
}
ans=max(ans,d);
cout<<ans<<endl;
}





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

int main(){

	long long L;
	long long R;
	cin >> L;
	cin >> R;
	long long ans;
	ans = 2019;
	long long tmp;
	long long L2;
	long long R2;
	L2 = L%2019;
	R2 = R%2019;

	if(L%2019==0 || R%2019==0){
		cout << 0 << endl;
	} else if((R-L)>=2019){
		cout << 0 << endl;
	} else {
		if(L2<R2){
			for(int i=L2;i<=R2;i++){
				for(int j=i+1;j<=R2; j++){
					tmp = (i*j)%2019;
					if(tmp<ans){
						ans = tmp;
					}
				}
			}
		} else {
			for(int i=R2;i<=L2;i++){
				for(int j=i+1;j<=L2; j++){
					tmp = (i*j)%2019;
					if(tmp<ans){
						ans = tmp;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int man=1000005;
const int MAXM= 15000005;
int n,k;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin>>n>>k;
  if(k&1)
  {
      ll t1=n/k;
      cout<<t1*t1*t1<<endl;
  }
  else
  {
      ll t1=n/k;
      ll t2=n*2/k-t1;
      cout<<t1*t1*t1+t2*t2*t2<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;

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

	if (a == b&&b == c)
	{
		puts("1");
	}	
	else if (a == b || b == c || a == c)
	{
		puts("2");
	}
	else
	{
		puts("3");
	}

	return 0;
}

Measured memory_bytes: 128
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(n);V t(n);V v(n);VECCIN(t);VECCIN(v);
  t.pb(1);v.pb(0);

  vector<double> maxsp(1,0);

  REP(i,n){
    REP(j,t[i]*2-1){
      maxsp.pb(v[i]);
    }
    maxsp.pb(min(v[i],v[i+1]));
  }

  maxsp.pb(0);
  // VECCOUT(maxsp);
  FOR(i,1,maxsp.size()-1)maxsp[i]=min({maxsp[i-1]+0.5,maxsp[i],maxsp[i+1]+0.5});
  // VECCOUT(maxsp);
  for(int i=maxsp.size()-2;i>=1;i--)maxsp[i]=min({maxsp[i-1]+0.5,maxsp[i],maxsp[i+1]+0.5});
  // VECCOUT(maxsp);

  double ans=0;
  FOR(i,1,maxsp.size()){
    ans += min(maxsp[i],maxsp[i-1])*0.5 + (abs(maxsp[i]-maxsp[i-1])/2);
  }
  printf("%.8f",accumulate(ALL(maxsp),0.0)/2);
  // printf("%.8f",ans);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

long long int combination(long long int a,long long int b){
    queue<long long int> bunsi,bunbo;
    long long int ans=1;
    b=min(b,a-b);
    for(int i=0;i<b;i++){
        bunsi.push(a-i);
        if(b-i>=2)bunbo.push(b-i);
    }
    while(bunsi.size()!=0||bunbo.size()!=0){
        ans*=bunsi.front();
        bunsi.pop();
        if(ans%bunbo.front()==0){
            ans/=bunbo.front();
            bunbo.pop();
        }
    }
    return ans;
}

bool one (int i) {
    if(i>=1)return true;
    else return false;
}

int main(){
    int n;
    in(n);
    int a,b;
    vector<pair<int,int>> vec(n);
    rep(i,n){
        in(a,b);
        vec[i]=make_pair(a,b);
    }
    ll ans=0;
    reverse(all(vec));
    rep(i,n){
        if((vec[i].first+ans)%vec[i].second!=0){
            ans+=(ll)vec[i].second-((ll)vec[i].first+ans)%((ll)vec[i].second);
        }
    }
    out(ans);
}

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

static const int X = 11, Y = 11;
static const int DIR = 4;
static const string dirchar= "RDLU";
static const int dirx[DIR] = {1,0,-1,0}, diry[DIR] = {0,1,0,-1};

int main(){
	int field[X][Y] = {0};
	string s;
	int x,y;
	y=0;
	while( getline(cin,s) ){
		for(x=0;x<s.size();++x)field[x*2+1][y+1] = s[x]-'0';
		y++;
	}
	for(y=1;y<Y;y+=2) for(x=1;x<X;x+=2) if(field[x][y])field[x+1][y] = 1;
	for(y=2;y<Y;y+=2) for(x=1;x<X;x+=2)
		if(field[x][y]){
			field[x][y+1] = 1;
			field[x][y-1] = 1;
		}
	vector<int> ans;
	x=y=1;
	int dir=0;
	while(true){
		for(int i=0; i<DIR; ++i){
			const int tdir = (dir+DIR-1+i)%DIR;
			if( field[x + dirx[tdir]][y + diry[tdir]] ){
				x += dirx[tdir]*2;
				y += diry[tdir]*2;
				ans.push_back(tdir);
				dir = tdir;
				break;
			}
		}
		if( x==1 && y==1 )break;
	}
	for(int i=0;i<ans.size();++i)cout << dirchar[ans[i]];
	cout << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int num, n, d, rev;
    cin>>num;
    while(num)
    {
        n=num%10;
        if(n==7) break;
        else {
            num=num/10;
        }
    }
    if(n==7)
      cout<<"Yes";
    else
    {
        cout<<"No";
    }
      
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
// #include "lib.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 0
#define MAXN 1000006
#define MAXK 26
#define MAXX 15000006
#define ll long long
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define forit(it, A) for(set<ll>::iterator it = A.begin(); it != A.end(); it++)
#define bg(ms) *ms.begin()
#define ed(ms) *prev(ms.end(), 1)
#define addedge(a, b, c) v[a].pb(pi(b, c)); v[b].pb(pi(a, c))
#define ph push
#define all(x) x.begin(), x.end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
ll n, dom;
pi ans[106];
spi A[106];
int main()
{
	cin >> n;
	for(ll i = 0; i < n; i++)cin >> A[i].s.f >> A[i].s.s >> A[i].f;
	for(ll x = 0; x <= 100; x++)
	{
		for(ll y = 0; y <= 100; y++)
		{
			memset(ans, 0, sizeof ans);
			dom = -1;
			ll cannot = 0;
			for(ll i = 0; i < n; i++)
			{
				ll h = A[i].f, nx = A[i].s.f, ny = A[i].s.s;
				if(h == 0)
				{
					ans[i].f = 0;
					ans[i].s = (abs(x-nx) + abs(y-ny));
					continue;
				}
				ans[i].f = 1;
				ans[i].s = h+(abs(x-nx) + abs(y-ny));
				dom = ans[i].s;
			}
			if(dom == -1)
			{
				for(ll i = 1; i < n; i++)
				{
					if(ans[i].f)assert(false);
					if(ans[i].s != ans[i-1].s)
					{
						cannot = 1;
						break;
					}
				}
				if(cannot)continue;
				cout << x << ' ' << y << ' ' << ans[0].s << "\n";
				return 0;
			}
			else
			{
				for(ll i = 0; i < n; i++)
				{
					if(ans[i].f)
					{
						if(ans[i].s != dom)
						{
							cannot = 1;
							break;
						}
					}
					else
					{
						if(dom > ans[i].s)
						{
							cannot = 1;
							break;
						}
					}
				}
				if(cannot)continue;
				cout << x << ' ' << y << ' ' << dom << "\n";
				return 0;
			}
		}
	}
	assert(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long
#define MP make_pair
#define N 805

using namespace std;
typedef pair<int, int> Pair;

inline int input() {
	int x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

const int mod = 1e9 + 7;
const int MAX = 88;
int Q, x, y;
int f[100];

vector<Pair> P[100]; // P[i] 存的是 f(x, y) == i 的 优秀的对

void init() {
	f[0] = 1, f[1] = 2;
	for (int i = 2; i <= MAX; ++i) f[i] = f[i - 1] + f[i - 2];
	P[1].push_back(MP(1, 2)), P[1].push_back(MP(1, 3)), P[1].push_back(MP(1, 4));

	for (int i = 1; i <= MAX; ++i)
		for (auto p : P[i]) {
			int x = p.first, y = p.second;
			for (int j = x + y; j <= f[i + 1] << 1; j += y)
				P[i + 1].push_back(MP(y, j));
		}
}

void solve(int x, int y) {
	int k = 1;
	if (x > y) swap(x, y);
	while (f[k] <= x && f[k + 1] <= y) ++k;
	printf("%lld ", k);

	if (k == 1) {
		printf("%lld\n", x % mod * y % mod);
		return void();
	}

	int res = 0;
	for (auto p : P[k - 1]) {
		int xd = p.first, yd = p.second;
		if (yd <= x) res += (y - xd) / yd % mod;
		if (yd <= y) res += (x - xd) / yd % mod;
	}

	printf("%lld\n", res % mod);
}

signed main() {

	init();
	Q = input();
	while (Q--) {
		x = input(), y = input();
		solve(x, y);
	}
	return 0;
}


Measured memory_bytes: 4096
class SegmentTree:
  def __init__(self, size, default, op = max):
    self.size = 2**size.bit_length()
    self.dat = [default]*(self.size*2)
    self.op = op

  def update(self, i, x):
    i += self.size
    self.dat[i] = x
    while i > 0:
      i >>= 1
      self.dat[i] = self.op(self.dat[i*2], self.dat[i*2+1])

  def add(self, i, x):
    i += self.size
    self.dat[i] = self.op(self.dat[i], x)
    while i > 0:
      i >>= 1
      self.dat[i] = self.op(self.dat[i], x)

  def get(self, a, b = None):
    if b is None:
      b = a + 1
    l, r = a + self.size, b + self.size
    res = None
    while l < r:
      if l & 1:
        if res is None:
          res = self.dat[l]
        else:
          res = self.op(res, self.dat[l])
        l += 1

      if r & 1:
        r -= 1
        if res is None:
          res = self.dat[r]
        else:
          res = self.op(res, self.dat[r])
      l >>= 1
      r >>= 1
    return res

N = int(input())
H = list(map(int,input().split()))
A = list(map(int,input().split()))

dp = SegmentTree(N,0)
for i in range(N):
  h = H[i]
  a = A[i]
  dp.update(h-1,dp.get(0,h)+a)
print(dp.get(0,N))


Measured memory_bytes: 123856
#include<iostream>
using namespace std;
int M,d[2<<17];
long c[2<<17];
main()
{
	cin>>M;
	long ans=-1;
	long now=0;
	for(int i=0;i<M;i++)
	{
		cin>>d[i]>>c[i];
		bool vis[10]={};
		long cnt[10]={};
		long id[10]={};
		long nid=0,ncnt=0;
		while(c[i]>0)
		{
			ncnt++;
			nid++;
			ans++;
			now+=d[i];
			c[i]--;
			while(now>=10)
			{
				ncnt++;
				ans++;
				now=now/10+now%10;
			}
			if(!vis[now])
			{
				vis[now]=true;
				cnt[now]=ncnt;
				id[now]=nid;
			}
			else
			{
				ans+=c[i]/(nid-id[now])*(ncnt-cnt[now]);
				c[i]%=nid-id[now];
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
s = gets.chomp

def muri
  p -1
  exit
end

if s[0]==?0 || s[-1]==?1
  muri
end

s = s[0..-2]

if !(s.size.times.map{|i| s[i]==s[-i-1]}.all?)
  muri
end

pre = 1
1.upto(s.size){|i|
  puts [pre,i+1]*" "
  pre = i+1 if s[i-1]==?1
}


Measured memory_bytes: 4088
#include<iostream>
#include<algorithm>
#include<cstring>
#include<numeric>
#include<vector>
using namespace std;

#define int long long

#ifdef lioraju
	#define ndbg(x) 
#else
	#define ndbg(x) x
#endif

const int mxsz = 100 + 5;
const int mxW = 1e5 + 5;

int w[mxsz], v[mxsz];

int dp[mxsz][mxW];
bool vis[mxsz][mxW];

int d(int n, int W)
{
	if (n<0) return 0;
	if (vis[n][W]) return dp[n][W];
	
	vis[n][W] = 1;
	int mxn = d(n-1, W);
	if (W>=w[n]) mxn = max(mxn, d(n-1, W-w[n])+v[n]);
	
	return dp[n][W] = mxn;
}

signed main()
{
	ndbg( ios::sync_with_stdio(0); cin.tie(0); );
	int n, W; cin>>n>>W;
	for (int i=0;i<n;i++) cin>>w[i]>>v[i];
	
	cout<<d(n-1, W)<<'\n';
}

Measured memory_bytes: 90368