akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int n, k;
	cin >> n >> k;
	int ret = k;
	rep(i, n - 1) {
		ret *= k - 1;
	}
	cout << ret << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --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; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N), B(N), C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    rep(i, N) {
        int a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        int b = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += (ll)a * b;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int N,K;
    string s;
    int i;
    cin >> N >> K >> s;
    for(i=0;i<N;i++){
      if(i!=K-1)cout << s[i];else cout << char(s[i]+32);
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

ans = 1
idx = 1
C = sorted(Counter(D[1:]).items())
for k, v in C:
    if k != idx:
        print(0)
        exit()
    if k == 1:
        _v = v
    else:
        ans = ans * _v ** v % 998244353
        _v = v
    idx += 1
print(ans)


Measured memory_bytes: 22236
import sys

def is_ok(i, conds):
    str_i = str(i)
    for cond in conds:
        if len(str_i) <= cond[0]-1:
            return False
        if not str_i[cond[0]-1] == str(cond[1]):
            return False
    return True

# print('input >>')
N, M = map(int,(input().split()))
scs = []
for _ in range(M):
    scs.append(tuple(map(int,(input().split()))))

start = 10**(N-1) if N >=2 else 0

for i in range(start, 10**N):
    if is_ok(i, scs):
       print(i)
       sys.exit() 

print(-1)

# print('-----output-----')

Measured memory_bytes: 3064
S = input()
O = set(S[::2])
E = set(S[1::2])
ans1 = [True if c in 'RUD' else False for c in O]
ans2 = [True if c in 'LUD' else False for c in E]
print('Yes' if False not in ans1 and False not in ans2 else 'No')

Measured memory_bytes: 3060
//#define LOCAL
#define INPUT
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define MAXSIZE 10010


#include <map>

using std::map;

int main(){
    #ifdef LOCAL
    freopen("in.txt", "r", stdin);
    #endif

    int n = 0;
    scanf("%d", &n);

    map<int, int> imap;
    int ii;
    for(int i = 0; i < n; ++i){
        scanf("%d", &ii);
        imap[ii]++;
    }
    int res = 0;
    for(auto it = imap.begin(); it != imap.end(); it++){
        if(it->second % 2 != 0){
            res++;
        }
    }
    printf("%d\n", res);



    return 0;

}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
const int maxn=2000;
char s[maxn];
char t[maxn];
int main()
{
   scanf("%s",s);
   scanf("%s",t);
   int len1=strlen(s);
   int len2=strlen(t);
   int ans=1e9;
   int cnt;
   for(int i=0;i<len1-len2+1;i++)
   {
   	cnt=0;
   	for(int j=i;j<=i+len2-1;j++)
   	{
   		if(s[j]!=t[j-i])
   		{
   			cnt++;
		   }
	   }
	   ans=min(ans,cnt);
	}
	printf("%d",ans); 
 } 

Measured memory_bytes: 3836
#include <stdio.h>
#define NMAX 9
 
int main(void){
    int a,b,c,d,n,temp;
    int sum;
    int count;
    while(scanf("%d",&n)!=EOF){
        count=0;
        sum=0;
        if(n<0||n>NMAX*4){
            printf("0\n");
            continue;
        }
        for(a=NMAX;a>=0;a--){
            for(b=NMAX;b>=0;b--){
                for(c=NMAX;c>=0;c--){
                    for(d=NMAX;d>=0;d--){
                        if(a+b+c+d==n){
                            count++;
                            //printf("a=%d,b=%d,c=%d,d=%d,count=%d\n",a,b,c,d,count);
                        }
                    }
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k,x,i;
	cin>>k>>x;
	for(i=x-k+1;i<x;i++)
		printf("%d ",i);
	for(i=x;i<x+k;i++)
		printf("%d ",i);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
void chmin(ll &a, ll b){a = min(a, b);}
void solve(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	string s;
    cin >> s;
    set<ll> se;
    for(int i=n-1;i>=0;i--){
    	for(auto itr=se.end();itr!=se.begin();) itr--,chmin(a[i], a[i] ^ *itr);
    	if(a[i]){
    		if(s[i] == '1'){
    			cout << 1 << endl;
    			return;
    		}else se.insert(a[i]);
    	}
    }
    cout << 0 << endl;
    return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 3648
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn read_str_as_char_vec() -> Vec<char> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().chars().collect()
}

fn read_str_as_T<T>() -> T 
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().unwrap()
}

fn main() {
    let x: usize = read_line()[0];

    let mut res = 0;
    let mut base: usize = 100;
    while (base as usize) < x {
        base = ((base as f64) * 1.01) as usize;
        res += 1;
    }

    println!("{}", res);
    // let a_base = (x/100.).log(1.01);
    // if a_base.fract() == 0. {
    //     println!("{}", a_base as usize);
    // } else {
    //     println!("{}", a_base as usize + 1);
    // }
}

Measured memory_bytes: 2116
#include <iostream>
#include <queue>

using namespace std;
using ll = long long;

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

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

  int ans[n];
  rep(i, n) ans[i] = 0;

  const int INF = 1 << 21;

  vector<int> m[n];
  m[x].push_back(y);
  m[y].push_back(x);
  rep(i, n) {
    if (i - 1 >= 0) m[i].push_back(i - 1);
    if (i + 1 <= n - 1) m[i].push_back(i + 1);
  }

  rep(i, n) {
    int d[n];
    rep(i, n) d[i] = INF;
    d[i] = 0;
    queue<int> q;
    q.push(i);

    while (!q.empty()) {
      int u = q.front();
      q.pop();
      if (i < u) ++ans[d[u]];

      for (auto v : m[u]) {
        if (d[v] == INF) {
          q.push(v);
          d[v] = d[u] + 1;
        }
      }
    }
  }

  for (int k = 1; k <= n - 1; ++k) {
    cout << ans[k] << '\n';
  }

  return 0;
}


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());
// greatest common divisor
long long gcd(long long a, long long b) {
  if (a==0 || b==0) return a+b;
  long long r = 1;
  while (r != 0) {
    r = a%b; a = b; b = r;
  }
  return a;
}

long long lcm(long long a, long long b) {
  return a/gcd(a,b)*b;
}


class CSnack {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll a, b; cin >> a >> b;
      cout << lcm(a,b) << endl;
    }
};

signed main() {
  CSnack solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
n.times{
  a,b,c,p,o=[0]*5
  loop{
    e=gets;
    if e[?I]
      p+=c
      a,b,c=1,a,b
    elsif e[?H]
      p+=a+b+c+1
      a,b,c=[0]*3
    else
      if(o+=1)==3
        break
      end
    end
  }
  p p
}

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
 
int main(){
vector<vector<int>>data(3,vector<int>(3));
int n,i,j,k;
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cin>>data[i][j];
    }
}
cin>>n;
vector<int>b(n);
for(i=0;i<n;i++)
cin>>b[i];
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        for(k=0;k<n;k++){
            if(b[k]==data[i][j])
            data[i][j]=0;
        }
    }
}
if(data[0][0]==0 && data[0][1]==0 && data[0][2]==0 || data[1][0]==0 && data[1][1]==0 && data[1][2]==0 || data[2][0]==0 && data[2][1]==0 && data[2][2]==0 || data[0][0]==0 && data[1][0]==0 && data[2][0]==0 || data[0][1]==0 && data[1][1]==0 && data[2][1]==0 || data[0][2]==0 && data[1][2]==0 && data[2][2]==0 || data[0][0]==0 && data[1][1]==0 && data[2][2]==0 || data[2][0]==0 && data[1][1]==0 && data[0][2]==0)
    cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x, y, temp;
    scanf("%d %d", &x, &y);
    
    while (x+y != 0) {
        if (x > y) {
            temp = x;
            x = y;
            y = temp;
        } 
        printf("%d %d\n", x, y);
        scanf("%d %d", &x, &y);
    }
    return 0;
}   

