akhauriyash/Code-Regression huggingface dataset:
import sys


def solve():
    readline = sys.stdin.readline
    H, W = map(int, readline().split())
    ch, cw = map(int, readline().split())
    dh, dw = map(int, readline().split())
    S = ['#'] * (W+2)
    for _ in range(H):
        S += ['#'] + list(readline().rstrip()) + ['#']
    S += ['#'] * (W+2)
    H += 2
    W += 2
    now = ch*W + cw
    goal = dh*W + dw
    q = [now]
    inf = 999_999_999
    dist = [inf] * (H*W)
    dist[now] = 0

    while q:
        same_area = []
        while q:
            x = q.pop()
            same_area.append(x)
            for d in [-W, -1, 1, W]:
                if S[x+d] == '.' and dist[x+d] > dist[x]:
                    q.append(x+d)
                    dist[x+d] = dist[x]
        
        for x in same_area:
            for dy in [-2*W, -W, 0, W, 2*W]:
                for dx in range(-2, 3):
                    xx = x + dy + dx
                    if 0 <= xx < W*H and dist[xx] > dist[x] and S[xx] == '.':
                        q.append(xx)
                        dist[xx] = dist[x] + 1
    return dist[goal] if dist[goal] != inf else -1


if __name__ == '__main__':
    ans = solve()
    print(ans)


Measured memory_bytes: 159672
#include<iostream>
#include<cstdio>
#include<climits>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<cmath>
using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define sz(a) int((a).size())
#define pb push_back
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
//const int N = 1e5+7;
int n,m,k,x,y,a,b;
string s;
int main(){
    fast;
    cin>>s;
    forn(i,sz(s)){
        if(s[i]=='N') x=1;
        else if(s[i]=='S') y=1;
        else if(s[i]=='E') a=1;
        else if(s[i]=='W') b=1;
    }
    if(x&&!y){
        cout<<"No"<<endl;
    }else if(!x&&y){
        cout<<"No";
    }else if(a&&!b){
        cout<<"No";
    }else if(!a&&b){
        cout<<"No";
    }
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
H = [0]
h = list(map(int,input().split()))
H += h 
AB = []
for i in range(M):
    A,B = map(int,input().split())
    AB.append([A,B])
h = [0]
for i in range(N):
    h.append(1)
    
for k in range (M):
    i = AB[k][0]
    j = AB[k][1]
    if H[i] < H[j]:
        h[i] = 0
    elif H[i] > H[j]:
        h[j] = 0
    else:
        h[i] = 0
        h[j] = 0

print(sum(h))

Measured memory_bytes: 28936
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define trace(x)  cerr << #x << ": " << x << endl;
typedef long long ll;
typedef long double ld;
 
int main()
{
	fast;
	string s,t;cin>>s>>t;
	ll n=s.size();ll cnt=0;
	for(ll i=0;i<n;i++)
	{
		if(s[i]!=t[i])cnt++;
	}
	cout<<cnt;

}

Measured memory_bytes: 3804
/*
 * zyrch - Rupanshu Yadav
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) 

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 1e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
	a %= mo;
	if(a < 0) a+=mo;
	return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
	return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}

//=========================CODE STARTS HERE=============================//

int main() {
	fast_cin();
	ll n,m;
	cin >> n >> m;
	ll k;
	fo(i,m) {
		cin >> k;
		n -= k;
	}
	
	cout << (n < 0 ? -1 : n);
	
	return 0; 
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B) << ' ' << max(0, A+B-N) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>

using namespace std;

class UnionFind{
private:
    vector<int> Parent;
public:
    UnionFind(int N){
        vector<int> Parent(N,-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> L(M),R(M);
    int Lmax=0,Rmin=N;
    for(int i=0;i<M;i++){
        cin >> L[i] >> R[i];
        Lmax = max(Lmax,L[i]);
        Rmin = min(Rmin,R[i]);
    }
    if(Lmax>Rmin) cout << "0" << endl;
    else cout << Rmin - Lmax + 1 << endl;
}

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

int main(){
  int K,S;
  cin >> K >> S;
  
  int ans=0;
  for(int i=0; i<=K; i++){
    for(int j=0; j<=K; j++){
      int d=S-i-j;
      if(d>=0 && d<=K) ans++;
    }
  }
  cout << ans << endl;
}

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

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

int main()
{
    int n, x, xx, ans;
    cin >> n >> x >> xx;
    ans = abs(x - xx);
    for(int i = 1; i < n; i++){
        cin >> xx;
        ans = gcd(ans, abs(x - xx));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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 n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    int l[q], r[q];
    rep(i, 0, q) {
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }

    int sum[n] = {};
    rep(i, 0, n - 1) {
        if (s.substr(i, 2) == "AC") {
            sum[i + 1] = sum[i] + 1;
        } else {
            sum[i + 1] = sum[i];
        }
    }

    rep(i, 0, q) {
        cout << sum[r[i]] - sum[l[i]] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    string a, b;
    cin >> a >> b;
    a += b;
    int num = 0;
    int k = 1;
    while(a.size() > 0){
        num += (a.back() - '0') * k;
        k *= 10;
        a.pop_back();
    }
    int sq = sqrt(num);
    if(sq * sq == num) cout << "Yes";
    else cout << "No";
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set>
using namespace std;

int main()
{
	char s[100010],z='z';
	int k;

	scanf("%s",s);
	scanf("%d",&k);

	for (int i=0; i < strlen(s) && k > 0; i++)
	{
		if (s[i] == 'a') continue;
		if (z+1-s[i] <= k)
		{
			k = k -(z+1-s[i]);
			s[i] = 'a';
		}
	}
	k = k%26;
	s[strlen(s)-1] += k;

	printf("%s\n", s);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int n=a,j=0;
	while(1){
		if(a%b==c){
			cout << "YES" << endl;
			return 0;
		}
		a = a+n;
		j++;
		if(j==10000){
			break;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950



int main() {
	int a, b, c, d; std::cin >> a >> b >> c >> d;
	//if(d > b)
		std::cout << c - (d - b) << " " <<  d + (c - a) << " " << a - (d - b) << " " << b + (c - a) << std::endl;
	/*else
		std::cout <<*/ 
	return 0;
}

