akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		int ans = 0;
		boolean flag = true;

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
			if (a[i] % 2 != 0) {
				flag = false;
				break;
			}
		}
		
		while(flag) {
			for (int i = 0; i < n; i++) {
				if (a[i] % 2 == 0) {
					a[i] /= 2;
				} else {
					flag = false;
					break;
				}
			}
			if (flag) ans++;
		}
		
		System.out.println(ans);
		sc.close();
	}
}

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

void solve(void)
{
  //CODE
  ll c=0;
  string s,t;
  cin>>s>>t;
  for(ll i=0;i<s.length();i++)
  {
  	if(s[i]!=t[i])
  	{
  		s[i]=t[i];
  		c++;
  	}
  }
  cout<<c;
}


int main()
{

  //TESTCASE
  long long t;
  //cin>>t;
  //while(t--)
    solve();

  return 0;
}


Measured memory_bytes: 3904
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String str_raw1[] = br.readLine().split(" ");
        String str_raw2[] = br.readLine().split(" ");
        int[] raw1 = new int[n+1];
        int[] raw2 = new int[n+1];
        raw1[0] = 0;
        raw2[0] = 0;
        for (int i = 1; i <= n; i++) {
            raw1[i] = raw1[i-1] + Integer.parseInt(str_raw1[i-1]);
            raw2[i] = raw2[i-1] + Integer.parseInt(str_raw2[i-1]);
        }
        
        int max = -1, temp = 0;
        for (int i = 1; i <= n; i++) {
            temp = raw1[i] + (raw2[n] - raw2[i-1]);
            max = Math.max(max, temp);
        }
        
        
        System.out.println(max);
    }
}


Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);
        double a, b, c, C, S, L, h;
        
        a = sc.nextDouble();
        b = sc.nextDouble();
        C = sc.nextDouble();
        
        S = 0.5 * a * b * Math.sin(Math.toRadians(C));
        c = a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(C));
        c = Math.sqrt(c);
        L = a + b + c;
        h = b * Math.sin(Math.toRadians(C));
        
        System.out.println(S);
        System.out.println(L);
        System.out.println(h);
        
    }
}


Measured memory_bytes: 27812
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    ll a,b;
    cin >> a >> b;
    if((a > 9 || a <1) || (b > 9 || b < 1)) cout << "-1";
    else cout << (a * b);

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

l = []
s = 0
for i in range(N-1):
    if A[i] > A[i+1]:
        l.append([s,i])
        s = i+1
    else:
        continue

l.append([s,N-1])

ans = 1000
for s,e in l:
    kabu = (ans//A[s])
    ans += (A[e]-A[s])*kabu
    ##print(ans,kabu)

print(ans)


Measured memory_bytes: 9148
N = int(input())
A = []

for i in range(N):
  a,b = map(int,input().split())
  A.append([a,b])

A.sort(key=lambda x:x[1] + x[0],reverse=True)


print(sum([a[0] for a in A[0::2]]) - sum([a[1] for a in A[1::2]]))

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

#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;

//str.substr(pos,number) str.insert(str.begin()+5,'3')
//set.insert(num) set.count(i)!=0
const int MAXN = 2e5 + 5;
const long long int INF = 1e18;
typedef pair<int,int> P;
int n;

long long int ans=1;
long long int over;
bool solve(long long int a){


}
int main(){
    fio();
	long long int a;
	long long int ans=1;
	cin>>n;
	bool test = false;
	for(int i=0;i<n;i++){
		cin>>a;	
		long long tem = ans;
		if(!test) ans*=a;
		if( ans>INF || ans<tem)
			test = true;
		if( a==0 ){
			ans = 0;
			test = false;
			break;
		}
	}

	if(!test) cout<<ans<<endl;
	else cout<<"-1"<<endl;

}














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

int main(){

	int W, H;
	cin>>W>>H;

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

	return 0;
}


Measured memory_bytes: 3120
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int d;
    scan(d);

    write("Christmas ");

    foreach (i ; 0 .. 25 - d) {
        write("Eve ");
    }
    writeln;
}


















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

const int kN = 100 + 5;
int n, a[2][kN];
int f[2][kN];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < 2; ++ i) {
        for (int j = 0; j < n; ++ j)
            scanf("%d", &a[i][j]);
    }
    f[0][0] = a[0][0];
    for (int j = 0; j < n; ++ j) {
        for (int i = 0; i < 2; ++ i) {
            if (i + j == 0) continue;
            int tmp;
            if (i && j)
                tmp = std::max(f[i - 1][j], f[i][j - 1]);
            else if (i)
                tmp = f[i - 1][j];
            else if (j)
                tmp = f[i][j - 1];
            f[i][j] = tmp + a[i][j];
        }
    }
    printf("%d\n", f[1][n - 1]);
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    vector<int>a(n);
    rep(i,n)cin>>a[i];

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

    cout<<a[n/2]-a[n/2-1]<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  if(s.size() == 26) {
    set<char> st;
    rrep(i, 26) {
      if(st.lower_bound(s[i]+1) != st.end()) {
        cout << s.substr(0, i) + *st.lower_bound(s[i]+1) << endk;
        return 0;
      }
      st.insert(s[i]);
    }
    cout << -1 << endk;
  } else {
    set<char> st;
    rep(i, 26) st.insert(char('a'+i));
    for(char c: s) st.erase(c);
    cout << s + *st.begin() << endk;
  }
  return 0;
}


