akhauriyash/Code-Regression huggingface dataset:
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 
#define MODB  998244353

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

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODB;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){ //除算のみO(log mod)なので注意。割る数が小さいならnCrのinvを使うこと
		ll exp = mod - 2;
		while(exp > 0){ 
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

//さらにnCrのために、x!とその逆元を配列で持つ
const int NMAX = 500000; // 10^7くらいまではいけそう
ll fact[NMAX], finv[NMAX], inv[NMAX];

void ncr_init(){ //はじめにinitすること
	fact[0] = fact[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i < NMAX; i++){
		fact[i] = fact[i-1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i-1]* inv[i] % mod;
	}
}
ll ncr(int n, int r){
	if(n<r) return 0;
	if(n<0 || r<0) return 0;
	return fact[n] * (finv[n-r] * finv[r] % mod) % mod;
}
//

int main() {
	modint ans = 0;
	ll tmp;
	int n; cin >> n;
	ll a, b, k;
	cin >> a >> b >> k;
	ncr_init();
	for(ll x=0; x <= n; x++){
		if((k - a * x) % b != 0) continue;
		if((k - a * x) / b < 0) continue;
		ll y = (k - a * x) / b;
		ans += ncr(n, x) * ncr(n, y);
	}
	cout << ans.x << endl;
}

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

void chkmin(long long &a, int b) {
  if (b < a)
    a = b;
}

int main() {
  int N; cin >> N;
  int K; cin >> K;
  long long input[100010];
  long long dp[100010];
  const long long INF = 1LL << 60;
  
  for (int i=0; i<N; ++i) cin >> input[i];
  for (int i=0; i<100010; ++i) dp[i] = INF;
  dp[0] = 0;
  
  for (int i=1; i<N; ++i) {
    for (int j=1; j<K+1; ++j) {
      if (i-j < 0) {
         break;
      }
      chkmin(dp[i], dp[i-j] + abs(input[i] - input[i-j]));
    }
  }
  cout << dp[N-1] << endl;
}

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

bool isPrime(int x){
  for(int i=2;i*i<=x;i++){
    if(x%i == 0)return false;
  }
  return true;
}

int main(){
  int n;
  while(cin >> n,n){
    int p = 0;
    for(int i=n+1;i<=2*n;i++){
      if(isPrime(i))p++;
    }
    cout << p << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define test int t; cin>>t;
#define MOD 998244353LL
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt() { ll x; cin>>x; return x; }

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS

    ll n = nxt();
    ll cnt = 0;
    bool ans = false;
    int prevX = -1, prevY = -1;
    for(int i = 0; i<n; i++){
        int x, y;
        cin>>x>>y;
        if(prevX == prevY && x == y){
            cnt++;
            if(cnt>=3){
                //cout<<x<<" "<<y<<endl;
                ans = true;
            }
            prevX = x, prevY = y;
        }
        else{
            cnt = 0;
            prevX = x, prevY = y;
            if(x == y) cnt++;
        }
    }

    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

using namespace std;
#define int long long

signed main(){
    int H,W;
    cin >> H >> W;
    
    char A[27];
    for(int i=0;i<26;i++){
        A[i] = 'A'+i;
    }
    string S[H+1][W+1];
    for(int i=1;i<=H;i++){
        for(int k=1;k<=W;k++){
            cin >> S[i][k];
            if(S[i][k]=="snuke") cout << A[k-1] << i << endl;
        }
    }
    return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 2e5 + 5;
const ll INF = 1e17;
const double eps = 1e-12 , PI = acos(-1);

ll n , m;

vl D;

map < ll , int > mp;

void solve(int cs){
    scanf("%lld %lld" , &n , &m);

    ll g = __gcd(n , m);

    for(ll i = 1 ; i*i <= g ; i ++){
            if(g%i == 0){
                    D.push_back(i);
                    if(g/i != i)D.push_back(g/i);
            }
    }

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

    int ans = 0;
    for(ll curr : D){
            if(mp[curr])continue;

            bool ok = 1;
            for(ll i = 2 ; i*i <= curr ; i ++){
                    if(curr % i == 0){
                            if(mp[i] == 1 || mp[curr/i] == 1){
                                    ok = 0;
                                    break;
                            }
                    }
            }

            if(ok){
                    ans ++;
                    mp[curr] = 1;
                    for(ll i = 2 ; i*i <= curr ; i ++){
                        if(curr % i == 0){
                                mp[i] = mp[curr/i] = 1;
                        }
                    }

            }
    }

    printf("%d\n" , ans);
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;


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

Measured memory_bytes: 512
#include<stdio.h>
int A[1000000],n;
int search(int key){
	int left = 0;
	int right = n;
	int mid;
	while ( left < right ){
		mid = (left + right)/2;
		if(key==A[mid])return 1;
		if(key>A[mid])left = mid+1;
		else if(key,A[mid])right = mid;
	}
	return 0;
}

int main(){
	int i, q, k, sum = 0;
	
	scanf("%d",&n);
	for ( i = 0; i < n; i++ )
	{
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for ( i = 0; i < q;i++){
		scanf("%d",&k);
		if(search(k))sum++;
	}
	printf("%d\n",sum);
	
	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int m,k;
int g[31],p[31];
int e[31];
int y[1000000]={0};

int main(){
	scanf("%d %d",&m,&k);
	if(m==0&&k!=0){
		printf("-1\n");
		return 0;
	}
	if(m==1&&k!=0){
		printf("-1\n");
		return 0;
	}
	e[0]=1;
	for(int i=1;i<31;i++) e[i]=e[i-1]*2;
	for(int i=30;i>=0;i--){
		if(k>=e[i]){
			k-=e[i];
			g[i]=1;
			if(e[i]<1000000) y[e[i]]=1;
		}
		else g[i]=0;
	}
	bool pc=true;
	for(int i=30;i>=0;i--){
		if(g[i]==1&&e[i]>e[m]-1) pc=false;
	}
	if(!pc){
		printf("-1\n");
		return 0;
	}
	for(int i=0;i<=e[m]-1;i++){
		if(y[i]) printf("%d ",i);
	}
	for(int i=0;i<=e[m]-1;i++){
		if(!y[i]) printf("%d ",i);
	}
	for(int i=e[m]-1;i>=0;i--){
		if(y[i]) printf("%d ",i);
	}
	for(int i=e[m]-1;i>=0;i--){
		if(!y[i]) printf("%d ",i);
	}
	
	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int dx[] = {-2, -1, 0}, dy[]  = {-2, -1, 0};
	int h, w, n;
	cin >> h >> w >> n;
	map<pair<int ,int>, long long> mp;
	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				if(a + dx[j] >= 1 && a + dx[j] <= h - 2 && b + dy[k] >= 1 && b + dy[k] <= w - 2) {
					mp[make_pair(a + dx[j], b + dy[k])]++;
				}
			}
		}
	}                   		
						/*for(auto i : mp) {
							cerr << i.first.first << " " << i.first.second << " " << i.second << endl;
						}*/
	vector<long long> ans(10);
	long long nonz = 0;
	for(int i = 9; i > 0; i--) {
		for(auto j : mp) {
			if(j.second == i) {
				ans[i]++;
				nonz++;
			}
		}
	}
	ans[0] = 1LL * (h - 2) * 1LL * (w - 2) - nonz;
	for(int i = 0; i < 10; i++) {
		cout << ans[i] << '\n';
	}
	return 0;	
}


Measured memory_bytes: 56576
#include<iostream>
using namespace std;
int dp[100001]={0};
int frog1(int *arr,int n)
{
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    return dp[n];
}
int main()
{
    int n;
    cin>>n;
    int arr[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    int ans=frog1(arr,n);
    cout<<ans<<endl;
}


Measured memory_bytes: 4408
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){

    int n;

    cin >>n;

    int d[n];

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

    sort(d,d+n);

    if(d[n/2] == d[n/2-1]){
        cout << 0 <<endl;
    }
    else{
        cout << d[n/2] -d[n/2-1];
    }


}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var n, q int
var bits []int

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	sc.Scan()
	q, _ = strconv.Atoi(sc.Text())
	cs := make([]int, n)
	for i := range cs {
		sc.Scan()
		cs[i], _ = strconv.Atoi(sc.Text())
	}
	qs := make([][]int, q)
	for i := range qs {
		sc.Scan()
		l, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ := strconv.Atoi(sc.Text())
		qs[i] = []int{l, r, i, 0}
	}
	sort.Slice(qs, func(i, j int) bool {
		return qs[i][1] < qs[j][1]
	})

	lis := make([]int, n+1)
	for i := range lis {
		lis[i] = -1
	}

	bits = make([]int, n+1)

	pr := 1
	for i := range qs {
		l, r := qs[i][0], qs[i][1]
		for j := pr; j <= r; j++ {
			c := cs[j-1]
			add(j, 1)
			if lis[c] != -1 {
				add(lis[c], -1)
			}
			lis[c] = j
		}
		qs[i][3] = sumr(l, r)
		pr = r + 1
	}
	sort.Slice(qs, func(i, j int) bool {
		return qs[i][2] < qs[j][2]
	})
	for i := range qs {
		fmt.Println(qs[i][3])
	}
}

func add(a, w int) {
	for i := a; i <= n; i += i & -i {
		bits[i] += w
	}
}

func sumr(l, r int) int {
	return sum(r) - sum(l-1)
}

func sum(a int) int {
	var s int
	for i := a; i > 0; i -= i & -i {
		s += bits[i]
	}
	return s
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 53224
s = list(sorted(set(str(input()))))
if len(s) == 2:
    if (s[0] == "N" and s[1] == "S") or (s[0] == "E" and s[1] == "W"): 
        print("Yes")
    else:
        print("No")
if len(s) == 1 or len(s) == 3:
    print("No")
if len(s) == 4:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using ld = long double;                  //   | grep -v ' .* '  1300111 ~2^20.31
using vl = vector<ll>;                   //                    10300777 ~2^23.30
using vvl = vector<vl>;                  //                   100400999 ~2^26.58
using pll = pair<ll,ll>;                 //                  1300400999 ~2^30.28
using vpll = vector<pll>;                //                 10200500333 ~2^33.25
using vb = vector<bool>;                 //                100200400777 ~2^36.54
using vs = vector<string>;               //               1200300700111 ~2^40.13
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //              10200300500777 ~2^43.21
const ld eps = 1e-9;                     //             100200300400777 ~2^46.51
#define sz(c) ll((c).size())             //            1200300400600999 ~2^50.09
#define all(c) begin(c),end(c)           //           10200300400600111 ~2^53.18
#define mp make_pair                     //          100200300400600333 ~2^56.48
#define mt make_tuple                    //         1200300400500800999 ~2^60.06
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(0) cerr << "TR: " << (#X) << " = " << (X) << endl; })

bool test_substr(string &s, ll start, ll len, ll test) {
	if (start + len > sz(s) || test + len > sz(s)) {
		return false;
	}

	return s.compare(start, len, s, test, len) == 0;
}

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

	ll n; string s; cin >> n >> s;
	TR(s);
	
	ll best = 0;
	FOR(i,0,n) {
		//TR(i);
		bool best_improved = true;
		ll test_start = i+best+1;
		while (best_improved) {
			best_improved = false;
			FOR(j, test_start, n-best) {
				if (test_substr(s, i, best+1, j)) {
					best++;
					best_improved = true;
					TR(j);
					TR(best);
					test_start = max(j,i+best+1);
					break;
				}
			}
		}
	}

	TR(s);
	cout << best << "\n";

	return 0;
}


Measured memory_bytes: 256
N = int(input())
dams = list(map(int, input().split()))

mountains = [0]*N

sum_part_dams = 0
for i in range(1, N, 2):
    sum_part_dams += dams[i]

mountains[0] = sum(dams)-2*sum_part_dams

for i in range(1, N):
    mountains[i] = 2*dams[i-1]-mountains[i-1]

print(*mountains)

Measured memory_bytes: 14032
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int k;
    string s;
    cin >> s;
    cin >> k;
    set<string> st;
    int l = min((int)s.size(), 10);
    for (int i = 1; i <= l; i++) {
        for (int j = 0; j <= s.size() - i; j++) {
            st.insert(s.substr(j, i));
        }
    }
    int cnt = 0;
    for (auto x : st) {
        cnt++;
        if (cnt == k) {
            cout << x << endl;
            break;
        }
    }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
const long long mod=1e9+7;

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

    int N, M;
    cin >> N >> M;
    vector<int> flag(N+1, true);//flag->trueなら通れる、falseなら通れない
    rep(i, M){
        int a;
        cin >> a;
        flag[a] = false;
    }
    vector<ll> dp(N+1);
    dp[0] = 1;
    for (int now = 0; now < N; now++){//now->今いる位置
        for (int next = now + 1; next <= min(N, now + 2); next++){//next->nowの次、Nは超えないようにする
            if (flag[next]){//trueなら
                dp[next] += dp[now];//ここまでの回数を次に足す
                dp[next] %= mod;//先に割っておく
            }
        }
    }
    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		
		
		for(int i=n;i<=999;i++) {
			String s=String.valueOf(i);
			if(s.charAt(0)==s.charAt(1)&&s.charAt(1)==s.charAt(2)) {
				System.out.println(i);
				return;
			}
		}
	}
}

Measured memory_bytes: 23252
n,k=map(int,input().split())
mod=10**9+7
if n==k:
    print(1)
    for i in range(k-1):
        print(0)
    exit()

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
if n-k+1>=k:
    for i in range(1,k+1):
        print(((cmb(n-k+1,i)%mod)*(cmb(k-1,i-1)%mod))%mod)
else:
    for i in range(1,k+1):
        if n-k+1>=i:
            print(((cmb(n-k+1,i)%mod)*(cmb(k-1,i-1)%mod))%mod)
        else:
            print(0)


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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int main()
{
	Fastest
	
    string ch;
    
    cin >> ch;
    
    int len = ch.size(), mx = 0;
    
    for(int i = 0; i < len; i++)
    {
		if(ch[i] == 'A' || ch[i] == 'T'  || ch[i] == 'C'  || ch[i] == 'G' )
		{
			int coun = 1;
			int j;
			for(j = i+1; j < len; j++)
			{
				if(ch[j] == 'A' || ch[j] == 'T'  || ch[j] == 'C'  || ch[j] == 'G')
				{
					coun++;
				}
				else break;
			}
			mx = max(mx, coun);
			
			i = j;
		}
	}
	
	cout << mx << endl;
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	S := nextBytes()

	cr := make([]int, N+1)
	cr[N] = 0
	cg := make([]int, N+1)
	cg[N] = 0
	cb := make([]int, N+1)
	cb[N] = 0

	// i番目以降のRGBそれぞれの数を数えておく
	for i := N - 1; i >= 0; i-- {
		cr[i] = cr[i+1]
		cg[i] = cg[i+1]
		cb[i] = cb[i+1]

		if S[i] == 'R' {
			cr[i]++
		}
		if S[i] == 'G' {
			cg[i]++
		}
		if S[i] == 'B' {
			cb[i]++
		}
	}
	ans := 0

	for i := 0; i < N-2; i++ {
		for j := i + 1; j < N-1; j++ {
			if S[i] == S[j] {
				continue
			}
			k := j + 1    // j < kより
			kj := 2*j - i // j - i == k - jとなる点

			if S[i] != 'R' && S[j] != 'R' {
				ans += cr[k]
				if kj < N && S[kj] == 'R' {
					ans--
				}
			} else if S[i] != 'G' && S[j] != 'G' {
				ans += cg[k]
				if kj < N && S[kj] == 'G' {
					ans--
				}
			} else if S[i] != 'B' && S[j] != 'B' {
				ans += cb[k]
				if kj < N && S[kj] == 'B' {
					ans--
				}
			}
		}
	}
	fmt.Println(ans)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n, m, x;
	ll ans = 0;
	//float ans = 0;
	cin >> n >> m >> x;

	V c(n);
	ll a[15][15];
	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}

	ll cost;
	ans = INF;
	bool ok;
	V level(m, 0);
	rep(i, 1 << n) {
		cost = 0;
		level = V(m, 0);
		rep(j, n) {
			if ((i >> j & 1) == 1) {
				cost += c[j];
				rep(k, m) {
					level[k] += a[j][k];
				}
			}
		}
		ok = true;
		rep(i, m) {
			if (level[i] < x) {
				ok = false;
				break;
			}
		}
		if (ok) ans = min(ans, cost);
	}

	if (ans == INF) ans = -1;

	cout << ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed;
	//cout << setprecision(7);

	solve_abc_c();

	return 0;
}


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

using namespace std;
#define N 2001000
#define SIGMA 26
#define MOD 1000000007LL

long long v[N], w[N], inv[N];
///inv[i] * i = 1 (modulo MOD)
int r1, r2, c1, c2;
inline long long M (long long X){
    if (X < MOD)
        return X;
    return X % MOD;
}

long long S (int a, int b){
    long long ans = 0;
    long long curr, curr1, x, y;
    if (a > b)
        swap (a, b);
    for (int it = 0; it < a; ++it){
        curr = M((b + 1) * v[b + it + 2]);
        curr1 = M(v[b + 1] * v[it + 2]);
        curr = M(curr + MOD - curr1);
        curr1 = M(w[it + 2] * w[b + 1]);
        curr = M(curr * curr1);
        ans = M (ans + curr);
    }
    return ans;
}

int main()
{
    v[0] = 1LL; v[1] = 1LL;
    inv[1] = 1;
    w[0] = 1LL; w[1] = 1LL;
    for (int i = 2; i < N; ++i){
        v[i] = M(v[i - 1] * i);
        inv[i] = M(MOD - M((MOD / i) * inv[MOD % i]));
        w[i] = M(w[i - 1] * inv[i]);
    }
    cin >> r1 >> c1 >> r2 >> c2;
    long long X = S (r1 - 1, c1 - 1);
    long long Y = S (r2, c2);
    long long Z1 = S (r1 - 1, c2);
    long long Z2 = S (r2, c1 - 1);
    cout << (Y + X - Z1 - Z2 + MOD + MOD) % MOD;
    return 0;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
 
#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))
 
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()
 
 
int main() {
 
    string s;
    cin >> s;
 
    char prev = 'A'; 
    for(int i=0;i<4;i++){
        if(prev==s[i]){
            cout << "Bad" << endl;
            return 0;
        }
        prev = s[i];
    }
 
    cout<< "Good" << endl;
    return 0;
 
}

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

typedef long long ll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve(int tc) {
    int h, w, k;
    cin >> h >> w >> k;

    int tot = 0;
    vector<int> row(h, 0);
    vector<int> col(w, 0);
    vector<string> grid(h, "");
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == '#') {
                row[i] += 1;
                col[j] += 1;
                tot += 1;
            }
        }
    }

    int cnt = 0;
    for (int r = 0; r < (1 << h); ++r) {
        int rrem = 0;
        int b = 0;
        while (b < h) {
            if (r & (1 << b)) {
                rrem += row[b];
            }
            b += 1;
        }

        for (int c = 0; c < (1 << w); ++c) {
            int crem = 0;
            b = 0;
            while (b < w) {
                if (c & (1 << b)) {
                    for (int i = 0; i < h; ++i) {
                        if (grid[i][b] == '#') {
                            if ((r & (1 << i)) == 0) {
                                crem += 1;
                            }
                        }
                    }
                }
                b += 1;
            }

            if (tot - rrem - crem == k) {
                cnt += 1;
            }
        }
    }

    cout << cnt << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int tcs = 1;
    int tc = 1;
    while (tc <= tcs) solve(tc++);
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        sc.close();
        String res = "";
        if (k >= s.length()) {
            res += s;
        } else {
            for (int i = 0; i < k; i++) {
                res += s.charAt(i);
            }
            res += "...";
        }
        
        System.out.println(res);
    }
}

