akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

string s;
map<int, int> cdest;
map<int, pair<int, int>> mem;

pair<int, int> walk(int curr) {
  if (s[curr] == 'L' && s[curr - 1] == 'L') {
    if (mem.find(curr) == mem.end()) {
      auto p = walk(curr - 1);
      int dist = curr - p.first;
      cdest[curr] = p.first + (dist % 2 ? p.second : 0);
      return mem[curr] = p;
    }
    return mem[curr];
  }
  else if (s[curr] == 'R' && s[curr + 1] == 'R') {
    if (mem.find(curr) == mem.end()) {
      auto p = walk(curr + 1);
      int dist = p.first - curr;
      cdest[curr] = p.first + (dist % 2 ? p.second : 0);
      return mem[curr] = p;
    }
    return mem[curr];
  }
  else if (s[curr] == 'L') {
    cdest[curr] = curr;
    return {curr, -1};
  }
  else if (s[curr] == 'R') {
    cdest[curr] = curr;
    return {curr, +1};
  }
  else {
    assert(0);
  }
}

int main() {
  cin >> s;
  int n = s.size();
  rep(i, n) {
    if (cdest.find(i) == cdest.end()) {
      walk(i);
    }
  }
  vector<int> ans(n);
  for (auto &e : cdest) {
    ans[e.second]++;
  }
  rep(i, n) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 21248
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a=0,b=0,c=0,d=0,area1,area2;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	area1=a*b;
	area2=c*d;
	if(area1>area2)
	   printf("%d",area1);
	else
	   printf("%d",area2);
}

Measured memory_bytes: 256
a,b,c,d=map(int, input().split())
x=list(range(a,b+1))
l=[]
for i in range(c,d+1):
  if i in x:
    l.append(i)
if len(l)==0:
  print(0)
elif len(l)==1:
  print(0)
else:
  print(l[-1]-l[0])

Measured memory_bytes: 3064
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1<<30;
enum mod = 10L^^9 + 7;

void main() {
    int h, w, a, b;
    scan(h, w, a, b);

    auto mc = ModComb(h + w);

    long ans;

    foreach (i ; 0 .. w - b) {
        ans += mc.comb(h - a - 1 + b + i, h - a - 1) * mc.comb(a - 1 + w - b - 1 - i, a - 1) % mod;
        if (ans > mod) ans-= mod;
    }

    writeln(ans);
}

struct ModComb {
    int _N;
    long[] _fact, _factinv;
    long _mod;

    this(int n, long mod = 10L^^9 + 7) {
        _N = n;
        _fact = new long[](_N + 1);
        _factinv = new long[](_N + 1);
        _mod = mod;

        _fact[0] = 1;
        foreach (i ; 1 .. _N + 1) {
            _fact[i] = (_fact[i-1] * i) % mod;
        }

        _factinv[_N] = _powmod(_fact[_N], mod - 2);
        foreach_reverse (i ; 0 .. _N) {
            _factinv[i] = (_factinv[i+1] * (i+1)) % mod;
        }
    }

    long comb(int n, int k) {
        return fact(n) * factinv(n - k) % mod * factinv(k) % mod;
    }

    long perm(int n, int r) {
        return fact(n) * factinv(n - r) % mod;
    }

    long fact(int n) {
        return _fact[n];
    }

    long factinv(int n) {
        return _factinv[n];
    }

    long _powmod(long x, long y) {
        return y > 0 ? _powmod(x, y>>1)^^2 % mod * x^^(y & 1) % mod : 1;
    }
}














































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4220
#include <iostream>
#include <stdio.h>

using namespace std;

const int MM=(20+20)*(20+20)*10+5;
const int MN=15;
const int MD=15;

int f[MM];

int x[MN][MD];

int d,n;

int dis(int i,int j)
{
	int ans=0;
	for(int k=0;k<d;k++)
		ans+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
	return ans;
}

