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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int d; cin>>d;

	int result = (d+0.99999999)/1.08;
	
	int check = result * 1.08;
	if(check != d){
		cout << ":(" << endl;
		return;
	}

	cout << result <<endl;


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
arr = []
n.times do
  arr << gets.to_s
end
max = arr.inject(Hash.new(0)) { |h,v| h[v] += 1; h }.sort.to_h
max_value = max.max_by{|_, v| v}[1]

for k, v in max
  puts k if v == max_value
end


Measured memory_bytes: 74624
#include <bits/stdc++.h>
//template based on percywtc
//best of luck
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define FOS(it,s) for (auto it=s.begin();it!=s.end();it++)
#define REP(n) FOR(zzzzzzzzzz, 0, n)
#define SET(a,e) memset(a,e,sizeof(a))
#define CPY(s,d) memcpy(d,s,sizeof(d))
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pq priority_queue
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define MII map<int,int>
#define MLI map<int,LL>
#define MIL map<LL,int>
#define MLL map<LL,LL>
#define MDD map<LD,LD>
#define MSI map<string,int>
#define UMII unordered_map<int,int>
#define SI set<int>
#define SPII set < PII >
#define USI unordered_set <int>
#define eps 1e-9
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define HH1 402653189
#define HH2 1610612741
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/gcd(a,b)
#define sc scanf
#define pr printf

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const double PI = acos(-1.0);
const LL mod = 1e9 + 7;

using namespace std;



int main(){
    // freopen("input.in","r",stdin);
    // freopen("output.out","w",stdout);
    vector<int> arr;
    FOR (i,0,3){
        int a;
        scanf("%d",&a);
        arr.pb(a);
    }
    sort(arr.begin(),arr.end());
    printf("%d\n",arr[0]+arr[1]);
}










Measured memory_bytes: 256
N, C, K = map(int, input().split())
arr = sorted([int(input()) for _ in range(N)])
start_t = arr[0]
bus_n = 0
ans = 1
for i in range(N):
    if arr[i] <= start_t + K and bus_n < C:
        bus_n += 1
    else:
        bus_n = 1
        start_t = arr[i]
        ans += 1
print(ans)


Measured memory_bytes: 8280
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int x,y;
    string str="#";
    string ing=".";
    while(1){
        cin>>x>>y;
        if(x==0&&y==0){
            break;
        }
        for(int j=0;j<x/2;j++){
            for(int i=0;i<y/2;i++){
                cout<<str<<ing;
            }
            if(y%2==1){
                cout<<str<<endl;
            }
            else{
                cout<<endl;
            }
             for(int i=0;i<y/2;i++){
                cout<<ing<<str;
            }
            if(y%2==1){
                cout<<ing<<endl;
            }
            else{
                cout<<endl;
            }
        }
        if(x%2==1){
            for(int i=0;i<y/2;i++){
                cout<<str<<ing;
            }
            if(y%2==1){
                cout<<str<<endl;
            }
            else{
                cout<<endl;
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1196
n, m, x = map(int, input().split())
a_tmp = input().split()
a = []
for _ in a_tmp:
    a.append(int(_))
cost_l = 0
cost_r = 0
j = 0
for i in range(n+1):
    if i < x:
        if i == a[j]:
            cost_l += 1
            j += 1
            if j >= len(a):
                break
    elif x < i:
        if i == a[j]:
            cost_r += 1
            j += 1
            if j >= len(a):
                break
    else:
        continue
print(min(cost_l, cost_r))


Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>

constexpr int NUM = 1 << (3*4);
int panel[8][8] = {0};
int w, h, c;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0, 1, 0, -1 };

int changeColor(int colors) {
	int newPanel[8][8];
	int colorCount = 1;
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) newPanel[i][j] = panel[i][j];
	for (int i = 0; i < 5; i++) {
		int color = c;
		if (i < 4) color = (colors >> (i*3)) & 0b111;
		if (color < 1 || 6 < color) return 0;
		int targetColor = newPanel[0][0];
		newPanel[0][0] = color;
		//DFS
		std::stack<std::pair<int, int>> s; s.push(std::make_pair(0, 0));
		while (!s.empty() && color != targetColor) {
			auto node = s.top(); s.pop();
			for (int i = 0; i < 4; i++) {
				auto next = node;
				next.first += dx[i]; next.second += dy[i];
				if (next.first < 0 || next.first >= w || next.second < 0 || next.second >= h) continue;
				if (newPanel[next.second][next.first] != targetColor) continue;
				newPanel[next.second][next.first] = color;
				s.push(next);
			}
		}
	}

	//DFS
	std::stack<std::pair<int, int>> s; s.push(std::make_pair(0, 0));
	newPanel[0][0] = 0;
	while (!s.empty()) {
		auto node = s.top(); s.pop();
		for (int i = 0; i < 4; i++) {
			auto next = node;
			next.first += dx[i]; next.second += dy[i];
			if (next.first < 0 || next.first >= w || next.second < 0 || next.second >= h) continue;
			if (newPanel[next.second][next.first] != c) continue;
			colorCount++;
			newPanel[next.second][next.first] = 0;
			s.push(next);
		}
	}
	return colorCount;
}

int main() {
	while (std::cin >> h >> w >> c && (h || w || c)) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				std::cin >> panel[i][j];
			}
		}

		int max = 0;
		for (int i = 0; i < NUM; i++) {
			max = std::max(changeColor(i), max);
		}
		std::cout << max << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<list>
