akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll inf=1e18;
const ll maxs = 201;
const ll mod = 1e9+7;

#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define line() cout<<endl;
#define fr(i,b) for(ll i=0;i<b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

ll lcm(ll a,ll b)
{
    return a*b/__gcd(a,b);
}


int main()
{
    fastio();
    
     ll t=1;
     //cin>>t;
     while(t--)
     {
        ll n;
        cin>>n;
        ll a[n];
        fr(i,n)
            cin>>a[i];
        ll dp[n];
        dp[0]=0;
        dp[1]=abs(a[0]-a[1]);
        for(ll i=2;i<n;i++)
        {
            dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]) , dp[i-2]+abs(a[i-2]-a[i]));
        }
        cout<<dp[n-1];
     }
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>

using namespace std;
using int64 = long long;

int main() {
    int64 n,k;
    cin >> n >> k;
    int64 ans = (n/k) * (n/k) * (n/k);
    if (k % 2 == 0) {
        int64 t = (n/k);
        if (n%k >= k/2) t++;
        ans += t * t * t;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] numbers = new int[n];
        int ans = 0;
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(input[i]);
        }
        
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                ans += numbers[i] * numbers[j];
            }
        }
        
        out.println(ans);
        out.close();
        
    }
}

Measured memory_bytes: 32756
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,k;
    std::cin >> n>>k;
    ll m = (n*(n-1))/2;
    if(m-k<n-1){
        std::cout << -1 << std::endl;
        return 0;
    }
    // std::cout << m << std::endl;
    std::cout << m-k << std::endl;
    
    bool usek[110][110];
    Fill(usek,true);
    ll c = k;
    
    for (int i = 0; i < n; i++) {
        bool end = false;
        for (int j = i+1; j < n-1; j++) {
            if(c>0){
                usek[i][j] = false;
                // std::cout << c<<" "<<i<<" "<<j << std::endl;
                // std::cout << c << std::endl;
                c--;
            }else{
                end = true;
                break;
            }
        }
        if(end){
            break;
        }
    }
    // std::cout << 11 << std::endl;
    for (int i = 0; i < n; i++) {
        // std::cout << 22 << std::endl;
        for (int j = i+1; j < n; j++) {
            // std::cout << 233 << std::endl;
            // std::cout << usek[i][j] << std::endl;
            if( usek[i][j] ){
                std::cout << i+1 <<" "<<j+1 << std::endl;
            }
        }
    }
}


Measured memory_bytes: 256
import itertools

n = int(input())
X = []
for _ in range(n):
    X.append(list(map(int, input().split())))
L = 0
count = 0
for xl in itertools.permutations(X):
    l = 0
    pre = []
    for x in xl:
        if len(pre) > 0:
            l += ((x[0] - pre[0]) ** 2 + (x[1] - pre[1]) ** 2) ** (1/2)
        pre = x
    L += l
    count += 1

