akhauriyash/Code-Regression huggingface dataset:
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let s = next()
    let ans = 0
    for(let i = 0; i<s.length-2; i++){
        let tmp = s.slice(i, i+3)
        if(tmp == "ABC") ans++
    }
    console.log(ans)
}
Main()


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

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using namespace std;

/* function */
//  - none - 


/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int N;    // input
  string ans;  // output

  int i, j, k;    // subscript
  int count;


  /* Input, Array_Proclamation */
  cin >> N;
  vector<int> A(N);


  for(i=0; i<N; i++)
  {
    cin >> A.at(i);
  }


  /* Initialize */
  count = 0;



  /* Calculation */
  for(i=0; i<N; i++)
  {
    if( (A.at(i) %2) != 0 )
    {
      count++;
    }
  }

  

  /* Output */
  if(count %2 == 0)
  {
    ans = "YES";
  }
  else
  {
    ans = "NO";
  }
  

  cout << ans << endl;


  return 0;

}


/* entity */
//  - none -




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

int main(){
    int i, a, t = 0, m = 10, m2 = 0;
    for(i=0; i<5; i++){
        cin >> a;
        if(a%10 != 0){
            m = min(m, a%10);
        }
        t += (((a-1)/10) + 1)*10;
    }
    if(m != 10){
        t = t-10+m;
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N, K;
    cin >> N >> K;
    V v(N);
    rep(i, N)cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());
    ll sum = 0;
    rep(i, N)if(i >= K)sum += v[i];
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn get_op(v: &i32) -> char {
    if *v == 1 {
        '+'
    } else {
        '-'
    }
}
fn main() {
    let vs = read::<String>()
        .chars()
        .map(|c| c as i32 - '0' as i32)
        .collect::<Vec<i32>>();
    for op1 in [-1, 1].iter() {
        for op2 in [-1, 1].iter() {
            for op3 in [-1, 1].iter() {
                if vs[0] + op1 * vs[1] + op2 * vs[2] + op3 * vs[3] == 7 {
                    println!(
                        "{}{}{}{}{}{}{}=7",
                        vs[0],
                        get_op(op1),
                        vs[1],
                        get_op(op2),
                        vs[2],
                        get_op(op3),
                        vs[3]
                    );
                    return;
                }
            }
        }
    }
}


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

int main(){
        int k;
        string s;
        cin>>s>>k;
        vector<string> ans;
        for(int i=0;i<s.size();i++){
                for(int j=1;j<=k;j++){
                        ans.push_back(s.substr(i,j));
                }
        }

        sort(ans.begin(),ans.end());
        unique(ans.begin(),ans.end());
        cout<<ans[k-1]<<endl;
}

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

using namespace std;

typedef long long ll;

ll C[2020], K[2020];
ll n,x,ans;

int main()
{
	ll i,j,k;
	
	ans = 1e18;
	
	scanf("%lld%lld",&n,&x);
	
	for(i=0;i<n;i++){
		scanf("%lld",C+i);
		K[i] = C[i];
	}
	
	for(i=0;i<n;i++){
		k = x * i;
		for(j=0;j<n;j++){
			K[j] = min(K[j], C[(j-i+n)%n]);
			k += K[j];
		}
		ans = min(ans, k);
	}
	
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 256
import bisect

n,q = map(int, input().split())
aList = list(map(int, input().split()))

sumList=[]
sep2SumList=[]
for i in range(n):
    if i==0:
        sumList.append(aList[i])
    else:
        sumList.append(sumList[-1]+aList[i])
    if n%2==0:
        if i%2==1:
            if i==1:
                sep2SumList.append(aList[i])
            else:
                sep2SumList.append(sep2SumList[-1]+aList[i])
    else:
        if i%2==0:
            if i==0:
                sep2SumList.append(aList[i])
            else:
                sep2SumList.append(sep2SumList[-1]+aList[i])

                
sakaime=[]
anskazu=(n+1)//2
for i in range(anskazu):
    sakaime.append((aList[n-(i+1+1)]+aList[n-((i+1+1)*2-1)])//2)
sakaime.reverse()
sakaime=sakaime[1:]

def kotae(x):
    bisect.bisect_left(sakaime,x)
    num=len(sakaime)+1-bisect.bisect_left(sakaime,x)
    if num==len(sakaime)+1:
        ans=sumList[-1]-sumList[-1-num]
    else:
        ans=sumList[-1]-sumList[-1-num]+sep2SumList[(n-num*2+1)//2-1] #+1することで奇数を吸収
    return ans

for i in range(q):
  x=int(input())
  print(kotae(x))

Measured memory_bytes: 20196
#include<stdio.h>
#define MAX 100
#define INF 999999
#define NIL -1
#define WHITE 0
#define BLACK 2
  
int prim();
  
int n, G[MAX][MAX];
  
int main()
{
  int i, j;
  
  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      for(j=0; j<n; j++)
    {
      scanf("%d", &G[i][j]);
    }
    }
    
  printf("%d\n", prim());
    
  return 0;
}
  
int prim()
{
  int u, i, v, mincost, d[n], pi[n], color[n], sum=0;
  
  for(u=0; u<n; u++)
    {
      d[u] = INF;
      pi[u] = NIL;
      color[u] = WHITE;
    }
  
  d[0] = 0;
  while(1)
    {
      mincost = INF;
  
      for(i=0; i<n; i++)
    {
      if(color[i] != BLACK && d[i] < mincost)
        {
          mincost = d[i];
          u = i;
        }
    }
        
      if(mincost == INF) break;
        
      color[u] = BLACK;
        
      for(v=0; v<n; v++)
    {
      if(color[v] != BLACK && G[u][v] < d[v] && G[u][v] != -1)
        {
          pi[v] = u;
          d[v] = G[u][v];
        }
    }
    }
  
  for(i=0; i<n; i++)
    {
      if(d[i] != INF) sum += d[i];
    }
  
  return sum;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define pb                  push_back
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)      type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
vi adj[N];
int vis[N];
void dfs(int src){
    vis[src]=1;
    for(auto i: adj[src]){
        if(!vis[i]){
            dfs(i);
        }
    }
}
void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int n,m;cin>>n>>m;
    fo0(i,m){
        int u,v;cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            dfs(i);
            cnt++;
        }
    }
    cout<<cnt-1<<endl;
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<fixed<<setprecision(3)<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 13572
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] a = new int[q + 1];
		for (int i = 1; i < q + 1; i++)
			a[i] = sc.nextInt();

		int[] score = new int[n + 1];
		for (int i = 1; i < n + 1; i++)
			score[i] = k;

		for (int i = 1; i < q + 1; i++)
			score[a[i]]++;

		for (int i = 1; i < n + 1; i++)
			System.out.println(score[i] - q > 0 ? "Yes" : "No");

	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

}

