akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,n,a);
  if(n%500<=a)puts("Yes");
else puts("No");
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val scanner = new java.util.Scanner(System.in)
  scanner.useDelimiter("")

  val input = Iterator.continually {
    if(scanner.hasNext)
      scanner.next()
    else
      null
  }.takeWhile(_ != null)
    .filter(s => ('A' to 'z').contains(s.head))

  val outputs = input.foldLeft(List.fill('z' - 'a' + 1)(0)) { (list, c) =>
    val lower = c.head.toLower
    val index = lower - 'a'

    list.updated(index, list(index) + 1)
  }.zipWithIndex

  outputs.foreach { t =>
    println(s"${('a' + t._2).toChar} : ${t._1}")
  }
}

Measured memory_bytes: 49660
#include<stdio.h>
 
int main(int argc, char* argv[])
{
  int n, b[200];
  int i, j, k, key;
 
  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    scanf("%d", &b[i]);
  }
 
  for(j = 2; j <= n; j++){
 
    for(k = 1; k < n; k++){
      printf("%d ", b[k]);
    }
    printf("%d\n", b[k]);
 
    key = b[j];
    i = j - 1;
    while(i > 0 && b[i] > key){
      b[i+1] = b[i];
      i = i - 1;
    }
    b[i+1] = key;
  }
  
   for(k = 1; k < n; k++){
      printf("%d ", b[k]);
    }
    printf("%d\n", b[k]);

  return(0);
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll i=0,count=1;
	while (a[i] != 2) {
		i = a[i] - 1;
		count++;
		if (count == a.size()) {
			cout << "-1" << endl;
			exit(0);
		}
	}
	cout << count << endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	string s;cin >> s;
	int n = s.size() - 1,m = n + 1;
	s.erase(n);
	rep(i, m) {
		if (n % 2 == 0) {
			string y = s.substr(n / 2), x = s.substr(0,n / 2);
			if (y == x) {
				cout << n << endl;
				return 0;
			}
			n--;
			s.erase(n);
		}
		else {
			n--;
			s.erase(n);
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define oprecision cout.precision(30);
#define ii int
#define ss string
#define ll long long
#define cc char
#define ff float
#define dd double
#define bb bool
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(sz, i) for (int i = 1; i <= sz; i++)
#define pb push_back
using namespace std;
ll a, b, c;
ii main() {
  speed;
  oprecision;
  /*#ifndef ONLINE_JUDGE
    freopen("outd.txt", "rt", stdin);
  #endif*/
  // code
  cin >> a >> b;
  c = max(a, b) - abs(a - b) / 2;
  if (abs(a - c) == abs(b - c))
    cout << c;
  else
    cout << "IMPOSSIBLE";
    // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 256
N, M = map(int,input().split())

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

a = cmb(N+M, 2)
print(a-N*M)

Measured memory_bytes: 3572
package main

import (
        "fmt"
        "math"
)

func solution(n, k int) float64 {

        out := 0.0
        for i := 1; i < n+1; i++ {
                if i < k {
                        x := helper(i, k)
                        out += 1 / (float64(n) * math.Pow(2, x))
                } else {
                        out += 1 / float64(n)
                }
        }
        return out
}

func helper(i, k int) float64 {
        x, out := i, 0.0
        for k > x {
                x *= 2
                out++
        }
        return out
}

func main() {
        var n, k int
        fmt.Scan(&n, &k)
        fmt.Printf("%.12f\n", solution(n, k))
}

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

using namespace std;



int main(){
  int H,W;

  cin>>H>>W;
  char grid[H][W];
  long long paths[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>grid[i][j];
      paths[i][j] = 0;
    }
  }

  paths[0][0] = 1;
  long long mod = 1e9 + 7;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(grid[i][j] == '.'){
        if(i-1>=0)
        paths[i][j] = (paths[i][j] + paths[i-1][j]%mod)%mod;
        if(j-1>=0)
        paths[i][j] = (paths[i][j] +paths[i][j-1]%mod)%mod;
      }
      else{
        paths[i][j] = (long long)0;
      }
    }
  }

  cout<<((int)(paths[H-1][W-1]%mod));

  return 0;
}


