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

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          String weather = sc.next();
          switch(weather){
            case "Sunny": 
                System.out.println("Cloudy");
                break;
            case "Cloudy":
                System.out.println("Rainy");
                break;
            case "Rainy":
                System.out.println("Sunny");
          }
      }
    }

Measured memory_bytes: 19412
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

//0566
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),s[] =new int[n];
        T[] t=new T[n];
        for (int i = 0; i < n * (n - 1) / 2; i++) {
            int a = sc.nextInt()-1, b = sc.nextInt()-1, c = sc.nextInt(), d = sc.nextInt();
            if (c == d) {
                s[a]++;
                s[b]++;
            } else if (c > d) {
                s[a] += 3;
            } else {
                s[b]+=3;
            }
        }
        for(int i=0;i<n;i++)
            t[i]=new T(i+1,s[i]);
        Arrays.sort(t, new Comparator<T>() {
            public int compare(T a, T b) {
                return b.s-a.s;
            }
        });
        t[0].r=1;
        for(int i=1;i<n;i++) {
            if(t[i].s==t[i-1].s)
                t[i].r=t[i-1].r;
            else
                t[i].r=i+1;
        }
        Arrays.sort(t, new Comparator<T>() {
            public int compare(T a, T b) {
                return a.i-b.i;
            }
        });
        for(T e:t) {
            System.out.println(e.r);
        }
    }
}
class T{
    int i;
    int s;
    int r;
    T(int i,int s){
        this.i=i;
        this.s=s;
    }
}


Measured memory_bytes: 49048
N,M =map(int,input().split())
L = [0]*M
R = [0]*M
ans = int(0)

for i in range(M):
    L[i],R[i] = list(map(int,input().split()))

a1 = max(L)
a2 = min(R)

ans = a2-a1+1

if ans<0 : ans = int(0)

print(int(ans))


Measured memory_bytes: 10996
#include <stdio.h>
#include <stdlib.h> //atoi関数
void push(int);
int pop();
int isEmpty();

int S[100],top;

int main(){
  int x;
  char s[100];
  int a,b;
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){  
      a = pop();
      b = pop();
      push(a+b);
    }
    else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b-a);
    }
    else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    }
    else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x){
  top = top + 1;
  S[top] = x;
}

int pop(){
  if(isEmpty()){
    fprintf(stderr,"error:isEmpty\n");
    exit(1);
  }
  else {
    top = top - 1;
  }
  return S[top+1];
}

int isEmpty(){
  return top==0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int A, B, K; IN(A, B, K);
    vector<int> ans;
    rep(i, A, min(A + K, B + 1)) ans.push_back(i);
    rep(i, max(A, B - K + 1), B + 1) ans.push_back(i);
    sort(ALL(ans));
    UNIQUE(ans);
    for(auto e: ans) cout << e << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <queue>
//#include <cmath>
//#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

int main()
{
	int n;
	ll int sum = 0LL;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		if (i % 3 && i % 5) {
			sum += (ll int)i;
		}
	}

	printf("%lld", sum);

	return 0;
}

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

using namespace std;
int n,k;
int main(){
    cin >> n >> k;
    int p[1010];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }    
    sort(p,p+n);
    int total = 0;
    for(int i=0;i<k;i++){
         total += p[i];
    }
    cout << total << endl;
}

Measured memory_bytes: 3640
#エラトステネスの篩
MAX_NUM = 999999
primes = []
max = Math.sqrt(MAX_NUM).ceil
arr = [*2..MAX_NUM]
0.upto(max) {|i|
  next if arr[i] == nil
  primes << arr[i]
  i.step(limit = arr.length, step = primes.last){|j| arr[j] = nil}
}
primes.concat(arr.compact!)
#Prime Number
while gets
  n = $_.to_i
  puts primes.count{|i| i <= n}
end

Measured memory_bytes: 21844
n,d = (int(i) for i in input().split())
x,ans = [],0
for i in range(n):
    y = [int(i) for i in input().split()]
    x.append(y)