Measured memory_bytes: 42716
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    int a, b;
    cin >> a >> b;
    if(a > 9 || b > 9) cout << -1 << endl;
    else cout << a * b << endl;

    return 0;

}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a * b,c * d) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

ans = [0] * N
for i in range(len(A)):
    ans[A[i]-1] = i + 1

print(*ans)


# L = []
# for i, a in enumerate(A):
#     L.append([i+1, a])
# L = sorted(L,key=lambda x: x[1])

# ans = []
# for i in range(N):
#     ans.append(L[i][0])
# print(*ans)

    


Measured memory_bytes: 15940
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

    R = [0] * K
    for n in range(1, N + 1):
        R[n % K] += 1

    ans = 0
    for a in range(K):
        b = (K - a) % K
        if 2 * b % K == 0:
            ans += R[a] * R[b] * R[b]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 10328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] ary = new int [11];
		int r = sc.nextInt();
		int d = sc.nextInt();
		ary[0] = sc.nextInt();
		for(int i = 0; i < 10; i++){
			ary[i + 1] = ary[i] * r - d;
			System.out.println(ary[i + 1]);
		}
	}
}


Measured memory_bytes: 23124
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
d, x = inintm()

ans = 0

for _ in range(n):
    a = inint()
    for i in range(102):
        if a*i + 1 > d:
            break
        ans += 1

print(ans+x)