Measured memory_bytes: 12344
k =int(input())
a , b=map(int,input().split())
flag = False


for i in range(a,b+1):#range(a,b+1)=[a,a+1,a+2,.....,b]
  if i % k == 0:
    flag=True
      
if flag :
  print("OK")
else:
  print("NG")
  
  

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int n,k;
string s;
vi cnt0, cnt1;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> k >> s;

  int res = 0, temp = 0;
  queue<pair<int,int>> q;
  int c0 = 0, c1 = 0, k0 = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      if (c1 > 0) {
        temp += c1;
        q.push(mp(1,c1));
      }

      if (k0 == k) {
        chmax(res,temp);
        while (k0 >= k) {
          auto p = q.front(); q.pop();
          temp -= p.snd;
          if (p.fst == 0) k0--;
        }
      }

      c1 = 0;
      c0++;
    } else {
      if (c0 > 0) {
        temp += c0;
        q.push(mp(0,c0));
        k0++;
      }
      c0 = 0;
      c1++;
    }
  }

  if (c0 > 0) {
    temp += c0;
    q.push(mp(0,c0));
    k0++;
  }

  if (c1 > 0) {
    temp += c1;
    q.push(mp(1,c1));
  }

  while (k < k0) {
    auto p = q.front(); q.pop();
    temp -= p.snd;
    if (p.fst == 0) k0--;
  }

  chmax(res,temp);

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 768
# coding: utf-8


def main():

    n, limit = map(int, input().split(' '))
    heights = list(map(int, input().split(' ')))

    nakama_count = 0
    for height in heights:
        if height >= limit:
            nakama_count += 1

    print(nakama_count)

    return 0
    
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 11908
import math

def main():
    data = []
    while 1:
        try:
            n = input().split()
            a = int(n[0])
            b = int(n[1])
            ans = int(math.log10(a+b)+1)
            data.append(ans)
        except EOFError:
            break

    for i in data:
        print(i)

if __name__ == "__main__":
    main()

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

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

    int N, K;
    cin >> N >> K;

    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    long long sum = 0;

    for(int i = 0; i < N-K; i++){
        sum += vec[i];
    }
    cout << sum << endl;

    return 0;
}

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

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w);
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

bool sortbysecdesc(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}


void solve()
{
    int n;cin>>n;
    int a[n+1];fo(i,n)cin>>a[i+1];
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]%2==1&&i%2==1)cnt++;
    }
    print(cnt)
}

int main()
{
   // fastio();
  //  test
    solve();
}


Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(int(1e6))

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
prev = -1
for a in A:
    i = a - 1
    ans += B[i]
    if (prev + 1) == a:
        ans += C[i-1]
    prev = a

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
  int x, y;
  cin>>x>>y;

  cout<<x+y/2<<endl;

  return 0;
}


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

