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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

int n;
ll d;

int main() { FAST
    cin >> n >> d;
    int cnt = 0;
    M00(i, n) {
        ll x, y; cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }
    finish(cnt);
}



Measured memory_bytes: 3652
from collections import deque
W, H = map(int, input().split())
pandq = []
for i in range(W):
	pandq.append([int(input()),"p"])
for i in range(H):
	pandq.append([int(input()),"q"])
sortedCost = deque(sorted(pandq))

a = W + 1
b = H + 1
totalcosts = 0
while sortedCost:
	cost = sortedCost.popleft()
	if cost[1] == "p":
		totalcosts += cost[0] * b
		a -= 1
	else:
		totalcosts += cost[0] * a
		b -= 1
print(totalcosts)


Measured memory_bytes: 33472
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
//        int int1 = Integer.parseInt(scan.next());
//        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        int int4 = Integer.parseInt(scan.next());
        double db = Double.parseDouble(scan.next());
        int ans_int = 0;
        String ans = "";
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();

        double ans_dob = 0;
        if(db % 2 == 0){
            ans_dob= (db/2)/db;
        }else{
            ans_dob = (db/2+0.5)/db;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_dob);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 25300
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	int L;
	cin >> N;
	cin >> L;

	int sum = 0;
	for (int i = 1; i <= N; i++) {
		sum += L + i - 1;
	}

	int val = sum - L;
	int d = abs(sum - val);
	int dmin = d;
	int ans = val;
	for (int i = 1; i <= N; i++) {
		val = sum - (L + i - 1);
		d = abs(val - sum);
		if (d < dmin) {
			ans = val;
			dmin = d;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n, k=map(int, input().split())
m=(n-1)*(n-2)//2
c=0
if k>m:
    print(-1)
else:
    e=n-1+m-k
    print(e)
    for i in range(n):
        for j in range(i+1,n):
            c+=1
            print(i+1,j+1)
            if c>=e:
                break
        if c>=e:
                break

Measured memory_bytes: 42736
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
//dp   dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j]
const int maxn=1e2+10; 
int n;
int a[maxn][maxn];
int dp[maxn][maxn];

int max(int a,int b)
{
	return a>b?a:b;
 } 

void solve()
{
	dp[1][1]=a[1][1];
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i==1)
				dp[i][j]=dp[i][j-1]+a[i][j];
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j]; 
		}
	}
} 
int main()
{
	while(~scanf("%d",&n))
	{
	
	memset(a,0,sizeof(a));
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	solve();
//	for(int i=1;i<=2;i++)
//	{
//		for(int j=1;j<=n;j++)
//			printf("%d ",dp[i][j]);
//		printf("\n");
//	}
	printf("%d\n",dp[2][n]);
}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <fstream>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {

	static const double pi = 3.141592653589793;
	long double a, b, h, m;
	cin >> a >> b >> h >> m;

	long double aa, bb;
		aa = a * a;
		bb = b * b;

	double x1, x2, y1, y2;
	double X, Y;
	long double kakudo, kakudo1,naiseki;
	long double ans, ansans;

	kakudo = ((h * 360 / 12)+(30*(m/60)))*(pi/180);
	kakudo1 = (m * 360 / 60)*(pi / 180);

	//cout << (h * 360 / 12)- (m * 360 / 60)<<endl;
	if (kakudo == 0) {
		kakudo = 2 * pi;
	}

	if (kakudo1 == 0) {
		kakudo1 = 2 * pi;
	}
	
	if (kakudo > kakudo1) {
		naiseki = kakudo - kakudo1;
	}
	else {
		naiseki = kakudo1 - kakudo;
	}
	
	ansans = aa + bb - 2 *a*b*cos(naiseki);
	//cout << ansans << endl;
	ans = sqrt(ansans);
	
	/*cout << kakudo1<<endl;
	x1 = a * std::sin(kakudo);
	y1 = a * std::cos(kakudo);

	x2 = -b * std::sin(kakudo1);
	y2 = b * std::cos(kakudo1);

	if (kakudo1 > pi) {
		x2 = -x2;
	}

	cout << x1 << " " << y1 << endl;
	cout << x2 << " " << y2 << endl;

	X = (x2 - x1)*(x2 - x1);
	Y = (y2 - y1)*(y2 - y1);
	ans = sqrt(X + Y);
*/
	cout << fixed << setprecision(15)<< ans;
	
	return 0;
}


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

int main() {
  int N,A,B,C,D;
  scanf("%d %d %d %d %d", &N,&A,&B,&C,&D);
  string input;
  cin >> input;
  --A;
  --B;
  --C;
  --D;

  char a[N];
  for(int i=0;i<N;++i){
    a[i] = (char)input[i];
  }

  if(A<B && C<D){
    bool flug = true;
    for(int i=A;i<C;++i){
      if(a[i]=='#' && a[i+1]=='#') flug = false;
    }
    for(int i=B;i<D;++i){
      if(a[i]=='#' && a[i+1]=='#') flug = false;
    }
    if(flug) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if(A<B && C>D){
    bool flug = false;
    for(int i=B-1;i<D;++i){
      if(a[i]=='.' && a[i+1]=='.' && a[i+2]=='.') flug = true;
    }
    for(int i=A;i<C;++i){
      if(a[i]=='#' && a[i+1]=='#') flug = false;
    }
    for(int i=B;i<D;++i){
      if(a[i]=='#' && a[i+1]=='#') flug = false;
    }
    if(flug) cout << "Yes" << endl;
    else cout << "No" << endl;
  }





}



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

#define int long long
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;

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

	int n;
	cin>>n;
	int arr[n];
	int lol[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	bool ans=true;
	for(int i=n-1;i>0;i--)
	{
		if(arr[i]<arr[i-1]-1)
		{
			ans=false;
			break;
		}
		else if(arr[i-1]-arr[i]==1)
		{
			arr[i-1]--;
		}
	}
	if(ans)
		cout<<"Yes";
	else
		cout<<"No";


    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
char s[10];
int main(){
    scanf("%s", s);
    for (int i = 0; i < strlen(s) - 1; ++i){
        if (s[i] == 'A' && s[i+1] == 'C'){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}

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

public class Main {

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

  private void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int heapSize = Integer.parseInt(br.readLine());
      String[] keys = br.readLine().split(" ");
      int[] mHeap = new int[heapSize+1];
      mHeap[0] = heapSize;
      for(int i=1; i<=heapSize; i++)
        mHeap[i] = Integer.parseInt( keys[i-1] );

      buildMaxHeap(mHeap);

      StringBuilder buf = new StringBuilder();
      for(int i=1; i<mHeap.length; i++) 
        buf.append(" ").append(mHeap[i]);

      System.out.println(buf);
    } catch(IOException e) {
      System.out.println("IOException!");
    }
  }
  private void buildMaxHeap(int[] heap) {
    for(int i= heap[0]/2; i>0; i--)
      maxHeapify(heap, i);
  }
  private void maxHeapify(int[] heap, int node) {
    int t,left,right,largest;
    left  = node*2;
    right = left+1;

    if( (left <= heap[0]) && (heap[left] > heap[node]) )
      largest = left;
    else
      largest = node;
    if( (right <= heap[0]) && (heap[right] > heap[largest]) )
      largest = right;

    if( largest != node ) {
      t = heap[node]; heap[node] = heap[largest]; heap[largest] = t;

      maxHeapify(heap, largest);
    }
  }
}


Measured memory_bytes: 75124
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();
		int m = sc.nextInt();
		int s = sc.nextInt()-1;
		int t = sc.nextInt()-1;
		
		List<E> map[] = new List[n];
		for(int i = 0; i < n ;i++){
			map[i] = new LinkedList<E>();
		}
		
		for(int i = 0; i < m ;i++){
			E e = new E();
			e.from = sc.nextInt()-1;
			e.to = sc.nextInt()-1;
			e.a = sc.nextInt();
			e.b = sc.nextInt();
			
			map[e.from].add(e);
			map[e.to].add(e);
		}
		
		
		long[] minE = new long[n];
		Arrays.fill(minE, Long.MAX_VALUE);
		{
			PriorityQueue<N> pq = new PriorityQueue<N>((x,y)-> Long.compare(x.cost, y.cost) );
			N init = new N();
			init.pos = s;
			init.cost  =0;
			pq.add(init);
			boolean visited[] = new boolean[n];
			for(;!pq.isEmpty();){
				N now = pq.poll();
				
				if(visited[now.pos]){
					continue;
				}
				visited[now.pos] = true;
				minE[now.pos] = now.cost;
				
				for(E e: map[now.pos]){
					
					int npos = e.from ^ e.to ^ now.pos;
					long ncos = now.cost + e.a;

					if(ncos < minE[npos]){
						minE[npos] = ncos;
						N next = new N();
						next.pos = npos;
						next.cost = ncos;
						pq.add(next);
					}
				}				
			}
		}
		long[] minS = new long[n];
		Arrays.fill(minS, Long.MAX_VALUE);
		{
			PriorityQueue<N> pq = new PriorityQueue<N>((x,y)-> Long.compare(x.cost, y.cost) );
			N init = new N();
			init.pos = t;
			init.cost  =0;
			pq.add(init);
			boolean visited[] = new boolean[n];
			for(;!pq.isEmpty();){
				N now = pq.poll();
				
				if(visited[now.pos]){
					continue;
				}
				visited[now.pos] = true;
				minS[now.pos] = now.cost;
				
				for(E e: map[now.pos]){
					
					int npos = e.from ^ e.to ^ now.pos;
					long ncos = now.cost + e.b;

					if(ncos < minS[npos]){
						minS[npos] = ncos;
						N next = new N();
						next.pos = npos;
						next.cost = ncos;
						pq.add(next);
					}
				}				
			}
		}
		
		long[] ansrev = new long[n];
		ansrev[0] = minE[n-1]+minS[n-1];
		for(int i = 1; i < n ;i++){
			ansrev[i] = Math.min(ansrev[i-1], minE[n-1-i]+minS[n-1-i]);
		}
		
		for(int i = n-1; i >=0; i --){
			System.out.println(1000000000000000L-ansrev[i]);
		}
		
	}
	
	class E{
		int from;
		int to;
		int a;
		int b;
	}
	
	class N{
		int pos;
		long cost;
	}
}


Measured memory_bytes: 154680
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(B,A*N) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;
// const int mo = 1e9 + 7;

int n;

vector<int> co;
vector<vector<pair<int, int> > > g;

void dfs(int u, int c) {
	co[u] = c;
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i].first;
		if (co[v] == -1) {
			if (g[u][i].second == 0)
				dfs(v, c);
			else
				dfs(v, 1-c);
		}
	}
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;

	g = vector<vector<pair<int, int> > >(n);

	for (int i = 0; i < n-1; ++i)
	{
		int u, v, w;
		cin >> u >> v >> w;
		--u;
		--v;

		w = w & 1;

		g[u].push_back(make_pair(v, w));
		g[v].push_back(make_pair(u, w));
	}
	
	int st = 0;
	co = vector<int>(n, -1);
	for (int i = 0; i < n; ++i)
		if (g[i].size() == 1) {
			st = i;
			break;
		}
	
	dfs(st, 0);

	for (int i = 0; i < n; ++i)
		cout << co[i] << endl;

	return 0;
}

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