Measured memory_bytes: 39724
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll x, ll y) 
{ 
    ll res = 1;    
    x = x;  
  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1; 
        x = (x*x); 
    } 
    return res; 
} 

void solve() {
	ll n;
	cin >> n;
	
	ll k=n;
	ll count=0;
	while(n>0) {
		n=n/2;
		count++;
	}
	cout << power(2,count)-1 <<endl;
}

signed main() {
	boost;
	solve();
}

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

#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define int long long 
const int INF = 1e18;
struct edge{int to,cost;};
vector<edge> G[1010];
int score[1010],neg[1010];
int N,M;

void bellman_ford(int start){
    score[start] = 0;
    for(int i=1;i<=N;++i){
        for(int v=1;v<=N;++v){
            rep(j,G[v].size()){
                edge e = G[v][j];
                if(score[v] == INF) continue;
                if(score[e.to] > score[v] + e.cost){
                    neg[e.to] = true;
                    score[e.to] = score[v] + e.cost;
                }
                if(neg[v]) neg[e.to] = true;
            }
        }
    }
}


signed main(){
    cin>>N>>M;
    rep(i,N+1) score[i] = INF;
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        G[a].push_back({b,-c});
    }

    bellman_ford(1);
    int ans = -score[N];

    rep(i,N+2) neg[i] = false;
    bellman_ford(1);

    if(neg[N]) puts("inf");
    else put(ans);

}


