akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

const int NMAX = 100 + 5;

int A[3][NMAX];

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

    for (int i = 1; i <= 2; ++ i)
        for (int j = 1; j <= N; ++ j)
            cin >> A[i][j];

    int ans = -1;
    for (int j = 1; j <= N; ++ j) {
        int s = 0;
        for (int k = 1; k <= j; ++ k)
            s += A[1][k];
        for (int k = j; k <= N; ++ k)
            s += A[2][k];
        if (s > ans)
            ans = s;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { -1, 0, 0, 1 };
const ll dy[4] = { 0, -1, 1, 0 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
struct Accelerate_Cin {
	Accelerate_Cin() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
};
///////////////////////////////////////

//    A     W-A

//B   0      1

//H-B 1      0  
int ans[1010][1010];
int main() {
	int H, W, A, B; cin >> H >> W >> A >> B;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (i < B&&j < A) {
				ans[i][j] = 0;
			}
			else if (i >= B&&j >= A) {
				ans[i][j] = 0;
			}
			else {
				ans[i][j] = 1;
			}
		}
	}
	REP(i, H) {
		REP(j, W) {
			cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

using namespace std;

const int maxi = 1e6+10;
#define pb push_back
int n;
string s;
vector<int> v[maxi];
int m,d;
int main()
{
    cin>>m>>d;

    int ans = 0;
    for (int i=10;i<=d;i++)
        for (int j = 1;j<=m;j++)
        if (i%10 * (i/10) == j && i%10>=2 && i/10 >=2) ans++;

    cout<<ans<<endl;
    return 0;
}
//pitaju me pitaju, mila gde si ?
//ja im kazem srecna jesi


Measured memory_bytes: 23680
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
//input
int main(void)
{
    int N, M;
    cin >> N >> M;
    int a[M], b[M];
    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
    }
    //map<int, int> x;
    int c[N + 1];
    fill(c, c + N + 1, 0);
    for (int i = 0; i < M; i++)
    {
        c[a[i]]++;
        c[b[i]]++;
    }
    for (int i = 1; i <= N; i++)
    {
        cout << c[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	string s;
	int w;
	cin >> s >> w;
	for (int i = 0;i < s.size();i += w) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int n;
    string s, t;

    cin >> n >> s >> t;

    int cnt = 0;


    for(int i = 1; i <= n; i++){
        // cout << t.substr(0, i) << " " << s.substr(n - i, i) << endl;
        if(t.substr(0, i) == s.substr(n - i, i)) cnt = max(cnt, i);
    }
    cout << 2 * n - cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

median = sum(As)/N
lis = [(abs(a-median), i) for i, a in enumerate(As)]
lis.sort()
print(lis[0][1])


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

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

    if(a % 3 == 0){
        cout << "Possible" << endl;
    }else if(b % 3 == 0){
        cout << "Possible" << endl;
    }else if((a + b) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
}

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

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




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


using namespace std;

int main()
{
  string w, s;
  int ans = 0;

  cin >> w;
  for(int i = 0; i < w.length(); i++)
  {
    if(w[i] >= 'A' && w[i] <= 'Z')
      w[i] = w[i] - 'A' + 'a';
  }
  while(true)
  {
    cin >> s;
    if(s == "END_OF_TEXT")
      break;

    if(w.length() != s.length())
      continue;
    for(int i = 0; i < w.length(); i++)
    {
      if(s[i] >= 'A' && s[i] <= 'Z')
        s[i] = s[i] - 'A' + 'a';
      if(s[i] != w[i])
        goto skip;
    }
    ans++;
skip:;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#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)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string M[55];
int x[4] = { 0,1,0,-1 };
int y[4] = { 1,0,-1,0 };

struct R
{
	R(pii g, int d)
		:g(g), d(d)
	{}
	pii g;
	int d;
};

int main()
{
	int H, W;
	cin >> H >> W;
	int N = 0;
	REP(i, H)
	{
		cin >> M[i];
		REP(w, W)
		{
			if (M[i][w] == '#')N++;
		}
	}

	queue<R> q;
	q.push(R(pii(0, 0), 1));
	while (!q.empty())
	{
		R r = q.front();
		q.pop();
		if (r.g == pii(H - 1, W - 1))
		{
			cout << H*W - r.d - N << endl;
			return 0;
		}
		REP(i, 4)
		{
			pii next = pii(r.g.first + x[i], r.g.second + y[i]);
			if (next.first < 0 || next.first >= H || next.second < 0 || next.second >= W)continue;
			if (M[next.first][next.second] == '#')continue;

			q.push(R(next, r.d + 1));
			M[next.first][next.second] = '#';
		}
	}
	cout << -1 << endl;
	return 0;
}

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

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

    int big = ((x >= y)? x : y), small = ((x >= y)? y : x);
    int min = 1000000000;
    for(int i = 0; i <= big; i++){
        int tmp;
        if(i <= small){
            tmp = c * i * 2 + (a * (x - i)) + (b * (y - i));
        }
        else{
            if(small == x){
                tmp = c * i * 2 + b * (y - i);
            }
            else{
                tmp = c * i * 2 + a * (x - i);
            }
        }
        if(tmp < min){
            min = tmp;
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;


int main()
{	
	int x;
	int idx=-1;
	for (int i = 0; i < 5; i++)
	{
		cin >> x;
		if (x==0)
		{
			idx = i;
		}
	}
	cout << (idx+1);
	return 0;
}



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

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2>> x3>> x4>> x5;

  if(x1 == 0){
    cout << 1 << endl;
  }else if(x2 == 0){
    cout << 2 << endl;
  }else if(x3 == 0){
    cout << 3 << endl;
  }else if(x4 == 0){
    cout << 4 << endl;
  }else if(x5 == 0){
    cout << 5 << endl;
  }

  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MAX=1e4+3;

int N;
vi G[MAX];
bool vis[MAX];
vi p;

void dfs(int s){
	vis[s]=true;
	p.push_back(s);
	rep(i,sz(G[s])){
		int v=G[s][i];
		if(vis[v])continue;
		dfs(v);
	}
}

int main(){
	cin>>N;
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
      		a--;
 	     	b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vi c(N), d(N);
	rep(i,N)cin>>c[i];
	sort(c.begin(),c.end(),greater<int>());
 	int ans=0;
	rep1(i,N-1)ans+=c[i];
  	cout<<ans<<endl;
  	
	rep(i,N)vis[i]=false;
	
	dfs(0);
  	rep(i,N)d[p[i]]=c[i];
	rep(i,N)cout<<d[i]<<" ";
	cout<<endl;
}

Measured memory_bytes: 1536
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, k = sc.nextInt()
    sc.nextLine()
    val s = sc.nextLine.toCharArray

    val nums = ArrayBuffer[Int]()
    var now = 1
    var cnt = 0
    for (i <- 0 until n) {
      if (s(i) == ('0' + now).toChar) {
        cnt += 1
      } else {
        nums.append(cnt)
        now = 1 - now
        cnt = 1
      }
    }
    if (cnt != 0) nums.append(cnt)

    // k=1の場合、1-0-1の1つ分の合算値をチェックしていく
    // 1-0-1-0 のように0の区間で終了していると、区間をチェックできない
    //  -> 0区間で終わる場合は、1の区間を末尾に付け足す（数値は0）
    if (nums.size % 2 == 0) nums.append(0)

    // 累積和をとる
    val sum = nums.scanLeft(0)(_ + _)

    // チェックする区間（k + 1個の1の区間 + k個の0の区間）
    val add = 2 * k + 1

    var ans = 0
    for (i <- 0 until nums.size by 2) {
      val left = i
      val right = math.min(i + add, nums.size)
      val tmp = sum(right) - sum(left)

      ans = math.max(ans, tmp)
    }

    println(ans)
  }
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define clean(used) memset(used,false,sizeof(used))
using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ans = 1;
    cin >> n;
    while(n>=2){
        n/=2;
        ans*=2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
A, B, C, X, Y = map(int, input().split())
ans = 0
if A+B < C*2:
    ans += (A+B)*min(X, Y)
else:
    ans += C * 2 * min(X, Y)
if X < Y:
    tmp = B*(Y-X)
else:
    tmp = A*(X-Y)
AB = C*abs(X-Y)*2
print(ans + min(tmp, AB))

Measured memory_bytes: 3064
#include<stdio.h>
  
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;
 
       
     
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}


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

int main(){
  unsigned int N,C,K;
  std::cin>>N>>C>>K;
  std::vector<unsigned int> time(N);
  for(auto &t:time){
    std::cin>>t;
  }

  std::sort(time.begin(),time.end());

  int i=0;
  int t;
  int bus_num=0;
  while(i<N){
    t = time[i];
    int num=1;
    while(time[i]<=t+K&&num<=C){
      i++;
      num++;
    }
    bus_num++;
  }

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

Measured memory_bytes: 888
// All Heil Fire Lord Zuko

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

#define F first
#define S second
#define PB push_back

const int N = 100 * 1000 + 19;
const int inf = 1000 * 1000 * 1000 + 19;

int n, m, cnt[N];

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i ++) {
        int u, v;
        cin >> u >> v;
        cnt[-- v] ++;
        cnt[-- u] ++;
    }
    for (int i = 0; i < n; i ++)
        if (cnt[i] % 2)
            return cout << "NO", 0;
    cout << "YES";
    return 0;
}

/* THINGS TO CHECK !! */ 

// Runtime ->
// Overflows ->
// Order is -> 26^2

/* READ PROBLEM STATEMENT CAREFULLY */



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

const int MAXN = 20005;

int n, a[MAXN], b[MAXN], p[MAXN];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]), a[i] = b[i] = 1;
	for (int i = 1; i <= n; i++)
		a[p[i]] += i, b[p[i]] += i;
	for (int i = 1; i <= n; i++) a[i] += a[i-1];
	for (int i = n; i >= 1; i--) b[i] += b[i+1];
	for (int i = 1; i <= n; i++) cout << a[i] << " ";
	cout << endl;
	for (int i = 1; i <= n; i++) cout << b[i] << " ";
	cout << endl;
	return 0;
}


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

using namespace std;

int main()
{
  long long a, b, c;
  scanf("%lld %lld %lld", &a, &b, &c);
  
  printf("%lld\n", min(a * b * (c % 2), min((a % 2) * b * c, a * (b % 2) * c)));
  return(0);
}

Measured memory_bytes: 256
// depends on: -

/*
usage:

tools::pow2(5) => 32
*/

#include <type_traits>
#include <cstddef>

namespace tools {
  template <typename T, typename std::enable_if<std::is_unsigned<T>::value, std::nullptr_t>::type = nullptr> constexpr T pow2(const T x) {
    return static_cast<T>(1) << x;
  }
  template <typename T, typename std::enable_if<std::is_signed<T>::value, std::nullptr_t>::type = nullptr> constexpr T pow2(const T x) {
    return static_cast<T>(static_cast<typename std::make_unsigned<T>::type>(1) << static_cast<typename std::make_unsigned<T>::type>(x));
  }
}
#include <iostream>
#include <cstdint>
#include <array>
#include <vector>

int main() {
  std::int_fast64_t n, a;
  std::cin >> n >> a;
  std::vector<std::int_fast64_t> positive_numbers;
  std::vector<std::int_fast64_t> negative_numbers;
  std::int_fast64_t zero_count = 0;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t x_i;
    std::cin >> x_i;
    if (x_i > a) {
      positive_numbers.push_back(x_i - a);
    } else if (x_i < a) {
      negative_numbers.push_back(a - x_i);
    } else {
      ++zero_count;
    }
  }

  std::array<std::int_fast64_t, 2501> positive_dp = {1};
  for (const std::int_fast64_t& positive_number : positive_numbers) {
    for (std::int_fast64_t i = 2500; i >= 0; --i) {
      if (positive_dp[i] > 0 && i + positive_number <= 2500) {
        positive_dp[i + positive_number] += positive_dp[i];
      }
    }
  }

  std::array<std::int_fast64_t, 2501> negative_dp = {1};
  for (const std::int_fast64_t& negative_number : negative_numbers) {
    for (std::int_fast64_t i = 2500; i >= 0; --i) {
      if (negative_dp[i] > 0 && i + negative_number <= 2500) {
        negative_dp[i + negative_number] += negative_dp[i];
      }
    }
  }

  std::int_fast64_t result = positive_dp[0] * negative_dp[0] * (tools::pow2(zero_count) - 1);
  for (std::int_fast64_t i = 1; i <= 2500; ++i) {
    result += positive_dp[i] * negative_dp[i] * tools::pow2(zero_count);
  }
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 256
from time import time
import random

start = time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]


def cal_score(t):
  S = 0
  last = [-1] * 26
  score = 0
  for d in range(D):
    S += s[d][t[d]]
    last[t[d]] = d
    for i in range(26):
        S -= c[i] * (d - last[i])
    score += max(10 ** 6 + S, 0)
  return score
    
def main():
  t = [random.randint(0, 25) for _ in range(D)]
  score = cal_score(t)
  while time()-start + 0.2 < 2:
    d = random.randint(0, D-1)
    q = random.randint(0, 25)
    old = t[d]
    t[d] = q
    if cal_score(t) < score:
      t[d] = old
    else:
      score = cal_score(t)
  return t

if __name__ == "__main__":
  ans = main()
  for t in ans:
    print(t+1)

Measured memory_bytes: 9708
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int flag1=0,flag2=0;
	cin>>a;
	int l=a.size();
	for(register int i(0);i<l;++i)
	{
		if(flag1==0 && a[i]=='C')
			flag1=1;
		if(flag1==1 && a[i]=='F')
			flag2=1;
	}
	if(flag2) printf("Yes");
	else  printf("No");
	printf("\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		long multCD = lcm(C, D);

		long CRem = B / C - (A - 1) / C;
		long DRem = B / D - (A - 1) / D;
		long multCDRem = B / multCD - (A - 1) / multCD;

		System.out.println(B - A + 1 - (CRem + DRem - multCDRem));
	}

	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int n;
	while(cin >> n, n)
	{
		int sum = 0;
		int sq = sqrt((double)n);
		for(int i=1; i <= sq; i++) {
			if(n % i == 0) {
				sum += i;
				int dev = (n/i);
				if(i != dev) sum += dev;
			}
		}
		sum -= n;
		if(n > sum) {
			cout << "deficient number" << endl;
		}
		else if(n < sum) {
			cout << "abundant number" << endl;
		}
		else {
			cout << "perfect number" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, w;
};


int main() {
	int a, b, c, x, y;


	cin >> a >> b >> c >> x >> y;
	int ans = 0;
	if (a + b > c * 2) {
		ans += min(x, y) * c * 2;
			int d = min(x, y);
			x -= d;
			y -= d;
	}
	if (a > c * 2) ans += c * 2 * x;
	else ans += a * x;
	if (b > c * 2) ans += c * 2 * y;
	else ans += b * y;

	cout << ans << endl;

	return 0;
}

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

int cnt_digits(int64_t x) {
    int digits = 0;
    while (x > 0) {
        x /= 10;
        digits++;
    }
    return digits;
}

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

    int ans = cnt_digits(N);
    for (int64_t A = 1LL; A * A <= N; A++) {
        if (N % A != 0) continue;
        int64_t B = N / A;

        int maximum = max(cnt_digits(A), cnt_digits(B));
        if (ans > maximum) ans = maximum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  string S; cin>>S;
  if(S=="ABC")cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
  
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    ll K;
    cin >> K;
    vector<int> A(N);
    REP(i,N){
        int a;
        cin >> a;
        A[i] = a;
    }

    ull ans = 0;
    for(int i = 0; i < N; i++){
        int a = A[i];
        ull tmp = 0;
        ull tmp2 = 0;
        for(int j = 0; j < N; j++){
            int x = A[j];
            if(a > x){
                tmp2++;
                if(i < j)
                    tmp++;
            }
            //cout << tmp << " " << tmp2 << endl;
        }

        tmp = tmp * K;
        tmp %= MOD;

        ull kk = K*(K-1) / 2;
        kk %= MOD;

        tmp += tmp2 * kk;
        tmp %= MOD;

        ans += tmp;
        ans %= MOD;
    }

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


Measured memory_bytes: 256
# input() は 'python3' で正常に動く
N = int(input())
S = input()
 
str_list = list(S)
str_trsf = []
 
for item in str_list:
    str_trsf.extend(chr(N - (ord('Z') - ord(item) + 1) + ord('A')) if ord(item) + N > ord('Z') else chr(ord(item) + N))

print(''.join(str_trsf))

Measured memory_bytes: 3188
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int s = x2 - x1; 
    int t = y2 - y1;
    int x3, y3, x4, y4;
    x3 = x1 - t;
    y3 = y1 + s;
    x4 = x2 - t;
    y4 = y2 + s;

    cout << x4 << " " << y4 << " " << x3 << " " << y3 << endl;
    return 0;
}


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

int main(){
  int H, W, N;cin>>H>>W>>N;
  int r, c;cin>>r>>c;
  vector<char> S, T;
  for (int i=0;i<N;++i){
    char s;cin>>s; S.push_back(s);
  }
  for (int i=0;i<N;++i){
    char t;cin>>t;T.push_back(t);
  }

  int py=r, px=c;

  for (int i=0;i<N;++i){
    if(S[i]=='L') px--;
    if(px<=0){
      cout << "NO" << endl;
      return 0;
    }
    if(T[i]=='R'&&px<W) px++;
  }

  py=r;px=c;

  for (int i=0;i<N;++i){
    if(S[i]=='R') px++;
    if(px>W){
      cout << "NO" << endl;
      return 0;
    }
    if(T[i]=='L'&&px>1) px--;
  }

  py=r;px=c;

  for (int i=0;i<N;++i){
    if(S[i]=='U') py--;
    if(py<=0){
      cout << "NO" << endl;
      return 0;
    }
    if(T[i]=='D'&&py<H) py++;
  }

  py=r;px=c;

  for (int i=0;i<N;++i){
    if(S[i]=='D') py++;
    if(py>H){
      cout << "NO" << endl;
      return 0;
    }
    if(T[i]=='U'&&py>1) py--;
  }

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

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

#define forn(i,n) for(int i=0;i<int(n);i++)
#define forsn(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define dforsn(i,s,n) for(int i=(int)(n-1);i>=int(s);i--)
#define si(a) ((int)(a).size())
#define pb push_back
#define mp make_pair
#define endl '\n'
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define x first
#define y second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long int tint;
typedef vector<pii> vii;

const int MAXN = 2e5+10, INF = 1<<30;
const double PI = acos(-1), cuarto = 0.05*PI, medio = 0.1*PI;

#define operacion(x, y) max(x, y)
typedef int tipo;
const int neutro=0;

struct RMQ{
	int sz;
	tipo t[4*MAXN];
	tipo &operator[](int p){return t[sz+p];}
	void init(int n){//O(nlgn)
		sz = 1 << (32-__builtin_clz(n));
		forn(i, 2*sz) t[i]=neutro;
	}
	void updall(){//O(n)
		dforsn(i, 0, sz) t[i]=operacion(t[2*i], t[2*i+1]);}
	tipo get(int i, int j){return get(i,j,1,0,sz);}
	tipo get(int i, int j, int n, int a, int b){//O(lgn)
		if(j<=a || i>=b) return neutro;
		if(i<=a && b<=j) return t[n];
		int c=(a+b)/2;
		return operacion(get(i, j, 2*n, a, c), get(i, j, 2*n+1, c, b));
	}
	void set(int p, tipo val){//O(lgn)
		for(p+=sz; p>0 && t[p]!=val;){
			t[p]=val;
			p/=2;
			val=operacion(t[p*2], t[p*2+1]);
		}
	}
} rmq;

vii v;
pii s, e;
map<int,int> idx;

inline bool inRect(pii p) {
	return s.x <= p.x && p.x <= e.x
		&& min(s.y, e.y) <= p.y && p.y <= max(s.y, e.y);
}

inline int dist(pii a, pii b) {
	return abs(a.x-b.x) + abs(a.y-b.y);
}

int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	
	#ifdef LOCAL 
		freopen("in.txt","r",stdin); 
	#endif

	cin >> s.x >> s.y >> e.x >> e.y;
	if (s.x > e.x) swap(s, e);
	int n;
	cin >> n;
	forn(i, n) {
		pii p;
		cin >> p.x >> p.y;
		if (inRect(p))
			v.pb(p);
	}

	n = si(v);

	double ans = dist(s,e);
	// compresion
	vii o;
	forn(i, n) o.pb(mp(v[i].y, i));
	sort(o.begin(), o.end());
	forn(i, n) idx[o[i].x] = i;

	// solve
	rmq.init(n);

	sort(v.begin(), v.end());
	forn(i, n) {
		int id = idx[v[i].y];
		int mx = (s.y < e.y ? rmq.get(0, id) : rmq.get(id, n)) +1;

		//cerr << i <<  " idx "<< id << endl;
		//cerr << v[i].x << ' ' << v[i].y << ' ' << mx << endl;

		rmq.set(id, mx);
	}

	//cerr << "cuartos: " << rmq.get(0,n) << endl;
	int best = rmq.get(0, n);
	ans -= best*(0.2-cuarto);

	if (best == abs(e.x-s.x)+1 || best == abs(e.y-s.y)+1)
		ans += cuarto;

	cout << fixed << setprecision(12) << ans*100 << endl;

	return 0;
}


Measured memory_bytes: 14832
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = 998244353;
const double EPS = 1e-9;

bool s[1000000] = {};
int sosu[1000000] = {};
void erast(){
  memset(s,1,sizeof(s));
  s[1] = false;
  s[0] = false;
  REP(i,2,1000){
    if(s[i]){
      REP(j,2,1000000){
        if(i*j>=1000000) break;
        s[i*j] = false;
      }
    }
  }
  REP(i,2,1000000) sosu[i] = sosu[i-1]+s[i];
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    erast();
    int n;
    while(cin >> n){
      cout << sosu[n] << endl;
    }
    return 0;
}



Measured memory_bytes: 7904
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv){
    int N, M;
    cin >> M >> N;
    unordered_map<int, list<int>> G;

    stack<int> s;
    vector<int> d(M);

    vector<int> in_degree(M);
    for(int i = 0; i < N ; ++i){
        int u, v;
        cin >> u >> v;
        G[u-1].push_back(v-1);
        in_degree[v-1]++;
    }
    vector<bool> visited(M);
    int max_d = 0;
    for(int i = 0; i < M; ++i){
        if(!visited[i] && in_degree[i] == 0)
            s.push(i);
        while(!s.empty()){
            int node = s.top();
            s.pop();
            visited[node] = true;
            for(const auto& other : G[node]){
                d[other] = max(d[node] + 1, d[other]);
                in_degree[other]--;
                if(in_degree[other] == 0){
                    s.push(other);
                }
            }

        }
    }
    for(const auto& c : d)
        if(c > max_d) max_d = c;
    cout << max_d <<"\n";
        return 0;
}

Measured memory_bytes: 9892
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N, L;
    scanf("%lld %lld", &N, &L);
    char S[110][110];
    rep(i, 0, N) scanf("%s", S[i]);
    qsort(S, N, sizeof(S[0]), cmp);
    rep(i, 0, N) printf("%s", S[i]);
    return 0;
}

int cmp(const void *a, const void *b){
    char *left_char = (char *)a;
    char *right_char = (char *)b;
    return strcmp(left_char, right_char );//abc..zの順に並べる
}


Measured memory_bytes: 252
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 924844033
#define N 2001
int n, k, num;
bool vis[N << 1];
ll fac[N] = {1}, f[N << 1][N][2] = {1};
int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
    for (int i = 1; i <= k; i++)
        for (int l = 1; l <= 2; l++)
            for (int j = i; j <= n; j += k) {
                num++;
                if (j != i) vis[num] = true;
            }
    for (int i = 0; i < 2 * n; i++)
        for (int j = 0; j <= n; j++) {
            f[i + 1][j][0] = (f[i][j][0] + f[i][j][1]) % mod;
            if (vis[i + 1]) f[i + 1][j + 1][1] = f[i][j][0];
        }
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        ll s = (f[2 * n][i][0] + f[2 * n][i][1]) * fac[n - i] % mod;
        ans = (ans + (i & 1 ? mod - s : s)) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 125312
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
string n;
int main(){
	cin>>n;
	int ln=n.size(),i=0;
	while(i<ln){
		if(n[i]=='A'){
			if(n[i+1]=='C'){
				cout<<"Yes"<<endl;
				return 0;
			}
			else if(n[i+1]=='A') i++;
				else i+=2;
		}
		else i++;
	}
	cout<<"No"<<endl;
	return 0;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int H1, H2, M1, M2, K;
        cin >>H1 >>M1 >>H2 >>M2 >>K;
        int S=(H2-H1)*60+M2-M1-K;
        cout <<S <<endl;
        return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define mm(x,n) memset(x,n,sizeof(x))
#define IOS cin.tie(0); ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
//const int maxn =

int main(){
	int n;
	cin>>n;
	map<ll,int> cnt;
	rep(i,1,n){
		int tmp;
		cin >> tmp;
		cnt[tmp]++;
	}
	vector<ll> v;
	for(auto i : cnt)
		if(i.Y >= 2){
			rep(j,1,(i.Y/2))
				v.pb(i.X);
		}
	if(v.size() >= 2){
		sort(ALL(v));
		unsigned long long ans = (v[v.size()-1]*v[v.size()-2]);
		cout<<ans;
	}
	else cout<<"0";
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FASTIO cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define ll long long int
#define F first
#define S second
#define pll pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vpii vector<pair<int,int> >
#define vvpii vector<vpii >
#define vpll vector<pair<ll,ll> >
#define vvpll vector<vpll >
#define pb push_back
#define MOD 1000000007
#define brk cout<<"\n"

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

struct compare {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		if ((a.S - a.F) != (b.S - b.F)) return ((a.S - a.F) > (b.S - b.F));
		else return (a.F < b.F);
	}
};

const int mx = 16;
const ll INF = 1e18L + 5;
ll n;
vl dp, score;

void rec(ll i, vl & not_taken, ll score_so_far, ll mask, ll group) {
	if (i == not_taken.size()) {
		dp[mask] = max(dp[mask], score_so_far + score[group]);
		return;
	}
	rec(i + 1, not_taken, score_so_far, mask, group);
	rec(i + 1, not_taken, score_so_far, mask ^ (1 << not_taken[i]), group ^ (1 << not_taken[i]));

}



int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	FASTIO;
	cin >> n;
	vvl giv(n, vl(n));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n; j++) cin >> giv[i][j];
	}

	dp.resize(1 << n, -INF);
	score.resize(1 << n);
	dp[0] = 0;
	for (ll mask = 0; mask < (1 << n); mask++) {
		for (ll i = 0; i < n; i++) {
			if (mask & (1 << i)) {
				for (ll j = i + 1; j < n; j++) {
					if (mask & (1 << j)) score[mask] += giv[i][j];
				}
			}
		}
	}
	for (ll mask = 0; mask < (1 << n); mask++) {
		vl not_taken;
		for (ll i = 0; i < n; i++) {
			if (!(mask & (1 << i))) {
				not_taken.pb(i);
			}
		}
		rec(0, not_taken, dp[mask], mask, 0);
	}

	cout << dp[(1 << n) - 1]; brk;


}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  int tmp = SUM(a);
  pair<int,int> p = mp(0,INF);
  rep(i,n){
    if(p.se > abs(tmp-a[i]*n)){
      p = mp(i,abs(tmp-a[i]*n));
    }
  }
  print(p.fi);
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}
int dig(int n){
    int ret=0;
    while(n>0){
        n/=10;
        ret++;
    }
    return ret;
}
int main()
{
    io;
    int n,m;
    cin>>n>>m;
    vector<string> v[n+1];
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        string a;
        cin>>a;
        v[x].pb(a);
    }
    int cor=0,pen=0;
    for(int i=1;i<=n;i++){
        int now = count(all(v[i]),"AC");
        if(now){
            now=1;
            int j=0;
            for(;j<v[i].size();j++){
                if(v[i][j]=="AC") break;
            }
            pen+=j;
            cor++;
        } 

    }
    cout<<cor<<' '<<pen;
    return 0;
}