Measured memory_bytes: 3604
n = int(input())
s = str(input())

ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ALPHABET_LEN = len(ALPHABET)
prceed_val = n % ALPHABET_LEN

def trans(s):
    pos = ALPHABET.index(s)
#     print(s)
#     print(pos)
    newpos = pos + prceed_val


    if newpos > ALPHABET_LEN - 1:
        newpos = abs(ALPHABET_LEN - newpos)
#         print(minus_pos)
#         newpos = newpos + minus_pos

#     print(newpos)
    new_s = ALPHABET[newpos]
    return new_s

new_str= ''.join([trans(_s) for _s in s])

print(new_str)




Measured memory_bytes: 3060
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		BigDecimal tax08 = BigDecimal.valueOf(0.08);
		BigDecimal tax10 = BigDecimal.valueOf(0.10);
		BigDecimal taxA = new BigDecimal(0);
		BigDecimal taxB = new BigDecimal(0);

		int result = -1;
		for(int i = 1; i < 10000; i++) {
			taxA = BigDecimal.valueOf(i);
			taxB = BigDecimal.valueOf(i);
			taxA = taxA.multiply(tax08);
			taxB = taxB.multiply(tax10);

			taxA = taxA.setScale(0, BigDecimal.ROUND_DOWN);
			taxB = taxB.setScale(0, BigDecimal.ROUND_DOWN);

			if(BigDecimal.valueOf(A).equals(taxA)
				&& BigDecimal.valueOf(B).equals(taxB)) {
				result = i;
				break;
			}
		}

		System.out.println(result);

	}

}