int main(){
	int n;
	long long ans=0;
	std::vector<long long> aList;
	std::vector<long long> expList;
	std::vector<bool> isUsed;
	std::cin>>n;
	aList.resize(n);
	expList.resize(30, 1);
	isUsed.resize(n, false);
	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	for(int i=1; i<30; i++)
		expList[i]= expList[i-1]*2;

	for(int i=29; i>=0; i--){
		std::vector<long long> deltaList(n);
		for(int j=0; j<n; j++)
			deltaList[j]= aList[j]-expList[i];
		
		std::sort(deltaList.begin(), deltaList.end());

		int left=0;
		int right= n-1;

		while(left<right){
			if(isUsed[left]){
				left++;
				continue;
			}

			if(isUsed[right]){
				right--;
				continue;
			}

			if(deltaList[left]+deltaList[right]==0){
				isUsed[left]=true;
				isUsed[right]=true;
				left++;
				right--;
				ans++;
				continue;
			}

			if(std::abs(deltaList[left]) > std::abs(deltaList[right]))
				left++;
			else
				right--;
		}
	}

	std::cout<<ans<<std::endl;

	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

const ll INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ld EPS = 1e-9;
ll dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
ll dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

//0~nの範囲操作
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//1~nの範囲操作
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
//n~0を後ろから範囲操作
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
//出力後改行を
#define fin(ans) cout << (ans) << endl;
#define all(a) a.begin(), a.end()

void Main()
{
  string s; cin >> s;
  str S = s;
  reverse(all(s));
  str q = s.substr(0, (s.size() - 1) / 2);
  str p = q;
  reverse(all(p));
  str b = s.substr((s.size() + 3) / 2 - 1);
  str d = b;
  reverse(all(d));
  if(S == s&&q == p&&b == d) fin("Yes")
  else fin("No")
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; 
	
    string s; 
    cin >> s; 
    int n = s.size() ; 
    vector<int> ans(n) ; 
    for(int i = 0 ; i < s.size() - 1; ++i) {
        if(s[i] == 'R' && s[i+1] == 'L') {
            int j = i ; 
            while(j>= 0 && s[j] == 'R') {
                if((i-j)%2 ==0)
                    ans[i]++;
                else {
                    ans[i+1]++ ; 
                }
                j--;
            }

            j = i + 1; 
            while(j < s.size() && s[j] =='L'){
                if((j-i)%2==0)
                    ans[i]++ ; 
                else 
                    ans[i+1]++;
                    j++;
            }
       }
    }
    for(int x : ans)cout << x << " " ; 
	
    return 0;
}


Measured memory_bytes: 3872
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 9999999999999
const double PI = acos(-1.0);
int N;
int a[200001];
bool vis[200001];
vector<int> v;
vector<int> r;
ll K;
ll loop;
int vs,rs;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> N >> K;
    rep2(i,1,N) cin >> a[i];

    int here = 1;
    while(!vis[here]){
        vis[here] = true;
        v.PB(here);
        here = a[here];
    }

    vs = v.size();
    rep1(i,0,vs){
        if(v[i] == here){
            rep1(j,i,vs) r.PB(v[j]);
            break;
        }
    }
    rs = r.size();

    if(K < vs){
        loop = K % vs;
        cout << v[loop];
    }
    else{
        loop = (K - vs) % rs;
        cout << r[loop];
    }
    return 0;
}


