akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int N;
vec<int> P;

signed main() {
	cin >> N;
	rep (i, N) {
		int p; cin >> p;
		P.push_back(p);
	}

	int ans = 0;
	int Min = 1e18;
	for (int i = 0; i < N; i++) {
		chmin(Min, P[i]);
		if (P[i] <= Min) ans++;
		/*
		bool ok = true;
		for (int j = 0; j <= i; j++) {
			if (P[i] > P[j]) {
				ok = false;
				break;
			}
		}
		ans += ok;
		*/
	}

	cout << ans << endl;

	return 0;
}

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

int main(void){
  int n,q;
  cin>>n>>q;
  vector<int> d(300010);
  int in;
  for(int i = 0 ; i < n ; i ++){
    cin>>in;
    d[in] = in;
  }
  for(int i = 0 ; i < 300000 ; i ++){
    if(!d[i+1])d[i+1] = d[i];
  }
  while(q--){
    cin>>in;
    
    int ret = 0;
    for(int i = in-1 ; i <= 300000 ; i +=in)ret = max(ret,d[i]%in);
    cout<<ret<<endl;
  }

}

Measured memory_bytes: 2324
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int w,h;cin>>w>>h;
  vi p(w),q(h);
  vector<pii> pq;
  rep(i,w){
    cin>>p[i];
    pq.pb(mp(p[i], 0));
  }
  rep(i,h){
    cin>>q[i];
    pq.pb(mp(q[i], 1));
  }
  sort(all(pq));

  int hcnt=h+1, wcnt=w+1;
  int ans = 0;
  rep(i, h+w){
    int cost = pq[i].first;
    int t = pq[i].second;
    dump(i, cost, t);
    if (t==0) {
      wcnt--;
      ans += cost*hcnt;
    }
    else{
      hcnt--;
      ans += cost*wcnt;
    }
    dump(i,ans,hcnt,wcnt);
  }
  cout << ans << endl;
  return 0;
}


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

int main(void) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while (A > 0 && C > 0) {
        C -= B;
        A -= D;
    }
    if (C <= 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3620
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K = map(int, readline().split())

if K == 0:
    print(pow(N, 2))
    sys.exit()

ans = 0
for b in range(1, N + 1):
    ans += N // b * max(0, b - K) + max(0, N % b - K + 1)

print(ans)


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

using namespace std;

int main(){
	int n,r;
	while(cin >> n >> r,n){
		int s[n];
		for(int i=0;i<n;i++){
			s[i] = n-i;
		}
		for(int i=0;i<r;i++){
			int p,c;
			cin >> p >> c;
			rotate(s,s+p-1,s+p+c-1);
		}
		cout << s[0] << endl;
	}
}

Measured memory_bytes: 1184
use std::cmp::*;
use std::io::*; //Not mine.
use std::str::FromStr;
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 main() {
    let n: usize = read();
    let k: usize = read();
    let h: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut ans = vec![1000000007; n];
    ans[0] = 0;
    for i in 1..n {
        for j in 1..k + 1 {
            if (i as i32 - j as i32) >= 0 {
                ans[i] = min(ans[i], (h[i] - h[i - j]).abs() + ans[i - j]);
            }
        }
    }
    println!("{}", ans[n - 1]);
}


Measured memory_bytes: 3556
use std::borrow::{Borrow, BorrowMut};
use std::collections::BinaryHeap;
use std::fs::File;
use std::io::{stdout, BufWriter, Read, Write};
use std::thread;

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    let stdin = std::io::stdin();
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}

fn run() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let input = read_input();
    let mut input = input.split_whitespace();

    let in_n: i64 = input.next().unwrap().parse().unwrap();
    let in_m: i64 = input.next().unwrap().parse().unwrap();
    let mut ab: Vec<(i64, i64)> = (0..in_n)
        .map(|_| {
            let r: Vec<i64> = input
                .borrow_mut()
                .take(2 as usize)
                .map(|s| s.parse().unwrap())
                .collect();
            (r[0], r[1])
        })
        .collect();

    ab.sort();
    let mut ans = 0;
    let mut i: usize = 0;
    let mut heap: BinaryHeap<i64> = BinaryHeap::new();
    for d in 1..in_m + 1 {
        // a が d のやつを入れられる
        while i < ab.len() && ab[i].0 <= d {
            heap.push(ab[i].1);
            i += 1;
        }
        if let Some(reward) = heap.pop() {
            ans += reward;
        }
    }
    writeln!(out, "{}", ans).ok();
}


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

