akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <climits>
#include <utility>
#include <map>
#include <set>
#include <complex>
#include <numeric>

#include <time.h>
#include <float.h>

#define loop(i, start, end) for(i = (start); i <= (end); i++)
#define loopIterators(it, vec) for(it = (vec).begin(); it != (vec).end(); it++)
#define loopIteratorsRev(it, vec) for(it = (vec).rbegin(); it != (vec).rend(); it++)
#define loopRev(i, start, end) for(i = (start); i >= (end); i--)
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCases(t) cin >> t; while(t--)
#define PN(n) cout << (n)
#define PN1(n) cout << (n) << " "
#define PN2(a, b) cout << (a) << " " << (b) << " "
#define PNN1(n) cout << (n) << endl
#define PNN2(a, b) cout << (a) << " " << (b) << endl
#define PNN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define PrintArray(ar, n) for(i = 0; i < n; i++) cout << ar[i] << " "; cout << endl
#define PrintObject(ar, it) loopIterators(it, ar) cout << *it << " "; cout << endl
#define PrintMap(map, it) loopIterators(it, map) PNN2(it->first, it->second)
#define sz(a) sizeof(a)
#define IN1(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define ALL(s) s.begin(), s.end()
#define SWAP(a, b, c) c = a; a = b; b = c
#define STRSP(s) scanf("%[^\n]%*c", s)
#define ENTER PNN1("");
#define MOD7 1000000007
#define MOD9 10000009
#define MAX 1000000000
#define llPair std::pair<lli, lli>
#define iiPair std::pair<int, int>
#define ONLINE_JUDGE

typedef long long int lli;
typedef long int li;
typedef unsigned long long int ulli;
typedef long double ld;

using namespace std;

