akhauriyash/Code-Regression huggingface dataset:
#import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np


def main():
	k=II()
	s=input()

	if len(s)<=k:
		print(s)
	else:
		print(s[:k]+"...")
















if __name__ == "__main__":
	main()


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int solve (int c,vector<int> &a, int n)
{	
	int ans = 0;
	for(int i=0;i<n;i++){
		ans = ans+((a[i] - c) * (a[i] - c));
	} 
return ans;
}
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	vector<int> v(n);
	int ans = 1e9+7;
	for(int i=1;i<=200;i++){
		// cout<<solve(i,a,n)<<"\n";
		if(solve(i,a,n)<ans)ans = solve(i,a,n);
	}
	cout<<ans;
}
// cnt == s.length() || 

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

lint SA[40], SB[40];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    lint A, B; cin >> A >> B;

    A--;
    lint p = 2, ans = 0;
    for(int i=0;i<40;i++){
        SA[i] = (p / 2 * (A/p) + max(0LL, A%p-p/2+1)) % 2;
        SB[i] = (p / 2 * (B/p) + max(0LL, B%p-p/2+1)) % 2;
        p <<= 1;
    }

    p = 1;
    for(int i=0;i<40;i++){
        ans += p * (SA[i]^SB[i]);
        p <<= 1;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FOR(x,n) for(int x = 0; x < n; x++)
#define FORR(x,n) for(int x = n-1; x >= 0; x--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)a.size())
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;

int main(){
  int N; cin >> N;
  string s, t; cin >> s >> t;
  for(int x = 0; x < N; x++) {
    bool can = true;
    for(int y = 0; y+x < N; y++)
      can &= s[x+y] == t[y];
    if(can){
      cout << 2*N-(N-x) << "\n";
      return 0;
    }
  }
  cout << 2*N <<"\n";
}

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

int main(void)
{
    ll a, b;
    cin >> a >> b;
    if (a * b % 2 == 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>


using namespace std;

vector<int> order{ 0,1,2,3 };


int main(){
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); i=i+2)
	{
		cout << str[i];
	}
	cout << endl;

	return 0;
}

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

using namespace std;

int main(void) {
  int s = 0;
  for (int i = 0; i < 4; i++) {
    int t;
    cin >> t;
    s += t;
  }
  cout << s / 60 << endl;
  cout << s % 60 << endl;

  return 0;
}


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

int gcd(int a, int b) {
  int A = max(a, b);
  int B = min(a, b);
  if (A < 1 || B < 1) {
    return A;
  }
  return gcd(B, A % B);
}

int main() {
  int N, X, i, x, D;
  cin >> N >> X;
  vector<int> dx(N);
  for (i = 0; i < N; ++i) {
    cin >> x;
    dx[i] = abs(X - x);
  }
  D = dx[0];
  for (i = 1; i < N; ++i) {
    D = gcd(D, dx[i]);
  }
  cout << D << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    int n, k;
    cin >> n >> k;

    vector<int> p(n);
    rep(i, n) cin >> p.at(i);

    sort(p.begin(), p.end());
    int sum = 0;
    for (size_t i = 0; i < k; i++) {
        sum += p.at(i);
    }
    cout << sum << endl;
}


Measured memory_bytes: 3520
#include <cstdio>
#include <algorithm>
using namespace std;
int H, W, L, P, x, y, cl[4009], cr[4009], c[4009], cc[4009], b[4009], bit[4009]; short pl[4009][4009], pr[4009][4009], pu[4009][4009], pd[4009][4009]; bool f[4009][4009];
inline int sum(int r) {
	int ret = 0;
	for (int i = r; i >= 1; i -= i & (-i)) ret += bit[i];
	return ret;
}
int main() {
	scanf("%d %d %d %d", &H, &W, &L, &P);
	for (int i = 0; i < P; i++) {
		scanf("%d %d", &x, &y);
		f[x - 1][y - 1] = true;
	}
	for (int i = 0; i < H; i++) {
		pl[i][0] = (f[i][0] ? 0 : 1);
		pr[i][W - 1] = (f[i][W - 1] ? 0 : 1);
		for (int j = 1; j < W; j++) pl[i][j] = (f[i][j] ? 0 : pl[i][j - 1] + 1);
		for (int j = W - 2; j >= 0; j--) pr[i][j] = (f[i][j] ? 0 : pr[i][j + 1] + 1);
	}
	for (int i = 0; i < W; i++) {
		pu[0][i] = (f[0][i] ? 0 : 1);
		pd[H - 1][i] = (f[H - 1][i] ? 0 : 1);
		for (int j = 1; j < H; j++) pu[j][i] = (f[j][i] ? 0 : pu[j - 1][i] + 1);
		for (int j = H - 2; j >= 0; j--) pd[j][i] = (f[j][i] ? 0 : pd[j + 1][i] + 1);
	}
	long long ret = 0;
	for (int i = L - 1; i <= H + W - L - 1; i++) {
		int vl = (i < W ? 0 : i - W + 1), vr = (i < H ? i + 1 : H);
		fill(c, c + vr - vl + 1, 0); cc[0] = 0;
		fill(bit, bit + vr - vl + 1, 0);
		for (int j = vl; j < vr; j++) {
			cl[j - vl] = min(pl[j][i - j], pd[j][i - j]);
			cr[j - vl] = min(pr[j][i - j], pu[j][i - j]);
			c[j - vl - cr[j - vl] + 2]++;
		}
		for (int j = 1; j <= vr - vl; j++) c[j] += c[j - 1], cc[j] = c[j];
		for (int j = 0; j < vr - vl; j++) b[cc[j - cr[j] + 1]++] = j;
		for (int j = 0; j < vr - vl; j++) {
			for (int k = c[j]; k < c[j + 1]; k++) {
				for (int l = b[k] + 1; l <= vr - vl; l += l & (-l)) bit[l]++;
			}
			if (cl[j] > L - 1) ret += sum(j + cl[j]) - sum(j + L - 1);
		}
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 142488
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define poi 1000000
#define int long long
using namespace std;
struct girl
{
	int x,y;
	bool operator<(girl b) const
	{
		return x<b.x;
	}
}a[poi];
inline int re()
{
	char c=getchar();
	int x=0,k=1;
	while(c<'0'||c>'9')
	{if(c=='-') k=-1;c=getchar();}
	while(c>='0'&&c<='9')
	{x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*k;
}
void wr(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) wr(x/10);
	putchar(x%10+'0');
}
signed main()
{
	int n=re(),m=re(),ans=0;
	for(int i=1;i<=n;i++)
	a[i].x=re(),a[i].y=re();
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(m-a[i].y<0)
		{
			ans+=a[i].x*m;
			break;
		}
		ans+=a[i].x*a[i].y;
		m-=a[i].y;
	}
	wr(ans);
	return 0;
}
/*

*/

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    ll k;
    cin >> k;

    vector<ll> flags;
    FOR(i, 0, k){
        ll b; cin >> b;
        flags.push_back(b);
    }

    ll L = flags.size();
    FOR(i, 0, 1LL<<L){
        ull ma = 0;
        FOR(j, 0, L){
            if(i>>j&1){
                ll bit = flags[j];
                ma |= (1LL<<bit);
            }
        }
        cout << ma << ":";
        FOR(j, 0, 28){
            if(ma>>j&1){
                cout << ' ' << j;
            }
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


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

long long len=s.size();

long long ans=len*(len-1);
ans/=2,ans++;
long long  alpha[26]={};
rep(i,len){
        alpha[s[i]-'a']++;
}
long long seki;
rep(i,26){
    if(alpha[i]>1){
    seki=alpha[i]*(alpha[i]-1);
    seki/=2;
    ans-=seki;
    }
}

cout<<ans<<endl;


 return 0;
}
/*
aatt

5

xxxxxxxxxx

1

abracadabra

44
*/

Measured memory_bytes: 640
import java.util.Scanner;

public class Main
{
    static int dx[] = {0, 0, 1, 1, 1, -1, -1, -1};
    static int dy[] = {1, -1, 1, 0, -1, 1, 0, -1};

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

	
	int h = sc.nextInt();
	int w = sc.nextInt();
	int mp[][] = new int[51][51];
	String s[][] = new String[51][51];

	for(int i = 0; i < h; i++) {
	    String line = sc.next();
	    for (int j = 0; j < w; j++)
		s[i][j] = String.valueOf(line.charAt(j));
	}
	
	for(int i = 0; i < h; i++) {
	    for(int j = 0; j < w; j++) {
		if(s[i][j].equals(".")) continue;
		for(int k = 0; k < 8; k++) {
		    int mx = j + dx[k];
		    int my = i + dy[k];
		    if(mx < 0 || w <= mx || my < 0 || h <= my) continue;
		    mp[i + dy[k]][j + dx[k]]++;
		}
	    }
	}

	for(int i = 0; i < h; i++) {
	    for(int j = 0; j < w; j++) {
		if(s[i][j].equals(".")) System.out.print(mp[i][j]);
		else System.out.print('#');
	    }
	    System.out.println();
	}
    }
}


Measured memory_bytes: 23764
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int N = Cin.Ni();

        Console.WriteLine(N * 800 - (N / 15 * 200));
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 13140
s = input()
t = input()

ls = len(s)
lt = len(t)

dp = [[0 for _ in range(lt + 1)] for _ in range(ls + 1)]  # dp[ls][lt] = LCS_length

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])

