akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.text.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int k = sc.nextInt();
		double[] p = new double[n];
		for (int i = 0; i < p.length; i++) {
			p[i] = sc.nextDouble();
			p[i] = (1 + p[i]) / 2.0;
		}
		for (int i = 1; i < p.length; i++)
			p[i] += p[i - 1];
		double max = p[k - 1];
		for (int i = k; i < p.length; i++) {

			max = Math.max(max, p[i] - p[i - k]);
		}
		pw.println(max);

		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


Measured memory_bytes: 42136
import sys

def parent(i):
    return i // 2
def left(i):
    return 2 * i
def right(i):
    return 2 * i + 1

# sys.stdin = open('input.txt')

size = int(input())
heap = [i for i in map(int, input().split())]
heap = [0] + heap # 1 origin

for i in range(1, size+1):
    print('node ' + str(i) + ': key = ' + str(heap[i]) + ', ', end='')
    if parent(i) >= 1:
        print('parent key = ' + str(heap[parent(i)]) + ', ', end='')
    if left(i) <= size:
        print('left key = ' + str(heap[left(i)]) + ', ', end='')
    if right(i) <= size:
        print('right key = ' + str(heap[right(i)]) + ', ', end='')
    print('')



Measured memory_bytes: 5700
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	public int num;
	public int vol;
 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 int[] a=new int[8];
	 int pro=0;
	 int min=0;
	 int max=0;
	 for(int i=0;i<N;i++) {
		 int temp=sc.nextInt();
		 
		 if(temp<=399) {
			 a[0]++;
		 }else if(temp>=400&&temp<=799) {
			 a[1]++;
		 }else if(temp>=800&&temp<=1199) {
			 a[2]++;
		 }else if(temp>=1200&&temp<=1599) {
			 a[3]++;
		 }else if(temp>=1600&&temp<=1999) {
			 a[4]++;
		 }else if(temp>=2000&&temp<=2399) {
			 a[5]++;
		 }else if(temp>=2400&&temp<=2799) {
			 a[6]++;
		 }else if(temp>=2800&&temp<=3199) {
			 a[7]++;
		 }else if(temp>=3200){
			 pro++;
		 }
	 }
	 
	 
	 
	 for(int i=0;i<8;i++) {
		 if(a[i]!=0) {
			 min++;
		 }
	 }
	 max = min+pro;
	 
	 if(min==0) {
		 min=1;
	 }
	
	 System.out.println(min+" "+max);
 }
	
 
 
}

Measured memory_bytes: 21844
function main()
	L=R=p=0
	s=chomp(readline())
	N=length(s)
	ans=zeros(Int,N)
	for i=1:N
		if s[i]=='R'
			R+=1
			p=i
		else
			L+=1
			if i==N||s[i+1]=='R'
				ans[p]=ans[p+1]=div(L+R,2)
				if (L+R)%2==1
					ans[p+L%2]+=1
				end
				L=R=0
			end
		end
	end
	println.(ans)
end
main()

Measured memory_bytes: 172436
#include <bits/stdc++.h>
        using namespace std;
        #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define trace1(x)                cerr<<#x<<": "<<x<<endl
        #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
        #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
        #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
        #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
        #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
        #define ll long long
        #define endl '\n'
        int main()
        {
            IOS;
            ll n;
            cin>>n;
            vector<ll> v(n);
            ll a,b;
            cin>>a>>b;
            for(ll i=0;i<n;i++)
                cin>>v[i];
            ll q=0,r=0,s=0;
            for(ll i=0;i<n;i++)
            {
                if(v[i]<=a)
                    q++;
                if(v[i]>a&&v[i]<=b)
                    r++;
                if(v[i]>b)
                    s++;
            }
            cout<<min({q,r,s});
        }

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	long long int ans = 1e20;
	vector<long long int> prefix;
	long long int sum = 0;
	long long int n;
	cin >> n;
	for (int i = 0; i < n;i++) {
		long long int l;
		cin >> l;
		sum += l;
		prefix.push_back(sum);
	}
	for (long long int i = 0; i < prefix.size() - 1;i++) {
		ans = min(ans, abs(sum - prefix[i] * 2));
	}
	cout << ans;
	//system("pause");
	return 0;

}