typedef long long ll;
ll t,n,i,j,a,b;
string s1;
int main() {
   cin>>n;
   ll a[n];
   for(i=0;i<n;i++)
   cin>>a[i];
   ll s=0;
   for(i=0;i<n-1;i++)
   {
       if(a[i]>a[i+1])
       {
           s+=a[i]-a[i+1];
           a[i+1]=a[i];
       }
   }
	cout<<s;
	return 0;
}


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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll A=ii();
    ll B=ii();
    ll C=ii();
    ll K=ii();
    REP(i,0,K){
        if(B<=A){
            B*=2;
        }else{
            C*=2;
        }
        if(C>B&&B>A){
            ose("Yes");
            return 0;
        } 
    }
    ose("No");
    return 0;
}

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

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

	if(a+b>=2)printf("Open\n");
	else {
		if(c==1)printf("Open\n");
		else printf("Close\n");
	}
}

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

#define int long long

using namespace std;

const int MAXN = 1e6 + 100;

const int MOD = 1e9 + 7;

int dp[MAXN][4];

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N;
    cin >> N;

    dp[0][0] = 1;

    for(int i = 1 ; i <= N ; i++)
    {
    	dp[i][0] = dp[i-1][0]*8;
    	dp[i][1] = dp[i-1][1]*9 + dp[i-1][0];
    	dp[i][2] = dp[i-1][2]*9 + dp[i-1][0];
    	dp[i][3] = dp[i-1][3]*10 + dp[i-1][1] + dp[i-1][2];

    	dp[i][0] %= MOD;
    	dp[i][1] %= MOD;
    	dp[i][2] %= MOD;
    	dp[i][3] %= MOD;
    }

    cout << dp[N][3] << '\n';

    return 0;
}