using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> dp(100001, 0);

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

	long long sum = 0;

	for (int i = 0; i < 100001; i++) {
		sum += (long long)dp[i] * (long long)i;
	}

	int Q;
	cin >> Q;

	vector<int> B(Q, 0);
	vector<int> C(Q, 0);
	
	for (int i = 0; i < Q; i++) {
		cin >> B[i] >> C[i];
	}

	for (int i = 0; i < Q; i++) {
		sum -= (long long)B[i] * (long long)dp[B[i]];
		sum += (long long)C[i] * (long long)dp[B[i]];
		dp[C[i]] += dp[B[i]];
		dp[B[i]] = 0;
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 4496
N,M = list(map(int,input().split()))
x=list(map(int,input().split()))
l=[]
s=0

if N >= M:
  print(0)
  quit()
else:
  x.sort()
  for i in range(1,M):
    l.append(x[i]-x[i-1])
  l.sort(reverse=True)
  for j in range(N-1):
    s += l[j]
  
  print(x[M-1]-x[0]-s)

Measured memory_bytes: 13968
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, x;
//ld ;
//string s;

int main() {
    cin >> n >> m >> x;
    ll a[n][m];
    ll c[n];
    ll prob = 1;
    ll costs = -1;
    for(ll i=0; i<n; i++){
        cin >> c[i];
        prob = prob*2;
        for(ll j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    for(ll i=0; i<prob; i++){
        ll flg = true;
        ll probtemp = i;
        ll keytemp[n];
        for(ll k=0; k<n; k++){
            keytemp[k] = probtemp % 2;
            probtemp = probtemp / 2;
        }
        ll cTemp = 0;
        ll xTemp[m];
        for(ll j=0; j<m; j++){
            xTemp[j] = 0;
            for(ll k=0; k<n; k++){
                xTemp[j] += (a[k][j] * keytemp[k]);
            }
            if(xTemp[j] < x) flg = false;
        }
        if(flg){
            for(ll k=0; k<n; k++){
                cTemp += c[k] * keytemp[k];
            }
            if(costs < 0 || costs > cTemp)costs = cTemp;
        }
    }
    cout << costs << endl;
    return 0;
}


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

int main(void){
    string a,b;
    cin >> a >> b;
    int cnt = 0;
    for(int i=stoi(a);i<=stoi(b);i++){
        string word = to_string(i);
        string rev = word;
        reverse(rev.begin(),rev.end());
        if(word==rev) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	int W, H, N;
	cin>>W>>H>>N;
	int nowLW = 0, nowRW = W, nowDH = 0, nowUH = H;
	for(int i = 0; i < N; i++){
		int x, y, a;
		cin>>x>>y>>a;
		if(a == 1){
			nowLW = max(nowLW, x);
		}
		else if(a == 2){
			nowRW = min(nowRW, x);
		}
		else if(a == 3){
			nowDH = max(nowDH, y);
		}
		else if(a == 4){
			nowUH = min(nowUH, y);
		}
	}
	int ans = (nowUH-nowDH)*(nowRW-nowLW);
	if((nowUH-nowDH)<0 || (nowRW-nowLW)<0)ans = 0;
	cout<<ans;
	
	return 0;
}

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

char field[100][100];
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
int newx, newy, H, W = 0;

void dfs(int x, int y, char target){
	field[x][y] = '.';
	for(int i = 0;i < 4;i++){
		newx = x + dx[i];
		newy = y + dy[i];
		if(0 <= newx && newx < H && 0 <= newy && newy < W && field[newx][newy] == target){
				dfs(newx, newy, target);
		}
	}
	return ;
}

int main(){
	while(true){
		int result = 0;
		cin >> H >> W;
		if(W == 0 && H == 0){break;}
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				cin >> field[i][j];
			}
		}
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				if(field[i][j] != '.'){
					dfs(i,j,field[i][j]);
					result++;
				}
			}
		}
		cout << result << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
        int n;
        ll cnt=0;
        cin>>n;
        vector<ll> a(n);
        for (int i=0; i<n; i++){
                cin>>a[i];
        }
        sort(a.begin(),a.end(),greater<ll>());
        cnt+=a[0];
        int i;
        for(i=0; i<(n-2)/2; i++){
                cnt+=a[i+1]*2;
        }
        if(n%2==1) cnt+=a[i+1];
        cout<<cnt<<endl;
        return 0;
}

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

bool isLowerCase(char x) {
	if (0 <= (x - 'a') && (x - 'a') <= 25) {
		return true;
	}
	else {
		return false;
	}
}

int main() {

	string s; cin >> s;

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

	int cnt = 0;
	for (int i = 2; i < s.size() - 1; i++) {
		if (s[i] == 'C') cnt++;
	}
	if (cnt != 1) {
		cout << "WA" << endl;
		return 0;
	}
	
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == 'C') continue;
		if (!isLowerCase(s[i])) {
			cout << "WA" << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

int main()
{
  int a[3];
  int i,j;

  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  if(a[0]==5 && a[1]==5 && a[2]==7)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

div4, div2 = 0, 0
for i in range(n):
    if a[i]%4 == 0:
        div4 += 1
    elif a[i]%2 == 0:
        div2 += 1

if div4 >= n//2:
    print("Yes")
else:
    if div2 >= n - div4 * 2:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head


void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n & 1) cout << "No\n";
    else{
        if (s.substr(0, n/2) == s.substr(n/2, n/2)) cout << "Yes\n";
        else cout << "No\n";
    }
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3612
/*
Author:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%   ANMOL GUPTA      %%%%%%%% 
%%%%%%%%   NIT HAMIRPUR     %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#define pb push_back
#define debug(x)  cout<<'>'<<#x<<" : "<<x<<endl;
#define mp make_pair
#define ff first
#define ss second
#define allunique(v) 	v.erase(unique(v.begin(),v.end()),v.end());
#define MOD 1000000007
#define MOD9 1000000009
#define th(n) cout<<n<<endl
#define gc getchar_unlocked
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define bolt ios::sync_with_stdio(0)
#define forr(i,n) for(ll i=0;i<n;i++)
#define eof (scanf("%d" ,&n))!=EOF
#define PI acos(-1.0) 
#define all(v) v.begin(),v.end() 
#define endl "\n"
typedef long long ll;
typedef double db;
typedef long long ll;
typedef pair< ll, ll > pll;
typedef vector< ll > vll;
typedef map< ll, ll > mll;
typedef set< ll > sll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//printf("%I64d", n)
	ll n,gd,temp;
	cin>>n;
	cin>>gd;
	for(int i = 1;i<n;i++)
	{
		cin>>temp;
		gd = __gcd(gd,temp);
	}
	cout<<gd;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int H, W; cin >> H >> W;
  vector<string> P(H);
  for(int i = 0; i < H; i++){
    cin >> P[i];
  }
  for(int i = 0; i < W+2; i++){
    cout << '#';
  }
  cout << endl;
  for(int i = 0; i < H; i++){
    cout << '#' << P[i] << '#' << endl;
  }
  for(int i = 0; i < W+2; i++){
    cout << '#';
  }
}


Measured memory_bytes: 256
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N+1)
	B := make([]int, N)
	for i := 0; i < N+1; i++ {
		fmt.Scan(&A[i])
	}
	for i := 0; i < N; i++ {
		fmt.Scan(&B[i])
	}

	ans := 0
	for i := 0; i < N; i++ {
		b := B[i]
		t := min(A[i], b)
		ans += t
		b -= t

		t = min(A[i+1], b)
		A[i+1] -= t
		ans += t
	}
	fmt.Println(ans)
}


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

int main() {
  int N , R;
  cin >> N >> R;
  
  if(N >= 10) {
    cout << R << endl;
  }
  
  else if(N < 10) {
    cout << R + (100*(10-N)) << endl;
  }
}

Measured memory_bytes: 256
#![allow(non_snake_case,unused_imports,dead_code)]
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        AB:[(Usize1,Usize1);N-1],
    }

    let mut E = vec![Vec::new();N];
    for &(a,b) in &AB{
        E[a].push(b);
        E[b].push(a);
    }
    let D = bfs_dist(N,&E,0);
    let (Ef,_Eb) = make_rooted_tree(N, &E, 0);
    let d = D[N-1]/2+1;

    let mut i = N-1;
    while D[i] != d{
        for &j in &E[i]{
            if D[j]<D[i]{
                i = j;
                break
            }
        }
    }

    let n = dfs_connect(N, &Ef, i);
    let ans = n.iter().filter(|&&x| x).count();

    if ans >= (N+1)/2{
        println!("Snuke");
    } else {
        println!("Fennec");
    }

}

fn make_rooted_tree(N:usize,E:&Vec<Vec<usize>>,root:usize) -> (Vec<Vec<usize>>,Vec<Vec<usize>>){
    let mut Ef = vec![Vec::new();N];
    let mut Eb = vec![Vec::new();N];
    let mut done = vec![false;N];
    let mut q = VecDeque::new();
    q.push_back(root);
    done[root] = true;
    while let Some(i) = q.pop_front(){
        for &j in &E[i]{
            if done[j] {continue;}
            done[j] = true;
            q.push_back(j);
            Ef[i].push(j);
            Eb[j].push(i);
        }
    }
    (Ef,Eb)
}

fn dfs_connect(N:usize,E:&Vec<Vec<usize>>,start:usize) -> Vec<bool>{
    let mut done = vec![false;N];
    done[start] = true;
    let mut q = vec![start];
    while let Some(i) = q.pop(){
        for &j in &E[i]{
            if done[j] {continue;}
            q.push(j);
            done[j] = true;
        }
    }
    done
}

fn bfs_dist(N:usize,E:&Vec<Vec<usize>>,start:usize) -> Vec<isize>{
    let mut d = vec![-1;N];
    let mut q = VecDeque::new();
    q.push_back(start);
    d[start] = 0;
    while let Some(i) = q.pop_front(){
        for &j in &E[i]{
            if d[j]!= -1{continue;}
            d[j] = d[i]+1;
            q.push_back(j);
        }
    }
    d
}

Measured memory_bytes: 21952
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
inline int gi() { 
    register int data = 0, w = 1; 
    register char ch = 0; 
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
} 
const int MAX_N = 2e5 + 5; 
int N, val[MAX_N], f[MAX_N]; 
int ans, S, cnt[20], sum[MAX_N]; 
int main () { 
	N = gi(); 
	for (int i = 1; i < N; i++) {
		int u = gi(), v = gi(), w = gi(); 
		val[u] ^= w, val[v] ^= w; 
	} 
	for (int i = 0; i < N; i++) ++cnt[val[i]]; 
    for (int i = 1; i <= 15; i++) ans += (cnt[i] >> 1), S |= (cnt[i] & 1) << (i - 1); 
	for (int i = 1; i < (1 << 15); i++) f[i] = f[i >> 1] + (i & 1); 
	for (int i = 1; i < (1 << 15); i++) --f[i]; 
	for (int i = 1; i < (1 << 15); i++) 
		for (int j = 0; j < 15; j++) if ((i >> j) & 1) sum[i] ^= (j + 1); 
	for (int i = 1; i < (1 << 15); i++) 
	    for (int j = (i - 1) & i; j; j = (j - 1) & i) 
			if (!sum[j]) f[i] = min(f[i], f[j] + f[i ^ j]); 
	printf("%d\n", f[S] + ans); 
	return 0; 
} 

Measured memory_bytes: 896
main = do
  n <- read <$> getLine
  as <- map read . words <$> getLine
  putStrLn . show $ solve n as

solve :: Int -> [Integer] -> Integer
solve n (x:y:xs) =
  if n == 2 then
    max x y
  else
    inSolve (gcd (gcd x y) (head xs)) (maximum [gcd x y,gcd y (head xs), gcd (head xs) x]) (tail xs)

inSolve :: Integer -> Integer -> [Integer] -> Integer
inSolve allgcd minusOne [] = minusOne
inSolve allgcd minusOne (x:xs)=
  let cand = max allgcd (gcd minusOne x)
  in (inSolve (gcd allgcd x) cand xs)


Measured memory_bytes: 36220
#include<cstdio>
#define N 100010
using namespace std;

int n;
char s[N];
int a[N];

void print(){
	for(int i=1;i<=n;i++) printf("%c",a[i]?'W':'S');
}

bool judge(int d,char c,int x,int y){
	if(d==0&&c=='o'&&x==y){return 1;}
	if(d==0&&c=='x'&&x!=y){return 1;}
	if(d==1&&c=='x'&&x==y){return 1;}
	if(d==1&&c=='o'&&x!=y){return 1;}
	return 0;
}

int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int d0=0;d0<=1;d0++){
		for(int d1=0;d1<=1;d1++){
			a[1]=d0;a[2]=d1;
			for(int i=3;i<=n;i++){
				if(a[i-1]==0&&s[i-1]=='o') 
				a[i]=a[i-2];
				if(a[i-1]==0&&s[i-1]=='x') 
				a[i]=a[i-2]^1;
				if(a[i-1]==1&&s[i-1]=='x')
				 a[i]=a[i-2];
				if(a[i-1]==1&&s[i-1]=='o')
				 a[i]=a[i-2]^1;
			}
			if(judge(a[1],s[1],a[n],a[2])&&judge(a[n],s[n],a[n-1],a[1])){
				print();
				return 0;
			}
		}
	}
	printf("-1");
	return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include <assert.h>

int main(void) {
    //int a, b, c, d;
    //int ans;
    //scanf("%d", &a);
    //scanf("%d", &b);
    char s[5];
    char a[] = "ABC";
    //char b[] = "ARC";
    scanf("%s", s);



    if (strcmp(s,a) == 0) {
        puts("ARC");
    }
    else {
        puts("ABC");
    }


    return 0;
}


Measured memory_bytes: 1660
fun main() {
    println(solve())
}

val solve: () -> Any = {
    when (readInt() % 10) {
        2, 4, 5, 7, 9 -> "hon"
        0, 1, 6, 8 -> "pon"
        3 -> "bon"
        else -> ""
    }
}

val mod: Int = 1_000_000_007


fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <T> T.alsoPrintln() = also { println(this) }

fun Boolean.toYesOrNo(yes: String = "Yes", no: String = "No") = if (this) yes else no

fun <E> List<E>.toPair() = this[0] to this[1]

fun <T> readPair(t: (String) -> T) = readPair(t, t)
fun <S, T> readPair(s: (String) -> S, t: (String) -> T) =
    readLine()!!.split(" ").let { Pair(s(it[0]), t(it[1])) }

fun Int.pow(n: Int) = Math.pow(this.toDouble(), n.toDouble())
fun Int.powInt(n: Int) = pow(n).toInt()

fun minAndMax(a: Int, b: Int) = if (a < b) a to b else b to a

fun <T> T.ifOrThis(bool: (T) -> Boolean, trans: (T) -> T) = if (bool(this)) trans(this) else this
fun <T> T.ifOrThis(bool: Boolean, trans: (T) -> T) = if (bool) trans(this) else this

Measured memory_bytes: 34552
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#define maxn 500011
using namespace std;

int n;

char s[maxn];
int DP[maxn][3],inf=0x3f3f3f3f;
int sl[maxn],sr[maxn];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	DP[1][1]=DP[2][1]=-inf;
	DP[1][0]=DP[2][0]=0;
	int one=0,cnt=0;
	for (int i=1;i<=n;i++){
		if (s[i]=='1') one++;
		else cnt++,sl[i]=one,one=0;
	}
	one=0;
	for (int i=n,tot=cnt;i>=1;i--){
		if (s[i]=='1') one++;
		else sr[i]=one,one=0,tot--;
	}
	DP[0][0]=0;DP[0][1]=DP[0][2]=-inf;
	int last=0,ans=0;
	for (int i=1;i<=n;i++) if (s[i]=='0'){
		DP[i][0]=max(DP[last][0],max(DP[last][1],DP[last][2]));
		DP[i][1]=sl[i] && sr[i]?max(DP[last][0]+sl[i],sl[i]>=1?DP[last][1]+sl[i]-1:-inf):-inf;
		DP[i][2]=sl[i] && sr[i]?
		max(max(DP[last][0]+sr[i],sl[i]>=2?DP[last][1]+sr[i]:0),sl[i]>=1?DP[last][2]+sr[i]-1:-inf):-inf;
		ans=max(ans,max(DP[i][0],max(DP[i][1],DP[i][2])));
		last=i;
//		cout<<DP[i][0]<<' '<<DP[i][1]<<' '<<DP[i][2]<<endl;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    vector<int> n(26,0);
    for(int i = 0; i < s.size(); i++)
        n[s[i]-'a']++;
    for(int i = 0; i < n.size(); i++){
        if(n[i]==0){
            cout<<(char)(i+'a');
            return 0;
        }
    }
    cout<<"None";
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 900000000000000
signed main(){
    int n;cin>>n;
    if(n%2==0)cout<<n/2-1<<endl;
    else cout<<n/2<<endl;
}
        

Measured memory_bytes: 764
#include<bits/stdc++.h>
typedef long long LL;
typedef double dl;
#define opt operator
#define pb push_back
const LL maxn=1e6+9,mod=998244353;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}return x*f;
}
LL n,m,K;
LL a[maxn],b[maxn];
int main(){
    n=Read(); m=Read(); K=Read();
    for(LL i=1;i<=n;++i){
    	a[i]=Read();
	}
	for(LL i=1;i<=m;++i){
		b[i]=Read();
	}
	LL sum(0),ans(0),nw(0);
	for(LL i=1;i<=m;++i){
		if(sum+b[i]<=K) sum+=b[i],nw=i;
		else break;
	}
	ans=nw;
	for(LL i=1;i<=n;++i){
		sum+=a[i];
		while(sum>K && nw){
			sum-=b[nw]; --nw;
		}
		if(sum<=K) ans=std::max(ans,i+nw);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6880
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
using namespace std;
map<int,int>a;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int t ;
		scanf("%d",&t);
		a[t]++;
	}
map<int,int>::iterator it;
int cnt=0;
for( it=a.begin();it!=a.end();it++)
{
	if(it->second%2!=0)
	{
		cnt++;
	}

}
cout<<cnt<<endl;
}

Measured memory_bytes: 4864
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
 
H,W = map(int,input().split())
 
table = [[0]*(W+1) for i in range(H+1)]
 
for row in range(H):
    work = list(map(int,input().split())) #★★直にtableに代入すると、列数が変わってしまう!!!★★★
    for col in range(W):
        table[row][col] = work[col]
 
 
for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]
 
 
for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]
 
 
for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6228
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
 
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { //
	return a < b ? a = b, 1 : 0; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// IGNORE
//
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	int cnt = 0;
	char grid[h][w];
	F0R(a, h){
		string s;
		cin >> s;
		strcpy(grid[a], s.c_str());
	}
	F0R(a, (1 << h)){
		F0R(b, (1 << w)){
			int c = 0;
			F0R(i, h){
				F0R(j, w){
					if(grid[i][j] == '#' && !(a & (1 << i) || b & (1 << j)))
						c++;
				}
			}
			if(c == k)
				cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 N, M;
  cin >> N >> M;
  vector<int64> A(N);
  cin >> A;
  debug(A);
  vector<int64> sum(N + 1, 0);
  for (int64 i = 1; i < N + 1; i++) {
    int64 amari = (sum[i - 1] + A[i - 1]) % M;
    sum[i] = amari;
  }
  debug(sum);
  map<int64, int64> mp;
  int64 ans = 0;
  for (int64 i = 0; i < N + 1; i++) {
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::multiprecision::cpp_int;

const long MOD = 1000000007;
template <long MOD = MOD>
class Mint {
  public:
  long x;
  Mint() : x{0L} {}
  Mint(long x) : x{(x % MOD + MOD) % MOD} {}
  Mint operator-() const {return x ? MOD - x : 0;}
  Mint &operator+=(const Mint &a) {
    if ((x += a.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  Mint &operator-=(const Mint &a) {return *this += -a;}
  Mint &operator*=(const Mint &a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  Mint &operator/=(const Mint &a) {
    Mint b{a};
    return *this *= b.power(MOD - 2);
  }
  Mint operator+(const Mint &a) const {return Mint(*this) += a;}
  Mint operator-(const Mint &a) const {return Mint(*this) -= a;}
  Mint operator*(const Mint &a) const {return Mint(*this) *= a;}
  Mint operator/(const Mint &a) const {return Mint(*this) /= a;}
  bool operator<(const Mint &a) const {return x < a.x;}
  bool operator<=(const Mint &a) const {return x <= a.x;}
  bool operator>(const Mint &a) const {return x > a.x;}
  bool operator>=(const Mint &a) const {return x >= a.x;}
  bool operator==(const Mint &a) const {return x == a.x;}
  bool operator!=(const Mint &a) const {return !(*this == a);}
  const Mint power(long N) {
    if (N == 0) {return 1;}
    else if (N % 2 == 1) {return *this * power(N - 1);}
    else {
      Mint half = power(N / 2);
      return half * half;
    }
  }
};

template <long MOD>
Mint<MOD> operator+(long lhs, const Mint<MOD> &rhs) {return rhs + lhs;}
template <long MOD>
Mint<MOD> operator-(long lhs, const Mint<MOD> &rhs) {return -rhs + lhs;}
template <long MOD>
Mint<MOD> operator*(long lhs, const Mint<MOD> &rhs) {return rhs * lhs;}
template <long MOD>
Mint<MOD> operator/(long lhs, const Mint<MOD> &rhs) {return Mint<MOD>{lhs} / rhs;}
template <long MOD>
istream &operator>>(istream &stream, Mint<MOD> &a) {return stream >> a.x;}
template <long MOD>
ostream &operator<<(ostream &stream, const Mint<MOD> &a) {return stream << a.x;}

cpp_int gcd(cpp_int x, cpp_int y) {return y ? gcd(y, x % y) : x;}
cpp_int lcm(cpp_int x, cpp_int y) {return x / gcd(x, y) * y;}

using mint = Mint<MOD>;

int main() {
  int N;
  cin >> N;
  vector<cpp_int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  cpp_int L = 1;
  for (int i = 0; i < N; i++) L = lcm(L, A.at(i));

  mint l{static_cast<long>(L % MOD)};
  vector<mint> B(N);
  for (auto i = 0; i < N; i++) B.at(i) = l / static_cast<long>(A.at(i));
  mint sum{accumulate(B.begin(), B.end(), mint{0})};

  cout << sum << endl;
}

Measured memory_bytes: 768
n,k=map(int,input().split())
p=list(map(int,input().split()))
r=[0]
for i in range(n):
    r.append(r[i]+p[i])
p=0
for i in range(k,n+1):
    p=max(p,r[i]-r[i-k])
print('{:.10f}'.format((p+k)/2))

Measured memory_bytes: 25060
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen

using namespace std;

string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.citation", "r", stdin );
	int n;

	while (cin >> n && n ){

		vector <int> page (n+1, 0 );

		for (int i = 0; i < n; ++i ){
			cin >> page[i];
		} // end for
		page[n] = 1000000;
	
		vector <string> res;

		bool cont = false;
		string str = "";

		for (int i = 0; i < n; ++i ){
			if (!cont ){
				str = itos(page[i] );
			} // end if
				
			if (page[i+1] == page[i] + 1 ){
				if (!cont ){
					cont = true;
				} // end if
				continue;
			}else{
				if (!cont){
					 res.push_back(str);
				}else{
					str += '-';
					str += itos(page[i] );
					res.push_back(str);
					cont = false;
				} // end if
			} // end if
		} // end for

		int size = res.size();

		for (int i = 0; i < size; ++i ){
			cout << res[i];
			if (i != size - 1 ){
				cout << ' ';
			} // end if
		} // end for
		cout << endl;
	} // end loop

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <assert.h>
#include <map>

using std::cerr;
using std::cin;
using std::cout;
using std::pair;
using std::string;
using std::vector;
//region
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (b); i >= (b); --i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n)-1; i >= 0; --i)
#define repr1(i, n) for (int i = (n); i > 0; --i)
#define outif(b, t, f) cout << ((b) ? (t) : (f)) << endl
#define all(vec) (vec).begin(), (vec).end()
#define sz(x) (int((x).size()))
#define mset(v, n) std::memset((v), n, sizeof(v))
#define BIT(N) (1LL << (N))
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using vint = vector<int>;
using vlong = vector<ll>;
using vstr = vector<string>;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpll = vector<pll>;
using vvi = vector<vint>;
using vvl = vector<vlong>;
vector<string> split(const string &s, const string &delim) {
  vector<string> res;
  uint pos = 0;
  while (true) {
    const int found = s.find(delim, pos);
    if (found < 0) {
      res.push_back(s.substr(pos));
      break;
    }
    res.push_back(s.substr(pos, found - pos));
    pos = found + delim.size();
  }
  return res;
}
template<typename T> string join(vector<T> &vec, const string &sep) {
  size_t size = vec.size();
  if (!size) return "";
  std::stringstream ss;
  for (int i = 0; i < size - 1; i++)
    ss << vec[i] << sep;
  ss << vec[size - 1];
  return ss.str();
}
template<typename T> std::istream &operator>>(std::istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template<typename Iter> inline void print(const Iter &first, const Iter &last, const std::string &d, bool endline) {
  cout << *first;
  for (Iter iter = first + 1; iter < last; ++iter) {
    cout << d << *iter;
  }
  if (endline) cout << "\n";
}
constexpr ll powmod(ll a, ull b, ull p) {
  ll res = 1;
  while (b > 0) {
    if (b % 2) res = res * a % p;
    a = a * a % p;
    b >>= 1u;
  }
  return res;
}
template<class T> bool chmax(T &a, const T &b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, const T &b) { return a > b ? (a = b, true) : false; }
template <typename T> void bsort(vector<T>& v) { std::sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T>& v) { std::sort(v.begin(), v.end(), std::greater<T>()); }
struct iii {
    iii() {
      cin.tie(nullptr); cout.tie(nullptr);
      std::ios::sync_with_stdio(false);
      cout << std::fixed << std::setprecision(16);
    }
} init;
//endregion

void solve();

int main() {
  int t = 1;
  // scanf("%d", &t);
  rep(_,t) solve();
  return 0;
}

void solve() {
  int X;
  int t;
  cin >> X >> t;
  std::cout << std::max(X - t, 0) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

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

int main(int argc, char *argv[])
{
    int K;
    ll sum = 0;
    cin >> K;

    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                sum += gcd(gcd(i, j), k);
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N,M,A[100];
    cin>>N>>M;
    for (int i=0;i<N;i++){
        cin>>A[i];
    }
    for (int k=1;k<=M;k++){
        for (int i=0 ; i<N-1 ; i++){
            if (A[i] % k>A [i+1] % k) {
                swap(A[i],A[i+1]);
            }
        }
    }
    for (int i=0;i<N;i++){
        cout<<A[i]<<endl;
    }
    return 0;
}



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

const int INF = 1000000;

int main()
{
    int n;
    cin >> n;
    int a[200005], b[200005], d[200005];
    vector<int> v[200005];
    for(int i = 0; i < n - 1; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
        d[n - i - 1] = INF;
    }
    d[0] = 0;
    for(int i = 0; i < n; i++){
        int k = v[i].size();
        for(int j = 0; j < k; j++){
//            cout << v[i][j];
        }
//        cout << endl;
    }
    queue<int> q;
    q.push(0);
    int last;
    while(q.size()){
        int now = q.front();
        q.pop();
        int k = v[now].size();
        for(int i = 0; i < k; i++){
            int next = v[now][i];
//            cout << next << endl;
            if(d[next] == INF){
                last = next;
                q.push(next);
                d[next] = d[now] + 1;
//                cout << next << " " << d[next] << endl;
            }
        }
    }
//    cout << last << endl;
    
    for(int i = 0; i < n; i++){
        d[i] = INF;
    }
    d[last] = 0;
    queue<int> qnew;
    qnew.push(last);
    int last2;
    while(qnew.size()){
        int now = qnew.front();
        qnew.pop();
        int k = v[now].size();
        for(int i = 0; i < k; i++){
            int next = v[now][i];
//            cout << next << endl;
            if(d[next] == INF){
                last2 = next;
                qnew.push(next);
                d[next] = d[now] + 1;
//                cout << d[next] << endl;
//                cout << next << " " << d[next] << endl;
            }
        }
    }
//    cout << d[last2] << endl;
    if(d[last2] % 3 == 1){
        cout << "Second" << endl;
    }
    else{
        cout << "First" << endl;
    }
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin >> N;
    map<ll, ll> mpA;
    REP(i, N - 1) {
        ll tmp; cin >> tmp;
        mpA[tmp]++;
    }
    for (int i = 1; i <= N; i++) {
        cout << mpA[i] << endl;
    }
    return 0;
}


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

int main(){
  int x;	cin >> x;
  if(x<=599)	cout << 8;
  else if(x<=799)	cout << 7;
  else if(x<=999)	cout << 6;
  else if(x<=1199)	cout << 5;
  else if(x<=1399)	cout << 4;
  else if(x<=1599)	cout << 3;
  else if(x<=1799)	cout << 2;
  else if(x<=1999)	cout << 1;
}

Measured memory_bytes: 3628
def main():
    num = int(input())
    #origin(num)
    origin2(num)

def origin2(n):
    i = 1
    while i <= n:
        x = i
        if x % 3 == 0:
            print(' %d' % i, end='')
            i += 1
            continue
        else:
            while x != 0:
                if x % 10 == 3:
                    print(' %d' % i, end='')
                    break
                else:
                    x //= 10
            # end of while x:
        i += 1
    # end of while 1 <= n: 

if __name__ == '__main__':
    main()
    print()


Measured memory_bytes: 5880
def function(S):
    ACGT = ['A', 'C', 'G', 'T']
    ret = 0
    N = len(S)
    for i in range(0, N):
        for j in range(i+1, N+1):
            temp = 0
            l = S[i:j]
            const = 0
            for x in l:
                if x not in ACGT:
                    const = 1
                    break
            if const == 1:
                break
            temp = len(l)
            if temp >= ret:
                ret = temp
    return ret

S = input()
print(function(S))


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

bool all_same(string s) {
    bool ret = true;
    rep(i,s.size()-1) {
        if (s[i] != s[i+1]) {
            ret = false;
            break;
        }
    }
    return ret;
}

int main() {
    string start;
    cin >> start;
    int ans = 1001001001;
    rep(i,26) {
        char target = 'a' + i;
        string s = start;
        int cnt = 0;
        while (!all_same(s)) {
            cnt++;
            string t;
            rep(i,s.size()-1) {
                if (s[i+1] == target) t.push_back(s[i+1]);
                else t.push_back(s[i]);
            }
            s = t;
        }
        ans = min(cnt, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
    a[i],b[i] = map(int, input().split())
import statistics
X = statistics.median(a)
Y = statistics.median(b)
if N%2==1:
    print(Y-X+1)
else:
    print(int((2*(Y-X)+1)))

Measured memory_bytes: 28872
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;
using namespace std;

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    if((a+b+1)>=c) cout<<b+c<<endl;
    else cout<<b+a+b+1<<endl;
}


Measured memory_bytes: 256
n,y = map(int, input().split())
ans=0
flag=False
for i in range(y//10000 + 1):
    for j in range((y-i*10000)//5000 + 1):
        if 10000*i+5000*j+1000*(n-i-j)==y and n-i-j>=0:
            print('{} {} {}'.format(i,j,n-i-j))
            flag=True
            break
    if flag:
        break
if not flag:
    print('{} {} {}'.format(-1,-1,-1))

Measured memory_bytes: 3064
s = input().strip()
t = input().strip()

dist = [[0]*(len(t)+1) for _ in range(len(s)+1)]
for i in range(1, len(s)+1):
    dist[i][0] = i

for i in range(1, len(t)+1):
    dist[0][i] = i

for i in range(1, len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1] == t[j-1]:
            dist[i][j] = dist[i-1][j-1]
        else:
            dist[i][j] = min(dist[i-1][j-1], dist[i][j-1], dist[i-1][j]) + 1

print(dist[len(s)][len(t)])


Measured memory_bytes: 41952
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define ll long long
using namespace std;

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

int main() {
    ll a, b;
    cin >> a >> b;
    cout << (a*b)/gcd(a,b);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c<<endl;
  }
  else if(b==c){
    cout<<a<<endl;
  }
  else{
    cout<<b<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
// AOJ 0092: Square Searching
// 2017.8.12 bal4u@uu
// 2017.11.1 retry

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

int dp[1002][1002];
char map[1002][1005];

int main()
{
    int n, r, c, t, ans;
    char buf[10];

    while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		for (r = 1; r <= n; r++) fgets(map[r]+1, 1005, stdin);

		memset(dp, 0, sizeof(dp));
		for (ans = 0, r = 1; r <= n; r++) for (c = 1; c <= n; c++) {
			if (map[r][c] == '*') dp[r][c] = 0;
			else {
				t = dp[r-1][c  ];
				if (dp[r  ][c-1] < t) t = dp[r  ][c-1];
				if (dp[r-1][c-1] < t) t = dp[r-1][c-1];
				dp[r][c] = ++t;
				if (t > ans) ans = t;
			}
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 6668
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{  
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        HashSet<String> hs=new HashSet<String>();
        int N=Integer.parseInt(br.readLine());
        int count=0;
        for(int i=0;i<N;i++){
            String str=br.readLine();
            boolean added=hs.add(str);
            if(added) count++;
        }
        System.out.println(count);
    }
}


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

int main() {
	char a;
	cin >> a;
	switch(a){
		case 'A':
			cout << 'T' << endl;
			break;
		case 'T':
			cout << 'A' << endl;
			break;
		case 'C':
			cout << 'G' << endl;
			break;
		case 'G':
			cout << 'C' << endl;
			break;
	}
	return 0;
}



Measured memory_bytes: 256