Measured memory_bytes: 25812
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n';
int main()
{
    fastIO;
    ll a,b;
    cin>>a>>b;
    set<ll>s,s1,s2;
    while(a%2==0)
    {
        s.insert(2);
        a/=2;
    }
    for(int i=3;i<=sqrt(a);i++)
    {
        while(a%i==0)
        {
            a/=i;
            s.insert(i);
        }
    }
    if(a>2)
    {
        s.insert(a);
    }
    while(b%2==0)
    {
        s1.insert(2);
        b/=2;
    }
    for(int i=3;i<=sqrt(b);i++)
    {
        while(b%i==0)
        {
            b/=i;
            s1.insert(i);
        }
    }
    if(b>2)
    {
        s1.insert(b);
    }
    for(auto itr=s.begin();itr!=s.end();itr++)
    {
        if(s1.find(*itr)!=s1.end())
        {
            s2.insert(*itr);
        }
    }
    cout<<s2.size()+1<<'\n';
    return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,A,B;
	cin >> N >> A >> B;
	int ans = 0;
	for(int i=0;i<N;++i){
		int t;
		cin >> t;
		if( A<= t && t < B ){
			
		}else{
			++ans;
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
m, n = map(int, input().split(" "))
if n - m >= 673:
    print(0)
else:
    score = m * n % 2019
    for i in range(m, n + 1):
        for j in range(i + 1, n + 1):
            if (i * j) % 2019 < score:
                score = (i * j) % 2019
    print(score)


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

int main(){
	string s;	cin>>s;
	string ans="Yes";

	for(int i=0; i<s.length(); i++){
		if(i%2==0){
			if(!(s[i]=='R' || s[i]=='U'||s[i]=='D')){
				ans="No";
				break;
			}
		}else{
			if(!(s[i]=='L' || s[i]=='U'||s[i]=='D')){
				ans="No";
				break;
			}
		}
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9+7)
#define INF (1e18)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int a[16][16];
int dp[70000];
int s[70000];

int32_t main() {
	INIT();
	//code...
	int n; cin>>n;
	For(i,0,n-1) For(j,0,n-1) cin>>a[i][j];
	For(mask,0,(1<<n)-1){
		s[mask]=0;
		For(i,0,n-2) For(j,i+1,n-1)
			if(mask&(1<<i) && mask&(1<<j)) s[mask]+=a[i][j];
	}
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	For(mask,1,(1<<n)-1){
		dp[mask]=-INF;
		for(int m=mask;m>0;m=(m-1)&mask){
			dp[mask]=max(dp[mask],dp[mask^m]+s[m]);
		}
	}
	cout<<dp[(1<<n)-1]<<"\n";
	return 0;
}

Measured memory_bytes: 4716
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    """
    from1 := 1から行ける島番号のリスト
    canN[i] := 島iがNに行くことができるか否か
    from1とtoNの両方に同じ島番号が存在するとき、POSSIBLE
    """
    from1 = []
    canN = [False] * (N+1)
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            from1.append(b)
        elif b == N:
            canN[a] = True
    
    for b in from1:
        if canN[b]:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")
        

if __name__ == "__main__":
    solve()


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




int main() {
  ll H, W;
  cin >> H >> W;
  

  if( H== 1 || W == 1){
    cout << 1 << endl;
  } else {
    cout << (H * W + 1) / 2 << endl;
  }


	return 0;
}



Measured memory_bytes: 3596
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}


console.log(main());
function main() {
    var l1 = o.getArray(0);
    var N = l1[0];
    var M = l1[1];

    var info = o.sliceArray(1);
    var keys = [];
    var ans = 0;
    for (var n = N; n > 0; n--) {
        ans += 1 << n;
    }

    for (var i = 0; M * 2 > i; i = i + 2) {
        keys.push({
            a: info[i][0],
            c: info[i + 1].reduce(function (a, c) {
                return a | 1 << (c - 1);
            }, 0)
        })
    }


    var dp = (new Array(1<<N)).fill(Infinity);
    dp[0] = 0;
    for(var s = 0; 1<<N > s; s++) {
        for(var j = 0; M > j; j++) {
            var t = s | keys[j].c;
            var cost = dp[s] + keys[j].a;
            dp[t] = Math.min(dp[t], cost);
        }
    }

    return dp[(1<<N) - 1] === Infinity ? -1 : dp[(1<<N) - 1] 
}

Measured memory_bytes: 9732
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
#define int long long

typedef vector<int> vi;		typedef vector<ll> vl;
typedef pair<int, int> ii; 	typedef vector<ii> vii;

// code start here //

vector<vii> graph;

const int N = 100005;

int ans[N];
bool flag = 1;
vi check;

void dfs(int u) {
	if(check[u] == -1) check[u] = 1;
	rep(i, 0, (int)graph[u].size()) {
		ii t = graph[u][i];
		if(check[t.first] == -1) {
			ans[t.first] = ans[u] - t.second;
			dfs(t.first);
		}
		else {
			if(ans[u] - t.second != ans[t.first]) flag = 0;
		}
	}
}

signed main() {
	fastio;
	int n, m; cin >> n >> m;
	graph.assign(n, vii());
	check.assign(n, -1);
	int l, r, d;
	rep(i, 0, n) ans[i] = LLONG_MAX;
	rep(i, 0, m) {
		cin >> l >> r >> d;
		l--; r--;
		graph[r].pb(mp(l, d));
		graph[l].pb(mp(r, -d));
	}
	rep(i, 0, n) {
		if(check[i] == -1) {
			ans[i] = 0;
			dfs(i);
		}
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 20396
#include "bits/stdc++.h"
	using namespace std;
	typedef long long int lint;
	typedef pair<lint, lint> plint;
	typedef pair<double long, double long> pld;
	#define ALL(x) (x).begin(), (x).end()
	#define SZ(x) ((lint)(x).size())
	#define POW2(n) (1LL << (n))
	#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
	#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
	#define REP(i, n) FOR(i,0,n)
	#define IREP(i, n) IFOR(i,0,n)
	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; }
	template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
	template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
	const lint MOD = 1e9 + 7, INF = 1e18;

	lint arr[200000], N;
	set<lint> st;
	lint cnt[1000001];

	vector< int64_t > divisor(int64_t n) {
		vector< int64_t > ret;
		for (int64_t i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				ret.push_back(i);
				if (i * i != n) ret.push_back(n / i);
			}
		}
		sort(begin(ret), end(ret));
		return (ret);
	}

	int main() {
		cin.tie(0); ios_base::sync_with_stdio(false);
		cin >> N;
		REP(i, N) {
			cin >> arr[i];
		}
		sort(arr, arr + N);
		lint ans = 0;
        REP(i, 1000001) {
          cnt[i] = 0;
        }
		REP(i, N) {
			cnt[arr[i]]++;
		}

		REP(i, N) {
			auto vec = divisor(arr[i]);
			bool flag = true;
			REP(j, SZ(vec)) {
				if (st.find(vec[j]) != st.end()) {
					flag = false;
				}
			}
			if (flag && cnt[arr[i]] == 1) ans++;
			st.insert(arr[i]);
		}
		cout << ans;
	}

Measured memory_bytes: 22264
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
#define pb 					push_back
#define FAST_IO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<" ";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<" ";
	return os;
}



int main() {	
	int n, k;
	cin >> n >> k;
	map<int,int> m;
	for(int i=1; i<=k; i++) {
		int d;
		cin >> d;
		while(d--) {
			int x;
			cin >> x;
			m[x]++;
		}
	}
	cout << n - (int)m.size() << "\n";
	return 0;
}














Measured memory_bytes: 3636
n = STDIN.gets.to_i
sequence = STDIN.gets.split[0...n].map!(&:to_i)

combined = []
1.upto(n) do |i|
	sequence.combination(i).each { |e| combined << e.inject(:+) }
end

m = STDIN.gets.to_i
STDIN.gets.split[0...m].map!(&:to_i).
	each { |q| puts combined.include?(q) ? "yes" : "no" }

Measured memory_bytes: 14492
#include<stdio.h>

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

Measured memory_bytes: 128
let () = Scanf.scanf "%d\n" @@ fun n ->
  let vs = Array.make n 0 in
  let ws = Array.make n 0 in
  for i = 0 to n - 1 do
    Scanf.scanf "%d %d\n" @@ fun v w ->
      vs.(i) <- v;
      ws.(i) <- w
  done;
  Scanf.scanf "%d\n" @@ fun q ->
    let vls = Array.init q @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun v l -> v, l in
    let maxl = Array.fold_right (fun (_, l) -> max l) vls min_int in
    let n' = min n ((1 lsl 10) - 1) in
    let dp = Bigarray.Array2.create Bigarray.int Bigarray.c_layout (n' + 1) (maxl + 1) in
    Bigarray.Array2.fill (Bigarray.Array2.sub_left dp 0 1) 0;
    for i = 1 to n' do
      let v = Array.unsafe_get vs (i - 1) in
      let w = Array.unsafe_get ws (i - 1) in
      Bigarray.Array2.blit
        (Bigarray.Array2.sub_left dp (i lsr 1) 1)
        (Bigarray.Array2.sub_left dp i 1);
      for j = w to maxl do
        let d = Bigarray.Array2.unsafe_get dp (i lsr 1) j in
        let d' = v + Bigarray.Array2.unsafe_get dp (i lsr 1) (j - w) in
        if d < d' then Bigarray.Array2.unsafe_set dp i j d'
      done
    done;
    let rec solve l i s m =
      if l < 0
      then m
      else if i <= n'
      then max m (s + Bigarray.Array2.unsafe_get dp i l)
      else solve l (i lsr 1) s @@ solve (l - Array.unsafe_get ws (i - 1)) (i lsr 1) (s + Array.unsafe_get vs (i - 1)) m in
    Array.iter (fun (v, l) -> Printf.printf "%d\n" @@ solve l v 0 min_int) vls



Measured memory_bytes: 814076
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}

//------------------変数-----------------------//
ll n, k, dp[1000][1000], ma, mb;
//-------------------関数----------------------//

int main() {
	fill_all(dp, (ll)-1); cin >> n;
	cin >> ma >> mb;
	dp[0][0] = 0;
	REP(i, n) {
		ll a, b, c;
		cin >> a >> b >> c;
		EREP(x, 900) {
			EREP(y, 900) {
				if (dp[x][y] != -1) {
					if (dp[x + a][y + b] == -1) { dp[x + a][y + b] = dp[x][y] + c; }
					else {
						dp[x + a][y + b] = min(dp[x][y] + c,	dp[x + a][y + b]);
					}
				}
			}
		}
	}
	ll mini = 11451419;
	REP(i, 900) {
		REP(j, 900) {
			if (i&&j&&i / ma == j / mb&&i / ma&&j / mb&&dp[i][j] != -1&&i%ma==0&&j%mb==0) { mini = min(dp[i][j], mini); }
		}
	}
	if (mini == 11451419) { cout << -1 << endl; }
	else { cout << mini << endl; }
}

Measured memory_bytes: 8064
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = 1000000000 + 7;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




ll pow(ll a, ll b) {


	if (b == 0) return 1;

	if (a % 2 == 1) {
		a * pow(a, b - 1);
	}
	else {
		ll ret = pow(a, b / 2);
		return ret * ret;
	}
}







vector<int> A;


int main() {
	ll N, M;
	vint::iterator it;
	vint::iterator it2;
	cin >> N;

	rep(i, N) {
		cin >> M;

		A.push_back(M);

	}


	sort(A.begin(), A.end());
	
	
	
	ll ans = 0;
	
	ll a = A[A.size() - 1];
	ll b = A[A.size() - 1];


	if (a % 2 == 0) {

		it = lower_bound(A.begin(), A.end(), a / 2);
		ans = *it;

		if (it != A.begin() && abs(*(it-1) - a/2) < abs(ans - a/2)) {
			ans = *(it - 1);
		}

		if (*it == a)
			ans = *(it - 1);


	}
	ll left = 0, right = 0;
	if (a % 2 == 1) {
		right = (a + 1) / 2;
		left = ((a + 1) / 2) - 1;
		it = lower_bound(A.begin(), A.end(), right);
		it2 = lower_bound(A.begin(), A.end(), left);
	
		ans = *it;

		if (it2 != A.begin() && abs(*(it2 - 1) - left) < abs(ans - right)) {

			ans = *(it2-1);

		}

		else if (*it == a) {
			ans = *(it - 1);
		}
		
		





	}

	cout << a << " " << ans << endl;

	
	return 0;
}

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

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

    int L = S/100;
    int R = S%100;

    if(L>=1 && L<=12){
        if(R>=1 && R<=12){
            printf("AMBIGUOUS\n");
        } else {
            printf("MMYY\n");
        }
    } else {
        if(R>=1 && R<=12){
            printf("YYMM\n");
        } else {
            printf("NA\n");
        }
    }
    return 0;
}

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

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, Q;
  cin >> N >> Q;
  map<ll, ll> R;
  map<ll, ll> C;
  R[N] = N-2;
  C[N] = N-2;

  ll rv = (N-2) * (N-2);

  for (;Q-->0;) {
    ll r, x;
    cin >> r >> x;
    if (r == 1) {
      auto it = R.upper_bound(x);
      if (it == R.begin()) {
        R[x] = it->second;
        C.begin()->second = x-2;
      }
      rv -= it->second;
    } else {
      auto it = C.upper_bound(x);
      if (it == C.begin()) {
        C[x] = it->second;
        R.begin()->second = x-2;
      }
      rv -= it->second;
    }
  }
  cout << rv << endl;
  return 0;
}