Measured memory_bytes: 2584
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,ans;
string s;
int32_t main(){
CODE_START;
cin >> s;
n=4;
if(s[0]=='0'&&s[1]!='0'){
    ans++;
}else {
if(s[0]=='1'&&(s[1]=='0'||s[1]=='1'||s[1]=='2')){
    ans++;
}
}
if(s[2]=='0'&&s[3]!='0'){
    ans++;
}else {
if(s[2]=='1'&&(s[3]=='0'||s[3]=='1'||s[3]=='2')){
        ans++;
}
}
if(ans==2){
    rc("AMBIGUOUS");
}
ans=0;
if(s[0]=='0'&&s[1]!='0'){
    ans++;
}else {
if(s[0]=='1'&&(s[1]=='0'||s[1]=='1'||s[1]=='2')){
    ans++;
}
}
if(ans==1){
    rc("MMYY");
}
if(s[2]=='0'&&s[3]!='0'){
    ans++;
}else {
if(s[2]=='1'&&(s[3]=='0'||s[3]=='1'||s[3]=='2')){
    ans++;
}
}
if(ans==1){
 rc("YYMM");
}
cout<<"NA";
return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int count = 0;
    int ans = 0;
    for(int i = 0; i < n-1; i++) {
        if(h[i] >= h[i+1]) {
            count++;
        }else {
            ans = max(ans,count);
            count = 0;
        }
    }
    ans = max(ans,count);
    cout << ans << endl;
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int &e : A) cin >> e;
  sort(A.begin(),A.end());
  int M = A[N-1];
  A.pop_back();
  auto itr = lower_bound(A.begin(),A.end(),M/2);
  int a = *itr;
  int b = *(itr - 1);
  int m  = a;
  if (a >= M-b) m = b;
  cout << M << " " << m << endl;
}