Measured memory_bytes: 10368
import java.util.Scanner;
public class Main {
 
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNext()) {
            double a = s.nextDouble();
            double b = s.nextDouble();
            double c = s.nextDouble();
            double d = s.nextDouble();
            double e = s.nextDouble();
            double f = s.nextDouble();
             
            double x = (e*c - b*f)/(a*e - d*b);
            double y = (d*c - a*f)/(b*d - a*e);
            if(x == -0.0) {
                x = 0;
            }
            if(y == -0.0) {
                y = 0;
            }
            System.out.printf("%.3f %.3f\n",x,y);
        }
         
    }
}


Measured memory_bytes: 28132
#include<stdio.h>
int main()
{
    int a,b,s=0,c=0,d=0,i,j,p=0,q;
    scanf("%d%d",&a,&b);
    for(i=2;;i=i+2)
    {
        if(c==a-1||(a-1)<0)
            break;
        c++;
        s=s+c;
    }
    for(j=1;;j=j+2)
    {
        if(d==b-1||(b-1)<0)
            break;
        d++;
        p=p+d;
    }
    q=s+p;
    printf("%d",q);
}


Measured memory_bytes: 128
n,a,b=map(int,input().split())
if (a-b) % 2 == 0:
    ans0= (b-a) // 2
    print(ans0)
