akhauriyash/Code-Regression huggingface dataset:
a, b, k = map(int, input().split())
ans_list = set()
for value in range(a, min([a+k, b])):
    ans_list.add(value)
for value in range(max([a, b-k+1]), b+1):
    ans_list.add(value)
ans_list = sorted(list(ans_list))
for ans in ans_list:
    print(ans)

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

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

Measured memory_bytes: 3668
#include<stdio.h>
int main()
{
  int i,j,n,a,b,c,d,e,f=0;
  scanf("%d",&n);
  for(i=21;i<=n;i=i+2)
  {
    d=0;
    for(j=1;j<=i;j++)
    {
      if(i%j==0) d++;
    }
    if(d==8) f++;
  }
  printf("%d\n",f);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int coin_500 = 0;
  int coin_5 = 0;
  unsigned int have = 0;
  
  scanf("%u", &have);
  coin_500 = have / 500;
  have -= 500 * coin_500;
  coin_5 = have / 5;
  printf("%d\n", coin_500 * 1000 + coin_5 * 5);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)cout<<c<<endl;
	if(a==c)cout<<b<<endl;
	if(b==c)cout<<a<<endl;
	return 0;
}



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

#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define int long long
#define MMAX 16384
#define fast_io() ios::sync_with_stdio(false)
#define FOR(i, l, r) for(int i = (l); i < (r); i++)

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef double ld;
typedef pair<ld, ld> dd;

const ll INF = 1000000000000000000LL;
const int NMAX = 1e6+4;
const int mod = 1e9+7;
const ld eps = 1e-10;
const ld PI = acos(-1);

int N;
vi a;

signed main(){
    fast_io();
    cin >> N;
    FOR(i,0,N){
        int A;
        cin >> A;
        a.pb(A);
    }
    a.pb(-1);
    int cnt = 0;
    int sz = 0;
    FOR(i, 1, N+1){
        sz ++;
        if(a[i] != a[i-1]) {
            cnt += sz/2;
            sz = 0;
        }
    }
    cout<<cnt<<endl;
}   

Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

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

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

int a[101], b[101];

//??????dp
int dp[101][101] = {};
int dfs(int l, int r) {
	if (dp[l][r] != INF)return dp[l][r];
	if (r - l == 1)
		dp[l][r] = 0;
	else if (r - l == 2)
		dp[l][r] = a[l] * b[l] * a[l + 1] * b[l + 1];
	else if (r - l >= 3)
		rep(m, l + 1, r) dp[l][r] = min(dp[l][r], dfs(l, m) + dfs(m, r) + a[l] * b[m - 1] * a[m] * b[r - 1]);
	return dp[l][r];
}

signed main() {
	memset(dp, 0x3f, sizeof(dp));
	int n; cin >> n;
	rep(i, 0, n)cin >> a[i] >> b[i];
	cout << dfs(0, n) << endl;
	return 0;
}

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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

// to avoid error on mingw
string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

class UnionFind {
private:
    vi par;
    vi rank;

    int find(int x) {
        if(par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

public:
    UnionFind(int n) {
        rep(i,n) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x==y) return;

        if(rank[x] < rank[y])
            par[x] = y;
        else {
            par[y] = x;
            if(rank[x] == rank[y])
                rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};



struct edge {int from, to; double cost;};
bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}
ll twice(int t) {return t*t;}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(8);
    ios_base::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector< pii > piles(N);
    rep(i, N)
        cin >> piles[i].first >> piles[i].second;

    vector<edge> edges(M);
    double totalCost = 0.0;
    rep(i, M) {
        int p, q;
        cin >> p >> q;
        --p, --q;
        double cost = sqrt( twice(piles[p].first - piles[q].first) + twice(piles[p].second - piles[q].second) );
        edges[i] = edge{ p, q, -cost };
        totalCost += cost;
    }

    // kruscal
    sort(all(edges), comp);
    UnionFind uf(N);

    double res = 0;

    tr(it, edges) {
        if(!uf.same(it->from, it->to)) {
            uf.unite(it->from, it->to);
            res += it->cost;
        }
    }

    cout << totalCost - (-res) << endl;

    return 0;
}

Measured memory_bytes: 1952
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vvll vector<vll>
#define wh(t) while(t--)
#define fi(n) for(ll i = 0; i < n; i++)
#define fj(n) for(ll j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fr first
#define se second
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x)%M;x = (x * x)%M;n = n>>1;}return a;}