Measured memory_bytes: 3640
import bisect
n,k=map(int,input().split())
mod=10**9+7
a=list(map(int,input().split()))
c=sorted(a)
d=[0]*n
e=[0]*n
for i in range(n):
  d[i]=bisect.bisect_left(c,a[i])
for i in range(n):
  cnt=0
  for j in range(i,n):
    if a[i]>a[j]:
      cnt+=1
  e[i]=cnt
st=sum(e)*k%mod
ad=sum(d)%mod
print((st+(ad*(k-1)*k//2)%mod)%mod)


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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;

  vector<int> A(100010), P(100010, 0);
  for(int i=0; i<Q; i++){
    cin >> A[i];
    P[A[i]-1]++;
  }

  for(int i=0; i<N; i++){
    if(Q-P[i] >= K){
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }

}

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

vector<ll> base_2(int n){
  vector<ll> ans(21,0);
  int i=0;
  while (n>0){
    ans[i] = n%2;
    n /= 2;
    i++;
  }
  return ans;
}

ll findlarge(vector<ll> v){
  for(auto p: v){
    if(p > 1){
      return 1;
    }
  }
  return 0;
}

vector<ll> v_sum(vector<ll> a, vector<ll> b){
  vector<ll> ans(a.size());
  for(ll i=0; i<a.size(); i++){
    ans[i] = a[i] + b[i];
  }
  return ans;
}

vector<ll> v_sub(vector<ll> a, vector<ll> b){
  vector<ll> ans(a.size());
  for(ll i=0; i<a.size(); i++){
    ans[i] = a[i] - b[i];
  }
  return ans;
}

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

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

  vector<vector<ll>> ac;
  
  ac.push_back(base_2(0));
  
  for(ll i=0; i<n+1; i++){
    ac.push_back(v_sum(ac[i], base_2(a[i+1])));
  }
 
  ac.push_back(base_2(0));
  for(auto&& p: ac[n+1]) p = n+2;

  ll l = 0, r = 1;
  ll ans = 0;
  
  while(r <= n){

    while(findlarge(v_sub(ac[r], ac[l])) == 0){
      ans += r-l;
      ++r;
    }
    
    if(l == r) break;
    ++l;    
  }

  cout << ans << endl;
}

Measured memory_bytes: 43692
#include <iostream>
#include <cstdio>
using namespace std;
int n, a[100010];
int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) scanf ("%d", &a[i]);
	long long l = 2, r = 2;
	for (int i = n; i >= 1; i--) {
		long long L = (l + a[i] - 1) / a[i], R = r / a[i];
		if (L > R || L == 0) { printf ("-1\n"); return 0; }
		l = L * a[i], r = (R + 1) * a[i] - 1;
		//printf ("%d %d\n", l, r);
	}
	printf ("%lld %lld\n", l, r);
	return 0;
}

Measured memory_bytes: 640
using System;

class SomethingOnIt{
    static void Main(string[] args){
        var input = Console.ReadLine();
        var charInput = input.ToCharArray();
        var ajitama = charInput[0];
        var tyashu = charInput[1];
        var negi = charInput[2];

        var nedan = 700;
        if(isOval(ajitama)){
            nedan = nedan + 100;
        }
        if(isOval(tyashu)){
            nedan = nedan + 100;
        }
        if(isOval(negi)){
            nedan = nedan + 100;
        }

        Console.WriteLine(nedan);
    }

    static bool isOval(char hoge){
        return hoge=='o';
    }
}

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

#define MOD 1000000007
#define INF (0x7fffffff)
#define NINF (1<<31)
#define INFL (0x7fffffffffffffff)
#define NINFL (1LL<<63)
#define MAX 100000000