Measured memory_bytes: 2420
// Kevin Mathew T
// Birla Institute of Technology, Mesra
// LinkedIn - https://www.linkedin.com/in/KevinMathewT/
// GitHub - https://github.com/KevinMathewT
// CodeForces - https://codeforces.com/profile/KevinMathew
// CodeChef - https://www.codechef.com/users/KevinMathew
// HackerRank - https://www.hackerrank.com/KevinMathew

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define F first
#define S second
#define fi(a, b) for(ll i=(a);i<=b;i++)
#define fj(a, b) for(ll j=(a);j<=b;j++)
#define fid(a, b) for(ll i=(a);i>=b;i--)
#define fjd(a, b) for(ll j=(a);j>=b;j--)

// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// #include <iostream> 
// using namespace __gnu_pbds; 
// using namespace std; 
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) : Value at kth index in sorted array. 
// order_of_key(k) : Index of the value k.

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    os << "]";
	return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class T> ostream& operator<<(ostream &os, multiset<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, unordered_map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}


const ll N = 210, M = 1e9 + 7;
ll n;

void solve(){
	cin >> n;

	ll tot = 0;

	fi(1, n) fj(1, n) for(ll k=1;k<=n;k++) tot += __gcd(i, __gcd(j, k));
	
	cout << tot << "\n";
}

int main(){
	// freopen("input.txt", "r", stdin);		//Comment
	// freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	// ll T;
	// cin >> T;
	// while(T--)
		solve();

	return 0;
}

Measured memory_bytes: 3616
// ARC093
// E - Bichrome Spanning Tree

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

class UnionFind {
public:
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return false;
        }
        if (data[y] < data[x]) {
            swap(x, y);
        }
        data[x] += data[y];
        data[y] = x;

        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : (data[x] = root(data[x])); }
    int size(int x) { return -data[root(x)]; }
};

struct edge {
    int u, v;
    ll w;
    bool operator<(const edge &e) { return w < e.w; }
};

constexpr ll MOD = 1e9 + 7;

int N, M;
ll X;
vector<edge> es;

int solve() {
    sort(es.begin(), es.end());

    vector<int> pow2(M + 1);
    pow2[0] = 1;
    for (int i = 0; i < M; i++) {
        pow2[i + 1] = pow2[i] * 2 % MOD;
    }

    int cnt_a = 0, cnt_b = 0;
    for (int i = 0; i < M; i++) {
        UnionFind uf = UnionFind(N);
        ll sum = es[i].w;
        uf.unite(es[i].u, es[i].v);
        for (int j = 0; j < M; j++) {
            if (!uf.same(es[j].u, es[j].v)) {
                uf.unite(es[j].u, es[j].v);
                sum += es[j].w;
            }
        }
        if (sum < X) {
            cnt_a++;
        } else if (sum == X) {
            cnt_b++;
        }
    }

    if (cnt_b == 0) {
        return 0;
    }
    if (cnt_a == 0) {
        return ((pow2[cnt_b] + MOD - 2) % MOD) * pow2[M - cnt_b] % MOD;
    }
    return ((pow2[cnt_b] + MOD - 1) % MOD) * pow2[M - cnt_a - cnt_b] % MOD * 2 %
           MOD;
}