int main()
{
	for(int i=1;i*i<MM;i++)
		f[i*i]=1;
	scanf("%d%d",&n,&d);
	for(int i=0;i<n;i++)
		for(int j=0;j<d;j++)
			scanf("%d",&x[i][j]);
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			ans+=f[dis(i,j)];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans_t = abs(A-(T - (H[0] * 0.006)))
ans_h = 1
for i in range(1, N):
    tmp_t = abs(A-(T - (H[i] * 0.006)))
    if tmp_t < ans_t:
        ans_t = tmp_t
        ans_h = i+1
print(ans_h)


Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var a, b, c, d, e int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)
	fmt.Scan(&e)

	times := []int{a, b, c, d, e}
	minNum := 10
	sum := 0

	for _, t := range times {
		sum += (t / 10) * 10
		if t%10 == 0 {
			continue
		} else if minNum == 10 {
			minNum = t % 10
		} else if minNum > t%10 {
			minNum = t % 10
			sum += 10
		} else {
			sum += 10
		}
	}

	sum += minNum % 10

	fmt.Println(sum)

}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

using CC = pair<int, int>;

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

	vector<int> P(M);
	vector<int> Y(M);

	vector<vector<int>> S(N, vector<int>());
	rep(i, M)
	{
		cin >> P[i] >> Y[i];
		S[P[i]-1].push_back(Y[i]);
	}

	vector<unordered_map<int, int>> T(N);
	rep(i, N)
	{
		sort(S[i].begin(), S[i].end());

		rep(j, S[i].size())
		{
			T[i][S[i][j]] = j+1;
		}
	}

	rep(i, M)
	{
		string A, B;
		A = to_string(P[i]);
		A = string(6 - A.size(), '0') + A;

		B = to_string(T[P[i]-1][Y[i]]);
		B = string(6 - B.size(), '0') + B;

		cout << A + B << endl;
	}
	
	return 0;
}

Measured memory_bytes: 21056
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int ans = 2e9;
    int a,b;
    int tmpa = 0,tmpb;
    rep(i,n){
        cin >> a >> b;
        if(tmpa < a){
             tmpa = a;
             tmpb = b;
        }
    }
    cout << tmpa + tmpb << endl;

    return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> d(N);
    rep(i, 0, N) cin >> d[i];
    int ans = 0;
    rep(i,0, N){
        rep(j, i + 1, N){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,p;
	cin>>p>>n;
	vector<int> v(n);
	for(int &x: v)cin>>x;
	int md = 0;
	for(int i=0;i<n-1;i++)
	{
		md = max(md,v[i+1]-v[i]);
	}
	md = max(md,p-v[n-1]+v[0]);
	cout<<p-md<<'\n';
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[m];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0; i < m; i++) {
            b[i] = sc.nextLong();
        }

        long total = 0;
        int j = 0;
        while (j < m) {
            if (total + b[j] <= k) {
                total += b[j];
                j++;
            } else {
                break;
            }
        }

        int max = j;
        int i = 0;
        while (i < n) {
            total += a[i];
            i++;
            while (0 < j && k < total) {
                j--;
                total -= b[j];
            }
            if (k < total) {
                break;
            }
            if (max < i + j) {
                max = i + j;
            }
        }

        System.out.println(max);

    }

}


Measured memory_bytes: 63052
#include<iostream>
 
using namespace std;
 
int main()
{
  int h, w;
 
  cin >> h >> w;
 
  while(true)
    {
      if (h == 0 && w == 0) break;
 
      for (int i = 0; i < h; i++)
        {
          if (i == 0 || i == h-1)
            {
              for (int j = 0; j < w; j++)
                {
                  cout << "#";
                }
              cout << endl;
            }
          else
            {
              for (int j = 0; j < w; j++)
                {
                  if (j == 0 || j == w-1)
                    {
                      cout << "#";
                    }
                  else
                    {
                      cout << ".";
                    }
                }
              cout << endl;
            }
        }
      cout << endl;
      cin >> h >> w;
    }
   
  return 0;
}

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

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