#define pe(str) return cout<<(str)<<endl,0
#define px(str) cout<<(str)<<endl,exit(0)
#define accu(ac,v) cout<<setprecision(ac)<<v<<endl
#define bpc(a) __builtin_popcount(a)
#define pr(str) cout<<(str)<<endl
#define prpr(str) cout<<str<<endl
#define db(str) cerr<<"debug:"<<(str)<<endl
#define dbdb(str) cerr<<"debugs:"<<str<<endl
#define re(i,n) for(int i=0;i<(n);i++)
#define rre(i,n) for(int i=(n);i>=0;i--)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b);i>=(a);i--)
#define bw(a,b,c) (((a)<=(b))&&((b)<=(c)))
#define hello cout<<"hello"<<endl
#define spre(a) setprecision(a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define IF(C,T,F) ((C)?(T):(F))
#define max3(a,b,c) max((a),max((b),(c)))
#define min3(a,b,c) min((a),min((b),(c)))
#define max4(a,b,c,d) max((a),max((b),max((c),(d))))
#define min4(a,b,c,d) min((a),min((b),min((c),(d))))
#define enl cout<<endl
#define declare(t,n) t n;cin>>n
#define EPS 1e-6
#define EPSIN(a,b) ((b)-EPS<=(a)&&(a)<=(b)+EPS)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef complex<int> point;

template<class InputIterator>
void dump(InputIterator first,InputIterator last,char delim=' '){
	for(InputIterator it=first;it!=last;it++){
		if(it!=first)cout<<delim;
		cout<<*it;
	}
}

ull p(ull x,ull y){
	if(y==0) return 1;
	ull A=p(x,y/2)%MOD;
	// return (y&1?((A*A)%MOD*x)%MOD: (A*A)%MOD);
	return (y&1?((A*A)*x):(A*A));
}

template<class T>
void swp(T &a,T &b){
	T t=a; a=b; b=t;
}

template<class T>
int h(T first,string t){
	T it=first;
	int c=0;
	for(int i=0;i<t.size();i++){
		if(*it!=t[i]) c++;
		it++;
	}
	return c;
}

ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int main(void){
	int n,m;
	while(cin>>n>>m,n||m){
	int a[n];
	int ans=0;
	re(i,n)cin>>a[i];
	re(i,n){
		rep(j,i+1,n){
			if(a[i]+a[j]<=m)ans=max(a[i]+a[j],ans);
		}
	}
	if(ans!=0)cout<<(ans)<<endl;
	else cout<<("NONE")<<endl;
	}
	return 0;
}