for i in range(n-1):
    for j in range(i+1,n):
        m = 0
        for k in range(d): m+=(x[i][k]-x[j][k])**2
        if int(m**0.5)**2==m: ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
  int n;
  cin >> n;
  long *a = new long[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long x, y, z;
  x = a[0];
  y = a[0];
  z = 0;
  for (int j = 0; j < n; j++) {
    x = min(x, a[j]);
    y = max(y, a[j]);
    z += a[j];
  }
  cout << x << " " << y << " " << z <<endl;
  delete[] a;
}

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

int main()
{
  string s;
  int sum = 0;

  while( cin >> s ) {
    bool flag = true;
    for(int i=0; i<s.size()/2; i++) {
      if( s[i] != s[s.size()-i-1] ) {
	flag = false;
	break;
      }
    }

    if( flag ) sum++;
  }

  cout << sum << endl;
}

Measured memory_bytes: 1184
N,M,C = map(int,input().split())
B = list(map(int, input().split()))
A = [0 for i in range(N)]
for j in range(N):
    A[j] = list(map(int,input().split()))

ans = 0
for k in range(N):
    score = C
    for l in range(M):
        score += A[k][l] * B[l]
    if score > 0:
        ans += 1

print(ans)

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

int main(){
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if(A1 <= A2 && A2 <= A3){
        cout << A3-A1 <<endl;
        return 0;
    }
    if(A1 <= A3 && A3 <= A2){
        cout << A2-A1 <<endl;
        return 0;
    }
    if(A2 <= A1 && A1 <= A3){
        cout << A3-A2 <<endl;
        return 0;
    }
    if(A2 <= A3 && A3 <= A1){
        cout << A1-A2 <<endl;
        return 0;
    }
    if(A3 <= A1 && A1 <= A2){
        cout << A2-A3 <<endl;
        return 0;
    }
    if(A3 <= A2 && A2 <= A1){
        cout << A1-A3 << endl;
        return 0;
    }
}


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

void input(long &n, vector<long> &a) {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
}

long div(long n) { // 整数が2で割り切れる回数
    long count = 0;
    while (n % 2 == 0) {
        n /= 2;
        count++;
    }
    return count;
}

