akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int length[6] = {60,80,100,120,140,160};
int weight[6] = {2,5,10,15,20,25};
int fee[6] = {600,800,1000,1200,1400,1600};

int main(int argc, const char * argv[]) {
    
    while (true) {
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        
        int sum = 0;
        for(int i=0;i<n;i++){
            int x,y,h,w;
            cin >> x >> y >> h >> w;
            
            for(int j=0;j<6;j++){
                if(length[j] >= x+y+h && weight[j] >= w){
                    sum+= fee[j];
                    break;
                }
            }
            
        }
        
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
    int N,K,X,Y,a=0;
    cin>>N>>K>>X>>Y;
    for(int i=1;i<=N;i++){
        if(i>K){
            a+=Y;
        }else{
            a+=X;
        }
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
var lines =[];
var readline = require("readline");
var rl = readline.createInterface({
  input:  process.stdin,
  output: process.stdout
});

rl.on('line',function(x){
  lines.push(x);
});

rl.on('close',function(){
  var ab = Number(lines[0].split(" ")[0]);
  var bc = Number(lines[0].split(" ")[1]);
  var ca = Number(lines[0].split(" ")[2]);

  console.log(ab*bc/2);
});


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

int main()
{
    int h, w, ans = 0;
    cin >> h >> w;
    vector<string> A(h);
    rep(i, h) cin >> A[i];
    rep(i, h) rep(j, w)
    {
        if (A[i][j] == '#')
            ans++;
    }
    if (ans == h + w - 1)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
dams = [int(x) for x in input().split()]
kisu = sum([dams[i] for i in range(1,N,2)])
gusu = sum([dams[i] for i in range(0,N-1,2)])
x1 = gusu-kisu + dams[N-1]
monts = []
monts.append(x1)
for i in range(N-1):

  monts.append(int((dams[i] - monts[i]/2)*2))
for i in range(len(monts)):
  print(monts[i],"",end = "") 

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

int main() {
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  long long f1 = a*c;
  long long f2 = a*d;
  long long f3 = b*c;
  long long f4 = b*d;
  
  long long ans = max(max(f1,f2),max(f3,f4));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int x[100010];
bool take[100010];
vector<pair<int, int>> G[100010];

bool dfs(int k, int d) {
    take[k] = true;
    x[k] = d;
    for (int i = 0; i < G[k].size(); i++) {
        if (!take[G[k][i].first]) {
            if (!dfs(G[k][i].first, d + G[k][i].second)) return false;
        }
        else {
            if (x[G[k][i].first] != d + G[k][i].second) return false;
        }
    }
    return true;
}

int main(void){
    int n, m;
    cin >> n >> m;
    
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;  r--;
        
        G[l].emplace_back(r, d);
        G[r].emplace_back(l, -d);
    }
    
    for (int i = 0; i < n; i++) take[i] = false;
    
    int ans = 1;
    for (int i = 0; i < n; i++) {
        if (!take[i]) ans = dfs(i, 0);
        if (!ans) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  ll N = 0,A = 0,B = 0;
  cin >> N >> A >> B;
  if(N == 1 && A != B){
    cout << "0";
    return 0;
  }
  if(B < A){
    cout << "0";
    return 0;
  }
  cout << B * (N - 2) - A * (N - 2) + 1;
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
const int N = 405 ; 
ll dp[N][N] , a[N] ;
ll solve(int l , int r ){
	if( l == r )return 0; 
	ll& rf = dp[l][r] , S =a[r]; 
	if( rf != -1 )return rf; 
	rf = 1e18 ;
	for(int i = l ; i < r ; i++ ){
		rf = min(solve(l,i)+solve(i+1,r),rf); 
		S+=a[i]; 
	}
	rf += S ; 
	return rf ; 
}
int main(){
	int n ; 
	cin >> n ; 
	for(int i = 0 ; i < n ;i++ ){
		cin >> a[i]; 
	}
	memset(dp,-1,sizeof dp); 	
	cout << solve(0,n-1)<<endl; 
}

Measured memory_bytes: 1536
from itertools import accumulate
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]

# 10**5=100000では、配列は0~99999。いもす法で必要な分は100001
ans = [0] * (10 ** 5 + 2)
for i, j in l:
    ans[i] += 1
    ans[j + 1] -= 1

print(list(accumulate(ans)).count(m))


Measured memory_bytes: 67032
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

template<typename T>
vector<T> Divisors(T n) {
	vector<T> res;
	for(T i = 1; i * i <= n; ++i) {
		if( n % i == 0 ) {
			res.push_back(i);
			
			if( i < n / i ) res.push_back(n / i);
		}
	}
	
	sort(res.begin(), res.end());
	
	return res;
}

int f(ll a, ll b) {
	string as = to_string(a);
	string bs = to_string(b);
	
	int ad = (int)as.size();
	int bd = (int)bs.size();
	
	if( ad >= bd ) return ad;
	else return bd;
}

int main(void) {
	ll n;
	cin >> n;
	
	vector<ll> div = Divisors(n);
	
	int ans = 100;
	for(auto& v : div) {
		ans = min(ans, f(v, n / v));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3708
my $s= <STDIN>;
my ($k,$N) = split(/ /,$s);
my $mod = 10**9+7;
my $sum =0;
my @del;
for(my $i=0;$i<$N;$i++){$del[$i] = 0;}
for(my $i=$N;$i>0;$i--){
 my $count = int($N /$i);
 $del[$i] = &powmod($count,$k,$mod);
 for(my $j=2;$j<=$count;$j++){
    $del[$i]= $del[$i] - $del[$i*$j];
 }
 $sum = ($sum + $i*$del[$i])%$mod;
 #print "i$i del$del[$i] $sum\n";
}
print "$sum";
exit;

sub powmod{
   my ($a,$b,$m) = @_;
   if($b==1){return $a;}
   my $c = powmod(($a*$a)%$m,int($b/2),$m);
   if($b%2){
     $c = ($c*$a)%$m;
   }
   return $c;
}

Measured memory_bytes: 7964
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;

int main()
{
	int n, m, s, g1, g2;
	while (cin >> n >> m >> s >> g1 >> g2, n | m | s | g1 | g2) {
		s--, g1--, g2--;
		vector<vector<int>> G(n, vector<int>(n, INF));
		for (int i = 0; i < n; i++) G[i][i] = 0;
		for (int i = 0; i < m; i++) {
			int b1, b2, c;
			cin >> b1 >> b2 >> c; b1--, b2--;
			G[b1][b2] = c;
		}
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
				}
			}
		}
		int res = INF;
		for (int i = 0; i < n; i++) {
			res = min(res, G[s][i] + G[i][g1] + G[i][g2]);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<queue>

using namespace std;

	int w,h,a,ans,tx,ty;
	bool map[62][62];
	int lap[62][62];
	
struct Node{
	int x,y,d;
	Node(int a,int b,int c){
		x=a;
		y=b;
		d=c;
	}
};
typedef struct Node node;


int main(){
	//??\????????????????????§??????????????????????????¨????????????????????????????????????
	cin>>w;
	cin>>h;
	
	while(w!=0 || h!=0){
		ans=0;
		for(int lop=0;lop<62;lop++){
			for(int lop2=0;lop2<62;lop2++){
				if(lop==0 || lop==61 || lop2==0 || lop2==61|| lop2==w*2 || lop==h*2){
					map[lop][lop2]=1;
				}else{
					map[lop][lop2]=0;
				}
				lap[lop][lop2]=0;
			}
		}
		//?????????????????´
		map[0][1]=0;
		map[h*2][w*2-1]=0;
		//??\?????£?????£
		
		for(int lop=0;lop<h*2-1;lop++){
			if(lop%2==0 || lop==0){
				for(int lop2=0;lop2<w-1;lop2++){
					cin>>a;
					if(a==1){
						if(map[lop][lop2*2+2]==0){
							map[lop][lop2*2+2]=1;
						}
						if(map[lop+1][lop2*2+2]==0){
							map[lop+1][lop2*2+2]=1;
						}
						if(map[lop+2][lop2*2+2]==0){
							map[lop+2][lop2*2+2]=1;
						}
					}
				}
			}else{
				for(int lop2=0;lop2<w;lop2++){
					cin>>a;
					if(a==1){
						if(map[lop+1][lop2*2]==0){
							map[lop+1][lop2*2]=1;
						}
						if(map[lop+1][lop2*2+1]==0){
							map[lop+1][lop2*2+1]=1;
						}
						if(map[lop+1][lop2*2+2]==0){
							map[lop+1][lop2*2+2]=1;
						}
					}
				}
			}
		}
		//?£???????????????????????????????????£?????????????????????????
		//?????¨?¨???§??????????????´???????£???????
		
		bool done[62][62]={0};
		queue<node> q;
		q.push(node(1,1,0));
		//??¨??¢?´¢??¨?????\?????????
		
		while(q.size()!=0){
			node qq=q.front();
			q.pop();
			//???????????? ??????????????¶ 1,1,0
			
			if(done[qq.y][qq.x]==0){
				//?£??????????????????????
				done[qq.y][qq.x]=1;
				//??????????????????????£??????????
				
				if(qq.x==w*2-1 && qq.y==h*2-1){
					ans=(qq.d+2)/2;
					break;
				}
				//??´????????????????????¢
				
				//cout<<"aaaa"<<endl;
				if(map[qq.y][qq.x-1]==0){
					q.push(node(qq.x-1,qq.y,qq.d+1));
				}
				if(map[qq.y-1][qq.x]==0){
					q.push(node(qq.x,qq.y-1,qq.d+1));
				}
				if(map[qq.y][qq.x+1]==0){
					q.push(node(qq.x+1,qq.y,qq.d+1));
				}
				if(map[qq.y+1][qq.x]==0){
					q.push(node(qq.x,qq.y+1,qq.d+1));
				}
			}
			//?????????????????´???0??????????????????
		}
		cout<<ans<<endl;
		
		cin>>w;
		cin>>h;
	}
	
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

struct mo{
  int l,r;
  bool operator<(const mo& o)const{return r < o.r;}
};

int main(){
  
  const int sq = 708;
  int n,Q;
  cin >> n >> Q;
  vector<int> c(n);
  rep(i,n)cin >> c[i];
  rep(i,n)c[i]--;
  vector<vector<pair<mo,int>>> q(sq);
  rep(i,Q){
    int l,r;cin >> l >> r;
    l--;r--;
    int pos = l/sq;
    mo o = {l,r};
    q[pos].push_back(make_pair(o,i));
  }
  rep(i,sq)sort(ALL(q[i]));
  vector<int> res(Q,0);
  rep(i,sq){
    if(q[i].empty())continue;
    int l = q[i][0].first.l,r = q[i][0].first.r;
    vector<int> cnt(n,0);
    int sum = 0;
    for(int j = l;j <= r;j++){
      cnt[c[j]]++;
      if(cnt[c[j]] == 1)sum++;
    }
    for(auto nq : q[i]){
      {
        if(nq.first.l < l){
          for(l = l-1;l >= nq.first.l;l--){
            cnt[c[l]]++;
            if(cnt[c[l]] == 1)sum++;
          }
          l = nq.first.l;
        }
        for(r = r+1;r <= nq.first.r;r++){
          cnt[c[r]]++;
          if(cnt[c[r]] == 1)sum++;
        }
        r = nq.first.r;
      }
      {
        if(nq.first.l > l){
          for(;l < nq.first.l;l++){
            cnt[c[l]]--;
            if(cnt[c[l]] == 0)sum--;
          }
        }
      }
      res[nq.second] = sum;
    }
  }
  rep(i,Q)cout << res[i] << "\n";

  
  

  return 0;
}

Measured memory_bytes: 18496
#include <stdio.h>

int main(){
    int s;
    int m[4];

    scanf("%d",&s);
    for(int i=3;i>=0;i--){
        m[i]=s%10;
        s=s/10;
    }
    if(m[0]*10+m[1]<=12&&m[2]*10+m[3]<=12&&m[0]*10+m[1]>0&&m[2]*10+m[3]>0){
        printf("AMBIGUOUS\n");
    }else if(m[0]*10+m[1]<=12&&m[0]*10+m[1]>0){
        printf("MMYY\n");
    }else if(m[2]*10+m[3]<=12&&m[2]*10+m[3]>0){
        printf("YYMM\n");
    }else{
        printf("NA");
    }
    return 0;
}

Measured memory_bytes: 128
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var inf = 1e9;
  var n = next();
  var a = xArray("[]",4);
  var s = {U:0,R:1,D:2,L:3};
  for(var i = 0; i < n; i++){
    var x = next(), y = next(), U = nextstr();
    a[s[U]].push([x,y,x-y,x+y]);
  }
  var ans = inf;
  for(var i = 0; i < 4; i++){
    var j = i&1;
    a[i].sort((a,b)=>a[j]>b[j]?1:a[j]<b[j]?-1:a[1-j]-b[1-j]);
  }
  for(var k = 0; k < 2; k++){
    var id = 0;
    if(a[k+2].length)for(var i = 0; i < a[k].length; i++){
      while(a[k+2].length > id && a[k+2][id][k] < a[k][i][k])id++;
      while(a[k+2].length > id && a[k+2][id][k] === a[k][i][k] && a[k][i][1-k] > a[k+2][id][1-k])id++;
      if(id === a[k+2].length)break;
      if(a[k][i][k] === a[k+2][id][k]){
        ans = Math.min(ans,a[k+2][id][1-k]-a[k][i][1-k]);
      }
    }
  }
  for(var i = 0; i < 4; i++){
    var j = 1-(i&1);
    a[i].sort((a,b)=>a[3]>b[3]?1:a[3]<b[3]?-1:a[j]-b[j]);
  }
  for(var k = 0; k < 4; k+=2){
    var id = 0;
    if(a[k+1].length)for(var i = 0; i < a[k].length; i++){
      while(a[k+1].length > id && a[k+1][id][3] < a[k][i][3])id++;
      while(a[k+1].length > id && a[k+1][id][3] === a[k][i][3] && a[k][i][1-k/2] > a[k+1][id][1-k/2])id++;
      if(id === a[k+1].length)break;
      if(a[k][i][3] === a[k+1][id][3]){
        ans = Math.min(ans,(a[k+1][id][1-k/2]-a[k][i][1-k/2])*2);
      }
    }
  }
  for(var i = 0; i < 4; i++){
    a[i].sort((a,b)=>a[2]>b[2]?1:a[2]<b[2]?-1:a[0]-b[0]);
  }
  for(var k = 0; k < 2; k++){
    var id = 0;
    if(a[3-k].length)for(var i = 0; i < a[k].length; i++){
      while(a[3-k].length > id && a[3-k][id][2] < a[k][i][2])id++;
      while(a[3-k].length > id && a[3-k][id][2] === a[k][i][2] && a[k][i][0] > a[3-k][id][0])id++;
      if(id === a[3-k].length)break;
      if(a[k][i][2] === a[3-k][id][2]){
        ans = Math.min(ans,(a[3-k][id][0]-a[k][i][0])*2);
      }
    }
  }
  return ans === inf ? "SAFE" : ans*5;
}

Measured memory_bytes: 127804
#include <stdio.h>

#define Max 500000
#define INFTY 1000000000

void  swap(int *x, int *y)
{
    int  buff;
	
	buff = *x;
	*x = *y;  
	*y = buff;
}

void printA(int A[Max], int N) {
	int i;

	for (i = 0; i < N - 1; i++)
		printf("%d ", A[i]);
	printf("%d\n", A[N - 1]);
}

int merge(int A[Max], int left, int mid, int right) {
	int i, j, k;
	int count = 0;

	int n1 = mid - left;
	int n2 = right - mid;

	// L[0...n1], R[0...n2] ?????????
	int L [Max], R[Max];
	for (i = 0; i < n1; i++) L[i] = A[left + i];
	for (i = 0; i < n2; i++) R[i] = A[mid + i];

	L[n1] = INFTY;
	R[n2] = INFTY;
	i = 0;
	j = 0;

	for (k = left; k < right; k++) {
		count++;
		if (L[i] <= R[j])  A[k] = L[i++];
		else  A[k] = R[j++];
	}

	return count;
}

int mergeSort(int A[Max], int left, int right) {
	int count = 0;
	int mid;

	if (left + 1 < right) {
		mid = (left + right)/2;
		count += mergeSort(A, left, mid);
		count += mergeSort(A, mid, right);
		count += merge(A, left, mid, right);
	}

	return count;
}

int main( ) {
	int N, i, count;
	int A[Max];

	scanf("%d", &N);

	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	count = mergeSort(A, 0, N);

	printA(A, N);

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

	return 0;
}

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

#define int long long

int g[10][10];
int d[10][10];

void wf() {
    for(int k=0; k<10; ++k) {
        for(int i=0; i<10; ++i) {
            for(int j=0; j<10; ++j) {
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

/**
vector<int> shortest_path(int s, int t) {
    int cur = s;
    vector<int> res;
    while(cur != t) {
        res.push_back(cur);
        for(int i=0; i<10; ++i) {
            if(i!=cur && g[cur][i]+d[i][t]==d[cur][t]) {
                cur = i;
                break;
            }
        }
    }
}
*/

signed main() {
    for(int i=0; i<10; ++i) {
        for(int j=0; j<10; ++j) d[i][j] = 1e+9;
    }

    int h, w;
    cin >> h >> w;
    for(int i=0; i<10; ++i) {
        for(int j=0; j<10; ++j) {
            int a;
            cin >> a;
            d[i][j] = a;
        }
    }
    wf();
    int ans = 0;
    for(int i=0; i<h; ++i) {
        for(int j=0; j<w; ++j) {
            int a;
            cin >> a;
            if(a<0) continue;
            ans += d[a][1];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
function main(lines) {
  const [N, M] = na();
  
  // 頂点情報構築
  const nodes = Array(N+1).fill(0).map(() => new Set());
  for (let i = 1; i <= M; i++) {
    const [a, b] = na();
    nodes[a].add(b);
    nodes[b].add(a);
  }

  // ルート探索
  let ans = 0;
  searchRoute(nodes[1], [1]);

  // 探索再帰関数
  function searchRoute(node, passed) {
    if (passed.length == N) return ++ans;
    for (let n of node) {
      if (passed.includes(n)) continue;
      searchRoute(nodes[n], passed.concat(n));
    }
  }
  
  return ans;
}


const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 33592
#minimum spaning tree

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
d = [0] + [1e4]*(n-1)
color = [0]*n

# break = 1 ; glay = 2
while 1:
    mincost = pow(10, 4)
    for i in range(n):
        if color[i] != 1 and d[i] < mincost:mincost = d[i];min_key = i
    if mincost == pow(10,4):
        break
    
    color[min_key] = 1
    
    for i in range(n):
        if color[i] != 1 and a[min_key][i] != -1 and d[i] > a[min_key][i]:
            d[i] = a[min_key][i]
            color[i] = 2
#             parent[i] = min_key
print(f"{sum(d)}")


Measured memory_bytes: 5916
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
a,b,c = readInts()
print('Yes' if a < c < b or b < c < a else 'No')


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

int main(){
  int N,W;
  cin >> N >> W;
  int v[100],w[1000];
  for(int i=0;i<N;i++){
    cin >> v[i] >> w[i];
  }
  int DP[N+1][W+1];

  for(int j=0;j<=W;j++){
    DP[0][j] = 0;
  }

  for(int i=1;i<=N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i-1]){
        DP[i][j] = DP[i-1][j];
      }
      else{
        if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1]){
          DP[i][j] = DP[i-1][j];
        }
        else{
          DP[i][j] = DP[i][j-w[i-1]]+v[i-1];
        }
      }
    }
  }
  cout << DP[N][W] << endl;
  return 0;
}



Measured memory_bytes: 7012
# coding: utf-8

class Proc:
    def __init__(self):
        self.s = input().rstrip()

    def is_unbalance(self):
        for i in range(1, len(self.s)):
            if self.s[i] == self.s[i-1]:
                print(str(i-1 + 1) + " " + str(i+1))
                return
            if i < len(self.s) - 1:
                if self.s[i - 1] == self.s[i + 1]:
                    print(str(i-1+1) + " " + str(i+1+1))
                    return
        print("-1 -1")


Proc().is_unbalance()


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

// define
# define loop(i,a,n) for(int i=a;i<n;++i)
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(0);
# define ll long long int 
# define endl "\n"
# define mp make_pair
# define mt make_tuple
# define pb push_back
# define eb emplace_back
# define in insert
# define rev(i,a,n) for(int i=n-1;i>=a;--i)
# define test int T; cin>>T; while(T--)
# define val 32

/* debug */ 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _itRS(_ss); err(_itRS, args); }

void err(istream_iterator<string> itRS) {}
template<typename T, typename... Args>
void err(istream_iterator<string> itRS, T a, Args... args) {
    cerr << *itRS << " = " << a << endl;
    err(++itRS, args...);
}
int dx[8] = {-1,-1,-1, 0, 0, 1, 1, 1}; 
int dy[8] = {-1, 0, 1,-1, 1,-1, 0, 1};


const int MOD=1000000007;



int main()
{   fast
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll state=0;
    for(int i=k;i<n;i++)
    {
        if(a[i]>a[state]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        state++;
    }

    return 0;
}

Measured memory_bytes: 5216
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;

const double EPS = 1e-8;
const double INF = 1e12;

// ½ÊãÌ_ExNg
typedef complex<double> P;
namespace std{
	bool operator< (const P& a, const P& b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

// OÏ
double cross(const P& a, const P& b){
	return imag(conj(a)*b);
}

// àÏ
double dot(const P& a, const P& b){
	return real(conj(a)*b);
}

// ¼ü
struct L : public vector<P> {
	L(const P &a, const P &b){
		push_back(a);
		push_back(b);
	}
};

// ½p`
typedef vector<P> G;

// ~
struct C{
	P p;
	double r;
	C(const P& p, double r) : p(p), r(r) {}
};

int ccw(P a, P b, P c)
{
	b -= a;
	c -= a;
	if(cross(b, c) > 0)   return +1; // ½vñè
	if(cross(b, c) < 0)   return -1; // vñè
	if(dot(b, c) < 0)     return +2; // c--a--b
	if(norm(b) < norm(c)) return -2; // a--b--c
	return 0;
}

// üªÆ_Ìð·»è
bool intersectSP(const L& s, const P& p){
	return abs(s[0]-p) + abs(s[1]-p) - abs(s[1]-s[0]) < EPS;
}

// ¼üãÌ_ÌËe
P projection(const L& l, const P& p){
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}

// üªÆ_Ì£
double distanceSP(const L& s, const P& p){
	const P r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s[0]-p), abs(s[1]-p));
}

char detect(const G& tri, const C& c)
{
	bool inner[3];
	rep(i, 3){
		inner[i] = abs(tri[i] - c.p) - EPS <= c.r;
	}
	if(inner[0] && inner[1] && inner[2])
		return 'b';
	if(inner[0] || inner[1] || inner[2])
		return 'c';
	
	bool tangent = false;
	rep(i, 3){
		L l(tri[i], tri[(i+1)%3]);
		double dist = distanceSP(l, c.p);
		
		if(fabs(dist - c.r) < EPS)
			tangent = true;
		else if(dist < c.r)
			return 'c';
	}
	
	int v = 0;
	rep(i, 3){
		int now = ccw(tri[i], tri[(i+1)%3], c.p);
		if(abs(now) == 2 || now * v < 0)
			return tangent ? 'c' : 'd';
		v = now;
	}
	
	return 'a';
}

int main()
{
	for(;;){
		G tri(3);
		rep(i, 3){
			scanf("%lf%lf", &tri[i].real(), &tri[i].imag());
			if(fabs(tri[i].real()) < EPS)
				break;
		}
		if(fabs(tri[0].real()) < EPS)
			break;
		
		P p;
		double r;
		scanf("%lf%lf%lf", &p.real(), &p.imag(), &r);
		printf("%c\n", detect(tri, C(p, r)));
	}

	return 0;
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
numbers = list(map(int, input().split()))
costs = [2,5,5,4,5,6,3,7,6] # <- 1,2,3,4,5,6,7,8,9
costmap = {}
for num in numbers:
  cost = costs[num-1]
  if cost in costmap and num < costmap[cost]:
    continue
  costmap[cost] = num

from functools import lru_cache
@lru_cache(None)
def recursive(remain=N):
  maxval = costmap[remain] if remain in costmap else 0
  for cost, num in costmap.items():
    if remain > cost:
      val = recursive(remain-cost)
      if val == 0:
        continue
      val = val * 10 + num
      if val > maxval:
        maxval = val
  return maxval
 
print(recursive(N))

Measured memory_bytes: 25060
#include<iostream>//itp14d.cpp
using namespace std;
int main(void)
{
	long long int n,m,i,max=0,min=10000000,all=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>m;
		all=all+m;
		if(max<=m) max=m;
		if(min>=m) min=m;
	}
	if(n==1) cout<<m<<" "<<m<<" "<<m<<endl;
	else cout<<min<<" "<<max<<" "<<all<<endl;
	return 0;
}


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

signed main()
{
    int mod=1e9+7;
    int n,m;
    cin>>n>>m;
    int dp[n+1]={0};
    map<int,int> mm;
    int x;
    for (int i = 0; i < m; ++i) {
        cin>>x;
        mm[x]=1;
    }

    dp[0]=1;

    if(mm[1]==0)
        dp[1]=dp[0];

    for (int i = 2; i <=n ; ++i) {
        if(mm[i]==0)
        {
            dp[i]=(dp[i-1]+dp[i-2])%mod;
        }
    }

    cout<<dp[n];
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll mpow(ll x, ll n){ //x^n(mod mo) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mo;
        x = x*x % mo;
        n = n >> 1;
    }
    return ans;
}
 
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<mint>sum(2e5+10);
    mint dp = 1;

    rep(i,N){
        cin >> A[i];
    }
    sum[A[0]] += 1;
    REP(i,1,N){
        if(A[i] != A[i-1]){
            sum[A[i]] += dp;
            dp = sum[A[i]];
        }
    }
    cout << dp << endl;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int top[3];
int main(){

	int h[10];
	for (int i = 0; i<=9;i++)
		cin >> h[i];
		
	for(int i = 0;i<=9;i++){
		if(top[0] <= h[i]){
			top[2] = top[1];
			top[1] = top[0];
			top[0] = h[i];
		
		}
		else if(top[1] <= h[i]){
			top[2] = top[1];
			top[1] = h[i];
		}
		else if(top[2]<= h[i]){
			top[2] = h[i];
		}
	
	}
	for(int j = 0;j<=2;j++)
		cout << top[j] << endl;
	
	return 0;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  int m = ((n-1)*(n-2))/2;
  
  if(k > m)
  {
    cout << "-1" << endl;
    return 0;
  }
  
  vector<P> res;
  rep(i, n-1) res.emplace_back(P(i, n-1));
  
  int num = -1;
  while((int)res.size()-n+1+k < m)
  {
    num++;
    int a = num/(n-1), b = num%(n-1);
    if(a >= b) continue;
    res.emplace_back(P(a, b));
    
  }
  
  cout << (int)res.size() << endl;
  for(auto x : res) cout << x.first+1 << " " << x.second+1 << "\n";

  return 0;
}

Measured memory_bytes: 384
global cnt
cnt=0

def merge(A,left,mid,right):
    L=A[left:mid]
    R=A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    
    i=0
    j=0
    for k in range(left,right):
        global cnt
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1
            cnt+=mid-left-i

def mergeSort(A,left,right):
    if left+1<right:
        mid=(int)((left+right)/2)
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=list(map(int,input().split()))

mergeSort(S,0,n)
print(cnt)


Measured memory_bytes: 27468
l1 = input().split()
a = int(l1[0])
b = int(l1[1])
if a == b:
    print("Draw")
    exit()
if a == 1:
    print("Alice")
    exit()
if b ==1:
    print("Bob")
    exit()
if a > b:
    print("Alice")
if b > a :
    print("Bob")

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

const int mxN=200005,M=1e9+7;
int n,a,b,tot;
int fat[mxN],inv[mxN];
int mod(int x,int M){int ret=x%M;if(ret<0)ret+=M;return ret;}

int exp(int a,int b,int M){
    if(b==0LL)return 1LL;
    if(b==1LL)return mod(a,M);

    int t=mod(exp(a,b/2,M),M);
    if(b%2==1)return mod(a*mod(t*t,M),M);
    return mod(t*t,M);

}

int C(int n,int k){
    int ans=1LL;
    for(int i=n;i>=n-k+1;i--){
        ans=mod(ans*i,M);
    }
    return mod(ans*inv[k],M);
}

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

    cin>>n>>a>>b;
    fat[0]=inv[0]=1;
    tot=exp(2,n,M);
    for(int i=1;i<mxN;i++){
        fat[i]=(i*fat[i-1]%M);

    }
    inv[mxN-1] = exp(fat[mxN-1],M-2,M);
	for(int i=mxN-2;i>=1;i--){
		inv[i] = (inv[i+1]*(i+1))%M;
	}

    tot=(tot-1-C(n,a)-C(n,b))%M;
    if(tot<0)tot+=M;

    cout<<tot;



}

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

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

    int x;
    x = b - a;
    int total = 0;
    for ( int i=0; i<=x; i++){
        total+=i;
    }
    int ans;
    ans = total - b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <stack>
#define ll long long
using namespace std;

int main() {
	vector<int> v;
	int bn,n;
	int ans = 0,anscall = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> bn;
		v.emplace_back(bn);
	}

	int j = 0,i;
	for (i = 0; i < n - 1; i++) {
		j = i;
		while (j < n-1 && v[j] >= v[j + 1]) {
			anscall++;
			j++;
		}
		ans = max(ans, anscall);
		anscall = 0;
		i = j;
	}
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>

using namespace std;

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

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

int dp[55][55];
int c[55][55];

int check(int x, int y)
{
	if (dp[x][y]) return 0;
	if (c[x][y] == 0) return 0;
	dp[x][y] = 1;
	
	rep(i, 8) {
		int xx = x + dx[i];
		int yy = y + dy[i];
		int take = check(xx, yy);
	}
	return 1;
}

int main(void)
{
	while(1) {
		int w, h;
		cin >> w >> h;
		if (w == 0) break;
		rep(i, 52) rep(j, 52) c[i + 1][j + 1] = 0;
		rep(i, h) rep (j, w) cin >> c[i + 1][j + 1];
		rep(i, 52) rep(j, 52) dp[i][j] = 0;
		rep(i, 55) {
			dp[0][i] = 1;
			dp[i][0] = 1;
			dp[h + 1][i] = 1;
			dp[i][w + 1] = 1;
		}

		int ans = 0;
		rep(i, h) rep(j, w) if (c[i + 1][j + 1]) ans += check(i + 1, j + 1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	int m[100] = {};
	int e[100] = {};
	int j[100] = {};
	string rank[10000] = {};
	int g = 0;
	while (cin >> n&&n) {
		for (int k = 0; k < n; k++) {
			cin >> m[k] >> e[k] >> j[k];
		}
		for (int i = 0; i < n; i++) {
			int s = (m[i] + e[i] + j[i]) / 3;
			g++;
			if ((m[i] == 100)||(e[i] == 100)||(j[i] == 100)) {
				rank[i] = "A";
			}
			else if ((m[i] + e[i]) / 2 >= 90) {
				rank[i] = "A";
			}
			else if (s >= 80) {
				rank[i] = "A";
			}
			else if (s >= 70) {
				rank[i] = "B";
			}
			else if (s >= 50 && m[i] >= 80) {
				rank[i] = "B";
			}
			else {
				rank[i] = "C";
			}
			cout << rank[i] << endl;
		}

	}

	return 0;
	
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int res;
  if(b <= c || d <= a) {
    res = 0;
  } else {
    int mx,mn;
    mx = max(a,c);
    mn = min(b,d);
    res = mn - mx;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    int N;
    cin >> N;
    vi a(N), b(N), c(N);
    rep(i, N) {
        cin >> a[i] >> b[i] >> c[i];
    }
    vi dpa(N+1), dpb(N+1), dpc(N+1);
    rep(i, N) {
        int j=i+1;
        dpa[j] = a[i] + max(dpb[i],dpc[i]);
        dpb[j] = b[i] + max(dpc[i],dpa[i]);
        dpc[j] = c[i] + max(dpb[i],dpa[i]);
    }
    cout << max({dpa[N], dpb[N], dpc[N]}) << '\n';
}

Measured memory_bytes: 2560
// author : Kartikey Tewari
// date: 2020-02-16   18:41:03
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int n;
    cin >> n;
    map<string,int> alpha;
    for (int i=0;i<=n-1;i++)
    {
        string s;
        cin >> s;
        if (alpha.find(s)!=alpha.end())
        {
            alpha[s]++;
        }
        else
        {
            alpha[s]=1;
        }
    }   

    int q=INT_MIN;
    for (auto i=alpha.begin();i!=alpha.end();i++)
    {
        q=max(q,i->second);
    }

    for (auto i=alpha.begin();i!=alpha.end();i++)
    {
        if (i->second==q)
        {
            cout << i->first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 23808
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast_io cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define MOD 1000000007
using namespace std;

int main(){
	fast_io;
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans;
	ans = n*a;
	ans = min(ans,b);
	cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
  int n,j;
  int sum=0;
  scanf("%d",&n);
  const int k=n;

  for(int i=0;n>=1;i++){
    j=n%10;
    n/=10;
    sum+=j;
    //printf(" %d番目のsumは%d ",i,sum);
  }
  //printf(" %d",sum);
  if(k%sum==0){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}


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


int main(){
	int n,a;
	vector<int> v;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		v.push_back(a);
	}
	
	int sum,sum2,ans=1e9;
	for(int i=0;i<n;i++){
		sum=sum2=0;
		for(int j=0;j<n;j++){
			if(i<=j) sum+=v[j];
			else sum2+=v[j];
		}
		ans=min(ans,abs(sum-sum2));
	}
	
	cout << ans << endl;
	return 0;
}

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

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

    queue<ll> que;
    for (ll i = 1; i <= 9; i++)
    {
        que.push(i);
    }

    ll counter = 0;
    ll ans;
    while (!que.empty())
    {
        ll v = que.front(); que.pop();
        if(++counter==K){
            ans = v;
            break;
        } 
        if(v%10==0){
            que.push(v*10);
            que.push(v*10+1);
        } else if (v%10==9){
            que.push(v*10+9-1);
            que.push(v*10+9);
        } else {
            que.push(v*10+(v%10)-1);
            que.push(v*10+(v%10));
            que.push(v*10+(v%10)+1);
        }
    }
    cout << ans << endl;
        
}

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

int main()
{
    long long int a,b,c,d,k,gcd,lcm,m,n,o,l,p;
    cin>>a>>b>>c>>d;
    n=c;
    o=d;
    while(d != 0){
        m=d;d=c%d;
        c=m;
    }
    gcd=c;
    lcm=n*o/gcd;

    if(a%n==0){
        k=b/n-a/n+1;
    }
    else{
        k=b/n-a/n;
    }
    if(a%o==0){
        l=b/o-a/o+1;
    }
    else{
        l=b/o-a/o;
    }
    if(a%lcm==0){
        p=b/lcm-a/lcm+1;
    }
    else{
        p=b/lcm-a/lcm;
    }

    cout<<b-a+1-k-l+p<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    if (x==3||x==5||x==7)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}


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

namespace ABC124a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            if(Math.Max(a,b)-1 > Math.Min(a, b))
            {
                Console.WriteLine(Math.Max(a, b) * 2 - 1);
            }
            else
            {
                Console.WriteLine(a + b);
            }

        }
    }
}


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

vector<int> A;

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x;
        cin >> x;
        A.push_back(x);
    }
    sort(A.begin(), A.end());

    for (int i = A[1]; i > 0; i--)
    {
        int flag = 0;
        for (int k = 0; k < N; k++)
        {
            if (A[k] % i)
                flag++;
            if (flag == 2)
                break;
        }
        if (flag < 2)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 892
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
bool bo[114514];
int v[114514];
void Sieve() {
    rep(i, 114514)bo[i]=true;
    bo[0]=bo[1]=false;
    for(int i = 2;i<114514;i++) {
        if(bo[i]) {
            for(int j = i*2;j<114514;j+=i) bo[j]=false;
        }
    }
}
signed main() {
    Sieve();
    rep1(i, 114510) {
        if(bo[i]&&bo[(i+1)/2]) v[i]++;
        v[i]+=v[i-1];
    }
    int q;cin >> q;
    rep(i, q) {
        int a,b;cin >> a >> b;
        cout << v[b]-v[a-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,C,X,Y;cin>>A>>B>>C>>X>>Y;C*=2;
    int ans;
    if(X>=Y){
        ans=X*C;
        ans=min(ans,C*Y+(X-Y)*A);
        ans=min(ans,A*X+B*Y);
    }
    else{
        ans=Y*C;
        ans=min(ans,C*X+(Y-X)*B);
        ans=min(ans,A*X+B*Y);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    MOD = 10 ** 9 + 7
    S = input()
    N = len(S)
    mod13 = [0] * 13
    mod13[0] = 1
    exponent = 1
    for i in range(1, N + 1):
        mod13_new = [0] * 13
        c = S[-i]
        if c == "?":
            for n in range(10):
                m = n * exponent % 13
                for r in range(13):
                    mod13_new[(r + m) % 13] += mod13[r]
        else:
            for r in range(13):
                mod13_new[(r + int(c) * exponent) % 13] = mod13[r]
        exponent = exponent * 10 % 13
        for r in range(13):
            mod13_new[r] %= MOD
        mod13 = mod13_new
    print(mod13[5])

if __name__ == "__main__":
    main()

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

const int DIM = 200005;

int arr[DIM], cnt[DIM], psm[DIM];

int main(void)
{
    int n, m;
    cin >> n >> m;
    
    for (int i = 1; i <= n; ++i)
        cin >> arr[i], ++cnt[arr[i]];
    
    for (int i = 1; i <= n; ++i)
        for (int j = i - cnt[i] + 1; j <= i; ++j)
            ++psm[j];
    
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += (psm[i] == 0);
    
    for (int i = 1; i <= m; ++i) {
        int x, z, y;
        cin >> x >> z; y = arr[x]; arr[x] = z;
        
        if (y - cnt[y] + 1 >= 1) {
            --psm[y - cnt[y] + 1];
            if (psm[y - cnt[y] + 1] == 0)
                ++ans;
        }
        cnt[y]--;
        
        ++cnt[z];
        if (z - cnt[z] + 1 >= 1) {
            if (psm[z - cnt[z] + 1] == 0)
                --ans;
            ++psm[z - cnt[z] + 1];
        }
        
        cout << ans << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3712
import sys
h,w = map(int,input().split())
matrix = [[0]*(w+2) for _ in range(h+2)]
for hi in range(h):
    all_inp = input()
    for i,a in enumerate(all_inp):
        matrix[hi+1][i+1]= 1 if a == '#' else 0
#print(matrix)
for ri,row in enumerate(matrix):
    for ci,column in enumerate(row):
        if column == 1:
            if row[ci-1] == 0 and row[ci+1] == 0 and matrix[ri-1][ci] == 0 and matrix[ri+1][ci] == 0:
                print('No')
                sys.exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int mae=(s[0]-'0')*10+s[1]-'0',usiro=(s[2]-'0')*10+s[3]-'0';
  if(mae>12 or mae==0){
    if(usiro>12 or usiro==0){
      cout << "NA\n";
    }else{
      cout << "YYMM\n";
    }
  }else{
    if(usiro>12 or usiro==0){
      cout << "MMYY\n";
    }else{
      cout << "AMBIGUOUS\n";
    }
  }
  return 0;
}



Measured memory_bytes: 256
def terminal_str(s):
    for i in range(1, len(s)-1):
        if s[i-1] != s[i+1]:
            return 0
    return 1

def solve(s):
    if s[0] == s[len(s)-1]:
        if len(s)%2:
            return 0
        else:
            return 1
    return len(s)%2

s = input()

if terminal_str(s):
    print('Second')
else:
    d = {}
    for x in s:
        d[x] = d.pop(x, 0)+1

    if len(d) == 3:
        if 1 in list(d.values()):
            if d.get(s[0]) == 1 or d.get(s[len(s)-1]) == 1:
                if solve(s):
                    print('First')
                else:
                    print('Second')
            else:
                print('First')        
        else:
            if solve(s):
                print('First')
            else:
                print('Second')
    else:
        if solve(s):
            print('First')
        else:
            print('Second')


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

int main() {
  int N;
  int X;
  int T;
  cin >> N >> X >> T;
  
  int U=0;
  
  if (N%X == 0) {
    U = N/X*T;
  }
  else {
    U = (N/X +1)*T;
  } 
  cout << U << endl;
}

Measured memory_bytes: 3620
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//abc133D
int main(void) {
  long long n, k, i, cou=0, tmp=0;
  scanf("%lld", &n);
  long long a[n];
  for(i=0; i < n; i++){
    scanf("%lld",&a[i]);
    tmp=2*a[i]-tmp;
  }
  tmp/=2;
  for(i=0; i < n; i++){
    printf("%lld ",tmp);
    tmp=2*a[i]-tmp;
  }
}


Measured memory_bytes: 2048
//   __      __       .__           .____________                   __________        __ ________   __                 
//  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
//  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define PI 3.14159265358979323846

using namespace std;

void solve()
{
    ll n, s;
    cin >> n >> s;
    ll a[n + 1];
    for(ll i = 1; i <= n; i++)
        cin >> a[i];
    ll dp[n + 1][s + 1];
    ll inf = 998244353;
    for(ll i = 0; i <= n; i++)
        for(ll j = 0; j <= s; j++)
            dp[i][j] = 0;
    dp[0][0] = 1;
    for(ll i = 1; i <= n; i++)
        for(ll j = 0; j <= s; j++)
        {
            dp[i][j] = (dp[i][j] + 2 * dp[i - 1][j]) % inf;
            if(j >= a[i])
                dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % inf;
        }
    /*for(ll i = 0; i <= s; i++)
    {
        for(ll j = 0; j <= n; j++)
            cout << dp[j][i] << " ";
        cout << endl;
    }*/
    cout << dp[n][s] << endl;
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 74012