akhauriyash/Code-Regression huggingface dataset:
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def attack_count(x):
    if x == 1:
        return 1
    else:
        return 2 * attack_count(math.floor(x/2)) + 1

# main
H = ii()
print(attack_count(H))


Measured memory_bytes: 3808
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll num[54],n,k,cnt[54];
ll dfs(ll x,ll y){
	if (y>=num[x]-1) return cnt[x];
	if (x==0) return 1;
	ll res=0;
	ll go=min(y-1,num[x-1]);
	if (y>1) res+=dfs(x-1,go);
	if (y>num[x]/2) res++;
	go=min(y-num[x]/2-1,num[x-1]);
	if (y>num[x]/2+1) res+=dfs(x-1,go);
	return res;
}
int main(){
	num[0]=1;
	cnt[0]=1;
	for (ll i=1;i<=50;i++){
		num[i]=num[i-1]*2+3;
		cnt[i]=cnt[i-1]*2+1;
	}
	cin>>n>>k;
	cout<<dfs(n,k);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;



int main()
{
  string s;
  cin >> s;

  string res;
  res.append(s.size(), 'x');

  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		int n;
		while ((n = sc.nextInt()) != 0)
		{
			int s[] = new int[n];
			int c[] = new int[n];
			int loop = 0;
			
			for (int i = 0; i < n; i++)
			{
				s[i] = sc.nextInt();
			}
			while (true)
			{
				for (int i = 0; i < n; i++)
				{
					int count = 0;
					for (int j = 0; j < n; j++)
					{
						if (s[i] == s[j]) count++;
					}
					c[i] = count;
				}
				if (check(s, c))
				{
					for (int i = 0; i < n; i++)
					{
						s[i] = c[i];
					}
					loop++;
				}
				else
				{
					break;
				}
			}
			
			System.out.println(loop);
			int i;
			for (i = 0; i < n-1; i++)
			{
				System.out.print(Integer.toString(c[i]) + " ");
			}
			System.out.println(c[i]);
		}
	}
	private static boolean check(int a[], int b[])
	{
		for (int i = 0; i < a.length; i++)
		{
			if (a[i] != b[i]) return true;
		}
		return false;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s, t; cin >> s >> t;
    bool flag = false;
    for (int i = s.size()-t.size(); i >= 0; i--) {
        bool ok = true;
        rep(j,t.size()) {
            if (s[i+j] != '?') {
                if (s[i+j] != t[j]) ok = false;
            }
        }
        if (ok) {
            rep(j,t.size()) {
                s[i+j] = t[j];
            }
            flag = true;
            break;
        }
    }
    if (flag) {
        rep(i,s.size()) {
            if (s[i] == '?') s[i] = 'a';
        }
        cout << s << endl;
    }
    else cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;

void yes(){
    cout<<"Yes"<<endl;
}

void no(){
    cout<<"No"<<endl;
}

void solve(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        yes();
    }else{
        no();
    }
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	S = input()
	if S[-1] == "s":
		print(S + "es")
	else:
		print(S + "s")
	

if __name__ == '__main__':
	main()

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    char x;cin>>x;
    map<char,char>a;
    a['A']='T';
    a['T']='A';
    a['C']='G';
    a['G']='C';
    cout<<a[x]<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    long long N;
    long long H[100000];

    cin >> N;
    for (int i=0; i<N; i++) cin >> H[i];

    for (int i=N-2; i>=0; i--) {
        if (H[i+1] - H[i] < -1) {
            cout << "No" << endl;
            return 0;
        }
        if (H[i+1] - H[i] == -1) {
            H[i]--;
            if (H[i] < 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 1024
H, W, K = map(int,input().split())

fibonacci = [1,1,2,3,5,8,13,21]

Amida = [ [0] * W for h in range(H+1)]

for h in range(H+1):
	if W == 1:
		break
	for w in range(W):
		if h == 0:
			if w == 0:
				Amida[h][w] = 1
			else:
				break
		elif w == 0:
			Amida[h][w] = fibonacci[W-2] * Amida[h-1][w+1] + fibonacci[W-1] * Amida[h-1][w]
		elif w == W-1:
			Amida[h][w] = fibonacci[W-2] * Amida[h-1][w-1] + fibonacci[W-1] * Amida[h-1][w]
		else:
			Amida[h][w] += (fibonacci[w-1] * fibonacci[W-w-1] * Amida[h-1][w-1])
			Amida[h][w] += (fibonacci[w] * fibonacci[W-w-1] * Amida[h-1][w])
			Amida[h][w] += fibonacci[w] * fibonacci[W-w-2] * Amida[h-1][w+1]

		Amida[h][w] = Amida[h][w] % 1000000007

if W == 1:
	if K == 1:
		print(1)
	else:
		print(0)
else:
	print(Amida[H][K-1])

Measured memory_bytes: 3064
a500 = gets.chomp.to_i
b100 = gets.chomp.to_i
c50 = gets.chomp.to_i
x = gets.chomp.to_i

cnt = 0

(0..a500).each do |ia|
  (0..b100).each do |ib|
    (0..c50).each do |ic|
      cnt += 1 if ia * 500 + ib * 100 + ic * 50 == x
    end
  end
end

puts cnt


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

void solve(int a, int b, int c, int turn=0) {
    if(a%2 || b%2 || c%2) {
        cout << turn << endl;
    }
    else if(a == b && b == c && c == a) {
        cout << -1 << endl;
    }
    else {
        int x=0, y=0, z=0;
        x = b/2 + c/2, y = a/2 + c/2, z = a/2 + b/2;
        solve(x, y, z, turn+1);
    }
}

signed main() {
    int A, B, C; cin >> A >> B >> C;
    solve(A, B, C);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
#define watch(x) cout << (#x)<<" = "<<x<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}


int main() {
	file();
	fast();
	int n; cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	for (int i = 0; i < n; i++) {
		string str; cin >> str;
		if (str == "AC") ac++;
		else if (str == "WA") wa++;
		else if (str == "TLE") tle++;
		else
			re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

 const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
#define rep(i, n) for (int i = 0; i < (n); i++)
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
long long modinv(long long a, long long mod) {
  return modpow(a, mod - 2, mod);
}
int main(){
  int n;
  cin>>n;
  vector<lint> a(n);
  rep(i,n)cin>>a[i];
  lint s=0;
  rep(i,n){
    s+=a[i];
    s%=mod;
  }
  s*=s;
  s%=mod;
  rep(i,n){
    s-=a[i]*a[i];
    s%=mod;
  }
  cout<<(s+mod)*modinv(2,mod)%mod<<endl;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int M, D;

int main() {
	cin >> M >> D;
	
	int ans = 0;
	FOR(i, 1, M + 1) FOR(j, 1, D + 1) {
		if (j % 10 < 2) continue;
		if (j / 10 < 2) continue;
		if ((j/10)*(j%10) == i) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int X;
    cin >> X;
    int max_prime = 100003;
    int prime[100005];
    int index = 0;
    prime[0] = 2;
    prime[1] = 3;
    index = 2;
    for(int i = 5; i <= max_prime; i++){
        int temp = 0;
        REP(j, index)
            if(i % prime[j] == 0){
                temp = 1;
                break;
            }
        if(temp == 0){
            prime[index] = i;
            index++;
        }
    }
    cout << *(lower_bound(prime, prime + index, X)) << endl;
    return 0;
    
}



Measured memory_bytes: 256
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd
class UnionFind(): #集合の取り扱い、辺に重み、階層を意識するときは使えない
    def __init__(self,n):
        self.n=n
        self.par = [-1]*n
    def find(self,x):
        if self.par[x] <0: #負なら親、要素数
            return x
        else: #正なら親の番号
            self.par[x]=self.find(self.par[x]) #一回調べたら根を繋ぎ変える、経路圧縮
            return self.par[x]
    def union(self,x,y):
        x=self.find(x) #x,yの親
        y=self.find(y)

        if x==y: #親が同じなら何もしない
            return 
        if self.par[x]>self.par[y]: #要素数が大きい方をxにする
            x,y=y,x
        self.par[x]+=self.par[y] #xがある集合にyが入った集合をくっつける
        self.par[y]=x

    def size(self,x):
        return -self.par[self.find(x)] #親のサイズ
    
    def same(self,x,y): #親が同じ、すなわち同じ集合か
        return self.find(x)==self.find(y)

    def member(self,x): #同じ木（集合）にある要素全部リストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i)==root ]
    
    def roots(self): #集合の根になってる要素をリストで返す
        return [i for i , x in enumerate(self.par) if x<0]
    
    def group_count(self): #集合の数、木の数
        return len(self.roots())

    def all_member(self): #辞書型で返す
        return {r: self.member(r) for r in self.roots()}
    def __str__(self):
        return "\n".join('{}:{}'.format(r,self.member(r)) for r in self.roots)


input=sys.stdin.readline
n,m=map(int,input().split())
v=tuple(tuple(map(lambda x: int(x)-1,input().split())) for _ in range(m))
ans=[0]*m
ans[-1]=(n*(n-1))//2

tree=UnionFind(n)
for i in range(1,m):
    a,b=v[m-i]
    if tree.same(a,b):
        ans[m-i-1]=ans[m-i]
        continue
    n1=tree.size(a)
    n2=tree.size(b)
    tree.union(a,b)
    ans[m-i-1]=ans[m-i]-(n1*n2)
print(*ans)

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

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

    if ( 2*k <= b-a ){
        for (int i=0; i<k; i++) cout << a + i << "\n";
        for (int i=0; i<k; i++) cout << b - k + i + 1 << "\n";
    }else{
        for (int i=0; i<b-a+1; i++) cout << a + i << "\n";
    }
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 17;
int n, m;
string s;
int dp[N];
int to[N];
PII t[N << 1];

PII combine(PII x, PII y)
{
	if (x.X != y.X) 
	{
		if (x.X < y.X) return x;
		else return y;
	}
	
	return {x.X, min(x.Y, y.Y)};	
}

void build(int v, int tl, int tr)
{
	if (tl == tr)
	{
		t[v] = {INF, tl};
		return;
	}
	
	int tm = (tl + tr) >> 1;
	build(v * 2, tl, tm);
	build(v * 2 + 1, tm + 1, tr);
	t[v] = combine(t[v * 2], t[v * 2 + 1]);
}

PII get(int v, int tl, int tr, int l, int r)
{
	if (l > r || tl > tr) return {INF, INF};
	if (tl == l && tr == r) return t[v];
	int tm = (tl + tr) >> 1;
	return combine(get(v * 2, tl, tm, l, min(r, tm)), 
	get(v * 2 + 1, tm + 1, tr, max(tm + 1, l), r));
}

void update(int v, int tl, int tr, int pos, int val)
{
	if (tl == tr)
	{
		t[v] = {val, tl};
		return;
	}
	
	int tm = (tl + tr) >> 1;
	if (pos <= tm) update(v * 2, tl, tm, pos, val);
	else update(v * 2 + 1, tm + 1, tr, pos, val);
	t[v] = combine(t[v * 2], t[v * 2 + 1]);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	cin >> n >> m >> s;
	FOR(i, 0, n) dp[i] = INF;
	
	build(1, 0, n);
	update(1, 0, n, n, 0);
	
	RFOR(i, n, 0)
	{
		if (s[i] == '1') continue;
		PII G = get(1, 0, n, i + 1, min(i + m, n));
		dp[i] = G.X + 1;
		to[i] = G.Y;
		update(1, 0, n, i, dp[i]);
	}
	
	if (dp[0] >= INF)
	{
		cout << -1;
		return 0;
	}
	
	cerr << dp[0] << endl;
	int zara = 0;
	while(zara != n)
	{
		cout << to[zara] - zara << ' ';
		zara = to[zara];
	}
	cout << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

#define MAXN (100010)

int n, m, tot;
std::vector<int> vec[MAXN];
std::deque<int> ans;
bool vis[MAXN];

void go(int u, bool mark){
	for(auto v : vec[u]){
		if(vis[v]) continue;
		vis[v] = true;
		if(mark) ans.push_back(v);
		else ans.push_front(v);
		go(v, mark);
		tot ++;
		break;
	}
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++ i){
		int u, v;
		scanf("%d%d", &u, &v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	for(int i = 1; i <= n; ++ i){
		if(!vis[i]){
			vis[i] = true;
			tot = 1;
			ans.clear();
			ans.push_back(i);
			go(i, true);
			go(i, false);
			if(tot >= 2){
				printf("%d\n", (int)ans.size());
				for(auto v : ans){
					printf("%d ", v);
				}
				printf("\n");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 11008
from math import gcd
from itertools import combinations_with_replacement

k = int(input())
lst = [i for i in range(1,k+1)]
itr = combinations_with_replacement(lst, 3)
ans = 0

for i in itr:
  st = set(i)
  num = len(st)
  if num == 1:
    ans += i[0]
  elif num == 2:
    a,b = st
    ans += gcd(a,b) * 3
  else:
    ans += gcd(gcd(i[0],i[1]), i[2]) * 6

print(ans)

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

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

    int ans = 0;
    if (A + B >= 24) {
        ans = A + B - 24;
    } else {
        ans = A + B;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

count = 0
for line in sys.stdin:
  try:
    if line == '\n' or line == '\r':
      break
    line = line.strip()
    condition = True
    for i in range(len(line) // 2):
      if line[i] != line[-(i+1)]:
        condition = False
        break
    if condition:
      count += 1
  except:
    break
print(count)



Measured memory_bytes: 5564
x,n=map(int,input().split())
p=list(map(int,input().split()))

for i in range(100):
    if x not in p:
        print(x)
        break

    else:
        x1=x
        x2=x
        x1=x1-i
        x2=x2+i
        if x1 not in p:
            print(x1)
            break
        
        elif x2 not in p:
            print(x2)
            break

        else:
            continue


Measured memory_bytes: 9216
// ???????????????
#include<vector>
#include<tuple>
// ???
typedef int Weight;
// ?????????
class Tree {
public:
  explicit Tree(int n);
  void join(int u, int v, Weight w);
  Weight diameter() const;
private:
  struct Edge {int from, to; Weight weight;};
  struct Farthest {int vertex; Weight cost;};
  const Farthest diameter_dfs(int current, int previous) const;
  std::vector<std::vector<Edge>> edge_;
};
// ?????????????????????
Tree::Tree(int n) : edge_(n) {}
// ????????????
void Tree::join(int u, int v, Weight w) {
  edge_[u].push_back({u, v, w});
  edge_[v].push_back({v, u, w});
}
// ??´???
Weight Tree::diameter() const {
  int v = diameter_dfs(0, 0).vertex;
  return diameter_dfs(v, v).cost;
}
const Tree::Farthest Tree::diameter_dfs(int current, int previous) const {
  Farthest result({current, 0});
  for(const auto& e: edge_[current]) {
    if(e.to == previous) continue;
    auto f = diameter_dfs(e.to, e.from);
    f.cost += e.weight;
    if(result.cost < f.cost) result = f;
  }
  return result;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  Tree tree(n);
  for(int i = 0; i < n - 1; ++i) {
    int s, t, w;
    cin >> s >> t >> w;
    tree.join(s, t, w);
  }
  cout << tree.diameter() << endl;
}

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

long long a[12] = {59049, 46656, 7776, 6561, 1296, 729, 216,
                    81, 36, 9, 6, 1};

long long counter(long long N, int index, long long count){
    if(index == 11){
        return N;
    }
    long long maxindex = N / a[index];
    long long minreturn = 99999999999;
    for(long long i = 0; i <= maxindex; i++){
        if(i>count) break;
        if(maxindex>count) break;
        minreturn = min(minreturn, i+counter(N-a[index]*i, index+1, count));
    }
    return minreturn;
}

int main(){
    long long N;
    long long shou,count=0;
    cin >> N;
    long long tempN = N;

    for(int i = 0; i<12; i++){
        shou = N / a[i];
        count += shou;
        N -= shou * a[i];
    }

    cout << counter(tempN, 0, count) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long ansB = B / C ;
		long ansA = A / C ;
		long ans = ansB - ansA;
	  if(A % C == 0){
			ans += 1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  if (n == 1) {
    cout << "Hello World\n";
    return 0;
  }
  
  int a, b;
  cin >> a >> b;
  cout << a + b << "\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#define INF 10000000
#define I64 long long int
#define FOR(a,start,end) for(I64 a=(start);a<(end);a++)
using namespace std;

int main(){
	//4ûüpzñ
	int vec[] = {1, -1, 4, -4};
	queue<string> que;
	que.push("01234567");

	//TõÏÝe[u
	map<string, int> d;

	//"01234567"©çtü«ÉDæTõµÈªçTõÏÝe[uðßé
	while(!que.empty()){
		string str = que.front();
		que.pop();
		int zero = str.find("0");

		string str2;
		FOR(i, 0, 4){
			int next_z;
			next_z = zero + vec[i];
			if(next_z >= 0 && next_z <= 7 && !((zero == 3 && next_z == 4) || (zero == 4 && next_z == 3))){
				str2 = str;
				swap(str2[zero], str2[next_z]);
				if(d.find(str2) == d.end()){
					que.push(str2);
					d[str2] = d[str] + 1;
				}
			}
		}
	}

	//üÍ©ç' 'ð¢ÄTõÏÝe[u©ç¦ðoÍ
	string num;
	while(getline(cin, num)){
		string::iterator end_it = remove(num.begin(), num.end(), ' ');
		num.erase(end_it, num.end());
		cout << d[num] << endl;
	}
}

Measured memory_bytes: 2048
package main

import "fmt"

func main() {
	var W, H, x, y, r int
	fmt.Scan(&W, &H, &x, &y, &r)
	ans := "No"

	switch {
	case x-r < 0 || y-r < 0:
	case x+r > W || y+r > H:
	default:
		ans = "Yes"
	}
	fmt.Println(ans)
}



Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n,ba=0;
	cin>>n;
	for(int t=1;t<=9;t++)
	{
		if(t<=n)
		{
			ba++;
		}
	}
	for(int t=100;t<=999;t++)
	{
		if(t<=n)
		{
			ba++;
		}
	}
	for(int t=10000;t<=99999;t++)
	{
		if(t<=n)
		{
			ba++;
		}
	}
	cout<<ba;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);CIN(K);
    I vec;
    int iti;
    REP(a,N){
        CIN(b);
        if(b==1)iti=a;
        vec.pb(b);
    }
    N--;
    int ans = 0;
    ans = N/(K-1);
    if(N%(K-1)!=0)ans++;
    COUT(ans);
    return 0;
}


Measured memory_bytes: 892
/*
* @Author: Samson
* @Date:   2018-06-28 21:51:36
* @Last Modified by:   Samson
* @Last Modified time: 2018-06-28 23:03:03
*/
//   @URL : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B

#include<bits/stdc++.h>
#include<algorithm>
#include <queue>
#include<vector>
#include<list>
#include <cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 1e4+10;

vector<int> g[MAXN];
list<int> l;
int in[MAXN],vis[MAXN];
 
void bfs(int s)
{
	queue<int> que;
	que.push(s);
	vis[s] = 1;
	while(que.size())
	{
		int u = que.front();
		que.pop();
		l.push_back(u);
		for(int i = 0; i < g[u].size(); ++i)
		{
			int v = g[u][i];
			--in[v];
			if(!in[v] && !vis[v])
			{
				que.push(v);
				vis[v] = 1;
			}
		}
	}
}

void solve(int n)
{
	for(int u = 0; u < n; ++u)
	{
		if(!in[u] && !vis[u])
			bfs(u);
	}
	for(list<int>::iterator it = l.begin(); it != l.end(); ++it)
		cout<<*it<<'\n';
}

int main(void)
{
	ios::sync_with_stdio(false); 
	//cin.tie(0);
	int v,e,s,t;
	cin>>v>>e;
	for(int i = 1; i <= e; ++i)
	{
		cin>>s>>t;
		g[s].push_back(t);
		++in[t];
	}

	solve(v);

	return 0;
}



Measured memory_bytes: 4144
#include <stdio.h>
#include <math.h>
 
int main(){
int n;
double x1,y1,x2,y2,x3,y3,a,b,c,s,q,sina,r,px,py;
scanf("%d",&n);
while (n--){
scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
a = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
b = sqrt(pow(x1-x3,2)+pow(y1-y3,2));
c = sqrt(pow(x2-x3,2)+pow(y2-y3,2));
s = (a+b+c)/2;
q= sqrt(s*(s-a)*(s-b)*(s-c));
sina = 2*q/b/c;
r = a/sina/2;
a = a*a; b = b*b; c = c*c;
px = (a*(b+c-a)*x3 + b*(a+c-b)*x2+c*(a+b-c)*x1)/16/pow(q,2);
py = (a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/pow(q,2);
printf("%.3f %.3f %.3f\n", px, py, r);
}
return 0;
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int row, col;
	cin >> row >> col;
	
	vector<vector<int>> blocks(row, vector<int>(col));

	for (int i=0; i<row; i++) {
		string line;
		cin >> line;
		for (int j=0; j<col; j++) {
			string r;
			r = line.at(j);
			if (r == ".") {
				blocks.at(i).at(j) = 0;
			}
			else {
				blocks.at(i).at(j) = -1;
			}
		}
	}
	
	for (int i=0; i<row; i++) {
		for (int j=0; j<col; j++) {
			if (blocks.at(i).at(j) == -1) {
				for (int k=max(0, i-1); k<min(row, i+2); k++) {
					for (int l=max(0, j-1); l<min(col, j+2); l++) {
						if (!(blocks.at(k).at(l) == -1)) {
							blocks.at(k).at(l)++;
						}
					}
				}
			}
		}
	}

	for (int i=0; i<row; i++) {
		for (int j=0; j<col; j++) {
			if (blocks.at(i).at(j) == -1) {
				cout << "#";
			}
			else {
				cout << blocks.at(i).at(j);
			}
		}
		cout << endl;
	}

}


Measured memory_bytes: 256
# stdin
INPUT_SENTENCES = 2
ss = [input() for i in range(INPUT_SENTENCES)]
n = int(ss[0])
p = [int(i) for i in ss[1].split()]
result = 0
print(len(
    [1 for i in
        [{"pm": sorted([p[i-1], p[i], p[i+1]])[1], "p": p[i]} for i in range(1, n-1)]
        if i["pm"] == i["p"]]
        ))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var count = new long[n + 1];
            for (int i = 0; i < n; i++)
            {
                count[a[i]]++;
            }

            long sum = 0;

            for(int i = 1; i <= n; i++)
            {
                sum += (count[i] - 1) * count[i] / 2;
            }

            for(int k = 0; k < n; k++)
            {
                Console.WriteLine(sum - count[a[k]] + 1);
            }
        }
    }
}


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

int main(){
	
	int n;
	string str;
	cin>>n;
	while(n>0){
		int base[4]={0};
		int o=0;
		while(o!=3){
		cin>>str;
		if(str=="HIT"){
			for(int i=3;i>0;i--){
				base[i]+=base[i-1];
				base[i-1]=0;
		}
			base[0]=1;
		}
			else if(str=="HOMERUN"){
				int k=1;
				for(int i=0;i<3;i++){
			if(base[i]==1)
				k++;
				base[i]=0;
				}
				base[3]+=k;
		}
			else if(str=="OUT")
				o++;
	}
		cout<<base[3]<<endl;
		n--;
	}
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    int r;

    int m = max({a,b,c});

    for(int i = m; ; i++){
        if((i*3 - sum) % 2 == 0){
            r = i;
            break;
        }
    }
    cout << (r*3 - sum) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <cmath> // fabs, pow, sqrt, sin, fmod
#include <chrono> // system_clock 
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

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

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

    vector<int> c(26);
    rep(i, 26) {
        cin >> c.at(i);
    }

    vector<vector<int>> s(D, vector<int>(26));
    rep(d, D) {
        rep(i, 26) {
            cin >> s.at(d).at(i);
        }
    }

    vector<int> t(D); //その日に選んだコンテスト

    /*
    rep(d, D) {
        int max = 0;
        t[d] = 1;
        rep(i, 26) {
            if(max < s[d][i]) {
                max = s[d][i];
                t[d] = i;
            }
        }
    }
    */
    

    //スコア計算
    int score = 0;

    vector<int> last(26);
    rep(i,26) last[i]= -1;

    rep(d, D) { //d:day
        int max_t = 10;
        int max_score = 0;

        rep(i, 26) { //i:contest
            int tmp_score = score;
            vector<int> tmp_last = last;
            t[d] = i;
            tmp_last[t.at(d)] = d;
            tmp_score += s[d][t[d]];
            rep(j, 26) { 
                tmp_score -= c[j] * (d - tmp_last[j]);
            }
            if(max_score < tmp_score) {
                max_t = i;
                max_score = tmp_score;
            }
        }
        t[d] = max_t;
        last[max_t] = d;
        score = max_score;
    }

    rep(d, D) {
        cout << t[d]+1 << endl;
    }
    
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define MAX 3000
using namespace std;

int dp[MAX+1][MAX+1];

string print_lcs(string& s, string& t, int len){

    string LCS = "";
    int i=0,j=0;

    while(len > 0){
        if(s[i] == t[j]){
            LCS += s[i];
            i++;
            j++;
            len--;
        }
        else{
            if(dp[i][j+1] > dp[i+1][j]){
                j++;
            }
            else{
                i++;
            }
        }
    }
    return LCS;
}

int length_lcs(string& s, string& t, int i, int j){

    if(i >= s.length() || j >= t.length()){
        return 0;
    }
    if(dp[i][j] != -1){
        return dp[i][j];
    }

    if(s[i] == t[j]){
        return dp[i][j] = 1 + length_lcs(s,t,i+1,j+1);  /// here dp[i][j] represents length of lcs of string s from i to end and string t from j to end
    }
    else{
        return dp[i][j] = max(length_lcs(s,t,i+1,j),length_lcs(s,t,i,j+1));
    }
}

int main(){

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

    memset(dp,-1,sizeof(dp));

    int len = length_lcs(s,t,0,0);

    string LCS;

    LCS = print_lcs(s,t,len);

    cout<<LCS<<"\n";

return 0;
}


Measured memory_bytes: 35968
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}


int main(){
  while(1){
    int x,y,count=0;
    cin>>x>>y;
    if(x<y) swap(x,y);
    if(x==0&& y==0) break;
    while(1){
      x%=y;
      swap(x,y);
      count++;
      if(y==0) break;
    }
    cout<<x<<" "<<count<<endl;
  }
  return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i = 1;i <= N;i++){
        ll num = N / i;
        if(num == 1){
            ans += i;
        }
        else{
            ll low = i;
            ll high = N / i * i;
            ans += (low + high) * num / 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
// #include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define int long long

// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define all(v) v.begin(), v.end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
// union of two containers
template <typename T>
void container_union(T &c1, T &c2, T &c3) {
  std::vector<int> vec;
  std::set_union(c1.begin(), c1.end(),
                 c2.begin(), c2.end(),
                 std::back_inserter(vec));
  T tmp(vec.begin(), vec.end());
  c3 = tmp;
}

// chmax, chmin
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// grid-search
std::vector<int> dx = {1, -1, 0,  0};
std::vector<int> dy = {0,  0, 1, -1};
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

// yes/no
std::string yes = "Yes";
std::string no = "No";
std::string YES = "YES";
std::string NO = "NO";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

void solve() {
  int n;
  std::cin >> n;
  std::set<int> s;
  int a;
  REP(i, n) {
    std::cin >> a;
    if (s.count(a)) {
      cout(NO);
      return;
    }
    s.insert(a);
  }
  cout(YES);
}


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

int main() {
  int n;
  cin >> n;
  vector<int> A(n), B(n);

  for (int i = 0; i < n; i++) {
    cin >> A[i] >> B[i];
  }

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

  if (n % 2 == 0) {
    cout << B[n / 2] + B[n / 2 - 1] - A[n / 2] - A[n / 2 - 1] + 1 << endl;
  }
  else {
    cout << B[n / 2] - A[n / 2] + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 4848
using System;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sum = 0;
			for(var i = 0; i < 10 ; i++)
			{
				sum += int.Parse(Console.ReadLine());
			}
			Console.WriteLine(sum);
		}
	}
}

Measured memory_bytes: 5600
#include<stdio.h>  
#include<stdbool.h>
#include<string.h>
int main(){
	int n,m,k;
	int max;
	int j;
	scanf("%d%d%d",&n,&m,&k);
	if(m>n)
	max=m;
	else 
	max=n;
	if(k%max==0)
    j=k/max;
    else 
    j=k/max+1;
    printf("%d",j);
    
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    rep(i, a) {
        if ('0' <= s[i] && s[i] <= '9') {}
        else {
            put("No");
            return 0;
        }
    }

    if (s[a] != '-') {
        put("No");
        return 0;
    }

    rep(i, b) {
        if ('0' <= s[a + 1 + i] && s[a + 1 + i] <= '9') {}
        else {
            put("No");
            return 0;
        }
    }
    put("Yes");
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<utility>
#define mod 998244853
using namespace std;
int in[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
struct b{
  int x, y;
};
struct compare{
  bool operator()(pair<int, int> const& a, pair<int, int> const& b)
  {
      return a.second > b.second;
  }
};
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    double n;
    cin >> n;
    cout.precision(6);
    if((int)(n)%2==0)
        cout << 0.5 << '\n';
    else
        cout << ((n-1.0)/2.0+1.0)/n << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  s+='.';
  int len=1;
  int st=0;
  int ans = 0;
  priority_queue<int>q;
  rep(i,n){
    if(s[i]==s[i+1])len++;
    else{
      ans += len-1;
      q.push(len);
      len=1;
    }
  }
  while(k){
    k--;
    ans+=2;
    q.pop();
  }
  cout << min(ans,n-1) << endl;
      
      
  return 0;
}

Measured memory_bytes: 4068
from fractions import gcd

N, M = list(map(int, input().split()))
S = input()
T = input()

L = (N * M) // gcd(N, M)

L1 = [0]
L2 = [0]

from collections import Counter
c = Counter()

for i in range(1, N):
    t = i * (L // N) + 1
    L1.append(t-1)

for i in range(1, M):
    t = i * (L // M) + 1
    L2.append(t-1)


d = {}
for i, li in enumerate(L1):
    d[li] = S[i]

# print(d)

ans = True

for i, li in enumerate(L2):
    if not d.get(li):
        continue
    if d[li] != T[i]:
        ans = False

# print(L1)
# print(L2)
# print(common)
# print(dic)

if ans:
    print(L)
else:
    print(-1)




Measured memory_bytes: 21076
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  long long N, K;

  std::cin >> N >> K;

  long long C = 0;

  if (K == 0) {
    C = N * N;
  }
  else {
    for (long long b = K + 1; b <= N; b ++) {
      long long c = N / b, u = c * b;

      C += (b - K) * c;

      if (u + 1 <= N) {
        int l = (u + 1) % b, u = N % b;

        l = std::max<long long>(l, K);
        u = std::min<long long>(u, b - 1);

        C += std::max(u - l + 1, 0);
      }
    }
  }

  std::cout << C << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 205
#define M 10000005
using namespace std;
bool B[M];
int n,a[N],m,k,P[M/10],w[N],G[N][N],mp[N],vis[N],cnt;
void prepare()
{
	int i,j; B[1]=1;
	for(i=2;i<M;i++){
		if(!B[i]) P[++m]=i;
		for(j=1;j<=m;j++){
			if(i*P[j]>=M) break;
			B[i*P[j]]=1;
			if(i%P[j]==0) break;
		  }
	  }
	B[2]=1;
}
int find(int t)
{
	int i,q=0;
	for(i=1;i<=m;i++){
		if(vis[i]==cnt||!G[t][i]) continue;
		vis[i]=cnt,q=mp[i],mp[i]=t;
		if(!q||find(q)) return 1;
		mp[i]=q;
	  }
	return 0;
}
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	prepare(),m=0;
	for(i=1;i<=n;i=j){
		for(j=i;j<=n&&a[j]==a[i]+j-i;j++);
		w[++m]=a[i],w[++m]=a[j-1]+1;
	  }
	for(i=1;i<=m;i++)
		if(w[i]%2==0)
			for(j=1;j<=m;j++)
				if(w[j]%2==1&&!B[abs(w[i]-w[j])])
					G[i][j]=1;
	for(i=1;i<=m;i++)
		if(w[i]%2==0)
			++cnt,k+=find(i);
	printf("%d",k+((cnt-k)/2+(m-cnt-k)/2)*2+((cnt-k)%2)*3);
	return 0;
}


Measured memory_bytes: 14080
// ※※※ 解答不能 ※※※
// koosaga氏.
// https://atcoder.jp/contests/code-festival-2016-quala/submissions/893805
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second
#define pb push_back

vector<P> gph[200005];
int n, m, k;
bool vis[200005];
LL val[200005], l, r;

void dfs(int x, LL v){
    if(vis[x]){
        if(val[x] != v){
            puts("No");
            exit(0);
        }
        return;
    }
    vis[x] = 1;
    val[x] = v;
    if(x <= n) l = max(l, v);
    else       r = min(r, v);
    for(auto &i : gph[x]) dfs(i.a, v + i.b);
}

int main(){
    scanf("%d %d %d", &n, &m, &k);
    rep(i, k){
        int x, y, v;
        scanf("%d %d %d", &x, &y, &v);
        gph[x].pb(P(y + n, v));
        gph[y + n].pb(P(x, -v));
    }
    repx(i, 1, n + m + 1){
        if(!vis[i]){
            l = -1e18, r = 1e18;
            dfs(i, 0);
            if(l > r) return !puts("No");
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 12928