akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 998244353;
const int N = 2e5+5;

int mpow(int x, int y) {
	if(y==0)
		return 1;
	int temp = mpow(x,y/2);
	temp*=temp;
	temp%=MOD;
	if(y&1)
		return (temp*x)%MOD;
	return temp;
}

int inverse(int x) {
	return mpow(x, MOD-2);
}

int fact[N];
int ifact[N];

int nCr(int n, int r) {
	int ans = fact[n];
	ans *= ifact[r];
	ans%=MOD;
	ans*=ifact[n-r];
	ans%=MOD;
	return ans;
}

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

	int n,m,k;
	cin>>n>>m>>k;

	fact[0]=1;
	ifact[0]=1;
	for(int i=1;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
		ifact[i]=inverse(fact[i]);
	}

	int ans = 0;
	int ca=m;
	int rem = n-1;
	int cam=1;;
	for(int i=0;i<n;i++) {
		int ta = ca*cam;
		ta%=MOD;
		// cout<<ta<<"\n";
		if(rem<=k)
			ans+=ta;
		ans%=MOD;
		rem--;
		ca*=(m-1);
		ca%=MOD;
		cam = nCr(n-1, i+1);
	}

	cout<<ans;


	return 0;
}

Measured memory_bytes: 6792
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int mini,i;
    ll a[10],n;
    ll sum=0;
    mini=0;
    scanf("%lld",&n);
    for(i=0;i<5;i++)
    {scanf("%lld",&a[i]);
        if(a[i]<a[mini])
            mini=i;
    }
    sum=4+n/a[mini];
    if(n%a[mini]!=0)
        sum++;
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 150;
ll cnt[MAX_N];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < k; i ++) {
        int d;
        cin >> d;
        for(int j = 0; j < d; j ++) {
            int a;
            cin >> a;
            cnt[a - 1] ++;
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i ++) {
        if(cnt[i] == 0) {
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;
vector<ll> A(100100, 0);
const ll INF = 1e18;

int main() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> A.at(i);
    }
    ll ans = 1;
    bool flg = true;
    for(int i = 0; i < n; ++i) {
        if(flg && INF/ans >= A.at(i)) {
            ans *= A.at(i);
        }else if(A.at(i) == 0) {
            cout << 0 << endl;
            return 0;
        }else {
            flg = false;
        }
    }
    if(flg) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3868
S = gets.chomp


pattern1 = ''
pattern2 = ''

S.size.times do |i|
  if i % 2 == 0
    # 0101
    pattern1 += '0'
    # 1010
    pattern2 += '1'
  else
    # 0101
    pattern1 += '1'
    # 1010
    pattern2 += '0'
  end
end

diff1 = 0
diff2 = 0
0.upto(S.size - 1) do |i|
  if S[i] != pattern1[i]
    diff1 += 1
  end

  if S[i] != pattern2[i]
    diff2 += 1
  end
end

p [diff1, diff2].min


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

int main(){
	int N, input, count = 0;
	cin >> N;
	rep(i, N){
		cin >> input;
		if(input % 2 == 1) count++;
	}
	if(count % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main() {
    int N; cin >> N;
    int cnt = 0;
    rep(i, N) {
        int a; cin >> a;
        if ((i+1) % 2 == 1 && a % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
 
using namespace std;
const int N = 5e3 + 5;
int dp[N], p[N], x[N];
vector <int> g[N];
 
void dfs(int v) {
    if (g[v].empty()) {dp[v] = x[v]; return ;}
    vector <int> vec;
    bitset <N> bt = 0;
    int res = 0;
    for (int u : g[v]) {
        dfs(u);
        if (x[u] < dp[u] - x[u]) res += x[u];
        else res += dp[u] - x[u];
        vec.push_back(abs(2 * x[u] - dp[u]));
        dp[v] += dp[u];
    }
    bt[res] = 1;
    for (int i : vec) bt |= bt<<i;
    for (int i = x[v]; i >= 0; i--) if (bt[i] == 1) {
        dp[v] += x[v] - i;
        return ;
    }
    cout << "IMPOSSIBLE\n";
    exit(0);
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n; cin >> n;
    for (int i = 2; i <= n; i++) cin >> p[i], g[p[i]].push_back(i);
    for (int i = 1; i <= n; i++) cin >> x[i];
    dfs(1);
    cout << "POSSIBLE\n";
    return 0;
}

Measured memory_bytes: 4568
mods = 1000000007
n, m = [int(x) for x in input().split()]
bads = [True] * (n + 1)
for i in range(m):
    bads[int(input())] = False
dp = [0] * (n + 1)
dp[0] = 1
for curr in range(n):
    for next in range(curr + 1, min(n, curr + 2) + 1):
        if bads[next]:
            dp[next] += dp[curr]
            dp[next] %= mods
print(dp[n])



Measured memory_bytes: 7700
n, k = map(int, input().split())
arr = list(map(int, input().split()))
dp = [0] * (k + 1)
dp[0] = 0
for i in range(k + 1):
    for j in arr:
        if i >= j and not dp[i - j]:
            dp[i] = 1
print("First" if dp[-1] else "Second")


Measured memory_bytes: 41580
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

#define ll long long

int main(void){

    int a,b,c;
    cin>>a>>b>>c;

    for(int i=1;i<10000;i++){
        if(a*i%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }

    cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,i;
  scanf("%d",&N);

  int A[N];
  int max1=0;
  int max2=0;

  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
    if( A[i] > max2){
      max2 = A[i];
      if( A[i] > max1){
      max2 = max1;
      max1 = A[i];
      }
    }
  }
  
  for(i=0; i<N; i++){
    if(A[i] == max1) printf("%d\n", max2);
    else printf("%d\n", max1);
  }
  return 0;
}

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

int main() {
	int N;
	int Y;
	int ans[3];
	ans[0]=-1;
	ans[1]=-1;
	ans[2]=-1;
	scanf("%d%d",&N,&Y);
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			if(i*10000+j*5000+(N-i-j)*1000==Y&&N-i-j>=0){
				ans[0] = i;
				ans[1] = j;
				ans[2] = N-i-j;
			}
		}
	}
	
	for(int i=0;i<3;i++){
		printf("%d ",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 256
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

function next(){return +cin[cid++];}
console.log(main().toString());


function main() {
    let n = next();
    let a = Array(n);
    let b = Array(n);
    for (let i = 0; i < n; i++) {
        a[i] = next();
        b[i] = next();
    }
    a.sort((x, y) => x - y);
    b.sort((x, y) => x - y);
    let min, max;
    if (n % 2 == 0) {
        // 偶数の時 中央値は X(2/n-1)とX(2/n)の平均値
        // 最小値は、それぞれの値が異なるとき、A(2/n)-1/2、同じならA(2/n)
        min = (a[n / 2 - 1] + a[n / 2]) / 2;
        max = (b[n / 2 - 1] + b[n / 2]) / 2;
        return (max - min) * 2 + 1;
    } else {
        min = a[(n - 1) / 2];
        max = b[(n - 1) / 2];
        return (max - min) + 1;
    }


}


Measured memory_bytes: 80116
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
	string s;
	cin>>s;
	int ans = 0;
	for(int i=0;i<3;i++){
		if(s[i]=='R'){
			int c = 0;
			while(i<3 && s[i]=='R'){
				c++;
				i++;
			}
			ans = max(ans,c);
		}
	
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<((a-b)%2==0 ? "Alice" : "Borys")<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
using ll = long long;

bool ok(const string& S, const string& T, int i)
{
    for (int j = 0; j < T.size(); ++j) {
        int index = i + j;
        if (index >= S.size()) {
            return false;
        }

        if (S[index] == '?') {
            continue;
        }

        if (S[index] != T[j]) {
            return false;
        }
    }

    return true;
}

string generate_ans_string(string S, const string& T, int i)
{
    for (int j = 0; j < T.size(); ++j) {
        S[i+j] = T[j];
    }

    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == '?') {
            S[i] = 'a';
        }
    }

    return S;
}

int main()
{
    string S, T;
    cin >> S >> T;

    vector<string> list;

    for (int i = 0; i < S.size(); ++i) {
        if (ok(S, T, i)) {
            // ここで文字作って出力
            string ans = generate_ans_string(S, T, i);
            list.emplace_back(ans);
        }
    }

    if (list.empty()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    sort(begin(list), end(list));

    cout << list[0] << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
x = input()

original_pop_count = x.count('1')
one_pop_count = original_pop_count - 1
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_pop_count != 0:
        one_mod = (one_mod * 2 + int(b)) % one_pop_count
    zero_mod = (zero_mod * 2 + int(b)) % zero_pop_count


#f の前計算

f = [0] * 220000
pop_count = [0] * 220000
for i in range(1, 220000):
    pop_count[i] = pop_count[i//2] + i % 2
    f[i] = f[i % pop_count[i]] + 1

#pow2 の前計算
one_pow2 = [1] * 220000
zero_pow2 = [1] * 220000
for i in range(1, 220000):
    if one_pop_count != 0:
        one_pow2[i] = one_pow2[i-1] * 2 % one_pop_count
    zero_pow2[i] = zero_pow2[i-1] * 2 % zero_pop_count
    
# n-1, n-2, ,, 0
for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_pop_count != 0:
            nxt = one_mod
            nxt -= one_pow2[i]
            nxt %= one_pop_count
            print(f[nxt] + 1)
        else:
            print(0)
    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += zero_pow2[i]
        nxt %= zero_pop_count
        print(f[nxt] + 1)
        

Measured memory_bytes: 30332
#include <iostream>
using namespace std;
int main(){
	while(1){
		int x,y,a,b;
		cin >> x >> y;
		if(x==0 && y==0) return 0;
		if(x>y){ a=y; b=x;}
		else   { a=x; b=y;}
		cout << a << " " << b << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

void solve(){
  ll n, k; cin >> n >> k;
  while(true){
    if(n<=k-n) {cout << n; return;}
  else if(n>=k/2 && n <= 3*k/2) {cout << abs(n-k); return;}
  else {
    n = n -k*((n-3*k/2+k-1)/k);
  }
  }
}



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

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using ld = long double;

template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

vector<int> G[200005];
int diam;
int dfs(int v, int pr = -1)
{
    int mx1 = 1;
    int mx2 = 0;
    for (int u : G[v]) if (u != pr)
    {
        int l = dfs(u, v) + 1;
        if (l >= mx1)
        {
            mx2 = mx1;
            mx1 = l;
        }
        else chkmax(mx2, l);
    }
    chkmax(diam, mx1);
    chkmax(diam, mx1 + mx2 - 1);
    return mx1;
}

signed main()
{
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i)
    {
        int v, u;
        cin >> v >> u;
        G[v].pb(u);
        G[u].pb(v);
    }
    diam = 1;
    dfs(1);
    vector<char> win(diam + 1);
    win[0] = false;
    win[1] = true;
    win[2] = false;
    for (int i = 3; i <= diam; ++i)
        win[i] = !win[i - 1] || !win[i - 2];
    cout << (win[diam] ? "First\n" : "Second\n");
    
    return 0;
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()

int main() {
  vector<int> x(5);
  cin >>x[0]>>x[1]>>x[2]>>x[3]>>x[4];
  for (int i=0; i<5; i++){
    if (x[i] == 0){
      cout << i+1 << endl;
  return 0;
    }
  }
}


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

int main(){
  long long N, K;
  cin >> N >> K;

  vector<long long> A(N);
  for(auto& x: A){
    cin >> x;
  }
  sort(A.begin(), A.end());

  // ans = sup_x(#{(i, j)| A_i * A_j <= x} < K) + 1

  long long ok = -1e18 - 1, ng = 1e18 + 1;
  while(ng - ok > 1){
    long long mid = (ok + ng) / 2;
    // cout << "ok: " << ok << ", ng: " << ng << endl;
    // cout << "mid: " << mid << endl;

    long long k = 0;
    for(int i = 0; i < N; i++){
      // A_i * A_j <= mid
      if(A[i] < 0){
        // A_j >= mid / A_i
        long long c = 0;
        if(mid > 0){
          c = - (mid / (-A[i]));
        }else if(mid < 0){
          c = (-mid + (-A[i]) - 1) / (-A[i]);
        }
        auto itr = lower_bound(A.begin() + i + 1, A.end(), c);
        k += A.end() - itr;
      }else if(A[i] == 0){
        // 0 <= mid
        if(mid >= 0){
          k += N - 1 - i;
        }else{
          k += 0;
        }
      }else{ // A[i] > 0
        // A_j <= mid / A_i
        long long f = 0;
        if(mid > 0){
          f = mid / A[i];
        }else if(mid < 0){
          f = -(((-mid) + A[i] - 1)/ A[i]);
        }
        auto itr = lower_bound(A.begin() + i + 1, A.end(), f + 1);
        k += itr - A.begin() - i - 1;
      }
    }
    //cout << "k = " << k << endl;
    if(k < K){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  long long ans = ok + 1;
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
typedef struct{
    int n;
    int S[1000];
}SC;
int main(void)
{
    SC sc[100];
    double sum=0;
    int num=0;
    int dnum=0;
    double a=0;
    double m=0;
    while(num<100){
        scanf("%d",&sc[num].n);
        if(sc[num].n==0){
            break;
        }
        for(int i=0;i<sc[num].n;i++){
            scanf("%d",&sc[num].S[i]);
        }
        num++;
    }
    while((num-1)>=0){
        sum=0;
        m=0;
        a=0;
        for(int i=0;i<sc[dnum].n;i++){
            sum=sum+sc[dnum].S[i];
        }
        m=sum/sc[dnum].n;
        for(int i=0;i<sc[dnum].n;i++){
            a=a+pow((sc[dnum].S[i]-m),2);
        }
        a=a/sc[dnum].n;
        a=sqrt(a);
        printf("%.8f\n",a);
        num--;
        dnum++;
    }
    return 0;
}


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

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

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> div = divisors(m);
    ll ans = -1;
    for (ll i : div) if (i * n <= m) ans = max(ans, i);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

    map<vector<int>,int> mp;
    for(int i = 0; i < n; i++){
        vector<int> cnt;
        string s;
        cin >> s;
        for(int j = 0; j < 10; j++){
            cnt.push_back((int)(s[j]-'a'));
        }
        sort(all(cnt));
        mp[cnt]++;
    }

    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        ll t = itr->second;
        if(t>1){
            ans += t*(t-1)/2;
        }
    }

    cout << ans << endl;
    return 0;

}


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

ll gcd(ll a, ll b) {
  return b!=0 ? gcd(b, a % b) : a;
}

ll a, b, c, d, cnt_c, cnt_d, cnt_cd;

int main(){
  cin >> a >> b >> c >> d;
  cnt_c = b/c - (a-1)/c;
  cnt_d = b/d - (a-1)/d;
  cnt_cd = b/((c*d)/gcd(c, d)) - (a-1)/((c*d)/gcd(c, d));
  cout << (b-a+1) - (cnt_c + cnt_d - cnt_cd) << endl;
}

Measured memory_bytes: 3620
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
N = 2 * 10 ** 5

factorial = [1]
for i in range(1, N + 1):
    factorial.append((factorial[i - 1] * i) % mod)

p_list = [n % mod]
for i in range(1, N + 1):
    p_list.append((p_list[i - 1] * (n - i)) % mod)

x = pow(2, n, mod) - 1
ya = pow(factorial[a], 10 ** 9 + 5, mod)
yb = pow(factorial[b], 10 ** 9 + 5, mod)

print((x - p_list[a - 1] * ya - p_list[b - 1] * yb) % mod)

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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int ans = 0;
  int sum;
  for(int i=0; i<N;i++){
    int x = i+1;
    sum = 0;
    for(int j=0;j<5;j++){
      sum += x%10;
      x /= 10;
    }
    if(sum >=A && sum <= B){
      ans += i+1;
    }
  }
    cout << ans <<endl;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const lines = input.trim().split('\n');

while (line = lines.shift()) {

    const numbers = line.split(' ').map(Number);
    // Edit from here
    
    if(numbers.length > 1){
        const diffList = [];
        numbers.map((num1, ind1) => {
            numbers.map((num2, ind2) => {
                const diff = Math.abs(num1 - num2);
                const pair = `${num1} ${num2}`;
                
                if (ind1 !== ind2) {
                    diffList.push([pair, diff]);
                }
            })
        })

        const sorted = diffList.sort((p1, p2) => p1[1] - p2[1])[0];
        console.log(sorted[1]);
    }
    // to here
}



Measured memory_bytes: 456504
using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            Console.WriteLine("{0} {1}",a*b,2*(a+b));
        }
    }
}

Measured memory_bytes: 9148
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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



ll N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  string s;
  cin>>s;
  ll count = 0;
  N = s.length();
  for(ll i = 0 ; i<N/2 ; i++){
    if(s[i] != s[N-1-i])
      count++;
  }
   
   cout<<count<<'\n';

}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
   solve();

  return 0;
}


Measured memory_bytes: 3632
(defun main ()
  (let ((n (read)))
    (princ (loop :as i :below n
                 :sum  (loop :as j :below n
                           :sum (loop :as k :below n
                                     :sum (gcd (+ i 1)
                                               (+ j 1)
                                               (+ k 1))))))))
(main)


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

using namespace std;

int recurse(int i , vector<int> &arr , vector<int> &dp)
{
    if(dp[i] != -1) return dp[i];
    dp[i] = 0;
    for(int j:arr)
        if(i >=j) dp[i] = max(dp[i] , 1 - recurse(i-j,arr,dp));
    return dp[i];
}

int main(int argc, char const *argv[])
{
    int n , k , temp;
    cin >> n >> k;
    vector<int> arr(n,0);
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        arr[i] = temp;
    } 

    vector<int> dp(k+1,-1); // dp[n] denotes if the first player to play this is a winner.
    dp[0] = 0;
    string t = recurse(k,arr,dp) ? "First" : "Second";
    cout << t ;
    return 0;
}


Measured memory_bytes: 11420
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(){
    string s;
    int h,w;
    char c;
    cin>>h>>w;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>s;
            if(s=="snuke"){
                c='A'+j;
                cout<<c<<i+1<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 
// const int mo = 1e9 + 7;

// int n;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a;
	cin >> a;

	cout << 180 * (a-2) << endl;

	return 0;
}

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

#define STACK_SIZE 1000
#define MAX_LENGTH 1000

int stack[STACK_SIZE];
int stack_size = 0;

int pop() {
  if (stack_size <= 0) {
    return 0;
  }
  return stack[--stack_size];
}

void push(int x) {
  stack[stack_size++] = x;
}

int check_number(char *s) {
  // 符号あり
  if (*s == '+' || *s == '-') {
    s++;
    if (*s >= '0' && *s <= '9') {
      return 1;
    } else {
      return 0;
    }
  }
  // 符号なし
  if (*s >= '0' && *s <= '9') {
    return 1;
  } else {
    return 0;
  }
}

int get_number(char *s) {
  int sign = 0;
  int n = 0;

  if (*s == '+') {
    s++;
  } else if (*s == '-') {
    sign = 1;
    s++;
  }
  while(*s >= '0' && *s <= '9') {
    n = n * 10 + (*s - '0');
    s++;
  }
  if (sign) {
    return -n;
  } else {
    return n;
  }
}

int calc(char *s) {
  int x, y, n;

  while(*s) {
    if (check_number(s)) {
      n = get_number(s);
      push(n);
      while (*s == '+' || *s == '-') {
        s++;
      }
      while (n) {
        n /= 10;
        s++;
      }
    } else {
      switch (*s) {
        case '+':
          x = pop();
          y = pop();
          push(y+x);
          break;
        case '-':
          x = pop();
          y = pop();
          push(y-x);
          break;
        case '*':
          x = pop();
          y = pop();
          push(y*x);
          break;
      }
      s++;
    }
  }
  return pop();
}

int main() {
  char s[MAX_LENGTH];
  scanf("%[^\n]*s", s);
	printf("%d\n", calc(s));

  return 0;
}



Measured memory_bytes: 2096
#include<stdio.h>

int pa[200010]={0};

int root(int x)
{
	if(x==pa[x])return x;
	else return pa[x] = root(pa[x]);
}

void unite(int x,int y)
{
	int rx=root(x);
	int ry=root(y);
	if(rx==ry)return;
	else pa[rx]=ry;
}

int same(int x,int y)
{
	int rx=root(x);
	int ry=root(y);
	return (rx==ry);
}

int main()
{
	int n,q;
	int i,j;
	int x,y,z;
	
	scanf("%d %d",&n,&q);
	for(i=1;i<=n;i++)pa[i]=i;
	
	for(j=0;j<q;j++)
	{
		scanf("%d %d %d",&x,&y,&z);
		if(x==0)unite(y,z);
		else if(x==1)
        {
		    if(same(y,z))printf("1\n");
		    else printf("0\n");
        }
	}

}

Measured memory_bytes: 2340
n = int(input())
ans = [0]*(n+1)
for i in range(1,10**2):
    for j in range(1,10**2):
        for k in range(1,10**2):
            if i**2+j**2+k**2+i*j+j*k+i*k<=n:
                ans[i**2+j**2+k**2+i*j+j*k+i*k]+=1

for i in range(1,n+1):
    print(ans[i])


Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,a,count;
    count = 0;
    std::deque<int> deq;
    cin >> n;
    for (int r=0;r<n;r++) {
        cin >> a;
        deq.emplace_back(a);
    }
    
    for (int i=0;i<=n-1;i++) {
        int min = i;
        for (int j=i;j<=n-1;j++) {
            if (deq[min]>deq[j]) {
                min = j;
            }
        }
        if (min!=i) {
            int tmp = deq[min];
            deq[min] = deq[i];
            deq[i] = tmp;
            count++;
        }
    }
    for (int h=0;h<deq.size();h++) {
        if (h==deq.size()-1) {
            cout << deq[h] << endl;
        } else {
            cout << deq[h] << " ";
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3088
function Main(input) {
	input = input.trim().split(" ").map((a)=>Number(a));
  var a = Math.abs(input[0] - input[1]);
  var b = Math.abs(input[0] - input[2]);
  if(a > b){
     console.log("B");
     }else{
     console.log("A");
     }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
    int *p = new int[100000], count{}, n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", p + i);
        p[i]--;
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (p[i] == i)
        {
            std::swap(p[i], p[i + 1]);
            count++;
        }
    }
    if (p[n - 1] == n - 1) count++;

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
int n, m, a[100009]; vector<int>A, B, C, D;
int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0)A.push_back(a[i]);
		if (a[i] % 2 == 1)B.push_back(a[i]);
	}
	if (B.size() >= 3) { cout << "Impossible" << endl; return 0; }
	if (m == 1) {
		if (n == 1)cout << "1" << endl << "1" << endl << "1" << endl;
		else {
			cout << n << endl;
			cout << "2" << endl;
			cout << n - 1 << " " << 1 << endl;
		}
	}
	else {
		if (B.size() >= 1)C.push_back(B[0]);
		for (int i = 0; i < A.size(); i++)C.push_back(A[i]);
		if (B.size() >= 2)C.push_back(B[1]);
		if (C[0] >= 2)D.push_back(C[0] - 1);
		for (int i = 1; i < (int)C.size() - 1; i++)D.push_back(C[i]);
		D.push_back(C[C.size() - 1] + 1);

		for (int i = 0; i < C.size(); i++) { if (i)cout << " "; cout << C[i]; }cout << endl;
		cout << D.size() << endl;
		for (int i = 0; i < D.size(); i++) { if (i)cout << " "; cout << D[i]; }cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int a[10][10];
int n,m;
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	int total=0;
	
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		for(int j=1;j<=m;j++){
			if(s[j-1]=='#') {
				a[i][j]=1;
				total++;
			}
		}
	}
	if(!a[1][1]){
		cout<<"Impossible";
		return 0;
	}
	int x=1,y=1;
	int cnt=1;
	while(1){
		if(x==n&&y==m){
			if(cnt==total){
				cout<<"Possible";
				return 0;
			}
			cout<<"Impossible";
			return 0;
		}
		if(!(a[x+1][y]^a[x][y+1])){
		
			cout<<"Impossible";
			return 0;
		}
		if(a[x+1][y]){
			x++;
			cnt++;
			continue;
		}
		else{
			y++;
			cnt++;
		}
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
queue<string> que;

signed main() {
	cin >> n;
	que.push({ "a" });
	while (!que.empty()) {
		string p = que.front();
		if ((int)p.size() == n)break;
		que.pop();
		int ma = 0;
		for (int i = 0; i < (int)p.size(); i++)ma = max(ma, (int)p[i] - 'a');
		for (int i = 0; i <= ma + 1; i++)que.push(p + char('a' + i));
	}
	while (!que.empty()) {
		cout << que.front() << endl;
		que.pop();
	}
}

Measured memory_bytes: 9728
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>())

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
using ll = long long;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


void Main() {
  int A, B;
  cin >> A >> B;
  int ans;
  ans = A - B*2;
  if(ans < 0) ans =0;
  OUT(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();

  return 0;
}

Measured memory_bytes: 256
N = int(input())
def f(a, b, c):
    return a**2 + b**2 + c**2 + a*b + b*c + c*a
ans = [0] * N

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = f(x,y,z)
            if n <= N:
                ans[n-1] += 1
for a in ans:
    print(a)
                

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin>>n;
    int a[n];
    
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    
    int sum = 0;
    for(int i=0; i<n; i++){
        int m = i;
        for(int j=i+1; j<n; j++){
            if(a[j]<a[m]){
                m =j;
            }
        }
        if(i!=m){
            int temp = a[i];
            a[i] = a[m];
            a[m] = temp;
            sum++;
        }
        

    }
    
    for(int i=0; i<n; i++){
        if(i!=n-1)cout<<a[i]<<" ";
        else cout<<a[i]<<endl;
    }
    cout<<sum<<endl;
    
    return 0;
}


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

#define H 2000000
#define NIL -2000000001
//int n;
//int A[H];
int heapsize =0;
void maxHeapify(int A[H],int i);
//void buildMaxHeap(int A[H]);
void HeapInsert(int A[H],int key);
void HeapIncreaseKey(int A[H],int i,int key);
int HeapExtractMax(int A[H]);


int main(){
  int i,x,key,max;
  char c[10];
  int A[H];
  while(1){
    scanf("%s",c);
      if(c[0]=='i'){
	scanf("%d",&key);
	HeapInsert(A,key);
      }
      else if(c[1]=='x'){
	max=HeapExtractMax(A);
	printf("%d\n",max);
      }
      else if(c[1]=='n'){
	break;
      }
  }

  return 0;
}
  void maxHeapify(int A[],int i){
  int l,r,largest,temp;
  l=i*2;
  r=i*2+1;
  if(l<=heapsize && A[l]>A[i]){
    largest = l;
  }
  else{
    largest = i;
  }
  if(r<=heapsize && A[r]>A[largest]){
    largest = r;
  }
  if(largest!=i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A,largest);
  } 
}
/*
void buildMaxHeap(int A[]){
  int i; 
 for(i=n/2;i>=1;i--)
    maxHeapify(A,i);

}
*/
void HeapIncreaseKey(int A[],int i,int key){
  int temp;
  if(key<A[i])
    printf("error");
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    temp=A[i];
    A[i]=A[i/2];
    A[i/2]=temp;
    i = i/2;
  }
}

void HeapInsert(int A[],int key){
  heapsize +=1;
  A[heapsize] = -1000000000;
  HeapIncreaseKey(A, heapsize, key);
}

int HeapExtractMax(int A[]){
  int max;

  if(heapsize < 1)
    printf("heap under flor\n");
  
  max = A[1];
  A[1] = A[heapsize];
  heapsize -= 1;
  maxHeapify(A, 1);
  return max;
  
}

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

void solve(){
	
	string s1 ;
	string s2 ;

	cin>>s1>>s2 ;

	//cout<<s1<<" "<<s2 ;
	int count=0 ;

	for(int i=0;i<s1.length();i++){
		if(s1[i]!=s2[i])
			count++ ;
	}

	cout<<count ;

}	

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3928
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            while(true){
                String line = br.readLine();
                if(line.equals("0")) {
                    break;
                }
                char[] data = line.toCharArray();
                int a = 0;
                for(int i=0; i<data.length; i++){
                    a += Character.getNumericValue(data[i]);
                }
                System.out.println(String.valueOf(a));
            }
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24316
N = int(input())
A = list(map(int, input().split()))

res = 0

for i in range(len(A)-1):
  if A[i] > A[i+1]:
    res += abs(A[i] - A[i+1])
    A[i+1] = A[i+1] + abs(A[i] - A[i+1])
    
print(res)



Measured memory_bytes: 32288
#include <stdio.h>

int main(void){
    int n,ans=0;
    scanf("%d",&n);
    int h[n];
    for (int i=0; i<n; i++){
        scanf("%d",&h[i]);
    }
    while(1){
        int flag=0;
        for (int i=0; i<n; i++){
            if (flag==0){
                if (h[i]!=0){
                    flag=1;
                    h[i]--;
                }
            } else if (flag==1){
                if (h[i]!=0){
                    h[i]--;
                } else {
                    flag=2;
                }
            }
        }
        if (flag==0){
            break;
        } else {
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;    
}


Measured memory_bytes: 128
n,*s=map(int,open(0).read().split());s,t,f,g=[s[i*n:i*n+n]for i in range(4)];r=range(n);a=[n*[0]for _ in r];e=1
for _ in[0]*64:
 u=[k&e for k in f];v=[k&e for k in g];l=[0]*n;m=l[:]
 for i in r:
  for j in r:
   if(u[i]&v[j])|((s[i]^1)*u[i])|((t[j]^1)*v[j]):a[i][j]|=e;l[i]+=1;m[j]+=1
 for i in r:
  if(l[i]==0)*s[i]*u[i]:
   for j in r:
    if(t[j]^1)*(n-m[j]>1):a[i][j]|=e;m[j]+=1;break
  if(m[i]==0)*t[i]*v[i]:
   for j in r:
    if(s[j]^1)*(n-l[j]>1):a[j][i]|=e;l[j]+=1;break
 e<<=1
h=a[0][:];w=[i[0]for i in a]
for i in r:
 for j in r:w[i]=(w[i]|a[i][j]if s[i]else w[i]&a[i][j]);h[j]=(h[j]|a[i][j]if t[j]else h[j]&a[i][j])
if(g!=h)|(f!=w):print(-1);exit() 
for i in a:print(*i)

Measured memory_bytes: 99020
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u){
	stringstream ss;
	ss << t;
	ss >> u;
}

int main(){
	int n;
	while(cin >> n && n != 0){
		vector<vector<int> > ans(n+1, vector<int>(n+1, 0));
	
		for(int i = 0; i < n; i++){
			int total = 0;
			for(int j = 0; j < n; j++){
				cin >> ans[i][j];
				total += ans[i][j];
				ans[n][j] += ans[i][j];
			}
			ans[i][n] = total;
			ans[n][n] += total;
		}

		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				printf("%5d", ans[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin>>n;
  	unordered_map<string,int> m;
  	while(n--){
    	string s;
      	cin>>s;
      	m[s]++;
    }
  	cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<'\n';
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"];
}

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




ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}


// int main(){
//     //多くて10^4くらいしか組み合わせがない 各クエリ見ても50なので余裕だけど作るのがわからない
//     //最終的に必要なのはdの合計なので配列すべての概要を知る必要はない
//     int N, M, Q;
//     cin >> N >> M >> Q;
//     // vector<vector<int>> q(Q,vector<int>(4));
//     // rep(i, Q)cin >> q[i][0] >> q[i][1] >> q[i][2] >> q[i][3];
//     vector<pair<int, vector<int>>> p(Q);
//     rep(i,Q){
//         vector<int> t(3);
//         cin >> t[0] >> t[1] >> t[2];
//         int c;
//         cin >> c;
//         p[i] = make_pair(c, t);
//     }
//     sort(all(p), greater<pair<int, vector<int>>>());
//     for(auto x: p){
//         cout << x.first << " " << x.second[0] << " " <<x.second[1] << " " << x.second[2]<<endl;
//     }
//     vector<int> ans(N, -1);
//     rep(i, Q){
//         if(ans[p[i].second[0] - 1] == -1 && ans[p[i].second[1] - 1] == -1){
//             ans[p[i].second[0] - 1] = 1;
//             ans[p[i].second[1] - 1] = 1 + p[i].second[2];
//         }else if(ans[p[i].second[0] - 1] == -1 && ans[p[i].second[1] - 1] != -1){
//             ans[p[i].second[0] - 1] = ans[p[i].second[1] - 1] - p[i].second[2];
//         }else if(ans[p[i].second[0] - 1] != -1 && ans[p[i].second[1] - 1] == -1){
//             ans[p[i].second[1] - 1] = ans[p[i].second[0] - 1] + p[i].second[2];
//         }
//     }
//     rep(i, N)cout << ans[i] << endl;
//     ll res = 0;
//     rep(i,Q){
//         if(ans[p[i].second[1] - 1] - ans[p[i].second[0] - 1] == p[i].second[2])res += p[i].first;
//     }
//     cout << res << endl;
    
// }
int digNum(int x, int n){
    int num = pow(10, n);
    num = x % num;
    num /= pow(10, n - 1);
    return num;
}


int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int>> q(Q,vector<int>(4));
    rep(i, Q)cin >> q[i][0] >> q[i][1] >> q[i][2] >> q[i][3];
    vector<int> test(N, 1);
    ll ans = 0;
    int vectorIndex = N - 1;
    while(1){
        if(test[0] == M + 1)break;
        ll tmp = 0;
        rep(i, Q){
            if(test[q[i][1] - 1] - test[q[i][0] - 1] == q[i][2]) tmp += q[i][3];
        }
        ans = max(ans, tmp);
        test[vectorIndex]++;
        while(test[vectorIndex] == M + 1){
            vectorIndex--;
            test[vectorIndex]++;
            for(int i = vectorIndex + 1; i < N; i++)test[i] = test[vectorIndex];
            if(test[0] == M + 1)break;
        }
        vectorIndex = N - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3708
#include<stdio.h>
int main(){
	int W, H, x, y, r;
	scanf("%d %d %d %d %d",&W, &H, &x, &y, &r);
	if((x >= r)&&(y >= r)&&((x+r) <= W)&&((y+r) <= H))
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 584
import math
n,d = map(int,input().split())
x = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        t = 0
        for k in range(d):
            t+=(x[i][k]-x[j][k])**2 
        if math.sqrt(t)==int(math.sqrt(t)):
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const int N = 7;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	vl a(N);
	rep(i,0,sz(a)) {
		cin >> a[i];
	}
	ll ret = a[1];
	ll x = min(a[0], min(a[3],a[4]));
	ll y = a[0]%2 + a[3]%2 + a[4]%2;
	if(y >= 2) {
		x = min(1LL, x);
	} else {
		x = 0;
	}
	rep(i,0,x+1) {
		ll loc = a[1] + 3 * i;
		loc += ((a[0]-i)/2)*2;
		loc += ((a[3]-i)/2)*2;
		loc += ((a[4]-i)/2)*2;
		ret = max(ret, loc);
	}
	cout << ret << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
//8c:1a:bf:89:66:b6
struct threeElements{
int _1st,_2nd,_3rd;
};
vector<vector<int>>adj(10);
int sum,n,m,visited[11];
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:42
   int a,b,w;
   cin>>w>>a>>b;
   cout<<max(max(a,b)-(min(a,b)+w),0);


}


Measured memory_bytes: 3580
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
#include <functional>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;
using Polygon=vector<Point>;

bool operator<(const Point &a, const Point &b) {
    return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

double convex_diameter(const Polygon &g) {
    size_t V=g.size();
    size_t is=0, js=0;
    for (size_t i=1; i<V; ++i) {
        if (imag(g[i]) > imag(g[is])) is = i;
        if (imag(g[i]) < imag(g[js])) js = i;
    }

    double res=abs(g[is]-g[js]);
    size_t i, j, max_i, max_j;
    i = max_i = is;
    j = max_j = js;
    do {
        (++(cross_prod(g[(i+1)%V]-g[i], g[(j+1)%V]-g[j])>=0? j:i)) %= V;

        if (res < abs(g[i]-g[j])) {
            res = abs(g[i]-g[j]);
            max_i = i;
            max_j = j;
        }
    } while (!((i == is) && (j == js)));

    // <max_i, max_j>
    return res;
}

int main() {
    size_t n;
    scanf("%zu", &n);

    Polygon g(n);
    for (size_t i=0; i<n; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        g[i] = Point(x, y);
    }

    printf("%.9f\n", convex_diameter(g));
    return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
	map<char, int>mp;
	mp['<'] = 0;
	mp['v'] = 1;
	mp['>'] = 2;
	mp['^'] = 3;
	mp['.'] = 4;
	while (1) {
		int H, W; cin >> H >> W;
		if (!H)break;
		vector<vector<int>>field(H, vector<int>(W));
		for (int i = 0; i < H; ++i) {
			string st; cin >> st;
			for (int j = 0; j < W; ++j) {
				field[i][j] = mp[st[j]];
			}
		}
		int nx = 0;
		int ny = 0;
		for (int i = 0; i < 20000; ++i) {
			if (i == 19999) {
				nx = -1;
				break;
			}
			int a = field[ny][nx];
			if (a == 4) {
				break;
			}
			else {
				nx += dx[a];
				ny += dy[a];
			}
		}
		if (nx == -1) {
			cout << "LOOP" << endl;
		}
		else {
			cout << nx << " " << ny << endl;
		}
	}
	
	return 0;
}

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

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

bool run(int N, std::vector<int>count)
{
	boost::sort(count);
	if (count.back() - count.front() > 1)
	{
		return false;
	}
	if (count.back() == count.front())
	{
		return count.back() <= N / 2 || count.back() == N - 1;
	}
	auto min_count = boost::lower_bound(count, count.back()) - count.begin();
	auto max_count = N - min_count;
	if (max_count == 1)
	{
		return false;
	}
	return 
		count.back() <= min_count + max_count / 2 &&
		min_count + 1 <= count.back();
}

void Main()
{
	int N;
	std::cin >> N;
	std::vector<int> count(N);
	for (auto& c : count)
	{
		std::cin >> c;
	}
	if (run(N, std::move(count)))
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
}

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

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	int n, k;
	while (cin >> n >> k) {
		if (n == 0 && k == 0) {
			break;
		}
		int s[100];
		bool hantei = true;
		for (int i = 0; i < k; i++) {
			cin >> s[i];
		}
		int a;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < k; j++) {
				cin >> a;
				s[j] -= a;
				if (s[j] < 0) {
					hantei = false;
				}
			}
		}
		if (hantei) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152