akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

ll powmod(ll a, ll p) {
	ll ans = 1;
	ll mul = a;
	for (; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
		if ((p & 1) == 1)ans = (ans * mul) % MOD;
	}
	return ans;
}


vll fact;//階乗
vll revFact;//階乗の逆元
void setFact(int N) {
	fact = vll(N);
	revFact = vll(N);
	fact[0] = 1;
	FOR(i, 1, N) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}
	revFact[N - 1] = powmod(fact[N - 1], MOD - 2);
	REPR(i, N - 1) {
		revFact[i] = revFact[i + 1] * (i + 1);
		revFact[i] %= MOD;
	}
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int ind1 = -1;
	int ind2 = -1;
	vi B(N,-1);
	REP(i, N + 1) {
		int a;
		cin >> a;
		a--;
		if (B[a] != -1) {
			ind1 = B[a];
			ind2 = i;
			break;
		}
		B[a] = i;
	}
	assert(ind1 != -1);
	setFact(N + 2);
	FOR(k, 1, N + 2) {
		ll ans = ((fact[N+1] * revFact[k]) % MOD) * revFact[N - k + 1] % MOD;
		int dcnt = ind1 + (N - ind2);
		if (dcnt >= k - 1) {
			ans -= ((fact[dcnt] * revFact[k-1]) % MOD) * revFact[dcnt - k + 1] % MOD;
		}
		if (ans < 0)ans += MOD;
		ans %= MOD;
		cout << ans << endl;

	}
	PAU;
	return 0;
}


Measured memory_bytes: 3448
#include <iostream>
#include <set>

int main(){
    int n, tmp[2];
    std::set<int> tt;
    
    std::cin >> n;
    while(n--){
        std::cin >> tmp[0] >> tmp[1];
        tt.insert(tmp[0] * 60 + tmp[1]);
    }
    std::cin >> n;
    while(n--){
        std::cin >> tmp[0] >> tmp[1];
        tt.insert(tmp[0] * 60 + tmp[1]);
    }
    
    for(auto it = tt.begin(); it != tt.end(); ++it){
        printf("%s%d:%02d", it != tt.begin() ? " " : "", *it / 60, *it % 60);
    }
    
    printf("\n");
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
 int n,W;
 cin>>n>>W;
 int w[n],v[n];
 for(int i=0;i<n;i++)
 {
     cin>>w[i]>>v[i];
 }
 int dp[n][W+1];
 for(int i=0;i<n;i++)
 {
     dp[i][0]=0;
 }
 for(int i=0;i<=W;i++)
 {
     if(i>=w[0])
     dp[0][i]=v[0];
     else
     dp[0][i]=0;
 }
 for(int i=1;i<n;i++)
 {
    for(int j=1;j<=W;j++)
    {
        if(j<w[i])
        dp[i][j]=dp[i-1][j];
        else
        dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
    }
 }
 cout<<dp[n-1][W]<<endl;
}

Measured memory_bytes: 78336
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