Measured memory_bytes: 384
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var input = input.split(" ");
	var A = parseInt(input[0],10);
  	var B = parseInt(input[1],10);
  
  	var arr = [];
  
  	var a = A+B
  	arr.push(a);
  	a = A*B
  	arr.push(a);
  	a = A-B
  	arr.push(a);
  
  	console.log(Math.max(...arr));
 
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long n,i,t,s,p,a[200003];
  cin>>n;
  for(i=0;i<n;i++){
  cin>>a[i];
  }
  t=s=0;
    for(i=0;i<n;i++){
      if(t<=a[i]){
            s=t;
        t=a[i];
        p=i;
      }
      else if(s<=a[i]){
        s=a[i];
    }
    }
        for(i=0;i<n;i++){
          if(i==p) cout<<s<<endl;
          else cout<<t<<endl;
        }
}


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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            var main = new Program();
            main.solve();
        }

        void solve()
        {
            int[] times = Console.ReadLine().Split(' ').Select(val => int.Parse(val)).ToArray();
            int sum = 0;
            sum = Math.Min(times[3], times[1]) - Math.Max(times[0], times[2]);

            if (sum >= 0) Console.WriteLine(sum);
            else Console.WriteLine("0");
        }
    }

    struct Vector2
    {
        public Vector2(long x, long y)
        {
            this.x = x;
            this.y = y;
        }
        public long x;
        public long y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
void solve()
{

int n;
cin>>n;
string s;
cin>>s;
int ans=0;
for(int i=0;i<n;i++)
{
    if(s[i]=='R')
    {
        int p=0,q=0,r=0;
        for(int j=i+1;j<n;j++)
        {
            if((j-i)%2==1)
            {
                if(s[j]=='B')
                    p++;
                else if(s[j]=='G')
                    q++;
            }
            else
            {
               if(s[j]=='B')
                    p++;
                else if(s[j]=='G')
                    q++;
                if(s[j]=='B'&&(s[(i+j)/2]=='G'))
                    r++;
                else if(s[j]=='G'&&(s[(i+j)/2]=='B'))
                    r++;
            }
        }
        ans+=((p*q)-r);
    }
    else if(s[i]=='G')
    {
          int p=0,q=0,r=0;
        for(int j=i+1;j<n;j++)
        {
            if((j-i)%2==1)
            {
                if(s[j]=='R')
                    p++;
                else if(s[j]=='B')
                    q++;
            }
            else
            {
               if(s[j]=='R')
                    p++;
                else if(s[j]=='B')
                    q++;
                if(s[j]=='R'&&(s[(i+j)/2]=='B'))
                    r++;
                else if(s[j]=='B'&&(s[(i+j)/2]=='R'))
                    r++;
            }
        }
        ans+=((p*q)-r);
    }
    else if(s[i]=='B')
    {
          int p=0,q=0,r=0;
        for(int j=i+1;j<n;j++)
        {
            if((j-i)%2==1)
            {
                if(s[j]=='R')
                    p++;
                else if(s[j]=='G')
                    q++;
            }
            else
            {
               if(s[j]=='R')
                    p++;
                else if(s[j]=='G')
                    q++;
                if(s[j]=='R'&&(s[(i+j)/2]=='G'))
                    r++;
                else if(s[j]=='G'&&(s[(i+j)/2]=='R'))
                    r++;
            }
        }
        ans+=((p*q)-r);
    }
}
cout<<ans<<endl;
}




signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
  solve();
}
}





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

