akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 100004;

llong fac[n_max];  /// fac[n] = n!
llong finv[n_max]; /// (fac[n] * finv[n]) % MOD = 1
llong inv[n_max];  /// (n * inv[n]) % MOD = 1
 
void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR (i, 2, n_max) {
    fac[i] = fac[i-1]*i % MOD;
    inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
    finv[i] = finv[i-1]*inv[i] % MOD;
  }
}
 
llong nCk (int n, int k) {
  if (n < k || k < 0 || n < 0) return 0;
  return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}


signed main(){
    init();
    int n;
    cin >> n;
    int A[n + 1] = {};
    REP(i,n+1) A[i]  = -1;
    int mae,usiro;
    REP(i,n+1){
        int a;
        cin >> a;
        if(A[a] != -1){
            usiro = n - i;
            mae = A[a];
        }
        A[a] = i;
    }

    cout << n << endl;
    FOR(k,2,n+2){
        int ans = nCk(n+1,k);
        if(k-1 <= usiro + mae){
            ans = ans + MOD - nCk(usiro + mae, k -1);
            ans %= MOD;
        }
        cout<< ans << endl;
    }

}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(b>a){
        swap(a, b);
    }
    while(a%b){
        int tmp=a%b;
        a=b;
        b=tmp;
    }
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 3096
use std::io::stdin;

fn main() {
    let mut args = String::new();
    stdin().read_line(&mut args).expect("Failed to read line");
    let args: Vec<i32> = args
        .trim()
        .split_whitespace()
        .filter_map(|it| it.parse().ok())
        .collect();
    let a = args[0];
    let b = args[1];
    println!("{}", if a > 8 || b > 8 { ":(" } else { "Yay!" });
}


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

#define COUT(x) cout << x << endl
#define CIN(x) cin >> x
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define EXIST(s, e) (s.find(e) != s.end())
#define SORT(c) sort(c.begin(), c.end())
#define ERASEUNIQE(v) v.erase(unique(v.begin(), v.end()), v.end())

// conversion
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

// typedef
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

// container util
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()

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

// debug
#define dump(x) cerr << #x << " = " << x << endl;
#define debug(x) cerr << #x << " = " << x << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

int main(int argc, char const *argv[])
{
    int N, x, ans = 0;
    bool isLastGet = false;
    CIN(N), CIN(x);
    VI a(N);

    for (int i = 0; i < N; i++)
    {
        CIN(a.at(i));
    }

    SORT(a);

    for (int j = 0; j < N; j++)
    {
        if (a.at(j) <= x)
        {
            if(j == N-1) {
                isLastGet = true;
            }
            x -= a.at(j);
            ans++;
        }
    }
    if(x > 0 && isLastGet) {
        ans--;
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
var readline = require('readline');
var lines = []; var result = 0;

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

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

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var M = Number(lines[0].split(" ")[1]);
    var X = lines[1].split(" ").map(value => Number(value));

    X.sort((a, b) => a - b);

    var sum = Array(M).fill(0);
    for (var i = 1; i < M; i++) { sum[i] = X[i] - X[i - 1]; }

    sum.sort((a, b) => b - a);

    for (var i = N - 1; i < M; i++) { result += sum[i] }
    
    console.log(result);
});


Measured memory_bytes: 18988
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
A = [0]*N
says = [[-1]*(N+1) for _ in range(N+1)]
for i in range(N):
    A[i] = int(input())
    for j in range(A[i]):
        x,y = inputlist()
        says[i+1][x] = y

suma = sum(A)

ans = 0

for i in range(2**N):
    bn = bin(i)
    bn = bn[2:]
    if len(bn) < N:
        for s in range(N-len(bn)):
            bn = '0' + bn
    flag = True
    for x in range(N):
        if bn[x] == '1':
            for y in range(N):
                if says[x+1][y+1] == -1:
                    continue
                if says[x+1][y+1] != int(bn[y]):
                    flag = False
                    break

    if flag:
        c = 0
        for i in range(N):
            if bn[i] == '1':
                c+=1
        ans = max(c,ans)