Measured memory_bytes: 640
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include<string.h>
#include<memory.h>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//ここから下

int par[100005];
int lank[100005];

void init(int n){
    for(int i=0; i<n; i++){
        par[i]=i;
        lank[i]=0;
    }
}
int find(int x){
    if(par[x]==x){
        return x;
    }else {
        return par[x]=find(par[x]);
    }
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(lank[x]<lank[y]){
        par[x]=y;
    }else {
        par[y]=x;
        if(lank[x]==lank[y])lank[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}
signed main(){
    int n,q;cin>>n>>q;
    init(n);
    rep(i,0,q){
        int a,b,c;cin>>a>>b>>c;
        if(a){
           cout<<(same(b,c)?1:0)<<endl;
        }
        else unite(b,c);
    }
    return 0;
}



Measured memory_bytes: 3252
// AOJ 2209: UTF-8
// 2017.12.9

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define M 1000000

char b[1001][10];
int dp[1001];
char utf8[4][4][9] = {
  { "0xxxxxxx" },
  { "110yyyyx", "10xxxxxx" },
  { "1110yyyy", "10yxxxxx", "10xxxxxx" },
  { "11110yyy", "10yyxxxx", "10xxxxxx", "10xxxxxx" }};

int calc(int k, int w)
{
	int i, x, y, ans;
	char *p, *q;

	x = 0, y = 0, ans = 1;
	for (i = 0; i < w; i++) {
		p = b[k+i], q = utf8[w-1][i];
		while (*p >= ' ') {
			if (*p == '0' || *p == '1') {
				if ((*q == '0' || *q == '1') && *q != *p) return 0;
				if (*q == 'y' && *p == '1') y = 1;
			} else {		// *p == 'x'
				if (*q == 'x') { ans <<= 1; if (ans >= M) ans -= M; }
				else if (*q == 'y') x++;
			}
			p++, q++;
		}
	}
	if (w > 1) {
		if (!x && !y) ans = 0;
		else {
			x = 1 << x;
			if (!y) x--;
			ans = ((long long)ans * x) % M;
		}
	}
	return ans;
}

int main()
{
	int n, i, j, x;
	char buf[6];

	while (fgets(buf, 6, stdin) && *buf != '0') {
		n = atoi(buf);
		for (i = 0; i < n; i++) fgets(b[i], 10, stdin);

		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		for (i = 0; i < n; i++) for (j = 1; j <= 4 && i+j <= n; j++) {
			if (x = calc(i, j)) {
				x = ((long long)dp[i] * x) % M;
				dp[i+j] += x;
				if (dp[i+j] >= M) dp[i+j] -= M;
			}
		}
		printf("%d\n", dp[n]);
	}
	return 0;
}

Measured memory_bytes: 1772
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>

int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int ans = 0;
    if (b<=c || d<=a) {
        ans = 0;
    } else if (a<=c && c<=b && b<=d) {
        ans = b-c;
    } else if (c<=a && a<=d && d<=b) {
        ans = d-a;
    } else if (a<=c && d<=b) {
        ans = d-c;
    } else {
        ans = b-a;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int h = in.nextInt(), w = in.nextInt();
			if(w==0 && h==0) return ;
			String board[] =  new String[h];
			for(int i=0; i<h; i++){
				board[i] = in.next();
			}
			int cx = 0, cy = 0;
			boolean isLoop = false;
			HashSet<Integer> s = new HashSet<Integer>();
			while(board[cy].charAt(cx) != '.'){
				char c = board[cy].charAt(cx);
				cx += (c == '>')?1:(c == '<')?-1:0;
				cy += (c == '^')?-1:(c == 'v')?1:0;
				if(s.contains(new Integer(cx*10000+cy))){
					isLoop = true;
					break;
				}
				else{
					s.add(new Integer(cx*10000+cy));
				}
			}
			if(isLoop){
				System.out.println("LOOP");
			}
			else{
				System.out.println(cx + " " + cy);
			}
		}
	}
	
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;


int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);
	rep(i, N) cin >> a[i];
	ll mi = a[0];
	ll mi_index = 0;
	rep(i, N) {
		if (a[i]<mi) {
			mi = a[i];
			mi_index = i;
		}
	}
	ll ma = a[0];
	ll ma_index = 0;
	rep(i, N) {
		if (a[i]>ma) {
			ma = a[i];
			ma_index = i;
		}
	}
	printf("%lld\n", 2 * N - 2);
	if (abs(mi)>abs(ma)) {
		rep(i, N) {
			if (i != mi_index) printf("%lld %lld\n", mi_index + 1, i + 1);
		}
		rep(i, N - 1) {
			printf("%lld %lld\n", N - i, N - i - 1);
		}
	}
	else {
		rep(i, N) {
			if (i != ma_index) printf("%lld %lld\n", ma_index + 1, i + 1);
		}
		rep(i, N - 1) {
			printf("%lld %lld\n", i + 1, i + 2);
		}
	}

	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    ll x,y,z,k; cin >> x >> y >> z >> k;
    ll a[x],b[y],c[z];

    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];
    
    vector<ll> tmp;
    vector<ll> ab;
    rep(i,x){
        rep(j,y) tmp.push_back(a[i]+b[j]);
    }
    sort(tmp.begin(),tmp.end());
    reverse(tmp.begin(),tmp.end());
    rep(i,min(k,(ll)tmp.size())){
        ab.push_back(tmp[i]);
    }
    vector<ll> abc;
    rep(i,ab.size()) rep(j,z) abc.push_back(ab[i]+c[j]);
    sort(abc.begin(),abc.end());
    reverse(abc.begin(),abc.end());
    rep(i,k) cout << abc[i] << endl;
}