Measured memory_bytes: 65920
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
#define F(i,x,n) for(int i=x;i<=n;++i)
#define F_(i,x,n) for(int i=x;i>=n;--i)
using namespace std;
inline void read(ll &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
const int N = 35;
ll n, a[N], b[N], c[N], ans;
/**/
int main()
{
	// freopen("test.in","r",stdin);
	// freopen("test.out","w",stdout);
	read(n);
	for(int i=1; i<=n; i++) read(a[i]);
	for(int i=1; i<=n; i++) read(b[i]);
	for(int i=1; i< n; i++) read(c[i]);
	for(int i=1; i<=n; i++)
	{
		ans+=b[a[i]];
		if(i!=1&&a[i-1]+1==a[i]) ans+=c[a[i-1]];
	}
	cout<<ans<<'\n';
	return 0;
}

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

main(){
	int n;
	pair<int,int> p[100010];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p[i].first;
		p[i].second = i;
	}
	sort(p,p+n);
	for(int i=0;i<n;i++)
		cout<<p[i].second+1<<" ";
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    ll res = 0;
    string s;
    cin >> s;
    ll l = 0;
    ll r = n-1;
    while (l < r) {
        if (s[l] == 'R')
            l++;
        else if (s[r] == 'W')
            r--;
        else {
            res++;
            l++;
            r--;
        }
    }

    // cout << fixed << setprecision(6);
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
    //cin.rdbuf()->in_avail()
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    int n;
    cin>>n;
    map<vector<int>,ll> m;
    ll ret = 0ll;
    for(int i=0;i<n;++i){
        string str;
        cin>>str;
        vector<int> num(26);
        for(int j=0;j<(int)str.size();++j){
            num[str[j]-'a']++;
        }
        if(m.count(num))ret += m[num];
        m[num]++;
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
    int main(){
        int x1, y1, x2, y2, x, y;
            cin >> x1 >> y1 >> x2 >> y2;
        if(x1 <= x2){
            if(y1 <= y2){
                x = x2 - x1;
                y = y2 - y1;
                    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x;
            }else{
                x = x2 - x1;
                y = y2 - y1;
                    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x;
            }
        }else{
            if(y1 <= y2){
                x = x2 - x1;
                y = y2 - y1;
                    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x;
            }else{
                x = x2 - x1;
                y = y2 - y1;
                    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x;
            }
        }
    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);
		while(true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			if (n == 0 && x == 0) {
				break;
			}
			int count = 0;
			for (int i1 = 1; i1 <= n-2; i1++) {
				for (int i2 = i1+1; i2 <= n-1; i2++){
					for (int i3 = i2+1; i3 <= n; i3++) {
						if (i1 + i2 + i3 == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 26628
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e5 + 42;
int h[N];
int dp[N];
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int n = 0;

  cin >> n;

  for(int i = 0; i < n; i++) cin >> h[i];

  for(int i = 0; i < n; i++) dp[i] = 1e9 + 42;

  dp[0] = 0;

  for(int i = 0; i + 1 < n; i++) {
    if(i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
  }

  cout << dp[n - 1];

  return 0;
}
/*

*/


Measured memory_bytes: 4412
#include <stdio.h>

int main()
{
    int a,b,temp,gcd,i,j,a1,b1,store1,store2;
    while(scanf("%d%d",&a,&b) ==2){
        if(a<b){temp=a; a=b; b=temp;}
        a1=a; b1=b; store1=a;store2=b;
        for(;;){
            gcd=b;
            a%=b;
            if(a==0)break;
            b=a;
            a=gcd;
        }
        for(i=1,j=1;;){
            if(a1==b1)break;
            else if(b1<a1){b1=store2*i;i++;}
            else if(b1>a1){a1=store1*j;j++;}
        }
        printf("%d %d\n",gcd,a1);
    }
    return 0;
}

Measured memory_bytes: 1856
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

K=II()
S=SR()

if len(S) <=K:
    print(S)
else:
    print(S[:K] + "...")

Measured memory_bytes: 10416
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))



//*
//遅延セグ木ここから
//↓ここを変える
typedef struct sayouso{ll a,b;}sayouso;
typedef struct atai{ll a;}atai;
//↑ここを変える

typedef struct node{sayouso T;atai x;}node;
node *lsegN,*lseg;
ll lsegNUM,lsegk;

//↓ここから変える
sayouso sid={1,0};
atai aid={(1LL<<31)-1};
atai xx(atai x,atai y){
	atai ret;
	ret.a=x.a+y.a;
	return ret;
}
atai Tx(sayouso T,atai x){
	atai ret;
	ret.a=T.a*x.a+T.b;
	return ret;
}
sayouso TT(sayouso S,sayouso T){
	sayouso ret;
	ret.a=S.a*T.a;
	ret.b=S.b+S.a*T.b;
	return ret;
}
sayouso fT(sayouso T,ll k){
	sayouso ret;
	ret.a=T.a;
	ret.b=T.b<<k;
	return ret;
}
//↑ここまで変える

//要素数(2ベキ)でこれを呼ぶ
void lseguse(ll n){
	lsegN=(node*)calloc(2*n,sizeof(node));
	lsegNUM=n;
	lseg=lsegN+lsegNUM;
	lsegk=0;while(n/=2)lsegk++;
	rep(i,1,2*lsegNUM){
		lsegN[i].x=aid;
		lsegN[i].T=sid;
	}
}
//lseg[i].xに値を与えてから初期化
void lseginit(){
	for(ll i=lsegNUM-1;i>0;i--)lsegN[i].x=xx(lsegN[2*i].x,lsegN[2*i+1].x);
}
void lsegupdatesub(ll l,ll r,sayouso T,ll i,ll cl,ll cr,ll ck){
	if(l>=r)return;
	//disjointなとき
	if(cr<=l||r<=cl)return;
	//完全に含むとき
	if(l<=cl&&cr<=r){
		lsegN[i].T=TT(T,lsegN[i].T);
		return;
	}
	//どちらでもないとき
	//遅延伝播
	lsegN[2*i  ].T=TT(lsegN[i].T,lsegN[2*i  ].T);
	lsegN[2*i+1].T=TT(lsegN[i].T,lsegN[2*i+1].T);
	//再帰的に更新
	ll cm=(cl+cr)/2;
	lsegupdatesub(l,r,T,2*i  ,cl,cm,ck-1);
	lsegupdatesub(l,r,T,2*i+1,cm,cr,ck-1);
	//自身のnodeを更新
	lsegN[i].x=xx(Tx(fT(lsegN[2*i].T,ck-1),lsegN[2*i].x),Tx(fT(lsegN[2*i+1].T,ck-1),lsegN[2*i+1].x));
	lsegN[i].T=sid;
}
void lsegupdate(ll l,ll r,sayouso T){lsegupdatesub(l,r,T,1,0,lsegNUM,lsegk);}
atai lsegcalcsub(ll l,ll r,ll i,ll cl,ll cr,ll ck){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return Tx(fT(lsegN[i].T,ck),lsegN[i].x);

	ll cm=(cl+cr)/2;
	//遅延伝播(変更はないので配るだけで良い)
	lsegN[2*i  ].T=TT(lsegN[i].T,lsegN[2*i  ].T);
	lsegN[2*i+1].T=TT(lsegN[i].T,lsegN[2*i+1].T);
	lsegN[i].x=Tx(fT(lsegN[i].T,ck),lsegN[i].x);
	lsegN[i].T=sid;

	//左側だけ
	if(r<=cm)return lsegcalcsub(l,r,2*i  ,cl,cm,ck-1);
	//右側だけ
	if(cm<=l)return lsegcalcsub(l,r,2*i+1,cm,cr,ck-1);
	//両方
	return xx(lsegcalcsub(l,r,2*i,cl,cm,ck-1),lsegcalcsub(l,r,2*i+1,cm,cr,ck-1));
}
atai lsegcalc(ll l,ll r){return lsegcalcsub(l,r,1,0,lsegNUM,lsegk);}
//遅延セグ木ここまで
//*/


int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	lseguse(1<<17);
	while(q--){
		int t;
		scanf("%d",&t);
		if(t){
			int x;
			scanf("%d",&x);
			printf("%lld\n",lsegcalc(x,x+1).a);
		}
		else{
			int x,y,b;
			scanf("%d%d%d",&x,&y,&b);
			sayouso T={0,b};
			lsegupdate(x,y+1,T);
		}
	}
}


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

typedef long long lint;
typedef long double louble;

const char lf = '\n';

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline lint ty()
	{
		lint a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 300007 , mo = 998244353;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

lint jc[_],rjc[_];

void fuck(int n=_-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

inline lint C(int n,int m)
{
	if(n<m || n<0 || m<0)return 0;
	return jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

lint finder(lint a,lint b,lint n)
{
	if(a>n || b>n)return 0;
	return C(n,a)*C(n,b)%mo;
}

int n;
lint a,b,tar;

int main()
{
	ios::sync_with_stdio(0),cout.tie(0);
	
	fuck();
	n=ty(),a=ty(),b=ty(),tar=ty();
	lint ans=0;
	for(int i=0;i<=n;i++)if((tar-a*i)%b==0)ans=(ans+finder(i,(tar-a*i)/b,n))%mo;
	printf("%lld\n",ans);

	return 0;
}


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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[105][4]; // dp[i][j] = 条件を満たす長さiの文字列で、末尾がj(0:A 1:G 2:C 4:T)で終わるものの個数

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

    rep(j,4) {
        dp[0][j] = mint(0);
        dp[1][j] = mint(1);
        dp[2][j] = mint(4);
    }

    for(int i=3; i<=n; i++) {
        mint x = 0;
        rep(j,4) x += dp[i-1][j];

        // A
        dp[i][0] = x;

        // G
        dp[i][1] = x - dp[i-2][0] + dp[i-3][1]; // ACGはNG (GACGは引きすぎなので足す)

        // C
        dp[i][2] = x - dp[i-2][0] - dp[i-2][1]; // AGC, GACはNG
        dp[i][2] -= (dp[i-3][0] * 3);    // ATGC, AGGC, AGTC はNG

        // T
        dp[i][3] = x;
    }

    mint ans = 0;
    rep(j,4) ans += dp[n][j];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

int a,b,c;
cin>>a;
  b=a/3;
  c=b/3;
  if(a%3==0){cout<<b*b*b<<endl;}
  if(a%3==1){if(b%3==0){cout<<b*b*b+b*b+c<<".037037037"<<endl;}
             if(b%3==1){cout<<b*b*b+b*b+c<<".370370370"<<endl;}
            if(b%3==2){cout<<b*b*b+b*b+c<<".703703703"<<endl;}}
  if(a%3==2){if(b%3==0){cout<<b*b*b+2*b*b+4*c<<".296296296"<<endl;}
            if(b%3==1){cout<<b*b*b+2*b*b+4*c+1<<".629629629"<<endl;}
            if(b%3==2){cout<<b*b*b+2*b*b+4*c+2<<".962962962"<<endl;}}
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C);

// ===

fn main() {
    let x: i32 = read();
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", (x-a)%b);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   
   long int n;
   cin>>n;
   long int ans = 0;

   for(long int i = 1; i <= n; i++){
    for(long int j = 1; j <= n; j++){
      for(long int k = 1; k <= n; k++){
        long int g = __gcd(i,j);
        ans += __gcd(k,g);
      }
    }
   }

   cout<<ans;
   return 0;
}

Measured memory_bytes: 3640
N = int(input())
S = input()
K = int(input())

target = S[K-1]

index =[]

for i in range(0,N):
   if S[i] != target:
       index.append(i)

for j in range(0,len(index)):
   S = S[:index[j]] + '*' + S[index[j] + 1:]

print(S)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std; 
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
struct edge{int nx,t;}e[MN*2+5];
int h[MN+5],en,v[MN+5],l[MN+5],r[MN+5],o;
inline void ins(int x,int y)
{
	e[++en]=(edge){h[x],y};h[x]=en;
	e[++en]=(edge){h[y],x};h[y]=en;
}
void dfs(int x,int fa)
{
	l[x]=r[x]=v[x]?v[x]:1e9;
	for(int i=h[x];i;i=e[i].nx)if(e[i].t!=fa)
	{
		dfs(e[i].t,x);
		if(l[e[i].t]==1e9)continue;
		if(l[x]==1e9){l[x]=l[e[i].t]-1;r[x]=r[e[i].t]+1;continue;}
		if(~(l[x]-l[e[i].t])&1)o=1;
		l[x]=max(l[x],l[e[i].t]-1);r[x]=min(r[x],r[e[i].t]+1);
	}
	if(l[x]>r[x])o=1;
}
void solve(int x,int fa)
{
	for(int i=h[x];i;i=e[i].nx)if(e[i].t!=fa)
	{
		if(l[e[i].t]==1e9)l[e[i].t]=l[x]-1;
		else l[e[i].t]=max(l[e[i].t],l[x]-1);
		solve(e[i].t,x);
	}
}
int main()
{
	int n=read(),k,i;
	for(i=1;i<n;++i)ins(read(),read());
	for(k=read();k--;)i=read(),v[i]=read()+1;
	dfs(1,0);
	if(o)return 0*puts("No");puts("Yes");
	solve(1,0);
	for(i=1;i<=n;++i)printf("%d\n",l[i]-1);
}

Measured memory_bytes: 8704
#include <cstdio>
#include <cstring>
int main(){
	bool a=0;
	char s[5];
	scanf("%s",s);
	for(int i=0;i<=strlen(s);i++){
		if(s[i]=='C'&&a){
			printf("Yes\n");
			return 0;
		}
		a=0;
		if(s[i]=='A'){
			a=1;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>

using namespace std;

int a, b;
int n;

bool cant[20][20];
int dp[20][20];

void solve() {
	memset(dp, 0, sizeof(dp));
	
	dp[1][1] = 1;
	for (int i=1; i<=a; i++) {
		for (int j=1; j<=b; j++) {
			if (!cant[i+1][j]) dp[i+1][j] = dp[i][j] + dp[i+1][j-1];
			if (!cant[i][j+1]) dp[i][j+1] = dp[i][j] + dp[i-1][j+1];
		}
	}
	
	cout << dp[a][b] << endl;
}

int main() {
	while (1) {
		cin >> a >> b; if (a==0 && b==0) break;
		cin >> n;
		
		memset(cant, 0, sizeof(cant));
		for (int i=0; i<n; i++) {
			int x, y; cin >> x >> y;
			cant[x][y] = true;
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main(){
	int A=0, B=0, a, b;
	for (int i = 0; i < 4; i++){
		cin >> a;
		A += a;
	}
	for (int i = 0; i < 4; i++){
		cin >> b;
		B += b;
	}
	if (A>B){
		cout << A << endl;
	}
	else{
		cout << B << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

long long lucas(long long N, long long res1, long long res2){

  if(N == 0) return res1;
  if(N == 1) return res2;

  return lucas(N-1,res2,res1+res2);
}

int main(void){

  int N;
  cin >> N;

  cout << lucas(N,2,1) << endl;
    
  return 0;
}

Measured memory_bytes: 384
def solve(N,u,v,G):
    
    def ikisaki(u):
        U = [0]*(N+1)
        u_que = [[u,0,-1]]
        u_visited = [0]*(N+1)
        u_visited[u] = 1
        while u_que != []:
            now,kaisuu,parent = u_que.pop()
            for to in G[now]:
                if to != parent:
                    U[to] = kaisuu+1
                    if len(G[to])!=1:
                        u_que.append([to,kaisuu+1,now])
        return U
    V = ikisaki(v)
    U = ikisaki(u)
    
    maxV = 0
    for i in range(1,N+1):
        if V[i] > U[i]:
            maxV = max(maxV,V[i])
    print(maxV-1)
    

    

N,u,v = map(int,input().split())
from collections import defaultdict
G = defaultdict(list)
for i in range(N-1):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)

solve(N,u,v,G)

Measured memory_bytes: 71000
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

int main(){
  ll k, a, b;
  cin >> k >> a >> b;
  if (b <= a || a == b-1) {
    cout << k+1 << endl;
    exit(0);
  }
  if (k <= a) {
    cout << k+1 << endl;
    exit(0);
  }
  //ビスケットの総数はk+1枚
  // 得られる金額は、(k+1)/a円。
  // 得られるビスケットは、得られる金額 * b


  // 叩けるだけたたいて、変換、あまりを足す
  // 1度に1円分しか変換できないので、何回変換する行動をとるか
  // 1度叩いて1円にしたら、以後はビスケットにしてお金にしてを繰り返す
  ll nokori = k+1 - a; // 1円分叩いた余り
  // cout << nokori << endl;
  ll d = b - a; //2回の行動で増える分
  ll sum = (nokori/2) * d;
  if (nokori % 2 == 1) {
    cout << sum+a+1 << endl;
  }else {
    cout << sum+a << endl;
  }
  // ll possible = ((k-1)/a) * b + ((k-1)%a);
  // cout << possible << endl;
  // cout << (k/a)*b << endl;
  // ll henkan = (k+1)/a;
  // cout << henkan*b << endl;

}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back



int main()
{
    ll N, M, Q;
    cin >> N >> M >> Q;
    vec a(Q), b(Q), c(Q), d(Q);
    REP(i,0,Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i]; --b[i];
    }

    vec A(10);
    ll mx = 0, sum;

    REP(a0,0,M)  {
    REP(a1,a0,M) {
    REP(a2,a1,M) {
    REP(a3,a2,M) {
    REP(a4,a3,M) {
    REP(a5,a4,M) {
    REP(a6,a5,M) {
    REP(a7,a6,M) {
    REP(a8,a7,M) {
    REP(a9,a8,M) {
    
        A[0] = a0;
        A[1] = a1;
        A[2] = a2;
        A[3] = a3;
        A[4] = a4;
        A[5] = a5;
        A[6] = a6;
        A[7] = a7;
        A[8] = a8;
        A[9] = a9;

        sum = 0;
        REP(i,0,Q) {
            if(A[b[i]]-A[a[i]] == c[i]) sum += d[i];
        }
        mx = MAX(mx,sum);

    }}}}}}}}}}

    _PR(mx);

    return 0;
}

/*



*/

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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1e18+1;

signed main() {
	int n;
	int imos[100005] = {0};

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

	for ( int i = 1; i <= 100003; i++ ) {
		imos[i] = imos[i]+imos[i-1];
	}

	//for ( int i = 0; i < 7; i++ ) cout << imos[i] << " ";
	//cout << endl;

	for ( int i = 100004; i >= 0; i-- ) {
		if ( i <= imos[i]+1 ) {
			cout << i-1 << endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 3880
s = input()
n = len(s)
flag = False
 
 
def palind(S):
    size = len(S)
    for i in range(size//2):
        if S[i] != S[-1-i]:
            return False
    return True
 
 
 
if palind(s):
    m = (n-1)//2
    sb = s[:m]
    if palind(sb):
        sa = s[m+1:]
        flag = palind(sa)
 
print("Yes" if flag else "No")


Measured memory_bytes: 9056
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (int i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N, M;
    cin >> N >> M;

    priority_queue<i64, vector<i64>, greater<i64>> pq;

    rep(i, N) {
        int a; cin >> a;
        pq.emplace(a);
    }

    vector<pii> p(M);
    rep(i, M) {
        i64 b, c;
        cin >> b >> c;
        p[i] = pii(c, b);
    }

    sort(ALL(p), greater<>());

    for (const auto &e : p) {
        i64 val = e.first;
        i64 count = e.second;

        rep(k, count) {
            if (pq.top() >= val) break;
            pq.pop();
            pq.push(val);
        }
    }

    i64 ans = 0;
    while(pq.size()) {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2804
n=int(input())
x=list(map(int,input().split()))
mod=10**9+7

# コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる
def cmb(n,r,mod):
  if (r<0 or r>n):
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
g1=[1,1] # g1[i]=i! % mod　:階乗
g2=[1,1] # g2[i]=(i!)^(-1) % mod　:階乗の逆元
inverse=[0,1]
for i in range(2,n+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

ans=0
nn=[g1[n-1]]
tmp=g1[n-1]
for i in range(2,n):
  tmp+=g1[n-1]*pow(i,mod-2,mod)
  tmp%=mod
  nn.append(tmp)
  
for i in range(n-1):
  d=x[i+1]-x[i]
  ans+=d*nn[i]
  ans%=mod
print(ans)


Measured memory_bytes: 111648
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,a,b,c = map(int,ipt().split())
    l = [int(ipt()) for i in range(n)]
    mi = 10**18

    for i in range(4**n):
        sa = 0
        sb = 0
        sc = 0
        na = 0
        nb = 0
        nc = 0
        for j in range(n):
            ni = i>>(2*j)
            if (ni&2):
                if ni&1:
                    sa += l[j]
                    na += 1
                else:
                    sb += l[j]
                    nb += 1
            elif ni&1:
                sc += l[j]
                nc += 1
        if na*nb*nc == 0:
            continue
        nm = abs(sa-a)+abs(sb-b)+abs(sc-c)+(na+nb+nc-3)*10
        if nm < mi:
            mi = nm

    print(mi)



    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 76004
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  ll sum = 0;
  for(int i=0;i<n;i++) sum += a[i];

  int r = n/2;
  vector<ll> m(n);
  m[0] = sum;
  for(int j=1;j<2*r;j=j+2){
    m[0] -= a[j]*2;
  }
  for(int i=1;i<n;i++){
    m[i] = 2*a[i-1]-m[i-1];
  }

  for(int i=0;i<n;i++){
    printf("%lld%c",m[i],i==n-1?'\n':' ');
  }
}


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	for(int i=0;i<N;i++)	cin >> H.at(i);

	int ans=0;
	int now=0;
	for(int i=0;i<N-1;i++){
		if(H.at(i)>=H.at(i+1)){
			now+=1;
		}
		else{
			ans=max(ans,now);
			now=0;
		}
	}
	ans=max(ans,now);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640