int main() {
    long n; vector<long> a;
    input(n, a);

    long sum = 0;
    for (int i = 0; i < n; i++) { //各要素の2で割り切れる回数の総和
        sum += div(a[i]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>

int main(void) {
  int a, b;

  std::string str;

  std::cin >> a;
  std::cin >> b;

  auto ans1 = a + b;
  auto ans2 = a - b;
  auto ans3 = a * b;

  auto ans_ = ans1 > ans2 ? ans1 : ans2;
  ans_ = ans_ > ans3 ? ans_ : ans3;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(n); i++)
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main(){
    ll N,M; cin >> N >> M;
    vector <ll> X(M);
    rep(i,M) cin >> X[i];
    sort(X.begin(),X.end());
    
    vector <ll> d(M-1);
    rep(i,M-1){
        d[i]=X[i+1]-X[i];
    }
    sort(d.begin(),d.end());
    
    ll sum=0;
    rep(i,(M-1)-(N-1)) sum+=d[i];
    
    cout << sum << endl;
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>

using namespace std;

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

int main(){
    string s;
    cin >> s;
    
    int count = 0;
    for(int i=1; i<=(s.size()-1)/2; i++){
        bool flag = true;
        REP(j, i){
            if(s[j+i] != s[j]){
                flag = false;
            }
        }
        if(flag) count = i;
    }
    cout << count*2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=1e16;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int a,b;
	cin>>a>>b;
	a+=b;
	if(a>=24)a-=24;
	cout<<a<<endl;
}









Measured memory_bytes: 256
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    x, y, z = map(int, input().split())
    print(z, x, y) 


if __name__ == '__main__':
    main()



Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
   string s;
   cin >> s;
   int ans = 0;
   for(int i = 0; i < 4; i++){
       if(s[i] == '+'){
           ans += 1;
       }else ans -= 1;
   }
   cout << ans << endl;
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


string s, s1, s2;
ll n, k, ans = INF;
ll a[SZ];
//ll b[SZ];



int main() {
    FR;
    ll cs = 0, tc = 1, x, y, z, i, j, g, p, q, sum = 0, c = 0, t = 0;
//    ll a, b, d;
//    string s, s1, s2;

    cin2(s, s1);

    ll n1 = s1.size();
    n = s.size();

    for(i = 0; i+n1-1 < n; i++) {
        c = 0;
        for(j = i, k = 0; j < i+n1; j++, k++) {
            if(s1[k] != s[j]) c++;
        }
        ans = min(ans, c);
    }

    cot1(ans);

    return 0;
}



Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int a;
cin>>a;
int b=1;
for(int i=0;i<a;i++)
{b*=2;
if(b>a)
{cout<<b/2;
system("pause");
return 0;
}
if(b==a){
cout<<b;
system("pause");
return 0;
}}
system("pause");
return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, max1 = 0, max2 = 0;
	int con = 0, maxi = 0;
	vector<int> A;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		max1 = max(A[i], max1);
	}
	for(int i = 0; i < N; i++){
		if(max1 == A[i]) {
			con++;
			maxi = i;
		} else {
			max2 = max(max2, A[i]);
		}
	}
	
	for(int i = 0; i < N; i++){
		if(con == 1){
			if(maxi == i) cout<<max2<<endl;
			else cout<<max1<<endl;
		} else {
			cout<<max1<<endl;
		}
	}
	
	return 0;
}

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

using namespace std;

int main(void){
	int N,x;
	long long ans =0;
	cin >> N>>x;
	int a[N];
	for(int i=0;i<N;i++)cin >> a[i];
	for(int i=1;i<N;i++){
		if((a[i-1]+a[i])>x){
			ans +=	a[i-1]+a[i] -x;
			a[i] -= a[i-1]+a[i] -x;
			if(a[i]<0)a[i]=0;
		}
	}
	cout << ans;
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll x; cin >> x;
    ll ans = x/11*2;
    x %= 11;
    if(0 < x && x < 7) ans++;
    else if(6 < x) ans += 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const ll MOD = 1e9+7;
int main() {
    ll n,k;
    std::cin >> n>>k;
    vector<ll> a(n);
    ll cntz = 0;
    ll cntn = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if(a[i]==0)cntz++;
        if(a[i]<0)cntn++;
    }
    sort(a.begin(),a.end());
    if(k==1){
        std::cout << (a[n-1]+MOD)%MOD << std::endl;
        return 0;
    }

    // 負で終わるケースを除く
    if(a[n-1]<0){
        if(k%2==1){
            ll ans = 1;
            for (int i = 0; i < k; i++) {
                ans *= a[n-1-i]+MOD;
                ans %= MOD;
            }
            std::cout << ans << std::endl;
            return 0;
        }
    }
    if(k==n){
        ll ans =1;
        for (int i = 0; i < n; i++) {
            ans *= a[i]+MOD;
            ans %= MOD;
        }
        std::cout << ans << std::endl;
        return 0;
    }
    
    if(n-cntz<k){
        std::cout << 0 << std::endl;
        return 0;
    }
    
    if(cntz+cntn==n&&k%2==1){
        std::cout << 0 << std::endl;
        return 0;
    }
    
    ll nowk = k;
    ll cur = n-1;
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    while(nowk){
        if(a[cur]>0){
            pq.push(a[cur]);
            cur--;
            nowk--;
        }else{
            break;
        }
    }
    if(nowk%2==1){
        pq.pop();
        nowk++;
    }
    // nowkは2の倍数
    ll add = 1;
    for (int i = 0; i < cntn/2; i++) {
        // 入れるしかなかったら入れる
        if(nowk>=2){
            add *= a[i*2]+MOD;
            add %= MOD;
            add *= a[i*2+1]+MOD;
            add %= MOD;
            nowk-=2;
        }else{
            // 先客がいる
            if(pq.size()>=2){
                auto n1 = pq.top();pq.pop();
                auto n2 = pq.top();pq.pop();
                if(n1*n2<(-1*a[i*2])*(-1*a[i*2+1])){
                    add *= a[i*2]+MOD;
                    add %= MOD;
                    add *= a[i*2+1]+MOD;
                    add %= MOD;
                }else{
                    pq.push(n1);
                    pq.push(n2);
                    break;
                }
            }else{
                break;
            }
        }
    }
    
    while(pq.size()){
        auto tmp = pq.top();pq.pop();
        add *= tmp+MOD;
        add %= MOD;
    }
    
    std::cout << add << std::endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int N;
    std::cin >> N;

    if(N == 1){
        std::cout << "Hello World" << std::endl;
    }else{
        int A, B;
        std::cin >> A >> B;

        std::cout << (A + B) << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define right sefudermano
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 200100;
int a[N],b[N];
const int inf = 1e9 + 1e8;
int pre[N];
int n;
int get(int x){
  int l = 1,r = n;
  int ans=0;
  while(l<=r){
    int mid = (l+r)/2;
    if(pre[mid]<=x){
      ans = mid;
      l = mid+1;
    }else r= mid-1;
  }
  return ans;
}

int32_t main(){
  fastio;
  int m,k;
  cin>>n>>m>>k;
  int id1=0,id2=0;
  for(int i=0;i<N;i++){
    a[i] = b[i] = inf;
  }
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
  for(int i=1;i<=m;i++){
    cin >> b[i];
  }
  int res=0;
  for(int i=1;i<=n;i++){
    pre[i] = pre[i-1] + a[i];
  }

  int r=0;
  for(int i=1;i<=m;i++){
    if(k-r<0)break;
    res = max(res, + i -1+ get(k-r));
    r+=b[i];
    if(k-r<0)break;
    res = max(res ,i + get(k-r));
  }
  cout << res << endl;

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
} 

Measured memory_bytes: 8344
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += A.at(i);
    }
    if (sum >= H){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - b) <= d && abs(b - c) <= d){
		cout << "Yes" << endl;
	}
	else if (abs(a - c) <= d){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int a[3][N];

int main() {
  int n;
  scanf("%d", &n);
  for (int k = 0; k < 3; ++k) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[k][i]);
    }
    sort(a[k], a[k] + n);
  }
  vector<int64> d(n, 1), e(n);
  for (int k = 1; k < 3; ++k) {
    int j = 0;
    int64 cur = 0;
    for (int i = 0; i < n; ++i) {
      for (; j < n && a[k - 1][j] < a[k][i]; ++j) cur += d[j];
      e[i] = cur;
    }
    swap(d, e);
  }
  int64 ret = accumulate(d.begin(), d.end(), 0LL);
  printf("%lld\n", ret);
  return 0;
}


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