int main() {
    cin >> N >> M;
    cin >> X;
    es.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> es[i].u >> es[i].v >> es[i].w;
        es[i].u--;
        es[i].v--;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>                                           
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 

 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;  
typedef unsigned long long ull;         
typedef vector < pii > vpii;                                   	
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;
 
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
 
const int inf = 1e9, maxn = 2e5 + 48, mod = 998244353, N = 102;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;


int n, m, a[N][N], b[N][N], c[N][N], used[N], mt[N], p[N], timer;
vi g[N];

bool try_kuhn (int v) {
	if (used[v] == timer)
		return 0;

	used[v] = timer;

	for (auto to : g[v])
		if (mt[to] == -1) {
			mt[to] = v;
			p[v] = to;
			return 1;
		}

	for (auto to : g[v])
		if (try_kuhn(mt[to])) {
			mt[to] = v;
			p[v] = to;
			return 1;
		}

	return 0;
}


main () {
	fastio
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j) {
			cin >> a[i][j]; 
			c[i][j] = (a[i][j] + m - 1) / m;
			g[i].pb(c[i][j]);
		}

	for (int j = 1; j <= m; ++j) {
		memset(p, -1, sizeof(p));
		memset(mt, -1, sizeof(mt));
		bool run;
		do {
			++timer;
			run = 0;
			for (int i = 1; i <= n; ++i)
				if (p[i] == -1 && try_kuhn(i)) 
					run = 1;
		} while (run);

/*		for (int i = 1; i <= n; ++i)
			cerr << p[i] << ' ';
		cerr << endl;*/

		for (int i = 1; i <= n; ++i)  {			
			for (int jj = 1; jj <= m; ++jj)
				if (c[i][jj] == p[i]) {
					b[i][j] = a[i][jj];
					c[i][jj] = -1;
					break;
				}

			assert(b[i][j]);
			for (int j = 0; j < sz(g[i]); ++j) 
				if (g[i][j] == p[i]) {
					swap(g[i][j], g[i][sz(g[i]) - 1]);
					g[i].ppb();
					break;
				}		
		}
	}
	
	for (int x = 1; x <= n; ++x) {
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= m; ++j) 
				if ((b[i][j] + m - 1) / m == x) 
					c[x][j] = b[i][j];
	}

	for (int i = 1; i <= n; ++i, cout << endl)
		for (int j = 1; j <= m; ++j)
			cout << b[i][j] << ' ';

//	cout << endl;
	for (int i = 1; i <= n; ++i, cout << endl)
		for (int j = 1; j <= m; ++j)
			cout << c[i][j] << ' ';

	return 0;
}	

	     


Measured memory_bytes: 3808
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> AB(N), LR(M);
    rep(i, N) cin >> AB[i].first >> AB[i].second;
    rep(i, M) cin >> LR[i].first >> LR[i].second;

    sort(all(AB));
    rep(i, M) {
        LR[i].first = lower_bound(all(AB), make_pair(LR[i].first, 0)) - AB.begin();
        LR[i].second = upper_bound(all(AB), make_pair(LR[i].second, 1)) - AB.begin();
    }
    vector<bool> C(N + 1);
    C[0] = AB[0].second;
    C[N] = AB[N - 1].second;
    rep(i, 1, N) C[i] = AB[i - 1].second ^ AB[i].second;

    vv<int> lbucket(N + 1);
    rep(i, M) {
        if (LR[i].first != LR[i].second) {
            lbucket[LR[i].first].push_back(i);
        }
    }
    vector<pair<int, int>> xorop;
    vector<bool> ans(M);
    rep(i, N + 1) {
        sort(all(lbucket[i]), [&](int l, int r) { return LR[l].second < LR[r].second; });
        for (int j = lbucket[i].size() - 1; j > 0; --j) {
            if (LR[lbucket[i][j - 1]].second == LR[lbucket[i][j]].second) continue;
            xorop.emplace_back(lbucket[i][j - 1], lbucket[i][j]);
            lbucket[LR[lbucket[i][j - 1]].second].push_back(lbucket[i][j]);
        }
        if (C[i]) {
            if (lbucket[i].size()) {
                ans[lbucket[i][0]] = true;
                C[LR[lbucket[i][0]].second] = !C[LR[lbucket[i][0]].second];
            }
            else {
                write(-1);
                return 0;
            }
        }
    }

    reverse(all(xorop));
    for (auto& op : xorop) ans[op.first] = ans[op.first] ^ ans[op.second];
    int k = accumulate(all(ans), 0);
    write(k);
    rep(i, M) {
        if (ans[i]) cout << (i + 1) << (--k ? ' ' : '\n');
    }
}