Measured memory_bytes: 3048
#include <bits/stdc++.h>
#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() {
    ll N;
    cin >> N;
    ll ans = N * (N - 1) / 2LL;
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ldb long double
#define mt meke_tuple
template<typename T> bool ckmn(T &a, T b){ T c=a;a=min(a,b);return a!=c;}
template<typename T> bool ckmx(T &a, T b){ T c=a;a=max(a,b);return a!=c;}
const int N=2050;
int w[N];
char s[N];
vector<int> E[N];
int DFS(int u, int p, int d)
{
	int sum=w[u]*d;
	for(int v:E[u]) if(v!=p) sum+=DFS(v,u,d+1);
	return sum;
}
pair<int,int> MIN(int u, int p, int d)
{
	int sum=w[u]*d;
	int cnt=w[u];
	int all=0;
	int mx=0;
	for(int v:E[u]) if(v!=p)
	{
		pair<int,int> now=MIN(v,u,d+1);
		all+=now.first-now.second*d;
		cnt+=now.second;
		sum+=now.second*d;
		mx=max(mx,now.first-now.second*d);
	}
	int ost=all-mx;
	if(ost<mx) all=mx-ost;
	else
	{
		if(all&1) all=1;
		else all=0;
	}
	sum+=all;
	return mp(sum,cnt);
}
int main()
{
	int n,i,u,v;
	scanf("%i",&n);
	scanf("%s",s+1);
	for(i=1;i<=n;i++) w[i]=(s[i]=='1');
	for(i=1;i<n;i++)
	{
		scanf("%i %i",&u,&v);
		E[u].pb(v);
		E[v].pb(u);
	}
	int ans=1e9+7;
	bool ok=0;
	for(i=1;i<=n;i++)
	{
		int sum=0,mx=0,mxj=0;
		for(int j:E[i])
		{
			int tmp=DFS(j,i,1);
			sum+=tmp;
			mx=max(mx,tmp);
			if(mx==tmp) mxj=j;
		}
		int mn=MIN(mxj,i,1).first;
		if(sum%2==0 && mn*2<=sum-mx+mn)
		{
			ans=min(ans,sum/2);
			//printf("i:%i %i   %i\n",i,sum/2,MIN(mxj,i,1).first);
			ok=1;
		}
	}
	if(ok) printf("%i\n",ans);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int ary[3];
    rep(i,3) cin >> ary[i];

    sort(ary, ary+3);
    if (ary[0]==5 && ary[1]==5 && ary[2]==7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include"cstring"
using namespace std;
int flag[100001]={0};
int main()
{
	int n;
	int a;
	int num=0;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(a>n)
		{
			num++;
		}
		else
		{
			flag[a]++;
		}
	}
	for(i=0;i<100001;i++)
	{
		if(flag[i]<i)
		{
			num+=flag[i];
		}
		else if(flag[i]>i)
		{
			num+=flag[i]-i;
		}
	}
	printf("%d",num);
} 

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

int main() {
  string s;
  int i,j;
  cin >> s;
  for(i=0; i<s.size(); i++){
    if(s.at(i) == 'A') break;
  }
  for(j=s.size()-1; j>-1; j--){
    if(s.at(j) == 'Z') break;
  }
  cout << j-i+1 << endl;
}


Measured memory_bytes: 640
s = input()[::-1]
a = 0
cnt = [0]*2019
cnt[0] = 1
d = 1
for c in s:
    a += int(c) * d
    a %= 2019
    d *= 10
    d %= 2019
    cnt[a] += 1

#slist = [(s%(10**i))%2019 for i in range(n+1)]
#print(slist)


ans = 0
for i in range(2019):
    ans += cnt[i]*(cnt[i]-1)//2

print(ans)


Measured memory_bytes: 68664
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long

using namespace std;
int n,m;
int cnt=0;
int divisor[10001];
int main()
{
	scanf("%d%d",&n,&m);
	
	for(int i=1;i<=sqrt(m);i++)
	{
		if(m%i==0)
		{
			divisor[++cnt]=i;
		}
		if(i*i==m)continue;
		if(m%i==0)
		{
			divisor[++cnt]=m/i;
		}
	}
	
	sort(divisor+1,divisor+cnt+1);
	
	for(int i=cnt;i>=1;i--)
	{
		if(m/divisor[i]>=n)
		{
			printf("%d\n",divisor[i]);
			return 0;
		}
	}
	
	return 0;
}



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


int const N = 202, M = 40016;
int E, Pa[N], VIS[N], VS, SR, TR;
vector<int> G[N];
pair<int, int> Ed[M];

bool path(int v = SR){
	if (v == TR)return true;
	VIS[v] = VS;
	f(i, 0, G[v].size()){
		pair<int, int> &e = Ed[G[v][i]];
		if (e.second == 0)continue;
		if (VIS[e.first] != VS && path(e.first)) { Pa[e.first] = G[v][i]; return true; }
	}
	return false;
}

int fix(){
	int an = 2e9, v = TR;
	while (v != SR){
		int e = Pa[v];
		an = min(an, Ed[e].second);
		v = Ed[e ^ 1].first;
	}
	v = TR;
	while (v != SR){
		int e = Pa[v];
		Ed[e].second -= an;
		Ed[e ^ 1].second += an;
		v = Ed[e ^ 1].first;
	}
	return an;
}

inline int MF(int a, int b){
	SR = a, TR = b;
	int an = 0;
	++VS;
	while (path())an += fix(), ++VS;
	return an;
}

inline void aded(int a, int b, int w1 = 1, int w2 = 0){
	Ed[E] = make_pair(b, w1);
	Ed[E + 1] = make_pair(a, w2);
	G[a].push_back(E++);
	G[b].push_back(E++);
}

inline void CL(){
	E = 0;
	f(i, 0, N)G[i].clear();
}


char g[100][101];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 0, n)scanf("%s", g[i]);
	pair<int, int> s, t;
	f(i, 0, n)f(j, 0, m)if (g[i][j] != '.'){
		aded(i, j + n, 1);
		aded(j + n, i, 1);
		if (g[i][j] == 'S')s = make_pair(i, j);
		else if (g[i][j] == 'T')t = make_pair(i, j);
	}
	aded(n + m, s.first, 1000000);
	aded(n + m, s.second + n, 1000000);
	aded(t.first, n + m + 1, 1000000);
	aded(t.second + n, n + m + 1, 1000000);
	int an = MF(n + m, n + m + 1);
	printf("%d\n", an > 100000 ? -1 : an);
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    rep(i, 2) rep(j, n) cin >> a[i][j];
    vector<vector<int>> dp(2, vector<int>(n,0));
    rep(i, n) {
        if ( i - 1 >= 0 ) {
            dp[0][i] = dp[0][i-1] + a[0][i];
        }
        else {
            dp[0][i] = a[0][i];
        }
    }
    rep(i, n) {
        if ( i - 1 >= 0 ) {
            dp[1][i] = max({dp[1][i], dp[1][i-1] + a[1][i], dp[0][i] + a[1][i]});
        }
        else {
            dp[1][i] = max({dp[1][i], dp[0][i] + a[1][i]});
        }
    }