Measured memory_bytes: 16040
s=input()
dic={}
for i in range(4):
    if s[i] in dic.keys():
        dic[s[i]]+=1
    else:
        dic[s[i]]=1
ans=0
for i in range(4):
    if dic[s[i]]!=2:
        ans=1
if ans==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,W; cin >> N >> W;
    vector<ll> w(N),v(N);
    rep(i,N) cin >> w[i] >> v[i];
    
    ll w0 = w[0];
    rep(i,N) w[i] -= w0;
    ll M = 3*N;
    vector<vector<vector<ll>>> dp(N+1, vector<vector<ll>>(M+1, vector<ll>(N+1)));
    rep(i,N) {
        rep(j,M+1) {
            rep(k,N+1) {
                if (j < w[i] || k == 0) dp[i+1][j][k] = dp[i][j][k];
                else dp[i+1][j][k] = max(dp[i][j][k], dp[i][j-w[i]][k-1] + v[i]);
            }
        }
    }
    ll ans = 0;
    rep(i,N+1) {
        if (W - i*w0 >= 0) chmax(ans,dp[N][min(M,W-i*w0)][i]);
    }

    cout << ans << endl;

}


Measured memory_bytes: 25472
n, a, b = map(int, input().split())
st = input()
c = a + b
for s in st:
    if s == "a":
        if c >= 1:
            c -= 1
            print("Yes")
        else:
            print("No")
    elif s == "b":
        if c >= 1 and b >= 1:
            c -= 1
            b -= 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define db double