typedef struct{
    int p;
    int y;
    int idx;
    int under;
}St;

bool cmp1(const St& a, const St& b){
    if(a.y < b.y){
        return true;
    }
    return false;
}

bool cmp2(const St& a, const St& b){
    if(a.idx < b.idx){
        return true;
    }
    return false;
}

void output(int n){
    if(n >= 100000){
        cout << n;
    }else if(n >= 10000){
        cout << "0" << n;
    }else if(n >= 1000){
        cout << "00" << n;
    }else if(n >= 100){
        cout << "000" << n;
    }else if(n >= 10){
        cout << "0000" << n;
    }else{
        cout << "00000" << n;
    }
}

int main(void){
    int n, m;
    cin >> n >> m;
    
    St c[100000];
    int i;
    for(i = 0; i < m; i++){
        cin >> c[i].p >> c[i].y;
        c[i].idx = i;
    }
    
    sort(c, c + m, cmp1);
    
    int city[100001] = {0};
    for(i = 0; i < m; i++){
        c[i].under = ++city[c[i].p];
    }
    
    sort(c, c + m, cmp2);
    
    for(i = 0; i < m; i++){
        output(c[i].p);
        output(c[i].under);
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

    ll i, j, n;
    cin>>n;
    ll a[n];
    double  k=0;
    for(i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a, a+n);
    k=(a[0]+a[1])/2.0 ;
    for(i=2; i<n; i++){
        k=(k+a[i])/2.0 ;
    }
    cout<<fixed<<setprecision(7);
    cout<<k<<endl;
    return 0;
}





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

ll choose(int n, int a)
{
    ll x = 1, y = 1;
    rep(i, a)
    {
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];

    map<int, int> mp;

    ll ans = 0;
    for(int i = 0; i < N; i++){
        mp[L[i]]++;
    }
    vector<pair<int, int>> p;
    for(auto m : mp){
        p.push_back(make_pair(m.first, m.second));
    }
    int n = p.size();
    // 3本の長さがそれぞれ同じの場合
    for(int i = 0; i < n; i++){
        ans += choose(p[i].second, 3);
    }
    // 2本の長さが同じ場合
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(p[j].first < p[i].first * 2){
                ans += (choose(p[i].second, 2) * p[j].second);
            }
            if(p[i].first < p[j].first * 2){
                ans += (choose(p[j].second, 2) * p[i].second);
            }
        }
    }

    // 3本の長さがそれぞれ異なる場合
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                int a = p[i].first, b = p[j].first, c = p[k].first;
                if(a < b + c && b < c + a && c < a + b){
                    ans += p[i].second * p[j].second * p[k].second;
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int arr[n], max = 1e18, prodak = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prodak = prodak * arr[i];
    (arr[i]) ? max = max/arr[i] : zero = 1; 
  }
  if (zero == 1){
  	printf("0\n");
  }
  else {
  	if (flag == 1){
  		printf("-1\n");
	  }
	  else{
	  	printf("%lld\n",prodak);
	  }
  }
  return 0;
}