Measured memory_bytes: 43396
#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;
    vector<ll> A(3*N);
    REP(i,3*N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    sort(A.rbegin(), A.rend());

    ll ans = 0;
    for(int i = 1; i < 2*N; i+=2){
        ll a = A[i];
        ans += a;
    }

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


Measured memory_bytes: 2560
#include <iostream>
#include <map>
#include <cstring>
using namespace std;

int x[100],y[100],sx[100],sy[100],n;

int lim , N , M , X;

int dp[2][1001][101];
int main(){
	while(cin >> lim >> N >> M >> X && lim){
		memset(x,-1,sizeof(x));
		memset(y,-1,sizeof(y));
		memset(sx,-1,sizeof(sx));
		memset(sy,-1,sizeof(sy));
		for(int i = 0 ; i < 2 ; i++)
			for(int j = 0 ; j < 1001 ; j++)
				for(int k = 0 ; k < 101 ; k++)
					dp[i][j][k] = -99999999;
		for(int i = 0 ; i < N ; i++){
			string t; cin >> t;
			cin >> sx[i] >> sy[i];
		}
		for(int i = 0 ; i < M ; i++){
			string t; cin >> t;
			cin >> x[i] >> y[i];
		}
		dp[0][0][0] = 0;
		
		for(int i = 0 ; i < M ; i++){
			for(int j = 0 ; j <= lim ; j++){
				for(int k = 0 ; k <= M ; k++){
					dp[i&1^1][j][k] = dp[i&1][j][k];
				}
			}
			for(int j = 0 ; j+x[i]  <= lim ; j++){
				for(int k = 0 ; k < M ; k++){
					dp[i&1^1][j+x[i]][k+1] = max( dp[i&1^1][j+x[i]][k+1] , dp[i&1][j][k] + y[i]);
				}
			}
		}
		int ans = 0;
		for(int i = 0 ; i < N ; i++)
			for(int j = i+1 ; j < N ; j++){
				int rem = lim - sx[i] - sx[j];
				for(int w = 0 ; w <= rem ; w++){
					for(int z = X ; z <= M ; z++){
						ans = max(ans,sy[i]+sy[j]+dp[M&1][w][z]);
					}
				}
			}
		for(int i = 0 ; i < N ; i++){
			int rem = lim - sx[i];
			for(int w = 0 ; w <= rem ; w++){
				for(int z = X ; z <= M ; z++){
					ans = max(ans,sy[i]+dp[M&1][w][z]);
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1712
import java.util.Scanner;
import java.lang.Math;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = (int)Math.floor(Math.sqrt(n));
	    ans = ans*ans;
		System.out.println(""+ans);
	}
}

Measured memory_bytes: 21844
x,y = map(int,raw_input().split())

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

flag = False

if x in a and y in a:
    flag = True
if x in b and y in b:
    flag = True
if x in c and y in c:
    flag = True

if flag:
    print 'Yes'
else:
    print 'No'

Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    rep(i,n-1)if(s[i] != s[i+1])ans++;
    cout << ans << endl;

}


Measured memory_bytes: 512
N = int(input())
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i],Y[i] = map(int,input().split())
for i in range(N):
    x = X[i]
    y = Y[i]
    b1 = x+y
    b2 = -x+y
    if i == 0:
        minb1=b1
        maxb1=b1
        minb2=b2
        maxb2=b2
        lowb1=[x,y]
        highb1=[x,y]
        lowb2=[x,y]
        highb2=[x,y]
    else:
        if b1<minb1:
            lowb1=[x,y]
            minb1 = b1
        if b1>maxb1:
            highb1=[x,y]
            maxb1 = b1
        if b2<minb2:
            lowb2=[x,y]
            minb2 = b2
        if b2>maxb2:
            highb2=[x,y]
            maxb2 = b2
            
candidate1 = highb1[0]-lowb1[0]+highb1[1]-lowb1[1]
candidate2 = lowb2[0]-highb2[0]+highb2[1]-lowb2[1]
print(max(candidate1,candidate2))

Measured memory_bytes: 73280
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(S: str):
    ret = S[:3]
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    cout<<max({a+b,a-b,a*b})<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long int
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	ll *x = new ll[n];
	ll *y = new ll[n];
	for(int i = 0; i < n; i++){
			cin >> x[i];
			y[i] = x[i];
	}
	sort(x, x + n, greater<ll>());
	ll med = x[n/2-1];
	ll med2 = x[n/2];//考虑去掉的那个数对中位数的影响 
	for(int i = 0; i < n; i++){
			if(y[i] >= med)cout << med2 << endl;
			else cout << med << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>

using namespace std;


int main()
{
    int n,d1,d2,j=0;
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>d1;
        cin>>d2;
        if (d1==d2){
            j++;
        }else if(d1!=d2 && j<3){
            j=0;
        }
    }
    if (j>2){
        cout<<"Yes";
    }else {
        cout<<"No";
    }
}


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

int main() {
    int N;
    int T, A;
    scanf("%d", &N);
    scanf("%d%d", &T, &A);
    vector<int> H(N, 0);
    for (int i = 0; i < N; i++) {
        scanf("%d", &H.at(i));
    }

    vector<double> temperature(N, 0);
    for (int i = 0; i < N; i++) {
        temperature.at(i) = (double) T - H.at(i) * 0.006;
    }

    double target = (double) A;
    double diff = abs(target - temperature.at(0));
    int ans = 1;
    for (int i = 1; i < N; i++) {
        if (abs(target - temperature.at(i)) < diff) {
            diff = abs(target - temperature.at(i));
            ans = i + 1;
        }
    }
    printf("%d", ans);
}

Measured memory_bytes: 256
def main(a, b, c, d):
    ans = -float('inf')
    for x in [a, b]:
        for y in [c, d]:
            z = x * y
            if ans < z:
                ans = z
    return ans

if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    ans = main(a, b, c, d)
    print(ans)



Measured memory_bytes: 9068
<?php
fscanf(STDIN, '%d %d', $n, $y);
for($i = 0; $i <= $n; $i++){
    for($j = 0; $j <= ($n - $i); $j++){
        $k = $n - $i - $j;
        $total = 10000*$k + 5000*$j + 1000*$i;
        if($total == $y){
            $ans = "$k $j $i";
            break 2;
        }else{
            $ans ='-1 -1 -1';
        }
    }
}
print $ans;

Measured memory_bytes: 4732
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(b-a == c-b){
        System.out.println("YES");
    }else{
        System.out.println("NO");
        
        }

        
    }
}



