akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
        int a,b,c,okikae;
        scanf("%d %d %d",&a,&b,&c);
        if(a<b){
                okikae=b;
                b=a;
                a=okikae;
        }
        if(a<c){
                okikae=c;
                c=a;
                a=okikae;
        }
        if(b<c){
                okikae=c;
                c=b;
                b=okikae;
        }

        printf("%d %d %d\n",c,b,a);
        return 0;
}


Measured memory_bytes: 2048
import sys
import math
from decimal import *
sys.setrecursionlimit(10**6)


def main(input, print):
    a, b, n = map(Decimal, input().split())
    l = 0
    r = n
    ans = math.floor(a*n/b) - a*math.floor(n/b)
    while r-l > 1:
        mid = (l+r)//2
        t = math.floor(a*mid/b) - a*math.floor(mid/b)
        if ans > t:
            r = mid
        else:
            ans = t
            l = mid

    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 88640
#include <stdio.h>

int main(){
    int N;
    scanf("%d", &N);

    char S[N];
    scanf("%s", &S);

    int a;
    scanf("%d", &a);

    for (int i=0; i<N; i++){
        if (S[i] != S[a-1]){
            printf("*");
        }else{
           printf("%c", S[i]); 
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n;
cin>>n;
ll ans = 1e18;
  for(ll i = 1; i*i<=n; i++){
      if(n%i!=0){
          continue;
      }
      else{
          ll j = n/i;
          ans = min(ans,i+j-2);
      }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
    boost;
    
    int h1,m1 , h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    
    int val =  (h2 - ( h1+1))*60 + m2 + (60-m1);
    
    int res = val  - k ;
    cout<<res<<endl;
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <iomanip>
#include"stdio.h"
#include <cstring>
#include<math.h>
#include<map>
#include<queue>
#include<stack>
#include"time.h"
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
double pi=3.1415926;

int main(){
	double r;cin>>r;
	printf("%.2f",r*2*pi);
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
long long dp[200001][5];
long long A[200000];

int main() {
    int L;
    cin >> L;
    for(int i=0; i<L; ++i) cin >> A[i];

    memset(dp, 0, sizeof dp);
    for(int i=0; i<L; ++i) {
        dp[i+1][0] = dp[i][0] + A[i];
        dp[i+1][1] = min(dp[i][0], dp[i][1]) + (A[i] == 0 ? 2 : A[i] % 2);
        dp[i+1][2] = min({dp[i][0], dp[i][1], dp[i][2]}) + (A[i] + 1) % 2;
        dp[i+1][3] = min({dp[i][0], dp[i][1], dp[i][2], dp[i][3]}) + (A[i] == 0 ? 2 : A[i] % 2);
        dp[i+1][4] = min({dp[i][0], dp[i][1], dp[i][2], dp[i][3], dp[i][4]}) + A[i];
    }
    cout << min({dp[L][0], dp[L][1], dp[L][2], dp[L][3], dp[L][4]}) << endl;;
}

Measured memory_bytes: 9600
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處
namespace Number {
    typedef long long int LL;
    // 求取 a, b 的最大公因數
    LL gcd(LL a, LL b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }
    // 求取 a, b 的最大公因數 gcd
    // 以及 x, y 使得 a*x + b*y = gcd
    LL gcd_extend(LL a, LL b, LL *x, LL *y) { 
        if (a == 0) { 
            *x = 0, *y = 1; 
            return b; 
        } 
    
        LL x1, y1; // To store results of recursive call 
        LL gcd = gcd_extend(b%a, a, &x1, &y1); 
    
        *x = y1 - (b/a) * x1; 
        *y = x1; 
    
        return gcd; 
    }
    // 求 a_inv 使得 (a * a_inv) % m = gcd(a, m)
    // 若 a, m 互質，即求 a 在 mod m 群的反元素 a_inv 
    LL mod_inv(LL a, LL m) { 
        LL x, y; 
        LL g = gcd_extend(a, m, &x, &y); 
        // 處理 x 爲負的情形 
        LL a_inv = (x%m + m) % m; 
        return a_inv;
    }
    // 求 x^n % m
    LL mod_pow(LL x, LL n, LL m) {
        if (n == 0) {
            return 1;
        } else if (n & 1) {
            LL half = mod_pow(x, n/2, m);
            return (half * half % m) * x % m;
        } else {
            LL half = mod_pow(x, n/2, m);
            return half * half % m;
        }
    }
    // 連乘
    LL mul(LL from, LL to, LL m) {
        LL ret = 1;
        for (LL i = from; i <= to; i++) {
            ret *= i;
            ret %= m;
        }
        return ret;
    }
    // 求 (C n 取 k) % m
    LL mod_comb(LL n, LL k, LL m) {
        LL mi = k < n-k ? k : n-k;
        LL up = mul(n - mi + 1, n, m);
        LL down = mul(1, mi, m);
        return (up * mod_inv(down, m)) % m;
    }
}
  

const LL M = (LL)1e9 + 7;

LL sum(LL x) {
    return (1 + x) * x / 2;
}

int main() {
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    
    LL total = 0;
    for (LL i = 0; i < n; i++) {
        for (LL j = 0; j < m; j++) {
            total += sum(n - 1 - i) * m % M;
            total += sum(i) * m % M;
            total += sum(m - 1 - j) * n % M;
            total += sum(j) * n % M;
            total = total % M;
        }
    }
    // printf("total = %lld\n", total);

    LL l = n * m;

    LL ans = Number::mod_comb(l - 2, k - 2, M) * total;
    ans %= M;
    ans *= Number::mod_inv(2, M);
    ans %= M;

    printf("%lld\n", ans);

}


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

int main() {
    int N;
    cin >> N;
    int l, r, cnt;
    for (int i = 0; i < N; i++){
        cin >> l >> r;
        cnt += r - l + 1;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

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

  int pay = 0;
  for (int i = 1; i <= n; ++i) {
    pay += 800;
    if (i % 15 == 0) pay -= 200;
  }

  cout << pay << endl;

  return 0;
}

Measured memory_bytes: 256
/*
  A - ABC/ARC
  <http://abc053.contest.atcoder.jp/tasks/abc053_a>
*/

int main(int argc, char const *argv[]) {

  int x;

  scanf("%d", &x);

  if( x < 1200 ){
    printf("ABC\n");
  }else{
    printf("ARC\n");
  }

  return 0;
}


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

long long x;

long long Count(long long n){
	if(n==-1)return 0;
	else{
		return n/x + 1;
	}

}

int main(){
	long long a,b;	cin>>a>>b>>x;
	long long ans=0;

	ans+=Count(b);
	ans-=Count(a-1);

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update> */

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
	
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll c=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
            c++;
    }
    ll c2=c;
    for(int i=0;i<c2;i++)
    {
        if(s[i]=='R')
            c--;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)

vector<int> adj[200010];
bool vis[200010];

int size1 = 0;
void DFS(int u)
{
    ::size1++;
    vis[u] = true;
    for (int i = 0; i < adj[u].size(); i++)
    {
        if (vis[adj[u][i]] == false)
        {
            //        size++;
            DFS(adj[u][i]);
        }
    }
}

int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int n, m, x, y;
    cin >> n >> m;
    //s(size, 1);

    s(vis, false);
    // int ans = 0;

    for (int i = 0; i < m; i++)
    {
        cin >> x >> y;
        // x--;
        //y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int ans = INT_MIN;
    for (int i = 1; i <= n; i++)
    {
        size1 = 0;
        if (vis[i] == false)
        {
            //size++;
            DFS(i);
        }
        ans = max(ans, size1);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 20980
def sol():
    n,a=map(int,input().split())
    x=[int(i) for i in input().split()]
    ans=chk=0
    d=[[0]*2501 for j in range(51)]
    d[0][0]=1
    for i in x:
        for j in range(2500,i-1,-1):
            for k in range(50,0,-1):
                d[k][j]+=d[k-1][j-i]
    for i in range(1,51):
        ans+=d[i][i*a]
    print(ans)

if __name__=="__main__":
    sol()


Measured memory_bytes: 42052
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3
7
10
---+/
/+---test
14
12
112
---+/

void main(string[] args) {
  const H = readln.chomp.to!long;
  const W = readln.chomp.to!long;
  const N = readln.chomp.to!long;

  ceil(N*1. / max(H, W)).to!int.writeln;
}


Measured memory_bytes: 256
#include <math.h>
#include <bits/stdc++.h>//一括で読み込み
typedef long long ll;
using namespace std;

#define MAX_V 200100//頂点数の最大値

int v;//頂点数
vector<int> G[MAX_V],revG[MAX_V],vs;
bool used[MAX_V];
int parents[MAX_V];

void AddEdge(int from,int to)
{
  G[from].push_back(to);
  revG[to].push_back(from);
}

void DFS(int v)
{
  used[v] = 1;
  for(int i = 0; i < G[v].size(); i++)
  {
    if(!used[G[v][i]]) DFS(G[v][i]);
  }
  vs.push_back(v);
}

void DFSback(int v,int k)
{
  used[v] = 1;
  parents[v] = k;
  for(int i = 0; i < revG[v].size(); i++)
  {
    if(!used[revG[v][i]]) DFSback(revG[v][i],k);
  }
}

void StronglyConnection()//強連結成分分解
{
  memset(used, 0, sizeof(used));
  vs.clear();
  for(int i = 0; i < v; i++)
  {
    if(!used[i]) DFS(i);
  }
  
  memset(used, 0, sizeof(used));
  int k = 0;
  for(int i = vs.size()-1; i >= 0; i--)
  {
    if(!used[vs[i]]) DFSback(vs[i], k++);
  }
}

int main()
{
  int e,s,t,q;
  cin >> v >> e;
  for(int i = 0; i < e; i++)
  {
    cin >> s >> t;
    AddEdge(s,t);//辺の追加
  }
  
  StronglyConnection();
  //強連結成分分解をO(V+E)で行う
  //強連結成分とは、互いに到達できる頂点同士のこと。
  
  cin >> q;
  for(int i = 0; i < q; i++)
  {
    cin >> s >> t;
    cout << (parents[s] == parents[t]) << endl;//強連結成分かどうか
  }
  return 0;
}


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

const int MAX_N = 3003;
double probability_heads[MAX_N][MAX_N], probability[MAX_N];

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

    for(int i = 1; i <= no_of_coins; i++)
        cin >> probability[i];

    memset(probability_heads, 0, sizeof(probability_heads));
    probability_heads[0][0] = 1;

    for(int i = 1; i <= no_of_coins; i++)
    {
        double head_event = probability[i], tail_event = 1 - probability[i];

        probability_heads[0][i] = tail_event*probability_heads[0][i - 1];

        for(int heads = 1; heads <= i; heads++)
        {
            probability_heads[heads][i] = head_event*probability_heads[heads - 1][i - 1] + tail_event*probability_heads[heads][i - 1];
        }
    }

    double answer = 0;
    for(int i = no_of_coins/2 + 1; i <= no_of_coins; i++)
        answer += probability_heads[i][no_of_coins];

    cout << setprecision(9) << answer;
    return 0;
}

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

int main() {
    int N, T; cin >> N >> T;
    vector<int> C(T + 1, 0);
    for(int i=0; i<N; ++i) {
        int l, r; cin >> l >> r;
        C[l] += 1;
        C[r] -= 1;
    }
    for(int i=0; i<T; ++i) C[i + 1] += C[i];
    cout << *max_element(begin(C), end(C)) << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int K,N;
  cin>>K>>N;
  vector<int> A(N);
  for(int i=0; i<N; i++){cin>>A[i];} 
  int maxdif=-1;
  for(int i=0; i<N-1; i++){
    maxdif=max(A[i+1]-A[i],maxdif);
  }
  maxdif=max(A[0]+K-A[N-1],maxdif);

  cout << K-maxdif << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, num = 30;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    int a, count = 0;
    cin >> a;
    
    while(a % 2 == 0){
      count++;
      a /= 2;
    }
    
    if(count < num)
      num = count;
    
  }
  
  cout << num << endl;
  
}

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

using namespace std;
const long long MOD=1e9+7;

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

long long modinv(long long a, long long mod){
  return modpow(a, mod-2, mod);
}

int main(){
  long long n, k, a[100009];
  long long fanc[100009], ifanc[100009];
  cin >> n >> k;
  for(int i=0;i<n;i++)cin >> a[i];
  fanc[0]=1, ifanc[0]=1;
  for(int i=1;i<=n;i++){
    fanc[i]=(i*fanc[i-1])%MOD;
    ifanc[i]=modinv(fanc[i], MOD);
  }
  sort(a, a+n);
  long long ans=0;
  for(int i=0;n-1-i>=k-1;i++){
    long long mul=1;
    mul = (mul*fanc[n-1-i])%MOD;
    mul = (mul*ifanc[k-1])%MOD;
    mul = (mul*ifanc[n-i-k])%MOD;
    mul = (a[n-1-i]*mul)%MOD;
    ans = (ans + mul + MOD)%MOD;
  }
  for(int i=0;n-1-i>=k-1;i++){
    long long mul=1;
    mul = (mul*fanc[n-1-i])%MOD;
    mul = (mul*ifanc[k-1])%MOD;
    mul = (mul*ifanc[n-i-k])%MOD;
    mul = (a[i]*mul)%MOD;
    ans = (ans - mul + MOD)%MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 5964
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
double len(double x1,double y1,double x2,double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
double theta(double a,double b,double c){
	return acos((a*a+b*b-c*c)/(2*a*b));
}
double r(double th1,double th2,double c){
	return c/(2+1/tan(th1/2)+1/tan(th2/2));
}
int main(){
	double x1,y1,x2,y2,x3,y3;
	scan(x1>>y1>>x2>>y2>>x3>>y3);
	double c1,c2,c3;
	c1=len(x2,y2,x3,y3);
	c2=len(x3,y3,x1,y1);
	c3=len(x1,y1,x2,y2);
	double t1,t2,t3;
	t1=theta(c2,c3,c1);
	t2=theta(c3,c1,c2);
	t3=theta(c1,c2,c3);
	double ans=max({r(t1,t2,c3),r(t2,t3,c1),r(t3,t1,c2)});
	prin(setprecision(13)<<ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll cnt=0;
	vector<ll>a;
	a.push_back(2);
	for(ll i=3;;i++){
		bool ch=true;
			for(auto itr=a.begin();itr!=a.end();itr++){
				if(i%*itr==0){
					ch=false;
				}
			}
			if(ch){
				if(i%5==1){
				cout << i<<" ";
				cnt++;
				}
				a.push_back(i);
			}
		if(cnt==n){
			return 0;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    int id0 = n/100;
    int id1 = n/10;
    id1 %= 10;
    int id2 = n%10;

    if(id0==id2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
#include <memory>
using namespace std;
typedef long long ll;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

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

    if (N < K) {
        cout << min(K - N, N) << endl;
    } else {
        N = N % K;
        cout << min(K - N, N) << endl;
    }

    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a-c) <= d) cout << "Yes\n";
  else if (abs(a-b) <= d && abs(b-c) <= d) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int bag,n,p,q;
    cin>>bag>>n;
    int sh[1011],xs[1011],dp[1011][10111];
    for(int i=1;i<=n;i++){
        cin>>p>>q;
        if(p<sh[0]&&q>xs[0])
                n--;
        else{
            sh[i]=p;
            xs[i]=q;
        }
    }


    for(int i=1;i<=n;i++){
        for(int j=1;j<=bag;j++){
            int c=j/sh[i];
            if(j%sh[i]!=0&&i==1)
                c++;
            if(dp[i][j]==0) {
                if(i==1)
                    dp[i][j] = c * xs[i];
                else{
                if(j<=sh[i])
                    dp[i][j]=min(dp[i-1][j],xs[i]);
                else
                    dp[i][j]=dp[i-1][j];
                }
            }
            if(i>1&&j>=sh[i]) {
                for (int k = c; k >=1; k/=2)
                    dp[i][j] = min(dp[i][j], dp[i][j - k * sh[i]] + k * xs[i]);
            }
        }
    }
        cout<<dp[n][bag];
    return 0;
}


Measured memory_bytes: 40064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    string s; cin >> s;
    int n = s.size(), p = 0, g = 0, ans = 0;
    rep(i, 0, n){
        if (s[i]=='p'){
            if (p < g) p++;
            else ans--, g++;
        }else {
            if (p < g) ans++, p++;
            else g++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll f(ll a){
	return (a*(a+1))/2;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ans+= i*f(n/i);
	}
	cout<<ans;
	
	
	return 0;
}

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

int main(){
    int a, b;
    int c, d;

    cin >> a >> b;
    cin >> c >> d;

    // Health, Strength
    while(true){
        c -= b;
        if (c <= 0) break;

        a -= d;
        if (a <= 0) break;
    }

    if (a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3604
// Problem : F - Pond Skater
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_f
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

struct state{
	int x, y, d, n, m;
	bool operator < (const state s) const{
		if(n == s.n){
			return m > s.m;
		}
		return n > s.n;
	}
};

int N, M, K;
priority_queue<state> pq;
vector<pair<int, int>> dist[4][1000005];
string mp[1000005];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0 , 0};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M >> K;
	int sx, sy, ex, ey;
	cin >> sx >> sy >> ex >> ey;
	sx--, sy--, ex--, ey--;
	for(int i = 0; i<N; i++){
		cin >> mp[i];
		for(int m = 0; m<4; m++){
			dist[m][i].resize(M, {INT_MAX, 0});
		}
	}
	for(int m = 0; m<4; m++){
		//cout << "here" << endl;
		//cout << dist[m][sx].size() << endl;
		dist[m][sx][sy] = make_pair(1, 0);
		pq.push({sx, sy, m, 1, 0});
	}
	while(pq.size()){
		auto s = pq.top();
		//cout << s.x << " " << s.y << endl;
		pq.pop();
		if(s.x+dx[s.d] >= 0 && s.x+dx[s.d] < N && s.y+dy[s.d] >= 0 && s.y + dy[s.d] < M && 
		mp[s.x+dx[s.d]][s.y+dy[s.d]] != '@'){
			pair<int, int> p = dist[s.d][s.x][s.y];
			p.second++;
			if(p.second == K+1){
				p.second = 1;
				p.first++;
			}
			if(dist[s.d][s.x+dx[s.d]][s.y+dy[s.d]] > p){
				dist[s.d][s.x+dx[s.d]][s.y+dy[s.d]] = p;
				pq.push({s.x+dx[s.d], s.y+dy[s.d], s.d, p.first, p.second});
			}
		}
		for(int m = 0; m<4; m++){
			pair<int, int> p = dist[s.d][s.x][s.y];
			p.first++;
			p.second = 0;
			if(dist[m][s.x][s.y] > p){
				dist[m][s.x][s.y] = p;
				pq.push({s.x, s.y, m, p.first, p.second});
			}
		}
	}
	int ans = INT_MAX;
	for(int m = 0; m<4; m++){
		ans = min(ans, dist[m][ex][ey].first);
	}
	cout << (ans == INT_MAX ? -1 : ans) << "\n";
}

Measured memory_bytes: 171208
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn gcd(a: usize, b: usize) -> usize {
    if a%b == 0 {
        return b;
    }
    else {
        return gcd(b, a%b);
    }
}

#[allow(unused_mut)]
fn main() {
    input!(
        n: usize,
        x: usize,
    );

    println!("{}", 3*(n - gcd(n,x)));
}


Measured memory_bytes: 4476
#include<iostream>
using namespace std;
int main(){
  int n,mi=10000000,ma=-10000000;
    long long sum=0;
  cin >> n;
  int i,b;
  for(i=0;i<n;i++){
    cin >> b;
    mi=min(mi,b);
    ma=max(ma,b);
    sum+=b;
  }
  cout << mi <<  " " << ma << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
 
int sort_ao(int n[]);
int sort_do(int n[]);
 
int main(void)
{
    int num;
    int num_p[4];
    int cnt;
    int l, s;
		int i;
		
    while (scanf("%d", &num) != EOF){
				if (num == 0000){
					break;
				}
				
        else if (num % 1111 == 0){
            printf("NA\n");
        }
				
        else {
            cnt = 0;
            
            while (num != 6174){
								num_p[0] = num / 1000;
		            num_p[1] = (num / 100) % 10;
		            num_p[2] = (num / 10) % 10;
		            num_p[3] = num % 10;
								
                l = sort_ao(num_p);
                s = sort_do(num_p);
                
                num = l - s;
                cnt++;
            }
            printf("%d\n", cnt);
        }
    }
     
    return (0);
}
 
 
int sort_ao(int n[])
{
    int i, j;
    int tmp;
    int ans;
     
    for (i = 0; i < 4; i++){
        for (j = 1; j < 4; j++){
            if (n[j - 1] < n[j]){
                tmp = n[j - 1];
                n[j - 1] = n[j];
                n[j] = tmp;
            }
        }
    }
    ans =(n[0] * 1000) + (n[1] * 100) + (n[2] * 10) + n[3];
		
    return (ans);
}
 
 
int sort_do(int n[])
{
    int i, j;
    int tmp;
    int ans;
     
    for (i = 0; i < 4; i++){
        for (j = 1; j < 4; j++){
            if (n[j - 1] > n[j]){
                tmp = n[j - 1];
                n[j - 1] = n[j];
                n[j] = tmp;
            }
        }
    }
    ans =(n[0] * 1000) + (n[1] * 100) + (n[2] * 10) + n[3];
		
    return (ans);
}

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

using namespace std;

typedef long long ll;

int main(){
 int N; cin >> N;
  vector<ll> A(N,0); 
 for(int i = 0; i < N; i++){ cin >> A[i];}
  
  sort(A.begin(),A.end());
  vector<ll> sum(N); sum[0] = A[0];
  
  
  
 for(int i = 0; i < N - 1; i++){
   sum[i+1] = sum[i] + A[i+1];}
  
  
 vector<bool> flag(N,false);
  
  for(int i = 0; i < N - 1; i++){
    if( sum[i] * 2 >= A[i+1]){ flag[i] = true;}}
  flag[N-1] = true;

  int itr = 0; 
  for(int i = N - 1; i >= 0; i--){
    if(!flag[i]){ itr = i + 1; break;}
  }
  
  cout << N - itr << endl;
  return 0;}
  


Measured memory_bytes: 1792
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

sosu = 10 ** 9 + 7
fac = [1 for i in range(N)]
finv = [1 for i in range(N)]
inv = [1 for i in range(N)]
for i in range(2, N):
    fac[i] = fac[i-1] * i % sosu
    inv[i] = sosu - inv[sosu%i] * (sosu // i) % sosu
    finv[i] = finv[i-1] * inv[i] % sosu
ans = 0

for i in range(N-K+1):
    ans += (((((A[-i-1] - A[i]) * fac[N-1-i]) % sosu ) * finv[K-1]) % sosu ) * finv[N-i-K] % sosu
    ans = ans % sosu
print(ans)


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

using namespace std;

const int N = 200010;

int n, m;
char s[N];
vector<int> adj[N];
int cnt[2][N];
int removed[N];

bool canRemove(int u) {
	return cnt[0][u] == 0 || cnt[1][u] == 0;
}

int main() {
	scanf("%d %d", &n, &m);
	scanf("%s", s + 1);
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		cnt[s[u] == 'A'][v]++;
		cnt[s[v] == 'A'][u]++;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	queue<int> q;
	for (int i = 1; i <= n; i++) {
		if (canRemove(i)) {
			q.push(i);
			removed[i] = 1;
		}
	}
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int v : adj[u]) {
			if (removed[v]) {
				continue;
			}
			cnt[s[u] == 'A'][v]--;
			if (canRemove(v)) {
				removed[v] = 1;
				q.push(v);
			}
		}
	}
	int id = -1;
	for (int i = 1; i <= n; i++) {
		if (!removed[i]) {
			id = i;
			break;
		}
	}
	puts(id == -1 ? "No" : "Yes");
	return 0;
}	

Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second
 
const int N = 1e5 + 10;
const int M = 1e5 + 10;
const int INF = 0x3f3f3f3f;
 
typedef long long ll;
typedef pair<int, int> PII;
 
priority_queue<PII> q[3][3];
int vis[N];

PII find(int i, int j)
{
	PII a;
	while(!q[i][j].empty()){
		a = q[i][j].top();
		if(vis[a.y] == i)
			break;
		q[i][j].pop();
	}
	return a;
}
 
struct pp{
	int a[3];
	
	void read()
	{
		scanf("%d %d %d", &a[0], &a[1], &a[2]);
	}
	
	void push(int i, int t)
	{
		int j = (i+1)%3;
		q[i][j].push(MP(a[j]-a[i], t));
		j = (i+2)%3;
		q[i][j].push(MP(a[j]-a[i], t));
		vis[t] = i;
	}
}A[N];

int main ()
{
	int x, y, z;
	scanf("%d %d %d", &x, &y, &z);
	int n = x + y + z;
	ll sum = 0;
	for(int i = 0; i < x; i++){
		A[i].read();
		A[i].push(0, i);
		sum += A[i].a[0];
	}
	for(int i = x; i < x + y; i++){
		A[i].read();
		A[i].push(1, i);
		sum += A[i].a[1];
	}
	for(int i = x + y; i < n; i++){
		A[i].read();
		A[i].push(2, i);
		sum += A[i].a[2];
	}
	
	bool f = 1;
	while(f){
		f = 0;
		for(int i = 0; i < 3; i++)
		for(int j = i+1; j < 3; j++){
			while(true){
				PII a = find(i, j), b = find(j, i);
				if(a.x + b.x <= 0) break;
				
				f = 1;
				sum += a.x;
				sum += b.x;
				
				q[i][j].pop(); q[j][i].pop();
				A[a.y].push(j, a.y); A[b.y].push(i, b.y);
			//	printf("n1 = %d n2 = %d\n", a.y, b.y);
			}
		}
		
		for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)if(i != j){
			int k = 3 - i - j;
			PII a = find(i, j), b = find(j, k), c = find(k, i);
			if(a.x + b.x + c.x <= 0) break;
			
			f = 1;
			sum += a.x; sum += b.x; sum += c.x;
			q[i][j].pop(); q[j][k].pop(); q[k][i].pop();
			A[a.y].push(j, a.y); A[b.y].push(k, b.y); A[c.y].push(i, c.y);
		}
	}
 
//	for(int i = 0; i < n; i++)
//		printf("%d ", vis[i]);
//	puts("");
	
	printf("%lld\n", sum);
	
	return 0;
}

Measured memory_bytes: 4892
#include <stdio.h>

int main(){
    
    int a, b, r, henkan;
    
    scanf("%d %d",&a,&b);
    
    if(a<b){
        henkan = a;
        a = b;
        b = henkan;
    }
    
    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    
    printf("%d\n",b);
    
    return 0;
}



Measured memory_bytes: 2104
import sys
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, d = na()
co = []
for i in range(n):
    co.append(na())

ct = 0
for i in range(n):
    for j in range(i+1,n):
        a = co[i]
        b = co[j]
        s = 0
        for k in range(d):
            s += (a[k] - b[k])*(a[k] - b[k])
        ss = int(math.sqrt(s))
        if ss * ss == s:
            ct += 1
print(ct)


Measured memory_bytes: 3064
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long S = sc.nextLong();
        sc.close();

        long x1,x2,x3,y1,y2,y3;

        x1 = 0; y1 = 0;
        x2 = (long)Math.pow(10, 9);
        y2 = 1;
        x3 = (x2 - (S%x2)) % x2;
        y3 = (S+x3) / x2;
        System.out.println(x1 + " " + y1 + " " + x2 + " " + y2 + 
                            " " + x3 + " " + y3);

    }
}

Measured memory_bytes: 21844
N,S = map(int, input().split())
As = list(map(int, input().split()))
i = 0
j = 0
sum = 0
m_l = float('inf')

while True:
	while j < N and sum < S:
		sum += As[j]
		j += 1
	
	if sum < S:
		break
	m_l = min(j-i, m_l)
	sum -= As[i]
	i += 1
	
"""
while j < N:
	sum += As[j]
	j += 1
	while i < j and sum :
		sum -= As[i]
		i += 1
		if sum >= S:
			continue
		m_l = min(j-i+1, m_l)
		break
"""
print(m_l if m_l != float('inf') else 0)


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

using namespace std;

int main(){
  int N;
  cin >> N;
  int ar[100000];
  for(int i = 0; i < N; i++)cin >> ar[i];
  sort(ar, ar + N);
  if(ar[N - 1] == 0){
  	cout << "Yes" << endl;
    return 0;
  }
  if(N % 3 != 0){
  	cout << "No" << endl;
    return 0;
  }
  if((ar[N / 3 - 1] == 0 && ar[N / 3] == ar[N - 1]) || 
    (ar[N / 3 - 1] == ar[0] && ar[N / 3 * 2 - 1] == ar[N / 3] && ar[N - 1] == ar[N / 3 * 2]
    && ((ar[0] ^ ar[N / 3]) ^ ar[N * 2 / 3]) == 0)){
  	cout << "Yes" << endl;
   	return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, x;
	cin >> n;
	x = 1;
	while (x * 2 <= n) x *= 2;
	cout << x << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define ll long long 

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  vector<bool> view(N, true);
  vector<vector<ll>> G(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  for (int i = 0 ; i < M; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  for (int i = 0; i < N; i++) {
    for (auto x : G[i]){
      if (H[i] <= H[x]) view[i] = false;
    }
  }
  
  int count = 0; 
  
  for (int i = 0; i < N; ++i) {
    if (view[i]) count++;
  }
  
  cout << count << endl;
}
  
  
  

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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

vector<long long> toDivisor(ll num)
{
	vector<long long> d;
	for (ll i = 1; i*i <= num; ++i)
	{
		if (i*i == num)
		{
			d.push_back(i);
		}
		else if (num % i == 0)
		{
			d.push_back(i);
			d.push_back(num/i);
		}
	}
	return d;
}

vector<pair<long long , long long>> toDivisorP(ll num)
{
	vector<pair<long long, long long>> d;
	for (ll i = 1; i * i <= num; ++i)
	{
		if (i*i == num) d.push_back(pair<ll, ll>(i, i));
		else if (num % i == 0)
		{
			d.push_back(pair<ll, ll>(i, num/i));
		}
	}
	return d;
}


int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	vector<bool> seen(1000010, false);
	ll N; cin >> N;
	vector<ll> V(N);
	REP(i, N)
		cin >> V[i];
	sort(ALL(V));
	ll res{0};
	vector<ll> tmp;
	for (ll i = 0; i < N-1; ++i)
	{
		if (V[i] == V[i+1])
			seen[V[i]] = true;
			
	}

	REP(i, N)
	{
		ll t = V[i];

		vector<ll> di = toDivisor(t);
		ll ok{true};
		for (auto &d : di)
		{
			if (seen[d])
				ok = false;
		}
		seen[t] = true;
		if (ok)
		{
			++res;
		}
		
	}

	std::cout << res << std::endl;
	return 0;
}


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

long long N;
long long X[105];

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++) {
		cin >> X[i];
	}

	long long ans = LONG_MAX;

	for(long long i = 0; i < 105; i++) {
		long long tmp = 0;
		for(long long j = 0; j < N; j++) {
			tmp += (i - X[j]) * (i - X[j]);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3592
import sys
input = sys.stdin.readline
N = int(input())
table = [0] * 26
mx = 0
a = ord("a")
for c in input()[: -1]:
  table[ord(c) - a] += 1
#print(table)
for _ in range(N - 1):
  s = list(input())[: -1]
  for t in range(26):
    table[t] = min(table[t], s.count(chr(t + a)))

res = []
for c in range(26):
  if table[c]:
    res += [chr(a + c)] * table[c]
print("".join(res))

Measured memory_bytes: 41072
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;
using System.Drawing;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();

            int l = 0;
            int r = S.Length - 1;
            int ans = 0;

            while (true) 
            {

                while (S[l] == 'R' && l < S.Length - 1) 
                {
                    l++;
                }
                while (S[r] == 'W' && r > 0)
                {
                    r--;
                }
                if (l < r)
                {
                    r--;
                    l++;
                    ans++;
                }
                else 
                {
                    break;
                }
            }

            Console.WriteLine(ans);

        }

    }
}


Measured memory_bytes: 28228
import java.util.Scanner;

class Main{
        public static void main(String[] args){
                Scanner scn=new Scanner(System.in);
                int a=scn.nextInt();
                int b=scn.nextInt();
                String str=scn.next();
                char c;
                for(int i=0;i<a;i++){
                        c=str.charAt(i);
                        if('0'>c || c>'9'){
                                System.out.println("No");
                                return;
                        }
                }

                if(str.charAt(a)!='-'){
                        System.out.println("No");
                        return;
                }
                for(int i=0;i<b;i++){
                        c=str.charAt(a+1+i);
                        if('0'>c || c>'9'){
                                System.out.println("No");
                                return;
                        }
                }
                System.out.println("Yes");
        }
}

Measured memory_bytes: 25172
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

u64 gen753(u64 i) {
  if(i < 27) return 0;
  
  u64 ret = 0;
  u64  a[4] = {0, 3, 5, 7};
  bool b[4] = {false};
  
  for(u64 j = 1; i > 0; i >>= 2, j *= 10) {
    u64 digit = a[i & 3];
    if(digit == 0) return 0;
    b[i & 3] = true;
    ret += digit * j;
  }
  
  if(b[1] && b[2] && b[3]) {
    return ret;
  } else {
    return 0;
  }
}
        

int main(int argc, const char* argv[]) {
  u64 n;
  cin >> n;
  
  u64 ret = 0;
  repd(i, 0, n + 1) {
    u64 a = gen753(i);
    if(a > n) {
      break;
    } else if(a > 0) {
      ++ret;
    }
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = list(input())
count = 0
b_rank = 1
for i in range(len(S)) :
    if S[i] == "a" :
        if count < A + B :
            print("Yes")
            count += 1
        else :
            print("No")
    if S[i] == "b" :
        if count < A + B and b_rank <= B :
            print("Yes")
            count += 1
            b_rank += 1
        else :
            print("No")
    if S[i] == "c" :
        print("No")


Measured memory_bytes: 9816
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    a = list(map(int , input().split()))
    ans = [0]*n
    for i, num in enumerate(a):
        ans[num-1] = i+1
    print(" ".join(map(str,ans)))

if __name__=="__main__":
    main()


Measured memory_bytes: 25276
import scala.collection.mutable._
import io.StdIn.readInt
import io.StdIn.readLine

object Main extends App {
  val out = new java.io.PrintWriter(System.out)

  def calculate(q:Array[Int],d:Array[Array[Int]]):Int = {
    val ts = q(0)
    val te = q(1)
    val st = q(2)

    val a = d.filter(_(2) == st)
    val map = new HashMap[Int,Array[Int]]
    val log = new ListBuffer[Tuple2[Int,Int]]
    a.foreach(l => {
      if(l(3) == 1) map.put(l(1),l)
      else {
        val e = map(l(1))
        log += {( e(0), l(0) )}
        }
    })
    // println(log.mkString)

    val time = Array.ofDim[Boolean](721)
    log.foreach(t => {
      val s = math.max(ts, t._1) -540
      val e = math.min(te, t._2) -540
      (s until e).foreach(time(_) = true)
    })
    time.count(_ == true)
  }

  def solve(s:String):Unit = {
    // val Array(n, m) = s.split(" ").map(_.toInt)
    val r = readInt
    val d = Iterator.continually(readLine)
      .take(r)
      .map(_.split(" ").map(_.toInt))
      .toArray
    val q = readInt
    Iterator.continually(readLine)
      .take(q)
      .map(_.split(" ").map(_.toInt))
      .foreach(qd => out.println(calculate(qd,d)))
  }

  Iterator.continually(readLine)
    .takeWhile(_ != "0 0")
    .foreach(solve(_))
  
  out.flush
}


Measured memory_bytes: 57364
#include <iostream>
using namespace std;
int main()
{
	long long a,b;cin>>a>>b;
	if(a>0&&b>0) cout<<"Positive";
	if((a<0&&b>0)||a==0||b==0) cout<<"Zero";
	if(a<0&&b<0) 
	{
		if((b-a+1)%2==0) cout<<"Positive";
		else cout<<"Negative";
	}
	return 0;
}

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

using Graph = vector<vector<int>>;

Graph G;

//vは頂点
void dfs(int v, vector<bool> &seen, int &res){
    bool end = true; //すべての頂点を探索済みか否かを表す
    
    for (int i = 0; i < seen.size(); i++){
        if (!seen[i] && i != v){
            end = false; 
            //頂点v以外の頂点を一通りすべて探索済みか？
            //探索していない点が存在すればfalse
        }
    }
    
    if (end){
        //すべての頂点を探索済み -> 答えをインクリメント
        res++;
        return;
    }
    
    seen[v] = true; //頂点vを訪問済みにする
    
    //vの隣接する点を調べる
    for (auto nv: G[v]){
        
        //v隣接点の中で訪問済み -> 調べない
        if (seen[nv]) continue;
        
        dfs(nv, seen, res);
    }
    
    //vを未訪問の状態に戻しておく
    seen[v] = false;
    
}

int main(){
    int n, m;
    cin >> n >> m;
    
    G.assign(n, vector<int>()); //入力
    
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        
        //0-indexにもどす
        a--;
        b--;
        
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<bool> seen(n, false); //頂点を検知済みか？？
    
    int numberOfHamiltonPath = 0;
    
    //dfs(parent, seen, path_number)
    dfs(0, seen, numberOfHamiltonPath);
    
    cout << numberOfHamiltonPath << endl;
}

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

using mint = modint998244353;

mint ten[200002],one[200002];

// data の型
struct S{
	lint len;	// 区間の幅
	mint val;	// 値
};

// lazy の型
using F = int;

// ボトムアップの計算式
S op(S l, S r){
	return S{l.len + r.len, l.val * ten[r.len] + r.val};
}

// op(a, e) = op(e, a) = a となる e
S e(){
	return S{0, 0};
}

// lazy f を下の data s に対して伝搬させる計算式
S mapping(F f, S s){
	if(f == 0) return s;
	// 新しい数値である lazy f に対して MOD を求める
	return S{s.len, one[s.len] * f};
}

// lazy l と下の lazy r をまとめる計算式
F composition(F l, F r){
	// 上位の lazy l が空の場合、下の lazy r を伝搬させる
	return ((l == 0) ? r : l);
}

// mapping(id, a) = a となる id
F id(){
	return 0;
}

int main() {
	int N, Q;
	cin >> N >> Q;
	int a=0, b=0, c=0, x, y, z;

	// 各桁が1の場合の余りを準備
	one[0] = 0, ten[0] = 1;
	rep(i, N+1) {
		// mapping(lazy) の計算では 111...11 * f の MOD を求めたい
		one[i+1] = one[i]*10+1;
		// op(data) の計算では 1 * 10^len * f の MOD を求めたい
		ten[i+1] = ten[i]*10;
	}

	// lazy_segtree の用意
	S s = {1, 1};
	vector<S> v(N, s);
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);

	// クエリを O(QlogN) で処理
	rep(i, Q) {
		cin >> x >> y >> z;
		seg.apply(x-1, y, z);
		cout << seg.all_prod().val.val() << endl;
	}
}


Measured memory_bytes: 17268
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef  long long ll;
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int main() {
    long long N, M; cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i], --A[i], --B[i];
    }
        
    UnionFind uf(N);
    long long cur = N * (N-1) / 2;
    vector<long long> res;
    for (int i = 0; i < M; ++i) {
        res.push_back(cur);
            
        int a = A[M-1-i], b = B[M-1-i];
        if (uf.issame(a, b)) continue;
        
        long long sa = uf.size(a), sb = uf.size(b);
        cur -= sa * sb;
        uf.merge(a, b);
    }
        
    reverse(res.begin(), res.end());
    for (int i = 0; i < res.size(); ++i) cout << res[i] <<endl;
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int a[20005],ans,bn,b[10000],n,k,q,cn,c[10000];
int main(){
	scanf("%d%d%d",&n,&k,&q);ans=2000000000;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int j=1;j<=n;j++){
		int maxv=a[j],qq=q;bn=cn=0;
		for (int i=1;i<=n;i++) if (a[i]<a[j]){
			sort(b+1,b+bn+1);
			for (int ii=1;ii<=bn-k+1;ii++) c[++cn]=b[ii];
//			maxv=max(maxv,b[min(qq,bn-k+1)]);
//			qq-=bn-k+1;
//			qq=max(qq,0);
			bn=0;
		}
		else{
			b[++bn]=a[i];
		}
		sort(b+1,b+bn+1);
		for (int ii=1;ii<=bn-k+1;ii++) c[++cn]=b[ii];
		bn=0;
		
		sort(c+1,c+cn+1);
		if (q<=cn) ans=min(ans,c[q]-a[j]);
	}
	printf("%d",ans);
}

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

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

  int x =0 ;
  vector<int> value_x;
  string ID = "ID";

  for(int i =0 ; i<N ; i++)
  {
    if(S[i] == ID[0])
    {
      x++;
    }
    else
    {
      x--;
    }
    value_x.push_back(x);
  }
  sort(value_x.begin(),value_x.end());
  if(value_x.at(N-1)<=0)
  {
    cout<<0;
  }
  else
  {
    cout << value_x.at(N-1);
  }
}


Measured memory_bytes: 256