akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

       		String initailString = scanner.nextLine();
		int initialNumber = Integer.parseInt(initailString);

		String answerTime = scanner.nextLine();

		String[] strStdIn = answerTime.split(" ", 0);
		
		String secondString = scanner.nextLine();
		int secondNumber = Integer.parseInt(secondString);

		String[] strDrink = new String[secondNumber];

		for (int r = 0; r < secondNumber; r++) {
			strDrink[r] = scanner.nextLine();
		}

		String[][] drink = new String[secondNumber][2];

		for (int n = 0; n < secondNumber; n++) {
			drink[n] = strDrink[n].split(" ", 0);
		}

		for (int s = 0; s < secondNumber; s++) {
			System.out.println(calculate(drink[s][0], drink[s][1], strStdIn, initialNumber));
		}
	}

	private static int calculate(String position, String number, String[] calculate, int totalNumber) {
		
		int iPosition = Integer.parseInt(position) -1;
		int iNumber = Integer.parseInt(number);

		int amount = 0;

		for (int i = 0; i < totalNumber; i++) {
			amount += Integer.parseInt(calculate[i]);
		}

		amount = amount + iNumber - Integer.parseInt(calculate[iPosition]);

		return amount;
	}

}

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

int main() {
  string str;
  cin >> str;
  
  int counter = 0;
  int size = str.size();
  
  for (int i = 0; i < size / 2; i++) {
    if (str.at(i) != str.at(size-i-1)) ++counter;
  }
  
  cout << counter << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second

using namespace std;

const double INF = 1e9;

int N, M, P, A, B;
double t[10], road[35][35], dp[35][(1<<8)];
int testCnt = 0;

double dfs(int nowNode, int ticketState){
  if(nowNode == B-1) return 0;
  if(ticketState == 0) return INF;
  if(dp[nowNode][ticketState] != -1.0) return dp[nowNode][ticketState];
  double ret = INF;
  //bool flag = false;
  REP(nextNode, 0, M){
    if(road[nowNode][nextNode] == INF) continue;
    REP(ticket, 0, N){
      if(!(ticketState & (1<<ticket))) continue;
      ret = min(ret, dfs(nextNode, ticketState^(1<<ticket) ) + road[nowNode][nextNode]/t[ticket] );
    }
  }
  testCnt++;
  return dp[nowNode][ticketState] = ret;
}

int main() {
  while(1){
    cin>>N>>M>>P>>A>>B;
    if(N==0) break;
    REP(i,0,N) cin>>t[i];
    REP(i,0,M)REP(j,0,M) road[i][j] = INF;
    REP(i,0,P){
      int x, y;
      double z;
      cin>>x>>y>>z;
      x--; y--;
      road[x][y] = road[y][x] = z;
    }
    REP(i,0,M)REP(j,0,(1<<N)) dp[i][j] = -1.0;
    double ans = dfs(A-1,(1<<N)-1);
    if(ans < INF) printf("%.5lf\n", ans);
    else cout<<"Impossible"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3284
#include<iostream>

using namespace std;

int Who_Is_winner(int Person, int Stones)
{
  int winner = 0;
  for(;Stones>0;Stones--)
  {
    winner += 1;

    if(winner > Person)
      winner = 1;
  }
  return winner;

}

int main(void)
{
  int Person[100];
  int Stones[100];
  int num =0, winner=0;

  cin>>num;

  for(int i=0;i<num;i++)
    cin>>Stones[i]>>Person[i];

  for(int i=0;i<num;i++)
  {
    winner = Who_Is_winner(Person[i],Stones[i]);
    cout<<winner<<endl;
  }

  return 0;

}

Measured memory_bytes: 3100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
    ll n, k; cin >> n >> k;
    vector<ll> A(n+10); A.push_back(-1);
    rep(i, n) cin >> A[i+1];

    vector<ll> visited(200200, -1);
    visited[1] = 0;
    vector<ll> pass; pass.push_back(1);

    ll rp = 0, nrp = 0, cur = 1;
    for(ll i=1; i<=min(n, k); i++){
        ll next = A[cur];
        if(visited[next] == -1){
            pass.push_back(next);
            visited[next] = i;
            cur = next;
        }else{
            rp = i - visited[next];
            nrp = pass.size() - rp;
            break;
        }
    }
    if(rp == 0) rp = pass.size();
    ll x = (k - nrp) % rp;
    cout << pass[nrp + x] << ln;
}


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

using namespace std;

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

    int n, d;
    cin >> n >> d;
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        long double xd = sqrt((x * x) + (y * y));
        if(xd <= d) cnt++;
    }
    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 3860
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


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

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

const int MOD = 1000000007;

vector<int> brdgs(7, -1);

int calc(int n){
  if(n < 0) return 1;  
  if(n == 0) return 1;
  if(n == 1) return 2;
  if(brdgs[n] == -1) brdgs[n] = calc(n-2) + calc(n-1);
  return brdgs[n];
}


int main(){
  int H, W, K;
  cin >> H >> W >> K;

  vector<vector<ll>> dp(H+1, vector<ll>(W,0));
  dp[0][0] = 1;

  for(int i = 0; i < H; i++){
    for(int k = 0; k < W; k++){
      dp[i+1][k] += dp[i][k] * calc(k-1) * calc(W-k-2);
      dp[i+1][k] %= MOD;

      if(k!= W-1){
        dp[i+1][k+1] += dp[i][k] * calc(k-1) * calc(W-k-3);
        dp[i+1][k+1] %= MOD;
      }

      if(k != 0){
        dp[i+1][k-1] += dp[i][k] * calc(k-2) * calc(W-k-2);
        dp[i+1][k-1] %= MOD;
      }
    }
  }

  cout << dp[H][K-1] << endl;

  return 0;
}


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

int main()
{
  int R,G,B,N,r,g,count;
  cin >> R >> G >> B >> N;
  r = 0;
  count = 0;
  while((N/R) >= r){
   g = 0;
    while((N/G) >= g){
      if((N - (R * r) - (G * g)) % B == 0 && (N - (R * r) - (G * g)) >= 0){
        count++;
        g++;
      }else{
          g++;
      }
    }
    r++;
  }
cout << count << endl;
}


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

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

int main(){
  int A, B, C, K, ans;
  
  cin >> A >> B >> C >> K;
  
  if(K <= A) cout << K << endl;
  
  else if(K <= B) cout << A << endl;
  
  else cout << A - (K - (A + B)) << endl;
}
  
  

Measured memory_bytes: 3596
/************************************************
┆  ┏┓　　　┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃　　　　　　　┃ ┆
┆┃　　　━　　　┃ ┆
┆┃　┳┛　┗┳　┃ ┆
┆┃　　　　　　　┃ ┆
┆┃　　　┻　　　┃ ┆
┆┗━┓　  　┏━┛ ┆
┆　　┃　  　┃　　┆　　　　　　
┆　　┃　  　┗━━━┓ ┆
┆　　┃　 AC代马 　　┣┓┆
┆　　┃　        　　┏┛┆
┆　　┗┓┓┏━┳┓┏┛ ┆
┆　　　┃┫┫　┃┫┫ ┆
┆　　　┗┻┛　┗┻┛ ┆
************************************************ */
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstring>
#include<cctype>
#include <math.h>
#include <cmath>
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define lb long double
#define LINF 0x3f3f3f3f3f3f3f3f
#define ull unsigned long long
#define random(x) (rand()%x)
#define sgn(x) (fabs(x) < eps ? 0 : ((x) < 0 ? -1 : 1))
#define rep(i, a, b) for(int i=a;i<b;i++)
#define req(j, a, b) for(int j=a;j<b;j++)
#define mem(a, b) memset(a, b, sizeof(a))
#define PI 3.14
#define K 20

using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
const double eps =1e-14;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const int hash_mod = 19260817;

inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline double dbread()
{
    double X=0,Y=1.0; int w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=X*10+(ch^48),ch=getchar();
    ch=getchar();//读入小数点
    while(isdigit(ch)) X+=(Y/=10)*(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

ll gcd(ll a,ll b)//辗转相除法（欧几里德算法）求最大公约数
{
    return b ? gcd(b,a%b) : a;
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);//最小公倍数
}
ll q_pow(ll base, ll p)
{
    ll result = 1;
    while(p > 0)
    {
        if(p&1)
        {//此处等价于if(power%2==1)
            result = result * base % 1000;
        }
        p >>= 1;//此处等价于power=power/2
        base = (base * base) % 1000;
    }
    return result;
}

struct node
{
    double k;
    double b;
}p[maxn];

bool cmp(node op1, node op2)
{
    if(op1.k == op2.k)
        return op1.b > op2.b;
    return op1.k < op2.k;
}

const int N = 250005;
int flag;
int fri[N];

void  init()
{
    for(int i = 0; i <= N; i++)
        fri[i] = i;
}
int find(int a)		//查找根节点
{
    int tem1 = a,tem2;
    while(a != fri[a])
        a = fri[a];
    while(tem1 != a)
    {
        tem2 = fri[tem1];
        fri[tem1] = a;
        tem1 = tem2;
    }
    return a;
}
void Union(int a,int b)
{
    int fri_a = find(a);
    int fri_b = find(b);
    if(fri_a != fri_b)
    {
        fri[fri_a] = fri_b;
        flag = 1;
    }
    return ;
}

map<string, int> m;



int ans[105];
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        string a;
        cin >> a;
        m[a]++;
    }
    int sum =0;
    for(auto it  : m)
	{
        sum = max(sum ,it.second);
    }
    //cout<<sum<<endl;
    for(auto it : m)
	{
        if(sum == it.second )
			cout<<it.first<<endl;
    }
    return 0;
}




