akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N;
    cin >> N;
    // N が奇数の時
    if(N % 2 == 1) cout << 0 << endl;
    // N が偶数の時
    else
    {
        ll ans = 0;
        ll dif = 10;
        while(N>=dif){
            ans+=(N/dif);
            dif*=5;
        }
        cout << ans << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio	
	int n;
	cin >> n;
	int a[n];
	int cnt = 0;
	std::vector<int> v;
	for(int i=0; i<n; i++){
		cin >> a[i];
		v.push_back(a[i]);
	}
	sort(a,a+n);
	for(int i=0; i<n; i++){
		if(v[i] != a[i])cnt++;
	}
	if(cnt>2){
		cout << "NO\n";
	}else{
		cout << "YES\n";
	}
	return 0;
}








Measured memory_bytes: 3652
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


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

	int p = 0;
	int m = 0;

	for(int i = 0; i < s.size(); i++){
		if(s[i] == '+')p++;
		if(s[i] == '-')m++;
	}

	cout << p - m << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner stdIn;
	
	public static void main(String[] args) {
		stdIn = new Scanner(System.in);
		
		String s = stdIn.nextLine();
		int n = 1;
		
		if(s.indexOf("N") >= 0) {
			if(s.indexOf("S") < 0){
				n = -1;
				System.out.println("No");
            }
        }
      if(s.indexOf("S") >= 0) {
			if(s.indexOf("N") < 0){
				n = -1;
				System.out.println("No");
            }
		}
		
		if(s.indexOf("E") >= 0) {
			if(s.indexOf("W") < 0 && n == 1){
				n = -1;
				System.out.println("No");
            }
		}
      if(s.indexOf("W") >= 0) {
			if(s.indexOf("E") < 0 && n == 1){
				n = -1;
				System.out.println("No");
            }
		}
		
		if(n == 1)
			System.out.println("Yes");
	}
}


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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int x;
  cin>>x;
  if(x>=400 && x<=599)
    cout<<8<<"\n";
  else if(x>=600 && x<=799)
    cout<<7<<"\n";
  else if(x>=800 && x<=999)
    cout<<6<<"\n";
  else if(x>=1000 && x<=1199)
    cout<<5<<"\n";
  else if(x>=1200 && x<=1399)
    cout<<4<<"\n";
  else if(x>=1400 && x<=1599)
    cout<<3<<"\n";
  else if(x>=1600 && x<=1799)
    cout<<2<<"\n";
  else
    cout<<1<<"\n";
}
  

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int red,green,blue;
int main()
{
	
	int n;
	cin >> red>> green >> blue;
	cin >> n;
	int k=0;
	bool flag=0;
	while(blue<=green){
		k++;
		blue*=2;
	}
	while(red>=green){
		k++;
		green*=2;
	}
	//cout << red << green << blue << endl;
	while(blue<=green){
		k++;
		blue*=2;		
	}//cout << red << green << blue << endl;cout << k << endl;
	if(k<=n)
		cout << "Yes\n";
	else cout <<"No\n";
	return 0;
} 

Measured memory_bytes: 3576
#include<stdio.h>

int main()
{
int a,b;
scanf("%d%d",&a,&b);
int s,d,m;
if(a==0&&b==0){
printf("0\n");
}
else{
s=a+b;
d=a-b;
m=a*b;
 if(s>=d&&s>m){
printf("%d\n",s);
}
else if(d>s&&d>m){
printf("%d\n",d);
}
else if(m>s&&m>d){
printf("%d\n",m);
}
}

return 0;

}