void solve(){
	ll n;
	cin >> n;
	vll a(n);
	fi(n) cin >> a[i];
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	ll sum = 0;
	ll cnt = 0;
	fi(n){
		sum+=a[i];
		cnt++;
		if(cnt==n-1) break;
		if(!i) continue;
		sum+=a[i];
		cnt++;
		if(cnt==n-1) break;
	}
	cout << sum;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	#endif
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		solve();
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 4780
function Main(input) {
    
    var data = input.split("\n");
    var n = parseInt(data[0]);
    var ans;
    if(n%2==0){
        ans = 0.5;
    }else{
        ans = (n+1)/2/n;
    }
    
    console.log(ans);
}
//（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.Scanner;

class Main {

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

		String S = scanner.next();
		
		scanner.close();

		for (int i = 0; i < S.length(); i++) {
			System.out.print('x');
		}
		System.out.println();
 		
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int A, B, X;
	cin >> A >> B >> X;
	if( A <= X && A + B >= X ){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long int ll;
ll gcd(ll a, ll b);
ll bur(ll N, ll X);
bool IsPrime(int num);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll L = 0;
	ll P = 0;
	//ll T = 0;
	//ll M = 0;
	ll h[1000] = {};
	//ll b[100] = {};
	//ll c[100] = {};
	//ll d[100] = {};

	//ll v[3] = {};
	//ll *c, *s, *n;
	string S[50],T[50],U[52];
	char fi[50], fv[50];

	ll count = 0;
	ll count2 = 0;
	float sum = 0;
	ll min = 1000000000000;
	ll max = 1;
	ll dist1 = 0;
	ll dist2 = 0;
	ll now = 0;
	int tmax = 0;
	int tmax2 = 0;
	//int flag = 0;
	char temp,head;
	//int is = 0;
	bool flag = false;
	
	//char p;

	ll all = 0;
	ll niku = 0;
	ll state = 2;
	bool down = true;
	

	//cin >> S;
	
	
	
	
	cin >> fi[0] >> fi[1] >> fi[2];
	cin >> fv[0] >> fv[1] >> fv[2];

	
	if((fi[0] == fv[2]) && (fi[1] == fv[1]) && (fi[2] == fv[0]))
	cout << "YES" << endl;
	else
		cout << "NO" << endl;
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	
	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	//cin >> N >> M;

	//vector<pair<int,int>> c(M);
	////vector<pair<int, int>> e(M);
	//vector<ll> d(M);

	//rep(i, 0, M) {
	//	cin >> c[i].first >> c[i].second;
	//	//e[i].first = c[i].first;
	//	//e[i].second = c[i].second;

	//}
	////sort(c.begin(), c.end());

	//

	//rep(i, 0, M) {

	//	
	//	
	//	rep(j, 0, M) {
	//		if (c[i].first == c[j].first && c[j].second < c[i].second) {
	//			d[i]++;
	//			//cout << j << endl;
	//		}
	//	}
	//	cout << std::setfill('0') << std::right << std::setw(6) << c[i].first;
	//	cout << std::setfill('0') << std::right << std::setw(6) << d[i]+1 << endl;
	//}

	return 0;

}

ll bur(ll N,ll X) {
	ll pan = 1;
	ll pat = 1;
	ll burg = 0;



	if (X > burg) {
		if (N == 0)
			return pat;


		burg += pan;
		burg += bur(N - 1, X);
		burg += pat;
		burg += bur(N - 1, X);
		burg += pan;


	}

	return burg;

}

ll gcd(ll a, ll b) {
	
	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y/b*x;
}

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

Measured memory_bytes: 256
n = int(input())
a = [ int(x) for x in input().split() ]

cnt = [ 0 for _ in range(n) ]
for i in range(n):
    c = 0
    while True:
        if a[i] & 1:
            break
        c += 1
        a[i] //= 2
    cnt[i] = c

print(min(cnt))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int tmp;
        double sum = 0,p;
        for(int i=0;i<n;i++){
            tmp = i+1;
            p = 1.0/n;
            while(tmp<=k-1){
                tmp*=2;
                p/=2.0;
            }
            sum+=p;
        }
        System.out.println(sum);
        System.out.flush();
        sc.close();
    }
}