Measured memory_bytes: 25856
#include <stdio.h>

int main() {
    int x,y;
    scanf("%d %d",&x,&y);
    for(int i = 1;i <= x;i++){
        if(i * 2 + (x - i) * 4 == y || i * 4 + (x - i) * 2 == y){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 1660
import java.util.*;

public 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[1001];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            a[i] = x;
            b[x]++;
        }
        Arrays.sort(a);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                int s = a[i] + a[j];
                int l = 0, r = n;
                while(1 < r - l){
                    int m = (l+r)/2;
                    if(s <= a[m]) r = m;
                    else l = m;
                }
                ans += l - j;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 26876
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> nums;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        nums.push_back(x);
    }
    sort(nums.begin(), nums.end());
    int i = nums[0];
    int j = nums[n - 1];
    int sum = 0;
    vector<int> ans;
    while(i <= j){
        for(int k = 0; k < n; ++k){
            sum += pow(nums[k] - i, 2);
        }
        ans.push_back(sum);
        sum = 0;
        i++;
    }
    int minans = 100000001;
    for(int k = 0; k < ans.size(); ++k){
        if(ans[k] < minans) minans = ans[k];
    }
    cout << minans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool f(long n)
  {if (n < 2) return false;
  for (long i(2); i * i <= n; ++i) if (!(n % i)) return false;
  return true;}
int main() {int X; for (cin >> X; ; ++X) if (f(X)) cout << X, exit(0);}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline LL read(){
    LL x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
const int N = 200050;
LL val[N<<1]; int lv;
struct Qwq{
	LL l,r;
}a[N];
int n,m,mx[N<<1],dp[N<<1]; bool ok[N<<1];
int main(){
	int i; LL x,l;
	n = read();
	lv = 0;
	for (i = 1; i <= n; ++i){
		x = read(),l = read();
		a[i].l = x - l,a[i].r = x + l;
		++lv; val[lv] = a[i].l;
		++lv; val[lv] = a[i].r;
	}
	sort(val+1,val+lv+1);
	for (i = 1; i <= n; ++i){
		a[i].l = lower_bound(val+1,val+lv+1,a[i].l)-val+1;
		a[i].r = lower_bound(val+1,val+lv+1,a[i].r)-val+1;
	}
	m = lv+1;
	for (i = 0; i <= m; ++i) mx[i] = -1,ok[i] = 0;
	for (i = 1; i <= n; ++i) mx[a[i].r] = max(1ll*mx[a[i].r],a[i].l),ok[a[i].r] = 1;
	dp[0] = 0; if (ok[0]) dp[0] = 1;
	for (i = 1; i <= m; ++i){
		dp[i] = dp[i-1];
		if (ok[i]) dp[i] = max(dp[i],1 + dp[mx[i]]);
	}
	cout << dp[m] << endl;
    return 0;
}

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


int main()
{
	int n, k;
	cin >> n >> k;
	
	if (k == 1) {
		cout << "0\n";
		return 0;
	}

	n -= k;

	cout << n << '\n';
	return 0;
}

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

using namespace std;

const int N = 2e5 + 5;
const int M = 1e6 + 9;
const long long INF = 1e9 + 7;
const int SM = 1e3 + 4;
const double EPS = 3e-16;
const int K = 25;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n; cin >> n;
    
    vector<int> a(n), b(n), c(n);
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    
    vector<vector<int>> dp(n + 1, vector<int>(4, 0));
    
    dp[1] = {0, a[1], b[1], c[1]};
    for(int i = 2; i <= n; i++){
        for(int k = 1; k <= 3; k++){
            if(k == 1){
                dp[i][k + 1] = max(dp[i][k + 1], dp[i - 1][k] + b[i]);  
                dp[i][k + 2] = max(dp[i][k + 2], dp[i - 1][k] + c[i]);
            }
            else if(k == 2){
                dp[i][k - 1] = max(dp[i][k - 1], dp[i - 1][k] + a[i]);
                dp[i][k + 1] = max(dp[i][k + 1], dp[i - 1][k] + c[i]);
            }
            else if(k == 3){
                dp[i][k - 2] = max(dp[i][k - 2], dp[i - 1][k] + a[i]);
                dp[i][k - 1] = max(dp[i][k - 1], dp[i - 1][k] + b[i]);
            }
        }
    }
    
    cout << max({dp[n][1], dp[n][2], dp[n][3]});
    return 0;
}

Measured memory_bytes: 6912
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, co;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> k >> s;
  rep(i, n - 1) {
    if (s[i] == s[i + 1]) ans++;
  }
  rep(i, k) ans += 2;
  ans = min(ans, n - 1);
  Cout(ans);
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<list>
#include<set>
#include<algorithm>
using namespace std;


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

  int d,a;
  set<int> st;

  for (int i =0; i < K ; i++) {
    cin >> d;
    for (int j=0 ; j < d ; j++) {
      cin >> a;
      st.insert(a);
    }
  }
  cout << N -st.size();
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
double dist(double x1,double y1,double x2,double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
int main(){
	double x[3],y[3];
	for(int i=0;i<3;i++){
		cin>>x[i]>>y[i];
	}
	double d[3];
	double ma=0;
	for(int i=0;i<3;i++){
		d[i]=dist(x[i],y[i],x[(i+1)%3],y[(i+1)%3]);
		ma=max(d[i],ma);
	}
	double ss=(d[0]+d[1]+d[2])/2.0;
	double s=sqrt(ss*(ss-d[0])*(ss-d[1])*(ss-d[2]));
	double r=2.0*s/(d[0]+d[1]+d[2]);
	double ok=0.0;double ng=100010.0;
	int c=10000;
	while(c--){
		double mid=(ok+ng)/2;
		if((1-mid/r)*ma>=2*mid){
			ok=mid;
		}else{
			ng=mid;
		}
	}
	printf("%.12f\n",ok);
	return 0;
}


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

#define ll long long 

ll gcd(ll a, ll b) {
  return (a % b ? gcd(b, a%b) : b);
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  
  ll C_multi = (B)/C - (A-1)/ C, D_multi = B/D - (A-1)/D;
  ll E = gcd(C,D);
  ll F = C * D / E;
  ll CD_multi = (B)/F - (A-1)/ F;
  
  cout << B- A +1 - C_multi - D_multi + CD_multi << endl;
}

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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}

int ascending_compare(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}




int a[100000];
int b[100000];
int c[100000];

int main(void){
    int n;
    int i;
    unsigned long long answer = 0;
    int ai, ci;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for (i = 0; i < n; i++){
        scanf("%d", &b[i]);
    }
    for (i = 0; i < n; i++){
        scanf("%d", &c[i]);
    }

    sort(a, a+n);
    sort(c, c+n);

    
    for (i = 0; i < n; i++){
        ai = lower_bound(a, a+n, b[i]) - a;
        ci = upper_bound(c, c+n, b[i]) - c;
        answer += (unsigned long long)(ai)*(n-ci);
        
    }

    printf("%lld\n", answer);
    return 0;
}


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

using namespace std;
typedef long long ll;
const int N=2e5+10;
const ll mod=998244353;
#define maxn 1000005
ll fac[maxn],inv[maxn];
ll pow_mod(ll a,ll n)
{
    ll ret =1;
    while(n)
    {
        if(n&1) ret=ret*a%mod;
          a=a*a%mod;
          n>>=1;
    }
    return ret;
}
void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
}
ll C(ll x, ll y)
{
    return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
}
ll ci[N];
int main()
{
   // cout<<pow_mod(3,3);
    init();
   // cout<<C(6,2);
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    for(int i=0;i<=k;i++){
        ans=(ans+((m*C(n-1,i))%mod*pow_mod(m-1,n-1-i))%mod)%mod;
            }
    cout<<(ans+mod)%mod<<endl;
}