res = ''
i = ls
j = lt
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        res = s[i - 1] + res
        i -= 1
        j -= 1
print(res)


Measured memory_bytes: 121308
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n;
		while(scan.hasNext()){
			n = scan.nextInt();
			int ans = 1;
			for(int i = 1;i <= n;i++){
				ans += i;
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 18048
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)

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

    vector<int> A(N), B(N), C(N);
    rep(i, 0, N) {
        int a, b, c;
        cin >> a >> b >> c;
        A[i] = a;
        B[i] = b;
        C[i] = c;
    }

    int dp[100000][3];
    dp[0][0] = A[0], dp[0][1] = B[0], dp[0][2] = C[0];
    rep(i, 1, N) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i];
    }
    cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2])) << endl;
}

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

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

using namespace std;

int main(){
	int d,g; cin>>d>>g;
	int p[10],c[10];
	rep(i,d) cin>>p[i]>>c[i];

	int ans=1000;
	rep(S,1<<d){
		int num=0,score=0;
		vector<int> rem;
		rep(i,d){
			if(S>>i&1){
				num+=p[i];
				score+=c[i]+100*(i+1)*p[i];
			}
			else{
				rep(j,p[i]) rem.emplace_back(100*(i+1));
			}
		}
		sort(rem.begin(),rem.end());
		while(!rem.empty() && score<g){
			num++;
			score+=rem.back();
			rem.pop_back();
		}
		if(score>=g) ans=min(ans,num);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
A = [input() for i in range(H)]
breadth = [[-1] * W for i in range(H)]
queue = deque()

for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            breadth[h][w] = 0
            queue.append([h, w])


def search(A, breadth):
    d = 0
    while queue:
        y, x = queue.popleft()
        d = breadth[y][x]
        for i, j in [-1, 0], [1, 0], [0, -1], [0, 1]:
            newy, newx = y + i, x + j
            if newy < 0 or newx < 0 or newy >= H or newx >= W:
                continue
            if breadth[newy][newx] == -1:
                breadth[newy][newx] = d + 1
                queue.append([newy, newx])

    return d


print(search(A, breadth))


Measured memory_bytes: 140764
n=int(input())
t=[0]*n;a=[0]*n
for i in range(n):t[i],a[i]=map(int,input().split())
T=t[0];A=a[0]
for i in range(1,n):
    k=max((T+t[i]-1)//t[i],(A+a[i]-1)//a[i])
    T=t[i]*k;A=a[i]*k
print(T+A)

Measured memory_bytes: 3064
#全方位木DPによって求める
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9 + 7)


def get_par_tree(tree: list, par: int) -> list:
    """親を求める"""
    n = len(tree)
    ans = [-1] * n
    visited = [False] * n
    visited[par] = True
    q = deque([par])
    while q:
        pos = q.popleft()
        for next_pos in tree[pos]:
            if visited[next_pos]:
                continue
            visited[next_pos] = True
            ans[next_pos] = pos
            q.append(next_pos)
    return ans


def topological_sort_tree(tree: list, par) -> list:
    n = len(tree)
    ans = [par]
    visited = [False] * n
    visited[par] = True
    q = deque([par])
    while q:
        pos = q.popleft()
        for next_pos in tree[pos]:
            if visited[next_pos]:
                continue
            visited[next_pos] = True
            ans.append(next_pos)
            q.append(next_pos)
    return ans


def dfs1():
    """その頂点の部分木での黒色で塗るパターンを求める"""
    visited = [False] * n
    for pos in tp_list[::-1]:
        visited[pos] = True
        for next_pos in graph[pos]:
            if visited[next_pos]:
                continue
            b1[next_pos] *= (1 + b1[pos])
            b1[next_pos] %= MOD


def dfs2():
    """全方位木DP"""
    for pos in tp_list:
        cnt = 0
        b = 1
        par = par_list[pos]
        for next_pos in graph[pos]:
            if next_pos == par:
                d = child_pos[par][pos]
                tmp_b = ruiseki_child_l[par][d] * ruiseki_child_r[par][-d-2]
                tmp_b %= MOD
                b *= (1 + tmp_b)
                b %= MOD
                child_pos[pos][next_pos] = cnt
                child_val[pos].append(1 + tmp_b)
                cnt += 1
            else:
                b *= (1 + b1[next_pos])
                child_pos[pos][next_pos] = cnt
                child_val[pos].append(1 + b1[next_pos])
                cnt += 1
                b %= MOD
        b2[pos] = b
        ruiseki_child_l[pos] += child_val[pos] 
        ruiseki_child_r[pos] += child_val[pos][::-1]
        for i in range(len(child_val[pos])):
            ruiseki_child_r[pos][i+1] = ruiseki_child_r[pos][i] * ruiseki_child_r[pos][i+1]
            ruiseki_child_l[pos][i+1] = ruiseki_child_l[pos][i] * ruiseki_child_l[pos][i+1]
            ruiseki_child_r[pos][i+1] %= MOD
            ruiseki_child_l[pos][i+1] %= MOD


n, m = map(int, input().split())
MOD = m
info = [list(map(int, input().split())) for i in range(n-1)]
graph = [[] for i in range(n)]
dag = [[] for i in range(n)]

for i in range(n-1):
    a, b = info[i]
    a -= 1
    b -= 1
    graph[b].append(a)
    graph[a].append(b)

par_list = get_par_tree(graph, 0)
tp_list = topological_sort_tree(graph, 0)
b1 = [1] * n
dfs1()

child_pos = defaultdict(lambda :defaultdict(dict))
child_val = [[] for i in range(n)]
ruiseki_child_l = [[1] for i in range(n)]
ruiseki_child_r = [[1] for i in range(n)]
b2 = [0] * n
dfs2()

for num in b2:
    print(num % MOD)


Measured memory_bytes: 152924
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    int n = s.length();
    vi num;
    vector<ll> counter(2019);
    vi pre(n+1);
    vi suf(n+1);
    FOR(i,n) num.push_back(s[i]-'0');
    suf[n] = 0;
    int cm = 1;
    for(int i = n-1; i >= 0; i--){
//        cerr << cm << " " << s[i] << " " << cm*s[i] << " " << suf[i+1] << " " << (cm*s[i] + suf[i+1])%2019 << endl;
        suf[i] = (cm*num[i] + suf[i+1])%2019;
        cm = (cm*10)%2019;
    }
    F0R(i,1,n){
        pre[i] = (suf[0] - suf[i-1] + 2019)%2019;
    }
//    FOR(i,n+1) cout << pre[i] << " ";
//    cout << endl;
//    FOR(i,n+1) cout << suf[i] << " ";
//    cout << endl;
    F0R(i,1,n) counter[suf[i]]++;
    int tot = suf[0];
    ll ans = 0;
    F0R(i,1,n){
        ans += counter[(tot-pre[i]+2019)%2019];
        counter[suf[i]]--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6064
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h){
        cin >> s[i];
    }
    REP(i,h){
        put(s[i]);
        put(s[i]);
    }
    return 0;
}


Measured memory_bytes: 256
// Author: 0ChanAk

#include<bits/stdc++.h>
using namespace std;
void isDoublePalindrome(string str, int n)
{
   //int length = string.length();
    // if length is not even, then it is not a double palindrome
    
    int start = 0, f=0;
    int end = n - 1;
    int middle = ((n-1) / 2)-1;
    while (middle >= 0) {
      // if characters are same, move the pointers, otherwise break and
      // return false
      if ((str.at(start) == str.at(middle))
          && (str.at(start) == str.at(end))) {
        start++;
        middle--;
        end--;
      } else {
          f=1;
          break;
        //cout<<"No\n";
      }
    }
    if(f==0)
    cout<<"Yes\n";
    else
    cout<<"No\n";
 
}
 
int main()
{
    string str;
    cin>>str;
    int n=str.size();
    if (n % 2 == 0 || n<3||n>99) {
      cout<<"No\n";
    }
    else
    isDoublePalindrome(str, n);
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N; cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  sort(A.begin(),A.end());
  vector<ll>  B(N);
  B[0] = A[0];
  for (int i = 1; i < N; i++) B[i] = B[i-1] + A[i];
  
  vector<ll> ans(N);
  ans[0] = 1;
  for (int i = 1; i < N; i++) {
    if (2*B[i-1] >= A[i]) ans[i] = ans[i-1]+1;
    else ans[i] = 1;
  }
  
  cout << ans[N-1] << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int n;
    int a;
    int amari;
    cin >> n >> a;
    amari = n%500;
    if(amari <= a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main(){
 int n;
 int v[30];
 int c[30];
 int sum[30];
 int num=0;
 int i;

 cin>>n;

 for(i=0;i<n;i++){
     cin>>v[i];
 }
 for(i=0;i<n;i++){
     cin>>c[i];
 }


 for(i=0;i<n;i++){
     sum[i]=v[i]-c[i];
     if(sum[i]>0){
         num+=sum[i];
     }
 }
 cout<<num;
}





Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$i=0;
while($i<$n){
  list($a[],$b[],$c[])=explode(' ',trim(fgets(STDIN)));
  ++$i;
}

$ans[0]=array(0,0,0);
$i=1;
while($i<=$n){
  $ans[$i][0]=$a[$i-1]+max($ans[$i-1][1],$ans[$i-1][2]);
  $ans[$i][1]=$b[$i-1]+max($ans[$i-1][2],$ans[$i-1][0]);
  $ans[$i][2]=$c[$i-1]+max($ans[$i-1][0],$ans[$i-1][1]);
  ++$i;
}

echo max($ans[$i-1]);

Measured memory_bytes: 65132
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	LL A, B, C;
	cin >> A >> B >> C;

	bool can_choose = false;
	for (LL i = 1; i <= B; i++)
	{
		if ((i*A) % B == C) {
			can_choose = true;
			break;
		}
	}

	if (can_choose) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	int ans = 0;
	for(int i = 3; i <= n; i++){
		for(int j = 1e9; j > 0; j /= 10){
			if(i >= j and  i / j % 2 == 0){
				i += j - 1;
				break;
			}
		}

		vector<bool> res(4, 0);
		for(int j = i; j > 0;){
			int a = j % 10;
			j /= 10;

			res[0] = res[0] or a == 3;
			res[1] = res[1] or a == 5;
			res[2] = res[2] or a == 7;
			res[3] = res[3] or (a != 3 and a != 5 and a != 7);
			if(res[3]) break;
		}
		if(res[0] and res[1] and res[2] and not res[3]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int rd[5000][5000];
using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  std::vector<int> x(N),y(N);
  std::vector<string> c(N);
  for(int i=0;i<N;i++)cin>>x[i]>>y[i]>>c[i];
  int ans=0;
  for(int i=0;i<N;i++)if(c[i]=="B")y[i]+=K;
  for(int i=0;i<N;i++){
    y[i]-=(y[i]/(2*K))*2*K;
    if(y[i]>=K){
      y[i]-=K;
      x[i]+=K;
    }
    x[i]-=(x[i]/(2*K))*2*K;
    //cout<<x[i]<<" "<<y[i]<<endl;
  }
  for(int i=0;i<5000;i++)for(int j=0;j<5000;j++)rd[i][j]=0;
  for(int i=0;i<N;i++){
    rd[x[i]][y[i]]++;
    rd[x[i]+K][y[i]]--;
    rd[x[i]][y[i]+K]--;
    rd[x[i]+K][y[i]+K]++;
  }
  for(int i=0;i<3000;i++){
    for(int j=1;j<3000;j++){
      rd[i][j]+=rd[i][j-1];
    }
  }
  for(int i=0;i<3000;i++){
    for(int j=1;j<3000;j++){
      rd[j][i]+=rd[j-1][i];
    }
  }
  for(int i=0;i<K;i++){
    for(int j=0;j<K;j++){
      rd[i+2*K][j]+=rd[i][j]+rd[i+K][j+K];
      rd[i+K][j]+=rd[i][j+K]+rd[i+2*K][j+K];
    }
  }
  for(int i=0;i<5000;i++)for(int j=0;j<5000;j++)ans=max(ans,rd[i][j]);
  cout<<ans<<endl;
}


Measured memory_bytes: 104192
import sys
input = sys.stdin.readline
H,W,K=map(int,input().split())
CO=[[0 for i in [0]*W] for j in [0]*H]
DO=[[0 for i in [0]*W] for j in [0]*H]
for i in range(H):
 C=input()
 for j in range(W):
  DO[i][j]=int(C[j])
CO[H-1]=DO[H-1]
F=1000000
for s in range(2**(H-1)):
 D=0
 E=0
 for k in range(H-1):
  if ((s >> k) & 1):
   for i in range(W):
    CO[H-k-2][i]=DO[H-k-2][i]
   E+=1
  else:
   for i in range(W):
    CO[H-k-2][i]=DO[H-k-2][i]+CO[H-k-1][i]
 lst=[0]*H
 for h in range(W):
  c=max(CO[x][h] for x in range(H))
  d=max(lst[y]+CO[y][h] for y in range(H))
  if c>K:
   E=1000000
   break
  elif d>K:
   D+=1
   lst=[0]*H
  for z in range(H):
   lst[z]+=CO[z][h]
 F=min(F,D+E)
print(F)

Measured memory_bytes: 52700
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) { cin >> A[i]; }

    ll money = 1000;
    rep(i, N - 1) {
        if (A[i] < A[i + 1]) {
            ll stock = money / A[i];
            ll mod = money % A[i];
            money = stock * A[i + 1] + mod;
        }
    }

    cout << money << endl;
}

Measured memory_bytes: 3632
N = int(input())
import math
def prime(n):
  sq = math.ceil(n**(1/2))
  for i in range(sq,1,-1):
    if n%i==0:
      return i,False
    
  return 1,True

A,B = prime(N)
if B:
  print(N-1)
  
else:
  print((N//A+A-2))

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,x,y;
vi red[252521];
vi blue[252521];
bool win[252521];
int reddepth[252521];
int bluedepth[252521];
int blueparent[252521];
// sigma is red in x
// sugim is blue in y
// sugim chases sigma
// sigma first

int bluelength(int a,int b){
  if(a==b)return 0;
  if(bluedepth[a]>bluedepth[b])swap(a,b);
  int dd = bluedepth[b]-bluedepth[a];
  if(dd>=3){
    return 3;
  }else if(dd==2){
    if(a==blueparent[blueparent[b]]){
      return 2;
    }else{
      return 3;
    }
  }else if(dd==1){
    if(a==blueparent[b]){
      return 1;
    }else{
      return 3;
    }
  }else{
    if(blueparent[a]==blueparent[b]){
      return 2;
    }else{
      return 3;
    }
  }
}

int main(){
  scanf("%d%d%d",&n,&x,&y);
  --x;--y;
  REP(i,n-1){
    int a,b;
    scanf("%d%d",&a,&b);
    --a;--b;
    red[a].push_back(b);
    red[b].push_back(a);
  }
  REP(i,n-1){
    int a,b;
    scanf("%d%d",&a,&b);
    --a;--b;
    blue[a].push_back(b);
    blue[b].push_back(a);
  }
  // search win point
  REP(i,n)bluedepth[i] = 252521;
  bluedepth[y] = 0;
  blueparent[y] = -1;
  stack<int> S;
  S.push(y);
  while(!S.empty()){
    int p = S.top();S.pop();
    int d = bluedepth[p]+1;
    REP(i,blue[p].size()){
      int to = blue[p][i];
      if(bluedepth[to] < d)continue;
      blueparent[to] = p;
      bluedepth[to] = d;
      S.push(to);
    }
  }
  REP(i,n){
    REP(j,red[i].size()){
      int to = red[i][j];
      // avoid duplication
      if(i<to){
        if(bluelength(i,to)>=3){
          win[i] = true;
          win[to] = true;
        }
      }
    }
  }
  // flee
  REP(i,n)reddepth[i] = 252521;
  reddepth[x] = 0;
  S.push(x);
  while(!S.empty()){
    int p = S.top();S.pop();
    int d = reddepth[p]+1;
    REP(i,red[p].size()){
      int to = red[p][i];
      if(reddepth[to] < d)continue;
      if(bluedepth[to] <= d)continue;
      reddepth[to] = d;
      S.push(to);
    }
  }
  // check
  int ans = -1;
  REP(i,n){
    if(reddepth[i]!=252521){
      if(win[i]){
        ans = -2;
        break;
      }else{
        CHMAX(ans,bluedepth[i]);
      }
    }
  }
  if(ans==-2){
    puts("-1");
  }else{
    printf("%d\n",ans*2);
  }
  return 0;
}


Measured memory_bytes: 29172
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        List<String> s = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            s.add(sc.next());
        }
        Collections.sort(s);
        for (String a : s) {
            System.out.print(a);
        }
        System.out.println();
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=1<<20;

int n,q,k;
char s[N];
LL sa[N],sb[N],sc[N];

int main() {
	scanf("%d %s %d",&n,s+1,&q);
	for(int i=n;i>0;i--) {
		sa[i]=sa[i+1]+(s[i]=='M');
		sb[i]=sb[i+1]+(s[i]=='C');
		sc[i]=sc[i+1]+(s[i]=='M')*sb[i];
	}
	while(q--) {
		scanf("%d",&k);
		LL ans=0;
		for(int i=1;i<=n;i++) {
			if(s[i]!='D') continue;
			ans+=sc[i]-sc[min(n+1,i+k)];
			ans-=(sa[i]-sa[min(i+k,n+1)])*sb[min(i+k,n+1)];
			//printf("i=%d sc=%lld sa=%lld sb=%lld ans=%lld\n",i,sc[i],sa[i]-sa[i+k],sb[i+k],ans);
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 25856
#include<bits/stdc++.h>
#define ll long long int 
#define mod 998244353
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(15);
	char ch;
	cin>>ch;
	if(ch>=65&&ch<=90)
	cout<<"A";
	else
	cout<<"a";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

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

	vector<long long> a(N);
	rep(i, N) cin >> a.at(i);

	long long ans = 0;
	rep(i, N){
		while (a.at(i) % 2 == 0){
			a.at(i) /= 2;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
/***************
*
*   Eostrix......
*
****************/
#include<bits/stdc++.h>
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);
#define pf printf
#define sc scanf
#define ll long long
#define gap " "
#define endl "\n"
#define maxSize 100000000
using namespace std;
const double pi = acos(-1.0);
void FILE_IO() {
	IN;
	OUT;
}
void faster_IO() {
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
}
int main()
{
	 ///faster_IO();
	///FILE_IO();
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n&1)
        cout<<"No"<<endl;
    else{
        string a;
        string b;
        int mid = n/2;
        for(int i=0;i<mid;i++)
            a.push_back(s[i]);
        for(int i=mid;i<n;i++)
            b.push_back(s[i]);
        if(a==b)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,ans = 0;
    cin >>n;
    int arr[n];
    for(int i = 0; i <n; ++i){
        cin >> arr[i];
    }
    for(int k = 0; k < n-1; ++k){
        for(int j =k+1; j < n; ++j ){
            ans+= (arr[k])*(arr[j]);
        }
    }
    cout<<ans; 

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  happiness <- V.replicateM n $ do
    [a,b,c] <- map (read . BS.unpack) . BS.words <$> BS.getLine
    -- a,b,c <= 10^4
    return (a,b,c :: Int)
  let (a,b,c) = V.foldl1' (\(!a,!b,!c) (!a',!b',!c') -> (max b c + a', max a c + b', max a b + c')) happiness
  print (max a (max b c))


Measured memory_bytes: 3452
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int ans=0;
  rep(i,n+1){
    rep(j,n+1){
      if(n-i*r-j*g>=0 && (n-i*r-j*g)%b==0){
        ans++;
      }
    }
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int A[N]{};
    for (int i = 1; i < N; i++) {
        cin >> A[i];
    }
    int b[N]{};
    for (int i = 1; i < N; i++) {
        b[A[i] - 1]++;
    }
    for (int i : b) {
        cout << i << "\n";
    }
    return 0;
}

Measured memory_bytes: 5144
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws ParseException {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String h = "Heisei";
		String t = "TBD";
		Calendar c =Calendar.getInstance();
		SimpleDateFormat f = new SimpleDateFormat("yyyy/MM/dd");
		Date d = f.parse("2019/05/01");
		if(f.parse(s).before(d)) 
			System.out.println(h);
		else
			System.out.println(t);
	}
}

Measured memory_bytes: 25552
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/7/13 12:59:34
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int maxx=1e6;
bool isprime[maxx+20];
LL pri[maxx+20],cnt=0;
LL gcd(LL x,LL y){
	return !y?x:gcd(y,x%y);
}

void findprime(){
	memset(isprime,true,sizeof(isprime));
	for(LL i=2;i<=maxx;++i){
		if(isprime[i]){
			pri[++cnt]=i;
		}
		for(LL j=1;j<=cnt;++j){
			if(i*pri[j]>maxx) break;
			isprime[i*pri[j]]=0;
			if(i%pri[j]==0) break;
		}
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	findprime();
	LL x,y,d;
	scanf("%lld%lld",&x,&y);
	d=gcd(x,y);
//	cout<<d<<endl;
	int i=1,ans=0;  
	while(i<=cnt && d>1){
		if(d%pri[i]==0){
			++ans;
			while(d%pri[i]==0) d/=pri[i];
		}
		++i;
	}
	if(d>1) ++ans;
	printf("%d\n",ans+1);
	return 0;
}


Measured memory_bytes: 5364
import sys

def main():
    sum=0
    ans=0
    ansc=0
    D,G = map(int,input().split())

    lis=[]
    for x in range(D):
        P,C = map(int,input().split())
        lis.append([P,C])

    op_cnt = D

    for i in range(2 ** op_cnt):
        for j in range(op_cnt):
            if((i>>j) & 1 and i!=0):
                for k in range(1, lis[j][0]+1):
                    sum+=(100*(j+1))
                    ansc+=1
                    if(k==lis[j][0]):
                        sum+=lis[j][1]
                    if(sum>=G):
                        break


        if(sum<G):
            for lef in reversed(range(0, op_cnt)):
                if(~(i>>lef) & 1 and lis[lef][0] != 1):
                    for l in range(1,lis[lef][0]+1):
                        if(sum>=G):
                            break
                        sum+=(100*(lef+1))
                        ansc+=1


        if(ans>=ansc or ans==0):
            ans=ansc

        ansc=0
        sum=0

    print(ans)
main()

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int h, w, n; cin >> h >> w >> n;
  vector<set<int>> me(h + 1);
  rep(i, n) {
    int x, y; cin >> x >> y;
    me[x].insert(y);
  }
  int acc = 0;
  for (int i = 2; i <= h; i++) {
    if (me[i].size() == 0) continue;
    if (me[i].count(i - acc) > 0) {
      acc++;
    }
    auto it = me[i].upper_bound(i - acc);
    while (it != me[i].end()) {
      me[i].erase(it++);
    }
    if (me[i].size() > 0) {
      cout << i - 1 << '\n';
      return;
    }
  }
  cout << h << '\n';
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define m 1000000007
#define ll long long int
using namespace std;
int main(){
  ll a, sum = 1;
  cin >> a;
  for(ll i = 1; i < a + 1; i++){
    sum = ((sum % m) * (i % m)) % m;
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  int n, k;
  cin >> n >> k;
  if(n == 0){
    if(k == 0)
      cout << "0 0\n";
    else 
      cout << "-1\n";
  }
  else if(n == 1){
    if(k == 0)
      cout << "1 1 0 0\n";
    else
      cout << "-1\n";
  }
  else{
    if(k < (1 << n)){
      for(int i = 0; i < (1 << n); i ++ ){
        if(i != k) 
          cout << i << " ";
      }
      cout << k << " ";
      for(int i = (1 << n) - 1; i >= 0 ; i -- ){
        if(i != k)
          cout << i << " ";
      }
      cout << k << " ";
    }
    else{
      cout << -1 << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] c = s.toCharArray();
		int n = s.length();
		long ans = 0;
		for(int mask = 0 ; mask < (1<<(n - 1)) ; mask++) {
			String a = "";
			for(int i = 0 ; i < n ; i++) {
				if((mask & (1<<i)) != 0) {
					a += c[i] + "+";
				} else {
					a += c[i];
				}
			}
			a = a.replace("+", "A");
			String[] b = a.split("A");
			for(int i = 0 ; i < b.length ; i++) {
				ans += Long.valueOf(b[i]);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 27220
n, m = map(int,input().split())
p = [0 for i in range(n+1)]
a = [0 for i in range(n+1)]
for i in range(m):
    a[int(input())] = 1
for i in range(1,n+1):
    if a[i] == 1:
        p[i] = 0
    elif i == 1:
        p[i] = 1
    elif i == 2:
        p[i] = p[1] + 1
    else:
        p[i] = p[i-1] + p[i-2]
print(p[n] % (10**9 + 7))

Measured memory_bytes: 460824
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const ll B = 1e6;
const ll INF = 1e12;

ll sumofDigit(ll n , ll b){
	ll sum = 0;
	while(n){
		sum += n%b;
		n /= b;
	}
	return sum;
}

int main(){
	fio; cout<<fixed<<setprecision(25);	
	ll n , s;
	cin >> n >> s;
	if(s == n){
		cout << n+1 << endl;
		return 0;
	}
	ll ans = -1;
	for(ll b = 2;b < B ; ++b){
		if(sumofDigit(n , b) == s){
			ans = b;
			break;
		}
	}
	if(ans == -1){	
		ll act = INF;
		for(ll b = 1 ; b < B ; ++b){
			// n/d is equal to b
			ll lo = 1 , high = n , ans = high;
			while(lo <= high){
				ll mid = (lo+high)/2;
				if(n/mid >= b){
					ans = mid;
					lo = mid+1;
				}
				else{
					high = mid-1;
				}
			}
			lo =1 , high = n ;
			ll ans1 = 1;
			while(lo <= high){
				ll mid = (lo+high)/2;
				if(n/mid <= b){
					ans1 = mid;
					high = mid-1;
				}
				else{
					lo = mid+1;
				}
			}
			if(n/ans != b || n/ans1 != b) continue;
			ll wnt = s-b;
			// trace(b , ans , ans1);
			// trace(wnt);
			if(wnt >= n%ans && wnt <= n%ans1 && ((n-wnt)%b == 0)){
				// trace(b , ans , ans1);
				// trace(b , ans , ans1);
				// assert(sumofDigit(n , (n-wnt)/b) == s);
				act = min(act , (n-wnt)/b);
			}
		}	
		if(act != INF){
			cout << act << endl;
		}
		else{
			cout << -1 << endl;
		}
	}
	else{
		cout << ans << endl;
	}







	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

   lli A,B,C,K;
   cin >> A >> B>> C >> K;
   cout << 1*(A>=K?K:A)+(-1)*(A+B<=K?K-A-B:0) << endl;

}

Measured memory_bytes: 3632
/******Old_school_@23******/
/******Why_would_a_compiler_lie?******/
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma") 
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back 
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}
lld solve(lld a[],lld n) 
{ 
    lld sumr = 0; 
    iot(n)
        sumr=(sumr%MOD+a[i]%MOD)%MOD; 
    lld s2=(sumr%MOD *sumr%MOD)%MOD; 

    lld s3= 0; 
    iot(n)
        s3=(s3%MOD+(a[i]%MOD*a[i]%MOD)%MOD)%MOD; 
    return ((s2-s3+MOD)%MOD*500000004)%MOD; 
} 
int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld n; cin>>n;
      pls(n,a);
      cout<<solve(a,n)%MOD;
}


Measured memory_bytes: 5220