akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

struct Frac {
  int64 p, q;
};

Frac operator -(const Frac& a, const Frac& b) {
  int64 p = a.p * b.q - a.q * b.p;
  int64 q = a.q * b.q;
  int64 d = abs(__gcd(p, q));
  p /= d; q /= d;
  return Frac{p, q};
}

int main() {
  int n;
  cin >> n;
  for (int i = n / 4 + 1; i <= 3500; ++i) {
    auto cur = Frac{4, n} - Frac{1, i};
    for (int j = cur.q / cur.p + 1; j <= 3500; ++j) {
      auto cur = Frac{4, n} - Frac{1, i} - Frac{1, j};
      if (cur.p == 1) {
        cout << i << " " << j << " " << cur.q << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    ll cnt = 0;
    rep(i, N) {
        ll a;
        cin >> a;
        while(a % 2 == 0) {
            a /= 2;
            cnt++;
        } 
    }
    print(cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define f(i,j,k) for(int i=j;i<k;i++)
    #define f2(i,j,k) for(int i=j;i>k;i--)
    using namespace std;
    int main(){
        long long a[3][3],ans=0;
        f(i,0,3){
            f(j,0,3){
                cin>>a[i][j];
                ans+=a[i][j];
            }
        }
        if(ans%3!=0){
            cout<<"No"<<endl;
            return 0;
        }
        long long d[6];
        d[0]=a[0][0]+a[1][1]+a[2][2];
        d[1]=a[0][0]+a[1][2]+a[2][1];
        d[2]=a[0][1]+a[1][0]+a[2][2];
        d[3]=a[0][1]+a[1][2]+a[2][0];
        d[4]=a[0][2]+a[1][0]+a[2][1];
        d[5]=a[0][2]+a[1][1]+a[2][0];
        f(i,0,6){
            if(d[i]!=ans/3){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        var F = new List<string>();
        for (int i = 0; i < N; i++) {
            F.Add(ReadLine().Replace(" ", ""));
        }
        var P = new List<List<long>>();
        for (int i = 0; i < N; i++) {
            P.Add(ReadLine().Split(' ').Select(s => long.Parse(s)).ToList());
        }

        var ans = 0L;
        for (int i = 1; i < 1024; i++) {
            var sum = 0L;
            for (int j = 0; j < N; j++) {
                var and = Convert.ToString(i & Convert.ToInt32(F[j], 2), 2);
                var cnt = and.Length - and.Replace("1", "").Length;
                sum += P[j][cnt];
            }
            if (i == 1) { ans = sum; }
            ans = Math.Max(sum, ans);
        }

        WriteLine(ans);
    }
}

Measured memory_bytes: 17472
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N,p,sum=0,highest=0;
  cin >> N;
  for(int i=0;i<N;i++){
      cin >> p;
      sum += p;
      highest = max(highest,p);
  }
  sum -= highest/2;
  
  cout << sum << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MOD(x) ((x) % (1e9 + 7))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	scanf("%d", &n);
	char str[100001];
	scanf("%s", str);

	char prev = str[0];
	int result = 1;
	REP(i, n) {
		result += str[i] == prev ? 0 : 1;
		prev = str[i];
	}

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

	return 0;
}

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

int main(){
	long long n, m, total=0;
	cin >> n >> m;
	long long a[m];
	for(int i=1;i<=m;i++){
		cin >> a[m];
		total+=a[m];
	}
	if(total>n){
		cout << "-1";
	}
	else{
		cout << n-total;
	}
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
static class Program
{
    static void Main()
    {
        var p = new Problem();
        p.A();
    }
}

public class Problem
{
    public void A()
    {
        while (true)
        {
            var input = IO.IARead();
            if (input.Length == 1)
                break;

            var p = input[0];
            var b = input[1];
            var c = input[2];
            var d = input[3];
            var q = input[4];

            var a = b / c;
            if (a >= q)
                a = q;
            var b2 = b - a*c;
            var a2 = b2 / d;
            var p2 = a + a2;
            
            var flag = true;
            if (a == 0)
                flag = false;
            while (p > p2)
            {
                a--;
                if (a == 0)
                {
                    flag = false;
                    break;
                }
                b2 += c;
                a2 = b2 / d;
                p2 = a + a2;

            }
            if (flag)
                Console.WriteLine("{0} {1}", a, a2);
            else Console.WriteLine("NA");
        }

    }

}


static public class IO
{
    static public void SetIn()
    {
        var sr = new System.IO.StreamReader("sample.txt");
        Console.SetIn(sr);
    }

    static public int IRead()
    {
        return int.Parse(Console.ReadLine());
    }
    static public int[] IARead(char c = ' ')
    {
        return Console.ReadLine().Split(c).Select(x => int.Parse(x)).ToArray();
    }
    static public long LRead()
    {
        return long.Parse(Console.ReadLine());
    }
    static public long[] LARead(char c = ' ')
    {
        return Console.ReadLine().Split(c).Select(x => long.Parse(x)).ToArray();
    }
    static public double DRead()
    {
        return double.Parse(Console.ReadLine());
    }
    static public double[] DARead(char c = ' ')
    {
        return Console.ReadLine().Split(c).Select(x => double.Parse(x)).ToArray();
    }
}
static public class Rep
{
    static public void For(this int range, Action<int> action, int start = 0)
    {
        for (int i = start; i < range + start; i++)
        {
            action(i);
        }
    }

    static public void For(this int range, Func<int, bool> func, int start = 0)
    {
        for (int i = start; i < range + start; i++)
        {
            var b = func(i);
            if (!b)
                break;
        }
    }
    static public void ForEach<T>(this IEnumerable<T> source, Action<T> action)
    {
        foreach (var x in source)
        {
            action(x);
        }
    }
    static public void ForEach<T>(this IEnumerable<T> source, Func<T, bool> func)
    {
        foreach (var x in source)
        {
            var b = func(x);
            if (!b)
                break;
        }
    }
}
//*/


Measured memory_bytes: 5956
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a, b;
    char op;
    while(true){
        cin >> a >> op >> b;
        if(op == '+') printf("%d\n", a+b);
        else if(op == '-') printf("%d\n", a-b);
        else if(op == '*') printf("%d\n", a*b);
        else if(op == '/') printf("%d\n", a/b);
        else if(op == '?') break;
    }
}


Measured memory_bytes: 3136
s = int(input())
a = []
a.append(s)
aTemp = s
while True:
    if aTemp % 2:
        aTemp = 3*aTemp + 1
    else:
        aTemp = int(aTemp/2)
    if aTemp in a:
        a.append(aTemp)
        print(len(a))
        break
    else:
        a.append(aTemp)


Measured memory_bytes: 2940
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;

int main() {
	ll n,m,s,t,a,b;
	cin >> n >> m;
	cin >> s >> t;
	for (ll i = 0; i < m-1; i ++ ) {
		cin >> a >> b;
		if (s < a)s = a;
		if (b < t)t = b;
	}
	if (t - s < 0) {
		cout << 0 << endl;
	}
	else {
		cout << t - s + 1 << endl;
	}
}


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

int n, a[1005];

bool check(){
	for(int i = 2; i <= n; i++){
		if(a[i] < a[i-1]) return false;
	}
	return true;
}

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 1; i <= n; i++){
		for(int j = i; j <= n; j++){
			swap(a[i], a[j]);
			if(check()){
				puts("YES");
				exit(0);
			}
			swap(a[i], a[j]);
		}
	}
	puts("NO");
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int d[100005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>d[i];
	}
	sort(d+1,d+n+1);
	int sum=n/2;
	if(d[sum+1]==d[sum]){
		cout<<"0";
		return 0;
	}
	cout<<d[sum+1]-d[sum];
	return 0;
}

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

int main(){
  int D, N; cin >> D >> N;
 
	int S = 1; for (int i = 0; i < D; i++) S *= 100;
	if(N == 100){
      cout << (N + 1) * S << endl;
    }
  else{ cout << N * S << endl;
  }
	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,t,ans=0;cin>>n;
  REP(i,n){
    cin>>t;
    ans+=t;
  }
  cout<<ans-n;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=[0]*(n-k+1)
for i in range(k):
    ans[0]+=(p[i]+1)/2
for i in range(n-k):
    ans[i+1]=ans[i]-(p[i]+1)/2+(p[i+k]+1)/2

print(max(ans))

Measured memory_bytes: 24804
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
   string s;
   stack<int>st;
   cin>>s;
   for(int i=0;i<s.size();i++){
     if(st.size()>=1&&st.top()!=s[i]-'0'){
       st.pop();
     } else st.push(s[i]-'0');
   }
   cout<<s.size()-st.size()<<endl;
  return 0;
}

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

int n;
string st;

int main() {
	cin >> n >> st;
  	if (n % 2) {
        cout << "No" << endl;
  		return 0;
	}

  	for (int i = 0; i < n / 2; i++)
      	if (st[i] != st[(n / 2) + i]) {
          	cout << "No" << endl;
  			return 0;
        }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int windowSize = sc.nextInt();
        int curtainSize = sc.nextInt();
        int result = (windowSize - curtainSize * 2) <= 0 ? 0 :  (windowSize - curtainSize * 2);
        System.out.println(result);
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    int d = a/b;
    int r = a % b;
    double f = double (a) / double (b);
    cout << d;
    cout << " ";
    cout << r;
    cout << " ";
    cout << fixed << setprecision(5) << f;
    cout << " ";
    
    cout << endl;
}


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

int w[100010], v[100010];
long long dp[128][100010];

long long calc(int pos, int left) {
    if(left <= 0) return 0;
    if(pos == 0) return 1e10;
    long long &y = dp[pos][left];
    if(y!=-1) return y;
    y = calc(pos-1, left);
    y = min(y, w[pos] + calc(pos-1, left - v[pos]));
    return y;
}

int main() {
    memset(dp, -1, sizeof(dp));
	int n, W;
	cin >> n >> W;
	for(int i=1; i<=n; ++i) {
	    cin >> w[i] >> v[i];
	}
	int ans = 0;
	while(calc(n, ans+1) <= W) {
	    ans = ans + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 103644
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define re(s) reverse(s.begin(),s.end())
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}

int32_t main()
{
  io
int k;
cin>>k;int ans=0;
for(int i=1;i<=k;i++)
{
  for(int j=1;j<=k;j++)
  {
    for(int kk=1;kk<=k;kk++)
    {
      ans+=__gcd(i,__gcd(j,kk));
    }
  }
}
cout<<ans<<endl;

}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int a = 1;

int main(void){
    int a, b, c, x, sum = 0;
    cin >> a >> b >> c >> x;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(i * 500 + j * 100 + k * 50 == x) sum++;
            }
        }
    }
    print(sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vll a(n), b(n), c(n);
  for (ll i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

  vector<vll> dp(3, vll(n + 1, 0));
  for (ll i = 1; i <= n; i++) {
    dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i - 1];
    dp[1][i] = max(dp[2][i - 1], dp[0][i - 1]) + b[i - 1];
    dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c[i - 1];
  }
  cout << max({dp[0][n], dp[1][n], dp[2][n]}) << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int dp[100005];
vector<int> children[100005];
void bfs(int from){
    if(dp[from] != 0) return;
    int maxi = 0;
    for(int i = 0; i < children[from].size(); i++){
        int to = children[from][i];
        bfs(to);
        maxi = max(maxi, dp[to]);
    }
    dp[from] = maxi + 1;
    return;
}

int main() {
    //cout.precision(10);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        children[x].push_back(y);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        bfs(i);
        ans = max(ans, dp[i]);
    }
    cout << ans - 1<< endl;
    return 0;
}


Measured memory_bytes: 8832
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int ans = 0;

        ans = N*(N-1)/2 + M*(M-1)/2;
        System.out.println(ans);
    }
}