negcnt = 0
mina = 10 ** 10
suma = 0
for i in a:
  if i < 0:
    negcnt += 1
  if mina > abs(i):
    mina = abs(i)
  suma += abs(i)

if negcnt % 2 == 1:
  ans = suma - 2*mina
else:
  ans = suma

print(ans)

Measured memory_bytes: 64880
#include<stdio.h>
int main(){
int a,b,c,d,x[100]={0},i,ans=0;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  for(i=a;i<b;i++)x[i]++;
  for(i=c;i<d;i++)x[i]++;
  for(i=0;i<100;i++)if(x[i]==2)ans++;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> c(m);
	vector<int> dp(n+1);
	for (int i = 0; i < n+1; i++) {
		dp[i] = i;
	}
	for (int i = 0; i < m; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j <= n; j++) {
			if (j-c[i] >= 0) {
				dp[j] = min(dp[j], dp[j-c[i]]+1);
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1288
#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>

static const size_t n_max = 15;
static size_t ps[1 << n_max][n_max];

static size_t encode(size_t s, size_t ls) {
  return (s << n_max) | ls;
}

static void decode(size_t x, size_t &s, size_t &ls) {
  s = x >> n_max;
  ls = x & ((1 << n_max) - 1);
}

int main() {
  for (;;) {
    size_t n, m;
    scanf("%zu%zu", &n, &m);
    if (!n && !m)
      return 0;
    for (size_t x = 0; x < (1u << n); x++)
      for (size_t s = 0; s < n; s++)
        ps[x][s] = size_t(-1);
    std::vector<size_t> es[n_max], rs[n_max];
    for (size_t i = 0; i < m; i++) {
      size_t s, t;
      scanf("%zu%zu", &s, &t);
      es[s-1].push_back(t-1);
      es[t-1].push_back(s-1);
    }
    size_t ls = 0;
    for (size_t i = 0; i < n; i++) {
      size_t l;
      scanf("%zu", &l);
      ls |= l << i;
    }
    for (size_t i = 0; i < n; i++) {
      size_t k;
      scanf("%zu", &k);
      for (size_t j = 0; j < k; j++) {
        size_t r;
        scanf("%zu", &r);
        if (i != r - 1)
          rs[i].push_back(r - 1);
      }
      std::sort(rs[i].begin(), rs[i].end());
    }
    const size_t start = encode(0, ls), goal = encode(n-1, 1 << (n-1));
    std::queue<size_t> q;
    q.push(start);
    ps[ls][0] = size_t(-2);
    int c = 3;
    while (q.size()) {
      size_t x = q.front(), s, ls;
      decode(x, s, ls);
      q.pop();
      if (x == goal) {
        c = 1;
        break;
      }
      if (s == n - 1)
        c = 2;
      for (auto t : es[s])
        if ((ls & (1 << t)) && ps[ls][t] == size_t(-1)) {
          ps[ls][t] = x;
          q.push(encode(t, ls));
        }
      for (auto t : rs[s]) {
        auto ks = ls ^ (1 << t);
        if (ps[ks][s] == size_t(-1)) {
          ps[ks][s] = x;
          q.push(encode(s, ks));
        }
      }
    }
    switch (c) {
      case 1:
        {
          std::vector<std::pair<int, size_t>> steps;
          for (size_t x = goal; x != start;) {
            size_t s, ls;
            decode(x, s, ls);
            size_t y = ps[ls][s], t, ks;
            decode(y, t, ks);
            if (s != t)
              steps.push_back(std::make_pair(0, s));
            else
              for (size_t i = 0; i < n; i++)
                if ((ls & (1 << i)) != (ks & (1 << i))) {
                  steps.push_back(std::make_pair((ls & (1 << i)) ? 1 : -1, i));
                  break;
                }
            x = y;
          }
          std::reverse(steps.begin(), steps.end());
          printf("You can go home in %zu steps.\n", steps.size());
          for (auto &&p : steps)
            if (!p.first)
              printf("Move to room %zu.\n", p.second + 1);
            else if (p.first > 0)
              printf("Switch on room %zu.\n", p.second + 1);
            else
              printf("Switch off room %zu.\n", p.second + 1);
        }
        break;
      case 2:
        puts("You can not switch off all lights.");
        break;
      case 3:
        puts("Help me!");
        break;
    }
  }
}

Measured memory_bytes: 6536
#include <iostream>
using namespace std;
int main(void){
    
    int a, b;
    cin >> a >> b; 
    
   int x = (a + b);
   
   if(x % 2 == 0){
       cout << x / 2<< endl;
   }
   
   else{
       cout << (x + 1) / 2 << endl;
   }
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int a,b,c,d,e,f,ansall=1,anssugar=0;
  cin>>a>>b>>c>>d>>e>>f;
  int A=100*a,B=100*b;
  rep(i,f/A+1){
    rep(j,(f-A*i)/B+1){
      rep(k,(f-A*i-B*j)/c+1){
        rep(l,(f-A*i-B*j-c*k)/d+1){
          int water=a*i+b*j;
          int sugar=c*k+d*l;
          if(100*water+sugar<=f && sugar<=e*water 
             && 100*anssugar*water<=sugar*(ansall-anssugar)){
            anssugar=sugar;
            ansall=100*water+sugar;
          }
        }
      }
    }
  }
  cout<<ansall<<" "<<anssugar;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N, L = MAP()
S = [input() for _ in range(N)]

S.sort()
ans = str()

for x in S:
	ans += x

print(ans)


Measured memory_bytes: 5204
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll h, n; cin >> h >> n;
    
    ll a[n], b[n];
    rep(i, n){
        cin >> a[i] >> b[i];
    }

    ll total_b[h + 1];
    rep(h_temp, h + 1){
        total_b[h_temp] = 1e18;
    }

    reps(h_temp, 1, h + 1){
        rep(i, n){
            if(h_temp - a[i] <= 0){
                total_b[h_temp] = min(total_b[h_temp], b[i]);
            }
            else{
                total_b[h_temp] = min(total_b[h_temp], total_b[h_temp - a[i]] + b[i]);
            }
        }
    }

    // rep(h_temp, h + 1){
    //     cout << h_temp << ": " <<  total_b[h_temp] << endl;
    // }

    cout << total_b[h] << endl;

    return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N;
	std::cin >> N;
	std::vector<std::pair<double, double>> city(N);
	for (auto& p : city)
	{
		std::cin >> p.first >> p.second;
	}
	boost::sort(city);
	double sum = 0;
	double count = 0;
	do
	{
		++count;
		for (auto i : boost::irange(1, N))
		{
			double a, b, x, y;
			std::tie(a, b) = city[i - 1];
			std::tie(x, y) = city[i];
			sum += std::sqrt((x - a) * (x - a) + (y - b) * (y - b));
		}
	} while (boost::next_permutation(city));
	std::cout << sum / count << std::endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n, a;
  cin >> n >> a;
  cout << n*n-a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
// template<class T> T gabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    i64 n;
    cin >> n;
    i64 m = n;
    vector<int> fs;
    for (i64 x = 2; x * x <= m; ++x) {
        if (m % x == 0) {
            fs.push_back(x);
            while (m % x == 0) {
                m /= x;
            }
        }
    }
    if (m > 1) fs.push_back(m);
    int k = fs.size();
    int ans = 0;
    for (int s = 0; s < (1 << k); ++s) {
        int cnt = 0, d = 1;
        for (int i = 0; i < k; ++i) {
            if ((s >> i) & 1) {
                d *= fs[i];
                ++cnt;
            }
        }
        int sign = cnt & 1 ? -1 : 1;
        ans += sign * (n / d);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3164
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 300


int main() {
	char b[N];
	vector<long long>a;
	long long d[N];
	long long p[N];
	long long n, k, t;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &t);
	p[0] = 1;
	f(i, 62)p[i + 1] = p[i] * 2;
	f(tt, t) {
		f(i, N) {
			b[i] = 0;
			d[i] = 0;
		}
		a.clear();
		v = true;
		scanf("%lld", &n);
		f(i, n) {
			scanf("%lld", &x);
			a.push_back(x);
		}
		scanf("%s", b);
		for(long long i=n-1;i>=0;i--){
			x = a[i];
			f(j, 62) {
				if ((p[j] & x) == p[j]) {
					if (d[j] == 0) {
						if (b[i] == '1')v = false;
						else d[j] = x;
						break;
					}
					else x = x ^ d[j];
				}
				if (x == 0)break;
			}
			if (!v)break;
		}
		if (v)printf("0\n");
		else printf("1\n");
	}

	return 0;
}

Measured memory_bytes: 3108
#include<iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	bool ans=false;
	for(int i=1;i<=n;i++)
	{
		long long a;
		cin >> a;
		if(a%2==1)
			ans=true;
	}
	cout << ((ans==true) ? "first" : "second") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

class UnionFind {
    int n;
    vector<int> uni;
    int forest_size;
public:
    explicit UnionFind(int n) : n(n), uni(static_cast<u32>(n), -1), forest_size(n) {};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        forest_size--;
        return true;
    }
    int size(){ return forest_size; }
    int size(int i){ return -uni[root(i)]; }
    bool same(int a, int b) { return root(a) == root(b); }
};

void solve(int h, int w){
    int sy, sx, gy, gx;
    cin >> sx >> sy >> gx >> gy;
    vector<vector<int>> grid(h+2, vector<int>(w+2, 0));
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int c, d, x, y;
        cin >> c >> d >> x >> y;
        if(d){
            for (int j = 0; j < 4; ++j) {
                for (int k = 0; k < 2; ++k) {
                    grid[y+j][x+k] = c;
                }
            }
        }else {
            for (int j = 0; j < 2; ++j) {
                for (int k = 0; k < 4; ++k) {
                    grid[y+j][x+k] = c;
                }
            }
        }
    }
    UnionFind uf((h+2)*(w+2));
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if(grid[i][j] == grid[i+1][j]){
                uf.unite(i*(w+2)+j, (i+1)*(w+2)+j);
            }
            if(grid[i][j] == grid[i][j+1]){
                uf.unite(i*(w+2)+j, i*(w+2)+j+1);
            }
        }
    }
    puts(uf.same(sy*(w+2)+sx, gy*(w+2)+gx) ? "OK" : "NG");
}

int main() {
    int w, h;
    while(cin >> w >> h, w){
        solve(h, w);
    }
    return 0;
}


Measured memory_bytes: 3192
# -*- coding: utf-8 -*-
import sys 
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
#Union Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return find(par[x])

def union(x,y):
    x = find(x)
    y = find(y)
    if x==y:
        return False
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

def same(x,y):
    return find(x) == find(y)        
    
N,M = map(int,readline().split())
par = [-1]*(N+1)
for i in range(M):
    x,y,z = map(int,readline().split())
    union(x,y)
print(sum(1 for i in par[1:] if i < 0))

Measured memory_bytes: 12008
#include<iostream>
using namespace std;
long long gcd(long long x, long long y) {
    if (x == 0) return y;
    if (y == 0) return x;
    return gcd(y, x%y);
}

int main(void){
  long long a,b;
  cin >> a >> b;
  
  cout << a * b / gcd(a,b) << endl;
  
  return 0;
}


Measured memory_bytes: 256