print(ans)

Measured memory_bytes: 51932
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,n,k;
	string s;
	cin>>n>>k;
	cin>>s;
	for(i=0;i<n;i++){
		if(i==k-1) s[i]+=32;
	} 
	cout<<s; 
	return 0;
}


Measured memory_bytes: 256
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    }
    let mut count = 0;
    for a in 0..a + 1 {
        for b in 0..b + 1 {
            for c in 0..c + 1 {
                let money = 500 * a + 100 * b + 50 * c;
                if money == x {
                    count += 1;
                }
            }
        }
    }
    println!("{}", count);
}


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

int main(){
    int N;
    cin >> N;
    
    vector<int> v(N,0);
    vector<int> s(N,0);
    int max = 0, nmax = 0;
    for (int i = 0; i < N; i++) {
        cin >> v[i];
        s[i] = v[i];
    }

    sort(s.begin(),s.end());
    for (int i = 0; i < N; i++) {
        if(v[i] == s[N-1]) cout << s[N-2] << "\n";
        else cout << s[N-1] << "\n";
    }
}

Measured memory_bytes: 3200
using System;
using System.Linq;

namespace ABC139_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int count = 0, max = 0;
            for (int i = 0; i < n-1; i++)
            {
                if (h[i] >= h[i + 1])
                    count++;
                else
                    count = 0;
                if (count > max)
                    max = count;
            }

            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 28124