Measured memory_bytes: 6524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 998244353;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll x, ll n) {
    if (x == 1) {
        return 1;
    } else if (n == 0) {
        return 1;
    } else {
        if (n % 2 == 0) {
            return modpow(x * x % MOD, n / 2);
        } else {
            return x * modpow(x, n - 1) % MOD;
        }
    }
}

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

    ll N, M, K;
    cin >> N >> M >> K;
    COMinit();

    ll ans = 0;
    for (int i = 0; i <= K; ++i) {
        (ans += (M * modpow(M - 1, N - i - 1) % MOD) * (COM(N - 1, i) % MOD)) %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15608
/*
 *  Created on: 31 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)
#define test(t)      while(t--)

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

//const ld PI = acos(-1);
//const ll mod = 1e15 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
    ll n; cin >> n;
    vector<ll>v(n);
    for (auto& it : v)
    {
        cin >> it;
    }
    sort(all(v));
    ll ans = 1;
    for (auto a : v)
    {
        if (a == 0)
        {
            cout << 0;
            return 0;
        }

        if (a > LLONG_MAX / ans)
        {
            cout << "-1\n";
            return 0;
        }
        ans *= a;
    }
    if (ans > (ll)1e18)
    {
        cout << -1;
        return 0;
    }
    cout << ans;
}
   

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int32_t main()
{
	int x;
	cin >> x;
	int l = (360 * x / __gcd(360LL, x)) / x;
	cout << l << '\n';
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <stack>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INT_MAX 0x7FFFFFFF
#define LL_MAX 0x7FFFFFFFFFFFFFFF
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
using namespace std;
typedef long long int LL;
 
int main(){
  string S, T;
  getline(cin, S);
  getline(cin, T);
  int lS = S.size(), lT = T.size();
  int score[3005][3005] = {};
  REP(i, 3001) {
    score[0][i] = 0;
    score[i][0] = 0;
  }
  REP(i, lS) {
    REP(j, lT) {
      if(S[i] == T[j]) {
        score[i+1][j+1] = score[i][j] + 1;
      } else {
        score[i+1][j+1] = MAX(score[i+1][j], score[i][j+1]);
      }
    }
  }
  stack<char> ret;
  {
    int i = lS, j = lT;
    while(score[i][j] > 0) {
      if(score[i-1][j] == score[i][j]) {
        --i;
      } else if(score[i][j-1] == score[i][j]) {
        --j;
      } else {
        ret.push(S[i-1]);
        --i; --j;
      }
    }
  }
  while(!ret.empty()) {
    cout << ret.top();
    ret.pop();
  }
  cout << endl;
}

Measured memory_bytes: 35712
from sys import setrecursionlimit


def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j


setrecursionlimit(10 ** 5)


N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

parent = [-1] * N
friends = [[] for _ in range(N)]
for A, B in AB:
    unite(parent, A - 1, B - 1)
    friends[A-1].append(B-1)
    friends[B-1].append(A-1)
blocks = [[] for _ in range(N)]
for C, D in CD:
    blocks[C-1].append(D-1)
    blocks[D-1].append(C-1)

result = []
for i in range(N):
    p = find(parent, i)
    t = -parent[p] - 1
    t -= len(friends[i])
    for b in blocks[i]:
        if p == find(parent, b):
            t -= 1
    result.append(t)
print(*result)

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> A>>B;
	if (A == 1) {
		A = 14;
	}
	if (B == 1) {
		B = 14;
	}
	if (A > B) {
		cout << "Alice";
	}
	else if (A < B) {
		cout << "Bob";
	}
	else {
		cout << "Draw";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define mst(a,X) memset(a,X,sizeof(a))
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void _main();int main(){cin.tie(0);ios::sync_with_stdio(false);_main();}
// dp[i][2]表示从第 i [0..N-1] 个商品开始 0 表示 X先手,  1表示 Y 先手的情况
int N, Z, W, dp[2010][2];
int A[2010];
// 表示现在从id个商品为止, 当 turn = 0(1) X(Y)先手 的最大值
int f(int id, int turn, int X, int Y) {
    // 最后一个商品都选择完,则放回差值
    if (id == N) return abs(X - Y);
    // 如果已经计算过 直接返回
    if (0 <= dp[id][turn]) return dp[id][turn];
    // X先手
    if (turn == 0) {
        int ma = -1;
        // 枚举接下来
        rep(i, id, N) ma = max(ma, f(i + 1, 1 - turn, A[i], Y));
        return dp[id][turn] = ma;
    // Y先手
    } else {
        int mi = INF;
        rep(i, id, N) mi = min(mi, f(i + 1, 1 - turn, X, A[i]));
        return dp[id][turn] = mi;
    }
}
void _main() {
    cin >> N >> Z >> W;
    rep(i,0,N) cin >> A[i];
    
    rep(i,0,N) rep(j,0,2) dp[i][j] = -1;
    
    cout << f(0, 0, Z, W) << endl;
}
//----------------------------------------------------------------------------------
/*----------------------------------------------------------------------------------
    2017-11-15 14:54 
    动态规划题目,自己没有注意看题,给新生出了一个DP题,然后自己也不会做,蒻狗写不出来了
    ,找了标程补题,这当中都是泪,不说了.还是不要给新生放这题的题解了.自己都搞了好久
----------------------------------------------------------------------------------*/


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y;
    cin>>x>>y;
    cout<<x+y/2;
}   
    
    
     

     
   





Measured memory_bytes: 3656
'''
Let g(x) = 序列內數字唯一，且最多 x 個位置不同。
Let f(x) = 序列內數字唯一，且給定 x 個位置時，使這些位置不同的方法數。

題目所求是 C(N, N) f(N)。

其中 g(x) 代表有至少 N - x 個位置是相同。可以分三個部份填數字，注意順序會影響，所以要乘上全排序：
(1) N - x 個位置（數字必需相同）：C(M, N - x) * (N - x)! = P(M, N - x)
(2) 序列 A 其餘位置（可以隨便填，但不能用到 (1) 的數字）：C(M - (N - x), x) * x! = P(M - (N - x), x)
(3) 序列 B 其餘位置（可以隨便填，但不能用到 (1) 的數字）：C(M - (N - x), x) * x! = P(M - (N - x), x)
g(x) = (1) * (2) * (3)

g(x) 是「選定 0 個位置，使這些位置不同的方法數」、「選定 1 個位置，使這些位置不同的方法數」、…、「選定 N 個位置，使這些位置不同的方法數」，即

g(x) = C(x, 0) f(0) + C(x, 1) f(1) + ... + C(x, x) f(x)
     = sum( C(x, i) * f(i) for i in [0, x] )
根據二項式反演，得到
f(x) = sum( (-1) ** (x - i) * C(x, i) * g(i) for i in [0, x] )
'''