Measured memory_bytes: 3972
package main

import (
        "fmt"
)

func main() {
        var a [3]int
        for i := range a {
                fmt.Scan(&a[i])
        }

        sum := 0
        for i := range a {
                sum += a[i]
        }
        max := a[0]
        for i := 1; i < len(a); i++ {
                if max < a[i] {
                        max = a[i]
                }
        }

        n := max
        if max*3%2 != sum%2 {
                n++
        }
        cnt := (n*3 - sum) / 2
        fmt.Println(cnt)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

long long gcd(long long a, long long b) {
	return b ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}

signed main() {
	int a, b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3024
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
import math
import time
ts=time.time()
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n=I()
b=LI()
ans=0

for i in range(n-2):
    ans+=min(b[i+1],b[i])

ans+=b[0]
ans+=b[-1]
    
print(ans)


Measured memory_bytes: 38512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {


    	Scanner sc = new Scanner(System.in);
    	int H = sc.nextInt();
    	int W = sc.nextInt();
    	int[][] board = new int[H][W];
    	int[] dx = {-1, -1, 0, 1, 1, 1, 0, -1};
    	int[] dy = {0, -1, -1, -1, 0, 1, 1, 1};
    	for(int i = 0; i < H; i++){
    		String[] strs = sc.next().split("");
    		for(int j = 0; j < W; j++){
    			board[i][j] = strs[j].equals("#")? 9 : 0;
    		}
    	}
    	for(int i = 0; i < H; i++){
    		for(int j = 0; j < W; j++){
    			if(board[i][j] != 9){
    				int cnt = 0;
        			for(int k = 0; k < 8; k++){
        				int x = i + dx[k];
        				int y = j + dy[k];
        				if(x >= 0 && x < H &&
        						y >= 0 && y < W && board[x][y] == 9){
        					cnt++;
        				}
        			}
        			board[i][j] = cnt;
    			}
    		}
    	}
    	for(int i = 0; i < H; i++){
    		for(int j = 0; j < W; j++){
    			if(board[i][j] == 9){
    				System.out.print("#");
    			}else{
    				System.out.print(board[i][j]);
    			}
    		}
    		System.out.println();
    	}
    }
}


Measured memory_bytes: 25172
/**
 * Title: D - Dice in Line
 * Url: https://atcoder.jp/contests/abc154/tasks/abc154_d
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n+1, 0);
    for(int i=1; i<=n; i++) cin >> p[i];
    vector<int> s(n+1, 0);
    s[0] = 0;
    for(int i=1; i<=n; i++) {
        s[i] = s[i-1] + p[i];
    }
    int max_i;
    int max_s = 0;
    for(int i=1; i<=n-k+1; i++) {
        if(s[i+k-1] - s[i-1]>=max_s) {
            max_s = s[i+k-1] - s[i-1];
            max_i = i;
        }
    }

    double ans = 0;
    for(int i=max_i; i<=max_i+k-1; i++) {
        for(int j=1; j<=p[i]; j++) {
            ans += j*(double)1/(double)p[i];
        }
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(n,i) for(int i=0;i<n;i++)
long int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
using namespace std;
int main(void){
    long int m,n;
    cin>>m>>n;
    long int kou=gcd(m,n);
    cout<<m*n/kou;
    
    
    
}


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

int main()
{
    ll n,ans=0;
    vector< ll > v;
    cin>>n;
    for(int x,i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
        if(i==0) continue;
        v[i]=v[i-1]+x;
    }
    sort(v.begin(),v.end());
    for(ll tm,i=0;i<n; )
    {
       ll l=lower_bound(v.begin(),v.end(),v[i])-v.begin();
       ll u=upper_bound(v.begin(),v.end(),v[i])-v.begin();
       //cout<<v[i]<<" : "<<u-l<<"\n";
       tm=u-l;
       if(v[i]==0) {
            ans+=(tm*(tm+1))/2;
       }
       else {
            ans+=(tm*(tm-1))/2;
       }

        i=u;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		sc.close();
		int ans = b / a;
		if(c < ans) ans= c;
		System.out.println(ans);
	}

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
double dp[3001][3001];
double p[3001];
lol a,b,c,d;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a;
  dp[0][0]=1;
  for(int n=0;n<a;n++) cin >>p[n];
  double ans=0;
  for(int n=1;n<=a;n++){
      for(int m=0;m<a;m++){
	  dp[n][m+1]+=dp[n-1][m]*p[n-1];
	  dp[n][m]+=dp[n-1][m]*(1-p[n-1]);
      }
  }
  for(int n=a;n>a/2;n--){
      ans+=dp[a][n];
  }
  cout <<SYOU(9)<<ans<<'\n';
  return (0);
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll dp[5001][5001];
ll cycle[5001];

ll M_INF = -100000000000000; // 9,223,372,036,854,775,808

ll abc175d(ll n, ll k, ll p[], ll c[]) {
  map<ll, ll> direct;
  for(ll i=0;i<n;i++) {
    direct[i] = p[i] - 1;
  }

  for(ll i=0;i<n;i++) {
    ll count = 1;
    ll cur = direct[i];
    dp[i][0] = c[cur];
    while(cur != i) {
      cur = direct[cur];
      dp[i][count] = c[cur] + dp[i][count-1];
      count++;
    }
    cycle[i]=count;
  }
  /*
     for(ll i = 0;i<n;i++) {
     cout << i << " -> ";
     for(ll j=0;j<cycle[i];j++) {
     cout << dp[i][j] << " ";
     }
     cout << endl;
     }
     */
  ll res = M_INF;
  //cout << " ====== " << endl;

  for(ll i=0;i<n;i++) {
    if(dp[i][cycle[i]-1] <= 0) {
      ll kk = min(k, cycle[i]);
      ll r = M_INF;
      for(ll j = 0;j<kk;j++) {
	r = max(r, dp[i][j]); 
      }
      res = max(res, r);
      continue;
    }
    // dp[i][cycle[i]-1] > 0
    ll r = 0;
    ll kk = k;
    ll rr = M_INF;
    if(k/cycle[i] > 1) {
      r = ((k/cycle[i]) - 1) * dp[i][cycle[i]-1];
      kk -= cycle[i] * ((k/cycle[i]) - 1);
      rr = 0;
    }
    if(kk<=cycle[i]) {
      for(ll j = 0;j<kk;j++) {
	rr = max(rr, dp[i][j]);
      }
      res = max(res, r + rr);
      continue;
    }

    ll mx = M_INF;
    for(ll j=0;j<cycle[i];j++) {
      mx = max(mx, dp[i][j]);
    }
    kk -= cycle[i]; 
    for(ll j = 0;j<kk;j++) {
      rr = max(rr, dp[i][j]);
    }
    res = max(res, max(r + dp[i][cycle[i]-1] + rr, r + mx));
  }
  // 26453481651
  // 3053541818
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  ll p[n], c[n];
  for(ll i = 0; i< n;i++) {
    cin >> p[i];
  }
  for(ll i = 0; i< n;i++) {
    cin >> c[i];
  }
  cout << abc175d(n, k, p, c);
}