int main() {
  int N;
  double T, A;
  cin >> N >> T >> A;
  int ans = 0;
  double diff_min = 1000000000;
  for (int i = 0; i < N; i++) {
    double H;
    cin >> H;
    double tmp = abs((T - H * 0.006) - A);
    if (tmp < diff_min) {
      ans = i + 1;
      diff_min = tmp;
    }
  }
  cout << ans << endl;
}

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

//for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//abbreviati
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//constant
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet**************************************
ifelse, isprime, torad, todeg, lcm, bfs
************************************************/

//adjacency list
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    cout << 10-n/200 ENDL;
    
    return 0;
}

Measured memory_bytes: 5960
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.C
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			long[] a = cin.ArrayLong(n);

			long sum = 0;
			for (int i = 0; i < n; i++)
			{
				sum = sum | a[i];
			}

			int ans = 0;
			while (sum%2==0)
			{
				ans++;
				sum /= 2;
			}

			Console.WriteLine(ans);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(){
  int N, K, J, count = 0;
  scanf("%d", &N);
  scanf("%d", &K);
  int arr[N];
  
  for(int i = 0; i<N; i++){
    arr[i] = scanf("%d", &J);
  	if(J >= K)
      count++;
  }
  printf("%d\n", count);
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

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

struct Book {
	string t, a;
	int y, m, d;
	Book(string _t, string _a, int _y, int _m, int _d) : t(_t), a(_a), y(_y), m(_m), d(_d) {}
};

bool comp_date(int yy1, int mm1, int dd1, int yy2, int mm2, int dd2) {
	if (yy1 > yy2) return false;
	if (yy1 == yy2) {
		if (mm1 > mm2) return false;
		if (mm1 == mm2) {
			if (dd1 > dd2) return false;
		}
	}
	return true;
}

int N, Q;
vector<Book> vb;

void solve() {
	for_(j,0,Q) {
		string t, a, from, to; cin >> t >> a >> from >> to;
		vector<Book> sub = vb;
		vector<Book> ans;
		
		if (t == "*") {
			ans = sub;
			sub = ans;
		} else {
			int s_size = size_of(sub);
			for_(i,0,s_size) {
				if (sub[i].t.find(t) != t.npos) ans.push_back(sub[i]);
			}
			sub = ans;
		}
		
		ans.clear();
		if (a == "*") {
			ans = sub;
			sub = ans;
		} else {
			int s_size = size_of(sub);
			for_(i,0,s_size) {
				if (sub[i].a.find(a) != a.npos) ans.push_back(sub[i]);
			}
			sub = ans;
		}
		
		ans.clear();
		if (from == "*") {
			ans = sub;
			sub = ans;
		} else {
			int y, m, d;
			sscanf(from.c_str(), "%d/%d/%d", &y, &m, &d);
			int s_size = size_of(sub);
			for_(i,0,s_size) {
				if (comp_date(y,m,d, sub[i].y, sub[i].m, sub[i].d)) ans.push_back(sub[i]);
			}
			sub = ans;
		}
		
		ans.clear();
		if (to == "*") {
			ans = sub;
			sub = ans;
		} else {
			int y, m, d;
			sscanf(to.c_str(), "%d/%d/%d", &y, &m, &d);
			int s_size = size_of(sub);
			for_(i,0,s_size) {
				if (comp_date(sub[i].y, sub[i].m, sub[i].d, y, m, d)) ans.push_back(sub[i]);
			}
			sub = ans;
		}
		
		int a_size = size_of(ans);
		for_(i,0,a_size) cout << ans[i].t << endl;
		if (j != Q - 1) cout << endl;
	}
}

int main() {
	cin >> N;
	for_(i,0,N) {
		string t, a; int y, m, d;
		cin >> t >> a;
		scanf("%d/%d/%d", &y, &m, &d);
		vb.push_back(Book(t, a, y, m, d));
	}
	cin >> Q;
	solve();
	return 0;
}

Measured memory_bytes: 1300
#!/usr/bin/env python3
import sys


def get_min_koubai(a, b):
    if a > b:
        tmp = b
        b = a
        a = tmp

    x = a * b
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    return x // b


def solve(A: int, B: int, C: int, D: int):
    # Bまでの間で
    #  Cで割り切れる物の数
    #  + Dで割り切れるもののかず
    #  - CDの最小公倍数で割り切れる物の数
    min_koubai = get_min_koubai(C, D)
    b1 = B // C
    b2 = B // D
    b3 = B // min_koubai
    b_count = b1 + b2 - b3

    # Aまでの間で
    #  同上
    a1 = (A - 1) // C
    a2 = (A - 1) // D
    a3 = (A - 1) // min_koubai
    a_count = a1 + a2 - a3

    # Bの数 - Aの数
    # B - A - 上の数
    print(B - (A - 1) - (b_count - a_count))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int A[3];
  int i;
  scanf("%d %d %d",&A[0],&A[1],&A[2]);
  int max = A[0],min = A[0];
  for(i = 0;i < 3; ++i){
    if(max < A[i])	max = A[i];
    if(min > A[i])	min = A[i];
  }
  printf("%d\n",max - min);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        for(int h=(int)N/4; h<=3500; h++){
            if(4*h<=N) continue;
            for(int w=(int)Math.max(h,N*h/(4*h-N));w<=3500;w++){
                if(4*h*w-N*w-N*h<=0) continue;
                long low = N*h*w/(4*h*w-N*w-N*h);
                if(low>3500) continue;
                for(long n= low;n<=low+1;n++){
                    if(n*(4*h*w-N*w-N*h)==N*h*w){
                        String ans = Integer.toString(h)+" "+Long.toString(n)+" "+Integer.toString(w);
                        System.out.println(ans);
                        System.exit(0);
                    }
                }
            }
        }
        //System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}



int main(){
	string s;
	cin>>s;
	ll n  =s.size();
	ll su =0;
	rep(i,0,n){
		su+= (s[i]-'0');
	}
	if(su%9) cout<<"No";
	else cout<<"Yes";

	
	
}
		 

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

int intersections(double d, int r1, int r2) {
    if (d > r1 + r2) { return 4; }
    if (d == r1 + r2) { return 3; }
    if (d > r2 - r1) { return 2; }
    if (d == r2 - r1) { return 1; }
    if (d < r2 - r1) { return 0; }
    return -1;
}

double dist(double c1x, double c1y, double c2x, double c2y) {
    return sqrt(pow((c2x - c1x), 2) + pow((c2y - c1y), 2));
}

int main()
{
    double c1x, c1y, c2x, c2y;
    int  c1r, c2r;
    cin >> c1x >> c1y>> c1r >> c2x >> c2y >> c2r;
    double d = dist(c1x, c1y, c2x, c2y);
    int ans = c1r < c2r ? intersections(d, c1r, c2r) : intersections(d, c2r, c1r);
    cout << ans << '\n';
    return 0;
}




Measured memory_bytes: 3228
#include <stdio.h>
#include <math.h>

int r[502];
double WID[502];

double width(int r1, int r2)
{
	if (r1 == 10001 && r2 == 10001) {
		return 0.0;
	} else if (r1 == 10001) {
		return (double)r2;
	} else if (r2 == 10001){
		return (double)r1;
	} else
		return 2 * sqrt((double)(r1 * r2));
}

int main(void)
{
	int N,i,j,k;
	double add;
	scanf("%d",&N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &r[i]);
	}
	r[0] = r[N + 1] = 10001;

	WID[0] = 0;
	for (i = 1; i <= N + 1; i++) {
		WID[i] = WID[i - 1] + width(r[i - 1],r[i]);
	}

	for (i = 2; i <= N; i++) {
		for (j = 0; j + i <= N + 1; j++) {
			if ((add = width(r[j], r[j + i]) - (WID[j + i] - WID[j])) > 0.0) {
				for (k = j + i; k <= N + 1; k++) {
					WID[k] += add;
				}
			}
		}
	}
	printf("%.5lf\n",WID[N + 1]);
	return 0;
}

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