class CombMod:
    def __init__(self, V, p):
        self.fact = [1] * V
        self.finv = [1] * V
        for i in range(1, V):
            self.fact[i] = self.fact[i - 1] * i % p
        self.finv[-1] = pow(self.fact[-1], p - 2, p)
        for i in range(V - 2, 0, -1):
            self.finv[i] = self.finv[i + 1] * (i + 1) % p
        self.p = p
        
    def fact(self, a):
        return self.fact[a]
    
    def finv(self, a):
        return self.finv[a]

    def comb(self, a, b):
        return self.fact[a] * self.finv[b] % self.p * self.finv[a - b] % self.p
        
    def perm(self, a, b):
        return self.fact[a] * self.finv[a - b] % self.p
    
    def hcomb(self, a, b):
        return self.comb(a + b - 1, b)


N, M = map(int, input().split())
mod = 10**9 + 7
tool = CombMod(max(N, M) + 10, mod)

f_N = 0
for i in range(0, N + 1):
    p1 = tool.perm(M, N - i)
    p2 = tool.perm(M - (N - i), i)
    g_i = p1 * p2 % mod * p2 % mod
    val = (-1)**((N - i) % 2) * tool.comb(N, i) % mod * g_i % mod
    f_N = (f_N + val) % mod
ans = tool.comb(N, N) * f_N % mod
print(ans)


Measured memory_bytes: 48232
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
string S;
int Q;
int qtype[20202];
int i[20202], l[20202], r[20202];
char c[20202];
set<int> char_pos[30];
vector<int> ans;

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

    for (int i = 0; i < N; i++)
    {
        char si = S[i];
        char_pos[si - 'a'].insert(i);
    }

    rep(j, 0, Q)
    {
        cin >> qtype[j];
        if (qtype[j] == 1)
        {
            int i;
            char c;
            cin >> i >> c;
            i--;
            char si = S[i];
            char_pos[si - 'a'].erase(i);
            S[i] = c;
            char_pos[c - 'a'].insert(i);
        }
        else
        {
            ll l, r;
            cin >> l >> r;
            l--;
            int cnt = 0;
            for (int k = 0; k < 26; k++)
            {
                auto lb = char_pos[k].lower_bound(l);
                if (lb != char_pos[k].end() && *lb < r)
                {
                    cnt++;
                }
            }
            cout << cnt << endl;
        }
    }
}


Measured memory_bytes: 24324
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

ll YAMA[100001][2] = {};//from,to
ll T[100001],A[100001];

void rec(){
    INT(N);
    REP2(i,1,N) {
        INT(t);
        T[i] = t;
    }
    REP2(i,1,N){
        INT(a);
        A[i] = a;
    }
    
    YAMA[1][0] = T[1];
    YAMA[1][1] = T[1];
    
    YAMA[N][0] = A[N];
    YAMA[N][1] = A[N];
    
    if (T[N] != A[1]) {
        cout << '0' << endl;
        return;
    }
    
    REP2(i,2,N) {
        if (T[i-1] < T[i]) {//高くなる
            if (i == N) {
                if (T[i] != YAMA[N][0]) {
                    cout << '0' << endl;
                    return;
                }
            }else{
            YAMA[i][0] = T[i];
            YAMA[i][1] = T[i];
            }
        }else{
            if (i == N) {
                if (YAMA[N][0] > T[i]) {
                    cout << '0' << endl;
                    return;
                }
            }else{
            YAMA[i][0] = 1;
            YAMA[i][1] = T[i];
            }
        }
    }
    
    RREP2(i,N-1,1){
        if (A[i+1] < A[i]) {//高くなる
            //YAMA[i][0] = A[i];
            //YAMA[i][1] = A[i];
            if (YAMA[i][0] <= A[i] && A[i] <= YAMA[i][1]) {
                YAMA[i][0] = A[i];
                YAMA[i][1] = A[i];
            }else{
                cout << '0' << endl;
                return;
            }
        }else{//範囲が重なっていなかったら問題
            //YAMA[i][0] = 1;
            //YAMA[i][1] = A[i];
            if (YAMA[i][0] <= A[i]) {
                YAMA[i][1] = min(A[i],YAMA[i][1]);
            }else{
                cout << '0' << endl;
                return;
            }
        }
    }
    
    ll modN = 1;
    REP2(i,2,N-1){
        modN = (modN*(YAMA[i][1] - YAMA[i][0] + 1))%1000000007;
    }
    cout << modN << endl;
}