int main(void) {
    string s;
    cin >> s;
    int n = s.length();
    bool ans = true;
    for (int i = 0; i < n / 2; i++) {
        ans &= s[i] == s[n - 1 - i];
    }

    for (int i = 0; i < (n - 1) / 4; i++) {
        ans &= s[i] == s[ (n - 1) / 2 - 1 - i];
    }

    for (int i = 0; i < (n - 1) / 4; i++) {
        ans &= s[(n + 3) / 2 - 1 + i] == s[n - 1 - i];
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	for(int n,m,p;cin>>n>>m>>p,n|m|p;){
		int x[n],sum=0;
		for(int i=0;i<n;i++){
			cin>>x[i];
			sum+=x[i];
		}
		
		if(x[m-1]==0)
			cout<<0<<endl;
		else
			cout<<sum*(100-p)/x[m-1]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for (int i = 1; ; i++) {
		int x;
		cin >> x;
		if (x == 0) break;
		cout << "Case " << i << ": " << x << endl;
	}
	return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;

int main() {
    int n[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << n[k-1]<<endl;
}

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

int isprime(int N){
  int S=(int)sqrt(N);
  int Ans=1;
  if(N==1){
    return 0;
  }
  for(int i=2; i<=S; i++){
    if(N%i==0){
      Ans=0;
      break;
    }
  }
  return Ans;
}

int main(){
  int Q;
  cin >> Q;
  vector<int> L(Q), R(Q);
  for(int i=0; i<Q; i++){
    cin >> L.at(i) >> R.at(i);
  }
  vector<int> Numprime(100000);
  Numprime.at(1)=0;
  for(int i=3; i<100000; i+=2){
    if(isprime(i)==1 && isprime((i+1)/2)==1){
      Numprime.at(i)=Numprime.at(i-2)+1;
    }
    else{
      Numprime.at(i)=Numprime.at(i-2);
    }
  }
  for(int i=0; i<Q; i++){
    cout << Numprime.at(R.at(i))-Numprime.at(max(L.at(i)-2, 1)) << endl;
  }
}

Measured memory_bytes: 1792
using System;

namespace AOJ.ITP
{
    public class Circle
    {
        public static void Main()
        {
            double r = double.Parse(Console.ReadLine());
            double area = Math.PI * r * r;
            double cir = 2 * Math.PI * r;

            Console.WriteLine(string.Format("{0:0.00000} {1:0.00000}", area, cir));
        }
    }
}

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

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

  if (S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  };

  string sub = S.substr(2, S.size() - 3);
  if (count(sub.begin(), sub.end(), 'C') != 1) {
    cout << "WA" << endl;
    return 0;
  }

  rep(i, 1, S.size()) {
    if (S[i] != 'C' && isupper(S[i])) {
      cout << "WA" << endl;
      return 0;
    }
  }

  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 3600
# 03
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


N, M, K = LI()

for i in range(N+1):
    for j in range(M+1):
        if i*(M-j) + j*(N-i) == K:
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 64536
#include <stdio.h>
#include <string.h>

int main() {
    char sa[100+1], sb[100+1], sc[100+1];
    scanf("%s %s %s", sa, sb, sc);

    int ca = 0, cb = 0, cc = 0;
    int la = strlen(sa), lb = strlen(sb), lc = strlen(sc);
    char sta = 'a';

    while (1) {
        switch (sta) {
        case 'a':
            if (ca == la) {
                puts("A");
                return 0;
            }
            sta = sa[ca];
            ca += 1;
            break;

        case 'b':
            if (cb == lb) {
                puts("B");
                return 0;
            }
            sta = sb[cb];
            cb += 1;
            break;

        case 'c':
            if (cc == lc) {
                puts("C");
                return 0;
            }
            sta = sc[cc];
            cc += 1;
            break;
        }
    }

    return 0;
}

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

int main() {
	int		a,b,h,c,i,j,k,n,m,x,y,ans = 0;
	string	s,t,u;
	
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	
	if (s == u) {
		a--;
	} else {
		b--;
	}

	cout << a << ' ' << b << endl;


}


Measured memory_bytes: 256
#include <iostream>

#define MOD 1000000007

using namespace std;

int main() {
        int n;
        unsigned long long pow = 1;

        cin >> n;
        for (int i = 1; i <= n; i++) {
                pow = (pow % MOD) * (i % MOD);
        }

        cout << pow % MOD;

        return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7

a, b = map(int, input().split())
if a >= b:
    ans = str(b)*a
else:
    ans = str(a)*b

print(int(ans))

Measured memory_bytes: 27380
N, K = map(int, input().split())
S = input()
kazulist = []
now = 1
for i in range(1, N):
    if S[i] == S[i-1]:
        now += 1
    else:
        kazulist.append(now)
        now = 1
kazulist.append(now)
lenkazu = len(kazulist)
sumkazu = sum(kazulist)
spl = max(lenkazu - 2 * K , 0)
if spl >= 1:
    print(sumkazu - spl)
else:
    print(N-1)

Measured memory_bytes: 3956
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int p[101][101];
int r[101][101];
int w,h,xg,yg;
void place(int c,int d,int x,int y)
{
  p[y][x] = c;
  p[y][x+1] = c;
  p[y+1][x] = c;
  p[y+1][x+1] = c;
  if(d==0){
    p[y][x+2] = c;
    p[y][x+3] = c;
    p[y+1][x+2] = c;
    p[y+1][x+3] = c;
  }else{
    p[y+2][x] = c;
    p[y+2][x+1] = c;
    p[y+3][x] = c;
    p[y+3][x+1] = c;
  }
}
int search(int x,int y)
{
  int a=0;
  int c=p[y][x];
  if(x==xg && y==yg) return 1;
  r[y][x] = 1;
  if (p[y][x-1] == c && r[y][x-1] == 0)
    a += search(x-1,y);
  if (p[y][x+1] == c && r[y][x+1] == 0)
    a += search(x+1,y);
  if (p[y-1][x] == c && r[y-1][x] == 0)
    a += search(x,y-1);
  if (p[y+1][x] == c && r[y+1][x] == 0)
    a += search(x,y+1);
  return a;
}
void show()
{
  int i,j;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      printf("%d",p[i][j]);
    }
    printf("\n");
  }
}
int main()
{
  int xs,ys,n,c,d,x,y;
  for(;;){
    scanf("%d%d",&w,&h);
    if(w==0&&h==0)break;
    memset(p,0,sizeof(p));
    memset(r,0,sizeof(r));
    scanf("%d%d",&xs,&ys);
    scanf("%d%d",&xg,&yg);
    scanf("%d",&n);
    while(n>0){
      scanf("%d%d%d%d",&c,&d,&x,&y);
      place(c,d,x,y);
      n--;
    }
    //show();
    if(search(xs,ys)) printf("OK\n");
    else printf("NG\n");
  }
  return 0;
}

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

int main(){
  int a,b,c,d,n;
  cin >> n;
  a = n/1000;
  b = (n%1000)/100;
  c = (n%100)/10;
  d = n%10;
  if((a==b && b==c) || (b==c && c==d)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>

using namespace boost::multiprecision;
using namespace std;

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

    cpp_int *ar = new cpp_int[n+1];
    for (int i = 0; i < n; ++i) {
        cin >> ar[i];
    }

    for (int i = 0; i < (n-k); ++i) {
        if (ar[i] < ar[i + k]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 9404
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------
int n;
int x[10], y[10];

double dist(int i, int j){
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx*dx + dy*dy, 0.5);
}

int main(void) {
  cin >> n;
  rep(i,n){
    cin >> x[i+1] >> y[i+1];
  }
  double sum=0.0;
  int fac=1;
  vec v(n);
  rep(i,n){
    v[i]=i+1;
    fac *= i+1;
  }

  do {
    rep(i,n-1){
      sum+=dist(v[i], v[i+1]);
    }
  } while(next_permutation(all(v)));

  prtd(9, sum/fac);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
//#define SZ(x) ((int)(x).size())
//#define F first
//#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
 
/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
 
//#define int long long
 
signed main()
{
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
n = input()

f=n[-1]
f=int(f)

hon=[2,4,5,7,9]
pon=[0,1,6,8]
bon=[3]

for i in hon:
    if i==f:
        ans='hon'
        break
for j in pon:
    if j==f:
        ans='pon'
        break
for k in bon:
    if k==f:
        ans='bon'
        break

print(ans)

Measured memory_bytes: 9136
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	
	public static void main(String args[]) {
		//変数の宣言
		int i=1;
		int x=0;
		sc = new Scanner(System.in);
		//System.out.println("Please input numbers below");
		//入力と出力
		for(;;){
			x=sc.nextInt();
			if(x==0) {
				break;
			}
			System.out.printf("Case %d: %d\n",i,x);
			i++;
		}
	}
}



Measured memory_bytes: 67924
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int x[100000];
int y[100000];

int main(){
	int n,k;
	cin>>n;
	while(scanf("%d %d",&n,&k)!=EOF){
		REP(i,n)scanf("%d",&x[i]);
		int ans = 0;
		REP(i,n-1){
			ans += (y[i] = x[i+1]-x[i]);
		}
		sort(y,y+n-1);
		//debug(y,y+n-1);
		int bnd = min(k-1,n-1);
		for(int i = 0; i < bnd; i++){
			ans -= y[n-2-i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
function bomb(y,x,f){
   yx[y][x]=("   "+cnt).slice(-3);
   cnt++;
   if(y==n-1 && x==n-1)return;
   else if(y==n-1 && f==-1)bomb(y,x+1,1);
   else if(y==n-1 && f==1)bomb(y-1,x+1,1);
   else if(x==n-1 && f==1)bomb(y+1,x,-1);
   else if(x==n-1 && f==-1)bomb(y+1,x-1,-1);
   else if(y==0 && f==1)bomb(y,x+1,-1);
   else if(y==0 && f==-1)bomb(y+1,x-1,-1);
   else if(x==0 && f==-1)bomb(y+1,x,1);
   else if(x==0 && f==1)bomb(y-1,x+1,1);
   else if(f==1)bomb(y-1,x+1,1);
   else if(f==-1)bomb(y+1,x-1,-1);
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var I=1;
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var yx=[];
   for(var i=0;i<n;i++){
      yx[i]=[];
      for(var j=0;j<n;j++){
         yx[i][j]=0;
      }
   }
   var cnt=1;
   bomb(0,0,1);
   console.log("Case "+I+":");
   I++;
   console.log(yx.join("\n").replace(/\,/g,""));
}

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

int main() {
    ll H, W, K;
    cin >> H >> W >> K;
    vector<vector<bool>> s(H, vector<bool>(W, false));
    vector<vector<ll>> ans(H, vector<ll>(W, 0));
    char tmp;
    rep(y, H) rep(x, W) {
        cin >> tmp;
        if (tmp == '#') s[y][x] = true;
    }
    ll depth = 1, left = 0, now = 1;
    bool hasCherry = false;
    rep(y, H) {
        left = 0;
        rep(x, W) {
            if (s[y][x]) {
                if (!hasCherry) {
                    hasCherry = true;
                } else {
                    for (int i = y - depth + 1; i <= y; i++) {
                        for (int j = left; j < x; j++) {
                            ans[i][j] = now;
                        }
                    }
                    now++;
                    left = x;
                }
            }
        }
        if (!hasCherry) {
            depth++;
        } else {
            for (int i = y - depth + 1; i <= y; i++) {
                for (int j = left; j < W; j++) {
                    ans[i][j] = now;
                }
            }
            now++;
            depth = 1;
            hasCherry = false;
        }
    }
    if (depth > 1) {
        for (int i = H - depth + 1; i < H; i++) {
            for (int j = 0; j < W; j++) {
                ans[i][j] = ans[i - 1][j];
            }
        }
    }
    rep(y, H) {
        cout << ans[y][0];
        rep(x, W - 1) { cout << " " << ans[y][x + 1]; }
        cout << "\n";
    }
    cout << flush;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n); sll(m);
	priority_queue<LL> pq;
	rep(i, 0, n)	pq.push(scanLong());
	rep(i, 0, m) {
		LL max = pq.top(); pq.pop();
		pq.push(max>>1);
	}
	LL ans = 0;
	while(!pq.empty()) {
		ans += pq.top(); pq.pop();
	}
	pll(ans); nl;
}


Measured memory_bytes: 1400
N, K = map(int, input().split())
ans = 0
sunuke = [0]*N
for i in range(K):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        sunuke[a-1] += 1
for i in sunuke:
    if i == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9192
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

k = inp()
print((k//2) * (k//2 + k%2))

Measured memory_bytes: 31168
#include <bits/stdc++.h>
#define nmax 202
using namespace std;

int arr[nmax],may=-1e9,aux,n,l;

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n>>l;
    for(int i=1;i<=n;i++){
        arr[i]=(l+i-1)+arr[i-1];
    }
    if((l*-1)>=n){
        cout<<arr[n-1];
    }
    else{
        if(l*1>0) cout<<arr[n]-arr[1];
        else cout<<arr[n];
    }
}


Measured memory_bytes: 256
//............Created by:- Arth Raj...........................//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vii vector<pair<int,int>>
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rlp(i,a,b) for(int i=b;i>=a;i--)
#define ld long double
#define tl tuple<ll,ll,ll>
#define all(x) (x).begin(),(x).end()
#define bs(x,b) binary_search(all(x),b)
#define vip vector<pair<int,pair<int,int>>>
#define pip pair<int,pair<int,int>>
#define INF 1e18
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll abm(ll a, ll b, ll m) {ll ans = 1; a = a % m; while (b > 0) {if (b & 1)ans = (ans * a) % m; a = (a * a) % m; b = b / 2;} return ans % m;}
ll ncr(ll n, ll r, ll m) {if (r == 0)return 1; ll fac[n + 5]; fac[0] = 1; lp(i, 1, n + 1) {fac[i] = fac[i - 1] * i % m;} return (((fac[n] * abm(fac[r], m - 2, m)) % m) * (abm(fac[n - r], m - 2, m))) % m;}
vi v[100005];
int dp[100005];
bool vis[100005];
void dfs(int x)
{
	vis[x] = 1;
	lp(i, 0, v[x].size())
	{
		int u = v[x][i];
		if (!vis[u])
			dfs(u);
		dp[x] = max(dp[x], 1 + dp[u]);
	}
}
int main()
{
	int n, m, u, w;
	cin >> n >> m;
	lp(i, 1, n + 1)
	{
		dp[i] = 0;
		vis[i] = 0;
	}
	while (m--)
	{
		cin >> u >> w;
		v[u].pb(w);
	}
	lp(i, 1, n + 1)
	{
		if (!vis[i])
		{
			dfs(i);
		}
	}
	int ans = -1;
	lp(i, 1, n + 1)
	{
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cctype>
#define rep(x,y,z) for(long long x=y;x<z;++x)
#define dwn(x,y,z) for(long long x=y;x>z;--x)
using namespace std;

typedef long long ll;

char g[1001][1001];
ll res[1001][1001];

int main() {
    ll h, w;
    cin >> h >> w;
    ll mod = 1000000007LL;
    for (ll i = 1; i <= h; i++) {
        for (ll j = 1; j <= w; j++) {
            cin >> g[i][j];
        }
    }
    res[1][1] = 1;
    for (ll i = 1; i <= h; i++) {
        for (ll j = 1; j <= w; j++) {
            if ((i == 1 && j == 1) || g[i][j] == '#') {
                continue;
            }
            res[i][j] = (res[i - 1][j] + res[i][j - 1]) % mod;
        }
    }
    cout << res[h][w] << endl;
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    ll A, B, M, ans = 0;
    cin >> A >> B >> M;
    vi a(A), b(B);
    ll minA = INF, minB = INF;
    for (ll i = 0; i < A; i++) {
        cin >> a[i];
        minA = min(minA, a[i]);
    }
    for (ll i = 0; i < B; i++) {
        cin >> b[i];
        minB = min(minB, b[i]);
    }

    ans = minA + minB;

    for (ll i = 0; i < M; i++) {
        ll x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, a[x - 1] + b[y - 1] - c);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 1000;
int main(){
	int N, M;
	int point[MAX_N + 1];
	int a[(MAX_N + 1) * (MAX_N + 1)];
	for(;;){
		scanf("%d %d", &N, &M);
		if(N == 0 && M == 0) break;
		point[0] = 0;
		for(int i = 1; i <= N; i++) scanf("%d", &point[i]);
		int index = 0;
		for(int i = 0; i < N + 1; i++){
			for(int j = 0; j < N + 1; j++){
				a[index] = point[i] + point[j];
				index++;
			}
		}
		sort(a, a + (N + 1) * (N + 1));
		int num_a = (N + 1) * (N + 1);
		int ans = 0;
		for(int i = 0; i < num_a; i++){
			if(a[i] > M) break;
			int lb = 0, ub = num_a - 1;
			int mid;
			while(ub - lb > 1){
				mid = (lb + ub) / 2;
				if(a[i] + a[mid] > M) ub = mid;
				else lb = mid;
			}
			mid = (lb + ub) / 2;
			if(a[i] + a[mid] > ans){
				ans = a[i] + a[mid];
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
int h,w;
cin>>h>>w;
	string s[h];
	for (int i = 0; i < h; ++i) {
		cin>>s[i];
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < 2; ++j) {
			cout<<s[i]<<endl;
		}
	}

}


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


int main() {
  int N;
  cin >> N;
  vector<string> w(N);

  cin >> w[0];

  int i = 1;
  do {
    bool ok = true;
    string word;
    cin >> word;
    if (w[i - 1].back() != word.front()) {
      ok = false;
    }
    if (find(w.begin(), w.end(), word) != w.end()) {
      ok = false;
    }

    if (!ok) {
      cout << "No" << endl;
      return 0;
    }

    w[i] = word;
    i++;    
  } while (i < N);

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc101/submissions/15815216 を参考に作成したソースコード
 */
public class Main {

	/** 10 */
	private static final int TEN = 10;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt();
			long a = 0, b = 1;
			for (int i = 0; i < k; i++) {
				if (((9 == (a / b) % TEN)) && (f(a + b) > f(a + TEN * b))) {
					b *= TEN;
				}
				a += b;
				System.out.println(a);
			}
		}
	}

	/**
	 * n/s(n)を計算する
	 * 
	 * @param n
	 * @return n/s(n)
	 */
	private static double f(long n) {
		long sum = 0, now = n;
		while (now > 0) {
			sum += now % TEN;
			now /= TEN;
		}
		return ((double) n) / sum;
	}
}


Measured memory_bytes: 36328
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 3e5;

int n, a[N];
string s;

int32_t main(){_
   
   cin >> s;

   int n = (int)(s.size());

   string tmp;
   for (int i = 0; i < N; ++i)
   {
      tmp += '-';
   }

   int sz = (int)(tmp.size());
   string curr = tmp + s + tmp;

   tmp = curr;
   int l = sz-1;
   int r = sz + n;

   int q;
   cin >> q;

   tr(tmp);
   int par = 0;
   while(q--){
      int type;
      cin >> type;
      if(type == 1){
         par ^= 1;
      }
      else{
         int x;
         cin >> x;
         char c;
         cin >> c;
         if(x == 1){
            if(par){
               tmp[r] = c;
               ++r;
               continue;
            }
            tmp[l] = c;
            --l;
         }
         else{
            if(par){
               tmp[l] = c;
               --l;
               continue;
            }
            tmp[r] = c;
            ++r;
         }
      }
   }

   if(par)
      reverse(tmp.begin(), tmp.end());

   string ret = "";
   for (int i = 0; i < (int)(tmp.size()); ++i)
   {
      if(tmp[i] == '-')continue;
      ret += tmp[i];  
   }

   cout<<ret;
   return 0;
}

Measured memory_bytes: 2852
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
//AtCoderC++.cpp

using namespace std;

inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}


int main() {
	int N; cin >> N;
	auto as = vector<pair<int, int>>(N);
	for (size_t i = 0; i < N; i++) {
		cin >> as[i].first;
		as[i].second = i;
	}
	sort(as.begin(), as.end(), [](pair<int, int> a, pair<int, int> b) {return a.first > b.first; });
	for (size_t i = 0; i < N; i++) {
		if (as[0].second == i)cout << as[1].first << endl;
		else cout << as[0].first << endl;
	}
}

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

using pii = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    int H, N, P, M, K;
    cin >> H >> N >> P >> M >> K;
    P--;
    vector<int> sw(H, -1);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        sw[a - 1] = b - 1;
    }

    vector<int> sum(H + 1);
    for(int i = 0; i < H; ++i) {
        sum[i + 1] = sum[i] + (sw[i] != -1);
    }
    vector<vector<double>> dp(N, vector<double>(K + 1));
    dp[P][0] = 1;
    double p = 1.0 / (N - 1);
    for(int i = H - 1; i >= 0; --i) {
        vector<vector<double>> nxt(N, vector<double>(K + 1));
        for(int j = 0; j < N; ++j) {
            for(int k = 0; k <= K; ++k) {
                if(dp[j][k] == 0) {
                    continue;
                }
                if(sw[i] == -1) {
                    double q = (double)(K - k) / (i + 1 - sum[i]); // put possibility
                    if(k == K) {
                        nxt[j][k] += dp[j][k] * (1 - q); // (1 - q) == 1
                    } else {
                        if(j != 0) {
                            nxt[j - 1][k + 1] += dp[j][k] * p * q;
                        }
                        if(j != N - 1) {
                            nxt[j + 1][k + 1] += dp[j][k] * p * q;
                        }
                        nxt[j][k] += dp[j][k] * (1 - q);
                        if(j == 0 || j == N - 1) {
                            nxt[j][k + 1] += dp[j][k] * q * (N - 2) / (N - 1);
                        } else {
                            nxt[j][k + 1] += dp[j][k] * q * (N - 3) / (N - 1);
                        }
                    }
                } else {
                    if(sw[i] == j) {
                        nxt[sw[i] + 1][k] += dp[j][k];
                    } else if(sw[i] + 1 == j) {
                        nxt[sw[i]][k] += dp[j][k];
                    } else {
                        nxt[j][k] += dp[j][k];
                    }
                }
            }
        }
        dp = move(nxt);
    }

    double res = 0;
    for(int i = 0; i < N; ++i) {
        res = max(res, dp[i][K]);
    }
    cout << res << endl;
}


Measured memory_bytes: 3384
n,m=map(int,input().split())
h=list(map(int,input().split()))
tall=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  tall[a]=max(tall[a],h[b])
  tall[b]=max(tall[b],h[a])
res=0
for i in range(n):
  if h[i]>tall[i]:
    res+=1
print(res)

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		string s;
		cin >> n >> s;
		int ret = 0;
		for(int i=0; i < n-2; i++){
			if(s.substr(i, 3) == "ABC")ret++;
		}
		cout << ret << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << '\n';
	return 0; 
}


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

using namespace std;

long long calc(long long x) {
	if (x < 2) {
		return 0;
	}
	return x * (x - 1) / 2;
}

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

	vector<long long> ball(n + 1, 0);
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ball[a[i]]++;
	}

	long long total = 0;
	for (auto x: ball) {
		total += calc(x);
	}

	vector<long long> memo(n + 1, -1);
	for (auto x: a) {
		if (memo[x] == -1) {
			memo[x] = total - calc(ball[x]) + calc(ball[x] - 1);
		}
		cout << memo[x] << endl;
	}

	return 0;
}


Measured memory_bytes: 6528
// https://beta.atcoder.jp/contests/abc079
// status:

#define SUBMIT

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

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(1234
)");
#endif
    char c[4];
    for (int i = 0; i < 4; ++i) stream >> c[i];

    set<char> s1 {c[0], c[1], c[2]};
    set<char> s2 {c[1], c[2], c[3]};

    if (s1.size() == 1 || s2.size() == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    vector<pii> p;
    REP(i,N) {
        int t;
        cin >> t;
        pii temp = make_pair(t,i+1);
        p.emplace_back(temp);
    }

    sort(ALL(p));

    for (auto x : p) {
        cout << x.second << " ";
    }

    return 0;
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  map<int, int> mp;
  mp[a];
  mp[b];
  mp[c];
  cout << mp.size() << endl;
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc051/tasks/abc051_b
#include <bits/stdc++.h>
using namespace std;

int main() {
    int k,s;cin>>k>>s;
    int ans=0;
    for(int x=0;x<=k;x++) {
        for(int y=0;y<=k;y++) {
            int z = s-x-y;
            ans += (0<=z && z<=k);
        }
    }
    cout<<ans<<"\n";    
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define  ll  long long

int main()
{
    IO;
    ll i, j=1, k = 0, mod = 1e9+7, m, n, n1, m1, l = 0, p, t, h, cnt=0;
    cin>>n>>m; cout<<n*m<<endl;
    return 0;
}


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

typedef long long ll;
const ll mod = 2019;

void solve(void) {
  ll L, R;
  cin >> L >> R;

  ll ans = 2020;
  R = min(R, (L + 2019 * 2));
  for (ll i = L; i <= R; ++i) {
    for (ll j = i+1; j <= R; ++j) {
      ans = min(ans, (i * j) % 2019);
    }
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    //input
    int d = sc.nextInt();
    /*
    int[] c = new int[26]; //array of decrease
    for(int i = 0; i < c.length; i++){
      c[i] = sc.nextInt();
    }
    */

    int[] c = new int[26];
    for(int i = 0; i < 26; i++){
      c[i] = sc.nextInt();
    }

    int[][] s = new int[d][26]; //two dimensional array of increase
    for(int row = 0; row < s.length; row++){ //day
      for(int col = 0; col < s[row].length; col++){ //contest number
        s[row][col] = sc.nextInt();
      }
    }
    int[] t = new int[d]; //array of contest numbers of the day
    for(int i = 0; i < t.length; i++){
      t[i] = 13;
    }

    //output
    //based on increase
    /*
    int largestNum = s[0][0];
    int largestNumRow = 0;
    int largestNumCol = 0;
    for(int row = 0; row < s.length; row++){
      for(int col = 0; col < s[row].length; col++){
        if( s[row][col] > largestNum ){
          largestNum = s[row][col];
          largestNumRow = row;
          largestNumCol = col;
        }
      }
    }

    int largestNuM = c.get(0);
    int largestNumPos = 0;
    for(int j = 0; j < c.size(); j++){
      if( c.get(j) > largestNuM ){
        largestNuM = c.get(j);
        largestNumPos = j;
      }
    }

    for(int i = 0; i < d; i++){
      if( largestNum > largestNuM ){
        System.out.println(largestNumCol+1);
      }else{
        System.out.println(largestNumPos+1);
      }
    }
    */


    /*

    for(int m = 0; m < d; m++){
      if( m%2 == 0 ){
        System.out.println(largestNumCol+1);
      }else{
        int largestNuM = c.get(0);
        int largestNumPos = 0;
        for(int j = 0; j < c.size(); j++){
          if( c.get(j) > largestNuM ){
            largestNuM = c.get(j);
            largestNumPos = j;
          }
        }
        c.remove(largestNumPos);
        System.out.println(largestNumPos+1);
      }
    }
    */



    for(int i = 0; i < d; i++){
      System.out.println((int)(Math.random()*26+1));
      //System.out.println(largestNumCol+1);
    }

    /*
    int value = 0;
    for(int i = 0; i < t.length; i++){
      int contestNum = t[i]-1;
      int day = i+1;
      value += s[day-1][contestNum]; //increase
      for(int j = 0; j < c.length; j++){
        if( !(j == contestNum) ){
          int daySinceLast = day;
          for(int m = 0; m < i; m++){
            if( j == t[m]-1 ){
              daySinceLast = day-m-1;
            }
          }
          value -= c[j]*(daySinceLast); //decrease (amount of decrease * days since last one)
        }
      }
      System.out.println(value);
    }
    */


  }
}


Measured memory_bytes: 38056
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int* arr = new int[n];
  for(int i = 0; i < n; ++i) cin >> arr[i];
  int res = 0;
  int l = -1;
  for(int i = 0; i < n; ++i)
  {
    l++;
    res = max(res, l);
    if(!((i == n-1) || arr[i+1] <= arr[i])) l=-1;
  }
  cout << res << endl;
  delete [] arr;
  return 0;
}


Measured memory_bytes: 640
def main ():
    N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)
    return

main ()


Measured memory_bytes: 21572
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  if (a+b <= 2*c){
    cout << a*x+b*y << endl;
  }
  else{
    if (x >= y){
        cout << min(2*c*y+(x-y)*a,2*c*x)  << endl;
    }
    else if (x < y){
        cout << min(2*c*x+(y-x)*b,2*c*y) << endl;
    }
  }
}



Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int number(const string &str, size_t &cur){
  int res = 0;
  while(cur < str.size() && isdigit(str[cur])){
    res = res * 10 + str[cur++] - '0';
  }
  return  res;
}

string atom(const string &str, size_t &cur){
  size_t start = cur;
  cur++;
  while(cur < str.size() && islower(str[cur])) cur++;
  return str.substr(start, cur - start);
}

map<string, int> expression(const string &str, size_t &cur){
  
  map<string, int> count;

  while(cur < str.size() && str[cur] != ')'){
    if(str[cur] == '('){
      map<string, int> tmp_c = expression(str, ++cur);
      assert(str[cur++] == ')');
      int n = number(str, cur);
      FOREACH(it, tmp_c){
        count[it->first] += it->second * n;
      }
    }else{
      int n = 1;
      string s = atom(str, cur);
      if(cur < str.size() && isdigit(str[cur])) n = number(str, cur);
      count[s] += n;
    }
  }

  return count;
}

map<string, int> calc(string str){
  size_t cur = 0;
  return expression(str, cur);
}

int main(){
  string atom, formula;
  string END = "END_OF_FIRST_PART";
  map<string, int> weight;

  while(cin >> atom && atom != END){
    cin >> weight[atom];
  }

  while(cin >> formula && formula != "0"){
    map<string, int> count = calc(formula);
    ll res = 0;
    FOREACH(it, count){
      if(weight.find(it->first) == weight.end()){
        res = -1;
        break;
      }
      res += it->second * weight[it->first];
    }
    if(res == -1){
      cout <<  "UNKNOWN" << endl;
    }else{
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>

#define len_string_max 4

int calculate_points (char data_string[len_string_max])
{
    // variables for `calculate_points`
    int points;

    // STEP.01
    // initialize the points
    points = 0;

    // STEP.02
    // calculate the points using given string
    for (size_t itr = 0; itr < len_string_max; itr++)
    {
        if (data_string[itr] == '+') points += 1;
        if (data_string[itr] == '-') points -= 1;
    }

    // STEP.END
    return points;
}

int main (void)
{
    // variables for `main`
    char given_string[len_string_max];

    // STEP.01
    // read out the given string
    scanf("%s", given_string);

    // STEP.02
    // calcualte & output the points
    printf("%d\n", calculate_points(given_string));

    // STEP.END
    return 0;
}

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

int main() {
    int N;
    while(cin >> N && N!=0) {
        int A=1, B=2, C=3;
        vector<string> order(N);
        for(int i=0; i<N; ++i) {
            cin >> order[i];
        }

        int ret=1;
        for(int i=0; i<N; ++i) {
            if(order[i] == "North") {
                swap(A, B);
                B = 7 - B;
            } else if(order[i] == "East") {
                swap(A, C);
                A = 7 - A;
            } else if(order[i] == "West") {
                swap(A, C);
                C = 7 - C;
            } else if(order[i] == "South") {
                swap(A, B);
                A = 7 - A;
            } else if(order[i] == "Right") {
                swap(B, C);
                C = 7 - C;
            } else if(order[i] == "Left") {
                swap(B, C);
                B = 7 - B;
            }
            ret += A;
        }
        cout << ret << endl;
    }
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<int> P(N);
  for (int i=0; i<N; i++) cin >> P[i];
  // 配点が低い順に，グループ1~3を考えてそれぞれの要素数を数える
  int group1=0, group2=0, group3=0;
  for (int i=0; i<N; i++) {
    if (P[i]<=A) group1++;
    else if (B+1<=P[i]) group3++;
    else group2++;
  }
  cout << min(group1, min(group2, group3)) << endl;
}

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

int main() {
  int N;
  cin >> N;
  long now = 7;
  for (int i = 1; i < 1e7; i++) {
    if (now % N == 0) return cout << i << "\n", 0;
    now *= 10;
    now %= N;
    now += 7;
    now %= N;
  }
  cout << -1 << "\n";
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

bool check(string &s, int i) {
    if (i == 0 && s[i] == 'L') return false;
    if (i == s.size() - 1 && s[i] == 'R') return false;
    if (s[i] == 'R') {
        return s[i + 1] == 'R';
    } else {
        return s[i - 1] == 'L';
    }
}

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int happy = 0;
    rep(i, s.size()) if (check(s, i)) happy++;

    happy += k * 2;
    happy = cmin(happy, n - 1);
    cout << happy << endl;

}


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

int main() {
	int p, q, r;
	cin >> p >> q >> r;
	
	vector<int> vec;
	vec.push_back(p);
	vec.push_back(q);
	vec.push_back(r);
	sort(vec.begin(), vec.end());
	cout << vec.at(0) + vec.at(1) << endl;
}

Measured memory_bytes: 256