Measured memory_bytes: 32360
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, ans = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	int N;
	cin>>N;
	map<string,int>mp;
	rep(i,1,N+1){
		string s,t;
		s=to_string(i);
		t.pb(s[0]);
		t.pb(s[s.size()-1]);
		mp[t]++;
		DBG(i,s,t,"");
	}
	ll ans=0;
	string u,v;
	rep(i,1,10){
		rep(j,1,10){
			u=to_string(i)+to_string(j);
			v=to_string(j)+to_string(i);
			DBG(i,j,u,v);
			ans+=mp[u]*mp[v];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
inc = [0]*n
out = [[] for _ in range(n)]
parent = [[] for _ in range(n)]
for _ in range(n-1+m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  out[a].append(b)
  parent[b].append(a)
  inc[b] += 1

S = {i for i, c in enumerate(inc) if c == 0}
L = []
 
while S:
    k = S.pop()
    L.append(k)
    for m in out[k]:
        inc[m] -= 1
        if inc[m] == 0:
            S.add(m)

A = [(float("inf"), -1) for _ in range(n)]
D = {j:i for i, j in enumerate(L)}
A[L[0]] = (0, -1)
for i in range(1, n):
  now = L[i]
  d, t = A[now]
  for j in parent[now]:
    if d > i - D[j]:
      d = i - D[j]
      t = j
  A[now] = (d, t)
for i, j in A:
  print(j+1)

Measured memory_bytes: 59324
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
const int N=1e5+5;
int n,m,a[N],pos[N],par[N];
int fd(int x) {
    return par[x]==x?x:par[x]=fd(par[x]);
}
void init() {
    for(int i=1;i<=n;i++) par[i]=i;
}
int main() {
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",a+i),pos[a[i]]=i;
    init();int u,v;
    while(m--) {
        scanf("%d%d",&u,&v);
        u=fd(u);v=fd(v);
        par[u]=v;
    }
    int ans=0;
    for(int i=1;i<=n;i++) if(fd(i)==fd(pos[i])) ans++;
    printf("%d\n",ans);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int i = 0;
  while (i + 1 < s.size()){
    if(s[i] == s[i+1]){
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
    if(i + 2 < s.size() && s[i] == s[i+2]){
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
    i++;
  }
  cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; string s; cin >> n >> s;
  int cnt = 0;
  s += "   ";
  for(int i=0; i<n; i++) {
    if(s.substr(i, 3) == "ABC") cnt++;
  }
  cout << cnt << endl;

  return 0;
}

// EOF


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b,c,t=0;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            t++;
        }
    }
    cout<<t<<endl;
    return 0;
}  
    


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




string N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    int ans = 0;
    fore(c, N) if (c == '2') ans++;
    cout << ans << endl;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001LL;
//constexpr double INF = 1e10;
constexpr double EPS = 1e-10;
using number = long long;

int main() {
   int a,b; cin >> a >> b;
   cout << (a <= 9 && b <= 9 ?  a*b : -1) <<endl; 
}


Measured memory_bytes: 256
// Problem : C - H and V
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_c
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

vector<int> tobase4(int n)
{
    vector<int> ans;
    while (n)
    {
        ans.push_back(n % 4);
        n /= 4;
    }

    int ns = 6 - ans.size();
    while (ns > 0)
    {
        ans.push_back(0);
        ns--;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}
char mp[6][6];

void dbg(pair<set<int>, set<int>> const &es)
{
    cerr << "r:[";
    for (auto e : es.first)
        cerr << e << ",";
    cerr << "] -> c:[";
    for (auto e : es.second)
        cerr << e << ",";
    cerr << "]\n";
}

int solve(set<pair<set<int>, set<int>>> const &filt, int k, int n, int m)
{
    int ans = 0;
    for (auto e : filt)
    {
        int count = 0;
        for (int a = 0; a < n; a++)
            for (int b = 0; b < m; b++)
            {
                if (e.first.find(a) != e.first.end())
                    continue;
                if (e.second.find(b) != e.second.end())
                    continue;
                if (mp[a][b] == '#')
                    count++;
            }
        if (count == k)
        {
            // dbg(e);
            ans++;
        }
    }
    return ans;
}

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int a = 0; a < n; a++)
    {
        string sd;
        cin >> sd;
        int j = 0;
        for (auto e : sd)
            mp[a][j++] = e;
    }

    vector<pair<set<int>, set<int>>> sup;
    for (int a = 0; a < 4097; a++)
    {
        auto exsp = tobase4(a);
        pair<set<int>, set<int>> asas;
        for (int t = 0; t < exsp.size(); t++)
        {
            if (exsp[t] == 1)
                asas.first.insert(t);
            else if (exsp[t] == 2)
                asas.second.insert(t);
            else if (exsp[t] == 3)
            {
                asas.second.insert(t);
                asas.first.insert(t);
            }
        }
        sup.push_back(asas);
    }
    set<pair<set<int>, set<int>>> filt;
    for (auto e : sup)
    {
        bool include = true;

        for (int a = n; a < 6; a++)
        {
            if (e.first.find(a) != e.first.end())
            {
                include = false;
                break;
            }
        }

        for (int a = m; a < 6 && include; a++)
        {
            if (e.second.find(a) != e.second.end())
            {
                include = false;
                break;
            }
        }

        if (include)
            filt.insert(e);
    }
    cout << solve(filt, k, n, m);
}


Measured memory_bytes: 5752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;

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

  while (true) {
    if (A+1 != B) {
      A ++;
    } else {
      cout << "Borys" << endl;
      return 0;
    }

    if (B-1 != A) {
      B --;
    } else {
      cout << "Alice" << endl;
      return 0;
    }
  }
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B,C;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>C;
	cout<<min(C,B/A)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long a,b,c,d,n;
int main()
{
	cin>>a>>b>>c>>d>>n;
	b=min(b,a*2);c=min(c,b*2);d=min(d,c*2);
	cout<<n/2*d+n%2*c;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const ll INF = 1000000000;
int main(){
    int n,m,r;
    cin >> n >> m >> r;

    vector<int> city(r);
    for(int i = 0;i < r;i++){
        cin >> city[i];
        city[i]--;
    }

    sort(city.begin(),city.end());

    vector<vector<ll>> d(n,vector<ll>(n,INF));
    for(int i = 0;i < m;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    for(int k = 0;k < n;k++){
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }

    ll ans = INF;
    do{
        ll now = 0;
        for(int i = 0;i < r-1;i++){
            now += d[city[i]][city[i+1]];
        }
        ans = min(ans,now);
    }while(next_permutation(city.begin(),city.end())); 


    cout << ans << endl;
}


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

#define tt template<typename T> ostream& operator <<(ostream& os, const
#define tuv template<typename U, typename V> ostream& operator<<(ostream& os, const
tt vector<T>& v)            { os << "["; for(auto & x : v) os << " " << x; os << " ]"; return os; }
tt vector<vector<T> >& m)   { for(auto & x : m) { for(auto & y : x) os << y << " "; os << "\n"; } return os; }
tt set<T>& s)               { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt unordered_set<T>& s)     { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt queue<T>& q)             { queue<T> q2(q); while(!q2.empty()) { os << q2.front() << " "; q2.pop(); } return os; }
tt stack<T>& s)             { stack<T> s2(s); while(!s2.empty()) { os << s2.top() << " "; s2.pop(); } return os; }
tuv pair<U,V>& p)           { os << "(" << p.first << "," << p.second << ")"; return os; }
tuv map<U,V>& m)            { os << "{ "; for(auto & x : m) os << x.first << ":" << x.second << " "; os << "}"; return os; }
tuv unordered_map<U,V>& um) { os << "{ "; for(auto & x : um) os << x.first << ":" << x.second << " "; os << "}"; return os; }