int main(){
	int mon[100][100];
	int tim[100][100];
	int n,m;
	while(cin >> m >> n && n ){
		rep(i,n)rep(j,n) mon[i][j] = tim[i][j] = 1e9;
		for(int i = 0 ; i < m ; i++){
			int a,b,c,d;
			cin >> a >> b >> c >> d;
			a--,b--;
			mon[a][b] = mon[b][a] = c;
			tim[a][b] = tim[b][a] = d;
		}
		rep(i,n)rep(j,n)rep(k,n){
			mon[j][k] = min(mon[j][k],mon[j][i]+mon[i][k]);
			tim[j][k] = min(tim[j][k],tim[j][i]+tim[i][k]);
		}
		int R;
		cin >> R;
		rep(i,R){
			int a,b,c;
			cin >> a >> b >> c;
			a--,b--;
			if(c) cout << tim[a][b];
			else cout << mon[a][b];
			cout << endl;
		}
	}
}

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

int main() {
    constexpr int INF = 1e9 + 6;
    int n, ma, mb; cin >> n >> ma >> mb;
    vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(401, vector<int>(401, INF)));
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++) {
        int a, b, c; cin >> a >> b >> c;
        for (int j = 0; j < 401; j++) {
            for (int k = 0; k < 401; k++) {
                if (dp[i][j][k] == INF) continue;
                dp[i + 1][j + a][k + b] = min(dp[i + 1][j + a][k + b], dp[i][j][k] + c);
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
            }
        }
    }
    int ans = INF;
    for (int i = 1; i < 401; i++) {
        if (ma * i <= 400 && mb * i <= 400) {
            ans = min(ans, dp[n][ma * i][mb * i]);
        }
        else {
            break;
        }
    }
    if (ans == INF) puts("-1");
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m;
int main(){
  cin >> n >> m; 
  ll ans = 1;
  for(ll i=1;i*i<=m;i++){
    if (m % i == 0){
      if (m/i >= n) ans = max(ans, i);
      if (i >= n) ans = max(ans, m/i);
    }    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ll long long
#define ull unsigned long long
#define pb push_back
#define rr return 0
#define fi first
#define se second
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define sz(s) s.size()
using namespace std;
//Debug template by livw
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


//const int Nmax=1000005;
//int arr[Nmax];

int main() 
{
    char ans;
    cin>>ans;
    if(ans>=65 && ans<=90)
    {
        cout<<"A";
    }
    else
    {
        cout<<"a";
    }
    rr;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void debug() { std::cerr << '\n'; }
template <class H, class... T> void debug(H &&head, T &&... args) {
    std::cerr << head;
    sizeof...(args) == 0 ? std::cerr << "" : std::cerr << ' ';
    debug(std::forward<T>(args)...);
}
template <class T> void debug(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cerr << v[i];
        i == v.size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
    }
}
template <class T> void debug(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cerr << v[i][j];
            j == v[i].size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
        }
    }
}

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

    int N, M;
    cin >> N >> M;
    vector<int> v(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        v[a - 1] ^= 1;
        v[b - 1] ^= 1;
    }
    for (auto &&i : v) {
        if (i == 1) {
            print("NO");
            return 0;
        }
    }
    print("YES");

    return 0;
}

Measured memory_bytes: 640
list = []
count = 0
flag = True

while flag:
    h,w=input().split()
    list.append((int(h),int(w)))
    if list[count][0] == 0:
        flag = False
    count += 1