Measured memory_bytes: 24148
# coding: utf-8
# Your code here!
N, Q = map(int,input().split())
edge = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
add = [0 for i in range(N)]
for q in range(Q):
    p,x = map(int,input().split())
    add[p-1] += x

ans = [0 for i in range(N)]
search = [(0,0)]
while len(search) > 0:
    x = search.pop()
    node,parent = x[0], x[1]
    ans[node] = ans[parent] + add[node]
    for x in edge[node]:
        if x != parent:
            search.append((x, node))
print(" ".join(list(map(str, ans))))

Measured memory_bytes: 72220
#include <iostream>
#include <cstdio>
using namespace std;
int N,M,A,B,C,D,x1,x2,y1,y2;
int P[32][32];
const int inf = 1001001001;
int main() {
	for(int e=0;e<32;++e){
		for(int f=0;f<32;++f){
			P[e][f]=inf;
		}
	}
	scanf("%d%d", &N, &M);
	for(int g=0;g<M;++g){
		scanf("%d,%d,%d,%d", &A, &B, &C, &D);
		P[A][B]=C;
		P[B][A]=D;
	}
	for(int k=1;k<=N;++k){
		for(int i=1;i<=N;++i){
			for(int j=1;j<=N;++j){
				if(P[i][j]>P[i][k]+P[k][j]){
					P[i][j] = P[i][k] + P[k][j];
				}
			}
		}
	}
	
	scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
	
	int X;
	X=y1-P[x1][x2]-P[x2][x1]-y2;
	printf("%d\n", X);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;


#define pb push_back
#define ff first
#define ss second
#define INF int(3e9)
#define BIG_INF ll(9e18)
#define SIZE 200001
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define len(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout);


ll binpow(ll a, ll b, ll MOD = BIG_INF)
{
    ll res = 1;

    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= MOD;
        res %= MOD;
    }

    return res % MOD;
}