Measured memory_bytes: 34828
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int A[3];
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>A[0]>>A[1]>>A[2];
    int K;
    cin>>K;sort(A,A+3,greater<int>());

    for(int i=0;i<K;i++){
        A[0]*=2;
    }
    cout<<A[0]+A[1]+A[2]<<"\n";
    
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter 
def main():
    N = int(readline())
    tasks = []
    for _ in range(N):
        a, b = map(int, readline().split())
        tasks.append((a, b))
    tasks.sort(key=itemgetter(1))
    time = 0
    for a, b in tasks:
        time += a
        if time > b:
            print('No')
            return  
    print('Yes')
if __name__ == '__main__':
    main()


Measured memory_bytes: 61904
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
    return 0;
}


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

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

using namespace std;
using lint = unsigned long long;

/*
bool checkAnagram(string str1, string str2)
{
    int alp1[26] = {0};
    int alp2[26] = {0};
    for(int i = 0; i < str1.size(); i++){
        alp1[str1[i]-'a']++;
        alp2[str2[i]-'a']++;
    }
    bool flag = true;
    for(int i = 0; i < 26; i++){
        if(alp)
    }
}
*/

lint comb(lint n, lint r)
{
    lint num = 1;
    if(n < r) return 0;
    for(lint i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
    
}
int main(void)
{
    int N;
    cin >> N;
    vector<vector<char> > vch(N, vector<char>(10));
    rep(i, N) rep(j, 10) cin >> vch[i][j];
    vector<string> vstr(N);
    rep(i, N){
        sort(vch[i].begin(), vch[i].end());
        string str(vch[i].begin(), vch[i].end());
        vstr[i] = str;
    }
    sort(vstr.begin(), vstr.end());
    lint ans = 0;
    lint cnt = 0;
    vstr.push_back("");
    for(int i = 0; i < N; i++){
        cnt++;
        if(vstr[i+1] != vstr[i]){
            ans += comb(cnt, 2);
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;
    string S[2];
    rep(i,2) cin>>S[i];
    int ans=1;
    rep(i,N){
        if(i==0){
            if(S[0][i]==S[1][i]) ans*=3;
            else{
                ans*=6;
                i++;
            }
        }else{
            if(S[0][i]==S[1][i]) {
                if(S[0][i-1]==S[1][i-1]){
                    ans*=2;
                }else ans*=1;
            }else{
                if(S[0][i-1]==S[1][i-1]){
                    ans*=2;
                }else ans*=3;
                i++;
            }
        }
        ans%=MOD;
    }


    cout << ans << endl;




}


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


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}

int main(void) {

int input[120];
inp_str(input);

int A,B,C,D,E;
A=input[0];
B=input[1];

//printf("%d\n",A);
//printf("%d\n",B);

D=0;
E=0;

if(A>B){
	E=B;
	D=A;
	C=A-1;
}else{
	E=A;
	D=B;
	C=B-1;
}

if(C>E){
	D=D+C;
}else{
	D=D+E;
}



printf("%d\n",D);



/*

if(flag==1) {
	printf(":(\n");
}else{
printf("Yay!\n");
} 

*/                       
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
 
 
 
 
typedef long long ll;
int N, A[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    vector<int> v;
    map<int, int> cnt;
    rep(i, 0, N) {
        cnt[A[i]]++;
        if (cnt[A[i]] == 2) cnt[A[i]] = 0, v.push_back(A[i]);
    }
    sort(v.begin(), v.end(), greater<int>());

    ll ans = 0;
    if (2 <= v.size()) ans = max(ans, 1LL * v[0] * v[1]);
    printf("%lld\n", ans);
}

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

int main(){
  int h,w;
  const int INF = 100000000;
  cin >> h >> w;
  queue<pair<int,int>> que;
  vector<vector<int>> d(h+2,vector<int>(w+2,INF));
  string pad(w+2,'#');
  vector<string> field;
  field.push_back(pad);
  string tmp;
  for(int i=0; i<h; i++){
    cin >> tmp;
    for(int j=0; j<w; j++){
      if(tmp.at(j)=='#'){
        que.push(make_pair(i+1,j+1));
        d[i+1][j+1] = 0;
      }
    }
    field.push_back("#" + tmp + "#");
  }
  field.push_back(pad);
  vector<int> ofst = {0,0,1,-1};
  int ans=0;
  while(que.size()){
    pair<int,int> p = que.front(); que.pop();
    for(int i=0; i<4; i++){
      int ny=p.first+ofst.at(i),nx=p.second+ofst.at(3-i);
      if(field[ny].at(nx)=='.'&&d[ny][nx]==INF){
        que.push(make_pair(ny,nx));
        ans = d[ny][nx] = d[p.first][p.second]+1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 14864
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==7&&b==5&&c==5){
        printf("YES");
        }
    else if (a==5&&b==7&&c==5)
    {
         printf("YES");
    }
    else if(a==5&&b==5&&c==7){
     printf("YES");
    }
    else  printf("NO");
    
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	int n, m;
	cin >> n >> m;

	VVI board( n + 2 );

	REP( i, 0, board.size() )
	{
		board[i].resize( i + 2, 0 );
	}

	REP( i, 0, m )
	{
		int a, b, x;
		cin >> a >> b >> x;

		a--;
		b--;

		board[a][b] ++;
		board[a][ b + 1 ] --;

		board[ a + x + 1 ][b] --;
		board[ a + x + 1 ][ b + x + 2 ] ++;

		board[ a + x + 2 ][ b + 1 ] ++;
		board[ a + x + 2 ][ b + x + 2 ] --;
	}

	REP( i, 0, board.size() )
	{
		REP( j, 1, board[i].size() )
		{
			board[i][j] += board[i][ j - 1 ];
		}
	}

	REP( i, 1, board.size() )
	{
		REP( j, 0, board[ i - 1 ].size() )
		{
			board[i][j] += board[ i - 1 ][j];
		}
	}	

	REP( i, 1, board.size() )
	{
		REP( j, 1, board[i].size() )
		{
			board[i][j] += board[ i - 1 ][ j - 1 ];
		}
	}

	int res = 0;

	REP( i, 0, board.size() - 2 )
	{
		REP( j, 0, board[i].size() - 1 )
		{
			res += 1 <= board[i][j];
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 50112
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll N;
constexpr ll maxN = 2e5;
vector<pair<ll, ll>> AB;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif
  cout << setprecision(20);

  cin >> N;
  for (ll i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    AB.push_back(make_pair(b, a));
  }
  for (ll i = 0; i < N; i++) {
    DLOG("AB[%lld] = (%lld, %lld)", i, AB[i].first, AB[i].second);
  }
  sort(AB.begin(), AB.end());
  for (ll i = 0; i < N; i++) {
    DLOG("AB[%lld] = (%lld, %lld)", i, AB[i].first, AB[i].second);
  }
  ll t = 0;
  for (ll i = 0; i < N; i++) {
    t += AB[i].second;
    DLOG("t = %lld", t);
    if (t > AB[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}



Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int x,i,t,y,z,c=0,k;
 int p;
 cin>>p>>k;
 while(p)
 {

     c++;
     p=p/k;
     if(p<=0)
     {
         break;
     }
 }
 cout<<c;

return 0;
}


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

using namespace std;

const int N = 2e5 + 4;
vector<int> g[N];
int n, u, v;
int a[N], ans[N];
map<int,int> mp;
set<int> st;
vector<int> removed(N, -1);
vector<int> run;

void dfs(int x, int p = 0) {
  assert(a[x]);
  int id = -1, val = -1;
  if (run.empty()) {
    run.push_back(a[x]);
  }
  else if (a[x] > run.back()) {
    run.push_back(a[x]);
  }
  else {
    auto it = lower_bound(run.begin(), run.end(), a[x]) - run.begin();
    if (it == run.size()) --it;
    assert(it >= 0 && it < run.size());
    assert(a[x] > 0);
    val = run[it], id = it;
    // assert()
    run[it] = a[x];
  }
  ans[x] = run.size();
  // cout << "Going inside  " << x << '\n';
  // for (int x: run) {
  //   cout << x << ' ';
  // }
  // cout << '\n';
  for (auto it: g[x]) {
    if (it != p) {
      dfs(it, x);
    }
  }
  if (id != -1) {
    run[id] = val;
  }  
  else run.pop_back();
  // cout << "Going out of " << x << '\n';
  // for (int x: run) {
  //   cout << x << ' ';
  // }
  // cout << '\n';
}

signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 27928
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

using Graph = vector<vector<int>>;

void dfs(const Graph &g, vector<int> &cmp, int v, int c) {
  if (cmp[v] != -1) return;
  cmp[v] = c;
  for (int i: g[v]) dfs(g, cmp, i, c);
}

void solve() {
  int N, K, L;
  cin >> N >> K >> L;
  Graph g(N), h(N);
  REP(i,K) {
    int s, t;
    cin >> s >> t;
    g[s-1].push_back(t-1);
    g[t-1].push_back(s-1);
  }
  REP(i,L) {
    int s, t;
    cin >> s >> t;
    h[s-1].push_back(t-1);
    h[t-1].push_back(s-1);
  }
  vector<int> cmp1(N, -1), cmp2(N, -1);
  REP(i,N) dfs(g, cmp1, i, i);
  REP(i,N) dfs(h, cmp2, i, i);
  map<pair<int,int>,int> m;
  REP(i,N) ++m[make_pair(cmp1[i], cmp2[i])];
  REP(i,N) {
    cout << m[make_pair(cmp1[i], cmp2[i])] << " \n"[i == N-1];
  }
  return;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;
    cin >> s;

    bool flag = false;
    for (char c : s) {
        if (c == '7') {
            flag = true;
            break;
        }
    }
    cout << (flag ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3652
N, W = map(int, input().split())
I = [tuple(map(int, input().split())) for _ in range(N)]
w0 = I[0][0]

dp = [[[0 for k in range(N * 3 + 1)] for j in range(N + 1)] for i in range(N + 1)]

for i in range(N):
    w, v = I[i]
    for j in range(N):
        for k in range(3 * N + 1):
            if k - (w - w0) >= 0:
                dp[i + 1][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k - (w - w0)] + v)
            else:
                dp[i + 1][j + 1][k] = dp[i][j + 1][k]

res = 0

for i in range(N + 1):
    for j in range(N + 1):
        for k in range(3 * N + 1):
            if w0 * j + k <= W:
                res = max(res, dp[i][j][k])

print(res)

Measured memory_bytes: 117296
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;
int a, b, c;
int ans;

int main() {
	cin >> a >> b;
	ans = 6;
	ans -= a;
	ans -= b;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    VI a(n); REP(i,n) cin >> a[i];
    out(MAX(a)-MIN(a));

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,ans=0;
  cin>>a>>b;
  for(int i=0;i<2;i++)
  {
    if(a>=b)
    {
      ans+=a;
      a--;
    }
    else if(b>a)
    {
      ans+=b;
      b--;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define for(i,a,b) for(ll i=a;i<b;i++)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl a(n);
  for(i,0,n){
    cin >> a[i];
  }
  vvl dp(n,vl(3));
  for(i,0,n){
    for(j,0,3){
      dp[i][j]=-INF;
    }
  }
  dp[0][0]=a[0];
  dp[1][1]=a[1];
  if(n>=3){
  dp[2][2]=a[2];
    if(n>=4){
  dp[3][1]=max(dp[0][0],dp[1][1])+a[3];
    }
  dp[2][0]=a[0]+a[2];
    }
  if(n>4){
  	for(i,4,n){
   	 if(i%2==0){
      dp[i][0]=dp[i-2][0]+a[i];
      }
 	   dp[i][1]=max(dp[i-2][1]+a[i],a[i]+dp[i-3][0]);
 	   dp[i][2]=max(dp[i-2][2]+a[i],max(dp[i-3][1],dp[i-4][0])+a[i]);
 	 }
  }
  if(n%2==0)
    cout << max(dp[n-2][0],dp[n-1][1]) << endl;
  else
    cout << max(max(dp[n-1][2],dp[n-2][1]),dp[n-3][0]) << endl;
}


Measured memory_bytes: 15648
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xy = Array(n){ 0.0 to 0.0 }
    repeat(n) {
        val (x, y) = readLine()!!.split(' ').map { it.toDouble() }
        xy[it] = x to y
    }

    val arr = Array(n){0}

    fun dist (a: Pair<Double,Double>, b: Pair<Double,Double>): Double =
        Math.sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second))

    var calced = 0
    fun calc (arr: Array<Int>): Double {
        calced++
        var sum = 0.0
        for (i in 0..n-2) {
            sum+= dist(xy[arr[i]], xy[arr[i+1]])
        }
        return sum
    }

    var sum = 0.0
    fun make(l: List<Int>, d:Int) {
        for (e in l) {
            arr[d] = e
            if (d == n-1) {
                sum += calc(arr)
            } else {
                make(l - e, d+1)
            }
        }
    }
    make((0 until n).toList(),0)
    println(sum/calced)
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
constexpr int mod = 1e9 + 7;

// clang-format off
struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
  mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
  mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { mint res(*this); return res += a; }
  mint operator-(const mint a) const { mint res(*this); return res -= a; }
  mint operator*(const mint a) const { mint res(*this); return res *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a; if (t & 1) a *= *this;
    return a; }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { mint res(*this); return res /= a; }
  friend ostream &operator<<(ostream &os, const mint &a) { os << a.x; return os; }
  friend istream &operator>>(istream &is, mint &a) { is >> a.x; return is; }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; }
};
// clang-format on

int main() {
  int a, b;
  cin >> a >> b;
  string s, t;
  for (int i = 0; i < b; ++i) s += to_string(a);
  for (int i = 0; i < a; ++i) t += to_string(b);
  if (s < t)
    cout << s << endl;
  else
    cout << t << endl;
  return 0;
}


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

typedef long long ll;
using namespace std;

int main()
{
    int n, m, q;
    int x, y, ans, l, r;
    int sum[505][505];

    cin >> n >> m >> q;

    for(int i=0; i<m; i++){
        cin >> x >> y;
        sum[x][y]++;
    }

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            sum[i][j] += sum[i][j-1];
        }
    }

    for(int i=0; i<q; i++){
        cin >> l >> r;
        ans = 0;
        for(int j=l; j<=r; j++){
            ans+=sum[j][r]-sum[j][j-1];
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
/* S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
__gcd()　lower_bound(a+l,a+r,x)-a でindex
配列  -> min/max({}) 
vector-> *min_element(a.begin()+l,a.begin()+r)  *忘れず lとrで[l,r) 
reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
clock()/CLOCKS_PER_SEC で秒数 int ti=clock() ok
vector v.push_back(x),v.pop_back()
q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
<deque>(push/pop)_(front/back)/fornt/back/insert/
priority_queue 宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに*/
using namespace std;
#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 range(i, s, n) for (int i = (s); i < (n); i++)
#define lange(i, s, n) for (long long i = (s); i < long long (n); i++)
#define rrep(i,n) for(int (i)=(n)-1;(i)!=-1;(i)--)
#define vep(i,v) for(auto (i)=v.begin();(i)<(v.end());(i)++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline T GCD(T a, T b) { return b?GCD(b,a%b):a;}
template<class T> inline T LCM(T a, T b) { return a/GCD(a,b)*b;}
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
template<class T> inline T modinv(T a, T M) { return (1-M*modinv(M%a,a))/a+M;}
typedef pair<long long,long long> P;
typedef pair<int,int> PI;
typedef std::vector<int> vi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<std::vector<long long>> vvl;
typedef std::vector<char> vc;
typedef std::vector<std::vector<char>> vvc;
typedef std::vector<long long> vl;
typedef std::vector<bool> vb;
typedef std::vector<std::vector<bool>> vvb;
using Graph = std::vector<std::vector<int> >;
const long long inf = 10e17;
const long long mod = 1000000007;
//int |x|<=2*10**9     long |x|<= 9*10**18
//printf(".(小数点以下の桁数)lf(double時、float ならf)")
#define ll long long
#define print(i) std::cout << (i) << '\n'
int f(string &s) {
    int n = s.size(),ret=0;
    vector<int> res(n);
    for(int i = 1, j = 0; i < s.size(); i++) {
        if(i + res[i - j] < j + res[j]) {
            res[i] = res[i - j];
        } else {
            int k = max(0, j + res[j] - i);
            while(i + k < n and s[k] == s[i + k]) ++k;
            res[i] = k, j = i;
        }
        if(res[i]<=i)ret=max(ret,res[i]);
    }
    return ret;
}
int main(){
int n,ans=0;string s;cin>>n>>s;
string now="";
rep(i,n){
    now=s[n-1-i]+now;
    ans=max(ans,f(now));
}
print(ans);
}



Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<ll, ll>;
const int mod = 1000000007;

int main(){
  int n, d, a;
  cin >> n >> d >> a;
  vector<P> V;
  rep(i, n){
    ll x, h;
    cin >> x >> h;
    V.push_back(P(x, h));
  }
  sort(V.begin(), V.end());
  ll damage=0;
  ll ans=0;
  multiset<int> M;
  vector<ll> mdamage(n+1);
  rep(i, n){
    if(M.find(i)!=M.end()){
      damage-=mdamage[i];
    }
    ll ix=V[i].first;
    ll ih=V[i].second;
    if(ih<=damage)continue;
    ans+=(ih-damage-1)/a+1;
    ll tmp=((ih-damage-1)/a+1)*a;
    damage+=tmp;
    int it=(int)(upper_bound(V.begin(), V.end(), P(ix+2*d, INF))-V.begin());
    M.insert(it);
    mdamage[it]+=tmp;
  }
  cout << ans << endl;
  return 0;
}


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

ll dp[2][5][105];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  string s;cin>>s;int k;cin>>k;

  dp[0][0][0]=1;
  for(int i=1;i<=s.size();i++){
    char c = s[i-1];
    int t = s[i-1]-'0';
    if(i>=2)dp[1][0][i-1]=1;
    if(t==0){
      for(int j=0;j<=k;j++){
        dp[0][j][i]+=dp[0][j][i-1];
        dp[1][j][i]+=dp[1][j][i-1];
        dp[1][j+1][i]+=dp[1][j][i-1] * 9;
      }
    } else {
      for(int j=0;j<=k;j++){
        dp[1][j][i]+=dp[0][j][i-1];
        dp[1][j][i]+=dp[1][j][i-1];
        dp[0][j+1][i]+=dp[0][j][i-1];
        dp[1][j+1][i]+=dp[0][j][i-1] * (t-1);
        dp[1][j+1][i]+=dp[1][j][i-1] * 9;
      }
    }
  }

  cout<<dp[0][k][s.size()]+dp[1][k][s.size()]<<endl;
  
  return 0;
}


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

using namespace std;

const int MAX_SIZE = 1e5 + 10;

int cnt[MAX_SIZE] = {0};

int main()
{
	int n;
	cin >> n;
	int a;
	for(int i = 1; i <= n; i++)
	{
		cin >> a;
		cnt[a] += 1;
		cnt[a - 1] += 1;
		cnt[a + 1] += 1;
	}
	int ans = 0;
	for(int i = 0; i <= 1e5; i++)
	{
		ans = max(ans, cnt[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int power(int x,int y){
    int res=1LL;
    while(y){
        if(y&1){
            res=(res*x)%MOD;
        }
        x=(x*x)%MOD;
        y=(y>>1);
    }
}

signed main()
{
    
    speed
    int a[4][4];
    rep(i,1,3){
        rep(j,1,3){
            cin>>a[i][j];
        }
    }
    int n;cin>>n;
    vector <int> v(n+1,0);
    rep(i,1,n){
        int x;cin>>x;
        rep(j,1,3){
            rep(k,1,3){
                if(a[j][k]==x){
                    a[j][k]=-1;
                }
            }
        }
    }
    int done=0;
    if(a[1][1]==a[1][2] && a[1][2]==a[1][3] && a[1][3]==-1)done=1;
    if(a[2][1]==a[2][2] && a[2][2]==a[2][3] && a[2][3]==-1)done=1;
    if(a[3][1]==a[3][2] && a[3][2]==a[3][3] && a[3][3]==-1)done=1;
    if(a[1][1]==a[2][1] && a[2][1]==a[3][1] && a[3][1]==-1)done=1;
    if(a[1][2]==a[2][2] && a[2][2]==a[3][2] && a[3][2]==-1)done=1;
    if(a[1][3]==a[2][3] && a[2][3]==a[3][3] && a[3][3]==-1)done=1;
    if(a[1][1]==a[2][2] && a[2][2]==a[3][3] && a[3][3]==-1)done=1;
    if(a[3][1]==a[2][2] && a[2][2]==a[3][1] && a[3][1]==-1)done=1;
    if(done){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

  



    

    
    
    
    return 0;
}

Measured memory_bytes: 256
s = input()

def bit():
    if len(s) == 1:
        print(s)
    else:
        total = 0
        for i in range((2 ** (len(s) - 1))):
            bit = format(i, '0{}b'.format(len(s) - 1))
            e = ''
            for j in range(len(s) - 1):
                e += s[j]
                if bit[j] == '1':
                    e += '+'
            e += s[-1]
            total += eval(e)
        print(total)

def recursive():
    def _recurs(s):
        if len(s) == 1:
            return [s]
        with_plus = []
        without_plus = []
        for i in _recurs(s[1:]):
            with_plus.append('{}+{}'.format(s[0], i))
            without_plus.append('{}{}'.format(s[0], i))
        return with_plus + without_plus
    ans = _recurs(s)
    print(sum(eval(a) for a in ans))

answer = recursive
answer()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
  int i, max = 0;

  int n; cin >> n;
  vector<string> s(n);
  for(i = 0; i < n; i++){
    cin >> s.at(i);
  }
  int m; cin >> m;
  vector<string> t(m);
  for(i = 0; i < m; i++){
    cin >> t.at(i);
  }

  for(i = 0; i < n; i++){
    if((count(s.begin(), s.end(), s.at(i)) - count(t.begin(), t.end(), s.at(i))) > max) max  = (count(s.begin(), s.end(), s.at(i)) - count(t.begin(), t.end(), s.at(i)));
  }

  cout << max << endl;

  return 0;
}


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

int main() {
  int N;
  cin>>N;
  int ans = 0;
  vector<int> num(N);
  for(int i=0;i<N;i++) cin>>num.at(i);
  bool odd = false;
  while(true) {
    for(int i=0;i<N;i++) {
      if(num.at(i)%2==1) odd=true;
    }
    if(odd) break;
    for(int i=0;i<N;i++) {
      num.at(i) /= 2;
    }
    ans++;
  }
   cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)

for i in range(n-1):
  if a[i+1]-a[i]==1:
    ans+=c[a[i]-1]
print(ans)

Measured memory_bytes: 38384