//    rep(i, 2) {
//        rep(j, n) cout << dp[i][j] << " ";
//        cout << endl;
//    }
    cout << dp[1][n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHEEM
//ALLAH IS WATCHING ME


// Shoeb Akibul Islam
// Dept of ICE, NSTU


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define dua ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define i_love_u_huu dua long long t;cin >> t;while(t--)
#define ses   "\n"
#define whp   " "
#define mxi 200003
#define mp make_pair
#define pii pair<long long, long long>
#define pf printf
#define sf scanf
#define ff first
#define sob(z)  (z).begin(), (z).end()
#define ss second
#define pb push_back
#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)
#define INF 0x3f3f3f3f
#define CLR(a,b) memset(a,b,sizeof(a));
#define PI acos(-1)
#define what_is(x) cerr<<x<<ses;
//set <int, greater <int> > ::iterator it;
//vector<pair<int,int> >a;
//memset(arr,0,sizeof(hg));
//priority_queue <int, vector<int>, greater<int> > pq;
///  string single character erase-
///             s.erase(s.begin()+x); where s is st ring name
///               ans x is index;
///    transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
///    transform(su.begin(), su.end(), su.begin(), ::toupper);
typedef long long v99;
typedef unsigned long long ull;
using namespace std;
using namespace __gnu_pbds;
v99 fx[4]= {1,-1,0,0};
v99 fy[4]= {0,0,1,-1};
v99 ox8[] = {0, 0, 1, 1, 1, -1, -1, -1};
v99 oy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
bool sort2val(const pii &a,const pii &b)
{
    if(a.second==b.second)return a.first<b.first;
    return a.second<b.second;
}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }


typedef tree< v99, null_type, less<v99>, rb_tree_tag,tree_order_statistics_node_update> ott;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/// find_by_order(k) – kth index a ki ache, pointer return korbe.
/// order_of_key(x) – x kon position a ache , oita bole dibe


bool prime[1000020];
v99 val[1000020];
void SieveOfEratosthenes(v99 n)
{
    for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
        val[j]++;
        }
    }
}

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



void solve()
{
    /// code is here->
    v99 n;cin>>n;SieveOfEratosthenes(n);
    v99 cr_h=0;
    for(v99 i=1;i<n;i++)
    {
        v99 kot=n-i, sq=sqrt(kot);
        //cout<<kot<<whp<<val[kot]<<ses;
        cr_h+=val[kot];
    }cout<<cr_h<<ses;
}



signed main()
{
    //dua
    //freopen("data.out","w",stdout);
    //while(1)
    //i_love_u_huu
    solve();
    return 0;
}



      ///  Alhamdulillah...


Measured memory_bytes: 11428
def calc(x,y,op):
    if op == '+':
        return x+y
    else:
        return x-y

s = input()
f = 1
A,B,C,D = [int(c) for c in s]
for i in ['-','+']:
    for j in ['-','+']:
        for k in ['-','+']:
            if calc(calc(calc(A,B,i),C,j),D,k) == 7 and f == 1:
                print(str(A)+i+str(B)+j+str(C)+k+str(D)+'=7')
                f = 0

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXL = 1e5 + 100;
char S[MAXL];

struct Node {
	int lev;
	bool used;
	Node *l, *r;
	Node(int l_): lev(l_), used(false), l(NULL), r(NULL) {}
};

VI num;

void DFS(Node *p) {
	if (p->used) return;
	if (p->l)
		DFS(p->l);
	else
		num.PB(p->lev + 1);
	if (p->r)
		DFS(p->r);
	else
		num.PB(p->lev + 1);
}

int main() {
	int N;
	ll L;
	scanf("%d%lld", &N, &L);
	Node *root = new Node(0);
	for (int i = 0; i < N; i++) {
		scanf("%s", S);
		Node *p = root;
		for (int j = 0; S[j]; j++) {
			if (S[j] == '0') {
				if (!(p->l))
					p->l = new Node(j + 1);
				p = p->l;
			}
			else {
				if (!(p->r))
					p->r = new Node(j + 1);
				p = p->r;
			}
		}
		p->used = true;
	}
	DFS(root);
	ll nim = 0;
	for (int u : num) {
		debug("u = %d\n", u);
		ll t = L - u + 1;
		ll r = t & (-t);
		nim ^= r;
	}
	debug("nim = %d\n", nim);
	if (nim == 0)
		puts("Bob");
	else
		puts("Alice");
	return 0;
}


Measured memory_bytes: 7292
def dfs(x,y,visited,grid,dp,r,c,n):
    stack = [(x,y)]
    k = 0
    while k < len(stack):
        x,y = stack[k]
        if (x,y) not in visited:
            dp[x][y] = n
            visited.add((x,y))
            if x+1 < r and grid[x+1][y] == '.':
                stack.append((x+1,y))

            if y+1 < c and grid[x][y+1] == '.':
                stack.append((x,y+1))

            if x-1 >= 0 and grid[x-1][y] == '.':
                stack.append((x-1,y))

            if y-1 >= 0 and grid[x][y-1] == '.':
                stack.append((x,y-1))

        k += 1