int main(int argc, char * argv[])
{
    std::ios_base::sync_with_stdio(false);    
    std::cin.tie(NULL);

    int A, B, H, M;
    std::cin >> A >> B >> H >> M;

    long double PI = 3.14159265358979323846264338327950L;


    long double angle_hour = (H/12.0 + M/60.0/12)*2*PI;
    long double minute_hour = (M/60.0)*2*PI;
    
    long double angle_diff = abs(angle_hour - minute_hour);
    if(angle_diff > PI) angle_diff = 2*PI - angle_diff;
    
    long double distsq = A*A + B*B - 2*A*B*cos(angle_diff);

    std::cout << std::setprecision(20) << sqrt(distsq) << std::endl;

    return 0;
}


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

int main() {
  int a, b;
  char op;
  while (1) {
    cin >> a >> op >> b;
    if (op == '?') {break;}
    if (op == '+') {cout << a+b << endl;}
    if (op == '-') {cout << a-b << endl;}
    if (op == '*') {cout << a*b << endl;}
    if (op == '/') {cout << a/b << endl;}
  }
  return 0;
}

Measured memory_bytes: 1164
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	char s[26], tmp;
	bool isunique = true;
	scanf("%s", s);
	string str = s;
	rep(i, int(str.length()) - 1) {
		tmp = str[i];
		str[i] = '-';
		if (str.find(tmp) != string::npos) isunique = false;
		str[i] = tmp;
	}
	printynl(isunique);

	return 0;
}