const db eps = 1e-8;

struct Point{
    db x, y;
    Point(db x=0, db y=0): x(x), y(y) {}    //必须有初始化
    bool operator < (const Point &p){
        return x < p.x || (x == p.x && y < p.y);
    }
};

typedef Point Vector;
Vector operator + (Vector a, Vector b){ return Point(a.x+b.x, a.y+b.y);}
Vector operator - (Point a, Point b){ return Vector(a.x-b.x, a.y-b.y);}
Vector operator * (Vector a, db k){ return Vector(a.x*k, a.y*k);}
Vector operator / (Vector a, db k){ return Vector(a.x/k, a.y/k);}

//inline将函数名为内联函数，不使用栈空间，直接运算，但不能有while,switch等复杂语句
inline db dot(Vector a, Vector b){
    return a.x*b.x + a.y*b.y;
}
inline db cross(Vector a, Vector b){
    return a.x*b.y - b.x*a.y;
}

int dcmp(db x){
    if(fabs(x) < eps) return 0;
    return x < 0? -1: 1;
}
bool operator == (Point a, Point b){
    return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
}

struct Segment{
    Point p1, p2;
};
typedef Segment Line;
vector<Point> Polygon;
Point project(Line l, Point p){
    Point p1 = l.p1, p2 = l.p2;
    Vector a = p2 - p1, b = p - p1;
    db len_a = a.x*a.x + a.y*a.y;   //这里不加sqrt，是因为下面算投影长度时，要除以两次len_a
    Vector tmp = a * (dot(a, b) / len_a);
    return Point(tmp.x+p1.x, tmp.y+p1.y);
}
int main()
{
    Line l;
    Point p;
    int n;
    cin >> l.p1.x>> l.p1.y >>l.p2.x >>l.p2.y >>n;
    while(n --){
        cin >> p.x>> p.y;
        Point ans = project(l, p);
        printf("%.10f %.10f\n", ans.x, ans.y);
    }
    return 0;
}