int main(){
    rec();
    
    return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
const int P = 998244353;
const int siz = 1e6+1;
#define fr(i,low,up) for(register int i = low;i <= up; ++i)
#define nfr(i,low,up) for(register int i = low;i >= up; --i)
int a[N];
int inv[siz];
int n;

inline int pow_mod(int x,int k){
   int res = 1,base = x;
   while(k){
      if(k & 1)res = 1LL*res*base%P;
      k >>= 1;
      base = 1LL*base*base%P;
   }
   return res;
}

int sum[(int)1e6+10],v[(int)1e6+10];
inline void add(int &x,int y){
   x = (x+y) >= P ? x+y-P : x+y;
}

int num[N],cnt,cntw;
int cal[2001];
int ind[(int)1e6+10];
int z[31],zcnt;

int isp[siz],prime[siz];
int cntp;
inline void Euler_Sieve(){
   isp[0] = isp[1] = 1;
   inv[1] = 1;
   fr(i,2,siz-1){
      if(!isp[i]){
         prime[++cntp] = i;
         inv[i] = pow_mod(i,P-2);
      }
      for(int j = 1;j <= cntp && i*prime[j] < siz; ++j){
         isp[i*prime[j]] = 1; inv[i*prime[j]] = 1LL*inv[i]*inv[prime[j]]%P;
         if(i%prime[j] == 0)break;
      }
   }
}

int s;
int main(){
   Euler_Sieve();
   scanf("%d",&n);
   fr(i,1,n)scanf("%d",a+i),add(v[a[i]],a[i]);
   fr(i,1,n)add(s,a[i]);
   
   fr(i,1,siz-1){
      for(register int j = i;j < siz;j += i)add(sum[i],v[j]);
   }

   int ans = 0,si;
   fr(i,1,n){
      cnt = 0;
      zcnt = 0;
      si = (int)sqrt(a[i]);
      for(int j = 1;j <= si; ++j){
         if(a[i]%j == 0){
            num[++cnt] = j,ind[j] = cnt;
            if(!isp[j])z[++zcnt] = j;
            if(j*j != a[i] && !isp[a[i]/j])z[++zcnt] = a[i]/j;
         }
      }
      for(int j = si;j > 0; --j){
         if(a[i]%j == 0 && j*j < a[i])num[++cnt] = a[i]/j,ind[a[i]/j] = cnt;
      }
      memset(cal,0,4*(cnt+1));
      nfr(j,cnt,1){
         cal[j] = sum[num[j]];
      }
      fr(w,1,zcnt){
         fr(j,1,cnt){
            if((a[i]/num[j])%z[w] == 0)add(cal[j],P-cal[ind[num[j]*z[w]]]);
         }
      }
      fr(j,1,cnt)add(ans,1LL*a[i]*cal[j]%P*inv[num[j]]%P);
   }
   printf("%d\n",1LL*(1LL*ans-s+P)*pow_mod(2,P-2)%P);
   return 0;
}


Measured memory_bytes: 23552
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int N,D,X;
    cin>>N>>D>>X;
    int* A = new int[N];
    for(int i =0;i<N;i++){
        cin>>A[i];
    }
    int ret =0;
    for(int i=0;i<D;i++){
        for (int j=0;j<N;j++){
            if(i%A[j]==0){
                ret += 1;
            }
        }
    }
    ret += X;
    cout<<ret;
    return 0;
}