int main(void){
	FLASH

	#ifndef ONLINE_JUDGE
		freopen("input-stream.txt", "r", stdin);
		freopen("output-stream.txt", "w", stdout);
	#endif

	int a, b;
	IN2(a, b);
	int ans = a * (a - 1) / 2;
	ans += b * (b - 1) / 2;

	PNN1(ans);

	#ifndef ONLINE_JUDGE
		fclose(stdin);
		fclose(stdout);
	#endif

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,b,i,j;
  int a[9],f[9],c[8];
  for(i=0;i<9;i++)
    cin >> a[i];
  fill(f,f+9,0);
  cin >> n;
  for(j=0;j<n;j++){
    cin >> b;
    for(i=0;i<9;i++)
      if(a[i]==b)
        f[i]=1;
  }
  for(i=0;i<3;i++)
    c[i]=f[i*3]+f[i*3+1]+f[i*3+2];
  for(i=0;i<3;i++)
    c[i+3]=f[i]+f[i+3]+f[i+6];
  c[6]=f[0]+f[4]+f[8];
  c[7]=f[2]+f[4]+f[6];
  if(*max_element(c,c+8)==3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d %d %d', $n, $m, $l);

$A = array();
for ($i = 0; $i < $n; $i++) {
    $line = trim(fgets(STDIN));
    $A[$i] = explode(' ', $line);
}

$B = array();
for ($i = 0; $i < $m; $i++) {
    $line = trim(fgets(STDIN));
    $B[$i] = explode(' ', $line);
}

$C = array();
for ($i = 0; $i < $n; $i++) {
    $C[$i] = array_fill(0, $l, 0);
}

foreach ($A as $i => $a) {
    foreach ($B as $j => $b) {
        foreach ($b as $k => $n) {
            $C[$i][$k] += $n * $a[$j];
        }
    }

    echo implode(' ', $C[$i]), PHP_EOL;
}

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

int main() {
  int N;
  cin >> N;
  
  if (N < 10){
    cout << N << endl;
  }
  else if (N < 100) {
    cout << 9 << endl;
  }
  else if (N < 1000) {
    cout << N - 90 << endl;
  }
  else if (N < 10000) {
    cout << 909 << endl;
  }
  else if (N < 100000) {
    cout << N - 9090 << endl;
  }
  else {
    cout << 90909 << endl;
  }
  
}

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

int main(){
    int N,K;
    cin >> N >> K;
    int a[50];
    int ans = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    
    sort(a,a + N, greater<int>());

    for(int i = 0; i < K ; i++){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<int(n);i++)

char table[10][10];
char digit[10000];

string toString(int x)
{
  string s = to_string(x);
  string t = "";
  REP(i,4-s.size()) t += "0";
  return t+s;
}

char getDigit(string s)
{
  return table[table[table[table[0][s[0]-'0']-'0'][s[1]-'0']-'0'][s[2]-'0']-'0'][s[3]-'0'];
}

bool check(string s)
{
  return table[digit[stoi(s.substr(0,4))]-'0'][s[4]-'0'] == '0';
}

int main()
{
  REP(i,10) REP(j,10) cin >> table[i][j];
  vector<bool> state(10000,false);
  REP(i,10000) digit[i] = getDigit(toString(i));
  REP(i,10000){
    if(state[i]) continue;
    string s = toString(i)+digit[i];
    string s_error;
    REP(j,5){
      REP(k,10){
        s_error = s;
        s_error[j] = to_string(k)[0];
        if(s == s_error) continue;
        if(check(s_error)) state[i] = state[stoi(s_error.substr(0,4))] = true;
      }
    }
    REP(j,4){
      s_error = s;
      swap(s_error[j],s_error[j+1]);
      if(s == s_error) continue;
      if(check(s_error)) state[i] = state[stoi(s_error.substr(0,4))] = true;
    }
  }
  cout << count(begin(state),end(state),true) << endl;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
bool cmp(string s1 , string s2)
{
    string temp1 = s1 + s2;
    string temp2 = s2 + s1;
    return temp1 < temp2;
}

int main()
{
   int n , l;
   cin>>n>>l;
   
   std::vector<string> v;
   for(int i = 0;i<n;i++)
   {
       string s;
       cin>>s;
       v.push_back(s);
   }
   sort(v.begin() , v.end() ,cmp);
   
   string res = "";
   for(auto it : v)
   res += it;
   
   cout<<res<<"\n";
        
    return  0;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int Maxn = 1e5+7;

int n, ans, x[Maxn];

int gcd(int a, int b)
{
    return b == 0 ? a : gcd(b, a%b);
}

int main()
{
    scanf("%d%d", &n, x);
    for(int i = 1; i <= n; ++i)
        scanf("%d", x+i);
    sort(x, x+n+1);
    ans = x[1]-x[0];
    for(int i = 2; i <= n; ++i)
        ans = gcd(ans, x[i]-x[i-1]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

template<class T>
T min(T a, T b) {
    return (a < b) ? a : b;
}

template<class T>
T max(T a, T b) {
    return (a > b) ? a : b;
}

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

    int count = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (h >= K) count++;
    };

    cout << count;

    return 0;
}



Measured memory_bytes: 256
n,m = map(int, input().split())
sc = list(tuple(map(int, input().split())) for _ in range(m))
sc = set(sc)



ans = [0]*n
cor = [0]*n
for s,c in list(sc):
    s = s-1
    ans[s] = c
    cor[s] += 1

for s,c in list(sc):
    s = s-1
    if cor[s] > 1:
        print(-1)
        exit()

if m == 0:
    if n == 1:
        print(0)
        exit()
    print(10**(n-1))
    exit()

if n == 1:
    print(ans[0])
    exit()

if ans[0] == 0 and cor[0] == 1:
    print(-1)
    exit()

if ans[0] == 0 and cor[0] == 0:
    ans[0] = 1

j = 0
for a in range(n):
    j += ans[a]*(10**(n-1-a))

print(j)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    int n; cin >> n;
    int a, b, c; cin >> a >> b >> c;
    vector<int> x(n); repeat (i, n) cin >> x[i];
    sort(x.begin(), x.end());
    
    int ans = 1e9;
    
    do {
        repeat (i, n) {
            repeat_from (j, i + 1, n) {
                repeat_from (k, j + 1, n) {
                    int t = 0;
                    int at = accumulate(&x[0], &x[i + 1], 0);
                    int bt = accumulate(&x[i + 1], &x[j + 1], 0);
                    int ct = accumulate(&x[j + 1], &x[k + 1], 0);
                    t = abs(at - a) + abs(bt - b) + abs(ct - c);
                    t += (10 * (i - 0));
                    t += (10 * (j - i - 1));
                    t += (10 * (k - j - 1));
                    ans = min(ans, t);
                    //if (t == 32) {vdump(x); dump(i); dump(j); dump(k); dump(at); dump(bt); dump(ct); el; el;}
                }
            }
        }
    } while (next_permutation(x.begin(), x.end()));
             
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ans = true;
    rep(i, a + b + 1) {
        if(i == a) {
            if(s[i] != '-') ans = false;
        } else {
            if(s[i] == '-') ans = false;
        }
    }
    if(ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

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

using namespace std;
typedef long double ld;
const ld eps = 1e-8, INF = 1e+8;

int main() {
  int h,w;
  cin>>h>>w;
  vector<string> t(h);
  REP(i,h)cin>>t[i];
  reverse(begin(t),end(t));
  map<ld,int> s;
  REP(i,h-1)REP(j,w-1) {
    if (t[i][j] == t[i+1][j+1] && t[i+1][j] != t[i][j+1]) {
      if (t[i][j] == t[i][j+1]) ++s[((ld)i+1)/(j+1)];
      else --s[((ld)i+1)/(j+1)];
    }
  }
  REP(i,h-1) {
    if (t[i][0] != t[i+1][0]) {
      if (t[i][0] == '#') --s[INF];
    }
  }
  REP(i,h-1) {
    if (t[i][w-1] != t[i+1][w-1]) {
      if (t[i][w-1] == '.') ++s[((ld)i+1)/w];
    }
  }
  REP(i,w-1) {
    if (t[0][i] != t[0][i+1]) {
      if (t[0][i] == '#') ++s[0];
    }
  }
  REP(i,w-1) {
    if (t[h-1][i] != t[h-1][i+1]) {
      if (t[h-1][i] == '.') --s[((ld)h)/(i+1)];
    }
  }
  if (t[h-1][0] == '#') --s[INF];
  if (t[0][w-1] == '#') ++s[0];
  int sum = 0;
  int mxsum = 0;
  for (auto p : s) {
    int addv;
    tie(ignore, addv) = p;
    sum += addv;
    mxsum = max(mxsum, sum);
  }
  cout << (mxsum + 1) << endl;
  return 0;
}

Measured memory_bytes: 6804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const ll inf = 0x3f3f3f3f3f;
const ll mod=1e9+7;
ll a[maxn],n;
ll b[maxn];
map<ll,ll>mp;

int main(){
	// ll x,y;
	// cin>>x>>y;
	// ll n;
	// cin>>n;
	// 	 if(n%6==0) cout<<(x+y+mod)%mod;
	// else if(n%6==1) cout<<(x+mod)%mod;
	// else if(n%6==2) cout<<(y+mod)%mod;
	// else if(n%6==3) cout<<(y-x+mod)%mod;
	// else if(n%6==4) cout<<(mod-x)%mod;
	// else if(n%6==5) cout<<(y+mod)%mod;
	ll a,b,c;
	cin>>a>>b>>c;
	ll t=b/a;
	cout<<min(t,c);
}

Measured memory_bytes: 256
s = input()

if s == "SSS":
    print(0)
elif s == "SSR":
    print(1)
elif s == "SRS":
    print(1)
elif s == "SRR":
    print(2)
elif s == "RSS":
    print(1)
elif s == "RSR":
    print(1)
elif s == "RRS":
    print(2)
else:
    print(3)

Measured memory_bytes: 9000
#include <cstdio>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(0 <= x - r && W >= x + r){
      if(0 <= y - r && H >= y + r){printf("Yes\n");}
      else{printf("No\n");};}
      else{printf("No\n");};  
    return 0;
}



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

int main() {
  int n; cin >> n;
  vector<int> b(n), ans;
  rep(i,n) {
    cin >> b[i];
    b[i]--;
  }
  while(!b.empty()) {
    for (int i = b.size()-1; i>=-1; i--) {
      if (i==-1) {
        cout << -1 << endl;
        return 0;
      }
      if (i == b[i]) {
        ans.push_back(i);
        b.erase(b.begin() + i);
        break;
      }
    }
  }
  for (int i = n-1; i>=0; i--) {
    cout << ans[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define INF -1
using namespace std;

int main()
{
	string tmp, cut;
	int ans = 100000;

	cin >> tmp;

	for (int i = 0; i < tmp.size() - 2; i++) {
		cut = tmp.substr(i, 3);
		if (ans > abs(753 - atoi(cut.c_str()))) {
			ans = abs(753 - atoi(cut.c_str()));
		}
	}

	printf("%d", ans);

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int k = 1;
    stack<int> s;
    rep(i, n) {
        if (a[i] == k) {
            s.push(k);
            k++;
        }
    }
    if (s.empty()) {
        cout << -1 << endl;
    } else {
        cout << (n - s.size()) << endl;
    }
}

Measured memory_bytes: 4840
#include <iostream>

using namespace std;

int main()
{
  /******input******/
  int N;
  cin >> N;
  int A[2][N];
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < N; j++){
      cin >> A[i][j];
    }
  }
  /******input******/


  /******main******/
  int ans = 0;
  for(int turn = 0; turn < N; turn++){
    int sum = 0;
    for(int k = 0; k <= turn; k++){
      sum += A[0][k];
    }
    for(int k = turn; k < N; k++){
      sum += A[1][k];
    }
    ans = max(ans, sum);
  }

  cout << ans << "\n";
  /******main******/


  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {

	A := make([]int, 200010)
	var n int
	fmt.Scan(&n)
	
	last_idx := -1
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	for i:=0; i<n; i++ {
		
		scanner.Scan()
		query, _ := strconv.Atoi(scanner.Text())

		switch query {
		case 0 :
			last_idx++
			scanner.Scan()
			x, _ := strconv.Atoi(scanner.Text())
			A[last_idx] = x
		case 1 :
			scanner.Scan()
			p, _ := strconv.Atoi(scanner.Text())
			fmt.Println(A[p])
		case 2 :
			A[last_idx] = 0
			last_idx--
		}	
	}
}



Measured memory_bytes: 5388
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def primes(n):
    """ 
    Input n>=6, Returns a list of primes, 2 <= p < n 
    6以上の数であれば p (素数) <= n のlistを返す 
    :param int n:
    :rytpe list:
    """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
        if sieve[i]:
            k=3*i+1|1
            sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

#solve
def solve():
    x = II()
    p = primes(10 ** 6)
    print(p[bisect_left(p, x)])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 48624
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

int n, A[MAXN];

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    for (int i = 1; i < n; i++) {
        if (A[i - 1] > A[i] || i == 1 || A[i - 1] > A[i - 2]) {
            A[i - 1]--;
        }
    }

    for (int i = 1; i < n; i++) {
        if (A[i - 1] > A[i]) {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");

    return 0;
}

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






typedef long long ll;
vector<ll> build(ll K) {
    vector<ll> ans;

    ll d = K % 50;
    rep(i, 0, 50 - d) ans.push_back(49 - d);
    rep(i, 0, d) ans.push_back(50);

    ll a = K / 50;
    rep(i, 0, 50) ans[i] += a;

    return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    ll K; cin >> K;

    auto ans = build(K);
    int n = ans.size();
    printf("%d\n", n);
    rep(i, 0, n) {
        if (i) printf(" ");
        printf("%lld", ans[i]);
    }
    printf("\n");
}

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

int main() {
    int n; cin >> n;
    //cout << n / 2-1 << endl;
    int ans = 0;
    int tmp = n%2? n/2+1 : n/2;
    for (int i = 1; i < tmp; i++)
        ans++;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;

int main(){
    int H,W,h,w;
    cin >> H >> W >> h >> w ;
    cout << H*W-h*W-H*w+h*w << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

int main() {
    ll N, K;
    cin >> N >> K;
    set<ll> A;
    ll m = 0;
    rep(i, N) {
        ll a;
        cin >> a;
        A.insert(a);
        m = max(m, a);
    }
    ll g = m;
    for(ll x : A)
        g = gcd(x, g);
    if((K % g == 0 && K <= m) || A.count(K)) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String S = scanner.next();
        String T = scanner.next();

        for(int i = 0; i < N; i++) {
            System.out.print(S.charAt(i));
            System.out.print(T.charAt(i));
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b && b==c && c==a) || (a!=b && b!=c && c!=a))
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 3600
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    T, A = map(int, sys.stdin.readline().split())
    H = list(map(int, sys.stdin.readline().split()))
    ans = H[0]
    ansi = 1
    for i, h in enumerate(H):
        temper = T - h * 0.006
        if abs(A - ans) > abs(A - temper):
            ans = temper
            ansi = i + 1
    print(ansi)


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

typedef struct {
  string str;
  int t;
} P;

int n,head,tail;
P Q[100001];

void init() { //初期化
  head = 0,tail = n;
}

int isEmpty() { //空か確認
  return head == tail;
}

int isFull(){ //満杯かどうか確認
  return head == (tail + 1)   % 100000;
}

void enqueue( P x ) { //キューに入れる
  if ( isFull() ) cout << "overflow" << endl;
  Q[tail] = x;
  if ( tail + 1 == 100000 ) tail = 0;
  else tail++;
}

P dequeue() { //キューに追加
  if ( isEmpty() ) cout << "underflow" << endl;
  P x = Q[head];
  if ( head + 1 == 100000 ) head = 0;
  else head++;
  return x;
}

int min( int a, int b ) { //最小値
  if ( a < b ) return a;
  else return b;
}

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

  for ( int i = 0; i < n; i++ ) cin >> Q[i].str >> Q[i].t;

  int time = 0;
  P u;

  while ( head != tail ) {
    u = dequeue();
    int minn = min(q,u.t);
    u.t -= minn; //qかu.tの小さい値の方をひく
    time += minn; //時間を加算
    if ( u.t > 0 ) enqueue(u); // 残っていたらキューに追加
    else cout << u.str << " " << time << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define PI 3.141592653589793
using namespace std;
int main(){
  double a, b, x; cin >> a >> b >> x;
  double k=(2*a*a*b-2*x)/(a*a*a);
  if(b/2>x/(a*a)){
    k=(2*x)/(a*b*b);
    double ans = 90-atan(k)*180.0/PI;
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
  }  
  double anss = atan(k)*180.0/PI;
  cout << fixed << setprecision(10);
  cout << anss << endl;
}
  

Measured memory_bytes: 256
import java.util.*;

class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int N = sc.nextInt();
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i=0; i<N; i++) {
			list.add(sc.nextInt());
		}
		int d = 0;
		while(true) {
			if(!list.contains(X-d)) {
				System.out.println(X-d);
				break;
			}
			if(!list.contains(X+d)) {
				System.out.println(X+d);
				break;
			}
			d ++;
		}
		
		
	}

}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = acos(-1.0);
const ll LINF = (ll)1e18 + 5;
const int INF = (int)1e9 + 5;

template<class T>
T sqr(T x) { return x * x; }

template<class T>
T abs(T x) { return x < 0 ? -x : x; }

template<class T>
ll round(T x) { return x < 0 ? x - 0.5 : x + 0.5; }

template<class T>
bool chmin(T & x, const T & y) {
	if (y < x) {
		x = y;
		return true;
	}
	return false;
}

template<class T>
bool chmax(T & x, const T & y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}


template<class P, class Q>
ostream & operator <<(ostream & os, const pair<P, Q> & p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template<class T>
ostream & operator <<(ostream & os, const vector<T> & v) {
	bool was = false;
	os << "{";
	for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

template<class T>
ostream & operator <<(ostream & os, const set<T> & v) {
	bool was = false;
	os << "{";
	for (typename set<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

template<class T>
ostream & operator <<(ostream & os, const multiset<T> & v) {
	bool was = false;
	os << "{";
	for (typename multiset<T>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

template<class P, class Q>
ostream & operator <<(ostream & os, const map<P, Q> & v) {
	bool was = false;
	os << "{";
	for (typename map<P, Q>::const_iterator it = v.begin(); it != v.end(); it++) {
		if (was) {
			os << ", ";
		}
		else {
			was = true;
		}
		os << *it;
	}
	os << "}";
	return os;
}

#define all(x) (x).begin(), (x).end()

template<class T>
T nextInt() {
	ll x = 0;
	bool p = false;
	char c;
	do {
		c = getchar();
	} while (c <= 32);
	if (c == '-') {
		p = true;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return (p ? -x : x);
}

int main() {
	srand(time(0));

#ifdef LOCAL
	//gen();
	freopen("input.txt", "r", stdin);
#else
	
#endif

	int n;
	cin >> n;
	vector<int> a(n);

	for (int & x : a) {
		cin >> x;
		x--;
	}

	int res = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > i && a[a[i]] == i) res++;
	}

	cout << res << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
	int n, m, l;
	long matA[100][100] = {};
	long matB[100][100] = {};
	long ans[100][100] = {};
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> matA[i][j];
	for (int i = 0; i < m; i++)
		for (int j = 0; j < l; j++)
			cin >> matB[i][j];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				ans[i][j] += matA[i][k] * matB[k][j];
			}
			cout << ans[i][j];
			if (j != l -1)
				cout << " ";
			if (j == l -1)
				cout << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3332
#include <cstdio>

const int N=41;
int a[N],mx=-1,t;
long long n;

int main(){
	scanf("%lld",&n);
	for(int i=40;~i;--i)
		if((n>>i)&1)
			if(~mx)a[i]=mx+(++t);
			else mx=i;
	printf("%d\n",mx+mx+2+t+t);
	if(a[0])printf("%d ",a[0]);
	for(int i=1;i<=mx;++i){
		printf("%d ",i);
		if(a[i])printf("%d ",a[i]);
	}
	for(int i=1;i<=mx+t;++i)printf("%d ",i);
	printf("%d %d\n",mx+t+1,mx+t+1);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    double ph[n]; 
    for(int i = 0; i < n; i++){
        cin >> ph[i];
    }
    vector<vector<double>>dp(n,vector<double>(n + 1));
    
    dp[0][0] = 1 - ph[0];
    dp[0][1] = ph[0];
    for(int i = 1; i < n; i++){
        for(int j = 0; j <= (i + 1); j++){
            dp[i][j] = (1 - ph[i]) * dp[i - 1][j];
            if(j > 0)
                dp[i][j] += ph[i] * dp[i - 1][j - 1];
        }
    }
    double ans = 0;
    int min_heads = ceil(n/2.0);
    for(int i = min_heads; i <= n; i++){
        ans += dp[n - 1][i];
    }
    cout << setprecision(10) << ans << endl;
}

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

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

typedef int64_t ll;

const int INF = 1e9;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

// ref: http://www.prefield.com/algorithm/graph/bellman_ford.html
bool shortestPath(const Graph g, int s, vector<Weight> &dist) {
  // Graph g has negative loop iff return false
  // O(VE)
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  bool negative_cycle = false;
  REP(k, n + 1) REP(i, n) for(Edge e : g[i]) {
    if (dist[e.dst] > dist[e.src] + e.weight) {
      dist[e.dst] = dist[e.src] + e.weight;
      if (k == n) {
        dist[e.dst] = -INF;
        negative_cycle = true;
      }
    }
  }
  return !negative_cycle;
}

vector<vector<int>> to(2501);
vector<vector<int>> ot(2501);
vector<bool> reachable1(2501);
vector<bool> reachableN(2501);

void dfs1(int u) {
  if(reachable1[u]) return;
  reachable1[u] = true;
  for (int v : to[u]) {
    dfs1(v);
  }
}

void dfsN(int u) {
  if(reachableN[u]) return;
  reachableN[u] = true;
  for (int v : ot[u]) {
    dfsN(v);
  }
}

int main(){
  int N, M, P;
  cin >> N >> M >> P;
  Edges edges;
  REP(i, M) {
    int A, B, C;
    cin >> A >> B >> C; --A; --B;
    edges.emplace_back(Edge(A, B, P - C));
    to[A].push_back(B);
    ot[B].push_back(A);
  }

  dfs1(0);
  dfsN(N - 1);
  vector<bool> reach(N);
  REP(i, N) reach[i] = reachable1[i] & reachableN[i];

  Graph g(N);
  REP(i, M) {
    if (!reach[edges[i].src] || !reach[edges[i].dst]) continue;
    g[edges[i].src].push_back(edges[i]);
  }

  vector<Weight> dist;
  bool normal = shortestPath(g, 0, dist);

  int ret = -1;
  if (normal) {
    ret = max(0, -dist[N - 1]);
  }

  cout << ret << endl;
  return 0;
}



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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

const int N = 2e5 + 5;

ll n, q, d[N];
bool vis[N];
vector<ll> G[N];

void dfs(int u, ll sum = 0) {
    vis[u] = true;
    for (auto to : G[u]) 
        if (!vis[to]) 
            dfs(to, sum + d[u]);
    d[u] += sum;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n >> q;

    for (int i = 0; i < n - 1; ++i) {
        ll u, v; cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    while (q--) {
        ll x, p; cin >> x >> p;
        d[x] += p;
    }

    dfs(1);

    for (int i = 1; i <= n; ++i)
        cout << d[i] << " \n"[i == n];
}

Measured memory_bytes: 24448
def gen_switch(i, n):
    ret = []
    str_bin = format(i, '011b')
    for k in range(n):
        ret.append(int(str_bin[-k-1]))
    ret.reverse()
    return ret


input_line = input()
splitted_line = input_line.split(" ")
n = int(splitted_line[0])
m = int(splitted_line[1])


my_mtx = []

for i in range(m):
    my_list = [0] * n
    splitted_line = input().split(" ")

    for j in range(len(splitted_line)):
        if j != 0:
            my_list[int(splitted_line[j])-1] = 1

    my_mtx.append(my_list)

splitted_line = input().split(" ")
my_list = []

for item in splitted_line:
    my_list.append(int(item))


count = 0

# print(my_list)                                                                                                                                                                                                              

for i in range(2 ** n):
    my_switch = gen_switch(i, n)
    for j in range(m):
        my_sum = 0
        for k in range(len(my_switch)):
            my_sum = my_sum + (my_switch[k] * my_mtx[j][k])
        if my_sum % 2 != my_list[j]:
            break
        if j == m - 1:
            count = count + 1

print(count)


Measured memory_bytes: 3064
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):
    return map(type,input().split())

#%%code

def resolve():
    
    S=input()
    index=0
    ans=0
    for i in range(len(S)):
        if S[i]=="W":
            ans+=i-index
            index+=1
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 3500
n,m=map(x->parse(Int,x),split(readline()))
c=zeros(m,1)
ans=0
for _=1:n
	b=map(x->parse(Int,x),split(readline()))
	for i=2:b[1]+1
		c[b[i]]+=1
		if c[b[i]]==n
			ans+=1
		end
	end
end
print(ans)

Measured memory_bytes: 112416
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;
const int N = 1e5 + 123 , mod = 1e9 + 7;
int h[N] , dp[N][3] , par[N] ,n ;
set < pair < int , int > > st;
vector < int > gr[N];
void dfs(int u , int p ){
	par[u] = p;
	h[u] = h[p] + 1;
	st.insert({h[u] , u});
	for(int i = 0 ; i < sz(gr[u]) ; ++i)
		if(p != gr[u][i])
			dfs(gr[u][i] , u);
	if(sz(gr[u]) == 1 && u != 1)
	dp[u][0] = dp[u][1] = 1;
}
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n;
	for(int i = 1 ; i < n ; i++){
		int u , v;
		dp[i][1] = dp[i][0] = 1;
		cin >> u >> v;
		gr[u].pb(v);
		gr[v].pb(u);
	}
	int i = n;
	dp[i][1] = dp[i][0] = 1;
	dfs(1 , 0);
	while(!st.empty()){
		pair < int , int > tmp = *st.rbegin();
		int u = tmp.se;
		st.erase(st.find(tmp));
		dp[par[u]][1] = (dp[par[u]][1] * (dp[u][1] + dp[u][0])) % mod;
		dp[par[u]][0] = (dp[par[u]][0] * dp[u][1]) % mod;
	}
	
	cout << (dp[1][0] + dp[1][1]) % mod;
}

Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	int ans = 0;
	for (int i = 0; i <= 999; ++i){
		char arr[3] = {i / 100 + '0', i / 10 % 10 + '0', i % 10 + '0'};
		
		int j = 0;
		for (int i = 0; i < s.size(); ++i){
			if (s[i] == arr[j]){
				++j;
			}
			if (j >= 3){
				ans++;
				break;
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 384
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    auto s = readln.chomp;
    
    bool ok = true;
    foreach (i, e; s) {
        if (i % 2 == 0) {
            ok &= e == 'R' || e == 'U' || e == 'D';    
        } else {
            ok &= e == 'L' || e == 'U' || e == 'D';
        }
    }
    
    writeln(ok ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int a, b;
  cin >> a >> b;
  vi l = {a, a-1, b, b-1};
  sort(all(l));
  cout << l[2]+l[3] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>

using lint = long long int;
using Graph = std::vector<std::vector<lint>>;

template<class T>
struct edge
{
	T dist;
	lint to;
	edge(){}
	edge(const T &a_dist,const lint &a_to) : dist(a_dist), to(a_to) {}
	~edge(){}
};

int main(int argc,char *argv[])
{
	int n;
	std::cin >> n;

	std::vector<int> x(n,0), y(n,0);
	for(int i = 0;i < n;++i) { std::cin >> x[i] >> y[i]; }

	double sum = 0.0;
	for(int i = 0;i < n;++i)
	{
		for(int j = 0;j < n;++j)
		{
			sum += std::sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
		}
	}

	std::cout << std::setprecision(13) << sum/n << std::endl;

	return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int ans=0;
	stack<string>s;
	string w,t;
	cin>>w;
	s.push(w.substr(0,1));
	for(int i=1;i<w.length();i++){
		if(!s.empty()){
			t=s.top();
		}
		s.push(w.substr(i,1));
		if( t!=s.top() && s.size()>=2){
			ans+=2;
			s.pop();
			s.pop();
		}
	}
	cout<<ans<<endl;
}


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

using namespace std;

int main(void){
  int N;
  
  cin >> N;
  
  for (int i = 1; i < 10; i++){
    for (int j = 1; j < 10; j++){
      if (i * j == N){
        cout << "Yes";
        return 0;
      }
    }
  }
  
  cout << "No";
}
  

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  ll n;
  cin>>n;
  cout<<(n+999)/1000*1000-n<<"\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h, w; cin >> h >> w;
  ll ans = longinf;
  if(h%3==0 || w%3==0) ans = 0;
  else ans = min({w, h, ans});
  REP(i, 1, h) {
    ll a = w/2*i;
    ll b = (w-w/2)*i;
    ll c = h*w-a-b;
    ans = min(max({a,b,c})-min({a,b,c}), ans);
  }
  REP(i, 1, w) {
    ll a = h/2*i;
    ll b = (h-h/2)*i;
    ll c = h*w-a-b;
    ans = min(max({a,b,c})-min({a,b,c}), ans);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	vector<string> S;
	vector<int> T;
	int total_t = 0;
	for (int i = 0; i < N; i++) {
		string s;
		int t;
		cin >> s >> t;
		S.push_back(s);
		T.push_back(t);
		total_t += t;
	}

	string X;
	cin >> X;
	int diff_t = 0;
	for (int i = 0; i < N; i++) {
		diff_t += T[i];
		if (S[i] == X) {
			cout << total_t - diff_t << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3604
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define piiii pair<pair<int, int>, pair<int, int>>

vector<ll> dp_nech;
vector<ll> dp_ch;
vector<ll> prefodd;
void solve() {
    int n;
    cin>>n;
    vector<ll> arr(n);
    dp_nech.resize(n);
    dp_ch.resize(n);
    prefodd.resize(n);

    for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=0;i<n;i++){
        if(i%2==0){
            prefodd[i]=arr[i];
        }
        prefodd[i]+=(i-1>=0)?prefodd[i-1]:0;
    }
    for (int i = 0; i <n ; ++i) {
       if(i%2==1){//i+1 - kolvo-chetnoe
           dp_ch[i]=max(arr[i]+((i-2>=0)?dp_ch[i-2]:0), prefodd[i]);
       }
       else{
           dp_nech[i]=max(arr[i]+((i-2>=0)?dp_nech[i-2]:0), (i-1>=0)?dp_ch[i-1]:0);
       }
    }
    if(n%2==0){
        cout<<dp_ch[n-1];
    }
    else{
        cout<<dp_nech[n-1];
    }

}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a.at(i);
    }

    map<ll, int> mp;
    for (int i=1; i<n; ++i) {
        mp[a.at(0) + a.at(i) - i]++;
    }
    ll ok = 0;
    ll res = 0;
    for (int i=0; i<n-1; ++i) {
        res += mp[ok];
        mp[a.at(0) + a.at(i+1) - (i+1)]--;
        ok -= a.at(i+1) - a.at(i) + 1;
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 27392
def ruisekiwa(l):
    #関数バージョン
    lst = [0]
    s = 0
    for i,v in enumerate(l):
        lst.append(s + v)
        s += v
    return lst

def solve(n,a):
    r = ruisekiwa(a)
    sm = 0
    for i in range(n-1):
        sm += a[i] * (r[-1] - r[i+1])
    return sm % (10**9 + 7)
def solve2(n,a):
    sm = 0
    for i in range(n-1):
        for j in range(i+1,n):
            sm += a[i] * a[j] % (10**9 + 7)
    return sm


def main():
    n = int(input())
    a = list(map(int,input().split()))

    print(solve(n,a))
    #print(solve2(n,a))



if __name__ == '__main__':
    main()


Measured memory_bytes: 31576
gets.to_i.times do
  n,k = gets.split.map(&:to_i)
  xs = gets.split.map(&:to_i)
  d = Array.new(n - 1) do |i|
    xs[i + 1] - xs[i]
  end
  d.sort!.reverse!
  ans = xs[-1] - xs[0]
  a = [n, k].min - 1
  ans -= d[0, a].inject(:+) if a > 0
  p [ans, 0].max
end

Measured memory_bytes: 21104