Measured memory_bytes: 199408
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n, a, b, cnt = 0;
    cin >> n >> a >> b;
    rep(i, 1, n+1){
        int k = i;
        int sum = 0;
        while(k > 0){
            sum += k % 10;
            k /= 10;
        }
        if(a <= sum && sum <= b){
            cnt += i;
        }
    }
    cout << cnt << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 2000010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll fac[MAX_N], inv[MAX_N], fiv[MAX_N]; //fiv:inv(fac(i))

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll invf(ll a) {
	return mod_pow(a, mod - 2);
}


void C_init(int n) {
	fac[0] = fac[1] = 1; inv[1] = 1;
	fiv[0] = fiv[1] = 1;
	rep(i, 2, n + 1) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fiv[i] = fiv[i - 1] * inv[i] % mod;
	}
}

ll C(int a, int b) { //assume a >= b
	if(a < b || a < 0 || b < 0) return 0;
	return fac[a] * fiv[b] % mod * fiv[a - b] % mod;
}


void solve() {
	int X, Y;
	cin >> X >> Y;
	if(2 * X - Y < 0 || -X + 2 * Y < 0) {
		cout << 0 << "\n"; return;
	}
	if((2 * X - Y) % 3 != 0) {
		cout << 0 << "\n"; return;
	}
	int x = (2 * X - Y) / 3, y = (-X + 2 * Y) / 3;
	C_init(x + y);
	cout << C(x + y, x) << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 20736
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string pre,act;
  cin>>pre>>act;
  int ct=0;
  for(int i=0;i<3;i++)
  {
    if(pre[i] == act[i])
      ct++;
  }
  cout<<ct;
  return 0;
}