Measured memory_bytes: 3292
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
	int i,j,num,temp;
	scanf("%d",&num); 
	int *x=(int *)malloc(sizeof(int)*num);
	for(i=0;i<num;i++)
	scanf("%d",&x[i]);
	for(j=0;j<num;j++)
		{
			printf("%d",x[j]);
			if(j!=num-1)
			printf(" ");
		}
		printf("\n");
	for(i=1;i<num;i++)
	{
		j=i-1;
		temp=x[i];
		for(;j>=0&&x[j]>temp;j--)
			x[j+1]=x[j];
			x[j+1]=temp;
		for(j=0;j<num;j++)
		{
			printf("%d",x[j]);
			if(j!=num-1)
			printf(" ");
		}
		printf("\n");
		
	}
	return 0;
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  const int acc = accumulate(a.begin(), a.end(), 0);
  const double avg = acc / static_cast<double>(n);
  size_t j = 0;
  for (size_t i = 1; i < n; ++i ) {
    if (abs(a[i] - avg) < abs(a[j] - avg)) {
      j = i;
    }
  }
  cout << j;


  return EXIT_SUCCESS;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll R;
    cin >> R;

    cout << setprecision(10) << R*2*3.14159265358979 << endl;

    return 0;
}

/*



*/

Measured memory_bytes: 3788
N,K=map(int,input().split())
 
if K%2 == 0:
  div = N//(K//2)
  if div%2 > 0:
    div = div//2
    print((div*div*div) + (div+1)*(div+1)*(div+1))
  else:
    div = div//2
    print(div*div*div*2)