else:
    ans1=(a-1) + (b-a+1)//2
    ans2=(n-b) + (b-a+1)//2
    print(min(ans1,ans2))

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>

using namespace std;

long long ans = 0;
long long len[100]={1};
long long b[100]={0};
long long p[100]={1};
void fun(long long L,long long X)
{
    //cout<<"L = "<<L<<" "<<"x = "<<X<<endl;
    if(L==0&&X){ans++;
    return;}
    if(X==len[L-1]+2){
        //cout<<"if1"<<endl;
        ans+=p[L-1];
        ans++;
        return;

    }
    else if(X>1&&X<=1+len[L-1]){
         //cout<<"if2"<<endl;
        fun(L-1,X-1);
    }
    else if(X==1){
         //cout<<"if3"<<endl;
        return;
    }
    else if(X>=len[L-1]+3&&X<=len[L]-1){
         //cout<<"if4"<<endl;
        ans+=p[L-1];
        ans++;
        fun(L-1,X-2-len[L-1]);
    }
    else if(X==len[L]){
       //  cout<<"if5"<<endl;
        ans+=p[L];
        return;
    }
}
int main()
{
    long long N,X;
    cin >> N >> X;

    for(int i = 1 ; i < 55 ; i ++)
    {
        len[i] = len[i-1]*2+3;
        b[i] = b[i-1]*2+2;
        p[i] = len[i]-b[i];
    }
    //cout<<"len50 = "<<len[50]<<endl;
    fun(N,X);
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
inline ll pow2(const int n) { return 1ll << n; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
// 1. 問題よくよめえええええええええええええええええええええええええ
// 2. intオーバーフロー << * + あたり
// 3. 落ち着け

int N;
vi p;

int main() {
    cin >> N;
    p.resize(N);
    rep(i, N) cin >> p[i];
    
    int ans = 0;
    rep(i, N) ans += p[i];

    sort(all(p));
    ans -= p[N - 1] / 2;

    write(ans);
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int MOD = 1e+7;

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

  int n, m, sum = 0;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  bool flag = true;
  rep(i,m) {
    if(a[i] * 4 * m < sum) flag = false;
  }
  YesorNo(flag);
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

int64_t M = 1000000007;

int main(){
	int n;
	cin >> n;
	vector<int> a(100001,0);
	for (int i = 0; i < n; ++i) {
		int ai;
		cin >> ai;
		a[ai]++;
	}
	bool flag = true;
	if (n % 2 == 1) {
		flag &= (a[0] == 1);
		for (int i = 1; i < n; ++i) {
			if (i % 2 == 1) flag &= (a[i] == 0);
			else flag &= (a[i] == 2);
		}
	}
	else {
		for (int i = 0; i < n; ++i) {
			if (i % 2 == 0) flag &= (a[i] == 0);
			else flag &= (a[i] == 2);
		}
	}
	if (!flag) cout << 0 << endl;
	else {
		int64_t ret = 1;
		for (int i = 0; i < n / 2; ++i) {
			ret *= 2;
			ret %= M;
		}
		cout << ret << endl;
	}
	return 0;
}

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

using namespace std;

int table[3005][3005], direction[3005][3005], highest = 0, hi = 0, hj = 0;
string s, t, ans = "";

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> s >> t;
	for (int i=1;i<=s.length();++i) {
		for (int j=1;j<=t.length();++j) {
			if (s[i-1] == t[j-1]) table[i][j] = table[i-1][j-1]+1;
			else if (table[i-1][j] > table[i][j-1]) { table[i][j] = table[i-1][j]; direction[i][j] = 1; }
			else { table[i][j] = table[i][j-1]; direction[i][j] = 2; }
			if (table[i][j] > highest) {
				highest = table[i][j];
				hi = i, hj = j;
			}
		}
	}
	while (hi > 0 && hj > 0) {
		if (s[hi-1] == t[hj-1]) ans = ans + s[hi-1];
		if (direction[hi][hj] == 0) { hi--; hj--; }
		else if (direction[hi][hj] == 1) hi--;
		else hj--;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

#define Speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define fr first
#define sc second
#define pb push_back
#define PI acos(-1.0)
#define print(num,ans) cout<<setprecision(num)<<fixed<<ans


int main()
{
    Speed;
    ll x,y;
    cin>>x>>y;
    if(x > 9 || y > 9)cout<<-1;
    else cout<<x*y;

    return 0;
}


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

int main()
{
    int s;
    string ans = "NA";
    cin >> s;
    int l = s / 100;
    int r = s % 100;
    if (l >= 1 & l <= 12)
    {
        if (r >= 1 & r <= 12)
        {
            ans = "AMBIGUOUS";
        }
        else
        {
            ans = "MMYY";
        }
    }
    else if (r >= 1 & r <= 12)
    {
        ans = "YYMM";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())

a=[0]*N
b=[0]*N
c=[0]*N

flag = -1
for i in range(N):
    a[i],b[i],c[i] = map(int,input().split())

dp=[[0]*3 for i in range(N)]

for i in range(N):
    if i==0:
        dp[i][0]=a[i]
        dp[i][1]=b[i]
        dp[i][2]=c[i]
    else:
        dp[i][0]=a[i] + max(dp[i-1][1],dp[i-1][2])
        dp[i][1]=b[i] + max(dp[i-1][2],dp[i-1][0])
        dp[i][2]=c[i] + max(dp[i-1][0],dp[i-1][1])
print(max(dp[N-1]))

Measured memory_bytes: 34676