Measured memory_bytes: 256
list = [0 for i in range(26)]

alpha = "abcdefghijklmnopqrstuvwxyz"

while True:
 try:
  sent = input().lower()
 except:
  break

 for i in range(len(sent)):
  for j in range(26):
   if sent[i] == alpha[j]:
    list[j] += 1

for i in range(26):
 print(alpha[i],":",list[i])


Measured memory_bytes: 5564
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    ll N, A, B;
    cin >> N >> A >> B;

    if (A > B) cout << 0 << "\n";
    else if (A < B and N == 1) cout << 0 << "\n";
    else if (A == B and N == 1) cout << 1 << "\n";
    else { // A < B and N > 2
        ll maxSum = A + B*(N-1);
        ll minSum = A*(N-1) + B;
        cout << maxSum-minSum+1LL << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define mp(a,b) make_pair(a,b)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int h,w,n;
    cin>>h>>w>>n;
    int g=max(h,w);
    cout<<(n/g + (n%g!=0));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,m;
  cin >> n>> m;

  ll a[n+1]={};
  bool b[n+1]={};

  ll c=0;
  ll d=0;

  for(ll i=0;i<m;i++){
    ll p;
    string s;
    cin >> p >> s;
    if(s=="AC"){
      b[p]=true;
    }
    else{
      if(b[p]);
      else{
        a[p]++;
      }
    }
  }

  for(ll i=1;i<=n;i++){
    if(b[i]){
      c++;
      d+=a[i];
    }
  }

  cout << c <<" " << d << endl;

}

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