def shortestPath(x,y,edges):
    stack = [(x,0)]
    visited = set()
    k = 0
    while k < len(stack):
        x,d = stack[k]
        if x not in visited:
            visited.add(x)
            if x == y:
                print(d)
                return
            
            for kid in edges[x]:
                stack.append((kid,d+1))

        k += 1

    print(-1)

def main():
    r,c = map(int,input().split())
    x1,y1 = map(int,input().split())
    x2,y2 = map(int,input().split())
    x1 -= 1
    y1 -= 1
    x2 -= 1
    y2 -= 1
    dp = [[0 for j in range(c)] for i in range(r)]
    grid = []
    for i in range(r):
        grid.append(input())

    visited = set()
    n = 1
    for i in range(r):
        for j in range(c):
            if (i,j) not in visited and grid[i][j] == '.':
                dfs(i,j,visited,grid,dp,r,c,n)
                n += 1

    edges = {}
    for i in range(1,n):
        edges[i] = set()

    for i in range(r):
        for j in range(c):
            if grid[i][j] == '.':
                x = dp[i][j]
                for k in range(max(0,i-2),min(r,i+3)):
                    for l in range(max(0,j-2),min(c,j+3)):
                        y = dp[k][l]
                        if x != y and y != 0:
                            edges[x].add(y)
                            edges[y].add(x)

    x = dp[x1][y1]
    y = dp[x2][y2]
    shortestPath(x,y,edges)

main()


Measured memory_bytes: 187440
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {
      int n=scanner.nextInt();
      System.out.print(3*n*n);
      
        
    }
}

Measured memory_bytes: 21716
#include<stdio.h>

int main(void){
    double n,k;
    int i,j;
    double ans= 0.0;
    scanf("%lf %lf",&n,&k);
    double temp = 1/n;
    if(n>=k){
        ans += (n-k+1)/n;
        for(i=1;i<k;i++){
            for(j=i;j<k;j*=2){
                temp/=2;
            }
            ans += temp;
            temp = 1/n;
        }
    }else{
        for(i=1;i<n+1;i++){
            for(j=i;j<k;j*=2){
                temp/=2;
            }
            ans += temp;
            temp = 1/n;
        }
    }
    printf("%.10f",ans);
    return 0;
}


Measured memory_bytes: 128
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int a[100001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n = gi();
    for (int i = 0; i <= n; i++)
        a[i] = gi();

    ll res = 0;
    for (int i = 0; i < n; i++) {
        int x = gi();
        int d = MIN(x, a[i]);
        res += d;
        x -= d;
        d = MIN(x, a[i+1]);
        res += d;
        a[i+1] -= d;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
import java.io.*;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        while (!(input = br.readLine()).equals("0 0")) {
            String[] st = input.split(" ");
            int a = Integer.parseInt(st[0]);
            int b = Integer.parseInt(st[1]);
            for (int i = 0; i < a; i++) {
                if (i % 2 == 0) {
                    for (int j = 0; j < b; j++) {
                        bw.append(j % 2 == 0 ? "#" : ".");
                    }
                } else {
                    for (int j = 0; j < b; j++) {
                        bw.append(j % 2 == 0 ? "." : "#");
                    }
                }
                bw.newLine();
            }
            bw.newLine();
        }
        bw.flush();
    }


}



Measured memory_bytes: 26204
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// dp[i][j] := A の物質量が i、B の物質量が j の時のコスト最小
int dp[410][410];
int N, Ma, Mb, a[50], b[50], c[50];