Measured memory_bytes: 22740
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        a[0] = sc.nextInt();
        for(int i = 1; i < n; i++) a[i] = a[i-1] + sc.nextInt();
        b[0] = sc.nextInt();
        for(int i = 1; i < n; i++) b[i] = b[i-1] + sc.nextInt();
        int ans = a[0] + b[n-1];
        for(int i = 1; i < n; i++)
            ans = Math.max(ans, a[i] + b[n-1] - b[i-1]);
        System.out.println(ans);
    }
}

Measured memory_bytes: 25300
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <climits>

char buf[200];

int calc(int offset)
{
  int result = 0;
  for (int i = 0; i < 3; i++) {
    result = 10* result + buf[offset+i] - '0';
  }
  return result;
}

int main()
{
  fgets(buf, sizeof(buf), stdin);
  *strchr(buf, '\n') = '\0';
  int result = INT_MAX;
  for (int i = 0; i + 3 <= strlen(buf); i++) {
    result = std::min(result, std::abs(753 - calc(i)));
  }
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int n,k,a[105],s=0;
int main (){
	n=read();k=read();
	for (int i=1;i<=n;i++)
	{a[i]=read();}
	sort(a+1,a+n+1);
	for (int i=n;i>=1&&i>=n-k+1;i--)
	{s+=a[i];}
	printf ("%d",s);
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
int inv(LL x, int m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
int mpow(LL a, LL k, int m) { int r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }


const int N = 1e5 + 5;
int n, m, F[N], C[N];
LL X[N];
struct Edge { int u, v, w; } E[N];
int root(int x) { return F[x] < 0 ? x : F[x] = root(F[x]); }
int size(int x) { return -F[root(x)]; }
bool same(int x, int y) { return root(x) == root(y); }
bool unite(int x, int y) {
    x = root(x), y = root(y);
    if (x != y) {
        if (F[y] < F[x]) swap(x, y);
        F[x] += F[y], F[y] = x, X[x] += X[y], C[x] += C[y];
    }
    return x != y;
}

int main() {
    memset(F, -1, sizeof F);
    cin >> n >> m;
    FI(i, 1, n) scanf("%lld", &X[i]);
    FI(i, 1, m) scanf("%d%d%d", &E[i].u, &E[i].v, &E[i].w);
    sort(E + 1, E + 1 + m, [](Edge a, Edge b) { return a.w < b.w; });
    FI(i, 1, m) {
        int u = E[i].u, v = E[i].v, w = E[i].w;
        u = root(u), v = root(v);
        if (u == v) {
            if (X[u] < w) C[u]++;
            continue;
        }
        if (X[u] + X[v] >= w) C[u] = C[v] = 0;
        else C[u]++;
        unite(u, v);
    }
    int r = root(1);
    cout << C[r] << endl;
}


Measured memory_bytes: 2944
s=input()
n=int(input())
to_a=[(ord("z")+1-ord(c))%26 for c in s]
is_a=[False for c in s]
for i in range(len(s)):
  if n>=to_a[i]:
    n-=to_a[i]
    is_a[i]=True
    to_a[i]=0
n%=26
for i in range(len(s)-1,-1,-1):
    if not is_a[i]:
        s=s[:i]+chr(ord(s[i])+n)+s[i+1:]
        n=0
        break
if n>0:
    s=s[:-1]+chr(ord("a")+n)
    is_a[-1]=False
for i in range(len(s)):
  if is_a[i]:
    print("a",end="")
  else:
    print(s[i],end="")

Measured memory_bytes: 55264
K,A,B = map(int,input().split())

# 最終的にビスケットに交換するのが必要
if (B-A < 2) :
    # ビスケットたたいてるほうがアド
    print(K+1)
elif (K < A - 1) :
    # たたいてる間に終わってしまう(換金操作は2行動必要)
    print(K+1)
else :
    # 最初はA枚になるまでビスケットをたたく
    K -= (A-1)
    biscuits = A

    action = K // 2
    # A枚払ってB枚獲得
    biscuits += (B-A) * action
    
    if (K % 2 == 1) :
        biscuits += 1
    
    print(biscuits)


Measured memory_bytes: 3060
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int x, y, z;
  cin >> x >> y >> z;
  int n = 0;
  x -= z;
  while (x >= y+z) {
    n++;
    x -= y+z;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
  let mut stdin = String::new();
  std::io::Read::read_to_string(
    &mut std::io::stdin(),
    &mut stdin).unwrap();
  let mut stdin = stdin.split_whitespace();
  let mut get = || stdin.next().unwrap();
  macro_rules! get {
    ($t:ty) => (get().parse::<$t>().unwrap());
    () => (get!(i64));
  }
  
  let n = get!(usize);
  let a = get!(usize) - 1;
  let b = get!(usize) - 1;
  let c = get!(usize) - 1;
  let d = get!(usize) - 1;
  let s = get().as_bytes();
  
  let r = b'#';
  
  fn no() { println!("No"); }
  fn yes() { println!("Yes"); }
  
  for i in a .. c {
    if s[i]==r && s[i+1]==r {
      no(); return;
    }
  }
  for i in b .. d {
    if s[i]==r && s[i+1]==r {
      no(); return;
    }
  }
  if c < d {
    yes(); return;
  }
  
  let e = std::cmp::min(c, d);
  let m = b'.';
  for i in b-1 .. e {
  	if s[i]==m && s[i+1]==m && s[i+2]==m {
    	yes(); return;
    }
  }
  
  no();
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=1;i<n;i++)
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int d=c-(a-b);
  if(d>0) cout<<d;
  else cout<<0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;




int main(void){
    ll N,A,B;
    cin >> N >> A >> B;
    ll C=A+B;
    ll out;
    out=(N/C)*A;
    N=N%C;
    if(N > A){
        cout << out+A << endl;
    }else{
        cout << out+N << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<ll> vint;
int main() {
  ll a,b,c,d,ans=0;
  cin >>a>>b>>c>>d;
  
  vint v(101,0),s(101,0);
  for (ll i=a;i<=b;i++) v.at(i)++;
  for (ll i=c;i<=d;i++) s.at(i)++;
  
  for (ll i=0;i<=100;i++) {
    if (v.at(i)==1 && s.at(i)==1) ans++;
  }
  if (ans>0) ans--;
  cout << ans;
}

Measured memory_bytes: 256
// atcoder/abc172/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

template<typename T>
struct PrefixSum {
  vector<T> sum;
  PrefixSum(vector<T> v) {
    sum.push_back(0);
    for (int i = 0; i < v.size(); ++i) {
      sum.push_back(sum.back() + v[i]);
    }
  }
  T operator () (size_t begin, size_t end) const {
    assert(begin <= end);
    return sum[end] - sum[begin];
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, m;
  lli k;
  while (cin >> n >> m >> k) {
    vec<lli> a(n);
    vec<lli> b(m);
    cin >> a >> b;

    // reverse(a.begin(), a.end());
    // reverse(b.begin(), b.end());

    PrefixSum<lli> x(a);
    PrefixSum<lli> y(b);

    lli mx = 0;
    for (int i = 0; i <= a.size(); ++i) {
      lli s = x(0, i);
      if (k < s) continue;
      auto itr = lower_bound(y.sum.begin(), y.sum.end(), k - s + 1);
      --itr;
      lli t = itr - y.sum.begin();
      setmax(mx, i + t);
    }
    cout << mx << endl;
  }

  return 0;
}


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

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

  int dp[n][n];

  for(int i = n - 1; i >= 0; i--){
    for(int j = n - 1; j >= 0; j--){
      if(s[j] != s[i]){
        dp[i][j] = 0;
        continue;
      }
      if(i + 1 >= n || j + 1 >= n) dp[i][j] = 1;
      else dp[i][j] = dp[i + 1][j + 1] + 1;
    }
  }

  int ans = 0;
  rep(i, n){
    rep(j, n){
      ans = max(ans, min(abs(i - j), dp[i][j]));
      //cout << dp[i][j] << " ";
    }
    //cout << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 101260
import java.util.*;

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int sheep = sc.nextInt();
          int wolf = sc.nextInt();
          if(sheep <= wolf){
          System.out.println("unsafe");
        } else {
          System.out.println("safe");
        }
          }
  }

Measured memory_bytes: 35844
package com.example.itp1.one

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    try {
        val a_b: Array<Int> = sc.nextLine().split(" ")
                .map{it.toInt()}
                .toTypedArray()
        val a = a_b[0]
        val b = a_b[1]
        val s = a * b
        val c = (a + b) * 2
        println(String.format("%d %d", s, c))
    } catch (e: Exception) {
        println(e)
    }
}



Measured memory_bytes: 32852
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;

int main() {
  INCANT;
  cin >> N;
  rep(i, 50000) {
    int d = (i+1)*1.08;
    if (d==N) {
      cout << i+1 << "\n";
      return 0;
    }
  }
  cout << ":(" << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const int Max = 3e5;

char num[Max + 5];

int main()
{
	while(~scanf("%s", num)){
		int str = strlen(num);
		int sum = 0;
		for(int i = str - 1; i >= 0; i--)
		{
			sum += (num[i] - '0');
		}
		if(sum < 9 * (str - 1) + (num[0] - '0' - 1)) sum = 9 * (str - 1) + (num[0] - '0') - 1;
		printf("%d\n", sum);
		memset(num, 0, sizeof(num));
	}
	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 20 16:39:29 2018

@author: Yuya
"""

N,A,B=map(int,input().split())

sum_k=0

for i in range(N+1):
    if i <10:
        k=i
    elif i<100:
        k=i//10+i%10
    elif i<1000:
        k=i//100+(i%100)//10+(i%100)%10
    elif i<10000:
        k=i//1000+(i%1000)//100+((i%1000)%100)//10+((i%1000)%100)%10
    else:
        k=1
    if A<=k and k<=B:
        sum_k=sum_k+i
      
print(sum_k)


Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d %d %d", $x, $y, $z);
$tmp = 0;
$unit = $z + $y;
$ret = 0;
do {
     if($z + $y + $z == $x) {
        $ret++;
        break;
    } elseif($z + $y + $z < $x) {
        $ret++;
        $x = $x - $unit;
    } else {
        break;
    }
} while($x > $unit);
echo $ret."\n";

Measured memory_bytes: 5496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
  int N;
  cin>>N;
  int cnt=0;
  bool ans=false;
  vector<vector<int>> A(N, vector<int>(2));
  rep(i,N){
      rep(j,2){
          cin>>A[i][j];
      }
      if(A[i][0]==A[i][1]){
          cnt++;
      }
     else{
         if(3<=cnt){
             ans=true;
         }
         cnt=0;
     }
  }
  if(3<=cnt){
      ans=true;
  }
  if(ans==true){
      cout<<"Yes"<<endl;
  }
  else
  {
      cout<<"No"<<endl;
  }
  
}



Measured memory_bytes: 3628
N = int(input())
S = [input() for i in range(N)]
from collections import Counter
ctr = Counter(S)
n = ctr.most_common()[0][1]

cands = []
for j in ctr.keys():
    if ctr[j] == n:
        cands.append(j)
cands.sort()
print(*cands, sep='\n')

Measured memory_bytes: 45064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define ci(n) cin >> n
#define ci2(n, o) cin >> n >> o
#define ci3(n, o, p) cin >> n >> o >> p
#define co(n) cout << n << endl

int main() {
  int N;
  ci(N);
  if(N - 9 < 0) {
    co(N);
  }
  else if(N - 99 < 0) {
    co(9);
  }
  else if(N - 999 < 0) {
    co(9 + N - 99);
  }
  else if(N - 9999 < 0) {
    co(9 + 900);
  }
  else if(N - 99999 < 0) {
    co(9 + 900 + N - 9999);
  }
  else {
    co(9 + 900 + 90000);
  }
}  

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

int table[11][11];
int stat[11];
int p[11];

int N, M;

int check() {
  for (int i = 0; i < M; i++) {
    if (stat[i] % 2 != p[i]) {
      return 0;
    }
  }
  return 1;
}

void calc_stat(int x) {
  fill(stat, stat + M, 0);
  for (int i = 0, idx = 1; i < N; i++, idx <<= 1) { // switch
    if (x & idx) {
      for (int j = 0; j < M; j++) { // lamp
        if (table[i][j]) {
          stat[j]++;
        }
      }
    }
  }
}

void solve() {
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;

    while (k--) {
      int s;
      cin >> s;

      table[s - 1][i] = 1;
    }
  }

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

  int ans = 0;
  int end = 1 << N;
  for (int i = 0; i < end; i++) {
    calc_stat(i);
    if (check()) {
      ans++;
    }
  }

  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

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

const int N = 200000 + 10;
const int MOD = 1000000007;
const int LOG = 20;
const int INF = 1000000010;
const int delta = 11353;

int n, a[N], k[N];

int Grundy(int x, int y){
	while (x >= y){
		if (x % y == 0) return x / y;
		int alp = x / y + 1;
		int zz = x % alp;
		int tt = (x / y) * y;
		int delta = ((zz - (tt % alp)) % alp + alp) % alp;
		tt += delta;
		x = tt;
		if (x % y == 0) return x / y;
		x -= alp;
	}
	return 0;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	int G = 0;
	for (int i = 1; i <= n; i++){
		cin >> a[i] >> k[i]; 
		G ^= Grundy(a[i], k[i]);
	}
	cout << (G == 0?"Aoki":"Takahashi");
	return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=305;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int f[2][MAXN][2*MAXN];
int vi[2*MAXN],a[2*MAXN],n;
int main()
{
//	freopen("a.in","r",stdin);
	n=read();
	for(int i=1;i<=2*n;i++)a[i]=read();
	int cnt=0;
	for(int i=1;i<=2*n;i+=2)
	{
		if(a[i]!=-1&&a[i+1]!=-1)vi[a[i]]=vi[a[i+1]]=2;
		else if(a[i]==-1&&a[i+1]==-1)++cnt;
		else 
		{
			if(a[i]==-1)vi[a[i+1]]=1;
			else vi[a[i]]=1;
		}
	}
	f[0][0][0]=1;int now=0;
	for(int i=2*n;i>=1;i--)if(vi[i]!=2)
	{
		now^=1;memset(f[now],0,sizeof(f[now]));
		for(int j=0;j<=n;j++)for(int k=0;k<=2*n;k++)if(f[now^1][j][k])
		{
			if(!vi[i])
			{
				if(j)ad(f[now][j-1][k],1LL*f[now^1][j][k]*j%mod);
				if(k)ad(f[now][j][k-1],f[now^1][j][k]);
				ad(f[now][j][k+1],f[now^1][j][k]);
			}
			else
			{
				if(k)ad(f[now][j][k-1],f[now^1][j][k]);
				ad(f[now][j+1][k],f[now^1][j][k]);
			}
		}
	}
	int pre=1;
	for(int i=1;i<=cnt;i++)pre=1LL*pre*i%mod;
	pr2(1LL*f[now][0][0]*pre%mod);
	return 0;
}


Measured memory_bytes: 1664
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort()
ans = 0
for a, b in ab:
    if m == 0:
        break
    if m <= b:
        ans += a*m
        m = 0
    else:
        ans += a*b
        m -= b
print(ans)

Measured memory_bytes: 27756
def main():
    n, T = map(int, input().split())
    cts = [list(map(int, input().split())) for _ in range(n)]
    ans = float("inf")
    for ct in cts:
        c, t = ct
        if t <= T:
            ans = min(ans, c)

    if ans == float("inf"):
        ans = "TLE"

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  while(true){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
        cout << ans << endl;
        return 0;
      }
    }
    for(int i = 0; i < n; i++){
      a[i] /= 2;
    }
    ans++;
  }
}

Measured memory_bytes: 3608
# ABC064D - Insertion
# http://drken1215.hatenablog.com/entry/2019/02/16/080900
def main():
    N = int(input())
    S = input().rstrip()
    l, r = 0, 0
    for i in S:
        if i == "(":
            r += 1
        else:
            if r:
                r -= 1
            else:
                l += 1
    ans = "(" * l + S + ")" * r
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n,q=map(int,input().split())
s=input()
a=[0]*n
ac=0
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        ac+=1
    a[i]=ac
for i in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])

Measured memory_bytes: 6084
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	ll r=0;
	vector<int>A,B;
	cin>>N;
	for(int i=0;i<N+1;i++)
	{
		int a;
		cin>>a;
		A.push_back(a);
	}
	for(int i=0;i<N;i++)
	{
		int b;
		cin>>b;
		B.push_back(b);
	}
	for(int i=0;i<N;i++)
	{
		r+=min(A[i],B[i]);
		int tb;
		tb=max(B[i]-A[i],0);
		r+=min(A[i+1],tb);
		A[i+1]=max(A[i+1]-tb,0);
	}
	cout<<r<<endl;
}

Measured memory_bytes: 1528
import heapq as pq
N,K = map(int,input().split(" "))
td = []
sushi_max = [-1] * N
for i in range(N):
    t,d = map(int,input().split(" "))
    td.append((d,t))
    sushi_max[t-1] = max(sushi_max[t-1],d)

td.sort(reverse=True,key=lambda x:x[0])
cnt = [0] * N
que = []
ans = 0
for i in range(K):
    cnt[td[i][1]-1] += 1
    sushi_max[td[i][1]-1] = -1
    pq.heappush(que,td[i])
    ans += td[i][0]

sz = len(list(filter(lambda x: x > 0,cnt)))
ans += (sz*sz)

sushi_max = sorted([ (val,idx) for idx,val in enumerate(sushi_max) ],reverse=True,key=lambda x:x[0])
idx = 0
cur = ans
while len(que) > 0 and sushi_max[idx][0] != -1:
    minValue,minIdx = pq.heappop(que)
    if cnt[minIdx-1] == 1:
        continue
    cur -= minValue
    cur -= (sz*sz)
    cnt[minIdx-1] -= 1
    cnt[sushi_max[idx][1]-1] += 1
    cur += (sushi_max[idx][0] + (sz+1)*(sz+1))
    sz += 1
    idx += 1
    ans = max(cur,ans)
print(ans)


Measured memory_bytes: 81880
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    char x;
    for(int i=0;i<1200;i++){
        scanf("%c",&x);
        if(isupper(x)) {
            printf("%c",tolower(x));
        }
        else if(islower(x)) {
            printf("%c",toupper(x));
        }
        else printf("%c",x);
        if(x=='\n') {
            break;
        }
    }
}


Measured memory_bytes: 2528
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] l = new int[n];
		for(int i = 0; i < n; i++){
		    l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		
		// 計算
		int result = 0;
		for(int i = 0; i < k; i++){
		    result += l[n-i-1];
		}
		
		// 出力
		System.out.println(result);
	}

}




Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

T = []
for j, D in enumerate([C, B, A]):
    for Di in D:
        T.append(Di * 10 + j)

Ai = Ci = cnt = 0

for t in sorted(T):
    c = chr(ord('C') - (t % 10))
    if c == 'A':
        Ai += 1
    if c == 'C':
        Ci += 1
    if c == 'B':
        cnt += Ai * (N - Ci)

print(cnt)

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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int W = input[0];
		int a = input[1];
		int b = input[2];

		long ans = 0;
		if (a + W < b) { ans = b - a - W; }
        else if (b + W < a) { ans = a - b - W; }
		
        
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	TLong x;
	scanf("%lld",&x);
	printf("%lld\n", (x / 11) * 2 + ((x % 11) > 6 ? 2 : (x % 11) > 0 ? 1 : 0));
	return 0;
}


Measured memory_bytes: 128
# Problem B - ISU

# input
x, y, z = map(int, input().split())

# initialization
chair_len = x - 2 * z
max_count = 0

# count
i = 0
while True:
    if i%2==0:
        if chair_len-y<0:
            break
        max_count += 1
        chair_len -= y
    else:
        if chair_len-z<0:
            break
        chair_len -= z

    i += 1

print(max_count)


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

int main(){
  int a, b;
  char op;
  cin >> a >> op >> b;
  
  if(op == '+') cout << a + b << endl;
  if(op == '-') cout << a - b << endl;
}

Measured memory_bytes: 256
object Main {
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt)).toSeq.init
        println(in.map(x => (x(0) to x(1)).filter(n => (n % 4 == 0 && n % 100 != 0) || n % 400 == 0) match {
            case l if (l.isEmpty) => "NA"
            case l  => l.mkString("\n")
        }).mkString("\n\n"))
    }
}

Measured memory_bytes: 44640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  double t,a;
  int id;
  double ans=1000000000;
  double s=0.006;
  cin>>n>>t>>a;
  for(int i=0;i<n;i++){
    double p;
    cin>>p;
    double temp=fabs(a-(t-p*s));
    if(ans>temp){
      ans=temp;
      id=i;
    }
  }
  cout<<id+1<<endl;
  return(0);
}


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

typedef long long int ll;
#define ent cout << "\n"
#define pb push_back
#define mp make_pair
#define sz(x) x.size()
#define pair < ll, ll > pp
#define f(a, b) for(auto i = a;i < b;i++)
#define rev_f(a, b) for(auto i = b;i >= a;i--)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define st(x) sort(x.begin(), x.end()) 
#define rv(x) reverse(x.begin(), x.end()) 
#define cintc() ll tc;while(tc--) 
#define deb(x) cout << x << "\n";
#define cin(a) ll a; cin >> a;
#define cin2() ll a, b; cin >> a >> b
#define cin3() ll a, b, c; cin >> a >> b >> c
#define cinn(vect, n) def_v vect(n); f(0, n) cin >> vect[i]
#define coutn(vect, n)  f(0, n) {cout << vect[i] << "";} cout << " ";

typedef vector < ll > def_v;
typedef tuple< ll, ll, ll> def_tuple;
ll mod = 1e9 + 7,cnt = 0;

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

    ll i = 0, j = 0, save;
    while(1)
    {
        ll x = ll(pow(i, 5)), y = ll(pow(j, 5));

        // cout << x << ' ' << y << '\n';
        while(x - y < n)
        {
            j--;
            y = ll(pow(j, 5));
        }


        if(x - y == n)
        {
            cout << i << " " << j << "\n";
            return 0;
        }
        else
        {
            j = -1;
            x = ll(pow(i, 5)), y = ll(pow(j, 5)); 
            while(x - y < n)
            {
                j--;
                y = ll(pow(j, 5));
            }  

            if(x - y == n)
            {
                cout << i << " " << j << "\n";
                return 0;
            }
            else
            {
                i = i + 1;
                j = i;
            } 
        }
    }
    
    return 0;
}

Measured memory_bytes: 4100
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int n;cin >> n;
    vi prime;
    for(int i=2;i<=1000;i++) {
        bool ok = false;
        for(int j = 2;j<=sqrt(i);j++) {
            if(i%j==0) {
                ok = true;
                break;
            }
        }
        if(!ok)prime.pb(i);
    }
    // for(auto p:prime) cout << p << ' ';
    ll count = 1;
    rep(i, 168) {
        int cnt = 0;
        int N = n;
        while(N/prime[i]!=0) {
            cnt+=N/prime[i];
            N/=prime[i];
        }
        count*=cnt+1;
        count%=mod;
    }
    cout << count << endl;
}

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

int main(){
    int h, w;
    cin >> h >> w;

    string s[50];

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

    const int dx[8] = {-1, 0 , 1, -1, 1, -1, 0, 1};
    const int dy[8] = {1, 1, 1, 0, 0, -1, -1, -1};
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(s[i][j] == '#') continue;

            int num = 0;
            for(int d = 0; d < 8; ++d){
                int nj = j + dx[d];
                int ni = i + dy[d];
                if(nj < 0 || w <= nj) continue;
                if(ni < 0 || h <= ni) continue;
                if(s[ni][nj] == '#') num++;
            }
            s[i][j] = char(num + '0');
        }
    }

    for(int i =0; i < h; ++i){
        cout << s[i] << endl;
    }
}

Measured memory_bytes: 384
/**
*    author:  yuya1234
*    created: 10.07.2020 15:42:49
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  int a[n];
  REP(i,n)cin>>a[i];

  sort(a,a+n);
  vector<ll> v;

  REP(i,n-1)
  {
    if(a[i]==a[i+1])
    {
      v.emplace_back(a[i]);
      i++;
    }
  }

  if(SZ(v)>=2)cout<<v[SZ(v)-1]*v[SZ(v)-2]<<endl;
  else cout<<0<<endl;

  return 0;
}

Measured memory_bytes: 4192
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;
void Anon_mouS(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b and b==c or a!=b and b!=c and c!=a)cout<<"No";
    else cout<<"Yes";

}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define int long long
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;

ll dp[105][105000];
int n,W;
int v[105],w[105];


signed main(){
  cin.tie(0), ios::sync_with_stdio(false);
  cin >>n >> W;
  FOR(i,n) cin >>w[i] >> v[i];
  fill(dp[0],dp[0]+105000,INF);
  dp[0][0]=0;
  FOR(i,n){
    FOR(j,105000){
      if( j < v[i])
        dp[i+1][j] = dp[i][j];
      else
        dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
    }
  }
  ll ans = 0;
  FOR(i,105000) {
    if(dp[n][i] <= W) ans = i;
  }
  cout << ans fin;
  return 0;
}



Measured memory_bytes: 84224