Measured memory_bytes: 35856
def main():
    N, K = [int(x) for x in input().split()]
    hs = [int(x) for x in input().split()]
    hs = sorted(hs, reverse=True)
    if K >= N:
        print(0)
    else:
        hs = hs[K:]
        print(sum(hs))


if __name__ == '__main__':
    main()

Measured memory_bytes: 26764
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<vector<long long int>>A(N,vector<long long int>(2));
	for (int i = 0; i < N; i++) {
		cin >> A[i][1] >> A[i][0];
	}
	sort(A.begin(), A.end());
	long long int recd = 0;
	long long int rec = 0;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		recd = A[i][0];
		rec += A[i][1];
		if (rec > recd) {
			ans++;
		}
	}
	if (ans == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100000
using namespace std;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

vector< int > graph[MAX_N];

bool dfs(int v, int c, int color[]){
  if(color[v] >= 0) return color[v] == c;
  color[v] = c;
  for(int w: graph[v]){
    if(!dfs(w, c ? 0 : 1, color)) return false;
  }
  return true;
}

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

  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
  }

  for(int i = 0; i < m; i++){
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }

  int color[n];
  fill(color, color + n, -1);

  ll ans;
  if(!dfs(0, 0, color)){
    ans = (ll)n * (n - 1) / 2 - m;
  }
  else{
    int count = 0;
    for(int v = 0; v < n; v++){
      if(color[v] == 0) ++count;
    }
    ans = (ll)count * (n - count) - m;
  }

  cout << ans << endl;

  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const int MAXN = 1024;

