akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int n, m, ans, cnt;
string s;
int a[100010];
map<int,int> mp;

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

  int aa, bb, cc;
  cin >> aa >> bb >> cc;
  if (bb > aa) swap(aa, bb);
  if (cc > aa) swap(aa, cc);
  cout << bb * cc / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5;
const int mod = 1e9+7;
long long g[N];

long long binpow(int a,int x)
{
	long long res;
	if(x == 0) return 1;
	res = binpow(a,x/2) % mod;
	if(x % 2 == 0) return res*res % mod;
	else return ((a*res) % mod * res) % mod;
}
 
long long tohop(int k,int n)
{
	if(k < 0 || n < 0 || k > n) return 0;
	long long res = (g[n-k]*g[k]) % mod;
	return (g[n] * binpow(res,mod-2) ) % mod;
}

long long path(int x,int y,int x1,int y1)
{
	x1 = x1-x+1;
	y1 = y1-y+1;

	return tohop(x1-1,x1+y1-2);
}

signed main()
{
	int H,W,A,B;
	cin>>H>>W>>A>>B;
	g[0] = 1;
	

	for(int i=1;i<N;i++)
	{
		g[i] = ( g[i-1]*i ) % mod;
	}
	// cin>>H>>W>>A>>B;
	int ans = 0;
	
	for(int i=1;i<=H-A;i++)
	{
		// cout<<i<<' '<<B<<'\n';
		ans = ( ans + ( path(1,1,i,B)*path(i,B+1,H,W) ) % mod ) % mod;
	}

	cout<<ans;


}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

double dist(pair<int, int> l, pair<int, int> r){
  double dx = l.first-r.first;
  double dy = l.second-r.second;
  return pow(dx*dx+dy*dy, 0.5);
}