print(L / count)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

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

	if (A == 0) {
		cout << "NO" << endl;
		return 0;
	}

	int val = A;
	REP(i, 0, 100) {
		if (val%B == C) {
			cout << "YES" << endl;
			return 0;
		}
		val += A;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "stdio.h"


int main()
{
	int s, *a;
	int ans = 0;

	a = new int[1000001];

	scanf("%d", &s);

	a[0] = s;

	for (int i = 0; i < 1000000; i++) {
		if (a[i] % 2 == 0) {
			a[i + 1] = a[i] / 2;
		}
		else {
			a[i + 1] = 3 * a[i] + 1;
		}
		for (int j = 0; j < i + 1; j++) {
			if (a[i + 1] == a[j]) {
				ans = i + 1;
				break;
			}
		}
		if (ans != 0) break;
	}

	
	
	printf("%d", ans + 1);

	delete[] a;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	vector<string> strings;
	string s;
	while (cin >> s) {
		while (s.find(",", 0) != string::npos) {
			s.erase(s.find(",", 0));
		}
		while (s.find(".", 0) != string::npos) {
			s.erase(s.find(".", 0));
		}
		if (3 <= s.size() && s.size() <= 6)
			strings.push_back(s);
	}
	vector<string>::iterator it = strings.begin();
	int ifs = 1;
	while (it != strings.end()) {
		if (ifs == 0)
			cout << " ";
		cout << *it;
		ifs = 0;
		it++;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1184
N = gets.to_i
A = gets.split(" ").map { |e| e.to_i }

cur = 0
sum = []
sum << 0
for i in 0..N-1 do
  cur += A[i]
  sum << cur
end

# count = 0
# sum.sort!
# for i in 0..N do
#   if i == 0 or sum[i] != sum[i-1]
#     num = sum.find_all{|e| e == sum[i]}.count
#     puts 1
#     if num > 1
#       count += num*(num-1)/2
#     end
#   end
# end
# puts count

count = 0
sum.sort!
for i in 0..N do
  if i == 0
    sta = 0
    fin = 0
  elsif sum[i] == sum[i-1]
    fin += 1
  elsif sum[i] != sum[i-1]
    num = fin - sta +1
    count += num*(num-1)/2
    sta = fin+1
    fin += 1
  end
end
num = fin - sta +1
count += num*(num-1)/2
puts count


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

int main(void)
{
	int i, x;
	char a[201], b[101];
	
	scanf("%s", a);
	x = strlen(a);
	memcpy(&a[x], a, x);
	a[x*2] = 0x00;
	
	scanf("%s", b);
	x = strlen(b);
	
	for(i = 0; a[i] != 0x00; i++){
		if(!memcmp(&a[i], b, x)) break;
	}
	if(a[i] != 0x00){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return(0);
}



Measured memory_bytes: 1788
#include <stdio.h>
char Grading(int m, int f, int r){
	char g;
	
	if(m>=0 && f>=0 && 80<=m+f) g='A';
	if(m>=0 && f>=0 && 65<=m+f && m+f<80) g='B';
	if(m>=0 && f>=0 && 50<=m+f && m+f<65) g='C';
	if(m>=0 && f>=0 && 30<=m+f && m+f<50 && r<50) g='D';
	if(m>=0 && f>=0 && 30<=m+f && m+f<50 && 50<=r) g='C';
	if(m>=0 && f>=0 && m+f<30) g='F';
	if(m==-1 || f==-1) g='F';
	return g;
}
int main(void){
	int m,f,r;
	char grade;
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1 && f==-1 && r==-1) break;
		grade=Grading(m,f,r);
		printf("%c", grade);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int cnt5=0;
  int cnt7=0;
  if (A==5){
    cnt5++;
  }
  if(A==7){
    cnt7++;
  }
  if(B==5){
    cnt5++;
  }
  if(B==7){
    cnt7++;
  }
  if(C==5){
    cnt5++;
  }
  if(C==7){
    cnt7++;
  }
  
  if (cnt5==2 && cnt7==1){
    cout << "YES"<< endl;
  }
  else{
    cout << "NO" << endl;
  }
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main(){
  string s;
  cin >> s;
  vector<string> nums;
  for (int i=0; i<s.length(); i++) nums.push_back(s.substr(i, 1));

  long res = 0;
  // パターン全列挙
  
  long tmp;
  long digit;
  long sum = 0;
  string ssum = "";
  for (int i=0; i< (1 << (nums.size() - 1)); i++) { // bit演算なので条件
    sum = 0;
    tmp = 0;
    digit = 1;
    ssum = nums[0];
    for (int k=0; k<nums.size()-1; k++) {
      if (i & (1 << k)) { // 見てるbitと現在見てる桁に+がついているとき
        sum +=  stol(ssum);
        ssum = "";
      }
      ssum += nums[k+1];
    }
    sum += stol(ssum);
    res += sum;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

int main()
{
  int n;
  double x[100],y[100],sum1=0,sum2=0,sum3=0,max;

  cin>>n;
  for(int i=0;i<n;i++)cin>>x[i];
  for(int i=0;i<n;i++)cin>>y[i];
  max=fabs(x[0]-y[0]);
  for(int i=0;i<n;i++){
    sum1+=fabs(x[i]-y[i]);
    sum2+=fabs((x[i]-y[i])*(x[i]-y[i]));
    sum3+=fabs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
    if(max<fabs(x[i]-y[i]))max=fabs(x[i]-y[i]);
  }
  printf("%.8f\n",sum1);
  printf("%.8f\n",sqrt(sum2));
  printf("%.8f\n",pow(sum3,1.0/3.0));
  printf("%.8f\n",max);
  return 0;
}

Measured memory_bytes: 1288
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
 
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

ll dp[1000010];

int main(void){
	ll k;
    cin>>k;
    dp[0]=1;
    ll t = 1;
    for(ll i=1;i<1000010;i++){
        if(i==1){
            dp[1]=7%k;
            if(dp[1]==0){
                cout<<1<<endl;
                return 0;
            }
            continue;
        }
        t*=10;
        t=t%k;
        ll s = (7*t);
        dp[i] = (dp[i-1]+s)%k;
        if(dp[i]==0){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 11444
package main

import (
	"fmt"
)

func main() {
	var K,S int
	fmt.Scan(&K,&S)
	
	cnt := 0
	for x := 0; x <= K; x++ {
		for y := 0; y <= K; y++ {
			z := S - ( x + y )
			if 0 <= z && z <= K {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    string s = to_string(n);
    if ((s[0] == s[1] && s[1] == s[2]) | (s[1] == s[2] && s[2] == s[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


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

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	char t[] = { 'L','R' };
	if (s[0] == 'R') swap(t[0], t[1]);
	int cnt = 0;
	char tmp = s[0];
	for (int i = 1; i < n; ++i) {
		if (tmp != s[i]) cnt++;
		if (cnt / 2 >= k) break;
		tmp = s[i];
		if (s[i] == t[1]) s[i] = t[0];
	}
	int ans = 0;
	for (int i = 1; i < n; ++i)
		if (s[i - 1] == s[i]) ans++;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
s=input()
l=len(s)
for i in range(l-2):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    break
  if s[i]==s[i+2]:
    print(i+1,i+3)
    break
else:
  if s[-2]==s[-1]:
    print(l-1,l)
  else:
    print(-1,-1)

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define trv(p, u) for (edg *p = h[u]; p; p = p->nxt)
#define pb push_back
typedef long long ll;
typedef double db;
const int N = 2e6 + 100;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;

inline int rd() {
  int s = 0, w = 1; char c = getchar();
  while (c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }
  while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
  return s * w;
}

int n, m, fac[N], inv[N];

inline int qpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = 1ll * res * a % mod;
    a = 1ll * a * a % mod, b >>= 1;
  }
  return res;
}

inline void prew() {
  fac[0] = inv[0] = fac[1] = inv[1] = 1;
  rep(i, 2, N - 100) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
  rep(i, 2, N - 100)
    fac[i] = 1ll * i * fac[i - 1] % mod, inv[i] = 1ll * inv[i] * inv[i - 1] % mod;
}

inline int C(int a, int b) { return 1ll * fac[a] * inv[a - b] % mod * inv[b] % mod; }

inline int calc(int x) {
  int res = 0;
  for (int i = x & 1; i <= min(x, min(n, m)); i += 2)
    res = (res + 1ll * C(n, i) * C((x - i) / 2 + n - 1, n - 1)) % mod;
  return res;
}

int main() {
  prew(); n = rd(), m = rd();
  printf("%lld\n", (calc(m * 3) - 1ll * n * calc(m - 1) % mod + mod) % mod);
  return 0;
}

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

int main(){
  string S; cin >> S;
  int Q; cin >> Q;
  string T;
  rep(i,Q){
    int x; cin >> x;
    switch(x){
      case 1:
        swap(S,T);
        break;
      case 2:
        int t; char c;
        cin >> t >> c;
        switch(t){
          case 1:
            T += c;
            break;
          case 2:
            S += c;
        }
    }
  }
  reverse(T.begin(), T.end());
  T += S;
  cout << T << endl;
  return 0;
}

Measured memory_bytes: 1128
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        k: i32,
        a: i32,
        b: i32,
    }
    if multiples(a..b, k) > 0 { println!("OK"); }
    else {println!("NG"); }
}

use std::ops::Range;
type SomeInt = i32;
fn multiples(r: Range<SomeInt>, n: SomeInt) -> SomeInt {
    r.end / n - ((((r.start + n - 1))/ n) - 1)
}



Measured memory_bytes: 2120
//abc150_d.cpp
//Thu Feb  6 22:32:27 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

ll gcd (ll a, ll b){ //最大公約数
	if (b == 0){
		return a;
	}
	return gcd(b, a%b);
}

ll lcm (ll a, ll b){ //最小公倍数
	ll temp = gcd(a,b);
	return (a/temp)*b;
}

int main(){
	ll n,m;
	cin >> n >> m;

	ll a[n];
	ll halflcm = 1;
	ll twonum = -1;
	for (int i=0;i<n;i++){
		cin >> a[i];
		ll tmp = a[i]/2;
		ll count = 0;
		while (tmp%2==0){
			count++;
			tmp = tmp/2;
		}
		if (twonum==-1){
			twonum = count;
		}else {
			if (twonum != count){
				cout << 0 << endl;
				return 0;
			}
		}
		halflcm = lcm(a[i]/2,halflcm);
		if (halflcm>m){
			cout << 0 << endl;
			return 0;
		}
	}
//	cout << halflcm << endl;

	ll ans = (m-halflcm)/(2*halflcm);
	cout << ans + 1<< endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;

int N, A[100005], ans;
int B[200005];

void cal(){
  
  int sum = 0;
  
  for(int i=1;i<=200000;i++){
    if( B[i] && B[i-1] ) sum += abs( B[i] - B[i-1] );
  }
  
  ans = max( ans, sum );
  
}

void check(int flag){
  
  memset( B, 0, sizeof( B ) );
  
  int L = 100000 - 1, R = 100000 + 1;
  int l = 0, r = N - 1;
  
  if( flag == 0 ) B[100000] = A[l++];
  else B[100000] = A[r--];
  
  flag = !flag;
  
  while(1){
    
    if( l > r ) break;
    
    if( flag == 0 ){
      
      if( l == r ){
	
	if( B[L+1] > B[R-1] ) B[L--] = A[l++];
	else B[R--] = A[l++];
	
      }
      else{
	
	B[L--] = A[l++];
	
	B[R++] = A[l++];
	
      }
      
    }
    else{
      
      if( l == r ){
	
	if( B[L+1] < B[R-1] ) B[L--] = A[r--];
	else B[R--] = A[r--];
	
      }
      else{

	B[L--] = A[r--];
	
	B[R++] = A[r--];
	
      }
      
    }
    
    flag = !flag;
    
  }
  
  cal();
  
}

signed main(){
  
  cin>>N;
  
  for(int i=0;i<N;i++) cin>>A[i];
  
  sort( A, A + N );
  
  check(0);
  
  check(1);
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int N;

	scanf("%d", &N);

	for (int i = 1; i <= N; i++)
	{
		if (int(double(i*1.08)) == N)
		{
			printf("%d\n", i);
			return 0;
		}
	}

	printf(":(\n");

	return 0;
}
	

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

void print( vector<int> &A, int lf = 0 )
{
	int N = A.size();
	for( int k = 0; k < N; k++ ) {
		cout << A[k];
		if( k < N - 1 && lf == 0 ) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
}

int insertSort( vector<int> &A, int N, int g )
{
	int cnt = 0;
	for( int i = g; i < N; i++ ) {
		int v = A[i];
		int j = i - g;
		while( j >= 0 && A[j] > v ) {
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
	return cnt;
}

int shellSort( vector<int> &A, int N, vector<int> &G )
{
	int cnt = 0;
	for( int i = 0; i < G.size(); i++ ) {
		cnt += insertSort( A, N, G[i] );
	}
	return cnt;
}

int main()
{
	int N;
	cin >> N;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	vector<int> G;
	int h = 1;
	while( h <= N ) {
		G.push_back( h );
		h = 3 * h + 1;
	}
	reverse( G.begin(), G.end() );

	int cnt = shellSort( A, N, G );

	cout << G.size() << endl;
	print( G );
	cout << cnt << endl;
	print( A, 1 );
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B, C, X, Y;
    ll maxi, mini;
    ll base;
    ll money;
    cin >> A >> B >> C >> X >> Y;
    maxi = max(X, Y);
    mini = min(X, Y);
    if(X > Y) base = A;
    else base = B;
    money = mini * min(A + B, 2 * C);
    money += (maxi - mini) * min(base, 2 * C);
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;
int main(){
	
	int x,h;
	double t,s;
	while(cin>>x>>h){
		if(x!=0&&h!=0){
			t=sqrt(pow((double)x/2,2)+pow(h,2));
			s=pow(x,2)+(double)(x*t)*2;
		
		printf("%.6f\n",s);
		}
		else
			break;
	}
	
}

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

#define is_uruu leapyear
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,a) for(int i=0;i<(a);++i)


	
int main(){
	
	ll x, count=0;
	cin >> x;
	
	count += x/11*2;
	if(0 < x%11 && x%11 <= 6) count += 1;
	else if(6 < x%11) count += 2;
	
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int s, w;
  cin >> s >> w;
  if (s > w) cout << "safe" << endl;
  else cout << "unsafe" << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll a,v,b,w,t = 0;
    cin >> a >> v >> b >> w >> t;
    ll dist = abs(b - a);
    ll speed = v - w;
    if(speed * t >= dist){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int x[100010];
int y[100010];

int main(){
    int a,b,m;
    scanf("%d%d%d",&a,&b,&m);

    int mina=1e5+1,minb=1e5+1;

    for (int i=1;i<=a;++i){
        scanf("%d",&x[i]);
        if (x[i]<mina) mina=x[i];
    }
    for (int i=1;i<=b;++i){
        scanf("%d",&y[i]);
        if (y[i]<minb) minb=y[i];
    }
    int ans=mina+minb;
    for (int i=0;i<m;++i){
        int t1,t2,c;
        scanf("%d%d%d",&t1,&t2,&c);
        int tmp=x[t1]+y[t2]-c;
        if (tmp<ans) ans=tmp;
    }
    printf("%d\n",ans);


}


Measured memory_bytes: 896
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e5 + 10;
int ans[N];
map<int, int> mc;
vector<pair<int, int>> v;
void add(vector<pair<int, int>>& vp, int a, int b)
{
	if (!vp.empty() && vp.back().first == a) vp.back().second += b;
	else vp.emplace_back(a, b);
}
void solve(int key)
{
	if (ans[key] != -1) return;
	auto pq = v;
	int& res = ans[key] = 0;
	while (!pq.empty())
	{
		int sum = 0;
		vector<pair<int, int>> vp;
		while (!pq.empty() && sum < key)
		{
			sum += pq.back().second;
			vp.push_back(pq.back());
			pq.pop_back();
		}
		if (sum < key) break;
		if (vp.size() == 1)
		{
			int a, b;
			tie(a, b) = vp.back();
			res += b / key;
			if (a > 1 && b >= key)
				add(pq, a - 1, b / key * key);
			if (b % key)
				add(pq, a, b % key);
			continue;
		}
		res++;
		int cur = key;
		for (auto& p : vp)
		{
			int a, b;
			tie(a, b) = p;
			int o = min(cur, b);
			cur -= o;
			if (b - o > 0)
			{
				if(a > 1) add(pq, a - 1, o);
				add(pq, a, b - o);
				p.second = 0;
			}
		}
		reverse(vp.begin(), vp.end());
		for (auto& p : vp)
		{
			if (p.second == 0) continue;
			if (p.first > 1) add(pq, p.first - 1, p.second);
		}
	}
	if (res == 0)
	{
		for (int i = key + 1; i < N; i++)
		{
			if (ans[i] == 0) break;
			ans[i] = 0;
		}
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	map<int, int> mm;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		mm[x]++;
	}
	for (auto& p : mm)
	{
		mc[p.second]++;
	}
	for (auto& p : mc)
		v.push_back(p);
	MEM(ans, -1);
	ans[1] = n;
	for (int i = 2; i <= n; i++)
	{
		solve(i);
		int l = i, r = n;
		int key = l;
		while (l <= r)
		{
			int mid = (l + r) / 2;
			solve(mid);
			if (ans[mid] == ans[i]) key = mid, l = mid + 1;
			else r = mid - 1;
		}
		for (int j = i; j <= key; j++) ans[j] = ans[i];
		i = key;
	}
	for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 15616
#include<iostream>
#include<set>
using namespace std;int Q,N,a,p,M,t;main(){for(cin>>Q;Q--;cout<<a<<endl){set<int>u;for(cin>>N,a=0;N/10&&~a;N=M)for(u.count(N)&&(a=-2),u.insert(N),a++,p=M=1;p<N;p*=10,M=t>M?t:M)t=(N/p)*(N%p);}}

Measured memory_bytes: 1200
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n=int(input())
G=[[0]*n for i in range(n)]
for i in range(n):
    inp=tuple(map(int,input().split()))
    now=inp[0]
    for j in range(2,inp[1]+2):
        G[now-1][inp[j]-1]=1
for g in G:
    print(*g)
    



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

int main() {
  vector<int>a(3);
  int n;
  cin>>a[0]>>a[1]>>a[2]>>n;
  sort(a.rbegin(),a.rend());
  while(n){
    a[0]*=2;
    n--;
  }
  int kotae=a[0]+a[1]+a[2];
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3604
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int n;
double ans;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    for ( int i = 1; i <= n; i++ ) {
        if ( i % 2 ) ans++;
    }
    ans /= n;
    cout << setprecision(15) << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007

int modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
int main()
{
	int n,k,c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	vector<ll> l(n),r(n);
	ll cnt=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='o')
		{
			l[i]=++cnt;
			i+=c;
		}
	}
	cnt=k;
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='o')
		{
			r[i]=cnt--;
			i-=c;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(l[i]>0&& l[i]==r[i])
			cout<<i+1<<endl;
	}
}

Measured memory_bytes: 4996
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int N, s[100], sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        sum += s[i];
    }
    sort(s, s + N);
    int i = 0;
    while (sum % 10 == 0 && sum != 0 && i < N) {
        if (s[i] % 10 == 0) i++;
        else sum -= s[i++];
    }
    cout << (sum % 10 ? sum : 0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <utility>
#include <vector>

#define MAX_N (100)
#define INF (1000000000)

using namespace std;

int main() {
  // read inputs
  int N, as[MAX_N], bs[MAX_N], cs[MAX_N], ds[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &as[i], &bs[i]);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &cs[i], &ds[i]);
  }

  // place in pairs
  vector<pair<int, int>> rps, bps;
  for (int i = 0; i < N; i++) {
    rps.push_back(make_pair(as[i], bs[i]));
    bps.push_back(make_pair(cs[i], ds[i]));
  }
  sort(bps.begin(), bps.end());

  // create pairs greedily
  vector<int> us(N, 0);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int max_j = -1, max_y = -1;
    for (int j = 0; j < N; j++) {
      if (!us[j] && rps[j].first < bps[i].first &&
          rps[j].second < bps[i].second) {
        if (rps[j].second > max_y) {
          max_j = j;
          max_y = rps[j].second;
        }
      }
    }
    if (max_j >= 0) {
      us[max_j] = 1;
      ans++;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(void){
  int h,m,s;
  while(cin>>h>>m>>s){
    if(h==-1&&m==-1&&s==-1)break;
	int sum=2*60*60-h*60*60-m*60-s;
	int tmp=3*sum;
	printf("%02d:%02d:%02d\n%02d:%02d:%02d\n",sum/3600,sum%3600/60,sum%60,tmp/3600,tmp%3600/60,tmp%60);
  }
}	

Measured memory_bytes: 1160
#include <iostream>

int main()
{
	using namespace std;
	int a, b, c;
	cin >> a;cin >> b;cin>> c;
	if (a == b) {
		cout << c;
	}
	else if (b == c) {
		cout << a;
	}
	else {
		cout << b;
	}
	
}

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

const int N = 2e5;

deque <int> ans;
int used[N];

int main(){
	int m, k;
	scanf("%d %d",&m,&k);
	if (m == 1){
		if (k == 0) printf("0 0 1 1\n");
		else printf("-1\n");
		return 0;
	}
	if (k >= (1 << m)){
		printf("-1\n");
		return 0;
	}
	for (int i = 0; i < m; i++){
		if (k & (1 << i)){
			ans.push_back(1 << i);
			used[1 << i] = 1;
		}
	}
	for (int i = 0; i < (1 << m); i++){
		if (!used[i]){
			ans.push_front(i);
			ans.push_back(i);
		}
	}
	for (int i = m - 1; ~i; i--){
		if (k & (1 << i)) ans.push_back(1 << i);
	}
	while (!ans.empty()){
		int num = ans.front(); ans.pop_front();
		printf("%d%c", num, " \n"[ans.empty()]);
	}
	return 0;
}

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


const int maxn=2e5+7;
int jishu[maxn],oushu[maxn],a[maxn];

int main(){
	int n;scanf("%d",&n);
	memset(jishu,0,sizeof(jishu));
	memset(oushu,0,sizeof(oushu));
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int tt,ans1=n/2,ans2=n/2;
	for(int i=1;i<=n;i++)
		if(i&1) jishu[a[i]]++;
		else oushu[a[i]]++;
	for(int i=1;i<=n;i+=2) if(ans1>(n/2)-jishu[a[i]]) ans1=n/2-jishu[a[i]],tt=a[i];
	for(int i=2;i<=n;i+=2) if(ans2>n/2-oushu[a[i]]&&a[i]!=tt) ans2=n/2-oushu[a[i]];

	int ans=ans1+ans2;
	ans1=n/2,ans2=n/2;
	for(int i=2;i<=n;i+=2) if(ans2>n/2-oushu[a[i]]) ans2=n/2-oushu[a[i]],tt=a[i];
	for(int i=1;i<=n;i+=2) if(ans1>(n/2)-jishu[a[i]]&&a[i]!=tt) ans1=n/2-jishu[a[i]];

	cout<<min(ans,ans1+ans2)<<endl;
	return 0;
}


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

using namespace std;

int main(void) {
	int n, k, q; cin >> n >> k >> q;
	int a, count = 0;
	vector<int> v(n, k);
	for (int i = 0; i < q; ++i) {
		cin >> a;
		v[a - 1] += 1;
	}
	for (int i = 0; i < n; ++i) {
		if (v[i] - q > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s,t;
string ans;

int main(void){
	cin >> s;
	cin >> t;
	for(int i=0;i<=(int)s.size()-(int)t.size();i++){
		bool flag=true;
		for(int j=0;j<t.size();j++){
			if(s[i+j]!=t[j] && s[i+j]!='?')flag=false;
		}
		if(flag){
			string b="";
			for(int j=0;j<s.size();j++){
				if(s[j]!='?')b+=s[j];
				else b+='a';
			}
			for(int j=0;j<t.size();j++){
				b[i+j]=t[j];
			}
			if(ans.size()==0)ans=b;
			else ans=min(ans,b);
		}
	}
	if(ans.size()==0){
		puts("UNRESTORABLE");
	}else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string n;
	cin>>n;
	int a=0,b=0;
	for(int i=0;i<n.size();i++)
	{
		if(i%2==0) 
		{
			if(n[i]=='0')
				++b;
			else
				++a;
		}
		else
		{
			if(n[i]=='1')
				++b;
			else
				++a;
		} 
    }
	if(a<b)
	{
		cout<<a;
	}
	else
	{
		cout<<b; 
	} 
	cout<<endl;
    return 0;	
} 

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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


ll dfs(int n, ll x) {
    if (n == 0) return 1LL;
    ll res = 0;
    ll len = (1LL<<(n+2)) - 3, hnum = (1LL<<n) - 1; 
    if (x >= len-1) res += hnum * 2 + 1;
    else if (x >= (len-3)/2+3) {
        res += hnum + 1;
        res += dfs(n-1, x-1-(len-3)/2-1);
    }
    else if (x >= (len-3)/2+2) res += hnum + 1;
    else if (x >= (len-3)/2+1) res += hnum;
    else if (x >= 2) res += dfs(n-1, x-1);
    return res;
}

int main(){
    int n;
    ll x;
    cin >> n >> x;
    cout << dfs(n, x) << endl;
    return 0;
}


Measured memory_bytes: 3632
#![allow(unused)]

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Self {
        Self { reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let x: i128 = sc.get();

    for a in 0..=120 {
        let a5 = a * a * a * a * a;
        for b in 0..=a {
            let b5 = b * b * b * b * b;
            if a5 - b5 == x {
                println!("{} {}", a, b);
                return;
            }
            if a5 + b5 == x {
                println!("{} {}", a, -b);
                return;
            }
        }
    }

    unreachable!();
}


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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int, int>;

/*
 */

signed main(){
  string s, t;
  cin >> s >> t;

  cout << t << s << endl;

  return 0;
}


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

int main()
{
    int k,s,ans=0;
    cin>>k>>s;
    for(int i=0; i<=k; i++)
        for(int j=0; j<=k; j++)
            if(s-i-j>=0 && s-i-j<=k) ans++;
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n,m,i;
    long long x;
    cin>>n>>m;
    string s;
    vector<int> v(n,0),c(n,0);
    for(i=0;i<m;i++) {
        cin>>x;
        cin>>s;
        x--;
        if(s=="AC") v[x]=1;
        if(v[x]==0 && s=="WA") c[x]++;
    }
    x=0;
    m=0;
    for(i=0;i<n;i++) if(v[i]==1) x+=c[i],m++;
    cout<<m<<" "<<x;
}


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

int main() {
    int N;
    cin>>N;
    int AN,A[100],BN,B[100],CN,C[100];
    cin>>AN;
    for(int i=0;i<AN;i++)cin>>A[i];
    cin>>BN;
    for(int i=0;i<BN;i++)cin>>B[i];
    cin>>CN;
    for(int i=0;i<CN;i++)cin>>C[i];
    
    int count=0;
    for(int i=0;i<CN;i++){
        int t=count;
        for(int j=0;j<AN;j++){
            if(C[i]==A[j]){
                break;
            }
            if(j==AN-1)count++;
        }
        
        if(AN==0)count++;
        
        if(t!=count)continue;
        
        for(int j=0;j<BN;j++){
            if(C[i]==B[j]){
                count++;
                break;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	long long n;
	long long a,b;
	cin>>n>>a>>b;
	long long ans=0;
	ans=a*(n/(a+b));
	n=n%(a+b);
	ans+=(a<=n?a:n);
	cout<<ans<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	list := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	var K int
	fmt.Scanf("%d", &K)
	fmt.Println(list[K-1])
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int GCD(int x,int y){
  if(x<y){
    swap(x,y);
  }
  while(x%y!=0){
    int temp=x;
    x=y;
    y=temp%y;
  }
  return y;
}

int digitsum(int x){
  int sum=0;
  while(x>0){
    sum+=(x%10);
    x/=10;
  }
  return sum;
}

int main() {
  int x;
  cin>>x;
  if(x==0) cout<<1<<endl;
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 3596
import java.io.*;

public class Main{
               public static void main(String args[]) throws IOException{
               
                 int x = 0;
                 InputStreamReader isr = new InputStreamReader(System.in);
                 BufferedReader br = new BufferedReader(isr);
                 String buf = br.readLine();
                 x = Integer.parseInt(buf);
                      
               System.out.println((int)Math.pow(x,3));
           }
    }

Measured memory_bytes: 24448
#include<iostream>                                        
using namespace  std;                                     
                                                          
int main(){                                               
  int n,x;                                                
  int i,j,k;                                              
                                                          
  while(1){                                               
    int counter = 0;                                      
    cin >> n >> x;                                        
    if(n==0 && x==0) break;                               
    for(i=1;i<=n;i++){                                    
      for(j=1;j<=n;j++){                                  
        if(j == i) break;                                 
        for(k=1;k<=n;k++){                                
          if(k==i || k==j) break;                         
          if((i + j + k == x) && (i != j) && (j != k) && \
(k != i)) counter++;                                      
        }                                                 
      }                                                   
    }                                                     
    cout << counter << endl;                              
  }                                                       
                                                          
  return 0;                                               
                                                          
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;};
void qmod(ll &a,ll b){a=(a*b)%MOD;};
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  result=100*n+1800*m;
  for(i=0;i<m;i++){
    result*=2;
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	double EPS=1e-6;

	int n, m;
	// n:black
	// m:white
	int[] xs, ys;

	void run(){
		for(;;){
			n=sc.nextInt();
			m=sc.nextInt();
			if((n|m)==0){
				break;
			}
			xs=new int[n+m];
			ys=new int[n+m];
			for(int i=0; i<n+m; i++){
				xs[i]=sc.nextInt();
				ys[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int[] s=new int[n+m];
		for(int b=0; b<n; b++){
			for(int w=n; w<n+m; w++){
				double xw=xs[w];
				double yw=ys[w];
				double xb=xs[b];
				double yb=ys[b];

				double a=xb==xw?0:(double)(yb-yw)/(xb-xw);
				double y1=yw;
				double x1=xw;

				boolean f=true;
				for(int i=0; i<n+m; i++){
					double x=xs[i];
					double y=ys[i];
					boolean on=false;
					if(xb!=xw){
						double y2=a*(x-x1)+y1;
						if(y+EPS<y2){
							// º
							s[i]=-1;
						}else if(y2+EPS<y){
							// ã
							s[i]=1;
						}else{
							on=true;
						}
					}else{
						// c
						if(x+EPS<x1){
							// ¶
							s[i]=-1;
						}else if(x1+EPS<x){
							// E
							s[i]=1;
						}else{
							on=true;
						}
					}
					if(on){
						// ¼üó
						boolean fx=false;
						boolean fy=false;
						if(i<n){
							// black
							fx|=c(xw, xb, x);
							fx|=c(x, xb, xw);
							fy|=c(yw, yb, y);
							fy|=c(y, yb, yw);
						}else{
							// white
							fx|=c(xb, xw, x);
							fx|=c(x, xw, xb);
							fy|=c(yb, yw, y);
							fy|=c(y, yw, yb);
						}
						if(fx&&fy){
							s[i]=0;
						}else{
							f=false;
						}
					}
				}

				// ã\ÆÈé(Ìóâ)
				int s1=0, s2=0;
				for(int i=0; i<n; i++){
					if(Math.abs(s[i])==1){
						s1=s[i];
					}
				}
				for(int i=n; i<n+m; i++){
					if(Math.abs(s[i])==1){
						s2=s[i];
					}
				}

				// 0©¯ê©Ì¸
				for(int i=0; i<n; i++){
					if(s1*s[i]==-1){
						f=false;
					}
				}
				for(int i=n; i<n+m-1; i++){
					if(s2*s[i]==-1){
						f=false;
					}
				}

				f&=s1*s2!=1;
				if(f){
					println("YES");
					return;
				}
			}
		}
		println("NO");
	}

	// a<=b<=c
	boolean c(double a, double b, double c){
		return a<b+EPS&&b<c+EPS;
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<"\n";  
  
  return 0;
}

Measured memory_bytes: 256
# abc110_a


def solve(numbers):
    return max(
        int(numbers[0] + numbers[2]) + int(numbers[4]),
        int(numbers[2] + numbers[4]) + int(numbers[0]),
        int(numbers[4] + numbers[0]) + int(numbers[2]),
    )


if __name__ == "__main__":
    print(solve(input("")))


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

int main(){
  long long int N;
  long long int i;
  long long int g,l;
  long long int ans = 1;
  cin >> N;
  for(i=0;i<=N-1;i++){
    long long int x;
    cin >> x;
    g = __gcd(ans,x);
    l = ans/g*x;
    ans = max(ans,l);
  }
  cout << ans << endl;
}

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

using ll = long long;
int n;
vector<vector<int>> ans;
void dfs(int i, int j, vector<int> v){
	if(i == n){
		ans.push_back(v);
		return;
	}
	for(int k = 0;k <= j;k++){
		v.push_back(k);
		dfs(i+1, j, v);
		v.pop_back();
	}
	v.push_back(j+1);
	dfs(i+1, j+1, v);
}
int main(){
	cin >> n;
	dfs(0, -1, vector<int>());
	for(auto a : ans){
		string s;
		for(auto b : a)s.push_back(b + 'a');
		cout<<s<<endl;
	}
}

Measured memory_bytes: 10032
package main

import (
	"fmt"
	"strings"
)

func main() {
	ans := []string{}
	for {
		var H, W int
		fmt.Scan(&H, &W)
		if H+W == 0 {
			break
		}

		for i := range make([]int, H) {
			if i == 0 || i == H-1 {
				ans = append(ans, strings.Repeat("#", W))
			} else {
				ans = append(ans, "#"+strings.Repeat(".", W-2)+"#")
			}
		}
		ans = append(ans, "")
	}
	fmt.Println(strings.Join(ans, "\n"))
}



Measured memory_bytes: 1428