int a[MAXN];
int b[MAXN];
int c[MAXN];
int d[MAXN];

bool red_used[MAXN];

int main() {
    int n; cin>>n;
    for(int i = 0; i < n; ++i) {
        cin>>a[i]>>b[i];
    }
    for(int i = 0; i < n; ++i) {
        cin>>c[i]>>d[i];
    }

    vector<pair<int,int> > v;
    for(int i = 0; i < n; ++i) {
        v.push_back(pair<int,int>(c[i], d[i]));
    }
    sort(v.begin(), v.end());

    int res = 0;
    fill(red_used, red_used + MAXN, false);
    for(int i = 0; i < n; ++i) {
        int x = v[i].first;
        int y = v[i].second;
        vector<pair<int,int> > vv;
        for(int j = 0; j < n; ++j) {
            if(!red_used[j] && a[j] < x) {
                vv.push_back(pair<int,int>(b[j], j));
            }
        }
        sort(vv.begin(), vv.end(), greater<pair<int,int> >());
        for(int j = 0; j < (int)vv.size(); ++j) {
            int yy = vv[j].first;
            int k = vv[j].second;
            if(yy < y) {
                red_used[k] = true;
                ++res;
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main() {
    string s, t;
    cin >> s >> t;
    int dp[int(s.length()) + 1][int(t.length()) + 1];
    memset(dp, 0, sizeof(dp));
    int prev[int(s.length()) + 1][int(t.length() + 1)];
    memset(prev, 0, sizeof(prev)); 
    for (int i = 1; i <= s.length(); ++i) {
        for (int j = 1; j <= t.length(); ++j) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                prev[i][j] = 1; //diagonally up
            }
            else if (dp[i - 1][j] >= dp[i][j - 1]) {
                dp[i][j] = dp[i - 1][j];
                prev[i][j] = 2; //up, t
            }
            else {
                dp[i][j] = dp[i][j - 1];
                prev[i][j] = 3; //left, s
            }
        }
    }
    string str;
    int i = s.length(), j = t.length();
    while (prev[i][j] != 0) {
        if (prev[i][j] == 1) {
            str += s[i-1];
            --i, --j;
        }
        else if (prev[i][j] == 2)    --i;
        else    --j;
    }
    /*
    cerr << "    \t";
    for (int i = 0; i < t.length(); ++i)    cerr << t[i] << "   \t";
    cerr << endl;
    for (int i = 1; i <= s.length(); ++i){
        cerr << s[i-1] << " -> ";
        for (int j = 1; j <= t.length(); ++j) {
            cerr << "(" << dp[i][j] << "," << prev[i][j] << ")\t";
        }
        cerr << endl;
    }
    */
    reverse(str.begin(), str.end());
    cout << str << endl;
    return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

pii iv[N];
int MX=300;
int pl[N];
int ans[N];
int tp[N],tp1[N];
int main(){
  int n,m; scanf("%d%d",&m,&n);
  REP(i,m){
    scanf("%d%d",&iv[i].X,&iv[i].Y);
  }
  REPP(i,1,MX){
    REP(j,m) if(iv[j].Y/i!=(iv[j].X-1)/i) ans[i]++;
  }
  REP(i,m){
    int ml=(iv[i].X-1)/MX;
    tp[0]=tp1[0]=n+1;
    REPP(j,1,ml+2){
      tp[j]=(iv[i].X-1)/j;
      tp1[j]=(iv[i].Y)/j;
    }
    REP(j,ml+1){
      pii z = mp(max(tp[j+1],tp1[j+1])+1,min(tp[j],tp1[j]));
      if(z.X<=z.Y){
        pl[z.X]++; pl[z.Y+1]--;
      }
      //printf("%d %d %d %d %d\n",iv[i].X,iv[i].Y,j,z.X,z.Y);
    }
  }
  int x=0;
  REP(i,n+1){
    x+=pl[i];
    if(i>=MX){
      ans[i]=m-x;
    }
  }
  REPP(i,1,n+1) printf("%d\n",ans[i]);
  return 0;
}

Measured memory_bytes: 4096
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

ll big=1e9+7;
vector<ll> p(2001,1);
vector<ll> ip(2001,1);

ll pow_ans(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
          res *= x;
          res %= big;
        }
        x *= x;
        x %= big;
        n >>= 1;
    }
    return res;
}

ll pp(int i,int j){
  if(i<0||j<0||i<j)return 0;
  else{
    ll tem;
    tem=p[i]*ip[i-j]%big;
    return tem;
  }
}

ll ppp(int i,int j){
  if(i<0||j<0||i<j)return 0;
  ll tmp=pp(i,j);
  tmp=tmp*ip[j]%big;
  return tmp;
}

int main(){
  ll n,k;
  cin>>n>>k;
  for(int i=1;i<2001;i++){
    p[i]=p[i-1]*i%big;
  }
  for(int i=1;i<2001;i++){
    ip[i]=pow_ans(p[i],big-2);
  }
  for(ll i=1;i<=k;i++){
    ll ans=ppp(k-1,i-1);
    ans=(ans*ppp(n-k+1,i))%big;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 888
#include<iostream> 
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	while(n > 0)
	{
		if(n%10 == 9) {
			printf("Yes"); return 0;
		}
		n /= 10;
	}
		printf("No"); 
		return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

//#define _DEBUG_ 4
void run() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b) {
		cout << 0 << endl;
		return;
	}

	if (n == 1) {
		cout << (a < b ? 0 : 1) << endl;
	} else if (n == 2) {
		cout << 1 << endl;
	} else {
		if (a == b) {
			cout << 1 << endl;
			return;
		}

		cout << b*(n-2) - a*(n-2) + 1 << endl;
	}
}

int main() {
#ifdef _DEBUG_
	using std::chrono::system_clock;
	using std::chrono::duration_cast;
	system_clock::time_point  start, end;
	std::ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	for (int i = 0; i < _DEBUG_; i++) {
		cout << "-------------------------- (cnt:" << i << ")" << endl;
		start = system_clock::now();
		run();
		end = system_clock::now();
		int elapsed = duration_cast<std::chrono::milliseconds>(end - start).count();
		cout << "-------------------------- (time:" << elapsed << "ms)" << endl << endl;
	}
#else
	run();
#endif
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;

int A,B;
int k;


int main(){
	cin >> A >> B;
	if(A==B){
    cout << 2*A << endl;
  }
  else{
    k = max(A,B);
    cout << k*2-1 << endl;
  }
				return 0;
			}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        a, b = L[i], L[j]
        ans += bisect_left(L, a + b) - 1 - j
print(ans)

Measured memory_bytes: 43740
N = int(input())
S = [[s for s in input()] for _ in range(N)]

from math import factorial
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def main():
    dic = {}
    ans = 0
    for i in range(N):
        S[i].sort()
        tmp = "".join(S[i])
        S[i] = tmp

    for s in S:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    for val in dic.values():
        if val > 1:
            ans += comb(val,2)

    print(int(ans))
    return

if __name__ == "__main__":
    main()


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

int main(){
    long int N;
    long int T[5];
    cin >> N >> T[0] >> T[1] >> T[2] >> T[3] >> T[4];
    int i;
    long int min = T[0];
    for(i=1;i<=4;i++)
        if(min > T[i]) min = T[i];
    long int t;
    if(N % min == 0) t = N / min;
    else t = N / min + 1;
    cout << t + 4 << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 2010;
const int MOD = 1e9+7;

ll fac[MAX<<2];
ll finv[MAX<<2];
ll inv[MAX<<2];

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR (i, 2, MAX<<2) {
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}

ll nCk (int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int N, K;

int calc(int n) {
    ll p1 = nCk(K-1, n-1);
    ll p2 = nCk(N-K+1, n);
    return p1 * p2 % MOD;
}

void solve() {
    init();
    FOR (k, 1, K+1) {
        cout << calc(k) << endl;
    }
}

int main() {
    cin >> N >> K;
    solve();
}

Measured memory_bytes: 384
from sys import stdin
from collections import deque

n = input()
g = [[] for i in xrange(n + 1)]
inp = stdin.readlines()

idx = 0
c = []
for line in inp:
    if idx < n - 1:
        u, v = map(int, line.strip().split())
        g[u].append([v, idx])
        g[v].append([u, idx])
        idx += 1
    else:
        c = map(int, line.strip().split())

num = [0] * (n + 1)
ans = [0] * (n - 1)
c.sort(reverse = True)

vis = [0] * (n + 1)
def bfs(root):
    global vis
    
    vis[root] = 1
    q = deque([root])
    ctr = 0
    num[root] = c[ctr]
    ctr += 1
    while q:
        u = q.popleft()
        for v, idx in g[u]:
            if not vis[v]:
                vis[v] = 1
                q.append(v)
                num[v] = c[ctr]
                ans[idx] = c[ctr]
                ctr += 1

bfs(1)
print sum(c) - c[0]
print ' '.join(map(str, num[1:]))

Measured memory_bytes: 37788
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int dig(ll x) {
  int cnt = 0;
  while (x > 0) {
    cnt += 1;
    x /= 10;
  }
  return cnt;
}

int main() {
  ll n;
  scan(n);
  int ans = 12;
  for (ll i = 1; i < n+10; ++i) {
    ll j = n / i;
    if (i > j) { break; }
    if (n != i * j) { continue; }
    ans = min(ans, dig(j));
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using std::cin;
using std::cout;
int main()
{
    int N;
    cin >> N;
    int a = 1;
    for(int i = 0; i < 1000000; i++)
    {
        if(a * 1000 < N) a++;
        else break;
    }
    cout << a * 1000 - N;
}

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

int main(){
    int a ,b;
    string s,t,u;
    cin>>s>>t>>a>>b>>u;
    if(s==u){
        cout<<a-1<<" "<<b<<endl;
    }
    else{
        cout<<a<<" "<<b-1<<endl;
    }

   return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N;
std::vector<int>a, ans;
std::vector<int>cou[5];

int main()
{
	in >> N;
	a.resize(N);
	rep(i, N) in >> a[i];
	rep(i, N)
	{
		cou[a[i] + 2].push_back(i + 1);
	}
	for (auto i : cou[4]) ans.push_back(i);
	rep(i, cou[0].size() / 2 * 2) ans.push_back(cou[0][i]);
	if (cou[1].size() > 0 && cou[0].size() % 2 == 1) {
		ans.push_back(cou[0][cou[0].size() - 1]);
		ans.push_back(cou[1][0]);
	}
	std::sort(ans.begin(), ans.end());
	out << ans.size() << std::endl;
	for (auto i : ans) out << i << std::endl;
	return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include<iomanip>
using namespace std;
int main(void){
    double r;
    double pi;
    cin>>r;
    pi =3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989;
    cout << std::fixed;
    cout << std::setprecision(10)<<r*r*pi<<" "<<2*r*pi<<endl;
    
}


Measured memory_bytes: 3284
import copy
import heapq

n, m = map(int, input().split())
a_list = list(map(int, input().split()))

tmp_list = list(map(lambda x: x * -1, a_list))

heapq.heapify(tmp_list)
#print(tmp_list)

for i in range(m):
    max_value = heapq.heappop(tmp_list)*-1
    #print(max_value)
    heapq.heappush(tmp_list, -1*(max_value//2))

print(str(int(-sum(tmp_list))))


Measured memory_bytes: 14784
#include <bits/stdc++.h>
using namespace std;
int A,B,x,y;
int Ans[41][100];

int main(){
  cin >> A >> B;
  for(int h=0;h<41;h++){
    for(int w=0;w<100;w++){
      if(h<20) Ans[h][w]=0;
      else Ans[h][w]=1;
    }
  }
  x=(A-1)/50;
  y=(A-1)%50;
  for(int i=0;i<x;i++){
    for(int j=0;j<50;j++){
      Ans[2*i][2*j]=1;
    }
  }
  for(int j=0;j<y;j++){
    Ans[2*x][2*j]=1;
  }

  x=(B-1)/50;
  y=(B-1)%50;
  for(int i=0;i<x;i++){
    for(int j=0;j<50;j++){
      Ans[2*i+21][2*j]=0;
    }
  }
  for(int j=0;j<y;j++){
    Ans[2*x+21][2*j]=0;
  }
  cout <<"41" <<" "<< "100"<<endl;
  for(int h=0;h<41;h++){
    for(int w=0;w<100;w++){
      if(Ans[h][w]==0) cout << '#';
      else cout << '.';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<tuple<string,int,int>> V;
  vector<string> S(N);
  vector<int> P(N);
  REP(i,N) {
    cin >> S.at(i) >> P.at(i);
    P.at(i)*=-1;
    V.emplace_back(S.at(i),P.at(i),i+1);
  }
  sort ALL(V);
  REP(i,N) cout << get<2>(V.at(i)) << endl;
}

Measured memory_bytes: 256
a, b, m = list(map(int, input().split()))
fridges = list(map(int, input().split()))
microwaves = list(map(int, input().split()))

price_min = min(fridges) + min(microwaves)
for _ in range(m):
	x, y, c = list(map(int, input().split()))
	price = fridges[x-1] + microwaves[y-1] - c
	if price < price_min:
		price_min = price
		
print(price_min)

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

ans=0
inf=10**9+7
flag=True
total=0
for i in range(N):
    total+=A[i]
    total%=inf

for i in range(N): 
    total-=A[i]
    ans+=A[i]*total
    ans%=inf    
          
print(ans)

Measured memory_bytes: 94120
import java.util.Scanner;
import java.util.*;
import java.lang.*; 
import java.util.regex.Pattern;
import java.text.DecimalFormat;
import java.util.stream.IntStream;
public class Main{    
public static void main(String[] args)
{     
Scanner scanner=new Scanner(System.in);
int a=scanner.nextInt();
int b=scanner.nextInt();
if(a>b){
if(a-1>b)
  System.out.println(2*a-1);
else System.out.println(a+b);
}
else {
  if(b-1>a)
  System.out.println(2*b-1);
else System.out.println(a+b);
}
}
}






Measured memory_bytes: 21076
package main

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

func main() {
	sc := NewScanner()

	s := sc.NextLine()
	r := []rune(s)
	for i := 0; i < len(r); i++ {
		if i%2 == 0 {
			if r[i] == 'L' {
				fmt.Printf("No\n") // output for debug
				return
			}
		}
		if i%2 == 1 {
			if r[i] == 'R' {
				fmt.Printf("No\n") // output for debug
				return
			}
		}
	}
	fmt.Printf("Yes\n")
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
long long h,w;
cin>>h>>w;
long long ans=0;
if(h==1||w==1){
  ans=1;
}
else{
ans=(h-h/2)*(w-w/2)+(h/2)*(w/2);
}
cout<<ans<<endl;
  return 0;
}

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

const int INF = 1e9;

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

  vector<vector<int>> edge(n, vector<int> (n, 0));
  vector<vector<int>> dist(n, vector<int> (n, INF));
  for (int i = 0; i < m; i++) {
    int a,b,c;
    cin >> a >> b >> c;
    a--, b--;
    dist[a][b] = dist[b][a] = edge[a][b] = edge[b][a] = c;
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if(edge[i][j] > dist[i][j]) ans++;
    }
  }
  cout << ans/2 << '\n';
}

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


 
void solve()  
{
	ll a, b;
	cin>>a>>b;
	ll c=0;
	if(b==1) { cout<<0<<endl; return; }
	if(a==b) { cout<<1<<endl; return; }
	c=1;
	ll em=a;
	while(em<b)
	{
		em+=a-1;
		c++;
	}
	cout<<c<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
	ll T = 1;
	//cin>>T; 
	while(T--)
	    solve();
	return 0;
}


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

int main() {
    int a, b ,c, d;
    cin >> a >> b >> c >> d;
    int i = 0;
    while(1) {
        if(i%2 == 0) {
            c -= b;
            if(c <= 0) {
                cout << "Yes" << '\n';
                return 0;
            }
        } else {
            a -= d;
            if(a <= 0) {
                cout << "No" << '\n';
                return 0;
            }
        }
        i++;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
 
int main() {
  string S,M,L;
 
  M = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int N;
  cin >> N ;
  cin >> S ;
  L = S;
  for(int i=0;i< S.size();i++){
    for(int j=0;j<26;j++){
      
  if (S.at(i) == M.at(j)){
    if (j+N >= 26){
    L.at(i) = M.at(j+N-26);
    }
      else if(j+N<26){
    L.at(i) = M.at(j+N);
      }
  }
  }
  }
  cout << L << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  ll n;
  cin >> n;
  ll ans = INF;
  for (ll i = 1; i*i <= n; i++) {
    if (n % i == 0) {
      ll a = i;
      ll b = n / i;
      chmin(ans, a - 1 + b - 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256