signed main() {
    rep(i,0,410) rep(j,0,410) dp[i][j] = INF;
    dp[0][0] = 0;

    cin >> N >> Ma >> Mb;
    rep(i,0,N) cin >> a[i] >> b[i] >> c[i];

    int ans = INF;
    rep(i,0,N) repr(j,400,0) repr(k,400,0) {
        if(j-a[i] < 0 || k-b[i] < 0) continue;
        chmin(dp[j][k], dp[j-a[i]][k-b[i]] + c[i]);
        if(j != 0 && k != 0 && j*Mb == k*Ma) chmin(ans, dp[j][k]);
    }
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  	if((a+b)%2 == 0){
  		cout << (a+b)/2 << endl;
    }else{
      	cout << (a+b+1)/2 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a, b) a = (((a)<(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
  ll n,m; cin>>n>>m;
  ll ans = 0;
  VL res;
  for(int i=1; i<=(int)pow(m,0.5)+1; i++){
    if(m%i==0){
      res.PB(i); res.PB(m/i);
    }
  }
  sort(RALL(res));
  rep(i,res.size()){
    if(res[i]<=m/n) return cout<<res[i]<<endl,0;
  }


  return 0;
}


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

typedef long long ll;
using namespace std;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _repi(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _repi, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll h;	cin >> h;
	ll ans = 2;

	while( ans <= h ){
		ans *= 2;
	}

	cout << ans - 1 << endl;

	return 0;
}


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

int main() {
	int A[3];
	for (int i=0; i <3; i++)  cin >> A[i];
	sort(A, A + 3);
	int res = abs(A[1] - A[0]) + abs(A[2] - A[1]);
	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	bool h=true;
	string t="AKIHABARA";
	int w=0;
	rep(i,s.size()){
		if(w==t.size()){
			h=false;
			continue;
		}
		if(s[i]==t[w]){
			w++;
		}else if(t[w]=='A'){
			w++;
			i--;
		}else h=false;
	}
	if(w!=t.size()&&w+1!=t.size())h=false;
	if(h)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}











Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    set<string> s;
    string tmp;
    int N;
    cin >> N;
    REP(i, N){
        cin >> tmp;
        if (s.find(tmp) == s.end()) s.insert(tmp);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication12
{

    //ONLINE JUDGE (ITP1_8_B)


    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string str = Console.ReadLine();

                if (str == "0")
                {
                    break;
                }

                int[] Array = new int[str.Length];
                int sum = 0;

                for (int i = 0; i < str.Length; ++i)
                {
                    Array[i] = int.Parse(str[i].ToString());
                    sum += Array[i];
                }
                Console.WriteLine(sum);


            }
        }
    }
}

Measured memory_bytes: 9692
a = gets.chomp.to_i
sichi = ["7","5","3"]
anan = []
for ap in 0..9
	anan.push(sichi.repeated_permutation(ap).collect {|aa| aa.join}.delete_if{|aa| aa.count("7") == 0 || aa.count("5") == 0 || aa.count("3") == 0})
end
puts anan.flatten.map(&:to_i).delete_if{|aa| aa > a }.size

Measured memory_bytes: 9312
#include <stdio.h>
int main(void)
{
int X,gohyaku,go,kouhuku;
scanf("%d",&X);
gohyaku=X/500;
X=X%500;


go=X/5;
kouhuku=gohyaku*1000+go*5;
printf("%d",kouhuku);
return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#define endl '\n'
using namespace std;

int main()
{
    int n,m,x,y;
    int k = 1;
    cin >> n >> m;
    bool box[n];
    int ball[n];
    for(int i = 0; i < n; i++)
    {
        box[i] = false;
        ball[i] = 1;
    }
    box[0] = true;
    while(m--)
    {
        cin >> x >> y;
        if(ball[x-1] > 0)
        {
            ball[x-1]--;
            ball[y-1]++;
            if(box[x-1] && !box[y-1])
            {
                box[y-1] = true;
                k++;
            }
            if(ball[x-1] == 0 && box[x-1])
            {
                box[x-1] = false;
                k--;
            }
        }
    }
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 768
package main
 
import (
	"fmt"
)
 
func main() {
	var N, count, a int
	fmt.Scan(&N)
	for i := 1; i <= N; i++ {
		fmt.Scan(&a)
		if i % 2 == 1 && a % 2 == 1 {
			count++
		}
	}
    fmt.Println(count)
}


Measured memory_bytes: 1776
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    string s,t;
    int n;
    cin>>n>>s;
    int r=0,w=0,c=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r++;
        }
        else{
            w++;
        }
    }
    for(int i=0;i<n;i++){
        if(i<r){
            t+='R';
        }
        else{
            t+='W';
        }
    }
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]){
            c++;
        }
    }
    cout<<(c+1)/2<<endl;

    return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 H, W;
  cin >> H >> W;

  i64 count = 0;
  char c;
  while(cin >> c){
    if(c=='#') count++;
  }
  if(count == H + W - 1) cout << "Possible\n";
  else cout << "Impossible\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int main(){
  string s;
  int min=754;
  
  cin>>s;

  int n=s.size();
  
  for(int i=0;i<n-2;i++){
  int a=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
  // cout<<a<<endl;
  int b=a-753;
  int c=abs(b);
  if(min>c) min=c;
  }

  cout<<min<<endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

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

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