Measured memory_bytes: 11408
#include<iostream>
using namespace std;
bool road[16][16];
int memo[16][16], h, w;
int solve(int x,int y){
  if(y < 0 || y >= h || x < 0 || x >= w || road[y][x]) return 0;
  if(memo[y][x]) return memo[y][x];
  if(x == w - 1 && y == h - 1) return 1;
  return memo[y][x] = solve(x+1,y) + solve(x,y+1);
}
int main(){
  int a, b, c;
  while(cin >> w >> h , w){
    fill_n(road[0],16*16,0) , fill_n(memo[0],16*16,0);
    cin >> c;
    while(c--){
      cin >> a >> b;
      road[--b][--a] = true;
    }
    cout << solve(0,0) << endl;
  }
}

Measured memory_bytes: 1160
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int n = ni();
		int[] a = na(n);
		if(n == 1) {
			out.println("Yes");
			return;
		}
		for(int i = n-2; i >= 0; i--) {
			if(a[i] <= a[i+1]) continue;
			a[i]--;
			if(a[i] > a[i+1]) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
	}
			    
	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private float nf() {
		return Float.parseFloat(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

int main()
{
    IOS
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)/__gcd(a,b)<<endl;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<ll>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl;
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod2 998244353
#define INT_MAX1 900000000
//////////////////////////////////////////////////////////////////////////////////////////////

int n, w;
int dp[100001][101];
bool v[100001][101];
int w1[100001], v1[100001];

int s1(int r, int i)
{
    if(r<0)
        return INT_MIN;
    if(i==n)
        return 0;
    if(v[r][i])
        return dp[r][i];
    v[r][i] = 1;
    return dp[r][i] = max(v1[i]+s1(r-w1[i],i+1),s1(r,i+1));   
}

void solve()
{
    cin >> n>>w;
    rep(i,0,n-1)
        cin >> w1[i] >> v1[i];
    cout << s1(w,0) << endl;
}
 
int32_t main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 88832
#include<iostream>
#include<list>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
    int k;
    if(n % 2 == 0) k = 1;
    else k = -1;
    list<int> a;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(k == -1) a.push_front(x);
        else a.push_back(x);
        k = -k;
    }
    string s = "";
    for(auto&& i : a){
        s += to_string(i) + " ";
    }
    s.erase(s.size() - 1, 1);
    cout << s << endl;
	return 0;
}


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

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	int t, d, ta, tb, da, db;
	cin >> t >> d >> ta >> tb >> da >> db;

	double ans = DBL_MAX;
	for(int va = 0; va <= d; va += da) {
		for(int vb = (va ? 0 : db); va + vb <= d; vb += db) {
			ans = min(ans, abs(t - static_cast<double>(ta * va + tb * vb) / (va + vb)));
		}
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1268
#include<stdio.h>
int main(){
    int H,N,i;
    int A[100000];
    int value = 0;
    
    scanf("%d %d",&H,&N);
    for(i = 0 ; i < N ; i++){
        scanf("%d",&A[i]);
    }
    for(i = 0 ; i < N ; i++){
        value += A[i];
    }
    if(value >= H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

int main()
{
    string S;
    cin >> S;

    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3588
#include <cstdio>
using namespace std;
int in[55];
int main() {
    int n, summ = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &in[i]);
    for (int i = 0; i < n ; i++)
        for (int j = i + 1; j < n; j++)
            summ += in[i] * in[j];
    printf("%d", summ);
    return 0;
}


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()
ab = [LIST() for _ in range(N-1)]
px = [LIST() for _ in range(Q)]

graph = defaultdict(list)

for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)

dic = defaultdict(int)

for p, x in px:
	dic[p-1] += x

ans = [0]*N

checked = [0]*N
checked[0] = 1

q = deque([])
q.append(0)

while q:
	n = q.popleft()
	ans[n] += dic[n]
	for node in graph[n]:
		if checked[node]:
			continue
		ans[node] += ans[n]
		checked[node] = 1
		q.append(node)

print(*ans)


Measured memory_bytes: 149272
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define ll long long
#define fir first
#define sz(a) int((a).size())

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n+x-1)/x*t<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int hap = 0;
  while(n >= 500) {
    hap += 1000;
    n -= 500;
  }
  while(n >= 5) {
    hap += 5;
    n -= 5;
  }
  cout << hap << endl;
}

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

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