const ll mod = 1e9 + 7;

int T = 1;

ll n, a[SIZE];
ll y = 1000, s = 0;

void solve()
{
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];

    int lst = 0;

    for(int i = 0; i < n; i++)
    {
        lst = i;
        while(i + 1 < n && a[i] <= a[i + 1])
        {
            i++;
        }
        ll cnt = y / a[lst];
//        cout << cnt << ' ';
        y -= cnt * a[lst];
        s += cnt;
        y += s * a[i];
        s = 0;
//        cout << y << ' ';
    }
    cout << y;

    return;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//    filein;fileout;

//    cin >> T;

    while(T--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3580
import sys
from pprint import pprint

def solve(n, s, t, x):
    ans = 0
    slept = False
    for i in range(n):
        if slept:
            ans += t[i]
        if s[i] == x:
            slept = True
    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    s = [""] * n
    t = [0] * n
    for i in range(n):
        s[i], tmp = sys.stdin.readline().strip().split(" ")
        t[i] = int(tmp)
    x = sys.stdin.readline().strip()
    solve(n, s, t, x)

Measured memory_bytes: 38384
N,K,*h=map(int,open(0).read().split())
h.sort()
if K == N:
    print(h[-1] - h[0])
else:
    dif_h=[]
    for i in range(N-1):
        dif_h.append(h[i+1] - h[i])
    _min = base = sum(dif_h[:K-1])
    for i in range(K-1,N-1):
        base += dif_h[i]
        base -= dif_h[i-K+1]
        _min = min(base,_min)
    print(_min)    
        
        
    

Measured memory_bytes: 14092
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n;
    int a[100000] = {};
    int temp1 = 1;
    int temp2 = 1;
    int count = 0;
    
    cin >> n;
    for( int i = 0; i < n; ++i){
        cin >> a[i];
    }
    
    while(1){
        temp2 = a[temp1-1];
        a[temp1-1] = 1;
        temp1 = temp2;
        ++count;
        if( temp2 == 2 ) {
            cout << count << endl;
            return 0;
        }
        if( temp2 == 1 ){
            cout << -1 << endl;
            return 0;
        } 
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	double a; cin >> a;
	cout << fixed << setprecision(10) <<  2.0 * a * 3.1415926535 << endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n,x; cin >> n >> x;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll res=0;
  rep(i,n-1){
    ll l = a[i];
    ll r = a[i+1];
    ll sum = l+r-x;
    if(sum<=0) continue;
    res += sum;
    r = max(r-sum,0LL);
    a[i+1] = r;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main(){
	int n,ans=0,minv=10000001;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
    for(int i=1;i<=n;i++){
    	if(a[i]<minv){
    		minv=a[i];
    		ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

a, b = map(int,input().split())
g = gcd(a,b)
count = 0
for i in range(2, int(g**0.5)+2):
    if g % i == 0:
        count += 1
        while g % i == 0:
            g //= i
if g != 1:
    count += 1
print(count+1)


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

const int MAX_N = 1e5;
struct edge{ int to, weight; };
vector<edge> Edges[MAX_N + 10];

int dir[MAX_N];

void dfs(int vertex, int parent, int distance){
	dir[vertex] = distance;
	for (auto e : Edges[vertex]){
		if (e.to == parent) continue;
		dfs(e.to, vertex, distance + e.weight);
	}
}

int main(){
	int N;
	cin >> N;
	for (int i = 0; i < N-1; ++i){
		int u, v, w;
		cin >> u >> v >> w;
		--u; --v;
		Edges[u].push_back(edge{v, w});
		Edges[v].push_back(edge{u, w});
	}

	dfs(0, -1, 0);
	for (int i = 0; i < N; ++i){
		if (dir[i] & 1){
			cout << 1 << endl;
		}else{
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 8320
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

n, a, b, c = nm()
d = {'A': a, 'B':b, 'C':c}
l = [input() for _ in range(n)] + ['#']
ans = list()
for i in range(n):
    u, v = l[i]
    if d[u] <= d[v]:
        u, v = v, u
    if d[u] == d[v] and u in l[i+1]:
        u, v = v, u
    ans.append(v)
    d[u] -= 1
    d[v] += 1
    if d[u] < 0:
        print('No')
        exit(0)
print('Yes')
printn(ans)


Measured memory_bytes: 17464
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int sz = 2e5+5;
//ll int arr[sz]={0},arr1[sz]={0},arr2[sz]={0};
char arr[205][205];
int arr1[205][205] = {0};
bool visited[205][205];
int prime[10005]= {0};
//vector <ll int> vec,vec1,vec2, edge, node;
//vector<pair<int, int>> vec[100],vec1;
vector <pair <int,int>> st;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);



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

    int k = ceil(a/b);

    k = k*c;

    cout<<k<<endl;

}


Measured memory_bytes: 3720
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll A,P;
	cin >>A>>P;
	cout<<(A*3+P)/2<<endl;
	
}


Measured memory_bytes: 256
def prime(p):
    memo = []
    for i in range(2,(int(p**0.5)+1)):
        while p%i==0:
            p //= i
            memo.append(i)
    if p != 1:
        memo.append(p)
    return memo

import collections

n=int(input())

memo = prime(n)

memo = collections.Counter(memo)

memo = sorted(memo.items(), key=lambda x:-x[1])

ans = 0

for sosu, count in memo:
  kosu = 1
  while 0 <= count-kosu:
    count -= kosu
    ans += 1
    kosu += 1
print(ans)

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

const int ALPHABET = 26;
const string MARCH = "MARCH";
const int MARCH_N = 5;
int main() {
	int N;
	int march[ALPHABET]; // 人数
	for (int i = 0;i < ALPHABET;i ++) march[i] = 0;
	static string S;
	cin >> N;
	for (int i = 0;i < N;i ++) {
		cin >> S;
		march[S[0] - 'A'] ++; // あるアルファベットの人数が何人いるか確認
	}
	
	int64_t ans = 0;
	for (int i = 0;i < MARCH_N;i ++) {
		for (int j = i + 1;j < MARCH_N;j ++) {
			for (int k = j + 1;k < MARCH_N;k ++) {
				ans += (int64_t)march[MARCH[i] - 'A'] * march[MARCH[j] - 'A'] * march[MARCH[k] - 'A'];
			}
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、答えの範囲を考える
5種類から3種類の記号を選び(5C3=10通り)、更に各々でどの名前の人を選ぶか決める(それぞれの積)ので、
それぞれの人数をx,y,z(x+y+z<=10^5、x,y,z>=0)とすると最大でも10^15<=2^45を上回らない
だから64bitあれば大丈夫

次に、具体的な実装
まず五種類の先頭文字を持つ人数をそれぞれカウントする
次に、上にある通りに計算すればおｋ
*/

Measured memory_bytes: 384
#include <iostream>

using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int n1 = mid -left;
  int n2 = right - mid;
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i=0, j=0;
  for(int k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for(i=0;i<n;i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i)cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 6904
from math import *
a,b,C=map(int,input().split())
C2=radians(C)
S=float(a*b*sin(C2)/2)
L=float(a+b+((a**2+b**2-2*a*b*cos(C2))**(1/2)))
h=float(b*sin(C2))
print(S)
print(L)
print(h)

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

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) return 0;
    vector <int> S(n);
    for (int i=0; i<n; i++) cin >> S.at(i);
    int sum = accumulate(S.begin(), S.end(), 0);
    double average = static_cast<double>(sum) / n;
    double std_times_n = 0;
    for (int i=0; i<n; i++) {
      std_times_n += pow(S.at(i)-average, 2);
    }
    cout << setprecision(12) << sqrt(std_times_n/ n) << endl;
  }
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;

  s[k - 1] = s[k - 1] - 'A' + 'a';

  cout << s << endl;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=8&&b<=8)
        cout<<"Yay!"<<endl;
    else
        cout<<":("<<endl;

    return 0;
}


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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N,K;
	cin >> N >> K;

	cout << (N % K == 0 ? 0 : 1) << endl;
	return 0;
}


Measured memory_bytes: 256
N,A,B,C,D=map(x->parse(Int,x),split(readline()))
S=readline()
for i=A:C-1
	if S[i]=='#'&&S[i+1]=='#'
		println("No")
		exit()
	end
end
for i=B:D-1
	if S[i]=='#'&&S[i+1]=='#'
		println("No")
		exit()
	end
end
if C<D
	println("Yes")
else
	for j=B-1:D-1
		if S[j]=='.'&&S[j+1]=='.'&&S[j+2]=='.'
			println("Yes")
			exit()
		end
	end
	println("No")
end


Measured memory_bytes: 166628
x, y = list(map(int, input().split()))

num1 = x + y
num2 = x - y
num3 = x * y

if num1 > num2:
    if num1 > num3:
        ans = num1
    else:
        ans = num3
elif num2 > num3:
    ans = num2
else:
    ans = num3

print(ans)

Measured memory_bytes: 3060
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        s: Chars,
    }

    let n =  s.len();
    let mut f_cnt = 0;
    let mut b_cnt = 0;

    for i in 0..n {
        if s[i]=='A' {
            break;
        }
        f_cnt += 1;
    }
    for i in (0..n).rev() {
        if s[i]=='Z' {
            break;
        }
        b_cnt += 1;
    }
    println!("{}", n-f_cnt-b_cnt);
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll nc2(ll x)
{
	return ((x-1)*x)/2;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<ll> v(n),ct(n+1,0);
	for(auto& x:v)
	{
		cin>>x;
		ct[x]++;
	}
	ll tc=0;
	for(int i=1; i<=n; i++)
	{
		tc = tc + nc2(ct[i]);
	}
	ll ans=0;
	for(auto& x:v)
	{
		ans = tc - ct[x] + 1;
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 5760
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

if M > N:
    print("NO")
    exit(0)

from collections import Counter
Dc = Counter(D)

for m in T:
    if m in Dc.keys():
        Dc[m] -= 1
        if Dc[m] < 0:
            print("NO")
            exit(0)
    else:
        print("NO")
        exit(0)

print("YES")

Measured memory_bytes: 43956
n=int(input())
*w,=map(int,input().split())
d=abs(sum(w)-2*w[0])
for i in range(1,n):
	left=sum(w[:i+1])
	right=sum(w[i+1:])
	td=abs(right-left)
	d=min(d,td)
print(d)
	

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int i,j,k,m,n;
int main()
{
	scanf("%d",&n);
	int i=n/100,j=n%100;
	if(i<=12&&j<=12&&i>0&&j>0)
	{
		printf("AMBIGUOUS\n");
		return 0;
	}
	if((i==0||i>12)&&j<=12&&j>0)
	{
		printf("YYMM\n");
		return 0;
	}
	if(i<=12&&(j>12||j==0)&&i>0)
	{
		printf("MMYY\n");
		return 0;
	}
	printf("NA");
}

Measured memory_bytes: 256