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

int main(void) {
    int n, i;
    scanf("%d",&n);
    printf("%d:",n);
    while(1) {
        for(i = 2; i * i <= n;i++ ) {
            if(!(n % i)) {
                printf(" ");
                printf("%d",i);
                n /= i;
                break;
            }
            if(i != 2) {
                i++;
            }
        }
        if(i * i > n) {
            printf(" %d\n",n);
            return 0;
        }
        if(n == 1) {
            break;
        }
    }
    puts("");
    return 0;
}

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

int n, k;
int t[102];

int score(){
  int res = 0;

  for(int i = 0; i <= n - k; i++){
    int mul = 1;
    for(int j = i; j < i + k; j++){
      mul *= t[j];
    }
    res = max(res, mul);
  }

  return res;
}

int main(){
  while(cin >> n >> k, n || k){
    for(int i = 0; i < n; i++){
      cin >> t[i];
    }

    int ans = -1;
    int before = score();

    for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
        swap(t[i], t[j]);
        int after = score();
        ans = max(ans, after - before);
        swap(t[i], t[j]);
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 868
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF INT_MAX>>1 //要climits#includ

typedef long long ll;

using namespace std;


int main(void){
	int n, k; cin >> n >> k;
	if(k==1) cout << 0 << endl;
	else cout << n - k << endl;


	return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

a = x2 - x1
b = y2 - y1

x3 = x2 - b
y3 = y2 + a
x4 = x1 - b
y4 = y1 + a

print("{} {} {} {}".format(x3, y3, x4, y4))

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

int main() {
	ios_base::sync_with_stdio( false );

	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int result = 0;

	for( int i = 0; R*i <= N; ++i ) {
		for( int j = 0; G*j <= N; ++j ) {
			int x = R*i + G*j;

			if( N >= x && (N-x) % B == 0 ) {
				result += 1;
			}
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
//Problem *
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100005;
int n,w;
ll s,dp[N];
int main(){
	scanf("%d%d",&n,&w);
	for(int i=1;i<=n;i++){
		int a;ll b;scanf("%d%lld",&a,&b);
		for(int j=w;j>=a;j--)dp[j]=max(dp[j],dp[j-a]+b);
	}
	for(int i=0;i<=w;i++)s=max(s,dp[i]);
	printf("%lld",s);
	return 0;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(obj) (obj).begin(), (obj).end()

using data = pair<ll, vl>;

int main() {

    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vl a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(all(a), greater<>()), sort(all(b), greater<>()), sort(all(c), greater<>());

    priority_queue<data> ans;
    set<data> used;
    ans.push(data(a[0] + b[0] + c[0], vl({0, 0, 0})));
    while (k-- > 0) {
        auto now = ans.top();
        ans.pop();
        cout << now.first << '\n';
        ll ia = now.second[0], ib = now.second[1], ic = now.second[2];

        data tmp;
        if (ia + 1 < a.size()) {
            tmp = data(a[ia + 1] + b[ib] + c[ic], vl({ia + 1, ib, ic}));
            if (used.find(tmp) == used.end()) {
                used.insert(tmp);
                ans.push(tmp);
            }
        }
        if (ib + 1 < b.size()) {
            tmp = data(a[ia] + b[ib + 1] + c[ic], vl({ia, ib + 1, ic}));
            if (used.find(tmp) == used.end()) {
                used.insert(tmp);
                ans.push(tmp);
            }
        }
        if (ic + 1 < c.size()) {
            tmp = data(a[ia] + b[ib] + c[ic + 1], vl({ia, ib, ic + 1}));
            if (used.find(tmp) == used.end()) {
                used.insert(tmp);
                ans.push(tmp);
            }
        }
    }
    return 0;
}

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

int main(){
 int N;
 cin >> N;
 
 vector <int> A(N-1),B(N);
 
 for(int i=0; i<N-1; i++){
   cin >> A.at(i); 
   B.at(A.at(i)-1)++;
 }
 for(int i=0; i<N; i++){cout << B.at(i) << endl;}
}
 

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

int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    int ans = min(b,d)-max(a,c); 
    if(ans < 0)cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class prog{
  static void Main(){
    
    int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = input[0];
    int a = input[1];
    int b = input[2];
    
    int plan1 = n * a;
    int plan2 = b;
    
    Console.WriteLine(Math.Min(plan1, plan2));
    
  }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    ll a, b, c; cin >> a >> b >> c;

    if(a & 1 && b & 1 && c & 1){
        cout << min({a * b, b * c, a * c}) << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {

            string read = Console.ReadLine();
            var temp_string = read.Split(' ');
            var ary = new int[] { int.Parse(temp_string[0]), int.Parse(temp_string[1]),int.Parse(temp_string[2])};

            Array.Sort(ary);

            Console.WriteLine(ary[0]+" "+ary[1]+" "+ary[2]);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	string s;
	cin >> s;
	int a = 0, c = 0;
	bool b = true;
	for (int i = 0;i < s.size();++i) {
		if (i == 0) {
			if (s[i] == 'A')++a;
		}
		else if (2 <= i && i <= s.size() - 2) {
			if (s[i] == 'C')++c;
			else if ('A' <= s[i] && s[i] <= 'Z')b = false;
		}
		else {
			if ('A' <= s[i] && s[i] <= 'Z')b = false;
		}
	}
	if (a == 1 && b && c == 1) {
		cout << "AC" << "\n";
	}
	else {
		cout << "WA" << "\n";
	}

	return 0;
}

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

int main()
{
	int a,b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0){
		cout << "Possible\n";
	}else{
		cout << "Impossible\n";
	}

	return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int answer = 0;
  bool match = false;
  for (int i = 1; i <= 1250; i++){
    if ((i*8/100 == A) && (i/10 == B)){
     match = true;
     answer = i;
     break;
    }
  }
  if(match) cout << answer << endl;
  else cout << "-1" << endl;
}

Measured memory_bytes: 256
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
N, x = gets_i_list
a_list = gets_i_list

a_list.sort.each_with_index do |a, i|
  if x - a >= 0
    x -= a
  else
    puts i
    exit
  end
end

if x == 0
  puts a_list.size
else
  puts a_list.size - 1
end

Measured memory_bytes: 4092
#include <iostream>
using namespace std;
int main(void){
    int h1,h2;
    int k1,k2;
    int a,b,c,d;
    int k,h;
    cin>>h1>>h2>>k1>>k2>>a>>b>>c>>d>>h>>k;
    h=(h1*a)+(h2*b)+((h1)*(c/10))+((h2)*(c/20));
    k=(k1*a)+(k2*b)+((k1)*(c/10))+((k2)*(c/20));
    if(h>k){
        cout<<"hiroshi"<<endl;
    }
    else if(h<k){
        cout<<"kenjiro"<<endl;
        
    }
    else if(k==h){
        cout<<"even"<<endl;
        
    }
}



Measured memory_bytes: 3100
#include <stdio.h>

int main(void) {
	int a,b,c;
	while(scanf("%d%d%d", &a,&b,&c)){
		if(a == -1 && b == -1 && c == -1) break;
		if(a == -1 || b == -1) printf("F\n");
		else if(a+b >= 80) printf("A\n");
		else if(a+b >= 65) printf("B\n");
		else if(a+b >= 50) printf("C\n");
		else if(a+b >= 30){
			if(c >= 50) printf("C\n");
			else printf("D\n");
		}
		else printf("F\n");
		
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
//    1周目は普通に最短を走る
    for (auto &&i: irange(sx, tx)){
        cout << "R";
    }
    for (auto &&i: irange(sy, ty)){
        cout << "U";
    }
    for (auto &&i: irange(sx, tx)){
        cout << "L";
    }
    for (auto &&i: irange(sy, ty)){
        cout << "D";
    }
//    2周目は下から始まる
    cout << "D";
    for (auto &&i: irange(sx, tx+1)){
        cout << "R";
    }
    for (auto &&i: irange(sy, ty+1)){
        cout << "U";
    }
    cout << "L";
    cout << "U";
    for (auto &&i: irange(sx, tx+1)){
        cout << "L";
    }
    for (auto &&i: irange(sy, ty+1)){
        cout << "D";
    }
    cout << "R";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    string S;cin>>S;
    REP(i,3){
        if(S[i]=='1')S[i]='9';
        else S[i]='1';
    }
    cout<<S<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        foreach (var x in Enumerable.Range(1, 9))
        {
            foreach (var y in Enumerable.Range(1, 9))
            {
                Console.WriteLine("{0}x{1}={2}", x, y, x * y);
            }
        }
    }
}

Measured memory_bytes: 5772
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>

int main () {
    ll n ;
    cin >> n ;
    vector<string> a(n) ;

    for(ll i = 0 ; i < n ; i++){
        cin >> a[i] ;
    }

    sort(a.begin() , a.end()) ;
    ll ans = 1 ;
    for(ll j = 0 ; j < n-1 ; j++){
       if(a[j] != a[j+1] ){
           ans ++ ;
       }
    }

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

 



Measured memory_bytes: 9604
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <sstream>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

string S;

// 124
// 124
// (1 24) (12 4)
// (1 2 4) (12 4)
void input() {
  cin >> S;
}

Int dfs(string s) {
  stringstream ss(s);
  Int x = 0;
  ss >> x;
  if (s.length() == 1) return x;
  loop(n,1,s.length()) {
    string left = s.substr(0, n);
    string right = s.substr(n);
    stringstream ss2(left); Int leftNum = 0; ss2 >> leftNum;
    Int rightNum = dfs(s.substr(n));
    // 1 + 23
    // 1 + 2 + 3
    // here '1 +' is added twice. (Twice is the number of cases)
    x += leftNum * pow(2, right.length()-1) + rightNum;
  }
  return x;
}

void solve() {
  cout << dfs(S) << endl;
}

int main(void) {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int D[10];
int K; 
bool isOk(int num) {
    while(num > 0) {
        int k = num % 10;
        num /= 10;
        rep(i, K) {
            if (k == D[i]) return false;
        }
    }
    return true;
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cin >> K;
    rep(i, K) cin >> D[i];
    while(true) {
        if (isOk(N)) {
            cout << N << endl;
            break;
        }
        N++;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int L[200010];
int R[200010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, C;
    cin >> N >> K >> C;
    string S; cin >> S;
    int cnt = K;
    for(int i = 0; i < S.length(); i++) {
        if (S[i] == 'o') {
            L[i] = cnt;
            i += C;
            cnt--;
        }
    }
    if(cnt < 0) return 0;
    cnt = K;
    for(int i = S.length() - 1; i >= 0; i--) {
        if (S[i] == 'o') {
            R[i] = cnt;
            i -= C;
            cnt--;
        }
    }
    if(cnt < 0) return 0;
    // rep(i, S.length()) cout << L[i] << " ";
    // cout << endl;
    // rep(i, S.length()) cout << R[i] << " ";
    // cout << endl;
    rep(i, S.length()) {
        if(L[i] && R[i]) cout << i + 1 << endl;
    }


    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S;
	ll w;
	cin >> S >> w;
	REP(i, (S.size()-1)/w+1){
		cout << S[w*i];
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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(b<a){a=b;return 1;}return 0;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll P[N+1],A[N+1],B[N+1];
  RREP(i,N){
    ll a;
    cin>>a;
    P[a]=i;
  }
  RREP(i,N) A[i]=N*i;
  
  ll X=N*N+1-P[N];  
  B[N]=1;
  RREP(i,N-1) B[i]=P[i]+X-A[i];
  
  RREP(i,N){
    if(i<N) cout<<A[i]<<" ";
    else cout<<A[i]<<endl;
  }
  RREP(i,N){
    if(i<N) cout<<B[i]<<" ";
    else cout<<B[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>

#define div 1000000000+7

typedef long long ll;

using namespace std;


int main() {
    int n;
    long t;
    long before = 0, after;
    ll x = 0;

    cin >> n >> t;
    for(int i = 0; i < n; i++){
        cin >> after;
        long temp = after-before;
        if(after == 0) {
        }else if(temp > t){
            x += t;
            before = after;
        }else{
            x += temp;
            before = after;
        }
        //cout << x << endl;
    }
    x += t;
    cout << x << endl;

}

Measured memory_bytes: 384
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)150000 + 5;
using namespace std;

int s[505][505];

int main()
{
	int n, m, q; scanf("%d %d %d", &n, &m, &q);
	int l, r;
	for(int i = 1; i <= m; i++){
		scanf("%d %d", &l, &r);
		s[l][r]++;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			s[i][j] += s[i-1][j] + s[i][j-1] - s[i-1][j-1];
		}
	}
	while(q--){
		scanf("%d %d", &l, &r);
		printf("%d\n", s[r][r] - s[r][l-1] - s[l-1][r] + s[l-1][l-1]);
	}
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstring>
//#include <fstream>

const int N = 10000000;

bool prime[N+1];

using namespace std;

void make_prime (void )
{
	memset (prime, true, sizeof (prime ) );

	prime[0] = false;
	prime[1] = false;

	for (int i = 2; i*i <= N; ++i){
		if (prime[i] ) {
			for (int j = i*i; j <= N; j += i ){
				prime[j] = false;
			} // end for
		} // end if	
	} // end for
}
	
int main()
{
//	cut here before submit 
//	freopen ("testcase.primequad", "r", stdin );

	make_prime();

	int n;
	while (cin >> n && n ){
		for (int i = n; i >= 13; --i ){
			if (prime[i] && prime[i-2] && prime[i-6] && prime[i-8] ){
				cout << i << endl;
				break;
			} // end if
		} // end for
	} // end loop
		
	return 0;
}

Measured memory_bytes: 10000
#include <iostream>
typedef long long int ll;


int main(void){
	int N;
	ll res = 1, a, max_value = 1000000000000000000;
	std::cin >> N;
	
  	bool ok = true;
	for(int i = 0; i < N; i++){
		std::cin >> a;
      	if(a==0){
        	std::cout<<0<<std::endl;
          	return 0;
        }
      	if(!ok) continue;
      	if(res > max_value / a){
        	ok=false;
        }
	    res *= a;
	}
	
	std::cout << (ok ? res : -1 ) << std::endl;
	return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  string s;
  int K;
  cin >> s >> K;
  int l = s.size();

  int k = 0;
  int cnt = 0;
  vector<string> dic2;


  while(cnt < K){
  	vector<string> dic;
    for(int i=0;i<l;i++){    
      if(s[i]=='a'+k){
        for(int j=1;i+j-1<l && j<=K;j++){
          dic.push_back(s.substr(i,j));
        }
      } 
    }
    if(!dic.empty()){
    	sort(dic.begin(),dic.end());
	    int dic_length = dic.size();

	    dic2.push_back(dic[0]);

	    for(int x=0;x<dic_length;x++){
	      if(dic2.back()!=dic[x]) dic2.push_back(dic[x]);
	    }
	    cnt = dic2.size();
    }
    k++;
  }


  //sort(dic2.begin(),dic2.end());



  /*for(int i=0;i<K;i++){
    cout << dic2[i] <<endl;
  }*/
  cout << dic2[K-1] <<endl;
  

  return 0;
}

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

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

const long long INF = 1LL << 60;


int main(void){
	int x,y,z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;


	return 0;
}



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

using namespace std;

int main(void)
{
	int x; cin>>x;
	
	int gohyaku = x / 500;
	x = x%500;
	int gomai = x/5;
	
	cout<<gohyaku*1000+gomai*5<<endl;
	return 0;
}



Measured memory_bytes: 256
class Calc:
    def __init__(self, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def nCr(self, n, r):
        r = min(n - r, r)
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod

    def nHr(self, n, r):
        return self.nCr(n - 1 + r, r)


def main():
    from itertools import accumulate
    MOD = 998244353

    N, M, K = map(int, input().split())

    cc = Calc(max_value=N, mod=MOD)
    *m_1, = accumulate([1] + [M - 1] * (N - 1), func=lambda a, b: a * b % MOD)

    ans = 0
    for bond in range(K + 1):
        t = cc.nCr(N - 1, bond)  # 結合位置の候補を左側のブロック総数N-1個からbond個選ぶ
        t = t * m_1[N - 1 - bond] % MOD  # N-bond個の相異なる色で塗り分けたときの2個目以降の色の塗り方
        ans = (ans + t) % MOD
    ans = ans * M % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 34820
#include <iostream>
#include <cstdio>
#define MAX_L 12
using namespace std;
char table[MAX_L][MAX_L];
int fdx[] = {1, 0, -1, 0}, fdy[] = {0, 1, 0, -1};


void dfs(int y, int x) {
    if(x < 0 || x >= MAX_L || y < 0 || y >= MAX_L || table[y][x] == '0') return;
    table[y][x]--;
    for(int r = 0; r < 4; r++) {
        dfs(y + fdy[r], x + fdx[r]);
    }
    return;
}

int main(void) {
    while(true) {
        for(int r = 0; r < MAX_L; r++) {
            if(scanf("%s", table[r]) == EOF) return(0);
        }
        int cnt = 0;
        for(int r = 0; r < MAX_L; r++) {
            for(int c = 0; c < MAX_L; c++) {
                if(table[r][c] == '1') {
                    dfs(r, c);
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return(0);
}

Measured memory_bytes: 1160
package main

import "fmt"

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}
func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	if abs(x-a) < abs(x-b) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using namespace std;
//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; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000


int main() {
 
    int n,k;
    cin >> n >> k ;
    int tindex,num;
	double tmax,tmp;
	double d ;
    vector<double> p(n) ;
    vector<double> a(n+1,0);

    for(int i=0; i < n; i++){
        cin >> p[i];
		p[i] = (p[i] + 1) /2 ;
        a[i+1]=a[i] + p[i];
    }

	tmp = 0;

	for(int i = 0; i < a.size()-k; i++){
	    
	    //if(a[i+k]-a[i] > tmp){
            tmp = std::max(a[i+k]-a[i],tmp);
		//	tmax = tmp;
	    //}
		

		//if(tmax > tmp) d = accumulate(a.begin()+i,a.begin()+i+k,0);
	}

	cout << setprecision(10) << tmp << endl;
}


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

#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rnd(time(0));
#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("avia.in", "r", stdin); freopen("avia.out", "w", stdout);
#define _GLIBCXX_DEBUG
#define s second
#define f first
#define pb push_back
#define add insert
#define del erase
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define res resize
#define PI acos(-1)
const ll INF = 1e9;//9223372036854775807L; //LONG_MAX;
constexpr ll mod = 1e9 + 7;

vector<vector<int>> graph;
vector<int> deepA, deepB;

void dfs1(int v, int par) {
    if (par != -1)deepA[v] = deepA[par] + 1;
    for (auto to : graph[v]) if (to != par)dfs1(to, v);
}
void dfs2(int v, int par) {
    if (par != -1)deepB[v] = deepB[par] + 1;
    for (auto to : graph[v]) if (to != par)dfs2(to, v);
}

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    graph.res(n), deepA.res(n, 0), deepB.res(n, 0);
    for (int i = 0; i < n-1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        graph[x].pb(y);
        graph[y].pb(x);
    }
    dfs1(a - 1, -1);
    dfs2(b - 1, -1);
    int mx = -1;
    for (int i = 0; i < n; i++) {
        if (deepB[i] > deepA[i]) {
            mx = max(mx, deepB[i]);
        }
    }
    cout << mx-1 << '\n';


}

signed main() {
    ioss
    //file
    //id.resize(3e5);
    int t = 1;                                                                                                                                                                        //ll
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 10368
N,K=map(int,input().split())
E=[[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  E[a-1].append(b-1)
  E[b-1].append(a-1)

DIV=10**9+7
ans=1
stack=[]
# 番号、選べる色、親フラグ（初回だけ全色選べる）
stack.append([0,K,-1])
while stack:
  node=stack.pop()
  v=node[0]
  color=node[1]
  parent=node[2]
  ans=((ans%DIV)*color)%DIV
  nextcolor=K-2
  if parent==-1:
    nextcolor=K-1
  children=E[v]
  for child in children:
    if child==parent:
      continue
    if nextcolor==0:
      ans=0
      break
    stack.append([child,nextcolor,v])
    nextcolor-=1
else:
  print(ans)


Measured memory_bytes: 35376
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>
#include<math.h>


using namespace std;

int main(){
	int G[60][60]={},ans[60][60]={};
	int h,w;

	cin>>h>>w;
	string p;
	for(int i=0;i<h;i++)
	{
		cin>>p;
		for(int j=0;j<w;j++)
			G[i][j]=p[j]-'0';
	}
	for(int i=0;i<w;i++)
	{
		ans[0][i]=G[0][i];
		if(i>0)ans[0][i]+=ans[0][i-1];
	}
	for(int i=0;i<h;i++){
		ans[i][0]=G[i][0];
		if(i>0)ans[i][0]+=ans[i-1][0];
	}

	for(int i=1;i<h;i++){//cout<<endl;
		for(int j=1;j<w;j++)
		{
			int x=ans[i-1][j];
			if(ans[i-1][j]>ans[i][j-1])x=ans[i][j-1];
			ans[i][j]+=x+G[i][j];
			//cout<<ans[i][j];
		}
	}
	/*
	for(int i=0;i<h;i++){cout<<endl;
		for(int j=0;j<w;j++)
		{
			cout<<ans[i][j];
		}
	}
	*/

	cout<<ans[h-1][w-1]<<endl;
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    
    int A, B;
    cin >> A >> B;
    
    int ans = 0;
    for(int i = A; i <= B; i++){
        string S = to_string(i);
        if(S[0] == S[4] && S[1] == S[3]) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define pii pair<ll,ll>
#define list vector<ll>
#define mp make_pair
#define vp vector< pair<ll,ll> >
#define in insert
#define pb push_back
#define ft first
#define sd second
#define matrix vector< vector<ll> >
#define all(x) x.begin(),x.end()
#define line string
#define rall(x) x.rbegin(),x.rend()
#define f(i,n) for(ll i=1;i<=n;i++) 
ll mod=(ll)(1e9+7);
ll po(ll a,ll b,ll c)
{ll printst=1;while(b){if(b&1){printst=(printst*a)%c;}b=b>>1;a=(a*a)%c;}return printst ;}            // :p (a^b)%c   po(a,b,c)
ll gcd(ll a,ll b){return __gcd(a,b);}                   // :p gcd(a,b)
bool isprime(ll x){if(x==2)return true ;if(x%2==0||x==1||x==0)return false ;ll i=3;  // :p isprime(x)
while(i*i<=x){if(x%i==0)break;i+=2;}if(i<x&&x%i==0)return false ;return true ;}
struct cmp
{
	bool operator()(ll a,ll b)
	{
		return a>b;
	}
};
map<ll,ll>M;
/*ll ed=0;
vector<ll>g[160000];
ll v[160000];
ll dfs(ll u)
{
	ll ans=0;v[u]=1;
	for(ll i=0;i<g[u].size();i++)
	{
		ed++;
		if(v[g[u][i]]==0)ans+=dfs(g[u][i]);
	}
	return ans+1;
}*/
ll arr[111111],a[111111];
ll d[111111][2];
ll solve(ll n,ll fl)
{
	if(n==0)return 0;
	if(d[n][fl]!=-1)return d[n][fl];ll ans=INT_MAX;
	if(fl==1)
	{
		if(a[n]<=a[n+1])ans=solve(n-1,1);
		else ans=1+min(solve(n-1,0),solve(n-1,1));
	}
	else
	{
		if(a[n]>=a[n+1])ans=solve(n-1,0);
		else ans=1+min(solve(n-1,0),solve(n-1,1));
	}
	return d[n][fl]=ans;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	memset(d,-1,sizeof(d));
	ll cnt=1;
	ll n;cin>>n;
	for(ll i=1;i<=n;i++)cin>>a[i];
	cout<<1+(min(solve(n-1,0),solve(n-1,1)))<<endl;
	return 0 ;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll mod = 998244353;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  N %= 10;
  if (N==2||N==4||N==5||N==7||N==9) cout << "hon" << endl;
  else if (N==0||N==1||N==6||N==8) cout << "pon" << endl;
  else cout << "bon" << endl;
  return 0;
}

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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int cnt0 = 0;
    int cntN = 0;
    for (int i = 0; i < M; i++){
        int A;
        cin >> A;
        if (A < X){
            cnt0++;
        }
        else {
            cntN++;
        }
    }
    cout << min(cnt0, cntN) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int H, W; cin >> H >> W;
  vector<vector<char>> S(H, vector<char> (W));
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < S.at(i).size(); j++) {
      cin >> S.at(i).at(j);
    }
  }
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < S.at(i).size(); j++) {
      if(S.at(i).at(j) == '.') continue;
      if((i > 0 && S.at(i - 1).at(j) == '.') && (j > 0 && S.at(i).at(j - 1) == '.')
        && (i < H - 1 && S.at(i + 1).at(j) == '.') && (j < H - 1 && S.at(i).at(j + 1) == '.')) {
          cout << "No" << endl;
          return 0;
        }
    }
  }
  cout << "Yes" << endl;
}

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

int p[5009];	

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; string s; cin >> n >> s;
	int ans = 0;
	while (n) {
		int r = 0, ri = 0;
		for (int i = 1; i < n; i++) {
			if (i <= r) p[i] = min(p[i - ri], r - i);
			else p[i] = -1;
			while (i + p[i] + 1 < n && s[i + p[i] + 1] == s[p[i] + 1]) p[i]++;
			if (r < i + p[i]) {
				r = i + p[i];
				ri = i;
			}
			ans = max(ans, min(i, p[i] + 1));
		}
		for (int i = 0; i < n - 1; i++)
			s[i] = s[i + 1];
		n--;
	}
	cout << ans << '\n';
	return 0;
}	

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') ch=getchar(),o=-1;
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,s1=0,s2=0,s3=0,x;
    cin>>n;
    for(int i=1;i<=n;i++) {
	x=gi();
	if(x%4==0) s3++;
	else if(x%2==0) s2++;
	else s1++;
    }
    if(s1<=s3||(s1==s3+1&&!s2)) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 384
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
namespace loquat {
template <typename T>
static std::pair<T, T> extended_gcd(T a, T b){
	if(b == 0){ return std::pair<T, T>(1, 0); }
	const auto p = extended_gcd(b, a % b);
	return std::pair<T, T>(p.second, p.first - a / b * p.second);
}
}
namespace loquat {
template <int MOD>
class modulus_integer {
public:
	typedef modulus_integer<MOD> self_type;
private:
	int m_value;
	static self_type unsafe_construct(int x){
		self_type y;
		y.m_value = x;
		return y;
	}
public:
	modulus_integer()
		: m_value(0)
	{ }
	modulus_integer(int x)
		: m_value(x % MOD)
	{
		if(m_value < 0){ m_value += MOD; }
	}
	int operator*() const { return m_value; }
	self_type& operator=(const self_type& x){
		m_value = x.m_value;
		return *this;
	}
	bool operator==(const self_type& x) const {
		return m_value == x.m_value;
	}
	self_type operator+(const self_type& x) const {
		const int y = m_value + x.m_value;
		return unsafe_construct(y >= MOD ? y - MOD : y);
	}
	self_type operator*(const self_type& x) const {
		return unsafe_construct(
			static_cast<long long>(m_value) * x.m_value % MOD);
	}
	self_type operator/(const self_type& x) const {
		return (*this) * self_type(extended_gcd(x.m_value, MOD).first);
	}
	self_type& operator+=(const self_type& x){
		return (*this = *this + x);
	}
};
template <int MOD>
inline std::ostream& operator<<(
	std::ostream& os, const modulus_integer<MOD>& x)
{
	os << *x;
	return os;
}
}
using namespace std;
using mint = loquat::modulus_integer<1000000007>;
static const int MAX_N = 1000;
int main(){
	ios_base::sync_with_stdio(false);
	vector<mint> factorial(MAX_N + 1), inv_factorial(MAX_N + 1);
	factorial[0] = inv_factorial[0] = mint(1);
	for(int i = 1; i <= MAX_N; ++i){
		factorial[i] = factorial[i - 1] * mint(i);
		inv_factorial[i] = mint(1) / factorial[i];
	}
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	vector<mint> cur(n + 1);
	cur[0] = mint(1);
	for(int i = a; i <= b; ++i){
		vector<mint> next(cur);
		for(int j = 0; j < n; ++j){
			if(cur[j] == mint(0)){ continue; }
			const int r = n - j, lim = r / i;
			vector<mint> local(lim + 1);
			local[0] = mint(1);
			for(int k = 0; k < lim; ++k){
				const int rr = r - k * i;
				const auto comb =
					factorial[rr] * inv_factorial[rr - i] * inv_factorial[i];
				local[k + 1] = local[k] * comb;
			}
			for(int k = c; k <= lim && k <= d; ++k){
				const int jj = j + k * i;
				next[jj] += cur[j] * local[k] * inv_factorial[k];
			}
		}
		cur = std::move(next);
	}
	cout << cur[n] << endl;
	return 0;
}


Measured memory_bytes: 256
//
// Created by Abhishek Bansal on 9/01/2020.
//
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<vector<int>> v(200001);
vector<bool> visited(200001);
void dfs(int i, int& cnt) {
    visited[i] = true;cnt++;
    for(int j: v[i]) {
        if (!visited[j]) dfs(j, cnt);
    }
}

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

    int n, m; cin >> n >> m;
    for(int i=0;i<m;i++) {
        int a, b; cin >> a >> b;
        v[a].push_back(b);v[b].push_back(a);
    }int ma = -1;
    for(int i=1;i<=n;i++) {
        int cnt =0;
        if (!visited[i]) {dfs(i, cnt);ma = max(ma, cnt);}
    }
    cout << ma;
//    string s, t; cin >> s >> t;
//    for(int i=0;i<s.length();i++) {
//        if (t[0] == s[i]) {
//
//        }
//    }

    return 0;
}

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

using namespace std;


int main() {

    int R, G, B, N;
    cin >> R >> G >> B >> N;
    long long ans = 0;
    int MAX = N + 1;
    for (int i = 0; i <= N / R; ++i) {
        int r = i * R;
        if (r > N){ break;}
        for (int j = 0; j <= N/ G; ++j) {
            if (i * R + j * G > N ){break;}
            long long balls = i * R + j * G;
            if ((N - balls) % B == 0 && (N - balls) / B >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])
ans = 1
first = T[0]
pas = 0
for t in T:
    pas += 1
    if t > first + k or pas > c:
        ans += 1
        pas = 1
        first = t
print(ans)

Measured memory_bytes: 14040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

int N;
vector<int> A;
vector<int> B;
vector<bool> seen;
vector<bool> seen1;
map<int, int> m;
int s;
int dividing = 0;
int cnt = 0;

void dfs(int v) {
    seen[v] = true;
    m[cnt] = v;
    B[v] = cnt;
    cnt++;

    if (seen[A[v]]) {
        s = A[v];
        return;
    }
    dfs(A[v]);
}

void when(int v) {
    seen1[v] = true;
    dividing++;
    if (seen1[A[v]]) return;
    when(A[v]);
}

int main() {
    cin >> N;
    ll K; cin >> K;
    A.resize(N + 1);
    B.resize(N + 1);
    seen.assign(N + 1, false);
    seen1.assign(N + 1, false);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
    }
    dfs(1);

    when(s);
    if (K <= B[s]) {
        cout << m[K] << endl;
    } else {
        cout << m[B[s] + ((K - B[s]) % dividing)] << endl;
    }
    return 0;
}

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

int main()
{
    int a,b,ans,c,temp=0;
    cin>>a>>b;

    c=max(a,b);
    for(int i=1;i<=c;i++)
    {
        if(abs(a-i)==abs(b-i))
        {
            ans = i;
            temp = 1;
            break;
        }

    }
    if(temp == 1)
        cout<<ans<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int a=0;
    int b=0;
    int num=0;

    cin >> a >> b;

    num=a*b;

    if((num*1)%2!=0)cout << "Yes" << endl;
    else if((num*2)%2!=0)cout << "Yes" << endl;
    else if((num*3)%2!=0)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ld W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << fixed << setprecision(2) << W * H / 2 << " ";
    if(x == W / 2 && y == H / 2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

const int N=5e5+10;

template<typename T>
struct Fenwick{
    vector<T> tree;
    Fenwick(int n){
        tree.resize(n);
    }

    T query(int i){
        int sum=0;
        while(i){
           sum+=tree[i];
           i-=i&(-i);
       }  
       return sum;
    }
    void update(int i,int n,T val){
       while(i<=n){
          tree[i]+=val;
          i+=i&(-i);
       }
    }
};


int solve(){
 	int n,q;cin>>n>>q;
 	vector<int>a(n+1);
 	rep(i,1,n+1){
 		cin>>a[i];
 	}
 	Fenwick<int>fn(n+1);
 	vector<int>last(n+1,-1),ans(q+1);
 	vector<pii>vec[n+1];
 	rep3(q){
 		int l,r;cin>>l>>r;
 		vec[r].pb({l,i});
 	}
 	for(int i=1;i<=n;i++){
 		fn.update(i,n,1);
 		if(last[a[i]]!=-1){
 			fn.update(last[a[i]],n,-1);
 		}
 		last[a[i]]=i;
 		int val=fn.query(i);
 		for(auto j:vec[i]){
 			ans[j.y]=val-fn.query(j.x-1);
 		}
 	}
 	for(int i=0;i<q;i++){
 		cout<<ans[i]<<endl;
 	}
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 44192
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;

using namespace std;

int main(){
    int n, tmp, chk=0;
    cin >> n;

    if(n<1 || n>100){
        chk=1;
    }

    int a[n];

    REP(i, n){
        cin >> tmp;
        if(tmp<1 || tmp>1000){
            chk=1;         
        }
        if(tmp%2 == 0){
            if(tmp%3==0){
            }
            else if(tmp%5==0){
            }
            else{
                chk=1;
            }
        }
    }

    if(chk==0){
        printf("APPROVED");
    }else if(chk==1){
        printf("DENIED");
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ab = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1])

    num=1
    while num < n:
        num *= 2
    num-=1
    inf=10**9+1

    m=num+n
    segtree=[inf]*m
    for i in range(num,m):
        segtree[i] = ab[i - num][0]
    for i in range(num-1,-1,-1):
        j=2*i+1
        if j>=m:
            segtree[i]=inf
        elif j+1>=m:
            segtree[i]=segtree[j]
        else:
            segtree[i] = min(segtree[j], segtree[j + 1])

    #探す
    def search(i, s):
        if i >= num:
            return i - num
        k = 2 * i + 1
        if k+2<=m:
            if segtree[k+1] <= s:
                return search(k+1, s)
        if 2*i+2<=m:
            if segtree[k] <= s:
                return search(k, s)
        return -1
    
    #更新
    def update_good(i, s):
        if segtree[i] > s:
            segtree[i] = s
            update_good((i - 1) // 2, s)
    
    def update_bad(i):
        k=(i - 1) // 2
        if i % 2 == 1:
            if m > i + 1:
                temp=min(segtree[i+1],segtree[i])
                if segtree[k]<temp:
                    segtree[k] = temp
                    update_bad(k)
            else:
                segtree[k] = segtree[i]
                update_bad(k)
        else:
            if i != 0:
                temp=min(segtree[i-1],segtree[i])
                if segtree[k]<temp:
                    segtree[k] = temp
                    update_bad(k)

    cnt = 0
    for i in range(n):
        a,b=ab[i][0],ab[i][1]
        if a > b:
            t = search(0, b)
            if t <= i:
                print("No")
                return 0
            update_good(num + i, a)
            segtree[num + t] = a
            update_bad(num + t)
            ab[i][0], ab[t][0] = ab[t][0], a
            cnt+=1
    if cnt <= n - 2:
        print("Yes")
    else:
        print("No")
    
main()

Measured memory_bytes: 25136
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
def MAP(): return map(int, input().split())

def remove_left(M, c):
	for i in range(len(M)):
		M[i] = M[i][c:]
	return M

def remove_bottom(M, c):
	M = M[:len(M)-c]
	return M

def reverse_tate(M):
	for i in range(len(M)//2):
		for j in range(len(M[0])):
			M[i][j], M[-1-i][j] = M[-1-i][j], M[i][j]

	return M
def reverse_yoko(M):
	for i in range(len(M)):
		M[i] = M[i][::-1]
	return M


def turn_left(M, c):
	if c > len(M[0])/2:
		M = reverse_yoko(M)
		c = len(M[0]) - c
	for i in range(len(M)):
		for j in range(c):
			M[i][c+j] += M[i][c-1-j]
	M = remove_left(M, c)
	return M

def turn_bottom(M, c):
	if c > len(M)/2:
		M = reverse_tate(M)
		c = len(M) - c
	for i in range(len(M[0])):
		for j in range(c):
			M[len(M)-c-1-j][i] += M[len(M)-c+j][i]
	M = remove_bottom(M, c)
	return M

ans = []
while 1:
	n, m, t, p = MAP()
	if (n, m, t, p) == (0, 0, 0, 0):
		break

	dc = [LIST() for _ in range(t)]
	xy = [LIST() for _ in range(p)]

	M = [[1]*n for _ in range(m)]
	for d, c in dc:
		if d == 1:  # 左->右
			M = turn_left(M, c)
		else:  # 下->上
			M = turn_bottom(M, c)

	for x, y in xy:
		ans.append(M[-1-y][0+x])

for i in ans:
	print(i)
	


Measured memory_bytes: 5792
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l_vec;
    for(int i = 0; i < n; i++){
        int lin;
        cin >> lin;
        l_vec.push_back(lin);
    }

    sort(l_vec.begin(), l_vec.end(), greater<int>());
    
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += l_vec[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256