Measured memory_bytes: 128
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll p[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, c = 0;
    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> p[i];
    for (ll i = 1; i + 1 < n; i++)
    {
        vector<ll> v(p + i - 1, p + i + 2);
        sort(v.begin(), v.end());
        c += (p[i] == v[1]);
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int N, K;
    bool use_num[10];
    int num[6] = {0}, result[6] = {0};
    int digit = 0;

    int ans;

    cin >> N >> K;

    for(int i=0; i<10; i++)
        use_num[i] = true;

    for(int i=0; i<K; i++){
        int x;
        cin >> x;
        use_num[x] = false;
    }

    if(N == 0)
        digit = 1;

    while(N > 0){
        int n = N%10;
        num[digit] = n;
        digit++;

        N/=10;
    }

    for(int i=0; i<digit; i++){
        int n = num[i];

        if(use_num[n] == false){
            if(i > 0){
                result[i-1] = 0;
                int j=0;
                for(; j<10; j++){
                    if(use_num[j] != false)
                        break;
                }
                result[i-1] = j;
            }

            while(n < 10 && use_num[n] == false){
                n++;
            }
            if(n >= 10){
                n=0;
                for(; n<10; n++){
                    if(use_num[n] != false)
                        break;
                }
                
                result[i+1] = num[i+1] = num[i+1] + 1;
            }
        }
        result[i] = n;
    }
    if(result[digit] != 0 && use_num[result[digit]] == false){
        int n=result[digit];
        for(; n<10; n++){
            if(use_num[n] != false)
                break;
        }
        result[digit] = n;
    }

    ans = 0;
    for(int i=5; i>=0; i--){
        ans = ans * 10 + result[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split(' '))

max_sugar = 0
max_water = 100*A
max_conc = 0.0
A_limit = F // (100*A)
for i in range(A_limit + 1):
    B_limit = (F-100*A*i) // (100*B)
    for j in range(B_limit + 1):
        if i == 0 and j == 0:
            continue
        sugar_limit = min(E * (A*i+B*j), F-100*(A*i+B*j))

        sugar_ = 0
        for c in range(sugar_limit//C + 1):
            d = (sugar_limit-c*C)//D
            temp_sugar = c*C + d*D
            sugar_ = max(sugar_, temp_sugar)
        temp_conc = sugar_/(sugar_+100*(A*i+B*j))
        if temp_conc > max_conc:
            max_conc = temp_conc
            max_water = 100*(A*i + B*j)
            max_sugar = sugar_
print('{0} {1}'.format(max_water+max_sugar, max_sugar))


Measured memory_bytes: 3064
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,len(p)-1):
  if p[i-1]<p[i]<p[i+1]\
  	or p[i-1]>p[i]>p[i+1]:
      count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>

#include <stdio.h>

using namespace std;

int main() {
	char a[5];
	char b[5];
	int cnt = 0;
	cin>>a;
	cin>>b;
	for (int i = 0; i < 3; i++) {
		if (a[i] == b[i]) cnt++;
	}
	printf("%d", cnt);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int a[] = new int[n];
		long ans = 0;
		for(int i=0;i<n;i++) {
			a[i] = scan.nextInt();
		}
		
		Arrays.sort(a);
		
		ans += a[a.length-1];
		
		int oppai = a.length-2;
		
		boolean second = false;
		for(int i=a.length-2;i >= 1;i--) {
			ans += a[oppai];
			
			if(second == true) {
				second = false;
				oppai -= 1;
			}else {
				second = true;
			}
		}
		
		System.out.println(ans);
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 

Measured memory_bytes: 59544
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,m; ll x,y,dx,dy,st[1005][1005]; char ar[1005][1005];
bool valid(ll i,ll j){
	if(i>=0&&j>=0&&i<n&&j<m) return true;
	else return false;
}
ll cx[4]={0,0,1,-1};
ll cy[4]={1,-1,0,0};
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,l;
	cin>>n>>m;
	cin>>x>>y;
	x--; y--;
	cin>>dx>>dy;
	dx--; dy--;
	for(i=0;i<n;i++){
		cin>>ar[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			st[i][j]=1e18;
		}
	}
	
	set< pair<ll, pair<ll,ll> >> pq;
	pq.insert({0,{x,y}}); st[x][y]=0;
	while(pq.size()>0){
		pair<ll, pair<ll,ll> > p=(*pq.begin());
		pq.erase(pq.begin());
		for(i=0;i<4;i++){
			if(valid(p.sc.fs+cx[i],p.sc.sc+cy[i])&&ar[p.sc.fs+cx[i]][p.sc.sc+cy[i]]=='.'&&st[p.sc.fs+cx[i]][p.sc.sc+cy[i]]>st[p.sc.fs][p.sc.sc]){
				st[p.sc.fs+cx[i]][p.sc.sc+cy[i]]=st[p.sc.fs][p.sc.sc];
				pq.insert({st[p.sc.fs+cx[i]][p.sc.sc+cy[i]],{p.sc.fs+cx[i],p.sc.sc+cy[i]}});
			}
		}
		for(i=p.sc.fs-2;i<=p.sc.fs+2;i++){
			for(j=p.sc.sc-2;j<=p.sc.sc+2;j++){
				if(valid(i,j)&&ar[i][j]=='.'&&st[i][j]>p.fs+1){
					st[i][j]=p.fs+1;
					pq.insert({st[i][j],{i,j}});
				}
			}
		}
	}
	if(st[dx][dy]==1e18) cout<<"-1"<<endl;
	else cout<<st[dx][dy]<<endl;
	return 0;	
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define SZ(v) (int)v.size()
#define endl "\n"
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 1e9;
const LL INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

void solve() {
  int k, a, b;
  cin >> k >> a >> b;
  if (b/k - (a - 1)/k) cout << "OK" << endl;
  else cout << "NG" << endl;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif
  int t = 1;
  for (int tc = 1; tc <= t; tc++) solve();
  return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,K,C;
string S;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> K >> C >> S;
}

int solve(){
    vector<int> dpL(N,0),dpR(N,0);
    int cnt=1;
    int last=-1e6;
    for (int i = 0; i < N; i++)
    {
        if(S[i]=='x') continue;
        if(last+C < i) {
            dpL[i] = cnt;
            last=i;
            cnt++;
        }
        if(cnt>K) break;
    }
    last = 1e6;
    cnt =K;
    for (int i = N-1; i >= 0; i--)
    {
        if(S[i]=='x') continue;
        if(last-C > i) {
            dpR[i] = cnt;
            last=i;
            cnt--;
        }
        if(cnt==0) break;
    }
    DBG(dpL)
    DBG(dpR)
    vector<int> ans;
    for (int i = 0; i < N; i++)
    {
        if(dpL[i]==dpR[i] && dpL[i]!=0) ans.push_back(i);
    }
    for(auto a:ans) cout << (a+1) << endl;

    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 4236
S = input()
ans = 0
a = []
up = True
count = 0
for i in S:
    if up:
        if i == '>':
            a.append(count)
            count = 1
            up = False
        else:
            count += 1
    else:
        if i == '<':
            a.append(count)
            count = 1
            up = True
        else:
            count += 1
a.append(count)
if len(a)%2 == 1:
    a.append(0)
for i in range(0,len(a),2):
    u,d = max(a[i],a[i+1]), min(a[i],a[i+1])-1
    ans += u*(u+1)//2 + d*(d+1)//2
print(ans)
    

Measured memory_bytes: 6300
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<ll> v(4);
    v.at(0) = a*c;
    v.at(1) = a*d;
    v.at(2)= b*c;
    v.at(3)= b*d;
    ll ans = v[0];
    for(int i=1;i<4;i++){
        ans = max(ans,v[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int n;
	Polygon pol;
	Polygon pols[];
	Scanner sc;
	
	void run() {
		sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			if( n == 0 ) break;
			pols = new Polygon[n];
			pol = new Polygon(sc.nextInt());
			for(int i=0;i<n;i++) {
				pols[i] = new Polygon(sc.nextInt());
			}
			
			for(int i=0;i<n;i++) {
				if( pols[i].isSame(pol) ) System.out.println(i+1);
			}
			System.out.println("+++++");
			
		}
	}
	
	class Polygon {
		P[] lines;
		int m;
		Polygon (int m) {
			this.m = m;
			lines = new P[m];
			for(int i=0;i<m;i++) {
				lines[i] = new P(sc.nextInt(), sc.nextInt());
			}
		}
		
		int[][][] mat = { 
				{ {1,0},
				  {0,1}},
				{ {0,-1},
				  {1,0}},
				{ {-1,0},
				  {0,-1}},
				{ {0,1},
				  {-1,0}}
		};
		
		boolean isSame(Polygon pol) {
			if( m != pol.m ) return false;
			for(int i=0;i<4;i++) {
				boolean flg = true;
				for(int j=1;j<m;j++ ) {
//					debug( lines[j].sub(lines[0]).mult(mat[i]).x, lines[j].sub(lines[0]).mult(mat[i]).y );
//					debug( pol.lines[j].sub(pol.lines[0]).x, pol.lines[j].sub(pol.lines[0]).y );
					if( !lines[j].sub(lines[0]).mult(mat[i]).isEquals(pol.lines[j].sub(pol.lines[0])) ) {
						flg = false;
						break;
					}
				}
//				debug("a");
				if(flg) return true;
			}
			for(int i=0;i<4;i++) {
				boolean flg = true;
				for(int j=m-2;j>=0;j-- ) {
//					debug( lines[j].sub(lines[m-1]).mult(mat[i]).x, lines[j].sub(lines[m-1]).mult(mat[i]).y );
//					debug( pol.lines[j].sub(pol.lines[m-1]).x, pol.lines[m-j-1].sub(pol.lines[0]).y );
					if( !lines[j].sub(lines[m-1]).mult(mat[i]).isEquals(pol.lines[m-j-1].sub(pol.lines[0])) ) {
						flg = false;
						break;
					}
				}
//				debug("a");
				if(flg) return true;
			}
//			debug("aa");
			return false;
		}
	}
	
	class P {
		int x, y;
		P(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
		P sub(P p) {
			return new P(x-p.x, y-p.y);
		}
		
		P mult(int[][] a) {
			int s = a[0][0] * x + a[0][1] * y;
			int t = a[1][0] * x + a[1][1] * y;
			return new P(s, t);
		}
		
		boolean isEquals(P p) {
			return p.x == x && p.y == y;
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int rev[n];
    for(int i=0;i<n;i++)
    {
        rev[a[i]-1]=i+1;
    }
    for(int i=0;i<n;i++)
    {
        cout<<rev[i]<<" ";
    }
}

Measured memory_bytes: 4368
#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
using namespace std;
#define int long long


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


    int n,k; cin >> n >> k;
    int ans = 0;

    if(k == 0){
        cout << n * n << endl;
        return 0;
    }

    for(int b = k+1;b < n+1;b ++){
        int a = max(k,(int)1);
        int pow = 1;
        while(a <= n){
            ans += min(b * pow, n+1) - a;
//            cout << a << " " << b << endl;
//            cout << ans << endl;

            a += b;
            pow ++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import math
 
N = int(input())
 
if math.floor(math.log(N, 2)) == math.log(N, 2):
    print("No")
    exit()
else:
    print("Yes")
 
i = 1
print(N+1, N+2)
for i in range(1, N, 2):
    if i+2 <= N:
        print(1, i+1)
        print(i+1, i+2)
        print(1, i+2+N)
        print(i+2+N, i+1+N)
    else:
        print(i-1, i+1)
        tmp = (i+1) ^ (i-1) 
        print(N+tmp+1, i+1+N)

Measured memory_bytes: 5464
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int N,A,B; cin>>N>>A>>B;
    cout<<min(N*A, B)<<endl;
    return 0;
}

Measured memory_bytes: 256
class Dice:

    def __init__(self, faces):
        self.faces = tuple(faces)

    def roll_north(self):
        self.faces = (self.faces[1], self.faces[5], self.faces[2],
                      self.faces[3], self.faces[0], self.faces[4])

    def roll_south(self):
        self.faces = (self.faces[4], self.faces[0], self.faces[2],
                      self.faces[3], self.faces[5], self.faces[1])

    def roll_west(self):
        self.faces = (self.faces[2], self.faces[1], self.faces[5],
                      self.faces[0], self.faces[4], self.faces[3])

    def roll_east(self):
        self.faces = (self.faces[3], self.faces[1], self.faces[0],
                      self.faces[5], self.faces[4], self.faces[2])

    def number(self, face_id):
        return self.faces[face_id - 1]


dice = Dice(list(map(int, input().split())))
commands = input()

for c in commands:
    if c == "N":
        dice.roll_north()
    elif c == "S":
        dice.roll_south()
    elif c == "W":
        dice.roll_west()
    elif c == "E":
        dice.roll_east()
print(dice.number(1))

Measured memory_bytes: 6752
#include<iostream>
#include<vector>
#include<set>
#include<string>

using namespace std;

int main(){
  int64_t n;
  cin >> n;
  string s;
  cin >> s;
  int64_t r_count = count(s.begin(), s.end(), 'R');
  int64_t g_count = count(s.begin(), s.end(), 'G');
  int64_t b_count = count(s.begin(), s.end(), 'B');
  int duplicate = 0;
  for(int64_t i = 0; i < n; ++i){
    for(int64_t j = 1; i+j+j <= n-1; ++j){
      set<char> colors;
      if(i+j+j >= n)continue;
      colors.insert(s[i]);
      colors.insert(s[i+j]);
      colors.insert(s[i+j+j]);
      if(colors.size() == 3)duplicate++;
    }
  }
  cout << r_count*g_count*b_count - duplicate << endl;

  return 0;
}



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

int main(){
    
    int N;
    cin >> N;
    int P;
    int cont = 0;
    int index = 1;
    for(int i = 0; i < N;i++){
        
        cin >> P;
        if(P==index){
            index++;
        }else{
            cont++;
        }
        
    }
    if(index == 1)cout << -1 <<endl;
    else cout << cont <<endl;
    
}
    
    



Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

long long kth_lunlun_number(int k) {
  if (k <= 9) {
    return k;
  }

  queue<long long> q;
  for (int i = 1; i <= 9; i++) {
    q.push(i);
  }

  for (int i = 0; i < k - 1; i++) {
    long long n = q.front();
    q.pop();

    if (n % 10 != 0) {
      q.push(n * 10 + n % 10 - 1);
    }

    q.push(n * 10 + n % 10);

    if (n % 10 != 9) {
      q.push(n * 10 + n % 10 + 1);
    }
  }

  return q.front();
}

int main(int argc, const char *argv[])
{
  int k;
  cin >> k;
  cout << kth_lunlun_number(k);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	if (S == "Sunny") cout << "Cloudy";
	else if (S == "Cloudy") cout << "Rainy";
	else if (S == "Rainy") cout << "Sunny";

	return 0;
}


Measured memory_bytes: 3540
class segtree:
  #セグメント木
  def __init__(s, v, op, e):
    s._n = len(v)
    s.log = s.ceil_pow2(s._n)
    s.size = 1 << s.log
    s.d = [e()] * (2 * s.size)
    s.e = e
    s.op = op
    for i in range(s._n): s.d[s.size + i] = v[i]
    for i in range(s.size - 1, 0, -1): s.update(i)
  
  # 1点更新
  def set(s, p, x):
    p += s.size
    s.d[p] = x
    for i in range(1, s.log + 1): s.update(p >> i)
 
  # 1点取得
  def get(s, p):
    return s.d[p + s.size]
 
  # 区間演算
  def prod(s, l, r):
    sml, smr = s.e(), s.e()
    l += s.size
    r += s.size
    while (l < r):
      if l & 1: 
        sml = s.op(sml, s.d[l])
        l += 1
      if r & 1:
        r -= 1
        smr = s.op(s.d[r], smr)
      l >>= 1
      r >>= 1
    return s.op(sml, smr)
 
  # 全体演算
  def all_prod(s): return s.d[1]
 
  # L固定時の最長区間のR
  def max_right(s, l, g):
    if l == s._n: return s._n
    l += s.size
    sm = s.e()
    while True:
      while (l % 2 == 0): l >>= 1
      if not g(s.op(sm, s.d[l])):
        while l < s.size:
          l = 2 * l
          if g(s.op(sm, s.d[l])):
            sm = s.op(sm, s.d[l])
            l += 1
        return l - s.size
      sm = s.op(sm, s.d[l])
      l += 1
      if (l & -l) == l: break
    return s._n
 
  # R固定時の最長区間のL
  def min_left(s, r, g):
    if r == 0: return 0
    r += s.size
    sm = s.e()
    while True:
      r -= 1
      while r > 1 and (r % 2): r >>= 1
      if not g(s.op(s.d[r], sm)):
        while r < s.size:
          r = 2 * r + 1
          if g(s.op(s.d[r], sm)):
            sm = s.op(s.d[r], sm)
            r -= 1
        return r + 1 - s.size
      sm = s.op(s.d[r], sm)
      if (r & - r) == r: break
    return 0
 
  def update(s, k): s.d[k] = s.op(s.d[2 * k], s.d[2 * k + 1])
  def ceil_pow2(s, n):
    x = 0
    while (1 << x) < n: x += 1
    return x
 
import sys
    
def e():
  return 0
 
def op(s, t):
  return max(s, t)
 
N, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
Query = [list(map(int, input().split())) for _ in range(Q)]

seg = segtree(A, op, e)

for q in Query:
  if q[0] == 1:
    _, x, v = q
    seg.set(x - 1 , v)
  elif q[0] == 2:
    _, l, r = q
    print(seg.prod(l - 1, r))
  elif q[0] == 3:
    _, x, v = q
    def g(n):
      return n < v
    print(seg.max_right(x - 1, g) + 1)

Measured memory_bytes: 130152
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

const long long N = 2e5 + 10;
const long long INF = 2e18;
long long n;
long long k, a[N], L, R;

int main() 
{
	cin >> n >> k;
	for (long long i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	L = -INF;
	R = INF;
	while (L + 1 != R) {
		long long Mid = (L + R) / 2;
		long long cnt = 0;
		for (long long i = 0; i < n; i++) {
			if (a[i] < 0) {
				long long l, r;
				l = i;
				r = n;
				while (l + 1 != r) {
					long long mid = (l + r) / 2;
					if (a[i] * a[mid] <= Mid) {
						r = mid;
					}
					else {
						l = mid;
					}
				}
				cnt += n - r;
			}
			else {
				long long l, r;
				l = i;
				r = n;
				while (l + 1 != r) {
					long long mid = (l + r) / 2;
					if (a[i] * a[mid] <= Mid) {
						l = mid;
					}
					else {
						r = mid;
					}
				}
				cnt += l - i;
			}
		}
		if (cnt < k)L = Mid;
		else R = Mid;
	}
	cout << R << endl;
}

Measured memory_bytes: 1792
N, T = map(int, input().split())
c = [0] * N
t = [0] * N
for i in range(N):
    c[i], t[i] = map(int, input().split())

z = zip(c, t)
z = sorted(z)
c, t = zip(*z)

for i in range(N):
    if t[i] <= T:
        print(c[i])
        exit()
print('TLE')


Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
long long s;
int main()
{
	cin>>s;
	long l=sqrt(s);
	while(l*l<s)
	  l++;
	cout<<"0 0 "<<l<<" 1 "<<l*l-s<<" "<<l<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
	import java.lang.Math;
    public class Main 
	{
		public static void main(String args[])
		{
			Scanner scan = new Scanner(System.in);
			char a = scan.next().charAt(0);
			String next = String.valueOf( (char) (a + 1));
			System.out.println(next);
		}
    }

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, k, in;
	vi v;
	cin >> n >> k;
	rep(i, n) {
		cin >> in;
		v.push_back(in);
	}
	sort(all(v), greater<int>());
	int sum = 0;
	rep(i, k) {
		sum+=v[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int digit_sum(int n){
	int sum=0;
	while(n!=0){
		sum+=n%10;
		n/=10;
	}
	return sum;
}
int main()
{
	int n;
	cin >> n;

	int min=digit_sum(1)+digit_sum(n-1);

	for(int i=1; i<n/2+1; i++){
		if(digit_sum(i)+digit_sum(n-i) < min){
			min = digit_sum(i)+digit_sum(n-i);
		}
	}

	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, k;
ll s[200100];

int main() {
	cin >> n >> k;
	rep(i, n) {
		int num;
		cin >> num;
		s[num]++;
	}
	sort(s, s + n);
	reverse(s, s + n);
	int ans = n;
	rep(i, k)ans -= s[i];
	cout << ans << endl;
}

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

int main(){
  int N,T,A,X;
  cin >> N >> T >> A;
  int ans =0;
  int cc = 1<<30;
  for(int i=1;i<=N;++i){
    cin >> X;
    int d = (T*1000-X*6)-A*1000;
    if(d<0) d= -d;
    if(cc>d) cc =d,ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    double r;
    cin>>r;
    cout<<2*PI*r<<endl;


}


Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <deque>
#include <queue>

using namespace std;

template<typename T>
using vec = vector<T>;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vec<int> adj[n] = {};
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].emplace_back(v);
    }

    int s, t;
    cin >> s >> t;
    s--, t--;
    
    queue<pair<int, int> > q;
    bool seen[n][3] = {};
    int d[n][3] = {};

    q.push({s, 0});
    seen[s][0] = true;
    while (!q.empty()) {
        const int v = q.front().first, x = q.front().second;
        const int y = (x + 1) % 3;
        q.pop();
        for (int u : adj[v]) {
            if (!seen[u][y]) {
                seen[u][y] = true;
                q.push({u, y});
                d[u][y] = d[v][x] + (x == 2);
            }
        }
    }

    if (!seen[t][0]) {
        cout << "-1\n";
        return 0;
    }

    cout << d[t][0] << '\n';
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1e18 //10^12:∞

int main()
{
  ll n,ans=0;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {cin >> a[i];}
  int i;
  for(i=1; i<n; i++)
  {
    if(a[i] < a[i-1]){ans += a[i-1]-a[i]; a[i] = a[i-1];}
  }
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
using  unll = unsigned long long;

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

Measured memory_bytes: 256
from itertools import combinations
N, K, *L = map(int, open(0).read().split())
L = [(x,y) for x,y in zip(*[iter(L)]*2)]
ans = float('inf')
for m in combinations(L,2):
  for n in combinations(L,2):
    mx = min(m,key=lambda x:x[0])[0]
    Mx = max(m,key=lambda x:x[0])[0]
    my = min(n,key=lambda x:x[1])[1]
    My = max(n,key=lambda x:x[1])[1]
    cnt = 0
    for x,y in L:
      if mx<=x<=Mx and my<=y<=My:
        cnt += 1
    if cnt>=K:
      ans = min(ans, (Mx-mx)*(My-my))
print(ans)


Measured memory_bytes: 51772
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    h, w = map(int, input().split())
    n = int(input())
    a = list(map(int, input().split()))
    g = []
    for i, x in enumerate(a):
        g += [i+1]*x
    import numpy as np
    g = np.array(g, dtype=int).reshape((h,w))
    for i in range(h):
        if i%2 == 1:
            g[i,:] = g[i, ::-1]
        print(' '.join(map(str, g[i])))

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 27548
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

long long map[2][100];
void init(){
    for(int i = 0; i < 100; i++){
        map[0][i] = 0;
        map[1][i] = 0;
    }
}
int main() {
    int N;
    cin >> N;
    string s1;
    string s2;
    cin >> s1 >> s2;
    int i = 0;
    long long count = 0;
    int prev = -1;
    long long MOD = 1000000007;
    while(i < N){
        if(s1[i] == s2[i]){
            //盾ドミノ
            if(i == 0){
                count = 3;
            }else{
                if(prev == 0){
                    count = (count * 2) % MOD;
                }else{
                    count = count;
                }
            }
            prev = 0;
            i+= 1;
        }else{
            //横ドミノ
            if(i == 0){
                count = 6;
            }else{
                if(prev == 0){
                    count = (count * 2) % MOD;
                }else{
                    count = (count * 3) % MOD;
                }
            }
            prev = 1;
            i += 2;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> c(10, vector<int>(10));
  rep(i, 10) {
    rep(j, 10) {
      cin >> c[i][j];
    }
  }
  vector<vector<int>> a(h, vector<int>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> a[i][j];
    }
  }

  bool flag = true;
  while (flag) {
    flag = false;
    rep(i, 10) {
      rep(j, 10) {
        rep(k, 10) { 
          if (c[i][j] > c[i][k] + c[k][j]) {
            flag = true;
            c[i][j] = c[i][k] + c[k][j];
          }
        }
      }
    }
  }

  vector<int> cnt(10, 0);
  rep(i, h) {
    rep(j, w) {
      if (a[i][j] == -1) continue;
      cnt[a[i][j]]++;
    }
  }

  int ans = 0;
  rep(i, 10) ans += cnt[i] * c[i][1];
  cout << ans << endl;




  
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long Int;

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst) :
    src(src), dst(dst) { }
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool augment(const Graph& g, int u,
             vector<int>& matchTo, vector<bool>& visited) {
    if (u < 0) return true;
    FOR(e, g[u]) if (!visited[e->dst]) {
        visited[e->dst] = true;
        if (augment(g, matchTo[e->dst], matchTo, visited)) {
            matchTo[e->src] = e->dst;
            matchTo[e->dst] = e->src;
            return true;
        }
    }
    return false;
}
int bipartiteMatching(const Graph& g, int L, Edges& matching) {
    const int n = g.size();
    vector<int> matchTo(n, -1);
    int match = 0;
    REP(u, L) {
        vector<bool> visited(n);
        if (augment(g, u, matchTo, visited)) ++match;
    }
    REP(u, L) if (matchTo[u] >= 0) // make explicit matching
        matching.push_back( Edge(u, matchTo[u]) );
    return match;
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
    return a * b / gcd(a, b);
}

int main(){
    while (true) {
        int m, n, b[510], r[510];
        cin >> m >> n;
        if (!n) break;

        Graph g(m + n);

        REP(i, m){
            cin >> b[i];
        }
        REP(i, n){
            cin >> r[i];
            REP(j, m){
                if (gcd(b[j], r[i]) > 1) {
                    g[j].push_back(Edge(j, m + i));
                    g[m + i].push_back(Edge(m + i, j));
                }
            }
        }
        Edges match;
        cout << bipartiteMatching(g, m, match) << "\n";


    }
    return 0;
}

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

int wa(int x){
  int sum=0;
  for(int i=0;i<5;i++){
    sum=sum+x%10;
    x=x/10;
  }
  return sum;
}

int main() {
  int n,a,b,sum=0;
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++){
    if(wa(i)>=a&&wa(i)<=b){
      sum=sum+i;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,j=1;
string s,t,m;
int main()
{
    cin>>s>>t;
    m=s;
    m+=t;
    for (int i=0;i<m.size();i++)
    {
        j*=10;
    }
    for (int i=0;i<m.size();i++,j/=10)
    {
        a+=(((int (m[i]))-48)*(j));
    }
    a/=10;
    for (int i=1;i<=1000;i++)
    {
        if (i*i==a)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <algorithm>

using namespace std;

uint32_t gcd(const uint32_t &a, const uint32_t &b) {
  uint32_t x = a;
  uint32_t y = b;

  if (y > x) {
    swap(x, y);
  }

  while (y > 0) {
    uint32_t z = x;
    x = y;
    y = z % y;
  }

  return x;
}

int main(int argc, char *argv[]) {
  uint32_t a, b;

  cin >> a >> b;

  cout << gcd(a, b) << endl;

  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#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 NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------

int main() {
    int ans = 700;

    rep(i, 3) {
        char c;
        cin >> c;
        if (c == 'o') ans += 100;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void) {
    long int i, n;
    long int sum = 0;
    scanf("%ld", &n);
    for(i = 1; i <= n; i++) {
        if(i%3 != 0 && i%5 != 0) {
            sum = i + sum;
        }
    }
    printf("%ld\n", sum);
}

Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define ll long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int n,k,a[100005];
int ans;
int main()
{
	n=read();k=read();
	register int i;
	for(i=1;i<=n;++i) a[i]=read();
	ans=1e9;
	for(i=1;i<=n-k+1;i++)
	{
		if(a[i]<=0&&a[i+k-1]<=0) ans=min(ans,-a[i]);
		if(a[i]<=0&&a[i+k-1]>=0) ans=min(ans,-a[i]+a[i+k-1]+min(-a[i],a[i+k-1]));
		if(a[i]>=0&&a[i+k-1]>=0) ans=min(ans,a[i+k-1]);
	}
	return 0*printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		int max = 0;
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		ans = a + b + c;
		max = Math.max(a, Math.max(b, c));
		ans -= max;
		int k = sc.nextInt();
		for(int i = 0; i < k; i++) {
			max *= 2;
		}
		ans += max;
		System.out.println(ans);
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

int main() {

	int w, a, b, ans;
	cin >> w >> a >> b;

	if (a < b)
		ans = b - (a + w);
	else if (b < a) {
		ans = a - (b + w);
	}
	else ans = 0;

	if (ans < 0)
		ans = 0;

	cout << ans << endl;

	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
 
  ll ans = 0; 
  rep(i, n-1) {
    for (int j = i + 1; j < n; ++j) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void)
{
  string s;
  cin >> s;
  int slen = s.size();
  vector<char> zero(slen);
  vector<char> one(slen);
  int zerocnt = 0;
  int onecnt = 0;
  for(int i = 0; i < slen; i++)
  {
    zero[i] = '0' + i % 2;
    one[i] = '0' + (i + 1 ) % 2;
    if(zero[i] != s[i])
    {
      zerocnt++;
    }
    if(one[i] != s[i])
    {
      onecnt++;
    }
  }
  cout << min(zerocnt, onecnt) << endl;
}

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

string repeat(int n, string s) {
    string res = "";
    for (int i=0; i<n; ++i)
        res += s;
    return res;
}

int main() {
    int N; cin >> N;
    for (int i=0; i<N; ++i) {
        string snake; cin >> snake;

        int len = snake.size();
        if (len <= 4) {
            cout << "NA" << endl; continue;
        }

        string body = repeat(len/2 - 2, "=");
        string A = ">'" + body + "#" + body + "~";
        if (snake == A) {
            cout << "A" << endl; continue;
        }

        body = repeat(len/2 - 2, "Q=");
        string B = ">^" + body + "~~";
        if (snake == B) {
            cout << "B" << endl; continue;
        }

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

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256