else:
  div = N//K
  print(div*div*div)

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

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

int main(void){
    // Your code here!
    int n, tmp, ans = 0;
    std::cin >> n;
    vector<int> data(n);
    for (int j = 0; j < n; ++j) {
        cin >> tmp;
        data[j] = tmp;
        
    }
    ans = data[0];
    for (int i = 0; i < n - 1; ++i) {
        ans = gcd(ans, data[i + 1]);
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
int main(){
    ll n, k; cin >> n >> k;
    ll ans = 0;
    _rep(i, 1, n + 1){
        ll p = n / i;
        ll q = n - p * i;
        ans += p * max(i - k, ll(0)) + max(q - k + 1, ll(0));
        if(k == 0)ans--;
    }
    cout << ans << endl;
}

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

int main(){
  int n,r;
  int array1[50],array2[50];

  while(1){
    cin>>n>>r;
    if(n+r==0)break;

    for(int i=0;i<n;i++) array1[n-i-1]=array2[n-i-1]=i+1;

    for(int j=0;j<r;j++){
      int c,p;
      cin>>c>>p;

      for(int i=0;i<p;i++){
	swap(array1[c-1+i],array1[i]);
	array2[c-1+i]=0;
      }
      int k=p;
      for(int i=0;i<n;i++){
	while(array2[i]==0) i++;
	array1[k++]=array2[i];
      }
      for(int i=0;i<n;i++){
	//	while(array2[i]==0)i++;
	array2[i]=array1[i];
      }
      //      for(int i=0;i<n;i++) cout<<array1[i]<<endl;     
    }

    cout<<array1[0]<<endl;
  }
  return 0;
}

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

int main(){
    int n;
    int A[200];
    int count = 0;
    bool odd = false;
    cin >> n ;
    for (int i = 0;i < n;i++)
    cin >> A[i] ;
    while (true){
        for (int i = 0;i < n;i++){
            if (A[i] % 2 == 0)
            A[i] /= 2;
            else
            odd = true;
        }
        if (odd == true)
        break;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
	int key;
	struct node *next;
};
typedef struct node* nP;

nP List[100001], NIL;
int n, visited[100001],att;

void insert(nP head, int x){
	nP data = (nP)malloc(sizeof(struct node));
	data->key=x;
	data->next=head->next;
	head->next=data;

	return;
}

void Search(int x){
	if(visited[x])return;
	int Q[1000000],front,tail, i;
	nP tmp;
	front=tail=0;
	Q[tail]=x;	++tail;

	while(front!=tail){
		x=Q[front];	++front;
		visited[x]=att;
		for(tmp=List[x]->next; tmp!=NIL; tmp=tmp->next){
			if(visited[tmp->key]==att)continue;
			Q[tail]=tmp->key;	++tail;
		}
	}

	return;
}

int main(){
	int i,j,m,q,s,t;	scanf("%d%d",&n,&m);
	nP tmp;

	NIL=(nP)malloc(sizeof(struct node));
	for(i=0;i<n;i++)List[i]=(nP)malloc(sizeof(struct node));
	NIL->key=-1;
	for(i=0;i<n;i++)List[i]->next=NIL;

	for(i=0;i<m;i++){
		scanf("%d%d",&s,&t);
		insert(List[s],t);
		insert(List[t],s);
	}

	att=0;
	for(i=0;i<n;i++){
		++att;
		Search(i);
	}

	scanf("%d",&q);
	for(i=1;i<=q;i++){
		scanf("%d%d",&s,&t);
		if(visited[s]==visited[t])printf("yes\n");
		else printf("no\n");
	}


	return 0;
}



Measured memory_bytes: 12852
#include "stdio.h"

int gcd(int a, int b)
{
	return (b > 0) ? gcd(b, a%b) : a;
}

int lcm(int a, int b)
{
	return (a/gcd(a, b)*b);
}

int main()
{
	int a, b;

	while(scanf("%d %d", &a, &b) != EOF){
		printf("%d %d\n", gcd(a, b), lcm(a, b));
	}

	return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        
        String S = br.readLine();
        String T = br.readLine();

        String tmp = T.substring(T.length() - 1, T.length());

        if(T.equals(S.concat(tmp))) {
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        br.close();
        pw.close();
    }
}

Measured memory_bytes: 32684
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

#define ll long long

using namespace std;
using Graph = vector<vector<int> >;

bool sortbysecdesc(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second>b.second; 
} 

int main() {
  int N; cin >> N;
  pair<int, int> Points[300];
  map<pair<int, int>, int> PointsABMap;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    Points[i] = make_pair(a, b);
    PointsABMap[make_pair(a, b)] = 2;
  }
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    Points[i+N] = make_pair(a, b);
    PointsABMap[make_pair(a, b)] = 3;
  }
  sort(Points, Points + 2 * N);
  // for (int i = 0; i < 2*N; i++) {
  //   cout << PointsABMap[Points[i]] << ": " << Points[i].first << Points[i].second  << endl;
  // }
  int cnt = 0;
  for (int i = 0; i < 2 * N; i++) {
    if (Points[i] != make_pair(-1, -1) && PointsABMap[Points[i]] == 3) {
      sort(Points, Points + i, sortbysecdesc);
      for (int j = 0; j < i; j++) {
        if (Points[j] != make_pair(-1, -1)
            && PointsABMap[Points[j]] == 2
            && Points[i].first > Points[j].first
            && Points[i].second > Points[j].second) {
          // cout << "pair: b("<< Points[i].first << Points[i].second << "), a(" << Points[j].first << Points[j].second << ")" <<endl;
          cnt++;
          // if (Points[i].first == 8) {
          //   for (int k = 0; k < 2 * N; k++) {
          //     cout << Points[k].first << Points[k].second << endl;
          //   }
          // }
          Points[j] = make_pair(-1, -1);
          break;
      }
      // int j = i;
      // while (j >= 0) {
      //   if (Points[j] != make_pair(-1, -1)
      //       && PointsABMap[Points[j]] == 2
      //       && Points[i].first > Points[j].first
      //       && Points[i].second > Points[j].second) {
      //     cout << "pair: b("<< Points[i].first << Points[i].second << "), a(" << Points[j].first << Points[j].second << ")" <<endl;
      //     cnt++;
          
      //     Points[j] = make_pair(-1, -1);
      //     break;
      //   } else {
      //     j--;
      //   }
      }
    }
  }
  // for (int i = 0; i < 2*N; i++) {
  //   cout << PointsABMap[Points[i]] << ": " << Points[i].first << Points[i].second  << endl;
  // }

  cout << cnt << endl;
}


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

const int N = 50010;
const int M = 100010;

std::bitset <N> set[N];
int n, m, t;
int x[M], y[M];
bool vis[N];
char ans[M];
int cnt[N], target[N];

void solve1(){
    for (int i = 0; i < n; ++ i){
        set[i][i] = true;
    }
    for (int i = m - 1; i >= 0; -- i){
        set[x[i]] = set[y[i]] = set[x[i]] | set[y[i]];
    }
    std::bitset <N> set1;
    set1.set();
    for (int i = 0; i < n; ++ i){
        set1 &= set[i];
    }
    for (int i = 0; i < n; ++ i){
        if (set1[i]){
            vis[i] = true;
            for (int j = m - 1; j >= 0; -- j){
                if (int(vis[x[j]]) + int(vis[y[j]]) != 1){
                    ans[j] = '^';
                    continue;
                }
                if (!vis[x[j]]){
                    ans[j] = 'v';
                }
                else{
                    ans[j] = '^';
                }
                vis[x[j]] = vis[y[j]] = vis[x[j]] || vis[y[j]];
            }
            puts(ans);
            return;
        }
    }
    puts("-1");
}

void solve2(){
    if (n == 2){
        puts("-1");
        return;
    }
    for (int i = 0; i < n; ++ i){
        cnt[i] = 1;
        target[i] = i;
    }
    for (int i = m - 1; i >= 0; -- i){
        int &t1 = target[x[i]], &t2 = target[y[i]];
        if (cnt[t1] + cnt[t2] < n || cnt[t2] >= 2){
            ans[i] = '^';
            -- cnt[t2];
            ++ cnt[t1];
            t2 = t1;
        }
        else{
            ans[i] = 'v';
            -- cnt[t1];
            ++ cnt[t2];
            t1 = t2;
        }
    }
    puts(ans);
}

int main(){
    scanf("%d%d%d", &n, &m, &t);
    for (int i = 0; i < m; ++ i){
        scanf("%d%d", &x[i], &y[i]);
        -- x[i], -- y[i];
    }
    if (t == 1){
        solve1();
    }
    else{
        solve2();
    }
    return 0;
}


Measured memory_bytes: 306816