Measured memory_bytes: 256
str = gets.chomp.split("")
str_downcase = []
str_upcase = []

str.each do |val|
  str_downcase << val.downcase
end

str.each do |val|
  str_upcase << val.upcase
end

ans = []

str.each_with_index do |val, ind|
  if val != str_upcase[ind]
    ans << str_upcase[ind]
  else
    ans << str_downcase[ind]
  end
end

puts ans.join

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
ll mo=998244353;

const int MAT=402;
int A[402][402];

int gf2_rank(int A[MAT][MAT]) { /* input */
	int i,j,k;
	FOR(i,H) {
		int be=i,mi=W+1;
		for(j=i;j<H;j++) {
			FOR(k,W) if(A[j][k]) break;
			if(k<mi) be=j,mi=k;
		}
		if(mi>=W) break;
		FOR(j,W) swap(A[i][j],A[be][j]);
		
		FOR(j,H) if(i!=j&&A[j][mi]) {
			FOR(k,W) A[j][k] ^= A[i][k];
		}
	}
	return i;
}

ll dp[603][603];
ll p2[3030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) FOR(x,W) cin>>A[y][x];
	if(H<W) {
		FOR(y,400) FOR(x,400) if(y<x) swap(A[y][x],A[x][y]);
		swap(H,W);
	}
	
	p2[0]=1;
	FOR(i,305) p2[i+1]=p2[i]*2%mo;
	
	x=gf2_rank(A);
	ll ret=(p2[x]+mo-1)*p2[H-x]%mo*p2[W-1]%mo;
	cout<<ret<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,k;
  cin>>n>>k;
  if(k==1 || n==k ||n%k==0)cout<<0<<endl;
  //else if(n<k)cout<<n<<endl;
  else{


   long int min =n;
   n = abs((n-k));
  //int x=1;
  vector<long long int>vec;
  std::vector<long long int>::iterator it; 
  vec.push_back(min);
  long long int x= abs(n-(k*(n/k)));
  long long int y=abs(n-(k*((n/k)+1)));

  // while(n<min)
  // {
    
  //   //cout<<n;
    
        
  //           min=n;
  //           n = abs((n-k));
  //           //cout<<min;
  //           // it = std::find (vec.begin(), vec.end(), min); 
  //           // if(it!=vec.end()){x=0;}
  //           // else vec.push_back(min);
        
        


  // }
  
  //sort(vec.begin(),vec.end());
  if(x>y)cout<<y<<endl;
  else cout<<x<<endl;}
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	string s, t;
	cin >> s;
	cin >> t;
	int n = s.size();
	int m = t.size();
	cout << (s == t.substr(0, n) && n + 1 == m ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;

signed main() {
    int n, ld, md;
    cin>>n;
    int cnt[11][11] = {};
    for (int i = 1; i <= n; i++) {
        ld = i % 10;
        md = i;
        while (md > 9) {
            md /= 10;
        }
        cnt[md][ld]++;
    }
    int ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
   Username : moondancer
   Name : Moon Dancer
*/


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

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int t1=a*c;
    int t2=a*d;
    int t3=b*c;
    int t4=b*d;
    cout<<max({t1,t2,t3,t4});
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int4(int *a1, int *a2, int *a3, int *a4) {
  scanf("%d %d %d %d", a1, a2, a3, a4);
  return 0;
}

#define X_MAX 1000
#define Y_MAX 1000

int main(void) {
    int num = get_int();
    int i, j;

    static int map[X_MAX+1][Y_MAX+1];

    for(i = 0; i < num; i++) {
        int x1, y1, x2, y2;
        get_int4(&x1, &y1, &x2, &y2);
        map[x1][y1]++;
        map[x1][y2]--;
        map[x2][y1]--;
        map[x2][y2]++;
    }

    for(i = 0; i <= X_MAX; i++) {
        for(j = 1; j <= Y_MAX; j++) {
            map[i][j] += map[i][j-1];
        }
    }
    for(i = 1; i <= X_MAX; i++) {
        for(j = 0; j <= Y_MAX; j++) {
            map[i][j] += map[i-1][j];
        }
    }

    int ans = 1;
    for(i = 0; i < X_MAX; i++) {
        for(j = 0; j < Y_MAX; j++) {
            ans = max(ans, map[i][j]);
        }
    }

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


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>


typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	string s,a,aa,ab,b="",c="";
	cin >> s;
	int n = s.size();
	a = s;
	reverse(s.begin(), s.end());
	rep(i, (n-1)/2) {
		b += a[i];
	}
	aa = b;
	reverse(b.begin(), b.end());
	for (int i = (n + 3) / 2 - 1; i < n; i++) {
		c += a[i];
	}
	ab = c;
	reverse(c.begin(), c.end());
	if (a == s && aa == b && ab == c) cout << "Yes";
	else cout << "No";
	return 0;
}









Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    if (i % 2 == 0) {
      if (s.at(i) != 'R' && s.at(i) != 'U' && s.at(i) != 'D') {
        puts("No");
        return 0;
      }
    } else {
      if (s.at(i) != 'L' && s.at(i) != 'U' && s.at(i) != 'D') {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
      
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;
int T[100005];
int main()
{
	int N, C, K;
	cin >> N >> C >> K;
	REP(i, N)
	{
		cin >> T[i];
	}
	sort(T, T + N);
	int ans = 1;
	int last = N - 1;
	IREP(i, N - 2)
	{
		if (T[i] + K < T[last] || last - i + 1 > C )
		{
			last = i;
			ans++;
			continue;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll a, b, c, k;
  ll ans;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
  for (int i = 0; i < k; i++)
  {
    ll biggest = MAX(MAX(a, b), c);
    if (a == biggest)
      a *= 2;
    else if (b == biggest)
      b *= 2;
    else
      c *= 2;
  }
  printf("%lld\n", a + b + c);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
 
int main () {
	int n;
	scanf("%d", &n);
	int AC = 0, WA = 0, TLE = 0, RE = 0;
	for (int i = 0; i < n; i++) {
		char s[6];
		scanf("%s", &s);
		if (s[0] == 'A') {
			AC++;
		}
		else if (s[0] == 'W') {
			WA++;
		}
		else if (s[0] == 'T') {
			TLE++;
		}
		else if (s[0] == 'R') {
			RE++;
		}
	}
	printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
	printf("TLE x %d\n", TLE);
	printf("RE x %d\n", RE);
	
	return 0;
}

Measured memory_bytes: 1708
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b = sc.nextInt();
        if(a<=0&&b>=0){
            System.out.println("Zero");
        } else if(a>0){
            System.out.println("Positive");
        } else {
            if(Math.abs(Math.abs(a)-Math.abs(b))%2==0){
                System.out.println("Negative");
            } else {
                System.out.println("Positive");
            }
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

ll calc_sum(vector<int> v,string S){
  vector<ll> n;
  ll res=0,tmp=0;
  rep(i,S.size()){
    if(v[i]==1){
      string s = S.substr(tmp,i+1-tmp);
      n.push_back(stoll(s));
      tmp=i+1;
    }
  }
  string s = S.substr(tmp,S.size()+1-tmp);
  n.push_back(stoll(s));
  res = accumulate(all(n),0ll);
  return res;
}

int main(){
  string S;cin>>S;
  ll ans=0;
  rep(i,S.size()){
    if(S.size()==1){ans = stoi(S);break;}
    vector<int> v(S.size()-1,1);
    rep(j,i) v[j]=0;
    do{
      ans += calc_sum(v,S);      
    }while(next_permutation(all(v)));
  }
  cout << ans << endl;
}

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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	int n; cin>>n;
	vl a(n); forn(i, n) cin>>a[i];
	sort(all(a), greater<ll>());
	ll answer = a[0];
	ll csum = n-2;
	forse(i, 1, n)
		answer += min(csum, (ll)2)*a[i], csum -= min(csum, (ll)2);
	cout<<answer<<endl;

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 4780
#include <iostream>

using namespace std;

int main()
{
    int h,n;
    int i;
    cin>>h>>n;
    for(i=0;i<n;i++)
    {
        int x;
        cin>>x;
        h-=x;
    }
    if(h>0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256