char ch;
int Count[26] ={0};
int main()
{
  while(cin >>ch){
    if(isalpha(ch)){//アルファベットかどうか判定
      if(isupper(ch)){//大文字なら小文字に変換
	ch = tolower(ch);
      }
    Count[ch-'a']++;
    }
  }
  for(char i = 'a';i <='z'; i++){
    cout <<i<<" : "<<Count[i-'a']<<endl;;
  }
  return 0;
}

Measured memory_bytes: 1140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <random>
#include <iomanip>
#include <functional>
#include <list>
#include <unordered_map>
#include <sstream>
#include <istream>
#include <iterator>
#include <numeric>
#include <tuple>
#include <cassert>
using namespace std;

int cnt[100100];
int ans0[100100];
int ans1[100100];

string get_string(int x)
{
	string ans;
	for (int d = 100000; d >= 1; d /= 10)
	{
		ans += to_string(x / d);
		x -= (x / d) * d;
	}
	return ans;
}

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

	vector<tuple<int, int, int>> v;
	for (int city_id = 0; city_id < m; city_id++)
	{
		int p, y;
		cin >> p >> y;

		v.push_back({ p, y, city_id });
	}

	sort(v.begin(), v.end());
	for (auto vv : v)
	{
		int p = get<0>(vv);
		int city_id = get<2>(vv);

		cnt[p]++;
		ans0[city_id] = p;
		ans1[city_id] = cnt[p];
	}

	for (int city_id = 0; city_id < m; city_id++)
	{
		string s1 = get_string(ans0[city_id]);
		string s2 = get_string(ans1[city_id]);

		assert(s1.size() == 6 && s2.size() == 6);

		cout << s1 << s2;
		if (city_id + 1 != m)
			cout << '\n';
	}
}


Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 9; i >= 2;i--){
        if(n%i==0){
            n /= i;
            break;
        }
    }
    if(n<=9){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	int a,b,c;
	cin>>a>>b>>c;
	if((a+b+c)>=22){cout<<"bust";}
	else cout<<"win";
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 892
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,from,cost;};