int main()
{
	int a[3];
	for(int i = 0; i < 3; i++)
		cin >> a[i];
	sort(a, a + 3);
	cout << a[2] * 10 + a[1] + a[0];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

void solve() {
    int n; cin >> n;
    vector <int> rp(n + 1);
    loop1(i, n) {
        int x; cin >> x;
        rp[x] = i;
    }
    loop1(i, n)
        cout << rp[i] << " ";
}

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

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define R register
#define L 2002

inline void read(int &x){
    static int ch; static bool flag;
    for(flag=0,ch=getchar(); ch>'9'||ch<'0'; ch=getchar()) flag |= ch=='-';
    for(x=0; ch>='0'&&ch<='9'; ch=getchar()) x = (x<<1) + (x<<3) + ch-48;
    x = flag ? -x : x; 
}

int N,M,Q,Ans;
char Map[L][L];
int node[L][L],x[L][L],y[L][L];

inline int calc(int a1,int b1,int a2,int b2,int s[L][L]){
	return s[a2][b2]-s[a1-1][b2]+s[a1-1][b1-1]-s[a2][b1-1];
}

int main()
{
	read(N),read(M),read(Q);
	for(R int i=1;i<=N;++i) scanf("%s",Map[i]+1);
	for(R int i=1;i<=N;++i)
		for(R int j=1;j<=M;++j){
			node[i][j] = Map[i][j]=='1';
			node[i][j] += node[i-1][j]+node[i][j-1]-node[i-1][j-1];
			x[i][j] = Map[i][j]=='1' && Map[i-1][j]=='1';
			x[i][j] += x[i-1][j]+x[i][j-1]-x[i-1][j-1];
			y[i][j] = Map[i][j]=='1' && Map[i][j-1]=='1';
			y[i][j] += y[i-1][j]+y[i][j-1]-y[i-1][j-1];
		}
	while(Q--){
		R int a1,b1,a2,b2; read(a1),read(b1),read(a2),read(b2); Ans=0;
		Ans += calc(a1,b1,a2,b2,node);
		Ans -= calc(a1+1,b1,a2,b2,x);
		Ans -= calc(a1,b1+1,a2,b2,y);
		printf("%d\n",Ans);
	}
	return 0;
}

Measured memory_bytes: 52736
a,b=map(int,input().split())
if a%2==b%2:
    k=(b-a)//2
    print(b^(k%2) if a%2==0 else a^(k%2))
elif a%2==0 and b%2==1:
    print(((b-a+1)//2)%2)
elif a%2==1 and b%2==0:
    print(a^b^((b-a-1)//2)%2)

Measured memory_bytes: 3064
def make_divisor(n):
    divisor = [1, n]
    i = 2
    while i * i <= n:
        q, r = divmod(n, i)
        if r == 0:
            divisor.append(i)
            divisor.append(q)
        i += 1
    return sorted(divisor)


n, m = [int(v) for v in input().split()]
divisors = make_divisor(m)

ans = 1
maxv = m // n
for v in divisors:
    if v <= maxv:
        ans = v
    else:
        break

print(ans)

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

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

    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int ans = 1 << 29;
    for(int x = -100; x <= 100; x++){
        int t = 0;
        for(int i = 0; i < n; i++){
            t += (a[i] - x) * (a[i] - x);
        }
        ans = min(ans, t);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
	int ret = h2 * 60 + m2 - (h1 * 60 + m1);
	cout << max(ret - k,0) << endl;
	return 0;
}

Measured memory_bytes: 3636