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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

        int n,x,z;
        cin>>n>>x>>z;

        cout<<(int)(ceil(1.0*n/x)*z);
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

const char dir[] = {'N', 'S', 'W','E'};

void solve(string S){
	bool flag[4] = {};

	REP(i,S.size()){
		REP(j,4){
			if(dir[j] == S[i])flag[j] = true;
		}
	}

	if((flag[0] && !flag[1]) || (!flag[0] && flag[1])){
		cout << "No" << endl;
	}else if((flag[2] && !flag[3]) || (!flag[2] && flag[3])){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
}



int main(){	
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	solve(S);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
const long long Mod = 1000000007;
long long Cow(long long n, long long m, long long Mod){
  long long ans = 1;
  while(m > 0){
    if(m & 1){
      ans = ans * n % Mod;
    }
    n = n * n % Mod;
    m >>= 1;
  }
  return ans;
}
int main(){
  long long n, m;
  cin >> n >> m;
  cout << Cow(n,m,Mod) << endl;
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int a,b,c,d,e,f,cap;cin>>a>>b>>c>>d>>e>>f;
    double water,sugar,am=1,as=-1;//初期値as=0だと0%でバグる
    double ans=0;

    cap=0;water=0;sugar=0;

    for(int i=0;cap+i*a*100<f+1;i++)
    {
        cap+=i*a*100;
        water+=100*a*i;

        for(int j=0;cap+j*b*100<f+1;j++)
        {
            cap+=j*b*100;
            water+=100*b*j;

            double capp=cap,suga=sugar;

            for(int k=0;cap+c*k<f+1;k++)
            {           
                cap+=c*k;
                sugar+=c*k;
                
                while(cap+d<f+1 && e*water>=100*(sugar+d))
                {
                    cap+=d;
                    sugar+=d;
                    
                }

                if(as*(sugar+water)<sugar*am && e*water>=100*(sugar)){
                    am=cap;
                    as=sugar;
                }
                
                cap=capp;
                sugar=suga;
            }
            cap-=j*b*100;
            water-=100*b*j;
        }
        cap-=i*a*100;
        water-=100*a*i;
    }
    cout<<(int)am<<" "<<(int)as<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int bubbleSort(int *,int);

int main(void){
  int A[N],num,cnt;
  int i;

  scanf(" %d",&num);
  
  for(i = 0; i < num; i++){
    scanf(" %d",&A[i]);
  }

  cnt = bubbleSort(A,num);

  for(i = 0; i < num-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[num-1]);

  printf("%d\n",cnt);
  
  return 0;
}

int bubbleSort(int *A, int num){
  int i,j;
  int flag=1,tmp,cnt=0;

  while(flag){
    flag = 0;
    for(i = num -1; i > 0; i--){
      if(A[i] < A[i-1]){
	tmp = A[i-1];
	A[i-1] = A[i];
	A[i] = tmp;
	flag = 1;
	cnt++;
      }
    }
  }

  return cnt;
}
  



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main() {
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < s.size()+5; i++) {
        s.insert(s.begin(), s[s.size() - 1]);
        s.pop_back();
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;



    return 0;
}


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

#define MAX_VALUE 1000000000000
#define MAX_NUM_PRIME 40

void prime_factor(long x, long *xp, int *n) {
    int i = 0;
    long upper;

    upper = (long) sqrt(x);

    xp[i++] = 1L;

    while (x % 2 == 0) {
        xp[i++] = 2;
        x /= 2;
    }

    for (long y = 3; x > 1 &&  y < upper; y += 2) {
        while (x % y == 0) {
            xp[i++] = y;
            x /= y;
        }
    }

    if (x > 1) {
        xp[i++] = x;
    }

    xp[i] = 0;
    *n = i;
}

void print_xp(long *xp) {
    int i = 0;
    while (xp[i] != 0) {
        printf("%ld ", xp[i++]);
    }
    printf("\n");
}

int main(void) {
    long a, b;
    int an, bn;
    long ap[MAX_NUM_PRIME + 1], bp[MAX_NUM_PRIME + 1];

    scanf("%ld %ld", &a, &b);
    
    prime_factor(a, ap, &an);
    prime_factor(b, bp, &bn);
    // print_xp(ap);
    // print_xp(bp);

    int ai = 0, bi = 0, count = 0, x;
    while (ai < an && bi < bn) {
        if (ap[ai] == bp[bi]) {
            count++;
            x = ap[ai];
            while (ap[++ai] == x);
            while (bp[++bi] == x);
        } else if (ap[ai] < bp[bi]) {
            ai++;
        } else {
            bi++;
        }
    }

    printf("%d\n", count);

    return 0;
}


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define sort(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	char x ,y;
	cin>>x>>y;
	if(x<y){
		cout<<"<"<<endl;
	  }
	 else if(x==y){
		  cout<<"="<<endl;
		}
	  else{
		  cout<<">"<<endl;
		}
}

Measured memory_bytes: 256
// Problem : B - Frog 2
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define fs second
#define lb lower_bound
#define ub upper_bound

#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector< vi >
#define vpii vector< pii >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl


#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define rl(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
void printv(vector<int>  v){ for(int i=0;i<v.size();i++) cout<<v[i]<<' '; cout<<endl;   }
int bem(int m , int n, int mod) { int res=1; while(n){
	     			        if(n%2!=0) { res*=m; res%=mod; }
	    			        m*=m;   m%=mod;   n/=2;
			                          }
				return res;	}
int be(int a, int b) { int res=1; 	while(b){
				if(b%2!=0) res*=a;
				a*=a; b/=2;
				}
			return res;	}
void sieve(int n, vb &prime){
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
              for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             	  }
    	 }
	}

void solve()
  {
int n, k; cin>>n>>k;
vi v(n); f(i, 0, n-1) cin>>v[i];
vi dp(n);
dp[0]=0; 
f(i, 1, n-1){
  int z=max((int)0, i-k);
  dp[i]=dp[z]+abs(v[i]-v[z]);
  f(j, z+1, i-1) dp[i]=min(dp[i],dp[j]+abs(v[i]-v[j]));
  }
  cout<<dp[n-1]<<endl;
  
  }

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








Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#define MAX 100

int main(){
    int n;
    int t_point=0, h_point=0;
    char tarou[MAX], hanako[MAX];

    scanf("%d", &n);
    for(;n>0;n--){
        scanf(" %s %s", tarou, hanako);
        if(strcmp(tarou, hanako)>0){
            t_point+=3;
        }else if(strcmp(tarou, hanako)==0){
            t_point+=1;
            h_point+=1;
        }else if(strcmp(tarou, hanako)<0){
            h_point+=3;
        }
    }
    printf("%d %d\n", t_point, h_point);

    return 0;
} 

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

int main(){
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;
  
  if(x>=r && x<=w-r && y>=r && y<=h-r) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

int main() {
    string n;
    cin >> n;
    for (int i=0; i<3; i++) {
        if (n.at(i)=='1') n.at(i)='9';
        else n.at(i)='1';
    }
    cout << n << "\n";
}

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

bool is753(long n)
{
    int b = 0;
    while (n != 0) {
        b |= 1 << (n % 10);
        if ((b & 0xA8) == 0xA8) return true; // 10101000
        n /= 10;
    }
    return false;
}

long solve(long n, long a)
{
    long tmp;
    long cnt = 0;

    tmp = a * 10 + 3;
    if (tmp <= n) {
        cnt += solve(n, tmp);
        if (is753(tmp)) {
            cnt++;
        }
    }
    tmp = a * 10 + 5;
    if (tmp <= n) {
        cnt += solve(n, tmp);
        if (is753(tmp)) {
            cnt++;
        }
    }
    tmp = a * 10 + 7;
    if (tmp <= n) {
        cnt += solve(n, tmp);
        if (is753(tmp)) {
            cnt++;
        }
    }

    return cnt;
}

int main()
{
    long n;
    cin >> n;
    long ans = solve(n, 0);
    cout << ans << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

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

string S, T;
map<int, int> ST;
map<int, int> TS;

signed main(){
	cin >> S;
	cin >> T;
	
	int s, t;
	REP(i, S.size()) {
		s = S[i] - 'a' + 1;
		t = T[i] - 'a' + 1;
		if((ST[s] != 0 && ST[s] != t)
					|| (TS[t] != 0 && TS[t] != s)) {

//		    cout << S[i] << " ST[" << s << "] = " << ST[s] << " != " << t << endl;
//		    cout << T[i] << " TS[" << t << "] = " << TS[t] << " != " << s << endl;

			cout << "No" << endl;
			return 0;
		} else {
			ST[s] = t;
			TS[t] = s;
//		    cout << "set  " << S[i] << "  ST[" << s << "] = " << t << "]" << endl;
//		    cout << "set  " << T[i] << "  TS[" << t << "] = " << s << "]" << endl;
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = a[n - 1];
    for(int c = 1; c < n; c++) {
        ll s1 = 0, s2 = a[n - 1];
        for(int k = 1; k * c < n - 1; k++) {
            s1 += a[k * c];
            ll t = n - 1 - k * c;
            s2 += a[t];
            if(t % c == 0 && k * c >= t) {
                break;
            }
            if(c < t) {
                chmax(ans, s1 + s2);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
K=int(input())

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 3, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[K-1])

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String S = s.nextLine();
    int count = 0,ans = 0;

    for(int i = 0; i < S.length(); i++){
      if(S.charAt(i) == 'A' || S.charAt(i) == 'C' || S.charAt(i) == 'G' || S.charAt(i) == 'T'){
        count++;
        if(ans < count){
          ans = count;
        }
      }
      else{
        count = 0;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
while (m, f, r = gets.chomp.split.map(&:to_i)) != [-1,-1,-1]
  if m == -1 || f == -1
    puts "F"
  elsif m+f >= 80
    puts "A"
  elsif m+f >= 65
    puts "B"
  elsif m+f >= 50
    puts "C"
  elsif m+f >= 30
    if r >= 50
      puts "C"
    else
      puts "D"
    end
  else
    puts "F"
  end
end


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> vec(H);

  for(int i=0; i<H; i++){
    cin >> vec.at(i);
  }

  string tag = "";

  for(int i=0; i<W+2; i++){
    tag.push_back('#');
  }

  for(int i=0; i<H; i++){
    if(i==0){
      cout << tag << endl;
    }
    cout << "#" << vec.at(i) << "#" << endl;
  }

  cout << tag << endl;

}


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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

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



int main()
{
    //freopen("input.txt", "r", stdin);


    cout.tie(0);
    cout.precision(20);

    double L;
    cin >> L;
    L /= 3.0;
    cout << L * L * L << '\n';

}


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

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double s = (h*2*M_PI)/12.0 + (m*2*M_PI)/(60*12.0);
    double t = 2*m*M_PI/60.0;
    double c = abs(s-t);
    if (c > M_PI) c = 2*M_PI - c;


    double x = a*a + b*b - 2*a*b*cos(c);
    x = sqrt(x);

    printf("%.10f\n", x);
    return 0;
}

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

const int N = 100005;

using namespace std;

string s;
int n, l[N], r[N], x[N], root[N], summ[N], sz[N];

int Root(int x)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x]);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    if (s.size() == 1)
    {
        cout << "YES";
        return 0;
    }
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i] >> r[i];
        l[i]--, r[i]--;
    }
    if (s.size() % 2 == 1)
    {
        int pos = s.size() / 2;
        for (int i = 0; i < n; i++)
        {
            if (l[i] == pos && r[i] == pos)
            {
                n--;
                swap(l[i], l[n]);
                swap(r[i], r[n]);
                i--;
                continue;
            }
            if (l[i] > pos) l[i]--;
            if (r[i] >= pos) r[i]--;
        }
        string t = "";
        for (int i = 0; i < s.size(); i++) if (i != pos) t += s[i];
        s = t;
    }
    int len = s.size() / 2;
    for (int i = 0; i < n; i++)
    {
        if (l[i] < len && r[i] >= len)
        {
            int p1 = len - l[i], p2 = r[i] - len + 1;
            if (p1 == p2) l[i] = -1, r[i] = -1;
            if (p1 < p2)
            {
                l[i] += 2 * p1;
            }
            if (p1 > p2)
            {
                r[i] -= 2 * p2;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (l[i] >= len)
        {
            int rr = s.size() - 1 - l[i];
            int ll = s.size() - 1 - r[i];
            l[i] = ll, r[i] = rr;
        }
    }
    for (int i = 0; i < len; i++)
    {
        x[i + 1] = (s[s.size() - 1 - i] + 26 - s[i]) % 26;
    }
    for (int i = len + 1; i > 0; i--)
    {
        x[i] = (x[i] - x[i - 1] + 26) % 26;
    }
    for (int i = 0; i < n; i++)
    {
        l[i]++, r[i]++, r[i]++;
    }
    iota(root, root + len + 2, 0);
    fill(sz, sz + len + 2, 1);
    for (int i = 0; i < n; i++)
    {
        int a = Root(l[i]), b = Root(r[i]);
        if (a == b) continue;
        if (sz[a] < sz[b])
        {
            sz[b] += sz[a];
            root[a] = b;
        }
        else
        {
            sz[a] += sz[b];
            root[b] = a;
        }
    }
    for (int i = 1; i < len + 2; i++)
    {
        int j = i;
        while (j != root[j]) j = root[j];
        summ[j] += x[i];
    }
    int t = -1;
    for (int i = 0; i < len + 2; i++)
    {
        if (summ[i] % 26 != 0)
        {
            if (t == -1) t = i;
            else cout << "NO", exit(0);
        }
    }
    cout << "YES";
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int D, N;
	long long int ans;
	cin >> D >> N;
	if (N < 100)
	{
		ans = pow(100, D) * N;
		//cout << pow(100, D) * N << endl;
	}
	else
	{
		ans = pow(100, D) * (N + 1);
		//cout << pow(100, D) * (N + 1) << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n), b(n);
  cin>>a>>b;
  int ans = 0;
  rep(k,30) {
    int now = 0;
    rep(i,n) now ^= a[i]>>k&1;
    rep(i,n) now ^= b[i]>>k&1;
    now &= n&1;
    int j = 0, x = (1<<k)-1;
    vi na(n), nb(n);
    rep(i,n) na[i] = a[i]&x;
    rep(i,n) nb[i] = b[i]&x;
    sort(rng(na));
    sort(rng(nb));
    drep(i,n) {
      while (j < n && na[i]+nb[j] <= x) ++j;
      now ^= (n-j)&1;
    }
    ans |= now<<k;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 3432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

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

int main() {
	int n, ans = 0;
	double d;
	cin >> n >> d;
	
	FOR(i, n) {
		ll a, b;
		cin >> a >> b;
		if(sqrt(a*a + b*b) <= d) ans++;
	}
	
	cout << ans << endl;	
	
	return 0;
}


Measured memory_bytes: 3704
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
    	Scanner s = new Scanner(System.in);
    	int n = s.nextInt(), m = s.nextInt();
    	if (n == 1 || m == 1) {
    		System.out.println(1);
    	} else {
    		System.out.println((long)Math.ceil(n*1.*m/2));
    	}
    	}
    }


Measured memory_bytes: 22996
#include<algorithm>
#include<cstdio>
#define MaxN 200500
using namespace std;
int read(){
  int X=0;char ch=0;
  while(ch<48||ch>57)ch=getchar();
  while(ch>=48&&ch<=57)X=X*10+(ch^48),ch=getchar();
  return X;
}
struct Node{
  int x,tg;
  void ladd(int c)
  {tg+=c;x+=c;}
}a[MaxN<<2];
int wfl,wfr,m;
inline void up(int u)
{a[u].x=max(a[u<<1].x,a[u<<1|1].x);}
inline void ladd(int u){
  if (a[u].tg){
    a[u<<1].ladd(a[u].tg);
    a[u<<1|1].ladd(a[u].tg);
    a[u].tg=0;
  }
}
void build(int l=0,int r=m+1,int u=1)
{
  if (l==r){
    a[u].x=-max(min(m,m-l+1),0);
    return ;
  }int mid=(l+r)>>1;
  build(l,mid,u<<1);
  build(mid+1,r,u<<1|1);
  up(u);
}
void add(int l=0,int r=m+1,int u=1)
{
  if (wfl<=l&&r<=wfr){
    a[u].ladd(1);
    return ;
  }ladd(u);
  int mid=(l+r)>>1;
  if (wfl<=mid)add(l,mid,u<<1);
  if (wfr>mid)add(mid+1,r,u<<1|1);
  up(u);
}
int qry(int l=0,int r=m+1,int u=1)
{
  if (wfl<=l&&r<=wfr)return a[u].x;
  ladd(u);
  int mid=(l+r)>>1,ret=(-1<<30);
  if (wfl<=mid)ret=qry(l,mid,u<<1);
  if (wfr>mid)ret=max(ret,qry(mid+1,r,u<<1|1));
  return ret;
}
int n;
struct Data{int l,r;}s[MaxN];
bool cmp(const Data &A,const Data &B)
{return A.l<B.l;}
int main()
{
  n=read();m=read();
  build();
  for (int i=1;i<=n;i++)
    {s[i].l=read();s[i].r=read();}
  sort(s+1,s+n+1,cmp);
  int ans=0;
  for (int i=1;i<=n;i++){
    wfl=0;wfr=s[i].r;add();
    wfl=s[i].l+1;wfr=m+1;
    ans=max(ans,qry()-s[i].l);
  }printf("%d",max(ans,n-m));
  return 0;
}

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

using namespace std;
#define ll long long int

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

	ll n;
	cin>>n;
	ll count=0;
	for (int i = 1; i <= n; ++i)
	{
		count+=(i*(n/i)*((n/i)+1))/2;
	}
	cout<<count<<endl;

	return 0;
}


Measured memory_bytes: 3644
readlines.each do |l|
  n = l.split.map(&:to_i)
  break if n.all?{|i| i==0}
  catch :solve do
    n.permutation do |a|
      [0,1,2].product([0,1], [0]).each do |arr|
        expr = a.dup
        arr.each do |i|
          expr[i,2] = "("+expr[i,2].join(" %c ")+")"
        end
        ope = %w(+ - *)
        ope.product(ope, ope).each do |opes|
          e = expr.first % opes
          if eval(e)==10
            puts e
            throw :solve
          end
        end
      end
    end
    puts 0
  end
end

Measured memory_bytes: 6400
#include <iostream>

using namespace std;

int prime(int x){
    int ans = 0;
    for(int i=1;i<=x;i++){
        if(x%i==0)
            ans++;
    }
    return ans;
}

int main(){
    int n;
    cin>>n;
    int cnt = 0;
    for(int i=1;i<=n;i=i+2){
        if(prime(i)==8){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc159/tasks/abc159_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int L;
    cin >> L;
    double a = ((double)L) / 3;
    printf("%.10f\n", a * a * a);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
/*
　　　　　 　 _... ..._
　　　　　 , ´⌒ ⌒ヽ
　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
　　　　　　△ﾑ,8ﾑﾌつ
　　　　　/(ﾝ_/＿ヽ＼
　　　　 ～～i_ﾌ_ﾌ～´
*/
	int n;
	cin >> n;
	vector<int>h(n);
	vector<int>dp(n, 10000);
	rep0(i, n - 1)cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	REP(2, n - 1) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << endl;

	return 0;
} 

Measured memory_bytes: 1024
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/15/ALDS1_15_B

import heapq
n, w = [int(i) for i in input().split()]
res = 0
pq = []

for _ in range(n):
    _v, _w = [int(i) for i in input().split()]
    e = _v / _w
    heapq.heappush(pq, (-e, _v, _w))


while w > 0 and pq:
    e, value, weight = heapq.heappop(pq)
    if w >= weight:
        res += value
        w -= weight
    else:
        res += -e * w
        w = 0
print(res)



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

int main() {
  int n;
  cin>>n;
  int a[n+2],sum=0,t;
  a[0]=0;
  a[n+1]=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    sum+=abs(a[i]-a[i-1]);
  }
  sum+=abs(a[n+1]-a[n]);
  t=sum;
  for(int i=1;i<=n;i++){
    sum=t;
    if(a[i-1]<=a[i] && a[i]<=a[i+1])
      cout<<sum;
    else if(a[i-1]>=a[i] && a[i]>=a[i+1])
      cout<<sum;
    else{ 
      sum-=abs(a[i]-a[i-1])+abs(a[i+1]-a[i])-abs(a[i-1]-a[i+1]);
      cout<<sum;
    }
    cout<<endl;
  }

}

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

int main() {
	int i=0;
	cin>>i;
	int x=0;
	//string s="";
	int c=i%10;
	i=i/10;
	int b=i%10;
	i=i/10;
	int a=i;
	if(a==9)
	{
	    if(i==999)
	    cout<<"1111"<<"\n";
	    else
	    cout<<"999"<<"\n";
	    return 0;
	}
	if(b>a)
	{
	    cout<<a+1<<a+1<<a+1<<"\n";
	}
	else if(b==a)
	{
	    if(c>a)
	    {
	        cout<<a+1<<a+1<<a+1<<"\n";
	    }
	    else if(c==a)
	    {
	        cout<<a<<a<<a<<"\n";
	    }
	    else
	    {
	        cout<<a<<a<<a<<"\n";
	    }
	}
	else
	{
	    cout<<a<<a<<a<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

inline int max2(const int a, const int b){return a<b?b:a;}

long a[100000];
int b[40][2];
int main(void){
	int n=nextint();
	long k=nextlong();
	for(int i=0; i<n; i++){
		a[i]=nextlong();
		for(int j=0; j<40; j++){
			if(a[i]&(1L<<j)) b[j][0]++; else b[j][1]++;
		}
	}
	long ans=0;
	{
		for(int j=0; j<40; j++){
			if(k&(1L<<j)) ans+=(long)b[j][1]<<j; else ans+=(long)b[j][0]<<j;
		}
	}
	for(int i=0; i<40; i++){
		if(k&(1L<<i)){
			long now=0;
			for(int j=0; j<i; j++){
				now+=(long)max2(b[j][1],b[j][0])<<j;
			}
			now+=(long)b[i][0]<<i;
			for(int j=i+1; j<40; j++){
				if(k&(1L<<j)) now+=(long)b[j][1]<<j; else now+=(long)b[j][0]<<j;
			}
			if(now>ans) ans=now;
		}
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 896
s = int(input())
if s % 10**9 == 0:
    print(0, 0, 10**9, 0, 0, s//10**9)
else:
    r = s % (10**9)
    print(0, 0, 10**9, 1, 10**9 - r, s//10**9 + 1)


Measured memory_bytes: 2940
using System;
class Program{
  static void Main(string[] args){
    string[] tmp = Console.ReadLine().Split(' ');
    int n=int.Parse(tmp[0]);
    int q=int.Parse(tmp[1]);
    string s=Console.ReadLine();
    int[] c=new int[n];
    c[0]=0;
    for(int k=0;k<n-1;k++){
      c[k+1]=c[k];
      if(s[k]=='A'&&s[k+1]=='C'){c[k+1]++;}
    }
    for(int i=0;i<q;i++){
      tmp=Console.ReadLine().Split(' ');
      int l=int.Parse(tmp[0]);
      int r=int.Parse(tmp[1]);
      Console.WriteLine(c[r-1]-c[l-1]);
    }
  }
}


Measured memory_bytes: 17816
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <assert.h>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <bitset>
#include <numeric>
#include <string.h>
#include <utility>

using namespace std;
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back 
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef LOCAL
#define cerr if(false)cerr
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll P=1e9+7;
double PI=3.141592653589793;
const int arrn = 2e5 + 1;


void solve(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(a>=k){
		cout << k;
	}else if(a+b>=k){
		cout << a;
	}else{
		cout << 2*a+b-k;
	}
}

int main() {
	IO;
	int T=1;
//	cin >> T;
	forn(c,T){
		solve();
	}
}



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

int main(){
  ll lowest, n;
  ll ans = 0;
  cin >> n;
  lowest = n + 1;
  rep(i,n){
    ll now;
    cin >> now;
    if(now <= lowest) {
      lowest = now;
      ans ++;
    }
    else{
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<vector>
#include<set>
using namespace std;
int c[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	long long ret=0;
	for(int i=0;i<a-1;i++){
		if(c[i]+c[i+1]<=b)continue;
		int t=c[i]+c[i+1]-b;
		ret+=t;
		c[i+1]=max(0,c[i+1]-t);
	}
	printf("%lld\n",ret);
}

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

int A, B, K;
int gcd(int A, int B)
{
    if (A == 0)
        return B;
    if (B == 0)
        return A;
    if (A <= B)
    {
        return gcd(A, B % A);
    }
    if (A >= B)
    {
        return gcd(A % B, B);
    }
}

int main()
{
    cin >> A >> B >> K;
    int g = gcd(A, B);
    vector<int> divisor;
    for (int i = 1; i <= g; i++)
    {
        if (g % i == 0)
            divisor.push_back(i);
    }
    int n = divisor.size();
    cout << divisor.at(n - K) << endl;
}
/*test
1.
8 12 2
->2
2.
100 50 4
->5
3.
1 1 1
->1
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int p,q,r;
	cin>>p>>q>>r;
	int ans=min(p+q,q+r);
	ans=min(ans,p+r);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
p = list(map(int,input().split()))

ans=0
for ii in range(1,n-1):
    p_order = sorted(list([p[ii-1],p[ii],p[ii+1]]))
    if p_order.index(p[ii]) == 1 and p_order[0] != p_order[1]:
        ans += 1

print(ans)


Measured memory_bytes: 3060
/*
* @Author: Nazrul Islam
* @Date:   2020-09-19 13:30:27
* @Last Modified by:   Nazrul Islam
* @Last Modified time: 2020-09-19 13:30:58
*/

#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll; 
typedef double dd;
typedef vector<int> vi;
typedef vector<char> vc;
typedef list<int> li;
typedef set<int> si;
typedef map<int,int> mp;
#define pb push_back
#define pf push_front
#define mk make_pair
#define sc scanf
#define pr printf
#define pi acos(-1.0)
#define endl '\n'
// char s[200009];
// char st[200009];
// int a[600][600];
// int b[29][10];
// int a[200009];
// int c[200009];
void solve()
{
	ll n, m, i, j, k, l; 
	cin >> n;
	if(n) cout << "0" << endl;
	else cout << "1" << endl;
}
int main()
{
	IO;
	int t; 
	t = 1;
	// cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3548
arr_1 = input().split(" ")

n=int(arr_1[0])
m=int(arr_1[1])

hs = [int(o) for o in input().split(" ")]

connected = list()
bad = list()
for num in range(0,m):
    arr_2 = input().split(" ")
    a = int(arr_2[0])
    b = int(arr_2[1])

    diff = hs[a-1] - hs[b-1]
    if diff == 0:
        bad.append(a)
        bad.append(b)
    elif diff > 0:
        bad.append(b)
    else:
        bad.append(a)

print(n - len(list(set(bad))))

Measured memory_bytes: 20132
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<int, int>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;


int main()
{

  int H, W; cin >> H >> W;
  vector<string> grid(H);
  rep(i, 0, H) cin >> grid[i];
  vector<vector<ll>> dp(H, vector<ll>(W, 0));
  dp[0][0] = 1;

  rep(i, 0, H){
    rep(k, 0, W){
      dp[i][k] %= MOD;
      if(i + 1 < H && grid[i + 1][k] == '.') dp[i + 1][k] += dp[i][k];
      if(k + 1 < W && grid[i][k + 1] == '.') dp[i][k + 1] += dp[i][k];
    }
  }

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

}


Measured memory_bytes: 12996
#ifdef ConanYu
#include "E:\yuzining\code\local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie();
  Main();
  return 0;
}
#endif

void Main() {
  int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  vector<int> A(a), B(b), C(c);
  for(auto &x: A) cin >> x;
  for(auto &x: B) cin >> x;
  for(auto &x: C) cin >> x;
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());
  reverse(C.begin(), C.end());
  vector<ll> nw;
  for(int i = 0; i < x; i++) {
    nw.push_back(A[i]);
  }
  for(int i = 0; i < y; i++) {
    nw.push_back(B[i]);
  }
  sort(nw.begin(), nw.end());
  for(int i = 0, j = 0; i < x + y && j < c; i++, j++) {
    if(C[j] > nw[i]) {
      nw[i] = C[j];
    } else break;
  }
  cout << accumulate(nw.begin(), nw.end(), 0ll) << "\n";
}

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include<cstring>
#define ll long long
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー
pair<pair<string, int>, int> p[110];//pair型
int length(char* str) {
    int len = strlen(str);
    return len;
}
ll GCD(ll a, ll b)
{

    ll r, tmp;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }


    return b;
}
ll LCM(ll a, ll b)
{

    ll r, x, tmp;
    ll i, j;
    ll lcm;
    i = a;
    j = b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    lcm = (i / b) * j;

    return lcm;
}
int main()
{
    char Res[100010];
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int t;
        cin >> Res >> t;
        string tmp = Res;
        p[i] = make_pair(make_pair(Res, -t), i);
    }
    std::sort(p, p + N);
    for (int i = 0; i < N; i++) {
        cout << p[i].second+1 << endl;
    }

}


Measured memory_bytes: 256
#define rep(i, N) for(int (i) = 0; (i) < N; (i) ++)
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(void){
    string abcd;
    cin >> abcd ;
    int res = 0;
    rep(i, (1 << 3)){
        int sum = abcd[0] - '0';
        rep(j, 3){
            if(((1 << j) & i)){
                sum += abcd[j + 1] - '0';
            }else{
                sum -= abcd[j + 1] - '0';
            }
        }
        if(sum == 7) {
            res = i;
        }
    }

    rep(i, 3){
        cout << abcd[i];
        if(((1 << i) & res)) {
            cout << "+";
        }else{
            cout << "-";
        }
    }
    cout << abcd[3] << "=7" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin>>n;
    long mi=1000000;
    long ma=-1000000;
    long sum=0;
    for(long i=0;i<n;i++){
        long a;
        cin>>a;
        mi=min(mi,a);
        ma=max(ma,a);
        sum+=a;
    }
    cout<<mi<<' '<<ma<<' '<<sum<<endl;
}


Measured memory_bytes: 3112
class VectorSpace:
    def __init__(self, k):
        self.k = k
        self.E = [0] * k
    
    def chk(self, n):
        for i in range(self.k)[::-1]:
            n = min(n, n ^ self.E[i])
        return 1 if n == 0 else 0
    
    def add(self, n):
        for i in range(self.k)[::-1]:
            n = min(n, n ^ self.E[i])
        if n: self.E[n.bit_length() - 1] = n
        return 1 if n == 0 else 0
    
    def dimension(self):
        return len(self.E)

T = int(input())
for _ in range(T):
    N = int(input())
    A = [int(a) for a in input().split()]
    S = [int(a) for a in input()]
    vs = VectorSpace(60)
    for i in range(N)[::-1]:
        a = vs.add(A[i])
        if S[i] and a == 0:
            print(1)
            break
    else:
        print(0)

Measured memory_bytes: 9176
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> VI;
typedef vector<bool> VB;

VI ms_prime_factor ( void )
{
	const int SIZE = 300010;
	VB is_ms_prime_number( SIZE, false );
	VI res;
	for ( int i = 0; 7 * i + 10 < SIZE; ++i ) {
		is_ms_prime_number[7 * i + 1] = true;
		is_ms_prime_number[7 * i + 6] = true;
	}

	for ( int i = 2; i < SIZE; ++i ) {
		if ( !is_ms_prime_number[i] ) {
			continue;
		}
		for ( int j = i + i; j < SIZE; j += i ) {
			is_ms_prime_number[j] = false;
		}
		res.push_back( i );
	}
	return res;
}

int main ( void )
{
	VI p_factor = ms_prime_factor();
	int num;
	while ( cin >> num, num != 1 ) {
		cout << num << ':';
		for ( int i = 0; i < p_factor.size(); ++i ) {
			if ( num % p_factor[i] == 0 ) {
				cout << ' ' << p_factor[i];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1384
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#define ll long long
using namespace std;
long double pi = 3.14159265358979323846;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

int main()
{
	
	int n;
	string z;
	cin >> n;
	set<string>s;
	for (int i = 0; i < n; i++)
	{
		cin >> z;
		s.insert(z);
	}
	cout << s.size();
	 return 0;

}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

int main() {
    IOS;

    long int n;
    cin>>n;

    priority_queue<long double,vector<long double>,greater<long double>> pq;
    for(long int i = 0; i < n; i++){
        long int x;
        cin>>x;
        pq.push(x);
    }

    while(pq.size() > 1){
        long double a = pq.top();
        pq.pop();
        long double b = pq.top();
        pq.pop();
        pq.push((a+b)/2);
    }

    cout<<pq.top();
    return 0;
}


Measured memory_bytes: 256
n=gets.split
m=->r,d{r.map{|i|n[i]}.rotate(d).map.with_index{|v,i|n[r[i]]=v}}
gets.chop.chars{|c|m[(c<?F||?V<c)?[0,2,5,3]:[0,4,5,1],c>?R?1:-1]}
puts n[0]

Measured memory_bytes: 6120
#include <iostream> // cout, endl, cin
#include <iomanip>
#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 <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int num = (100 * r) + (10 * g) + b;
    if(num % 4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int MAX = 2e5+4;
const ll INF = 1e18;
int dp[MAX];
bool past[MAX];
vector<int> edges[MAX];
int dfs(int v)
{
	if(past[v]) return dp[v];
	past[v]=true;
	for(int x : edges[v])
	{
		dp[v]=max(dp[v],dfs(x)+1);
	}
	return dp[v];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		edges[a].push_back(b);
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		ans=max(ans,dfs(i));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 9984
L, R = map(int, input().split())
mini = 9999
if R - L >2019:
  R = L + 2019
for l in range(L, R + 1):
  for r in range(l + 1, R + 1):
    temp = (r * l) % 2019
    if temp < mini:
      mini = temp
    if mini == 0:
      break
print(mini)

Measured memory_bytes: 3060
N = int(input())
A = [int(x) for x in input().split()]
times = 0

for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    if i != minj:
        times += 1
    A[i], A[minj] = A[minj], A[i]
  


print(*A)
print(times)

Measured memory_bytes: 7676
#include <iostream>
const int MAX = 200 ;
bool mark[MAX];
int main(){
    int k , n , x ;
    scanf("%d%d",&k,&n);
    while(n--){
        scanf("%d",&x);
        mark[x]=1;
    }
    int i = k , j = k ;
    while(i>=0){
        if(!mark[i]){
            printf("%d\n",i);
            return 0;
        }
        if(!mark[j]){
            printf("%d\n",j);
            return 0;
        }
        --i;
        ++j;
    }
    printf("-1\n");
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 3612
from itertools import accumulate
N = int(input())
A = tuple([0,] + list(map(int, input().split())) + [0,])
D = []
sum = 0
for i, a in enumerate(A[1:-1]):
  i += 1
  pre = A[i - 1]
  tem = A[i]
  nex = A[i + 1]
  x = abs(pre - tem)
  y = abs(tem - nex)
  sum += x
  D.append(abs(pre - nex) - x - y)
sum += y
for d in D:
  print(sum + d)

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int n;
    cin >> n;

    set< string > s;

    for ( long long int i = 0; i < n; i++ ) {
        string in;
        cin >> in;
        s.insert(in);
    }

    cout << s.size() << endl;

    return 0;

}


Measured memory_bytes: 19224