signed main (){
    int n,m;
    cin>>n>>m;
    vector<int> a(m),b(m),c(m);
    rep(i,0,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--; b[i]--;
        c[i]*=-1LL;
    }
    vector<int> dist(n,1LL<<50);
    dist[0]=0;

    rep(i,0,2*n){
        rep(j,0,m){
            //cout<<dist[b[j]]<<" "<<dist[a[j]]+c[j]<<" "<<(dist[b[j]]>dist[a[j]]+c[j])<<endl;
            if(dist[a[j]]!=1LL<<50 && dist[b[j]]>dist[a[j]]+c[j]){
                dist[b[j]]=dist[a[j]]+c[j];
                if(i>=n-1 && b[j]==n-1){
                    cout<<"inf"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<-dist[n-1]<<endl;
    
}
/*
1-21-2
*/


Measured memory_bytes: 256
n,t = map(int,input().split())
lis = [list(map(int,input().split())) for x in range(n)]

lis = sorted(lis)
def TimeLimit(lis):
    for x in lis:
        if t >= x[1]:
            print(x[0])
            return
    else:
        print('TLE')
TimeLimit(lis)


Measured memory_bytes: 3060
import math

A, B, H, M = map(int, input().split())
theta_1 = (H + M / 60) / 12 * (2 * math.pi)
theta_2 = M / 60 * (2 * math.pi)
print(math.sqrt((A * math.cos(theta_1) - B * math.cos(theta_2)) ** 2 + (A * math.sin(theta_1) - B * math.sin(theta_2)) ** 2))

Measured memory_bytes: 9416
import sys
sample = sys.stdin.read().splitlines()
n, stones = int(sample[0]), list(map(int, sample[1].split()))
dp = [float('inf')] * n
jumps = (1, 2)
dp[0] = 0
for idx in range(len(dp)):
  for jump in jumps:
    if idx+jump < len(dp):
      dp[idx+jump] =  min(dp[idx]+abs(stones[idx+jump]-stones[idx]), dp[idx+jump])
print(dp[-1])
 


Measured memory_bytes: 14380
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

template<typename T1,typename T2>
std::ostream& operator<< (std::ostream& os,std::pair<T1,T2> pa){return os<<"["<<pa.first<<", "<<pa.second<<"]";}

template<typename T>
std::ostream& operator<< (std::ostream& os,std::vector<T> vec){
  os<<"{";
  for(int i=0;i<vec.size();i++)os<<vec[i]<<(i+1 == vec.size()?"":", ");
  os<<"}";
  return os;
}

long long extgcd(long long a,long long b,long long& x,long long& y){
  for(ll u=y=1,v=x=0;a;){
    ll q=b/a;
    std::swap(x-=q*u,u);
    std::swap(y-=q*v,v);
    std::swap(b-=q*a,a);
  }

  return b;
}

//非再帰累乗(mod付き)
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

const ll MOD = 998244353;
//const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,ans=0;
  std::cin>>n;

  std::vector<ll> a(n),w(1e6+10,0),cnt(1e6+10,0);
  rep(i,0,n){
    std::cin>>a[i];
    cnt[a[i]]=(cnt[a[i]]+a[i])%MOD;
    ans=(ans+MOD-a[i])%MOD;
  }

  rep(i,1,1e6+1){
    ll temp,_;
    extgcd(i,MOD,temp,_);
    w[i]=(w[i]+temp+3*MOD)%MOD;
    for(ll j=2;i*j<=1e6;j++){
      w[i*j]=(w[i*j]+MOD-w[i])%MOD;
    }
  }

  rep(i,1,1e6+1){
    ll temp=0;
    for(ll j=1;i*j<=1e6;j++){
      temp=(temp+cnt[i*j])%MOD;
    }
    ans=(ans+(((temp*temp)%MOD)*w[i])%MOD)%MOD;
  }

  ans=(ans*pow_mod(2,MOD-2,MOD))%MOD;

  std::cout<<ans;

  return 0;
}

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

long long n, total = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (long long i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            total += i;
        }
    }

    cout << total;
    cin >> n;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
using namespace std;

struct datum{
  datum(){};
  datum(bool type,double ratio,int charge){
    t=type;
    r=ratio;
    c=charge;
  }
  bool t;
  double r;
  int c;
};

int charge;
int years;
vector<datum> data;

void init(){
  charge=years=0;
  data.clear();
}

bool input(){
  int n=0;
  cin>>charge>>years;
  cin>>n;
  bool t;
  double r;
  int c;
  for(int i=0;i<n;i++){
    cin>>t>>r>>c;
    data.push_back(datum(t,r,c));
  }
  return true;
}



int cul_end(datum a,int c,int y){
  int res=c;
  if(a.t){
    for(int i=0;i<y;i++){
      int A,B;
      A=res;
      B=res*a.r;
      res=A+B-a.c;
    }
  }else{
    int add=0;
    for(int i=0;i<y;i++){
      int A,B;
      A=res;
      B=res*a.r;
      res=A-a.c;
      add+=B;
    }
    res+=add;
  }
  return res;
}


int solve(){
  int res=0;
  for(int i=0;i<data.size();i++){
    res=max(res,cul_end(data[i],charge,years));
  }
  return res;
}


int main(){
  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    init(),input();
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1240
a = 4*[0]
for i in range(3):
    n, k = list(map(int, input().split(" ")))
    a[n-1] += 1
    a[k-1] += 1

for i in range(4):
    if(a[i] == 3):
        print("NO")
        exit()

print("YES")

Measured memory_bytes: 3064
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int f(int d,int a,int b){
	if(!a)return !d;
	int w=abs(d)%10;
	if(d<0)w=(10-w)%10;
	int out=0;
	out+=(10-w-b)*f((d-a*w)/10,a/100,0);
	out+=(w-b)*f((d+a*(10-w))/10,a/100,0);
	return out;
}
signed main(){
	int a,out=0;
	cin>>a;
	if(a%9){
		cout<<0<<endl;
		return 0;
	}
	a/=9;
	int w=1;
	loop(i,2,19){
		w*=10;
		int t=f(a,w/9,1);
		out+=t;
		if(i%2)out+=t*9;
	}
	
	cout<<out<<endl;
}















Measured memory_bytes: 256
N = int(input())
S = input()
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
res = ""

for i in S:
  for j in range(len(alphabet)):
    if i == alphabet[j]:
      res += alphabet[j + N]
      break
print(res)

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

int hantei(int data){
  int i = 3;
  if(data == 2){
    return 1;
  }
  if(data < 2 || data % 2 == 0){
    return 0;
  }
  while(i <= sqrt(data)){
      if(data % i == 0){
        return 0;
      }
      i = i + 2;
  }
return 1;
}

int main(void){
   int data;
   int num,i;
   int sum=0;
   while(1){
      scanf("%d",&num);
      if(num >= 1 && num <= 10000){
        break;
      }
   }

  for(i = 0 ; i < num ; i++){
     while(1){
     scanf("%d",&data);
     if(data >= 2 && data <= 100000000){
       break;
     }
     }
     sum += hantei(data);
  }
   printf("%d\n",sum);
   return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i];
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[25][25],b[25],sum,top,c;

lli p[N];

int main()
{
	fast;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>p[i].fi>>p[i].se;
	sort(p+1,p+n+1);
	for(int i=1;i<=n && m;i++)
	{
		sum=sum+p[i].fi*min(p[i].se,m);
		m-=min(p[i].se,m);
	}
	cout<<sum;
}

Measured memory_bytes: 1792