Measured memory_bytes: 256
S = list(input())
K = int(input())

komoji = list('abcdefghijklmnopqrstuvwxyz')
komoji2 = komoji + komoji
index = {}

num = 1
for k in komoji:
    index[k] = num
    num += 1

cost = []
for s in S:
    c = 27 - index[s]
    if c == 26:
        c = 0
    cost.append(c)

ans = []

for num, c in enumerate(cost):
    if c <= K:
        K -= c
        ans.append('a')
    else:
        ans.append(S[num])
        continue
if K != 0:
    K %= 26
    last = ans[-1]
    last = komoji2[komoji.index(last) + K]
    ans[-1] = last
print(''.join(ans))

Measured memory_bytes: 51212
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll a, b, c, d, e, k;

int main(){
	cin >> a >> b >> c >> d >> e >> k;
	if(e-a <= k){cout << "Yay!" << endl;}
	else{cout << ":(" << endl;}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int TaroPoint = 0;
			int HanakoPoint = 0;

			for(int i = 0;i < n;i++) {
				String TaroCard = sc.next();
				String HanakoCard = sc.next();

				if(TaroCard.compareTo(HanakoCard) > 0) {
					TaroPoint +=3;
				}else if(HanakoCard.compareTo(TaroCard) > 0){
					HanakoPoint +=3;
				}else {
					TaroPoint ++;
					HanakoPoint ++;
				}
			}
			System.out.println(TaroPoint+" "+HanakoPoint);
		}

	}
}


Measured memory_bytes: 29972
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

