akhauriyash/Code-Regression huggingface dataset:
N = input()
a = len(N)
#1桁は9個、3桁は100~999の900個、5桁は10000 ~ 99999 の　　９００００
if a%2==0:
    b = 0
    for i in range(int(a/2)):
        b += 9*(10**(2*i)) 
else:
    c = 0
    for i in range(int((a-1)/2)):
        c += 9*(10**(2*i))
    d = int(N) - 10**(a-1) +1
    b = c+d
print(b)

Measured memory_bytes: 3060
#include <iostream>

int main(){
   int A, B, C;
   std::cin >> A >> B >> C;

   for(int a=A; a<=A*B; a+=A){
      if(a%B==C){
         std::cout << "YES" << std::endl;
	 return 0;
      }

   }
   std::cout << "NO" << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
using namespace std;
int main()
{
    int N, H;
    cin >> N >> H;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    int swing = *max_element(A.begin(), A.end());
    sort(B.rbegin(), B.rend());
    int cnt = 0;
    for (int thro : B) {
        if (thro < swing || H <= 0) break;
        H -= thro;
        cnt++;
    }
    if (H > 0) {
        cnt += (H + swing - 1) / swing;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b] <- replicateM 2 getInt
    print $ 1 + 2 + 3 - (a + b)

Measured memory_bytes: 380
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

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

int main()
{
    int n;
    cin>>n;
    int x[n+1];
    for(int i=0; i<n+1; i++)
    {
        cin>>x[i];
    }
    sort(x, x+n+1);
    int ans= x[1]-x[0];
    for(int i=2; i<n+1; i++)
    {
        ans=gcd(ans, x[i]-x[i-1]);
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>

#define max_v 100010

using namespace std;

int dfnum[max_v];
int vertex[max_v];
int parent[max_v];
int ancestor[max_v];
int idom[max_v];
int semi[max_v];
int samedom[max_v];
int best[max_v];
vector<int>bucket[max_v];

vector<int>G[max_v],rG[max_v];
int N;


void dfs(int p, int n){
  if(dfnum[n]==0 && !(n==0 && p>0)){
    dfnum[n]=N;
    vertex[N]=n;
    parent[n]=p;
    N++;
    for(int i=0;i<G[n].size();i++){
      dfs(n,G[n][i]);
    }
  }
}

int ancestorWithLowestSemi(int v){
  int a=ancestor[v];
  //if(ancestor[a]>=0){
  if(ancestor[a]>0){
    int b=ancestorWithLowestSemi(a);
    //if(v>0)ancestor[v]=ancestor[a];
    ancestor[v]=ancestor[a];
    if(dfnum[semi[b]] < dfnum[semi[best[v]]])best[v]=b;
  }
  return best[v];
}

void link(int p,int n){
  //if(n>0)ancestor[n]=p;
  ancestor[n]=p;
  best[n]=n;
}

void dominator(int sz,int root){
  N=0;
  for(int i=0;i<sz;i++){
    bucket[i].clear();
    dfnum[i]=0;
    //semi[i]=ancestor[i]=idom[i]=samedom[i]=-1;
    semi[i]=ancestor[i]=idom[i]=samedom[i]=0;
  }
  //dfs(-1,root);
  dfs(0,root);
  //int k=0;
  //dfs(0,root,k);
  //assert(N==sz);

  for(int i=N-1;i>0;i--){
    int n=vertex[i],p=parent[n],s=p;
    for(int j=0;j<rG[n].size();j++){
      int v=rG[n][j],s1;
      if(dfnum[v]<=dfnum[n])s1=v;
      else s1=semi[ancestorWithLowestSemi(v)];
      
      if(dfnum[s1]<dfnum[s])s=s1;
    }
    semi[n]=s;
    bucket[s].push_back(n);
    link(p,n);
    for(int j=0;j<bucket[p].size();j++){
      int v=bucket[p][j],y=ancestorWithLowestSemi(v);
      if(semi[y]==semi[v])idom[v]=p;
      else samedom[v]=y;
    }
    bucket[p].clear();
  }

  for(int i=1;i<N;i++){
    int n=vertex[i];
    //if(samedom[n]>=0){
    if(samedom[n]>0){
      idom[n]=idom[samedom[n]];
    }
  }

  for(int i=1;i<N;i++){
    for(int j=0;j<rG[i].size();j++){
      if(rG[i][j]==root)idom[i]=0;
    }
  }
}

int main(void){

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

  for(int i=0;i<m;i++){
    int s,t;
    cin >> s >> t;
    s--,t--;
    G[s].push_back(t);
    rG[t].push_back(s);
  }

  dominator(n,0);

  int q,r;
  cin >> q;
  while(q--){
    cin >> r;
    r--;
    if(idom[r]==0)cout << r+1 << endl;
    else cout << idom[r]+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 21396
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 N, M, V, P;
vs64 A;

bool solve(int x)
{
    s64 sum = M * (P - 1 + N - x);
    bool ret = true;
    for (int i = P - 1; i < x && ret; ++i)
    {
        if (A[x] + M - A[i] < 0) ret = false;
        sum += A[x] + M - A[i];
    }
    if (ret) ret = sum >= M * V ? true : false;

    return ret;
}

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

    cin >> N >> M >> V >> P;
    A.resize(N);
    rep (i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<s64>());

    int l = 0;
    int r = N;
    int mid;
    while (l + 1 < r)
    {
        mid = (l + r) / 2;
        if (solve(mid))
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }

    cout << l + 1 << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int x=0;
  int N;cin>>N;
  string S;cin>>S;

  int max_=0;
  for(int t=0;t<N;t++){
    if(S[t]=='I')x++;
    if(S[t]=='D')x--;
    max_=max(max_,x);
  }

  cout<<max_<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	static Map<Integer,Integer> m;
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=sc.nextInt();
		}
		m=new HashMap<Integer,Integer>();
		System.out.println(dp(0,h));
	}
	
	static int dp(int i,int arr[])
	{
		if(m.containsKey(i))
			return m.get(i);
		int returnVal=-1;
		if(i==arr.length-1)
			returnVal=0;
		else if(i==arr.length-2)
			returnVal=abs(arr[i]-arr[i+1]) + dp(i+1,arr);
		else
			returnVal=min(abs(arr[i]-arr[i+1]) + dp(i+1,arr),abs(arr[i]-arr[i+2]) + dp(i+2,arr));
		m.put(i,returnVal);
		return returnVal;
	}	
	
	static int min(int a,int b)
	{
		if(a<b)
			return a;
		return b;
	}
	
	static int abs(int a)
	{
		if(a<0)
			return a*-1;
		else
			return a;
	}
}

Measured memory_bytes: 78604
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 1000000001;
void solve() {
	int64 N, K; cin >> N >> K;
	vector<int64> h(N);
	for (int64 i = 0; i < N; ++i) {
		cin >> h[i];
	}
	sort(all(h));
	int64 ans = INFL;
	int64 slide = K - 1;
	for (int64 i = 0; i < N - K + 1; ++i) {
		ans = min(ans, h[i + slide] - h[i]);
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
int A[100];

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

    int sup=0,inf=1001001001;
    rep(i,N){
        if(sup<A[i]) sup=A[i];
        if(A[i]<inf) inf=A[i];
    }

    int ans=sup-inf;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  string s;
  cin >> s;
  if ((s.at(2) == s.at(3)) && (s.at(4) == s.at(5)))
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 384
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    
    let (k,x) = {
        let mut n = String::new();
        stdin.read_line(&mut n).unwrap();
        let mut input = n.trim().split_whitespace();
        (
            input.next().unwrap().parse::<i32>().unwrap(),
            input.next().unwrap().parse::<i32>().unwrap(),
        )
    };

    let x_min = if x-k+1 > -1000000 { x-k+1 } else { -1000000 };
    let x_max = if x+k-1 < 1000000 { x+k-1 } else { 1000000 };

    for i in x_min..x_max+1 {
        print!("{} ", i);
    }
    println!("");
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

int m[102][102];

int main(){
	int w,h,x,y,cnt=0;
	int dx[]={0,-1,1,-1,0,-1},dy[]={1,1,0,0,-1,-1};
	queue<pii> q;
	scanf("%d%d",&w,&h);
	rep(i,h)rep(j,w)scanf("%d",m[i+1]+j+1);
	m[0][0]=2;
	q.push(pii(0,0));
	while(!q.empty()){
		x=q.front().first;
		y=q.front().second;
		q.pop();
		rep(i,6){
			int tx=x+dx[i]+(i/2==1?0:y%2),ty=y+dy[i];
			if(in(tx,0,w+1)&&in(ty,0,h+1)){
				if(m[ty][tx]==1)cnt++;
				else if(m[ty][tx]==0){
					m[ty][tx]=2;
					q.push(pii(tx,ty));
				}
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1252
MOD = 1000000007
a, b = 0, 1
$<.bytes do |c|
	t = c % 2 * b
	a = (a * 3 + t) % MOD
	b = (b + t) % MOD
end
p ((a + a % 3 * MOD) / 3 + b) % MOD


Measured memory_bytes: 1788
#include<iostream>
#include<map>
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<int64_t, int64_t> ma = {};
	int n, m;
	int64_t a[200001] = {};
    int64_t ans = 0;
	cin >> n;
	ma[0]++;
	for (int i = 1; i <= n; i++) {
		cin >> m;
		a[i] = m + a[i - 1];
		ans += ma[a[i]];
		ma[a[i]]++;
	}
	cout << ans;
}

Measured memory_bytes: 14336
MOD = 998244353
N,M,K= map(int,input().split())

num = 200010
fact = [1] * (num+1)
ifact = [1] * (num+1)
inv = [pow(i,MOD-2,MOD) for i in range(num+1)]
for i in range(1,num+1):
    fact[i] = (fact[i-1] * i) % MOD
    ifact[i] = (ifact[i-1] * inv[i]) % MOD

def nCr(n,r):
    return (fact[n] * ifact[r] * ifact[n-r]) % MOD

ans = 0
for i in range(K+1):
    temp = M * pow(M-1,N-1-i,MOD)
    temp *= nCr(N-1,i)
    ans += temp
    ans %= MOD
print(ans)




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

int main () {
  int N;
  cin >> N;
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

// A

signed main(){
  string n; cin>>n;
  for(int i=0; i<n.size(); i++){
    if(n[i]-'0'==1) cout<<'9';
    else if(n[i]-'0'==9) cout<<'1';
  }
  cout<<en;
}

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

int main(){  
  int array[5][4][11], n;
  for (int i = 1; i <= 4; i++)
    for (int j = 1; j <= 3; j++)
      for (int k = 1; k <= 10; k++) array[i][j][k] = 0;
  
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int b,f,r,v;
    cin >> b >> f >> r >> v;
    array[b][f][r] += v;
  }

  for (int f = 1; f <= 4; f++){
    if (f > 1){
      cout << "####################" << endl;
    }
    for (int b = 1; b <= 3; b++){
      for (int r = 1; r <= 10; r++){
        cout << " " << array[f][b][r];
      }
      cout << endl;
    }
  }
  return 0;
}


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

int main() {
  int h, n;
  cin >> h >> n;
  
  int attack = 0;
  rep(i, n) {
    int a;
    cin >> a;
    attack += a;
  }
  
  if(attack >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
    
  return 0;
}


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

int main() {
	int a=0, max=0,n;
	string s;
	cin >>n>> s;
	for (int i = 0; i < n; i++) {
		if (s.substr(i,1) == "I") {
			a++;
		}
		else if (s.substr(i,1) == "D") {
			a--;
		} 
		if (a > max) {
			max = a;
		}
	}
	cout<< max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int abs_B(long long num, long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}



const long long MOD = 1000000007;

int main() {
    string S;
    cin >> S;
    int count = 0;
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
            count++;
        }
        else {
            count = 0;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}



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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] = tolower(s[k - 1]);
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

int main()
{
	int N;

	std::cin >> N;

	if (N < 10)
		std::cout << N << "\n";
	else if (N < 100)
		std::cout << 9 << "\n";
	else if (N < 1000)
		std::cout << (9 + (N-99)) << "\n";
	else if (N < 10000)
		std::cout << 909 << "\n";
	else if (N < 100000)
		std::cout << (909 + (N - 9999)) << "\n";
	else
		std::cout << 90909 << "\n";
}


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

int main() {
    int S, h, m, s;
    cin >> S;
    
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3096
n = int(input())
dp = [2**60]*(100000+n)
dp[0] = 0
for i in range(n+1):
    for j in range(7):
        dp[i] = min(dp[i-6**j]+1,dp[i])
    for k in range(6):
        dp[i] = min(dp[i],dp[i-9**k]+1)
print(dp[n])

Measured memory_bytes: 43756
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<double,double> pdd;
typedef pair<string,int> psi;

const int MOD = 1e9 + 7;
const int N = 100011;

typedef long long ll;

int n , m, u , v;

bool vis[N];

vector<int> g[N];

vector<int> f,s;

void dfs(int u , vector<int> &p){
	if(vis[u])
		return;
	p.push_back(u);
	vis[u] = 1;
	for (int i = 0; i < g[u].size(); ++i){
		int v = g[u][i];
		if(vis[v])
			continue;
		dfs(v,p);
		break;
	}
}
int main() {
	//freopen("input.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for (int i = 0; i < m; ++i){
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(g[1].size()){
		dfs(1,f);
	}
	for (int i = 0; i < g[1].size(); ++i){
		int v = g[1][i];
		if(vis[v])
			continue;
		dfs(v,s);
		break;
	}
	reverse(f.begin(),f.end());
	printf("%d\n",(int)(f.size()+s.size()));
	for (int i = 0; i < s.size(); ++i){
		f.push_back(s[i]);
	}
	for (int i = 0; i < f.size(); ++i){
		if(i)
			printf(" ");
		printf("%d",f[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 9720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  if (n % 2 == 0) {
    ll now = 0;
    for (int i = 0; i < n; i += 2) now += a[i];
    ll maximum = now;
    for (int i = n-2; i >= 0; i -= 2) {
      now += (a[i+1] - a[i]);
      if (now > maximum) maximum = now;
    }

    cout << maximum << endl;
  }
  else {
    vector<vector<ll> > dp(n+2, vector<ll>(3, (ll) -1e18));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    for (int i = 0; i < n; i++) {
      if (i+2 < n) dp[i+2][0] = max(dp[i+2][0], dp[i][0] + a[i+2]);
      if (i+2 < n) dp[i+2][1] = max(dp[i+2][1], dp[i][1] + a[i+2]);
      if (i+2 < n) dp[i+2][2] = max(dp[i+2][2], dp[i][2] + a[i+2]);
      if (i+3 < n) dp[i+3][1] = max(dp[i+3][1], dp[i][0] + a[i+3]);
      if (i+3 < n) dp[i+3][2] = max(dp[i+3][2], dp[i][1] + a[i+3]);
      if (i+4 < n) dp[i+4][2] = max(dp[i+4][2], dp[i][0] + a[i+4]);
    }

    cout << max(max(dp[n-3][0], dp[n-2][1]), dp[n-1][2]) << endl;
  }

  return 0;
}


Measured memory_bytes: 15596
S_list = [input() for i in range(2)]
N = map(int,S_list[0].split())    
A_list = list(map(int,S_list[1].split()))

A_max = max(A_list)
A_min = min(A_list)
A_abs = abs(A_max - A_min)
print(A_abs)

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

#define B

const int vmax=100010;

vector<int> graph[vmax],ord,low,scc,par;
stack<int>s;

void dfs(int v,int p,int &k){
	ord[v]=k++;
	low[v]=ord[v];
	par[v]=p;
	#ifdef S
		s.push(v);
	#endif
	for(auto &i:graph[v]){
		if(ord[i]==-1){
			dfs(i,v,k);
			low[v]=min(low[v],low[i]);

		#ifdef S
			}else if(scc[i]==-1){
		#else
			}else if(i!=p){
		#endif
			low[v]=min(low[v],ord[i]);
		}
	}
	#ifdef S
		if(ord[v]==low[v]){
			while(1){
				int u=s.top();s.pop();
				scc[u]=v;
				if(u==v) break;
			}
		}
	#endif
}

void lowlink(int n){
	int k=0;
	ord.assign(n,-1),low.resize(n);
	scc.assign(n,-1),par.resize(n);
	rep(i,n) if(ord[i]==-1) dfs(i,-1,k);
}

int main(void){
	int v,e;
	cin >> v >> e;
	rep(loop,e){
		int a,b;
		cin >> a >> b;
		graph[a].push_back(b);
		#ifdef S
		#else
			graph[b].push_back(a); // B,A
		#endif
	}
	lowlink(v);

/*	rep(i,v){
		cout << "ord[" << i << "]=" << ord[i]  << endl;
		cout << "low[" << i << "]=" << low[i]  << endl;
	}
*/

// Bridge
#ifdef B
	vector<pair<int,int>> bridge;
	rep(i,v){
		int j=par[i];
		if(j==-1)
			continue;
		if(ord[i] < low[j] || ord[j] < low[i] ){
			auto in=make_pair(i,j);
			if(in.second<=in.first) swap(in.first,in.second);
			bridge.push_back(in);
		}
	}
	sort(bridge.begin(),bridge.end());
	for(auto &i:bridge)
		cout << i.first << " " << i.second << endl;
#endif

// Articulation Points
#ifdef A
	vector<int> articulation_point;
	rep(i,v){
		if(i){
			bool ok=false;
			for(auto &j:graph[i]){
				if(i==par[j]&&ord[i]<=low[j])
					ok=true;
			}
			if(ok) articulation_point.push_back(i);
		}else{
			int d=0;
			rep(j,v) if(par[j]==0) d++;
			if(d>=2) articulation_point.push_back(i);
		}
	}
	sort(articulation_point.begin(),articulation_point.end());
	for(auto &i:articulation_point)
		cout << i << endl;
#endif
// Strongly Connected Components
#ifdef S
	int q;
	cin >> q;
	rep(loop,q){
		int a,b;
		cin >> a >> b;
		cout << (scc[a]==scc[b]) << endl;
	}
#endif
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> hotel(N);
  int cnt = N;
  for (int i = 0; i < N; i++){
    cin >> hotel.at(i);
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < i; j++){
      if(hotel.at(i) < hotel.at(j)){
        cnt--;
        break;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
d = N.times.map{N.times.map{100000}}
N.times{|i| d[i][i] = 0}
ABCs = readlines.map do |l|
  a, b, c = l.split.map(&:to_i)
  a, b = a - 1, b - 1
  d[a][b] = d[b][a] = c
  [a,b,c]
end
N.times do |i|
  N.times do |j|
    N.times do |k|
      d[j][k]=[d[j][k],d[j][i]+d[i][k]].min
    end
  end
end
puts ABCs.count{|(a,b,c)| d[a][b] < c}


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

int main(){
	int goal;
	while(cin >> goal, goal){
		int n;
		cin >> n;
		for(int i=0; i < n; i++){
			int start, end;
			cin >> start >> end;
			goal -= (end - start);
		}
		if(goal <= 0) cout << "OK" << endl;
		else cout << goal << endl;
	}
}

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

int main() {
	long long n, k; cin >> n >> k;
	long long mod_0 = 0, mod_k2 = 0;
	for (int i = 1; i <= n; i++) {
		if (i%k == 0) {
			mod_0 += 1ll;
		}
		if (k % 2 == 0) {
			if (i%k == k / 2) {
				mod_k2 += 1ll;
			}
		}
	}
	cout << mod_0 * mod_0*mod_0 + mod_k2 * mod_k2*mod_k2 << endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

A, B, C, D = map(int, input().split())
count_c = (B // C) - ((A-1) // C)
count_d = (B // D) - ((A-1) // D)

cd = lcm(C, D)
count_cd = (B // cd) - ((A-1) // cd)
count_c_or_d = count_c + count_d - count_cd
count_all = B - A + 1
ans = B - A + 1 - count_c_or_d
print(ans)

Measured memory_bytes: 64620
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int h, w; cin >> h >> w;
	char red[500][500],blue[500][500];
	rep(i, h) {
		rep(j, w) {
			red[i][j] = blue[i][j] = '.';
		}
	}
	rep(i, h) {
		string s; cin >> s;
		rep(j, w) {
			if (s[j] == '#') {
				red[i][j] = blue[i][j] = '#';
			}
			if ((i % 2&&i<h-1&&j>0&&j<w-1)||(i%2==0&&i>0&&i<h-1&&j==1)) {
				red[i][j] = '#';
			}
			else blue[i][j] = '#';
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << red[i][j];
		}
		cout << endl;
	}
    cout<<endl;
	rep(i, h) {
		rep(j, w) {
			cout << blue[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

int main() {
  int a,b,x;
  cin >> a >> b >> x;
  if(a>x) cout << "NO" << endl;
  else if(a+b>x) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int c(int n)
{
	int cur=0;
	for(int i=1;n-i>=0;i++){cur++;n-=i;}
	return cur;
}
int32_t main()
{
	
	int n=in();
	int an=0;int ans=0;
	while(n%2==0){n/=2;an++;}
	ans+=c(an);an=0;
	for(int i=3;i<=sqrt(n);i+=2)
	{
		while(n%i==0){an++;n/=i;}
		ans+=c(an);
		an=0;
	}
	if(n>2)
	ans++;
	cout<<ans;

}

Measured memory_bytes: 3720
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] T = new int[N];
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			T[i] = sc.nextInt();
			A[i] = sc.nextInt();
		}

		long t = T[0];
		long a = A[0];
		for (int i = 1; i < N; i++) {
			long factor = Math.max(t / T[i], a / A[i]);
			long nextT = T[i] * factor;
			long nextA = A[i] * factor;
			while (nextT < t || nextA < a) {
				nextT += T[i];
				nextA += A[i];
			}

			t = nextT;
			a = nextA;
		}

		System.out.println(t + a);
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 8276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp36 {
    class Program {
        static void Main(string[] args) {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            string s3 = Console.ReadLine();

            Console.WriteLine(s1[0].ToString() + s2[1].ToString() + s3[2].ToString());
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    int N; string S;
    cin >> N >> S;
    int left_black = 0, right_white = 0;
    rep(i,N) if(S[i]=='.') right_white++;
    
    int minimum = right_white;
    rep(i,N){
        if(S[i]=='.') right_white--;
        if(S[i]=='#') left_black++;
        minimum = min(minimum, left_black + right_white);
    }
    cout << minimum << endl;
}

Measured memory_bytes: 640
n = gets.to_i
Dish = Struct.new(:a, :b, :id)
dishes = []

n.times do |i|
  a, b = gets.split.map(&:to_i)
  dishes << Dish.new(a, b, i)
end

# example
# a1 b1
# a2 b2
# 高橋君がa1をとったときの総和
# a1 - b2
# 高橋君がa2をとったき総和
# a2 - b1
# a1をとるべきときは
# a1 - b2 >= a2 - b1
# => a1 + b1 >= a2 + b2

dishes.sort_by! {|d| -(d.a + d.b) }

ans = 0
n.times do |i|
  d = dishes.shift
  if (i % 2) == 0
    ans += d.a
  else
    ans -= d.b
  end
end

p ans


Measured memory_bytes: 12664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
ll ans;
int main(){
	scanf("%lld",&n);
	n--;
	for(int l=1,r;l<=n;l=r+1){
		r=n/(n/l);
		ans+=n/l*(r-l+1);
	}
	printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3812
#include <stdio.h>
int main(void){
    
    int a,i,j,tmp;
    int w[110];
    int sum;
    
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d",&w[i]);
    }
    
    for (i=0; i<a; ++i) {
        for (j=i+1; j<a; ++j) {
            if (w[i] < w[j]){
                tmp =  w[i];
                w[i] = w[j];
                w[j] = tmp;
              }
          }
     }
     
     sum=w[0]-w[a-1];
     printf("%d",sum);

}


Measured memory_bytes: 128
n,m = map(int, input().split())
penalty = [[0,0] for i in range(n)]

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s=='AC':
        penalty[p][0]=1
    else:
        if penalty[p][0]==0:
            penalty[p][1]+=1
a = 0
b = 0
for i in range(n):
    if penalty[i][0]==1:
        a += penalty[i][0]
        b += penalty[i][1]
print(a,b)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const ll INFL = (1L<<61);

int main() {
  ll n, m, L; cin >> n >> m >> L;
  vvl dist(n,vl(n,INFL));
  rep(i,n) dist[i][i] = 0;
  rep(i,m) {
    ll a, b, c; cin >> a >> b >> c; a--; b--;
    dist[a][b] = dist[b][a] = c;
  }
  rep(k,n) rep(i,n) rep(j,n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  vvl ans(n,vl(n,INFL));
  rep(i,n) rep(j,n) if (dist[i][j] <= L) ans[i][j] = 1;
  rep(i,n) ans[i][i] = 0;
  rep(k,n) rep(i,n) rep(j,n) ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j]);

  ll Q; cin >> Q;
  rep(i,Q) {
    ll s, t; cin >> s >> t;
    s--; t--;
    if (ans[s][t] == INFL) {
      cout << -1 << endl;
    } else {
      cout << ans[s][t] - 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

//ll a[100] = {};
//ll b[100] = {};

int main() {
	ll q; cin >> q;
	ll a, b;

	rep(i, 0, q) {
		ll ans = 0;
		cin >> a >> b;
		if (a < b) swap(a, b);

		if (a == b || a + 1 == b) {
			ans = 2 * a - 2;
		}
		else {
			ll c = sqrt(a*b);

			if (c*c == a * b) {
				c--;
			}

			if (c*(c + 1) >= a * b) {
				ans = 2 * c - 2;
			}
			else {
				ans = 2 * c - 1;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 3010
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
bool f[MAXN];
int a[MAXN],n;
void dfs(int u,int p)
{
	f[u]=0;
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p)
		{
			dfs(V[i],u);
			if(f[V[i]]==0&&a[u]>a[V[i]])
				f[u]=1;
		}
}
int main()
{
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		dfs(i,0);
		if(f[i])
			printf("%d ",i);
	}
}

Measured memory_bytes: 384
import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())
P = list(map(lambda x:x - 1, map(int,readline().split())))
C = list(map(int,readline().split()))

# 全ての頂点からスタートして、ループを探す
# ループを一周したときの得点が正であれば、
# ・[可能な限り - 1]回ループを回して、あとは得点が最大になるところまで歩く
# (-1回は、最後のループは回し切らないほうが良いパターンがあるため)

ans = - (10 ** 10)
for start in range(N):
  cur = start
  point_sum = 0
  cnt = 0
  best = []
  while True:
    cur = P[cur] # 次に進む
    cnt += 1 # ステップ数を記録
    point_sum += C[cur] # 得点を加算
    if len(best) == 0:
      best.append(point_sum)
    else:
      best.append(max(best[-1], point_sum))
    if cur == start:
      break # 始点に戻っていたらそこで終了
  #print("start",start,"best",best,"point_sum",point_sum)
  
  # ここから場合分け
  # 1.ループの得点が正のとき
  # 1.1. 可能な限りループを回して、そのあと最も得点が高いところまで行く
  # 1.2. [可能な限り - 1]回ループを回して、そのあと最も得点が高いところまで行く
  # 2.ループの得点が正でないとき
  # 2.1. Kがループ一周以上の回数のときは好きな得点を選べる
  # 2.2. Kがループ一周未満の回数のときは、そこまでの最高得点を選ぶ
  
  # 1.
  if point_sum > 0:
    # 1.1.
    loop_count = K // cnt # 可能な限り回したときのループ数
    case1_point = loop_count * point_sum
    rest = K % cnt
    if rest > 0:
      case1_point += best[rest - 1]
    #print("case1_point",case1_point)
    
    point = case1_point
    # 1.2.
    if loop_count > 0: # ループが一回以上あるときのみ検討可能
      loop_count -= 1
      case2_point = loop_count * point_sum
      # ループを一回省略しているので、好きな数を選べる
      case2_point += best[-1]
      #print("case2_point",case2_point)
      if point < case2_point:
        point = case2_point
    if ans < point:
      ans = point
  else:
    # 2. ループの得点が正でないとき
    point = 0
    if cnt <= K: # 2.1. 好きな得点を選べる
      point = best[-1]
      #print("2.1.point",point)
    else:
      # 2.2 行けるとこまで
      point = best[cnt - 1]
     # print("2,2.point",point)
    if ans < point:
      ans = point
  
print(ans)

Measured memory_bytes: 81084
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <string.h>
#include <math.h>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define pb push_back
#define _1 first
#define _2 second

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 998244353; //1000000007;
const int alphabet = 26;
const int MAXINT = 2e5+1;

int main() {
    string s;

    cin >> s;
    int n = s.size();

    if(s[n-1] == '2') cout << "hon"<<endl;
    if(s[n-1] == '4') cout << "hon"<<endl;
    if(s[n-1] == '5') cout << "hon"<<endl;
    if(s[n-1] == '7') cout << "hon"<<endl;
    if(s[n-1] == '9') cout << "hon"<<endl;
    if(s[n-1] == '0') cout << "pon"<<endl;
    if(s[n-1] == '1') cout << "pon"<<endl;
    if(s[n-1] == '6') cout << "pon"<<endl;
    if(s[n-1] == '8') cout << "pon"<<endl;
    if(s[n-1] == '3') cout << "bon"<<endl;


    
}

/*

*/  



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,a,b;
  cin >> n>>a>>b;
  cout<<min(n*a,b)<<endl;
  return 0;
}

Measured memory_bytes: 3604
N,M = map(int,input().split())
H = list(map(int,input().split()))
ab = [map(int, input().split()) for _ in range(M)]
a, b = [list(i) for i  in zip(*ab)]

t = [1]*(N)
#print(N,M,H,t,a,b)
for i in range(M):
    if H[a[i]-1] > H[b[i]-1] :
        t[b[i]-1] = 0
    elif H[a[i]-1] < H[b[i]-1]:
        t[a[i]-1] = 0
    else:
        t[a[i]-1]=0
        t[b[i]-1]=0

ans = 0
for i in t:
    if i == 1:
        ans += 1

print(ans)

Measured memory_bytes: 66968
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int N = int.Parse(ipt[0]);
    int M = int.Parse(ipt[1]);
    
    bool[] ac = new bool[N];
    int[] pn = new int[N];
    for (int i = 0; i < N; i++) {
      ac[i] = false;
      pn[i] = 0;
    }
    
    for (int i = 0; i < M; i++) {
      ipt = Console.ReadLine().Split(' ');
      int p = int.Parse(ipt[0]);
      if (!ac[p-1]) {
        if (ipt[1] == "AC") {
          ac[p-1] = true;
        } else {
          pn[p-1]++;
        }
      }
    }
    
    int answer = 0, penalty = 0;
    for (int i = 0; i < N; i++) {
      if (ac[i]) {
        answer++;
        penalty += pn[i];
      }
    }
    Console.WriteLine(answer.ToString() + " " + penalty.ToString());
  }
}


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

int main() {
    int dinner[5];
    int min = 10;
    for(int i = 0; i < 5; i++) {
        cin >> dinner[i];
        if(dinner[i] % 10 < min) {
            if( dinner[i] % 10 != 0) {
                min = dinner[i] % 10;
            }
        }
    }

    int total = 0;
    for(int i = 0; i < 5; i++) {
        int tmp = (dinner[i] / 10) * 10;
        tmp += (dinner[i] % 10 > 0)? 10 : 0;
        //cout << tmp << endl;
        total += tmp;
    }

    total -= (10 - min);

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """ 根を見つける関数を定義（同時にxを直接根にくっつける操作も行う）"""
        tmp = []
        parents = self.parents
        while parents[x] >= 0:
            tmp.append(x)
            x = parents[x]
        for y in tmp:
            parents[y] = x
        return x

    def union(self, x, y):
        """ 二つの木をくっつける（子を多く持つ方を根とした親子関係）。これは破壊的操作を行う。"""
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        """ xとyが同じ根の子かを判定 """
        return self.find(x) == self.find(y)

    def size(self, x):
        """ x の根の parent（= 要素数）を返す """
        return -self.parents[self.find(x)]

    def members(self, x):
        """ xが属するグループの要素をリストとして返す O(N)"""
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """ 全ての根の要素をリストとして返す O(N)"""
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """ グループの数を返す O(1)"""
        return len(self.roots())

    def size_list(self):
        """ 各グループの要素数のリストを返す(根の番号は返さない) O(N)"""
        return [-x for x in self.parents if x < 0]

    def all_group_members(self):
        """ {根:[根の子(根を含む)のリスト],...}を辞書で返す """
        res = [[] for _ in range(self.n)]
        for i in range(self.n):
            x = self.find(i)
            res[x].append(i)
        return {r: res[r] for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


##############################################################################################################
import sys
input = sys.stdin.readline


N = int(input())
U = UnionFind(2*N)
P = [[] for _ in range(N)]
code1, code2 = {}, {}
for i in range(N):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    if a not in code1:
        code1[a]=i
    if b not in code2:
        code2[b]=i+N
    U.union(code1[a],code2[b])
res = 0
for a in U.all_group_members().values():
    x, y = 0, 0
    for b in a:
        if b<N: x += 1
        else: y += 1
    res += x*y
print(res-N)

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

int main (){
  long N,l;
  vector<long>A(5),copy(5);
  cin >> N;
  for(int i = 0 ;i < 5;i++){
    cin >> A.at(i);
    copy.at(i)=A.at(i);
  }
  sort(copy.begin(),copy.end());
  l= (N + copy.at(0) - 1)/copy.at(0); 
  int m = 0;
  while(copy.at(0) != A.at(m)) m++;
  cout << l + 4 <<   endl;
}

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

int main() {
  int n, h;
  cin >> n >> h;
  int maxa = 0, a;
  vector<int> b(n);
  for (int i = 0; i < n; i ++) {
    cin >> a >> b[i];
    maxa = max(maxa, a);
  }

  sort(b.begin(), b.end());
  int ans = 0;
  while (h > 0 && !b.empty()) {
    int x = b.back();
    b.pop_back();
    if (x <= maxa) break;

    ans ++;
    h -= x;
  }
  if (h > 0) ans += ceil((double)h / maxa);

  cout << ans << endl;
}

Measured memory_bytes: 640
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include<algorithm>
#include<vector>
#include<cmath>


using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    vector<int>x(n);

    int minx = 1000000000;

    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i <= n - k; i++) {
        int a = min(abs(x[i]) + abs(x[i + k - 1] - x[i]), abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]));
        if (minx > a) {
            minx = a;
        }
    }

    cout << minx << endl;

    return 0;
}



Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int c=a+b;
    int d=a-b;
    int e=a*b;
    int tmp=max(c,d);
    cout<<max(tmp,e)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MAX_N 100100
struct BIT{
	ll bit[MAX_N+1];
	void add(int i,ll x){
		i++;
		while(i<=MAX_N){
			bit[i]+=x;
			i+=i&-i;
		}
		return;
	}
	ll sum(int i){
		i++;
		ll res=0;
		while(i>0){
			res+=bit[i];
			i-=i&-i;
		}
		return res;
	}
	ll sum(int l,int r){// [l,r]
		if(l==0)return sum(r);
		else return sum(r)-sum(l-1);
	}
}bit;
int N,M;
P range[300100];
int length(P a){
	return a.sec-a.fi;
}
bool comp(P a,P b){
	return (a.sec-a.fi) < (b.sec-b.fi);
}
int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++){
		cin >> range[i].fi >> range[i].sec;
	}
	sort(range,range+N,comp);
	int k = 0;
	for(int i=1;i<=M;i++){
		while(k<N&&length(range[k])<i){
			bit.add(range[k].fi,1);
			bit.add(range[k].sec+1,-1);
			k++;
		}
		int ans = N-k;
		for(int j=0;j<=M;j+=i){
			ans += bit.sum(j);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//long n = long.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] a = Console.ReadLine().Split().Select(int.Parse).OrderBy(p => p).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			System.Diagnostics.Debug.WriteLine(string.Join(" ", a));
			int ans = 0;
			for (int i = 1; i < a.Length; i++) {
				ans += Math.Abs(a[i] - a[i - 1]);
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
def examA():
    A, B = LI()
    if B%A==0:
        ans = A+B
    else:
        ans = B-A
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()


Measured memory_bytes: 3672
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	hs := make([]int, n)
	for i := range hs {
		fmt.Scan(&hs[i])
	}

	var cur int
	for i := 0; i < n; i++ {
		if hs[i] < cur {
			fmt.Println("No")
			return
		}

		if hs[i]-1 >= cur {
			cur = hs[i] - 1
		} else {
			cur = hs[i]
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 6308
s = gets.chomp
alph = Array.new(26, false)
s.each_char do |c|
  alph[c.ord - 'a'.ord] = true
end
res = "None"
alph.each_with_index do |a, i|
  unless a then
    res = (i + 'a'.ord).chr
    break
  end
end
puts res


Measured memory_bytes: 1916