int main(){
	string S;
	cin >> S;
	for(int i = 0; i < S.size(); i++){
		if((i % 2 == 0 && S[i] == 'L') || (i % 2 == 1 && S[i] == 'R')){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using V = vector<int>;
using VV = vector<vector<int>>;
int Inf = (1<<30);
ll inf = (1LL<<60);
int main() {
	int n;
	cin >> n;
	int sum = 0;
	int i;
	for (i = 1; i <= n; i++) {
		sum += i;
		if (sum >= n) break;
	}
	int point = i;
	int diff = sum - n;
	for (i = 1; i <= point; i++) {
		if (diff == i) continue;
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if (A + B >=C) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

}

Measured memory_bytes: 21972
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn=100000+505;
ll a[maxn],b[maxn],c[maxn];
ll n;
ll cntb[maxn];
ll cnta[maxn];
int main()
{
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    memset(cntb,0,sizeof(cntb));
    memset(cnta,0,sizeof(cnta));
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    sort(b,b+n);
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(c,c+n);
    for(int i=n-1;i>=0;i--){
        ll pos=upper_bound(c,c+n,b[i])-c;
        cntb[i]+=cntb[i+1];
        if(pos<n)
            cntb[i]+=n-pos;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        int pos=upper_bound(b,b+n,a[i])-b;
        if(pos<n)
            ans+=cntb[pos];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4224
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [a, b] = input[0];

  const ab = Number(`${a}${b}`);

  return Math.ceil(Math.sqrt(ab)) ** 2 === ab ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29592
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long a[10005],b[10050];
long long st[4005][4005];
int main ()
{
	int n; long long x;
	scanf("%d%lld",&n,&x);
	for(int i=1;i<=n;++i) scanf("%lld",a+i),a[i+n]=a[i];
	memset(st,127,sizeof(st));
	for(int i=1;i<=2*n;++i)
	for(int j=i;j<=2*n;++j)
	st[i][j]=min(st[i][j-1],a[j]);	
//	for(int i=1;i<=2*n;++i)
//	{
//			for(int j=1;j<=2*n;++j) cout<<st[i][j]<<" ";
//			cout<<endl;
//	}

	long long ans=1ll<<60;
	for(int i=0;i<n;++i)
	{
		long long sum=0;
		for(int j=n;j<=2*n-1;++j)sum+=st[j-i][j];
		sum+=x*i;
		ans=min(sum,ans);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vvec<char> S(H,vec<char>(W));
    for(auto& v:S) for(auto& c:v) cin >> c;
    string init = "";
    for(int i=0;i<H;i++) init += '#';
    bool ok = false;

    auto is_palindrome = [](string s){
        string t = s;
        reverse(t.begin(),t.end());
        return s==t;
    };

    auto check = [&](vec<pair<int,int>> v){
        vec<string> A(W,init);
        int n = v.size();
        int c = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<W;j++){
                A[j][c] = S[v[i].first][j];
                if(v[i].second!=-1) A[j][H-1-c] = S[v[i].second][j];
            }
            c++;
        }
        vec<string> B = A;
        map<string,int> mp,rev;
        for(int i=0;i<W;i++){
            mp[A[i]]++;
            reverse(B[i].begin(),B[i].end());
            rev[B[i]]++;
        }
        int cnt = 0;
        int rev_cnt = 0;
        for(auto& s:mp){
            if(!is_palindrome(s.first)) cnt += max(0,s.second-rev[s.first]);
            else{
                rev_cnt += s.second;
                cnt += (s.second%2==1? 1:0);
            }
        }
        if(W%2==0){
            ok |= cnt==0;
        }else{
            ok |= (cnt==1 && rev_cnt%2==1);
        }
    };

    vec<int> vis(H);
    auto dfs = [&](auto&& self,vec<pair<int,int>>& v,int dep,int mid=-1)->void{
        if(v.size()==H/2){
            if(mid!=-1) v.emplace_back(mid,-1);
            check(v);
            if(mid!=-1) v.pop_back();
        }
        else{
            vec<int> now;
            for(int i=0;i<H;i++) if(mid!=i && !vis[i]) now.push_back(i);
            for(int i=0;i+1<now.size();i++){
                v.emplace_back(now[0],now[i+1]);
                vis[now[0]] = vis[now[i+1]] = 1;
                self(self,v,dep+1,mid);
                v.pop_back();
                vis[now[0]] = vis[now[i+1]] = 0;
            }
        }
    };
    vec<pair<int,int>> v;
    if(H%2==0) dfs(dfs,v,0);
    else for(int i=0;i<H;i++) dfs(dfs,v,0,i);
    cout << (ok? "YES\n":"NO\n");
}

Measured memory_bytes: 3676
#define mod 998244353
#define G2 499122177
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn=1<<19;
int n;
ll a[maxn],p[maxn];
inline ll qpow(ll x,ll y)
{
	ll ans=1,base=x;
	while(y)
	{
		if(y&1)
			ans=ans*base%mod;
		base=base*base%mod;
		y>>=1;
	}
	return ans;
}
inline void FWT(ll*A,int limit)
{
	for(int len=2;len<=limit;len<<=1)
		for(int i=0;i<limit/len;++i)
			for(int j=0;j<len/2;++j)
			{
				ll x=A[i*len+j],y=A[i*len+j+len/2];
				A[i*len+j]=(x+y)%mod;
				A[i*len+j+len/2]=(x-y+mod)%mod;
			}
}
inline void IFWT(ll*A,int limit)
{
	for(int len=2;len<=limit;len<<=1)
		for(int i=0;i<limit/len;++i)
			for(int j=0;j<len/2;++j)
			{
				ll x=A[i*len+j],y=A[i*len+j+len/2];
				A[i*len+j]=(x+y)%mod*G2%mod;
				A[i*len+j+len/2]=(x-y+mod)%mod*G2%mod;
			}
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	ll s=0;
	for(int i=0;i<(1<<n);++i)
	{
		cin>>p[i];
		s+=p[i];
	}
	s=qpow(s%mod,mod-2);
	for(int i=0;i<(1<<n);++i)
		p[i]=p[i]*s%mod;
	a[0]=(1<<n)-1;
	for(int i=1;i<(1<<n);++i)
		a[i]=mod-1;
	p[0]=(p[0]-1+mod)%mod;
	FWT(p,1<<n),FWT(a,1<<n);
	for(int i=0;i<(1<<n);++i)
		a[i]=a[i]*qpow(p[i],mod-2)%mod;
	IFWT(a,1<<n);
	for(int i=0;i<(1<<n);++i)
		cout<<(a[i]-a[0]+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 11008
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    BPalindromephilia solver = new BPalindromephilia();
    solver.solve(1, in, out);
    out.close();
  }

  static class BPalindromephilia {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      String s = in.next();
      int cnt = 0;
      for (int i = 0; i < s.length() - 1 - i; i++) {
        if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
          cnt++;
        }
      }
      out.println(cnt);
    }

  }
}



Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  bool ans = true;
 
  cin >> N;

  vector<long long> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for(int i = 1; i < N; i++){
    if(a[i-1] == a[i]){
      ans = false;
    }
  }
  if(ans){
      cout << "YES" << endl;;
  }else{
      cout << "NO" << endl;;
  }
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(long a, long b){     // C(a,b) = a! * b!^(M-2) * (a-b)^(M-2)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(long a, long b){     // P(a,b) = a! * (a-b)!^(M-2)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(long i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M)
    }
    return;
}


ll dp[205][100005];

int main(int argc, char* argv[])
{
    long n, x;
    scanf("%ld%ld", &n, &x);

    vector<long> s(n);
    long i,j;
    for(i=0; i<n; i++) {
        scanf("%ld", &s[i]);
    }
    sort(s.rbegin(), s.rend());

    pre_comb();

    dp[0][x]=1;
    for(i=0; i<n; i++) {
        for(j=0; j<=x; j++) {
            if(dp[i][j]) {
                long m;
                for(m=i+1; m<=n; m++) {
                    ll tmp = dp[i][j];
                    tmp = (tmp * perm(n-i-1, m-i-1))%MOD;
                    dp[m][j%s[m-1]] = (dp[m][j%s[m-1]] + tmp)%MOD;
                }
            }
        }
    }

    ll ans=0;
    for(i=0; i<s[n-1]; i++) {
        ans = (ans + i*dp[n][i])%MOD;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 160640
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int n,ans;
int main() {
//	freopen("1.txt","r",stdin);
	read(n);
	while (n>=500) n-=500,ans+=1000;
	ans+=5*(n/5);
	printf("%d\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        int a, b;
        intReadLine(out a, out b);
        string[] ab = new string[2];
        for(int i = 0; i < b; i++)
        {
            ab[0] += a.ToString();
        }
        for(int i = 0; i < a; i++)
        {
            ab[1] += b.ToString();
        }
        Array.Sort(ab);
        WriteLine(ab[0]);
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 13536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int S = scan.nextInt();

		int h,m,s;
		h = S / 3600;
		m = (S % 3600) / 60;
		s = (S % 3600) % 60;

		
		System.out.println( h + ":" + m  + ":" + s);

	}

}

Measured memory_bytes: 26272
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    int price = 700;
    char str[3];
    scanf("%s", str);
    for (auto x : str) {
        if (x == 'o')
            price += 100;
    }
    printf("%d\n", price);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <set>
#include <map>
#include <string>

using namespace std;

bool sortVec(pair<int, int> p1, pair<int, int> p2)
{
    return p1.second < p2.second;
}

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

    int p[m];
    vector<pair<int, int>> vec[n + 1];

    for(int i=0; i<m; i++)
    {
        int y;
        cin >> p[i]; cin >> y;
        vec[p[i]].emplace_back(make_pair(i, y));
    }

    for(int i=0; i<=n; i++) sort(vec[i].begin(), vec[i].end(), sortVec);

    int order[m];
    for(int i=0; i<=n; i++)
    {
        for(int j=0; j<vec[i].size(); j++)
        {
            order[vec[i][j].first] = j + 1;
        }
    }

    for(int i=0; i<m; i++)
    {
        printf("%06d%06d\n", p[i], order[i]);
    }

    return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int N;
  int first, last;
  char S[100];
  int isExist, isFirst;
  int cut_array[99] = {0};
  int max = 0;
  scanf("%d\n", &N);
  scanf("%s", S);

  for (char i = 'a'; i <= 'z'; i++) {
    isFirst = 1;
    isExist = 0;
    first = 0;
    last = 0;
    for (int j = 0; j < N; j++) {
      if (S[j] == i) {
        isExist = 1;
        if (isFirst) {
          first = j;
          isFirst = 0;
        } else {
          last = j - 1;
        }
      }
    }
    // printf("debug %c first = %d last = %d\n", i, first, last);
    if (isExist && last != 0) {
      for (int i = first; i <= last; i++) {
        cut_array[i]++;
      }
    }
  }
  for (int i = 0; i < N - 1; i++) {
    if (cut_array[i] > max) max = cut_array[i];
    // printf("debug cutarray[%d] = %d\n", i, cut_array[i]);
  }
  printf("%d", max);
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();  //文字列S
		String newS = "";  //xに置き換えて新しく表示する文字列

		//newSにsの文字数分xを代入
		for(int i=0 ; i<s.length() ; i++) {
			newS += "x";
		}
		System.out.print(newS);
		sc.close();
	}
}

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

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

	int Q = 1;
	int power = 1;
	while (Q) {
		if (N >= pow(K, power)) {
			power++;
		}
		else {
			Q = 0;
		}
	}

	cout << power << endl;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=Counter(a).most_common()
b.sort(key=lambda x:x[0],reverse=True)
s=0
t=0
for len in b:
    if s==0 and len[1]>=4:
        print(len[0]**2)
        exit()
    elif s==0 and len[1]>=2:
        s=len[0]
    elif s!=0 and len[1]>=2:
        print(s*len[0])
        exit()
print(0)

Measured memory_bytes: 21540
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <P,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int path[26][26];
int visited[26];
bool isConnect;

int dfs(int src,int* visited){
	visited[src] = 1;
	int res = 1;
	for(int i=0;i<26;i++){	
		if(path[src][i] && visited[i] == 0){
			res += dfs(i,visited);
		}
	}
	return res;
}

int main(){
	int n;
	
	while(~scanf("%d",&n)){
		if(n==0) break;
		memset(path,0,sizeof(path));
		memset(visited,0,sizeof(visited));
		set<int> src;
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			if(*str.begin()-'a' != *(str.end()-1)-'a'){
				path[*str.begin()-'a'][*(str.end()-1)-'a']++;
			}

			src.insert(*(str.end()-1)-'a');
			src.insert(*str.begin()-'a');
		}
				

		if(src.size() != dfs(*src.begin(),visited)){
			printf("NG\n");
			continue;
		}

		bool isok=true;

		for(set<int>::iterator it = src.begin(); it != src.end(); it++){
			int out=0;
			for(int j=0;j<26;j++){
				out += path[*it][j];
			}

			int in=0;
			for(int j=0;j<26;j++){
				in += path[j][*it];
			}

			if(out != in) isok = false;
		}

		printf("%s\n",isok ? "OK" : "NG");
	}
}

Measured memory_bytes: 936
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define MP(a,b) make_pair(a,b)
#define PB push_back
#define lp (p << 1)
#define rp (p << 1|1)

typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;
const int mod = (int)(1e9 + 7);

char s[10];

int main(){
	scanf("%s",s + 1);
	bool flag = false;
	for(int i = 1; s[i + 1] != '\0'; ++i){
		if(s[i] == 'A' && s[i + 1] == 'C'){
			flag = true;
			break;
		}
	}
	if(flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
#define deb(x) cerr << "\n" << (#x) << " is " << (x) << endl
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}
auto random_add = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_add() | 1);
mt19937_64 rng(SEED);


const int N=1e6+5;
int a[N]={0};


void solve()
{ 

  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<n;i++)
  {
   // cout<<a[i]<<":";
    for(int j=1;j*i<=n;j++)
    {
      a[j*i]++;
    }
    //cout<<a[i]<<endl;
    ans+=a[i];
  }
  cout<<ans<<endl;

}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
// cin>>t;
 for(int i=1;i<=t;i++)
 {
   solve();
 }
}