for k in range(len(list)):
    for i in range(list[k][0]):
        for j in range(list[k][1]):
            print("#",end="")
        print("")
    if list[k][0] == 0:
        break
    print("")



Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
int main() {
	int A,B,K;
	cin >> A >> B;
	if ((A + B) % 2 == 0)
	{
		K = (A + B) / 2;
		cout << K;
		cout << endl;
	}
	else {
		cout << "IMPOSSIBLE";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main()
{
	string s;
	cin >> s;
	if (s == "ABC")	cout << "ARC" << endl;
	else {
		cout << "ABC" << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <cstdio>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);

  int res = 40;
  for (int i = 0; i < N; ++i) {
    int A;
    scanf("%d", &A);
    int cur = 0;
    while (A % 2 == 0) {
      A /= 2;
      ++cur;
    }
    res = std::min(res, cur);
  }
  printf("%d\n", res);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[10];
	for (int i = 0; i < 10; i++)
	{
		cin >> a[i];
		for (int j = 0; j < 10; j++)
		{
			if (a[0] < a[i])swap(a[i], a[0]);
		}

		for (int j = 0; j < 10; j++)
		{
			if (a[1] < a[i])swap(a[i], a[1]);
		}
			
		for (int j = 0; j < 10; j++)
		{
			if (a[2] < a[i])swap(a[i], a[2]);
		}

	}
	cout << a[0] << endl;
	cout << a[1] << endl; 
	cout << a[2] << endl;
	
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
    int m, f, b;

    scanf("%d%d%d", &m, &f, &b);
    
    if (m >= b){
        printf("0\n");
    }
    else if (m + f >= b){
        printf("%d\n", (b - m));
    }
    else {
        printf("NA\n");
    }

    return (0);
}



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

int main() {
    int n,m;
    cin >> n >> m;
    int s[100], c[100];
    for (int i = 0; i < m; ++i)
    {
        cin >> s[i] >> c[i];
    }


    int ret[3];
    for (auto& it : ret)
        it = -1;

    for (int i = 0; i < m; ++i)
    {
        int keta = s[i];
        if (ret[n - keta] == -1 || ret[n - keta] == c[i])
            ret[n - keta] = c[i];
        else
        {
            cout << -1;
            return 0;
        }
    }

    for (int i = 0; i < n; ++i)
    {
        if (ret[i] == -1)
            ret[i] = i == n-1 && n != 1 ? 1 : 0;
    }

    int result = 0;
    int keta = 1;
    for (int i = 0; i < n; ++i)
    {
        result += ret[i] * keta;
        keta *= 10;
    }

    if (n != 1 && ret[n - 1] == 0)
    {
        cout << -1;
        return 0;
    }

    if (result == 0)
    {
        cout << 0;
        return 0;
    }

    if (keta <= result * 10)
        cout << result;
    else
        cout << -1;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define ull unsigned long long
#define ll long long
void codeforces()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.in", "w", stdout);
    #endif
}

int32_t main()
{
    //codeforces();
    // int t;cin>>t;
    // while(t--) {
        
    // }
    int n;cin>>n;
    vi b(n);
    for(int i=0;i<n;i++)cin>>b[i];
    vi a(n);
    for(int i=0;i<n;i++){
        a[b[i]-1]=i+1;
    }
    for(int i=0;i<n;i++)cout<<a[i]<<" ";
        cout<<'\n';
    return 0;
}

Measured memory_bytes: 2432
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=100005;
int n,x,q;
int a[maxn],p[maxn][20][2];
vector<int>edge[maxn][2];

void dfs(int x,int par,int type){
	p[x][0][type]=par;
	rep(i,edge[x][type].size()){
		int y=edge[x][type][i];
		if(y!=par)dfs(y,x,type);
	}
}

void get_p(){
	rep(t,2){
		if(!t)dfs(n-1,-1,0);
		else dfs(0,-1,1);
		rep(j,19)rep(i,n)
		if(p[i][j][t]!=-1)p[i][j+1][t]=p[p[i][j][t]][j][t];
		else p[i][j+1][t]=-1;
	}
}

int up(int u,int dis,int t){
	for(int i=19;i>=0;i--)
	if(dis&(1<<i)){
		if(p[u][i][t]==-1){
			if(!t)return INF+10;
			else return -1;
		}
		u=p[u][i][t];
	}
	return u;
}

int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	scanf("%d",&x);
	rep(i,n-1){
		int cur=a[i]+x;
		int pos=upper_bound(a,a+n,cur)-a-1;
		edge[i][0].push_back(pos);
		edge[pos][0].push_back(i);
	}
	for(int i=n-1;i>=1;i--){
		int cur=a[i]-x;
		int pos=lower_bound(a,a+n,cur)-a;
		edge[i][1].push_back(pos);
		edge[pos][1].push_back(i);
	}
	get_p();
	scanf("%d",&q);
	while(q--){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;v--;
		if(u<v){
			int l=0,r=n;
			while(r-l>1){
				int mid=(l+r)>>1;
				int cur=up(u,mid,0);
				if(cur>v)r=mid;
				else l=mid;
			}
			if(up(u,l,0)>=v)printf("%d\n",l);
			else if(up(u,r,0)>=v)printf("%d\n",r);
		}
		else{
			int l=0,r=n;
			while(r-l>1){
				int mid=(l+r)>>1;
				int cur=up(u,mid,1);
				if(cur<v)r=mid;
				else l=mid;
			}
			if(up(u,l,1)<=v)printf("%d\n",l);
			else if(up(u,r,1)<=v)printf("%d\n",r);
		}
	}
	return 0;
}
/*
9
1 3 6 13 15 18 19 29 31
10
10000
1 8
7 3
6 7
8 5
*/

Measured memory_bytes: 34048
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int p[100001],r[100001];
void init(){rep(i,100001)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

void Main() {
  init();
  int n,m;
  cin >> n >> m;
  vector<int> v[m];
  for(int i=0; i<n; i++) {
    int k;
    R k;
    for(int j=0; j<k; j++) {
      int x;
      R x;
      x--;
      v[x].pb(i);
    }
  }
  for(int i=0; i<m; i++) {
    for(int j=0; j<v[i].size(); j++) unite(v[i][0],v[i][j]);
  }
  set<int> s;
  for(int i=0; i<n; i++) s.in(find(i));
  if(s.size()==1) pr("YES");
  else pr("NO");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
using namespace std;
int main(){
  string t;
  cin >> t;
  int size=t.size();
  while(t.find('?')!=string::npos){
  	for(int i=0;i<size;i++){
      if(t.at(i)!='?')continue;
      if((i!=0)&&(i!=size-1)){
   	  	if(t.at(i-1)=='P')t.replace(i,1,"D");
        else if(t.at(i-1)=='D'&&t.at(i+1)=='D')t.replace(i,1,"P");
        else if(t.at(i-1)=='D'&&t.at(i+1)=='P')t.replace(i,1,"D");
        else if(t.at(i-1)=='D'&&t.at(i+1)=='?')t.replace(i,1,"D");
      }else if(i==size-1){
        t.replace(i,1,"D");
      }else{
        if(t.at(i+1)=='D')t.replace(i,1,"P");
        else t.replace(i,1,"D");
      }
  	}
  }
  cout << t << endl;
}

Measured memory_bytes: 3760
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun main (str)
  (count #\1 str))

(princ (main (read-line)))


Measured memory_bytes: 19128
#include <bits/stdc++.h>
#define pb(x) push_back(x)

using namespace std;
typedef vector<int> vi;

int xt, yt, cnt;
string s;
bitset<8005> dp[2][8005];
vi vx, vy, v;

bool esPos (int p, int id, int a) {
	if (id == v.size()) return p == a;

	if (p >= 0) {
		if (dp[0][p][id]) return 0;
		dp[0][p][id] = 1;
	} else {
		if (dp[1][-p][id]) return 0;
		dp[1][-p][id] = 1;
	}

	if (esPos(p + v[id], id + 1, a) || esPos(p - v[id], id + 1, a))
		return 1;
	return 0;
}

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

	cin >> s >> xt >> yt;

	for (char c : s)
		if (c == 'F') cnt++;
		else {
			if(vx.size() == vy.size()) vx.pb(cnt);
			else vy.pb(cnt);
			cnt = 0;
		}

	if (vx.size() == vy.size()) vx.pb(cnt);
	else vy.pb(cnt);

	v = vx;
	if (!esPos(v[0], 1, xt)) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < 8005; i++)
		dp[0][i].reset(), dp[1][i].reset();
	
	v = vy;
	if (!esPos(0, 0, yt)) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 16256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		char[] orig = "CODEFESTIVAL2016".toCharArray();
		char[] my = sc.next().toCharArray();
		int ans = 0;
		for (int i = 0; i < my.length; ++i) {
			if (orig[i] != my[i]) ++ans;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 10064
a=int(input(""))
b=int(input(""))
c=int(input(""))
x=int(input(""))
def countcourse(r,t,y,u):
    cnt=0
    n=0
    for h in range(r+1):
        for l in range(t+1):
            for o in range(y+1):
                if 500*h+100*l+50*o==u:
                    cnt+=1
    return cnt
print(countcourse(a,b,c,x))

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    int n, m;
    string s;
    map<string, int> a, b;

    cin >> n;
    while (n--) {
        cin >> s;
        a[s]++;
    }
    cin >> m;
    while (m--) {
        cin >> s;
        b[s]++;
    }

    int ans = 0;
    for (auto t : a) {
        ans = max(ans, a[t.first] - b[t.first]);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int c,d,x,flag=0,flag2=0,count=0,n,m,y,max=-1000,min=99999;
  vint a(10000,0);
  vint b(10000,0);
  string s;
  cin>>s;
  c=s.size();
  rep(i,c){
    if(i==0){
      if(s[i]=='B'){
	flag=1;
      }
      else{
	flag2=1;
      }
    }
    else{
      if(flag==1){
	if(s[i]=='W'){
	  count++;
	  flag=0;
	  flag2=1;
	}
      }
      else if(flag2==1){
	if(s[i]=='B'){
	  count++;
	  flag=1;
	  flag2=0;
	}
      }
    }
  }
  cout<<count<<'\n';
  return(0);
}


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

int main() {
    string S;
    int count = 0;
    cin >> S;
    for (int i = 0; i < S.size()/2; i++){
        if(S.at(i) != S.at(S.size()-i-1)){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
int main(){
  string s;
  cin >> s;
  ll size = s.size();
  rep(i,size){
    if(i % 2 == 0)cout << s[i];
  }
  cout << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i,n) cin >> a[i];
  vector<int> ans(n);
  //気分的にはans[a[i]]=iにしたいけどa[i]は1から始まるけどansの添字は0~n-1までで、i+1にするのは添字は0~n-1までだけど出席番号は1からだから
  rep (i,n) ans[a[i]-1]=i+1;
  rep (i,n) {
     cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
long long a[3010],b[3010],dp[3010][6010];
pair<long long,long long> p[3010];
int main(){
	int i,j,n,t;
	cin >> n >> t;
	for(i=0;i<n;i++){
		cin >> a[i] >> b[i];
		p[i] = {a[i],b[i]};
	}
	sort(p,p + n);
	for(i=0;i<n;i++){
		a[i] = p[i].first,b[i] = p[i].second;
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=6001;j++){
			dp[i][j] = -100000000000;
		}
	}
	dp[0][0] = 0;
	for(i=1;i<=n;i++){
		for(j=0;j<=6001;j++){
			dp[i][j] = max(dp[i][j],dp[i - 1][j]);
		}
		for(j=0;j<t;j++){
			dp[i][j + a[i - 1]] = max(dp[i][j + a[i - 1]],dp[i - 1][j] + b[i - 1]);
		}
	}
	long long mx = 0;
	for(i=0;i<=6001;i++){
		mx = max(dp[n][i],mx);
	}
	cout << mx << endl;
}
	

Measured memory_bytes: 141568
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	vector<int> vec(N);
	rep( i, 0, N ){
		cin >> vec[i];
	}
	sort_desc( vec );
	ll h = 0, w = 0;
	rep(i,0,N){
		if (vec[i] == vec[i+1]){
			h = w;
			w = vec[i];
			i++;
		}
		if (h > 0)
			break;
	}
	cout << h*w << endl;

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-8;
const double pi=acos(-1.0);
const int K=1e6+7;
const int mod=1e9+7;
 
int r,c,n,x,y,ans[200][200];
 
int main(void)
{
    scanf("%d%d%d",&r,&c,&n);
    x=1,y=1;
    for(int i=1,cnt;i<=n;i++)
    {
        scanf("%d",&cnt);
        while(cnt--)
        {
            ans[x][y]=i;
            if(y==c&&x%2==1)
                y=c,x++;
            else if(y==1&&x%2==0)
                y=1,x++;
            else if(x&1)
                y++;
            else
                y--;
        }
    }
    for(int i=1;i<=r;i++)
    for(int j=1;j<=c;j++)
        printf("%d%c",ans[i][j],j==c?'\n':' ');
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);

    int a[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        for (int j = i; j > 0; j--) {
            if (a[j] > a[j-1]) {
                int tmp;
                tmp = a[j-1];
                a[j-1] = a[j];
                a[j] = tmp;
            }
        }
    }

    int alice=0, bob=0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    printf("%d\n", alice - bob);
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys

# from math import gcd
from fractions import gcd

def isprime(x :int):
    if(x == 1):
        return False

    for i in range(2, int(x**0.5)+1):
        if(x%i == 0):
            return False

    return True


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def solve(A: int, B: int):

    x = list(set(make_divisors(A)) & set(make_divisors(B)))
    
    ans = 1
    for i in x:
        if(isprime(i)):
            ans += 1

    print(ans)
            
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7196
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vecl divisors(ll N) {
    vecl ans;
    for(ll i = 1; i * i <= N; i++) {
        if(N%i == 0) {
            ans.push_back(i);
            if(N/i != i) ans.push_back(N/i);
        }
    }
    sort(ans.begin(),ans.end(),greater<ll>());
    return ans;
}

int main() {
    ll N,M; cin >> N >> M;
    vecl res = divisors(M);
    for(ll x : res) {
        if(x <= M/N) {
            cout << x << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define all(a) a.begin(), a.end()
#define sz(a) a.size()
using namespace std;

int n, m, k, b=0, ans=0;
char a[6][6];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("A.txt", "r", stdin);
    #endif
    cin >> n >> m >> k;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
            if(a[i][j]=='#') b++;
        }
    }
    for(int i=0; i<(1<<n); i++){
        for(int j=0; j<(1<<m); j++){
            int tb=b;
            for(int k=0; k<n; k++){
                for(int l=0; l<m; l++){
                    if(a[k][l]=='#'&&((i&(1<<k))||(j&(1<<l)))) tb--;
                }
            }
            if(tb==k) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3576
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int odddp[2030]={},evendp[2030]={},res=0;
long long int N,M,A,B,C,X,Y;


int main()
{
    cout << fixed << setprecision(18);
    cin>>A>>B>>C>>X>>Y;
    if(X>=Y){
    cout<<min({max(X,Y)*C*2,min(X,Y)*C*2+(X-Y)*A,X*A+Y*B})<<endl;
    }else{

    cout<<min({max(X,Y)*C*2,min(X,Y)*C*2+(Y-X)*B,X*A+Y*B})<<endl;
    }
}    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
const int MAXN = 1e5 + 5;

int main()
{
	zapp;
	ll n, x, t;
	cin >> n >> x >> t;
	if (n % x == 0)
		cout << (n / x)*t;
	else
		cout << ((n / x) + 1)*t;

	return 0;
}



Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int a=0,b=int.MaxValue;
		for(int i = 1;i<=s[0];i++) {
			a+=s[1]+i-1;
			if(Abs(b)>Abs(s[1]+i-1)){b=s[1]+i-1;}
		}
		Console.WriteLine("{0}",a-b);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13268
N = int(input())
a = list(map(int, input().split()))
cnt_4 = 0
cnt_2 = 0
for i in range(N):
    if a[i]%4 == 0:
        cnt_4 += 1
    elif a[i]%2 == 0:
        cnt_2 += 1
if cnt_4 + cnt_2//2 >= N//2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62576
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int a[105][105];
int main()
{
	int n,k;cin >> n >> k;
    for(int i = 1;i <= k;++i)
    {
    	int d;cin >> d;
    	for(int j = 1;j <= d;++j)
    	{
    		int x;cin >> x;
    		a[x][i] = 1;
    	}
    }
    int res = 0;
    for(int i = 1;i <= n;++i)
    {
    	bool ok = 1;
    	for(int j = 1;j <= k;++j)
    	{
    		if(a[i][j] != 0)
    		{
    			ok = 0;
    			break;
    		}
    	}
    	res += ok;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3668
<?php

    fscanf(STDIN, "%s", $input);
    $array = preg_split("/[^ACGT]/", $input);
    $result = 0;
    foreach ($array as $key => $value) {
    	
    	if ($result<strlen($value)) {
    		$result = strlen($value);
    	}
    }
    echo $result;


Measured memory_bytes: 4856
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  LL H;
  cin >> H;
  vector<LL> v(H);
  REP(i,H){
    cin >> v[i];
  }

  LL ans = 0;

  REP(i,H){
    bool flag = true;
    REP(j, i)
    {
      if(v[j]>v[i]){
        flag = false;
      }
    }
    if(flag){
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    int A, B;
    cin >> A >> B;

    cout << A * B << endl;

    return 0;
}


Measured memory_bytes: 3172