std::string substrBack(std::string str, size_t pos, size_t len) {
	const size_t strLen = str.length();

	return str.substr(strLen - pos, len);
}

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	rep(i, 1000) {
		string str = substrBack("000" + to_string(i),3, 3);
		int k = 0;
		rep(j, n) {
			if (str[k] == s[j]) {
				k++;
			}
			if (k == 3){
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	system("pause");
}




Measured memory_bytes: 3812
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,k;
int g[500];

int grundy(int x,int k){
  //cout << x << " " << k << endl;
  int a=x/k,r=x%k;
  if (r==0) return a;
  if (a==0) return 0;
  return grundy(x-(1+(r-1)/(a+1))*(a+1),k);
}

int grundy2(int x,int k){
  vector<int> gs(x+1,0);
  Rep(i,1,x+1){
    vector<int> used(x+1);
    Rep(j,1,i/k+1){
      //cout << gs[i-j] << endl;
      used[gs[i-j]]|=1;
    }
    rep(j,x+1){
      //cout << used[j] << endl;
      if (!used[j]) {
        gs[i]=j;
        break;
      }
    }
    cout << i << " " << k << " grundy:" << gs[i] << endl; 
  }
  return gs[x];
}

void solve(){
  cin >> n;
  int ans=0;
  rep(i,n){
    int x,k;
    cin >> x >> k;
    int g1=grundy(x,k);//g2=grundy2(x,k);
    //cout << x << " " << k << " " << g1 << " " << g2 << " " << endl;
    ans^=g1;
  }
  if (ans) cout << "Takahashi" << endl;
  else cout << "Aoki" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
def search(n):
    for i in range(1, 3*n):
        if i*(i-1) == 2*n:
            return i
    return 0


n = int(input())

nodes = search(n)
if nodes != 0:
    print("Yes")
    print(nodes)
    out = [[] for i in range(nodes)]
    index = [int(i) for i in range(nodes)]
    counter = 1
    for i in range(len(index)):
        for j in range(index[i]):
            out[j].append(counter)
            out[i].append(counter)
            counter += 1
    for i in range(len(out)):
        str1 = str(out[i])
        table = str1.maketrans({
            ',': '',
            '[': '',
            ']': '',
        })
        str1 = str1.translate(table)
        print(("{} {}".format(len(out[i]), str1)))
else:
    print("No")

Measured memory_bytes: 8948
#include<bits/stdc++.h>
using namespace std;
const int mx = 1e5+5;
typedef long long ll;
const ll INF = 1e13;
long long int dp[mx];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie();
     int n,W;
     ll V=0;
    cin>>n>>W;
    int  wei[mx],value[mx];
    for(int item =0;item<n;item++)
    {
            cin>>wei[item]>>value[item];
            V+=value[item];
    }
    for(int i=0;i<=V;i++)
        dp[i] = INF;
    dp[0] =0;

    for(int item=0;item<n;item++)
    {
        ll w = wei[item], v = value[item];
        for(ll i=V;i>=v;i--)
            dp[i] = min(dp[i],dp[i-v]+w);
    }
    long long int ans =0;
    for(int i=V;i>=0;i--)
        {
            if(dp[i]<=W)
            {
                ans  =i;
                break;
            }
        }
        cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int n,ans=0;
    cin >> n;
    if(n>2)ans++;
    for(int i=2;i*i<(n-1);i++){
    	if((n-1)%i)continue;
    	ans+=2;
    }
    int x=sqrt(n-1);
    if(x>1 and x*x==n-1)ans++;
    for(int i=2;i*i<n;i++){
    	if(n%i)continue;
    	int t=n;
    	while(t%i==0)t/=i;
    	if(t%i==1)ans++;
    }
    x=sqrt(n);
    if(x*x==n)ans++;
    cout << ans+1;
}


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

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

	if(a == b && a != c){
		cout << "Yes" << endl;
	}else if(b == c && a != c){
		cout << "Yes" << endl;
	}else if(a == c && b != a){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(a<=x&&a+b>=x)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;

const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;

/*
  filippos
  Contest : AtCoder DP contest
  Task : F - LCS
*/

int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  string s, t; cin >> s >> t;

  vvi memo(s.size(), vi(t.size(), -1));

  // 0 = s, 1 = t
  vector<vector<bool>> choice(s.size(), vector<bool>(t.size()));

  function<int(int, int)> lcs = [&](int i, int j){
    if(i == s.size() || j == t.size()) return 0;
    int &ans = memo[i][j];
    if(ans != -1) return ans;
    if(s[i] == t[j]) return ans = 1 + lcs(i+1, j+1);
    int s = lcs(i+1, j);
    int t = lcs(i, j+1);
    choice[i][j] = s < t;
    return ans = max(s, t);
  };

  lcs(0, 0);

  for(int i = 0, j = 0; i < s.size() && j < t.size();){
    // cout << "print in " << i << ", " << j << " @ " << memo[i][j] << '\n';
    if(s[i] == t[j]) cout << s[i], i++, j++;
    else (choice[i][j] ? j : i)++;
  }

  return cout << endl, 0;
}

Measured memory_bytes: 37504
import math
K = int(input())
sum = 0
for i in range(1, K+1):
  for j in range(i, K+1):
    #2i or 3i
    if (i == j):
      for k in range(i, K+1):
        #print("i"+str(i)+"j"+str(j)+"k"+str(k))
        if ((i == j) and (i == k)):
          sum += math.gcd(i, math.gcd(j, k))
        else:
          sum += (3*math.gcd(i, math.gcd(j, k)))
    #1i
    else:
      for k in range(i+1, K+1):
        #print("i"+str(i)+"j"+str(j)+"k"+str(k))
        sum += (3*math.gcd(i, math.gcd(j, k)))
      
print(sum)
      
      
  

Measured memory_bytes: 9200
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.string;


void main() {
    readln;
    auto input = readln.chomp.split.map!(to!int).array;
    auto set = new RedBlackTree!int(input);
    auto cards_num = input.length;
    auto kinds_num = set.length;
    (kinds_num - (cards_num - kinds_num) % 2).writeln;
}

Measured memory_bytes: 6076
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


ll a[16][16];
ll dp[1<<16];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    int i,j;
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            scanf("%lld", &a[i][j]);
        }
    }

    int mm=(1<<n);
    int z[17];
    int k;
    for(k=0; k<mm; k++) {
        int siz=0;
        for(i=0; i<n; i++) {
            if(k & (1<<i)) z[siz++]=i;
        }

        dp[k]=0;
        for(i=0; i<siz; i++) {
            for(j=i+1; j<siz; j++) {
                dp[k] += a[z[i]][z[j]];
            }
        }
    }

    for(k=0; k<mm; k++) {
        int siz=0;
        for(i=0; i<n; i++) {
            if(k & (1<<i)) z[siz++]=i;
        }
        ll max=0;
        int MM=(1<<siz);
        for(i=0; i<MM; i++) {
            int tmp0=0;
            for(j=0; j<siz; j++) {
                if(i & (1<<j)) tmp0 |= (1<<z[j]);
            }
            ll val = dp[tmp0]+dp[k^tmp0];
            max = MAX(max, val);
        }
        dp[k] = max;
    }
    printf("%lld\n", dp[mm-1]);

    return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main{
	static void main() throws Exception{
		int n=sc.nextInt();
		long ans=0;
		for(int i=1;i<=n;i++) {
			long cntL=i,cntR=n-i+1;
			ans+=cntL*cntR;
		}
		for(int i=0;i<n-1;i++) {
			int x=sc.nextInt(),y=sc.nextInt();
			long cntL=Math.min(x, y),cntR=n-Math.max(x, y)+1;
			ans-=cntL*cntR;
		}
		pw.println(ans);
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 46140
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k, s, d = 0;
    cin >> k >> s;
    for (int i = 0; i <= k; i++)
    {
        if (s - i <= k * 2 && s - i >= 0)
            d += min(s - i, k) - max(0, s - i - k) + 1;
    }
    cout << d;
}

Measured memory_bytes: 3552
#include <cstdio>
const int MAXI = 10;

int main() {
    int D, r, x;
    scanf(" %d%d%d", &r, &D, &x);
    for (int i = 0; i < MAXI; ++i) {
        x = r * x - D;
        printf("%d\n", x);
    }
    return 0;
}


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

using namespace std;

const int N = (int)1e2 + 7;	
const int inf = (int)1e9 + 7;

int n, m;
char a[N][N];

int dp[N][N][2];
int calc(int x = 1, int y = 1, int last = 0) {
	if (x > n || y > m) return inf;
	int add = (a[x][y] == '#' && !last);
	if (x == n && y == m) {
		return add;
	}
	int &res = dp[x][y][last];
	if (~res) return res;
	last = (a[x][y] == '#');
	return res = (min(calc(x + 1, y, last), calc(x, y + 1, last)) + add);
}
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> (a[i] + 1);
	}
	memset(dp, -1, sizeof(dp));
	cout << calc();
	return 0;
}

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

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

string s;

ll sol, a;

int main() {
  cin >> s;
  for (auto c : s) {
    if (c == 'B') a++;
    else sol += a;
  }

  cout << sol << endl;
  return 0;
}


Measured memory_bytes: 640