Measured memory_bytes: 11416
#include<iostream>

using namespace std;

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a >= 13) cout << b << endl;
	else if(a <= 5) cout << 0 << endl;
	else cout << b / 2 << endl;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define mp make_pair
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcd(int a,int b){return a*b / gcd(a,b);}
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  LL blue,red;
  LL n;
  cin >> n >> blue >> red;
  LL res = 0;
  res += n /(blue+red) * blue;
  res += min(n%(blue+red),blue);
      cout << res <<endl;
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
s,c=[],[]
for _ in range(M):
    s_,c_ = map(int,input().split())
    s.append(s_)
    c.append(c_)

if N != 1:
    a,b=10**(N-1),10**N
else:
    a,b=0,10

for i in range(a,b):
    ok = True
    num = str(i)
    for k in range(M):
        if num[s[k]-1] != str(c[k]):
            ok = False
    if ok:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(a: int, b: int, c: int, d: int):
    if abs(a-c) <= d:
        print("Yes")
    elif abs(a-b) <= d and abs(b-c) <= d:
        print("Yes")
    else:
        print("No")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(a, b, c, d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

N,T = gi
t = gi
ans = 0

rep N do |i|
	if i>0 && t[i]-t[i-1] > T
		ans += T
	else
		if i > 0
			ans += t[i]-t[i-1]
		else
			ans += t[i]
		end
	end
end

puts ans+T

Measured memory_bytes: 15540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace past10.Abc
{
    public class Question5
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var Arr = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long t;
            long total;
            long ans=0;
            for(long i=1;i<=Arr[0];++i){
                t = i;
                total=0;
                while(t > 0){
                    total += t%10;
                    t=t/10;
                }
                if(total >= Arr[1] && total <= Arr[2]){
                    ans+=i;
                }
            }
            Console.WriteLine(ans);
            Console.Out.Flush();
        }
    }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int H,W;
  cin>>H>>W;
  vector<string>C(H);
  for(int i=0;i<H;i++){
    cin>>C[i];
  }
  for(int i=0;i<2*H;i++){
    for(int j=0;j<W;j++){
      cout<<C[i/2][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vp vector< pair<int,int> >

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,t;
    cin>>a>>b>>t;
    int c=0;
    for(int i=0;i<=t+0.5;i+=a)
    {
        c+=b;
    }
    cout<<c-b<<"\n";
    return 0;
}



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

using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    if(s == "SUN")cout << 7;
    else if(s == "MON")cout << 6;
    else if(s == "TUE")cout << 5;
    else if(s == "WED")cout << 4;
    else if(s == "THU")cout << 3;
    else if(s == "FRI")cout << 2;
    else if(s == "SAT")cout << 1;
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    int lis[3];
    for(int i=0;i<N;i++)cin>>lis[i];
    for(int i=1;i<=100000000;i++){
        int flg=1;
        for(int j=0;j<N;j++){
            if(lis[j]%i)flg=0;
        }
        if(flg)cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160