int main(){
  int n;
  cin>>n;
  vector<pair<int,int>> xy;
  rep(i, n){
    int x,y;
    cin>>x>>y;
    xy.emplace_back(x,y);
  }
  
  vector<int> ar;
  rep(i,n){
    ar.push_back(i);
  }
  
  double sum = 0;

  do {
    rep(i,n-1){
      sum += dist(xy[ar[i]], xy[ar[i+1]]);
    }
  } while( next_permutation(ar.begin(), ar.end()) );
  
  int fac = 1;
  rep(i,n) fac *= (i+1);

  cout<<fixed<<setprecision(7)<<(sum/fac)<<setprecision(6);

  return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    answer = [0] * M
    pref = {}
    for i in range(M):
        P, Y = map(int, input().split())
        if P not in pref:
            pref[P] = []
        pref[P].append((i, Y))
    for p, arr in pref.items():
        arr.sort(lambda a: a[1])
        for i in range(1, len(arr)+1):
            item = arr[i-1]
            answer[item[0]] = ("0" * 5 + str(p))[-6:]
            answer[item[0]] += ("0" * 5 + str(i))[-6:]
    for i in range(M):
        print(answer[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 85720
function Main(input){
    input = input.split('\n');
    var arr_o = input[0].split('');
    var arr_e = input[1].split('');

    var arr_oc = [];
        for(var i = 0;i < arr_o.length; i++) {
            arr_oc.push(arr_o[i]);
            arr_oc.push(arr_e[i]);
        }

    console.log(arr_oc.join(''));
  }
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int p[105];
bool exist[105];

int main()
{
	int x,n;
	cin >> x >> n;
	rep(i,n)
	{
		cin >> p[i];
		exist[p[i]] = true;
	}
	int i = 0;
	while(true)
	{
		if (!exist[x-i])
		{
			cout << x-i << endl;
			return 0;
		}
		if (!exist[x+i])
		{
			cout << x+i << endl;
			return 0;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 3632
class StronglyConnectedComponents():
    def __init__(self, n):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.rev = [[] for _ in range(n)]

    def add_edge(self, fr, to):
        self.graph[fr].append(to)
        self.rev[to].append(fr)

    def scc_id(self):
        group = [0] * self.n
        order = []
        for s in range(self.n):
            if group[s]: continue
            stack = [s]
            group[s] = -1
            while stack:
                node = stack.pop()
                for adj in self.graph[node]:
                    if group[adj]: continue
                    group[adj] = -1
                    stack.append(node)
                    stack.append(adj)
                    break
                else:
                    order.append(node)
        cnt = 0
        for s in order[::-1]:
            if group[s] != -1: continue
            stack = [s]
            group[s] = cnt
            while stack:
                node = stack.pop()
                for adj in self.rev[node]:
                    if group[adj] != -1: continue
                    group[adj] = cnt
                    stack.append(adj)
            cnt += 1
        return group, cnt

    def scc(self):
        group, cnt = self.scc_id()
        res = [[] for _ in range(cnt)]
        for i in range(self.n):
            res[group[i]].append(i)
        return res

class TwoSAT():
    def __init__(self, n):
        self.n = n
        self.res = [0] * self.n
        self.scc = StronglyConnectedComponents(2 * n)

    def add_clause(self, i, f, j, g):
        #assert 0 <= i < self.n
        #assert 0 <= j < self.n
        self.scc.add_edge(2 * i + (not f), 2 * j + g)
        self.scc.add_edge(2 * j + (not g), 2 * i + f)

    def satisfiable(self):
        group, cnt = self.scc.scc_id()
        for i in range(self.n):
            if group[2 * i] == group[2 * i + 1]: return False
            self.res[i] = (group[2 * i] < group[2 * i + 1])
        return True

    def result(self):
        return self.res

import sys
input = sys.stdin.buffer.readline

N, D = map(int, input().split())
F = [tuple(map(int, input().split())) for _ in range(N)]

ts = TwoSAT(N)

for i in range(N - 1):
    x0, y0 = F[i]
    for j in range(i + 1, N):
        x1, y1 = F[j]
        if abs(x0 - x1) < D:
            ts.add_clause(i, 1, j, 1)
        if abs(x0 - y1) < D:
            ts.add_clause(i, 1, j, 0)
        if abs(y0 - x1) < D:
            ts.add_clause(i, 0, j, 1)
        if abs(y0 - y1) < D:
            ts.add_clause(i, 0, j, 0)

if ts.satisfiable():
    print('Yes')
    print('\n'.join(map(str, (f[r] for r, f in zip(ts.result(), F)))))
else:
    print('No')

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



int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N = 1000000;
    int a=100,b=101,c=102,d=103,e=104,f=105;
	int x;
    cin>>x;
    int sum=0;
  
    for(int i = 0; i <= N ; i++){
        if(i*a>x)break;
        for(int j = 0; j <= N; j++){
            if(j*b>x)break;
            for(int s = 0; s <= N; s++){
                if(s*c>x)break;
                for(int t = 0; t <= N; t++){
                    if(t*d>x)break;
                    for(int u = 0; u <= N; u++){
                        if(u*e>x)break;
                        for(int h = 0; h <= N; h++){
                            if(f*h>x)break;
                            sum = a*i+b*j+c*s+d*t+e*u+f*h;
                            if(sum == x){
                              cout<<"1";
                              return 0;
                            }
                        }
                    }
                }
            }
        }
    }

	cout<<"0";
    
    

    return 0;
}

Measured memory_bytes: 256
extern crate proconio;
use proconio::fastout;
use std::collections;

#[fastout]
fn main() {
    proconio::input! {
        n: usize,
        a: [i32; n],
    }
    let mut map = collections::HashMap::new();
    let mut ans = 0 as u64;
    for i in 0..n {
        ans += *map.get(&(i as i32 - a[i])).unwrap_or(&0);
        *map.entry(i as i32 + a[i]).or_insert(0) += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 10892
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void){
    char w[20],t[1000];
    int count = 0,i = 0;
    scanf("%s",&w);
    while(1){
        scanf("%s",t);
        if(!strcmp(t,"END_OF_TEXT")) break;
        for(int i=0;t[i];i++)   t[i] |= 32;
        if(!strcmp(t,w))    count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2148
#include<stdio.h>
#include<string.h>
#include<iostream>

using namespace std;
int main()
{
	int len,i,flag=1;
	char s[101];
	char a[100],b[100];
	cin>>s;
	len=strlen(s);
	for(i=0;i<len;i++)
	{	if((i+1)%2!=0)
		if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')flag=0;

		if((i+1)%2==0)
		if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')flag=0;

	}
	if(flag==0)
		printf("No\n");
	else
		printf("Yes\n");
return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%s%s%s", $a, $b, $c);

$arrayA = str_split($a);
$arrayB = str_split($b);

$countA = strlen($a) - 1;
$countB = strlen($b) - 1;

if ($a[$countA] == $b[0] && $b[$countB] == $c[0]){
    echo 'YES';
}else{
    echo 'NO';
}

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

int main(){
	long long n,k;
	cin>>n>>k;

	long long res = 0;

	for(int i = 1;i<=n;i++){
		res+=((n/i)*max((long long)0,i-k));
		//cout<<"res:"<<i<<" "<<res<<endl;
		long long t = n%i;
		 res+=(k)?max((long long)0,t - k + 1):t;
		//cout<<i<<" "<<res<<endl;
	}
	cout<<res;
}


Measured memory_bytes: 256
gets
a=gets.split
n=0
b=a.sort_by &l=->(i){[i[1],n+=1]}
c=b.map{r=a.min_by &l;a[a.index r]=a[0];a.shift;r}
puts b*" ",:Stable,c*" ",b==c ?:Stable:"Not stable"

Measured memory_bytes: 6100
#include <iostream>
#include <string>

using namespace std;


int main(){

  // 標準入力
  int l, p, i=0, a[2];
  while (cin >> l){
    a[i] = l;
    i++;
  }

  p = a[0] * a[1];

  if (p % 2 == 0){
    cout << "Even" << "\n";
  } else {
    cout << "Odd" << "\n";
  }


  return 0;
}


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

int main(int argc, char const *argv[]) {
  string alphs;
  int m, h;
  while(cin >> alphs){
    if (alphs == "-") break;
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h;
      alphs = alphs + (alphs.substr(0, h));
      alphs.erase(0, h);
    }
    cout << alphs << endl;
  }
  return 0;
}

Measured memory_bytes: 3152
#include<stdio.h>
#define MAX 2000
 
int solve(int, int);
 
int n, A[MAX];
 
main()
{
  int q, m, i;
 
  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      scanf("%d", &A[i]);
    }
 
  scanf("%d", &q);
  for(i=0; i<q; i++)
    {
      scanf("%d", &m);
 
      if(solve(0, m))printf("yes\n");
      else printf("no\n");
    }
 
  return 0;
}
 
int solve(int i, int m)
{
  if(A[i] == m)return 1;
  if(i+1 == n)return 0;
  if(solve(i+1, m-A[i]) || solve(i+1, m))return 1;
  return 0;
} 

Measured memory_bytes: 2596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int a, b, m, n;

ll fpm(ll a, ll b) {
	ll ret = 1ll;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)ret = ret * a % mod;
	return ret;
}
ll C(ll a, ll b) {
	ll x = 1, y = 1;
	for (int i = 1; i <= a; ++i) {
		x = x * i % mod;
	}
	for (int j = 1; j <= b; ++j) {
		x = x * j % mod;
	}
	x = fpm(x, mod - 2);
	for (int i = 1; i <= a + b; ++i) {
		y = y * i % mod;
	}
	return x * y % mod;
}
void solve() {
	scanf("%d%d", &a, &b);
	/*a=2*m+n;
	b=2*n+m;
	a-b=m-n;
	a+b/3=m+n;*/
	if (!a || !b || (a + b) % 3) {
		puts("0");
		return;
	}
	m = a - b;
	n = (a + b) / 3;
	if ((m + n) & 1) {
		puts("0");
		exit(0);
	}
	a = (n - m) >> 1;
	b = (m + n) >> 1;
	if (a < 0 || b < 0) {
		puts("0");
		exit(0);
	}
	printf("%lld\n", C(a, b));
}
int main() {
	solve();

	return 0;
}

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

int main()
{
	int x[200];
	int y[200];
	int num;
	int n, d;
	int xmin, xmax, ymin, ymax;
	
	while (1) {
		cin >> num;
		if (num == 0) {
			break;
		}
		x[0] = 0;
		y[0] = 0;
		for (int i = 1; i < num; i++) {
			cin >> n >> d;
			switch (d) {
				case 0:
					x[i] = x[n] - 1;
					y[i] = y[n]; 
					break;
				case 1:
					x[i] = x[n];
					y[i] = y[n] + 1;
					break;
				case 2:
					x[i] = x[n] + 1;
					y[i] = y[n];
					break;
				case 3:
					x[i] = x[n];
					y[i] = y[n] - 1;
					break;
			}
		}
		xmin = 10000;
		xmax = -10000;
		ymin = 10000;
		ymax = -10000;
		for (int i = 0; i < num; i++) {
			if (x[i] < xmin)
				xmin = x[i];
			if (x[i] > xmax)
				xmax = x[i];
			if (y[i] < ymin)
				ymin = y[i];
			if (y[i] > ymax)
				ymax = y[i];
		}
		cout << xmax - xmin + 1 << " " <<  ymax - ymin + 1 << endl;
	}
	return 0;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n, k;
int a[2009], b[2009];
vector<int> G[2009];

int ans = 1 << 30;
int d[2009];

void dfs(int v, int p) {
    for(auto &&u : G[v])
        if(u != p) {
            d[u] = d[v] + 1;
            dfs(u, v);
        }
}

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

    cin >> n >> k;
    rep(i, n - 1) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    if(k & 1) {
        rep(i, n - 1) {
            d[a[i]] = d[b[i]] = 0;
            dfs(a[i], b[i]);
            dfs(b[i], a[i]);
            int cnt = 0;
            rep(i, n) cnt += (d[i] > k / 2);
            chmin(ans, cnt);
        }
    } else {
        rep(i, n) {
            d[i] = 0;
            dfs(i, -1);
            int cnt = 0;
            rep(i, n) cnt += (d[i] > k / 2);
            chmin(ans, cnt);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void s_g_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	s_g_c();
	int n;
	cin >> n;
	int a[n];
	int freq[100005] = {0};
	int sum = 0;
	rep(i, 0, n)
	{
		cin >> a[i];
		sum += a[i];
		freq[a[i]]++;
	}
	w(k)
	{
		int l, r;
		cin >> l >> r;
		sum += (freq[l] * r) - (freq[l] * l);
		freq[r] += freq[l];
		freq[l] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 5224
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, W;
int dp[200000];
int w[200000], v[200000];
signed main() {
	cin >> n >> W;
	for (int i = 1; i <= 100000; i++) {
		dp[i] = Inf;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
		for (int j = 100000-v[i]; j >= 0; j--) {
			if (dp[j] < Inf&&dp[j] + w[i] <= W) {
				dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
				ans = max(ans, j + v[i]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2304
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

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

	int N;
	cin >> N;
	ll sum = 0;
	REP(i, N) {
		int A;
		cin >> A;
		sum += A;
	}
	cout << (sum%2==0?"YES":"NO") << endl;
	return 0;
}


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

bool judge(int *x){
  bool p=true;
  rep(i,0,20){
    if(x[i]>1){
      p=false;
    }
  }
  return p;
}

int main(){
  int n;
  cin>>n;
  ll a[n];
  rep(i,0,n){
    cin>>a[i];
  }
  int b[n][20];
  rep(i,0,n){
    rep(j,0,20){
      if(a[i]>>j & 1){
        b[i][j]=1;
      }
      else{
        b[i][j]=0;
      }
    }
  }
  
  ll ans=0;
  int s=0;
  int t=0;
  int cur[20];
  rep(i,0,20){
    cur[i]=0;
  }
  while(true){
    while(t<n && judge(cur)){
      rep(i,0,20){
        cur[i]+=b[t][i];
      }
      t++;
    }
    if(s==n) break;
    if(t==n && judge(cur)) t++;
    rep(i,0,20){
      cur[i]-=b[s][i];
    }
    s++;
    ans+=t-s;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 17408
S = list(input())
before = 0
last_upper = -1
count = 0
answer = 0
for i, s in enumerate(S):
  # print(answer, i, before, last_upper)
  if s == '<':
    if before < 0 and last_upper < i-1:
      answer += abs(before)*(i-last_upper)
      before = 0
    elif before > 0 and last_upper < i-1:
      answer -= before*(i-last_upper-1)
      before = 0
    before += 1
    answer += before
    last_upper = i
  else:
    before -= 1
    answer += before
# print(answer, before, last_upper)
if before < 0:
  answer += abs(before)*(len(S)-last_upper)
elif before > 0:
  answer -= before*(len(S)-last_upper-1)
print(answer)


Measured memory_bytes: 97508
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String input = sc.next();
			char[] chars = input.toCharArray();
			System.out.println(count(chars));
		}
	}

	private static int count(char[] chars) {
		int len = chars.length;
		int maxCount = 0;
		int count = 0;
		for (int i = 0; i < len; i++) {
			if (isATGC(chars[i])) {
				count++;
			} else {
				maxCount = count > maxCount ? count : maxCount;
				count = 0;
			}
		}
		maxCount = count > maxCount ? count : maxCount;
		return maxCount;
	}

	private static boolean isATGC(char c) {
		return (c == 'A' || c == 'C' || c == 'G' || c == 'T');
	}
}


Measured memory_bytes: 24916
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 200001;
int n, m; 
vector<pair<int,int>> g[N];
string id[N];

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0; i<m; ++i){
         int x, y; 
         scanf("%d%d", &x, &y);
         g[x].push_back({y, i+1});
    }
    for(int i = 1; i<=n; ++i){
        sort(all(g[i]));
        int c = 1; 
        string x = "";
        stringstream ss; 
        ss << i; 
        ss >> x;
        while(x.size() < 6)x = '0'+x;
        for(auto j: g[i]){
            id[j.second] = x;
            string y = "";
            ss.clear();
            ss << c; 
            ss >> y; 
            while(y.size() < 6)y = '0'+y;
            id[j.second] += y;
            ++c;  
        }
    }
    for(int i = 1; i<=m; ++i)printf("%s\n", id[i].c_str());
}

Measured memory_bytes: 13952
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
vector<int>G[100000];
int n;
pair<int,bool>dfs(int u,int p,int no)
{
	int cnt=1;
	bool flag=no==u;
	for(int i=0;i<G[u].size();i++)
	{
		if(G[u][i]==p)continue;
		pair<int,bool>p=dfs(G[u][i],u,no);
		cnt+=p.first;
		flag|=p.second;
	}
	return make_pair(cnt,flag);
}
int parent[1<<17],d[1<<17];
main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;++i<n;)d[i]=1e9;
	queue<int>P;
	P.push(0);
	while(!P.empty())
	{
		int u=P.front();P.pop();
		for(int i=0;i<G[u].size();i++)
		{
			if(d[G[u][i]]>d[u]+1)
			{
				d[G[u][i]]=d[u]+1;
				parent[G[u][i]]=u;
				P.push(G[u][i]);
			}
		}
	}
	int backn,F,S;
	if(d[n-1]%2)
	{
		backn=d[n-1]/2;
		F=n-1,S;
		for(int i=0;i<backn;i++)
		{
			F=parent[F];
		}
		S=F,F=parent[F];
	}
	else
	{
		backn=d[n-1]/2;
		F=n-1,S;
		for(int i=0;i<backn-1;i++)
		{
			F=parent[F];
		}
		S=F,F=parent[F];
	}
	int cntF=1,cntS=1;
	for(int i=0;i<G[F].size();i++)
	{
		pair<int,bool>p=dfs(G[F][i],F,S);
		if(!p.second)cntF+=p.first;
	}
	for(int i=0;i<G[S].size();i++)
	{
		pair<int,bool>p=dfs(G[S][i],S,0);
		if(!p.second)cntS+=p.first;
	}
	cout<<(cntF<=cntS?"Snuke":"Fennec")<<endl;
}

Measured memory_bytes: 10368
#include <stdio.h>

int main(void)
{
	int a,b,c,count_5,count_7;
	scanf("%d %d %d",&a,&b,&c);
	int s[]={a,b,c};
	
	for(int i=0;i<3;i++){
		if(s[i]==5){
			count_5++;
		}
		if(s[i]==7){
			count_7++;
		}
	}
	
	if(count_5==2&&count_7==1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
		
	return 0;
		
}
		

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_N (100)
#define MAX_M (100)

int N, M;
int T[MAX_N], P[MAX_M], X[MAX_M];
ll SUM;

void solve() {
  for (int i = 0; i < M; i++) {
    int ans = SUM - T[P[i]] + X[i];
    printf("%d\n", ans);
  }
}

int main() {
  SUM = 0;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &T[i]);
    SUM += T[i];
  }
  scanf("%d", &M);
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &P[i], &X[i]);
    P[i]--;
  }

  solve();

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    vector<char> bubbleA(n);
    vector<int> bubbleB(n);
    
    vector<char> selectA(n);
    vector<int> selectB(n);
    
    for (int i=0; i<n; i++){
        cin >> bubbleA[i] >> bubbleB[i];
        selectA[i] = bubbleA[i];
        selectB[i] = bubbleB[i];
    }
    
    //bubble sort
    for (int i=0; i<n-1; i++){
        for(int j=n-1; j>i; j--){
            if (bubbleB[j] < bubbleB[j-1]){
                swap(bubbleA[j], bubbleA[j-1]);
                swap(bubbleB[j], bubbleB[j-1]);
            }
        }
    }
    
    //selection sort
    for (int i=0; i<n-1; i++){
        int mini = i;
        for (int j=i; j<n; j++){
            if (selectB[j] < selectB[mini]){
                mini = j;
            }
        }
        swap(selectA[i], selectA[mini]);
        swap(selectB[i], selectB[mini]);
    }
    
    for (int i=0; i<n; i++){
        if(i) cout << " ";
        cout << bubbleA[i] << bubbleB[i];
    }
    cout << endl << "Stable" << endl;
    
    //stable check
    bool check = true;
    for (int i=0; i<n; i++){
        if (bubbleA[i] == selectA[i] && bubbleB[i] == selectB[i]){
            continue;
        }
        check = false;
        break;
    }
    
    for (int i=0; i<n; i++){
        if(i) cout << " ";
        cout << selectA[i] << selectB[i];
    }
    cout << endl;
    if (check) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b,c=0;
    scanf("%d",&k);
    scanf("%d%d",&a,&b);
    for(int i=a; i<=b; i++)
    {
        if(i%k==0)
        {
            c++;
            break;
        }
    }
    if(c==0)
        printf("NG\n");
    else
        printf("OK\n");
    return 0;
}


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

using namespace std;
typedef long long ll;
string s;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> s;
	int sum = 0;
	reverse(s.begin(), s.end());
	s += "000";
	int n = s.size(), carry = 0;
	for(int i = 0; i < n; i ++){
		carry += (s[i] - '0')*9;
		s[i] = (carry % 10) + '0';
		sum += carry % 10;
		carry /= 10;	
	}
	int ans = 0;
	while( true ){
		ans ++;
		int carry = 9;
		for (int i = 0; i < n; i ++){
			if(carry == 0) break;
			carry += (s[i] - '0');
			sum += (carry % 10) - (s[i] - '0');
			s[i] =(carry % 10) + '0';
			carry /= 10;
		}
		if( sum <= 9*ans) return cout << ans << endl, 0;
	}
	return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define bit(x,i) (x>>(i-1)&1ll)
#define onbit(x,i) (x|(1ll<<(i-1)))
#define offbit(x,i) (x&~(1ll<<(i-1)))

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> tpa;
typedef long long ll;
typedef unsigned long long ull;

template<typename X,typename Y> void Max(X &x,Y y){
	x=(x>y)?x:y;
}
template<typename X,typename Y> void Min(X &x,Y y){
	x=(x<y)?x:y;
}

const int N=19;
int n,a[N][2],f[1<<N][N],oo;

main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.tpa", "r", stdin);
	cin>>n;
	for(int o=0; o<=1; ++o){
		for(int i=1; i<=n; ++i) cin>>a[i][o];
	}
	memset(f, 127, sizeof(f));
	oo=f[0][0];
	int all_sta=(1ll<<n)-1;
	for(int i=1; i<=n; ++i) f[1<<(i-1)][i]=0;
	for(int sta=0; sta<=all_sta; ++sta){
		int p=__builtin_popcount(sta)+1;
		for(int i=1; i<=n; ++i){
			if(!bit(sta,i)) continue;
			for(int j=1; j<=n; ++j){
				if(bit(sta,j)) continue;
				int u=a[i][abs(p-1-i)%2],v=a[j][abs(p-j)%2];
				if(u>v) continue;
				int need=0;
				for(int k=j+1; k<=n; ++k){
					if(bit(sta,k)) need++;
				}
				f[onbit(sta,j)][j]=min(f[onbit(sta,j)][j],f[sta][i]+need);
			}
		}
	}
	int ans=oo;
	for(int i=1; i<=n; ++i) ans=min(ans,f[all_sta][i]);
	if(ans==oo) cout<<-1;
	else cout<<ans;
}

Measured memory_bytes: 78080
from collections import defaultdict
R, C, K = map(int, input().split())
rc2v = defaultdict(int)
for _ in range(K):
    r, c, v = map(int, input().split())
    r-=1
    c-=1
    rc2v[(r, c)]=v

dp = [0] * C
for r in range(R):
    dp_ = [[0] * C for _ in range(4)]
    for c in range(C):
        dp_[3][c] = max(dp_[3][c-1], dp[c])
        dp_[2][c] = dp_[2][c-1]
        dp_[1][c] = dp_[1][c-1]
        dp_[0][c] = dp_[0][c-1]
        if (r, c) in rc2v:
            dp_[0][c] = max(dp_[0][c-1], dp_[1][c]+rc2v[(r, c)])
            dp_[1][c] = max(dp_[1][c-1], dp_[2][c]+rc2v[(r, c)])
            dp_[2][c] = max(dp_[2][c-1], dp_[3][c]+rc2v[(r, c)])
        dp[c] = max(dp_[3][c], dp_[2][c], dp_[1][c], dp_[0][c])

print(dp[-1])


Measured memory_bytes: 131800
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 1e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int n, k;
int a[105];
int dp[105][maxN];

// here dp[i][j] will store the prefix sum of the diff no. of ways to distribute
// j candies among i children with the given upper bound constraints

int solve(int child, int candy) {
	if (candy < 0) return 0;
	if (candy == 0) return 1;
	if (child == n + 1) return 1;
	//
	int& dd = dp[child][candy];
	if (dd != -1) return dd;
	// max amt of candies that can be given to the child
	int mini = min(candy, a[child]);
	dd = solve(child + 1, candy) - solve(child + 1, candy - mini - 1) + MOD;
	dd %= MOD;
	dd += solve(child, candy - 1);
	dd %= MOD;
	return dd;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	FIO
	// Ashishgup you're great bro
	cin >> n >> k;
	memset(dp, -1, sizeof(dp));
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ans = solve(1, k) - solve(1, k - 1) + MOD;
	ans %= MOD;
	cout << ans;
	return 0;
}


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

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<int> rain(N);
    int x = 0;
    for (int i = 0; i < N; i++) {
        if(i%2) x -= A[i];
        else x += A[i];
    }
    rain[0] = x;
    for(int i = 1; i < N; i++){
        rain[i] = abs(rain[i-1]/2 - A[i-1])*2;
    }
    for(int i = 0; i < N-1; i++){
        cout << rain[i] << " ";
    }
    cout << rain[N-1];
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;
template<typename Monoid, typename Operand>
class SegTree {
public:
	Monoid* tree;
	size_t size;
	int32 i;
	//?????????????????????
	SegTree(size_t length) {
		--length;
		size = length;
		if (size & 0xffff0000) { size = size & 0xffff0000; }
		if (size & 0xff00ff00) { size = size & 0xff00ff00; }
		if (size & 0xf0f0f0f0) { size = size & 0xf0f0f0f0; }
		if (size & 0xcccccccc) { size = size & 0xcccccccc; }
		if (size & 0xaaaaaaaa) { size = size & 0xaaaaaaaa; }
		if (length) { size <<= 1; }
		else { size = 1; }
		tree = (Monoid *)calloc(size << 1, sizeof(Monoid));
	}
	//?????????
	void set(bool merge) {
		i = size << 1;
		while (--i) { tree[i].set(); }
		if (merge) {
			i = size;
			while (--i) { tree[i] = tree[i << 1] + tree[i << 1 | 1]; }
		}
	}
	//tree[index]???data??§??´??°
	void update(size_t index, Operand &data) {
		index += size;
		tree[index] = tree[index] * data;
		while (index >>= 1) tree[index] = tree[index << 1] + tree[index << 1 | 1];
	}
	//[begin,end)??????????????????
	Monoid range(size_t begin, size_t end) {
		Monoid retL, retR;
		for (begin += size, end += size;begin < end;begin >>= 1, end >>= 1) {
			if (begin & 1) retL = retL + tree[begin++];
			if (end & 1)  retR = tree[end - 1] + retR;
		}
		return retL + retR;
	}
};
struct SUB {
	int32 e;
	SUB() { set(); }
	SUB(int32 x) { e = x; }
	void set() { e = 1000000000; }
	SUB operator*(const SUB &other) {
		return other;
	}
};
struct MIN {
	int32 e;
	MIN() { set(); }
	MIN(int32 x) { e = x; }
	void set() { e = 2147483647; }
	MIN operator+(const MIN &other) {
		return e < other.e ? MIN(e) : MIN(other.e);
	};
	MIN operator*(const SUB &other) {
		return MIN(other.e);
	}
};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	size_t n, q;
	cin >> n >> q;
	bool c;
	size_t x, y;
	SUB z;
	SegTree<MIN, SUB> t(n);
	t.set(0);
	while (q--) {
		cin >> c;
		if (c) {
			cin >> x >> y;
			printf("%d\n", t.range(x, y + 1).e);
		}
		else {
			cin >> x >> z.e;
			t.update(x, z);
		}
	}
	return 0;
}

Measured memory_bytes: 5272
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int inputNumber     = sc.nextInt();
        int inputNumber2    = sc.nextInt();
        int inputNumber3    = sc.nextInt();
        
        int count = 0;
        for(int i = inputNumber; i <= inputNumber2; i++){
            if((inputNumber3 % i) == 0){
                count++;
            }
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 26404
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    d = dict()
    count = 0
    ar = [(a[i]+i+1) for i in range(n)]
    br = [(i+1-a[i]) for i in range(n)]
    for i in range(n):
        if d.get(ar[i]) is not None:
            d[ar[i]] += 1
        else:
            d[ar[i]] = 1
    c = dict()
    for i in range(n):
        if c.get(br[i]) is not None:
            c[br[i]] += 1
        else:
            c[br[i]] = 1
    count = 0
    for no in c.keys():
        if d.get(no) is not None:
            count += (c[no]*d[no])
    
    print(count)

    
    






Measured memory_bytes: 63008
x = int(input())
if 1 <= x and x <= 99:
  print(0)
  exit()
elif 106 <= x and x <= 199:
  print(0)
  exit()
elif 211 <= x and x <= 299:
  print(0)
  exit()
elif 316 <= x and x <= 399:
  print(0)
  exit()
elif 421 <= x and x <= 499:
  print(0)
  exit()
elif 526 <= x and x <= 599:
  print(0)
  exit()
elif 631 <= x and x <= 699:
  print(0)
  exit()
elif 736 <= x and x <= 799:
  print(0)
  exit()
elif 841 <= x and x <= 899:
  print(0)
  exit()
elif 946 <= x and x <= 999:
  print(0)
  exit()
elif 1051 <= x and x <= 1099:
  print(0)
  exit()
elif 1156 <= x and x <= 1199:
  print(0)
  exit()
elif 1261 <= x and x <= 1299:
  print(0)
  exit()
elif 1366 <= x and x <= 1399:
  print(0)
  exit()
elif 1471 <= x and x <= 1499:
  print(0)
  exit()
elif 1576 <= x and x <= 1599:
  print(0)
  exit()
elif 1681 <= x and x <= 1699:
  print(0)
  exit()
elif 1786 <= x and x <= 1799:
  print(0)
  exit()
elif 1891 <= x and x <= 1899:
  print(0)
  exit()
elif 1996 <= x and x <= 1999:
  print(0)
  exit()
else:
  print(1)
  exit()

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

void reverse(int *array, int length) {
        int i;
        int j;
        for(i=0;i<length-1;i++){
                for(j=i+1;j<length;j++){
                        if(array[i]<array[j]){
                                int temp=array[i];
                                array[i]=array[j];
                                array[j]=temp;
                        }
                }
        }
}

int main() {
        int mountain[10];
        for (int i = 0; i < 10; i++) {
                cin >> mountain[i];
        }
        reverse(mountain, 10);
        for (int i = 0; i < 3; i++) {
                cout << mountain[i] << endl;
        }
}

Measured memory_bytes: 0
n = int(input())
t=list(map(int,input().split()))
m=int(input())
ans=0
for j in range(n):
    ans+=t[j]
for i in range(m):
    y=ans
    p,x=map(int,input().split())
    y=y-t[p-1]+x
    print(y)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
#define SP setprecision
#define PI 3.141592653589793
string s;
int W, H, x, y, a, b, c, num[5];
double r;

int main() {
	cin >> r;
	cout << SP(18) << r*r*PI << " " << r*2*PI << endl;

	return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int k,a,b;
    cin >> k >> a >> b;
    long long int c = b - a,result=1ll;
    if(c<2){
        result += k;

    }else{
        k -= a - 1;
        result += a - 1;
        if(k&1){
            k--;
            result++;
        }
        result += (b - a) * (k / 2ll);
    }
    cout << result << endl;
    return 0;
}


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

int dis(P x,P y){
  return abs(x.first-y.first)+abs(x.second-y.second);
}

int main(){
  int n;
  cin>>n;
  ll a[5]={0,0,0,0,0};
  rep(i,0,n){
    string s;
    cin>>s;
    if(s[0]=='M'){
      a[0]++;
    }
    if(s[0]=='A'){
      a[1]++;
    }
    if(s[0]=='R'){
      a[2]++;
    }
    if(s[0]=='C'){
      a[3]++;
    }
    if(s[0]=='H'){
      a[4]++;
    }
  }
  ll ans=0;
  ans+=a[0]*a[1]*a[2];
  ans+=a[0]*a[1]*a[3];
  ans+=a[0]*a[1]*a[4];
  ans+=a[0]*a[2]*a[3];
  ans+=a[0]*a[2]*a[4];
  ans+=a[0]*a[3]*a[4];
  ans+=a[1]*a[2]*a[3];
  ans+=a[1]*a[2]*a[4];
  ans+=a[1]*a[3]*a[4];
  ans+=a[2]*a[3]*a[4];
  cout<<ans<<endl;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const int MAX_N=1000000;
const ll P=1000000000+7;
// 1baseでs1,...,snの和を計算
class BIT{
private:
  ll bit[MAX_N];
  int n;
public:
  BIT(int sz){
    n=sz;
    for(int i=0;i<=n;i++)
      bit[i]=0;
  }
  ll sum(int i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      s%=P;
      i-=i&-i;
    }
    return s;
  }
  // from-to間の総和を求める
  ll rangeSum(int from,int to){
    ll res=0;
    res=(sum(to)-sum(from-1)+P)%P;
    return res;
  }
  void add(int i,ll x){
    while(i<=n){
      bit[i]+=x;
      bit[i]%=P;
      i+=i&-i;
    }
  }
  // sumとaddを組み合わせて、iの場所にxの値を代入
  void insert(int i,ll x){
    add(i,-(sum(i)-sum(i-1))+x);
  }
};

BIT bit(800000);
int N, K;
int A[200010];
map<ll, int> num_to_idx;

int main(){

    set<ll> s;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A[i] -= K;
    }
    {
        s.insert(A[0]);
        s.insert(0);
        ll base = 0;
        for(int i = 1; i < N; i++){
            base -= A[i];
            s.insert(base);
        }
        for(ll a : s){
            int idx = num_to_idx.size() + 1;
            num_to_idx[a] = idx;
        }
    }

    ll ans = 0;
    if(A[0] >= 0) ans++;
    bit.add(num_to_idx[A[0]], 1);
    ll base = 0;
    for(int i = 1; i < N; i++){
        bit.add(num_to_idx[base], 1);
        base -= A[i];
        ans += bit.rangeSum(num_to_idx[base], 500000);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 30336
#include <iostream>
#include <cmath>
using namespace std;
unsigned int a, b, c;
int main() {
  cin >> a >> b >> c;
  if (a>100 or b>100 or c>100){
  cout << "Unaccepted values";
  } else if (a<b && b<c){
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

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

#define N 100010
#define MOD 1000000007

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	string s, t;
	int a, b;
	cin >> s >> t >> a >> b;
	string s1;
	cin >> s1;

	if ( s == s1)
		a--;
	else 
		b--;

	cout << a << " " << b;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();

            var convet = line.Select(l =>
            {
                if ('a' <= l && l <= 'z')
                {
                    return l - 'a' + 'A';
                }
                else if ('A' <= l && l <= 'Z')
                {
                    return l - 'A' + 'a';
                }
                else
                {
                    return l;
                }
            })
            .Select(x => ((char)x).ToString())
            .ToArray();

            System.Console.WriteLine(string.Join("", convet));
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll w[101],v[101];
ll dp[100001];
int main(){
    int n,W;
    cin>>n>>W;
    rep(i,n) cin>>w[i]>>v[i];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    rep(i,n)for(int j=W;j>=w[i];--j){
        if(dp[j-w[i]]!=-1){
            dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    ll ans=0;
    rep(i,W+1) ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if(a[0] == a[1] && a[1] == a[2])cout << "No";
  else if(a[0] != a[1] && a[1] != a[2] && a[0] != a[2])cout << "No";
  else cout << "Yes";
}

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



using namespace std;

int main(){

string a,b;

cin>>a>>b;

string c=a+b;

int n=stoi(c);

string ans;
for(int i=1;i<=1000;i++){
if((i*i)==n){
ans="Yes";
break;
}
else{
 ans="No";
}


}

cout<<ans<<endl;
}











Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(a, b, c) for(ll c=a;c<b;c++)
#define re(b, c) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll d(n);
  re(n, i) std::cin >> d[i];
  if(n>=24){
    std::cout << 0 << '\n';
    return 0;
  }
  int ans = 0;

  for(int i=0;i<(1<<n);i++){
    vector<short> v(24, 0);
    int tmp = 24;
    v[0]++;
    for(int j=0;j<n;j++){
      if((i&(1<<j))!=0||d[j]==0) {
        if(v[d[j]]==1){
          tmp = 0;
          break;
        }
        v[d[j]]++;
      }else {
        if(v[24-d[j]]==1){
          tmp = 0;
          break;
        }
        v[24 - d[j]]++;
      }
    }
    int m = 0;
    for(int j=1;j<24;j++){
      if(v[j]==1){
        tmp = min(tmp, j-m);
        m = j;
      }
    }
    tmp = min(tmp, 24-m);
    ans = max(ans, tmp);
    //std::cout << tmp << '\n';
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 888
#2-1-1 #ARC061C
s=input()
lenth=len(s)
kugiri=set()
def roop(before,now,kugiri):
    if now==lenth:
        kugiri|={before,}
        return kugiri
    kugiri = roop(before+(0,),now+1,kugiri)
    kugiri = roop(before+(1,),now+1,kugiri)
    return kugiri


def calc(ans,kugiri,s):
    test=s
    now=test[0]
    test=test[1:]
    for i in range(len(s)-1):
        k=kugiri[i]
        if k==0:
            now+=test[0]
        elif k==1:
            ans+=int(now)
            now=test[0]
        test=test[1:]
        if i==len(s)-2:ans+=int(now)
    return ans
            
ans=0
if len(s)!=1:
    kugiri = roop((0,),2,kugiri)
    kugiri = roop((1,),2,kugiri)
    for i in kugiri:
        ans=calc(ans,i,s)
    print(ans)
elif len(s)==1:print(int(s))

Measured memory_bytes: 3064