fun main(args: Array<String>) {
    var (n, m) = readLine()!!.split(" ").map{it.toInt()}
    var a = readLine()!!.split(" ").map{it.toInt()}.sortedDescending()
    if (a[m-1] < a.sum()/(4.0*m)) {
        println("No")
    } else {
        println("Yes")
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define intpow(a, n) (int)pow((long double) a, (long double) n)
#define int long long

int MOD = 1e9 + 7;

inline int mod (int a, int m = MOD) { return (a % m + m) % m; }

int modpow(int a, int n){
    int ret = 1;
    while(n>0){
        if(n&1) ret = (ret*a) % MOD;
        a = (a*a) % MOD;
        n >>= 1;
    }
    return ret % MOD;
}

signed main(){
    int n, k;
    cin >> n >> k;
    
    int sum = 0;
    vector<int> summed(k+1);
    for(int i=k; i>=1; i--){
        summed[i] = modpow(k/i, n);
        for(int j=2*i; j<=k; j += i){
            summed[i] = mod(summed[i] - summed[j]);
        }
        sum = mod(sum + mod(summed[i] * i));
    }
    
    cout << sum % MOD << endl;
}

Measured memory_bytes: 4048
import java.io.PrintWriter
import java.util.NoSuchElementException

fun main(args: Array<String>) = IO().exec {
    val n = int()
    val m = int()
    val x = IntArray(m)
    val y = IntArray(m)
    for (i in 0 until m) {
        x[i] = int()-1
        y[i] = int()-1
    }

    val balls = IntArray(n){1}
    val prob = BooleanArray(n)
    prob[0] = true
    for (i in 0 until m) if (balls[x[i]] > 0) {
        balls[x[i]]--
        balls[y[i]]++
        if (balls[x[i]] == 0) {
            prob[y[i]] = prob[y[i]] or prob[x[i]]
            prob[x[i]] = false
        } else {
            prob[y[i]] = prob[y[i]] or prob[x[i]]
        }
    }

    println(prob.count{ it })
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 38692
#include<iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{      
    int n;
    cin >> n;
    int tree[n];
    for (int i=0;i<n;i++){
        cin >> tree[i];
    }
    if(tree[0]!=0){
        cout << 0;
        exit(0);
    }
    sort(tree,tree+n);
    if(tree[1]==0){
        cout << 0;
        exit(0);
    }
    long long co=1,bco=1;
    long long sum = 1;
    for (int i=1;i<n;i++){
        if(tree[i]==tree[i-1]){
            co++;
        }else if(tree[i]==tree[i-1]+1){
             for (int i=0;i<co;i++){
                 sum=(sum*bco)%998244353;
             }
            //sum=(long long)(sum*(long long)(powl(bco,co)))%(long long)(998244353);
            bco=co;
            co=1;
        }else{
            cout << 0;
            exit(0);
        }

    }
    for (int i=0;i<co;i++){
        sum=(sum*bco)%998244353;
    }
    cout << sum;


}
 

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

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

  rep(i, a) {
    if (s[i] != '-'){
    } else {
      p("No");
      return 0;
    }
  }


  if (s[a] == '-'){
  } else {
    p("No");
    return 0;
  } 


  for (int i = a+1; i < a+b; i++) {
    if (s[i] != '-'){
    } else {
      p("No");
      return 0;
    }
  }

  p("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	vector<string> d = { "maerd","remaerd","esare","resare" };
	int n = s.size();
	string t;
	rep(i, n) {
		for (string c : d) {
			if (c == s.substr(i, c.size())) {
				t += c;
				i += c.size() - 1;
				break;
			}
		}
	}
	if (s == t) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3756
#include <stdio.h>
int main(void){
  char s[16];
  int i,n=0;
  scanf("%s",s);
  for(i=0;s[i]!='\0';i++)
    if(s[i]=='x')
      n++;
  if(n<=7)
    printf("YES");
  else
    printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    vector<LL> cum(n+1);
    map<LL,LL> cnt;
    cnt[0] += 1;
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
        cum[i+1] = cum[i] + a[i];
        cnt[cum[i+1]] += 1;
    }
    LL total = 0;
    for(auto p: cnt){
        total += p.second * (p.second-1) / 2;
    }
    cout << total << endl;
    return 0;
}



Measured memory_bytes: 15872
#include<bits/stdc++.h>
	using namespace std;
	#define rep(i,n) for(ll i=0;i<(n);i++)
	#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
	#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
	#define mem(u, vis) memset(u, vis, sizeof(u))
	#define ll long long
	#define ull unsigned long long
	#define MOD  1000000007
	#define MAX  1e9
	#define pb   push_back
	#define F    first
	#define S    second


	signed main() {
		int t=1;
		//cin>>t;
		while(t--){
			string n;
			cin>>n;
			if(n=="ABC") cout<<"ARC";
			else cout<<"ABC";
			
		}
		
	}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=3e3+5;
long double f[maxn][maxn];
void Input()
{
    int n;
    cin >> n;
    f[0][0]=1;
    FOR(i,1,n) {
        long double p;
        cin >> p;
        f[i][0]=f[i-1][0]*(1.0-p);
        FOR(j,1,i)
            f[i][j]=(f[i-1][j-1]*p+f[i-1][j]*(1.0-p));
    }
    long double res=0;
    FOR(i,1,n)
        if (i>n-i) res+=f[n][i];
    cout.precision(9);
    cout << fixed << res;
}
void Solve()
{

}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> cnts;
  int now = 1, cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == (char)('0' + now))
      cnt++;
    else {
      cnts.push_back(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if (cnt != 0) cnts.push_back(cnt);
  if (cnts.size() % 2 == 0) cnts.push_back(0);
  int len = 2 * K + 1;
  vector<int> psum(cnts.size() + 1, 0);
  for (int i = 0; i < cnts.size(); i++)
    psum[i + 1] = psum[i] + cnts[i];
  int res = 0;
  for (int i = 0; i < cnts.size(); i += 2) {
    int left = i;
    int right = min(i + len, (int)cnts.size());
    int tmp = psum[right] - psum[left];
    res = max(res, tmp);
  }
  cout << res << '\n';
  return 0;
}


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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

LL gcd(LL m, LL n)
{
  return (n == 0) ? m : gcd(n, m%n);
}

// --------------------------------------

LL n;
vector<LL> a;

void input()
{
  cin >> n;
  a.resize(n);

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

vector<LL> divisor(LL n)
{
  vector<LL> res;
  for(LL i = 1; i*i <= n; i++)
  {
    if(n % i == 0)
    {
      res.push_back(i);
      if(i * i != n) res.push_back(n/i);
    }
  }
  sort(begin(res), end(res));
  return res;
}

void solve()
{
  vector<LL> divisors = divisor(a[0]);
  vector<LL> a2Divisor = divisor(a[1]);
  divisors.reserve(divisors.size() + a2Divisor.size());
  copy(a2Divisor.begin(), a2Divisor.end(), back_inserter(divisors));

  LL maxDivisor = 0;
  for(auto d : divisors)
  {
    int ableCnt = 0; 
    for(auto aElem : a)
    {
      if(aElem % d == 0) ableCnt++;
    }

    if(n-1 <= ableCnt) maxDivisor = max(maxDivisor, d);
  }

  cout << maxDivisor;
}

int main()
{
  input();
  solve();
  return 0;
}

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

using namespace std;

int main() {
  while (1) {
    string str;
    cin >> str;
    if (str == "-") {
      break;
    }
    int m;
    cin >> m;

    int first = 0;
    for (int i = 0; i < m; i++) {
      int h;
      cin >> h;

      first = (first + h) % str.size();
    }

    for (int i = 0; i < str.size(); i++) {
      cout << str[(first + i) % str.size()];
    }
    cout << endl;
  }

  return 0;
}


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

int main() {
  	int N, X, Y;
  	cin >> N >> X >> Y;
  	int num[N - 1] = {0};
  	int res = 0;
  	int helpX = 0, helpY = 0;
  	for (int i = 1; i < N; i++){
      	for (int j = 1; j <= N; j++){
          	if (i < j){
              	res = j - i;
              	if (X > i) helpX = X - i;
              	else helpX = i - X;
              	if (Y > j) helpY = Y - j;
              	else helpY = j - Y;
              	if (res > helpX + helpY + 1) res = helpX + helpY + 1;
              	num[res - 1]++;
              	res = 0;
              	helpX = 0;
              	helpY = 0;
            }
        }  
    }
  	for (int i = 0; i < N - 1; i++){
      	cout << num[i] << endl;
    }
}  

Measured memory_bytes: 256
S = list(input())
K = int(input())
st = set()
for i in range(len(S)):
    for j in range(6):
        st.add(''.join(S[i:i+j]))

st_list = sorted(list(st))
if '' in st_list:
    st_list.remove('')
print(st_list[K-1])

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;

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

int n;
cin >> n;
map<string, int> mp;
rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
}
cout << "AC x "  << mp["AC"]  << endl;
cout << "WA x "  << mp["WA"]  << endl;
cout << "TLE x " << mp["TLE"] << endl;
cout << "RE x "  << mp["RE"]  << endl;

return 0;
}

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

using namespace std;

int a[120000],l[120000],r[120000];

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

int main()
{
    int n,i,ans=1;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    l[0] = a[0];
    for (i=1; i<n; i++)
    {
        l[i]=gcd(l[i - 1], a[i]);
    }
    r[n - 1] = a[n - 1];
    for (i=n-2; ~i; i--)
    {
        r[i] = gcd(r[i + 1], a[i]);
    }
    for (i=1; i<n-1; i++)
    {
        ans = max(gcd(l[i - 1],r[i + 1]),ans);
    }
    cout << max(ans,max(r[1],l[n-2])) << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>
int main()
{
    double x,y;
    scanf("%lf %lf", &x, &y);
    printf("%.0lf %.0lf %.5lf\n", floor(x/y), x-y*(int)(x/y), x/y);
    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
const int maxN = 2e5 + 7;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

void NIE() {
	puts("No");
	exit(0);
}

int n;
char a[maxN];
list<int> seg[maxN]; int tt;
int col[maxN], tc;

void debug(list<int> l) {
	for (int x : l) cerr << x << " ";
	cerr << endl;
}

void debug(int x) {
	debug(seg[x]);
}

void color(list<int> seg) {
	vector<int> v;
	for (int x : seg) v.push_back(x);
	For (i, 0, v.size() / 2) col[v[i]] = col[v[i + v.size() / 2]] = ++tc;
	int tp = 1;
	for (int i = 1; i <= n; ++i) if (!col[i]) {
		col[i] = tp ? ++tc : tc;
		tp ^= 1;
	}
	assert(tp == 1);
}

int main() {

	n = ri() << 1;
	scanf("%s", a+1); a[0] = a[n] = '1';
	
	seg[tt = 1].push_back(0);
	rep (i, 1, n+1) { 
		if (a[i-1] == '1')
			seg[tt].push_back(i);
		else if (a[i-1] == '0' && a[i] == '1')
			seg[++tt].push_back(i);
	}
//	cerr << seg[1].front() << " " << seg[tt].back() << endl;
	if (1 != tt) {
		seg[tt].pop_back(); seg[1].pop_front();
		seg[tt].splice(seg[tt].end(), seg[1]);
		if (seg[tt].empty()) --tt;
	}
	else seg[tt = 2] = seg[1];
	{
		int sum = 0, x = 0, y = 0;
		rep (i, 2, tt) { 
			sum += seg[i].size() - 2;
			if (seg[i].size() > 2) {
				if (!x) x = i;
				else y = i;
			}
		}
		if (sum & 1) NIE();
		if (sum % 4 == 2) {
			if (!y) NIE();
			int a = seg[x].back(); seg[x].pop_back();
			int b = seg[y].back(); seg[y].pop_back();
			int u = seg[x].back(); seg[x].pop_back();
			int v = seg[y].back(); seg[y].pop_back();
			col[u] = col[v] = ++tc;
			seg[x].push_back(b);
			seg[y].push_back(a);
			sum -= 2;
		}
		For (i, 2, tt) {
			int u = seg[2].back(); seg[2].pop_back();	
			int v = seg[i+1].front(); seg[i+1].pop_front();
			col[u] = col[v] = ++tc;
			seg[2].splice(seg[2].end(), seg[i+1]);
		}
		int u = seg[2].back(); seg[2].pop_back();
		int v = seg[2].front(); seg[2].pop_front();
		if (v != 0) col[u] = col[v] = ++tc;
		assert(seg[2].size() % 4 == 0);
		color(seg[2]);
	}
	puts("Yes");
	rep (i, 1, n) printf("%d%c", col[i], " \n"[i == n]);

	return 0;
}


Measured memory_bytes: 24424
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	ll n,a,b; cin >> n >> a >> b;
	vll x(n); rep(i,n) cin >> x[i];
	ll ans = 0;
	rep(i,n-1){
		ans += min((x[i+1]-x[i])*a,b);
	}
	cout << ans << endl;
}




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

int main() {
    string S;
    cin >>S;
    sort(S.begin(),S.end());
    for(int i=0;i+1<S.size();i++){
        if(S.at(i)==S.at(i+1)){
            cout<<"no";
            return 0;
        }
    }
    cout<<"yes";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
#define maxn 2000

using namespace std;
int n, m, s[maxn + 1], t[maxn + 1], dp[maxn + 1][maxn + 1];

signed main()
{
	
 	FLASH

 	cin>>n>>m;

 	fr(i, 1, n + 1){
 		cin>>s[i];
 	}

 	fr(j, 1, m + 1){
 		cin>>t[j];
 	}

 	fr(i, 1, n + 1){
 		fr(j, 1, m + 1){
 			if(s[i] == t[j]){
 				dp[i][j] = 1 + dp[i - 1][j - 1];
 			}
 			dp[i][j] += dp[i - 1][j] + dp[i][j - 1] + mod - dp[i - 1][j - 1];
 			
 			dp[i][j] %= mod;
 		}
 	}

 	cout<<(1 + dp[n][m]);
}

Measured memory_bytes: 31616
/*
#include <boost/functional/hash.hpp>
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mlint;
*/
#include <bits/stdc++.h>

#define debug 0
#define fcout(d) cout << fixed << setprecision(d)
#define urep(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define drep(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) urep(i,0,(n) - 1)
#define rep1(i,n) urep(i,1,(n))
#define rrep(i,n) drep(i,(n) - 1,0)
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define rsz resize
#define era erase
#define emp emplace
#define emf emplace_front
#define emb emplace_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second

using namespace std;

typedef long long ll;
typedef double db;
typedef vct<vct<ll>> mat;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef map<int,int> mpii;
typedef unordered_map<int,int> umpii;

const int dir[8][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const ll inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
const ll mod = 1e9 + 7;
const db eps = 1e-15;

auto esc = [](auto ret) { cout << ret << endl; exit(0); };
auto odd = [](auto x) { return x & 1; };
auto even = [](auto x) { return !odd(x); };
auto qceil = [](auto x, auto y) { return x > 0 ? (x - 1) / y + 1 :  x / y; };
auto parity = [](auto x, auto y) { return odd(x) ^ even(y); };
auto chmax = [](auto& m, auto x) { if(m < x) { m = x; return 1; } return 0; };
auto chmin = [](auto& m, auto x) { if(m > x) { m = x; return 1; } return 0; };
auto cmprs  = [](auto& v) {
    auto tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return tmp.size() != v.size();
};


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

    string s;
    cin>>s;
    int n=s.size();
    if(odd(n)){
        int mid=n/2,k=0;
        while(k <= n/2 && s[mid]==s[mid-k]&&s[mid]==s[mid+k]){ k++; }
        cout<<(n+2*k-1)/2<<endl;
    }else{
        int l=n/2-1,r=n/2,k=0;
        while(k<=l&&s[l-k]==s[l]&&s[r+k]==s[r]&&s[l]==s[r]){ k++; }
        cout<<(n+2*k)/2<<endl;
    }
}


Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

NX = input().split(' ')
N = int(NX[0])
X = int(NX[1])
L = map(int, input().split(' '))

LL = list()
LL.append(0)
n = 0
for l in L:
    n += l
    LL.append(n)

LL = list(filter(lambda x: x <= X, LL))
print(len(LL))


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

int main()
{
	int N;
	
	while ( cin >> N, N != 0 ) {

		int index, maxv;
		int a, b, c;
		cin >> index >> b >> c;
		maxv = b + c;
		for ( int i = 1; i < N; i++ ) {
			cin >> a >> b >> c;
			if ( b + c > maxv ) {
				maxv = b + c;
				index = a;
			}
		}
		cout << index << " " << maxv << endl;
	}

	return ( 0 );
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

  ll N,k;
  cin >> N >> k;

  vector<ll> A(N),cnt(N,INF);
  FOR(i,0,N) cin >> A[i];
  FOR(i,0,N) A[i]--;

  cnt[0] = 0;
  ll now = 0;

  FOR(i,0,3*N){

    if(k==0){
      cout << now+1 << endl;
      return 0;
    }
    ll nex = A[now];
    if(nex==now){
      cout << now+1 << endl;
      return 0;
    }

    if(cnt[nex]==INF)cnt[nex] = cnt[now]+1;
    
    if(cnt[nex]<cnt[now]){
      ll loop = abs(cnt[now] - cnt[nex]) + 1;
      k -= (k/loop)*loop;
    }


    if(k==0){
      cout << now+1 << endl;
      return 0;
    }


    now = nex;
    k--;
  }

}


Measured memory_bytes: 6432
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

int cal(int num){
	int ans = 0;
	while(num){
		ans += num%10;
		num /= 10;
	}
	return ans;
}
void solve(){
	int N,A,B;
	cin>>N>>A>>B;
	int ans = 0;
	for(int i=1;i<=N;++i){
		int res = cal(i);
		if( A <= res && res <= B ){
			ans += i;
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#include<string>
using namespace std;
int N, D, K, M, C, h[6], dist[110][65]; vector<tuple<int, int, int>>x[110][65];
int parse(string U) {
	if (U == "H")return 0;
	if (U == "D")return N - 1;
	if (U[0] == 'L')return stoi(U.substr(1, U.size() - 1));
	if (U[0] == 'C')return stoi(U.substr(1, U.size() - 1)) - 1 + (D + 1);
}
void add_edge(string U1, string U2, int U3) {
	int u1 = parse(U1), u2 = parse(U2);
	int e = 0, f = 0;
	if (U2[0] == 'C') {
		int num = stoi(U2.substr(1, U2.size() - 1)) - 1;
		f = h[num]; e = (1 << num);
	}
	for (int j = 0; j < (1 << C); j++) {
		if ((j&e) != 0)continue;
		x[u1][j].push_back(make_tuple(u2, (j | e), U3 * K - f));
	}
}
int main() {
	while (true) {
		cin >> N >> D >> K >> M; C = N; N += D + 2; if (K == 0 && M == 0)break;
		for (int i = 0; i < C; i++)cin >> h[i];
		for (int i = 0; i < 110; i++) { for (int j = 0; j < 65; j++) { dist[i][j] = 99999999; x[i][j].clear(); } }
		for (int i = 0; i < M; i++) {
			string S, T; int r; cin >> S >> T >> r;
			add_edge(S, T, r);
			add_edge(T, S, r);
		}
		dist[0][0] = 0;
		for (int i = 0; i < N*C; i++) {
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < (1 << C); k++) {
					for (tuple<int, int, int>l : x[j][k]) {
						dist[get<0>(l)][get<1>(l)] = min(dist[get<0>(l)][get<1>(l)], dist[j][k] + get<2>(l));
					}
				}
			}
		}
		int minx = 99999999; for (int i = 0; i < (1 << C); i++)minx = min(minx, dist[N - 1][i]);
		cout << minx << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;

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

	int h,w;
	cin>>h>>w;

	map<int,int> etos;
	multiset<int> distset;
	for (int i = 0; i < w; i++) {
		etos[i] = i;
		distset.insert(0);
	}
	for (int i = 0; i < h; i++) {
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		int max_s = -1;
		{
			auto bgn = etos.lower_bound(a);
			auto end = etos.upper_bound(b+1);
			for (auto it = bgn; it != end; ++it) {
				max_s = max(max_s, it->second);
				auto dist = it->first - it->second;
				assert(distset.count(dist)>0);
				distset.erase(distset.find(dist));
			}
			etos.erase(bgn, end);
		}
		if (max_s != -1 and b+1 < w) {
			auto min_dist = b+1 - max_s;
			distset.insert(min_dist);
			assert(etos.count(b+1) == 0);
			etos[b+1] = max_s;
		}
		if (!distset.empty()) {
			cout << i+1 + *distset.begin() << endl;
		} else {
			cout << -1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 22340
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	ll n, a, b;
	cin >> n >> a >> b;
	cout << n / (a + b) * a + min(n % (a + b), a);
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
// October.cpp : Defines the entry point for the console application.
//

#include "iostream"
#include "algorithm"
#include "vector"
#include "set"
#include "string"
#include "map"
#include "stack"
#include "bitset"
#include "deque"
#include "queue"
#include "cmath"
#include "fstream"
#include "list"
#include "unordered_set"
#include "functional"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define double ld
#define all(a) a.begin(), a.end()
const int N = 100050;
vector<int> ans[N];

int findk(int n) {
	int k = 1;
	while ((k*(k - 1)) / 2 < n)
		k++;
	if ((k*(k - 1)) / 2 == n)
		return k;
	else
		return -1;
}

signed main()
{
	ios::sync_with_stdio(0);
	int n; cin >> n; 
	int k = findk(n);
	if (k == -1)
		return cout << "No\n", 0;
	cout << "Yes\n" << k << '\n';
	int stop = 1;
	for (int i = 1; i <= k; i++) {
		int j = i + 1;
		while (j <= k) {
			ans[i].push_back(stop);
			ans[j].push_back(stop);
			j++;
			stop++;
		}
	}
	for (int i = 1; i <= k; i++) {
		cout << ans[i].size() << ' ';
		for (auto a : ans[i])
			cout << a << ' ';
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 5632
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if (((a + b) == c) || ((b + c) == a) || ((a + c) == b)) { 
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint powmod(int n) {
  if (n == 1) return 2;
  mint res = powmod(n / 2);
  res *= res;
  if (n % 2 != 0) {
    res *= 2;
  }

  return res;
}

mint choose(int n, int r) {
  mint x = 1;
  mint y = 1;

  rep (i, r) {
    x *= (i + 1);
    y *= (n - i);
  }

  return y / x;
}

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n, a, b;
  cin >> n >> a >> b;

  mint ans = powmod(n);
  ans -= 1; // n choose zero
  ans -= choose(n, a);
  ans -= choose(n, b);

  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 3584
n, c, k = map(int, input().split())
t_list = []
for i in range(n):
    t_list.append(int(input()))
t_list.sort()
count = 1
current_c = []
start_t = None


for t in t_list:
    if not start_t:
        start_t = t
        current_c.append(t)
    elif len(current_c) < c:
        if start_t + k < t:
            count += 1
            current_c = [t]
            start_t = t
        else:
            current_c.append(t)
    elif len(current_c) >= c:
        count += 1
        current_c = [t]
        start_t = t
    else:
        print("error")
print(count)


Measured memory_bytes: 50520
#include<cstdio>
#include<algorithm>
using namespace std;

#define ran 111

int n, m;
pair<int, int> v[ran], x[ran];

int cmp(pair<int, int> &a, pair<int, int> &b) {
	if (a.second != b.second) return a.second < b.second;
	return a.first < b.first;
}
void upd(long long &a, long long b) {
	if (a==-1 || a>b) a = b;
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<n;i++) {
		scanf("%d%d", &v[i].first, &v[i].second);
	}
	sort(v, v+n);
	
	long long ans = -1LL;
	for(int i=0;i+m-1<n;i++)
		for(int j=i+m-1;j<n;j++) {
			for(int k=i;k<=j;k++)
				x[k-i] = v[k];
			int len = j-i+1;
			sort(x, x+len, cmp);
			
			for(int l=0, r=m-1; r<len; l++, r++) 
				upd(ans, 1LL*(v[j].first - v[i].first) * (x[r].second - x[l].second));
		}
	printf("%lld\n", ans);
	
	return 0;
}

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

using namespace std;

#define mod1 1000000007
#define mod2 998244353
#define int long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define all(x) x.begin(),x.end()
// #define endl "\n"

const int maxn=2e5+5;


void solve()
{
	int n;
	cin>>n;
	int ans=0;
	for(int l=1;l<=n;l++)
		ans += (n-l+1)*(l+n)/2 - (n-l+1)*(l-1);
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		if(u>v)
			swap(u,v);
		ans -= u*(n-v+1);
	}
	cout<<ans<<endl;
}	

int32_t main()
{
	fio;
	int t;
	// cin>>t;
	t=1;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);
 
ll n;
vector<ll> powers;

ll go(ll x){
    ll lo = 1, hi = x;
    ll ans = 0;
    while(lo<=hi){
        ll m = (lo+hi)>>1;
        if((m*(m+1)/2) <= x){
            ans = m;
            lo = m+1;
        }else{
            hi= m-1;
        }
    }
    return ans;
}

void solve(){
 

    powers.assign(sqrt(n)+5, 0);
    ll N= n;
    //if(n==1){
        //printf("%d\n", 0);
        //return;
    //}

    ll  cnt =0;
    while(n%2==0){
       cnt++;
       n/=2; 
    }


    //printf("%lld\n", n);
    powers[2] = cnt;
    cnt = 0;

 
    for(int i = 3; i <= sqrt(N); i+=2){


        while(n%i==0){
            cnt++;
            n/=i;
        }
        powers[i] = cnt;

        cnt = 0;
    }

    ll ans = 0;
    for(auto x:powers){
        //printf("%d", x);
        ans += go(x);
    }
    if(n > sqrt(N)){
        ans++;

    }
    printf("%lld\n",ans );
} 
 
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
 
    scanf("%lld", &n);
    solve();
 
 
    return 0;
 
 
}


Measured memory_bytes: 11168
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    let (a, b) = read_parameters::<usize>().map(|xs| (xs[0], xs[1])).unwrap();

    println!("{} {} {:.5}", a / b, a % b, (a as f64) / (b as f64));
}



Measured memory_bytes: 5044