const int N =1e5+10;
int n;
int v[N];
int cnt[2][N];
int ans;
int main(int argv, char ** argc) {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%d", &n);
  rep(i, 1, n+1){
    scanf("%d", v+i);
    int parity = i % 2 == 0;
    cnt[parity][v[i]]++;
  }

  int odd_hi_num = 0, odd_hi_num_2 = 0,
    even_hi_num = 0, even_hi_num_2 =0;

  rep(i, 1, N){
    // odd
    if(cnt[0][i] > cnt[0][odd_hi_num]){
      odd_hi_num_2 = odd_hi_num;
      odd_hi_num = i;
    } else if(cnt[0][i] > cnt[0][odd_hi_num_2]){
      odd_hi_num_2 = i;
    }

    // even
    if(cnt[1][i] > cnt[1][even_hi_num]){
      even_hi_num_2 = even_hi_num;
      even_hi_num = i;
    } else if(cnt[1][i] > cnt[1][even_hi_num_2]){
      even_hi_num_2 = i;
    }
  }

  if(odd_hi_num == even_hi_num){
    // both have same highest num
    ans = min(n - cnt[0][odd_hi_num] - cnt[1][even_hi_num_2],
              n - cnt[1][even_hi_num] - cnt[0][odd_hi_num_2]);
  } else {
    // different highest num
    ans = n - cnt[0][odd_hi_num] - cnt[1][even_hi_num];
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int search(int x,int y);

int n;
int b[3][110],a[3][110];
int main()
{
	cin>>n;
	int i,j;
	for(i=1;i<=2;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}

	int g=search(1,1);
	cout<<g;
	return 0;
}
int search(int x,int y)
{
	int p,q;
	p=a[x][y];
	q=a[x][y];
	
	if(x==2 && y==n)
	{
		return a[x][y];
	}
	if(y+1<=n)
	{
		if(b[x][y+1]>0)
		{
			p+=b[x][y+1];
		}
		else
		{		
			b[x][y+1]=search(x,y+1);
			p+=b[x][y+1];
			//cout<<x<<' '<<y+1<<' '<<b[x][y+1]<<endl;
		}
	}
	
	if(x+1<=2)
	{
		if(b[x+1][y]>0)
		{
			q+=b[x+1][y];
		}
		else
		{
			b[x+1][y]=search(x+1,y);
			q+=b[x+1][y];
			//cout<<x+1<<' '<<y<<' '<<b[x+1][y]<<endl;
		}
	}
	
	if(p>q)
	{
		b[x][y]=p;
		return p;
	}
	else
	{
		b[x][y]=q;
		return q;
	}
}

Measured memory_bytes: 256
/**
 * ???????????´??°a, b, c?????????????????????????????? a < b < c????????¶????????????????????°"Yes"??????
 * ???????????????????????°"No"???????????????????????°??????
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
// 2-A ???????????´??°a, b, c?????????????????????????????? a < b < c????????¶????????????????????°"Yes"??????
//???????????????????????°"No"???????????????????????°??????
class Main {
 
    // ????????°???????????¨?????????????????????
    public static void main(String[] args) {
 
        //??\??????1??????
        int intNum1 = 0;
 
        //??\??????2??????
        int intNum2 = 0;
 
        //??\??????2??????
        int intNum3 = 0;
 
        try{
            //??????????????????????????\?????????
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
            //??????????????????????????\??????String?????§????????????
            String strLine = br.readLine();
 
            //??????????????????:??\?????????" "??§?????????
            //?????????????????????strLineAry[0]??¨strLineAry[1]??????????????????
            String[] strLineAry = strLine.split(" ");
 
            //??\????????????????????????
            intNum1 = Integer.parseInt(strLineAry[0]);
 
            //???????????????
            intNum2 = Integer.parseInt(strLineAry[1]);
 
            //???????????????
            intNum3 = Integer.parseInt(strLineAry[2]);
 
            if(intNum1 < intNum2 && intNum2 < intNum3) {
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
 
 
 
            //????????????
            }catch(IOException e) {
 
                //??????????????????
                System.out.println(e);
 
            }catch(NumberFormatException e) {
 
                //??°?????\????????\????????§??????
                System.out.println("??°?????§??\??????????????????");
            }
    }
}

Measured memory_bytes: 16892
N, M = map(int, input().split())
Drink = [[int(i) for i in input().split()] for _ in range(N)]
Drink.sort()

Need = M
Payment = 0
for i in range(N):
    if Need > Drink[i][1]:
        Payment += Drink[i][0] * Drink[i][1]
        Need -= Drink[i][1]
    else:
        Payment += Drink[i][0] * Need
        break
print(Payment)


Measured memory_bytes: 21604
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++) {scanf("%d",&a[i]);}
	qsort(a, n, sizeof(int), compare_int);
	
	int before=0;
	int now=0;
	int beforebefore=0;
	int temp=-10;
	int btemp=-20;
	int bbtemp=-30;
	int countmax=0;
	for(int i=0;i<n;i++){
		if(temp==a[i]){
			now++;
		}
		else{
			if(countmax<beforebefore+before+now){countmax=beforebefore+before+now;}
			
			bbtemp=btemp;
			btemp=temp;
			temp=a[i];
			
			if(temp-btemp>=3){before=0;beforebefore=0;}
			else if(temp-btemp==2){before=0;beforebefore=now;}
			else if(temp-btemp==1){
				if(temp-bbtemp>=3){beforebefore=0;before=now;}
				else{beforebefore=before;before=now;}
			}
			now=1;
			
		}
	}
	if(countmax<beforebefore+before+now){countmax=beforebefore+before+now;}
	
	
	printf("%d",countmax);
	
} 

Measured memory_bytes: 892