akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n, d;
        cin >> n >> d;
        int a[n + 1][d + 1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                cin >> a[i][j];
            }
        }
        int cnt = 0;
        for (int k = 0; k < n; k++) {
            for (int i = k + 1; i < n; i++) {
                int tot = 0;
                for (int j = 0; j < d; j++) {
                   // cerr << a[k][j] << " " << a[i][j] << endl;
                    tot += (a[k][j] - a[i][j]) * (a[k][j] - a[i][j]);
                }
                int x = sqrt(tot);
                if (x * x == tot) cnt++;
            }
        }
        cout << cnt << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

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

int main(){
	long double dt[4][2];
	while(cin>>dt[0][0]){
		cin>>dt[0][1];
		for(int i=1;i<4;i++){
			for(int j=0;j<2;j++){
				cin>>dt[i][j];
			}
		}
		long double vector[2][2];
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				vector[i][j]=dt[i*2][j]-dt[i*2+1][j];
			}
		}
		if(!(vector[0][0]*vector[1][0]+vector[0][1]*vector[1][1])) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n; cin >> n;
    vector<unsigned long long> as(n);
    for(int i=0; i<n; ++i){
        cin >> as[i];
    }

    sort(as.begin(), as.end());
    int i;
    unsigned long long l1=0, l2=0;
    for(i=n-1; i>0; --i){
        if(as[i]==as[i-1]){
            l1=as[i];
            i-=2;
            break;
        }
    }
    for(; i>0; --i){
        if(as[i]==as[i-1]){
            l2=as[i];
            break;
        }
    }

    cout << l1*l2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int ctoi(char c){
	switch(c){
		case '0':{return 0;}
		case '1':{return 1;}
		case '2':{return 2;}
		case '3':{return 3;}
		case '4':{return 4;}
		case '5':{return 5;}
		case '6':{return 6;}
		case '7':{return 7;}
		case '8':{return 8;}
		case '9':{return 9;}
		default:{return -1;}
	}
}
int main(){
	int sum;
	char c;
	while(1){
		sum = 0;
		c = getchar();
		if(c=='0')break;
		else ungetc(c,stdin);
		while(1){
			c = getchar();
			if(c == '\n')break;
			sum += ctoi(c);
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 936
#include <iostream>

#include <set>
#include <vector>
#include <algorithm>

#include <cassert>

using namespace std;

typedef long long llong;
typedef vector<int> VI;

VI solve(int N, llong L, VI& A) {
   int ii = -1;
   for (int i = 1; i <= N-1; ++i)
      if (A[i] + A[i+1] >= L) {
         ii = i;
         break;
      }
   if (ii < 0) return {};
   VI res;
   for (int i = 1; i < ii; ++i)
      res.push_back(i);
   for (int i = N-1; i > ii; --i)
      res.push_back(i);
   res.push_back(ii);
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);

   int N;
   llong L;
   cin >> N >> L;
   VI A(N+1);
   for (int i = 1; i <= N; ++i)
      cin >> A[i];

   auto res = solve(N, L, A);

   if (res.empty())
      cout << "Impossible\n";
   else {
      cout << "Possible\n";
      for (int x : res) {
      // assert(1 <= x && x < N);
         cout << x << '\n';
      }
   }

   return 0;
}


Measured memory_bytes: 1784
import collections

N,M,X = map(int,input().split())
C = [0] * N
A = [None] * N
for i in range(N):
  c,*a = map(int,input().split())
  C[i] = c
  A[i] = a

INF = 10 ** 9
ans = INF
import itertools
for i in range(1,N + 1):
  for comb in itertools.combinations(range(N),i):
    cost = 0
    skills = [0] * M
    for c in comb:
      cost += C[c]
      for j in range(M):
        skills[j] += A[c][j]
    if cost >= ans:
      continue
    for s in skills:
      if s < X:
        break
    else:
      ans = cost

if ans == INF:
  print(-1)
else:
  print(ans)        


Measured memory_bytes: 9380
N,K = map(int,input().split())
P = list(map(float,input().split()))

wa = float(0)
for i in range(K):
    wa = wa + P[i]

ans = wa 
  
repeat = N-K
for i in range(repeat):
    wa = wa + P[i+K]-P[i]
    if ans <= wa :
        ans = wa
      
print(ans/2+(K*0.5))

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

int main() {
	string S; cin >> S;
	int t=0;
	for(int i=0; i<S.size(); ++i){
	    if(S[i]=='g') ++t;
	    else --t;
	}
	t /= 2;
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 512
nd = list(map(int, input().split()))
xnd = []
for _ in range(nd[0]):
    xnd.append(list(map(int, input().split())))
    
    
    
import math
count = 0
for i in range(nd[0] - 1):
    for i_2 in range(i+1, nd[0], 1):
        xSum = 0
        for j in range(nd[1]):
            xSum += (xnd[i][j] - xnd[i_2][j]) ** 2
        ans = math.sqrt(xSum)
        if ans == int(ans):
            count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 55
#define MOD 1000000007
using namespace std;
using LL = long long;
struct Mat {
    int sz;
    LL x[M][M];
    Mat () { MSET(x, 0); }
    Mat (int _sz) { sz = _sz; MSET(x, 0); }
    Mat operator * (Mat a) {
        Mat res(sz);
        REP(i,1,sz) REP(j,1,sz) REP(k,1,sz) {
            res.x[i][j] += x[i][k] * a.x[k][j];
            res.x[i][j] %= MOD;
        }
        return res;
    }
}pw[64], ans;
int n;
LL k;
int main()
{
    scanf("%d %lld", &n, &k);
    
    ans = Mat(n);
    REP(i,1,n) ans.x[i][i] = 1LL;
    REP(i,0,63) pw[i] = Mat(n);
    REP(i,1,n) REP(j,1,n) scanf("%lld", &pw[0].x[i][j]);
    REP(i,1,63) pw[i] = pw[i-1] * pw[i-1];


    REP(i,0,62) if (k&(1LL<<i)) ans = ans * pw[i];

    LL out = 0;
    REP(i,1,n) REP(j,1,n) out = (out + ans.x[i][j]) % MOD;
    printf("%lld\n", out);
    return 0;
}


Measured memory_bytes: 5364
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mod 1000000007
#define maxn 200015
#define PI 3.1415926535
#define all(x) x.begin(),x.end()
#define speedUp ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void CyBerForCe()
{
	string s;
	cin>>s;
	int n=0;
	for(int i=0;i<s.length();i++)
	n+= s[i]-'0';
	if(n%9==0)
	cout<<"Yes\n";
	else
	cout<<"No\n";
}
signed main()
{
    speedUp
    /*int t;
    cin>>t;
    while(t--)*/
    CyBerForCe();
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> P(N); REP(i, N) cin >> P[i];
  vector<pair<ll, int>> idx_pairs;
  REP(i, N) {
    idx_pairs.emplace_back((ll)P[i], i);
  }
  sort(ALL(idx_pairs));

  std::set<int> bin_tree;
  ll ans = 0;
  bin_tree.emplace(idx_pairs[N-1].second);
  for (int i = N-2; i >= 0; i--) {
    ll p; int idx; tie(p, idx) = idx_pairs[i];
    bin_tree.emplace(idx);
    auto it = bin_tree.lower_bound(idx);
    auto next_it = next(it);

    //cout << i << ": " << *it << endl;

    if (it == bin_tree.begin()) {
      ll n_left = *it + 1, n_right = 0;
      if (next(next_it) == bin_tree.end()) {
        n_right = N - *next_it;
      } else {
        n_right = *next(next_it) - *next_it;
      }
      //cout << n_left << "," << n_right << endl;
      ans += n_left * n_right * p;
    } else if (next_it == bin_tree.end()) {
      ll n_left = 0, n_right = N - *it;
      auto prev_it = prev(it);
      if (prev_it == bin_tree.begin()) {
        n_left = *prev_it + 1;
      } else {
        n_left = *prev_it - *prev(prev_it);
      }
      //cout << n_left << "," << n_right << endl;
      ans += n_left * n_right * p;
    } else {
      ll n_left = 0, n_right = 0;
      auto prev_it = prev(it);

      // it => left, next_it => right
      n_left = *it - *prev_it;
      if (next(next_it) == bin_tree.end()) {
        n_right = N - *next_it;
      } else {
        n_right = *next(next_it) - *next_it;
      }
      //cout << n_left << "," << n_right << endl;
      ans += n_left * n_right * p;

      // prev_it => left, it => right
      n_right = *next_it - *it;
      if (prev_it == bin_tree.begin()) {
        n_left = *prev_it + 1;
      } else {
        n_left = *prev_it - *prev(prev_it);
      }
      //cout << n_left << "," << n_right << endl;
      ans += n_left * n_right * p;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6896
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n;
ll a[100000];

ll s[100001];

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) cin >> a[i];
	sort(a, a + n);
	s[0] = 0;
	REP(i, n) s[i + 1] = s[i] + a[i];
	int res = 0;
	REP(i, n - 1) if (s[i + 1] * 2 < a[i + 1]) res = i + 1;
	cout << (n - res) << endl;
	return 0;
}


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

#define froop1(a,n) for(long long i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N,M,count= 0;
  cin >> N >> M;
 set<long long> N1;
  set<long long> M1;
  long long sN = N,sM = M;
  
  froop1(2,sqrt(sN) + 1){
    if(N == 1){
      break;
    }else{
      while(N % i == 0){
      N1.insert(i);
        N /= i;
      }
    }
  }
  if(N > sqrt(sN) + 1){
    N1.insert(N);
  }
    froop1(2,sqrt(sM) + 1){
    if(M == 1){
      break;
    }else{
        if(N1.count(i) && M % i == 0){
			count++;
    	}
      while(M % i == 0){
      M1.insert(i);
        M /= i;
      }
    }
  }
    if(M > sqrt(sM) + 1 && N1.count(M)){
    count++;
  }
  
cout << count + 1 << endl;
  
  
return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N, M;  cin >> N >> M;
	vector<string> A(N);  VECCIN(A);
	vector<string> B(M);  VECCIN(B);

	//初めに左上の座標を決める
	//横列
	for(int i = 0 ; i <= N - M ; i++){
		//縦列
		for(int j = 0 ; j <= N - M ; j++){
			bool flag = true;
			for(int k = 0 ; k < M ; k++)
					for(int l = 0 ; l < M ; l++)
							if(A[j + k][i + l] != B[k][l])  flag = false;
 
			if(flag){
					cout << "Yes" << endl;
					return 0;
			}
		}
	}
			
	cout << "No" << endl;	

	return 0;
}

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

int main(){
    long long int a,b,c,k,ans;
    double ans2;
    cin>>a>>b>>c>>k;
    if(k%2==1){
        ans2=b-a;
        ans=b-a;
    }else{
        ans2=a-b;
        ans=a-b;
    }
    if(abs(ans2)>1e+18)cout<<"Unfair"<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

template< int mod >
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using modint = ModInt< MOD >;

signed main() {
    int N;
    cin >> N;
    vector<int> x(N);
    cin >> x;
    vector<modint> base(N);
    {
        modint temp = 1;
        for (int i = 1; i <= N - 1; i++) temp *= i;
        base[0] = modint(1) * temp;
        for (int i = 1; i <= N - 1; i++) {
            base[i] = base[i - 1] + ((temp) / (i + 1));
        }
    }
    modint ans = 0;
    for (int i = 0; i < N - 1; i++) {
        ans += base[i] * (x[i + 1] - x[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
int main()
{
string s,t;cin>>s>>t;
int ans=1e9;
rep(si,s.size()){
	if(si+t.size()>s.size()) {break;}
	int cnt=0;
	rep(i,t.size()){
		if(s[si+i]!=t[i]){++cnt;}
		
	}
ans=min(ans,cnt);
	
}cout<<ans<<endl;
    return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}



Measured memory_bytes: 3588
package main

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

var c [4]int

func outResult() {
	fmt.Printf("AC x %s\n", strconv.Itoa(c[0]))
	fmt.Printf("WA x %s\n", strconv.Itoa(c[1]))
	fmt.Printf("TLE x %s\n", strconv.Itoa(c[2]))
	fmt.Printf("RE x %s\n", strconv.Itoa(c[3]))
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		switch scanner.Text() {
		case "AC":
			c[0]++
		case "WA":
			c[1]++
		case "TLE":
			c[2]++
		case "RE":
			c[3]++
		}

	}

	outResult()
}


Measured memory_bytes: 1784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

long long xorsum(long long x)
{
    long long a;
    long long xorsum;

    xorsum = x & ~0x03LL;
    for (a = xorsum; a < x; a++) {
        xorsum ^= (a + 1);
    }
    return xorsum;
}

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

    scanf("%lld %lld", &a, &b);

    ans = xorsum(a - 1) ^ xorsum(b);

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
#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<ll, ll>;
const long double PI = acos(-1.0L);
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 gem[25][25];
int n, m;

int main() {
    while(1) {
        cin >> n;
        if(n == 0) break;
        memset(gem, 0, sizeof(gem));
        for(int i = 0; i < n; ++i) {
            int x, y; cin >> x >> y;
            gem[y][x] = 1;
        }
        cin >> m;
        int nx = 10, ny = 10;
        int cnt = 0;
        if(gem[ny][nx]) {
            cnt++;
            gem[ny][nx] = 0;
        }
        for(int i = 0; i < m; ++i) {
            char dir;
            int len;
            cin >> dir >> len;
            while(len--) {
                if(dir == 'N') ny++;
                else if(dir == 'E') nx++;
                else if(dir == 'S') ny--;
                else nx--;
                if(gem[ny][nx]) {
                    cnt++;
                    gem[ny][nx] = 0;
                }
            }
        }
        if(cnt == n) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9+7;
const int N = 5e5+5;
typedef pair<int,int> pii;

ll bigmod(ll a, ll b)
{
    a%=mod;
    ll ans =1;
    while(b>0)
    {
        if(b&1)
        {
            ans = (ans*a)%mod;
        }
        a= (a*a)%mod;
        b>>=1;
    }
    return ans;
}
ll fact[N];
void init()
{
    fact[0]=1;
    for(ll i=1; i<N; i++)
        fact[i]= (fact[i-1]*i)%mod;
}
ll getncr(ll n, ll r)
{
    if(n<r)
    {
        //cout<<n<<" "<<r<<endl;
        return 0;
    }
    ll up = fact[n];
    ll down = (fact[r]* fact[n-r])%mod;
    return (up * bigmod(down,mod-2))%mod;
}
ll add(ll x, ll y)
{
    x+=y;
    if(x>=mod)
        x-=mod;
    return x;
}
ll sub(ll x, ll y)
{
    x-=y;
    if(x<0)
        x+=mod;
    return x;
}
ll gun(ll x, ll y)
{
    return (x*y)%mod;
}
ll vag(ll x, ll y)
{
    x= x* bigmod(y,mod-2);
    return x%mod;
}

void TEST_CASES(int cas)
{
    init();
    ll n,m;
    cin>>n>>m;
    ll ans = 0;
    for(ll i=0; i<=n; i++)
    {
        ll t= getncr(n,i);
        t= gun(t, getncr(m-i,n-i));
        t= gun(t, fact[n-i]);
        if(i%2==0)
        {
            ans = add(ans, t);
        }
        else{
            ans= sub(ans, t);
        }
    }
    ans = gun(ans,gun(getncr(m,n), fact[n]) );
    printf("%lld\n",ans);
}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 7640
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y,x%y)
def lcm(x,y):
  return (x*y)//gcd(x,y)
z=lcm(a[0],a[1])
for i in range(2,n):
  z=lcm(z,a[i])
sum=0
for i in range(n):
  sum+=(z-1)%a[i]
print(sum)

Measured memory_bytes: 3316
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
double get(vector<double>a,vector<double>b,double med)
{
	double r=0;
	for(int i=0;i<6;i++)r+=max(a[i]*med,b[i]*(1-med));
	return r;
}
int main()
{
	vector<double>a,b;
	for(int i=0;i<6;i++)
	{
		int z;
		scanf("%d",&z);
		a.push_back(double(z)/100.0);
	}
	for(int i=0;i<6;i++)
	{
		int z;
		scanf("%d",&z);
		b.push_back(double(z)/100.0);
	}
	double beg=0.0,end=1.0;
	for(int p=0;p<100;p++)
	{
		double m1=(beg+beg+end)/3.0,m2=(beg+end+end)/3.0;
		if(get(a,b,m1)>get(a,b,m2))beg=m1;
		else end=m2;
	}
	printf("%.15lf\n",get(a,b,beg));
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B;
	cin >> A >> B;
	cout << (A + B) % 24 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int n;
double x[100],y[100];
 
double distance(double p){
  double sum=0;
  for(int i=0;i<n;i++){
    double w=abs(x[i]-y[i]);
    sum += pow(w,p);
  }
  return pow(sum,1.0/p);
}
 
int main(){
  cout<<fixed<<setprecision(12);
 
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i<n;i++){
    cin>>y[i];
  }
   
  cout<< distance(1) <<endl;
  cout<< distance(2) <<endl;
  cout<< distance(3) <<endl;
 
  double mx=0;
  for(int i=0;i<n;i++){
    mx=max(mx, abs(x[i]-y[i]) );
  }
  cout<< mx <<endl;
   
  return 0;
}


Measured memory_bytes: 3456
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>


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

using namespace std;
using ll = long long;

#define M (1'000'000'007)

int hoge() { return 1; }

int main() {
    ios::sync_with_stdio(false);
    int i;
    cin >> i;
    if (i == 1)
        cout << 0 << endl;
    else
        cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 3180
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ solve s

solve :: String -> String
solve [] = []
solve s = (head s):(solve (drop 2 s))


Measured memory_bytes: 4988
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		n=sc.nextInt();
		m=sc.nextInt();
		r=sc.nextInt();
		a=new int [r];
		for(int i=0;i<r;i++)
			a[i]=sc.nextInt()-1;
		adj=new int [n][n];
		for(int [] x : adj)
			Arrays.fill(x, inf);
		for(int i=0;i<n;i++)
			adj[i][i]=0;
		while(m-->0){
			int u=sc.nextInt()-1;
			int v=sc.nextInt()-1;
			int c=sc.nextInt();
			adj[u][v]=c;
			adj[v][u]=c;
		}
		
		for(int k=0;k<n;k++)
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					adj[i][j]=Math.min(adj[i][j], adj[i][k]+adj[k][j]);
		
		mem=new int [r][1<<r];
		for(int [] x : mem)
			Arrays.fill(x, -1);
		int ans=dp(0, 1);
		for(int i=1;i<r;i++)
			ans=Math.min(ans, dp(i, 1<<i));
		pw.println(ans);
		pw.flush();
		pw.close();
	}
	static int inf=(int)1e8;
	static int n,m,r;
	static int [] a;
	static int [][] adj;
	static int [][] mem;
	
	static int dp(int i,int msk){
		if(Integer.bitCount(msk)==r)
			return 0;
		if(mem[i][msk]!=-1)
			return mem[i][msk];
		int ans=inf;
		for(int j=0;j<r;j++)
			if((msk & (1<<j))==0)
				ans=Math.min(ans, adj[a[i]][a[j]]+dp(j, msk | (1<<j)));
		return mem[i][msk]=ans;
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

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

typedef struct {
  int row;
  int col;
} Coord;

typedef struct _stack {
  struct _stack *next;
  Coord point;
} *stack, stackelem;


int solve (int W, int H);

stack  new_stack (void);
int is_empty (stack);
int push (stack, Coord);
Coord top (stack);
Coord pop (stack);


int main () {
  int W, H;

  while(scanf("%d%d", &W, &H))
    {
      if(W==0&&H==0)
	break;
      else
	printf("%d\n", solve(W,H));
    }

  return 0;
}


int solve (int W, int H) {
  stack S = new_stack ();  
  char M[H+2][W+2]; 
  Coord start;   
  int i, j, tile=1;

 
  for (i=0; i<=W+1; i++) { M[0][i] = '#'; M[H+1][i] = '#'; }
  for (i=1; i<=H; i++) { M[i][0] = '#'; M[i][W+1] = '#'; }

  for (i=1; i<=H; i++) {
    for (j=1; j<=W; j++) {
      scanf(" %c", &M[i][j]);
      if (M[i][j]=='@') {
	start.row = i;
	start.col = j;
      }
    }
  }


  push(S,start); 

  while (!is_empty(S)) {
    Coord current = pop(S);                  
    int d;                                 
    int D1[]={1,0,-1,0}; int D2[]={0,-1,0,1};
    
    for (d=0; d<4; d++) {
      Coord nc = current;
      
      if(M[nc.row + D1[d]][nc.col + D2[d]] == '.')
	{
	  nc.row += D1[d];
	  nc.col += D2[d];
	  push(S,nc);
	  M[nc.row][nc.col] = '*';
	  tile++;
	}
    }
  }
  return tile;
}

stack new_stack (void) {
  stack s;
  s = (stack) malloc (sizeof (stackelem));
  if (s == NULL) return NULL;
  s->next = NULL;
  return s;
}

int is_empty (stack s) {
  return (s && s->next == NULL);
}

int push (stack s, Coord v) {
  stack p;
  if (s == NULL) return 0;
  p = (stack) malloc (sizeof (stackelem));
  if (p == NULL) return 0;
  p->point = v;
  p->next = s->next;
  s->next =  p;
  return 1;
}

Coord top (stack s) {
  if (s && s->next) 
    return s->next->point;
  exit (1);
}

Coord pop (stack s) {
  stack p;
  Coord v = top (s);
  p = s->next;
  s->next = p->next;
  free (p);
  return v;
}

Measured memory_bytes: 616
import qualified Data.Vector.Unboxed as VU
import Control.Monad
import Data.List

main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  hs <- fmap VU.fromList $ fmap sort $ replicateM n readLn :: IO (VU.Vector Int)
  xs <- VU.forM (VU.fromList [k-1..n-1]) $ \i -> return $ (hs VU.! i) - (hs VU.! (i-k+1))
  print $ VU.minimum xs 


Measured memory_bytes: 65916
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int a, b, n, k, cou = 2, m[1000005] = {}, sum = 0;
	string str;
	cin >> n;
	m[n]++;
	while (cou < 10000000) {
		if (n % 2 == 0) {
			n /= 2;  
			m[n]++;
		}
		else {
			n = 3 * n + 1;
			m[n]++;
		}

		if (m[n] >= 2) {
			cout << cou;
			return 0;
		}
		cou++;
	}

	
}

Measured memory_bytes: 8064
n = int(input())
a = list(map(int,input().split()))
denied = False
for i in range(len(a)):
  if a[i] % 2 == 0:
    if (a[i] % 3 != 0 and a[i] % 5 != 0) :
      print ("DENIED")
      denied = True
      break
      
if not denied :
  print ("APPROVED")


Measured memory_bytes: 9080
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b;
    
    
    
    return 0;
}

Measured memory_bytes: 3640
#include <cstring>
#include <sstream>
#include <iostream>
using namespace std;

string fizzbuzz(int x) {
	if (x % 15 == 0) return "FizzBuzz";
	if (x % 5 == 0) return "Buzz";
	if (x % 3 == 0) return "Fizz";
	ostringstream os;
	os << x;
	return os.str();
}

int main () {
	int n, m;
	while (cin >> m >> n, n || m) {
		int alive = m;
		bool fail[m];
		memset(fail, 0, sizeof(fail));
		int p = 0;
		for (int i = 0; i < n; i++) {
			string str;
			cin >> str;
			if (alive == 1) continue;
			if (str != fizzbuzz(i + 1)) {
				fail[p] = true;
				alive--;
			}
			do {
				p = (p + 1) % m;
			} while (fail[p]);
		}
		bool first = true;
		for (int i = 0; i < m; i++) {
			if (fail[i]) continue;
			if (first) first = false;
			else {
				cout << ' ';
			}
			cout << i + 1;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>

int main() {
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  std::cin >> k;
  std::cout << a[k - 1] << std::endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
-- templete

f x y = 1 + g * (tx + ty - 1)
  where
    g = gcd x y
    tx = div x g
    ty = div y g


main = getInts >>= print . apply2 f



Measured memory_bytes: 3652
a,b,c=map(int,input().split())
k=int(input())
i=0
while True:
  if a<b:
    break
  b*=2
  i+=1
while True:
  if b<c:
    break
  c*=2
  i+=1
if i<=k:
  print("Yes")
elif i>k:
  print("No")

Measured memory_bytes: 9136
n = int(input());
s = input();
ans = []

for i in s:
    num = ord(i) + n;
    #正規化
    num = num - ord("A")
    num = num % 26
    ans.append(chr(num  + ord("A")))
    
new = ""
for j in ans:
    new += j

print(new.upper())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
//#define maxi 1e18
#define pll pair<ll,ll>
#define inf 1000000007
map<ll,ll> m;
int main(){
    ll n,i,j,sum=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            ll in=upper_bound(a,a+n,a[i]+a[j]-1)-a;
           // cout<<i<<" "<<j<<" "<<in<<endl;
            sum+=max(1ll*0,in-j-1);
        }
    }
    cout<<sum;
}


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

vector<string> recipe[101];
map<string,int> items;
map<string,int> links;

int check(string name){
  if(recipe[links[name]].size()<1)
    return items[name];
  int sum=0;
  for(int i=0;i<recipe[links[name]].size();i++)
    {
      sum+=check(recipe[links[name]][i]);
    }
  return min(items[name],sum);
}

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      for(int i=0;i<101;i++)
	recipe[i].clear();	      
      items.clear();
      links.clear();
      
      for(int i=0;i<n;i++)
	{
	  int a;
	  string b;
	  cin>>b>>a;
	  items.insert(make_pair(b,a));
	  links.insert(make_pair(b,i));
	}
      int m;
      
      cin>>m;
      for(int i=0;i<m;i++)
	{
	  string o;
	  int k;
	  cin>>o>>k;
	  for(int j=0;j<k;j++)
	    {
	      string tmp;
	      cin>>tmp;
	      recipe[links[o]].push_back(tmp);
	    }
	}
      string iname;
      cin>>iname;
      cout<<check(iname)<<endl;
      
    }
}

Measured memory_bytes: 1228
import numpy as np
one = [int(x) for x in input().split()]
two = [int(x) for x in input().split()]
three = [int(x) for x in input().split()]
l = [one, two, three]
card = np.array(l)
N = int(input())


for n in list(range(N)):
    try:
        b = int(input())
        card = np.where(card == b, 0, card)
    except EOFError:
        break
#print(card)

if card[0, 0] == card[0,1] == card[0,2] or\
card[1,0]==card[1,1]==card[1,2] or \
card[2, 0] == card[2, 1] == card[2, 2] or \
card[0, 0] == card[1, 0] == card[2, 0] or \
card[0, 1] == card[1, 1] == card[2, 1] or \
card[0, 2] == card[1, 2] == card[2, 2] or \
card[0, 0] == card[1, 1] == card[2, 2] or \
card[0, 2] == card[1, 1] == card[2, 0] :
    print('Yes')
else:
    print('No')

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

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nx = in.readLineAsIntArray();
        final int N = nx[0];
        final int X = nx[1];

        int[] cities = in.readLineAsIntArray();
        for (int i = 0; i < N; i++) {
            cities[i] -= X;
        }

        int d = Math.abs(cities[0]);
        for (int i = 1; i < N; i++) {
            d = gcd(d, Math.abs(cities[i]));
        }
        System.out.println(d);
    }

    private int gcd(int x, int y) {
        if (y > x) {
            return gcd(y, x);
        }
        int m = x % y;
        if (m == 0) {
            return y;
        } else {
            return gcd(y, m);
        }
    }

    static class CustomReader extends BufferedReader {
        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

        public char[][] readAsCharMatrix(int rows) throws IOException {
            char[][] matrix = new char[rows][];
            for (int i = 0; i < rows; i++) {
                matrix[i] = this.readLine().toCharArray();
            }
            return matrix;
        }

    }

}

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

// B - Battle
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int tern = 0;
    while(true) {
        if (A <= 0) {
            cout << "No";
            return 0;
        }
        if (C <= 0) {
            cout << "Yes";
            return 0;
        }
        if (tern % 2 == 0) {
            C -= B;
        } else {
            A -= D;
        }
        tern++;
    }
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i;
    string s1;
    cin>>s1;
    for(i=0;i<s1.size();i++)
    {
      if(s1[i]=='?')
      {
          s1[i]='D';
      }
    }
    cout<<s1<<endl;


}

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

int main() {
    int n; long long c; cin >> n >> c;
    vector<long long> x(n), sum(n+1, 0);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        sum[i+1] = sum[i] + x[i];
    }
    long long ans = 1e18;
    for (long long k = n; k > 0; k--) {
        long long t = n;
        long long cur = (k+n) * c;
        for (int i = 0; t > 0; i++) {
            long long s = min(k, t);
            long long y = (i == 0 ? 5 : (2*i+3));
            cur += (sum[t] - sum[t-s]) * y;
            t -= s;
            if (ans < cur) break;
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
    return 0;
}

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

const int MAXN = 18;
const int MAXM = 1 << MAXN;
int N;
int M;

int A[MAXM];

int ans[MAXM];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	M = 1 << N;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}

	for (int m = 0; m < M; m++) {
		int v[2] = {};
		for (int s = m; true; s = (s-1) & m) {
			int a = A[s];
			for (int i = 0; i < 2; i++) {
				if (a > v[i]) {
					swap(a, v[i]);
				}
			}
			if (s == 0) break;
		}
		ans[m] = v[0] + v[1];
	}

	for (int m = 1; m < M; m++) {
		ans[m] = max(ans[m], ans[m-1]);
	}

	for (int m = 1; m < M; m++) {
		cout << ans[m] << '\n';
	}

	return 0;
}

Measured memory_bytes: 5248
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <iomanip>
using namespace std;

#define abs(x) ((x)>=0?(x):-(x))
#define i64 long long
#define u32 unsigned int
#define u64 unsigned long long
#define clr(x,y) memset(x,y,sizeof(x))
#define PI acos(-1.0)
#define sqr(x) ((x)*(x))
#define mod 1000000007
#define maxn 2005

struct node
{
  int v,next;
};
node e[maxn * 2 ];
int head[maxn];
int cnt;
int ind[maxn];
void init()
{
  memset(head,-1,sizeof(head));
  cnt = 0;
}
void add(int u ,int v  )
{
  e[cnt].v = v ;
  e[cnt].next = head[u];
  head[u] = cnt ++ ;

  return ;
}
int col[maxn];
int dfn[maxn],low[maxn];
int st[maxn];
int top;
int scnt;
int dep ;
bool instack[maxn];
int mp[maxn][maxn];

void tarjan(int u)
{
  //printf("u = %d\n",u);
  dfn[u]=low[u]=dep++;
  st[++top]=u;
  instack[u]=true;
  int v;
  for(int i = head[u]; i != -1; i = e[i].next)
  {
    v = e[i].v;
    if (dfn[v]==-1)
    {
      tarjan(v);
      low[u]=min(low[u],low[v]);
    }
    else if (instack[v]) low[u]=min(low[u],dfn[v]);
  }
  if (dfn[u]==low[u])
  {
    int x;
    do
    {
      x=st[top--];
      instack[x]=false;
      col[x]=scnt;
    }
    while (x != u);
    scnt++;
  }
  return ;
}
int n,m;
void base()
{
  memset(dfn,-1,sizeof(dfn));
  memset(instack,0,sizeof(instack));
  top = 0 ;
  scnt = 1 ;
  dep = 0 ;
  for(int i = 1 ; i <= n ; i ++ )
  {
    if(dfn[i] == -1)
    {
      tarjan(i);
    }
  }
  memset(mp,0,sizeof(mp));
  memset(ind,0,sizeof(ind));
  for(int i = 1 ; i <= n ; i ++ )
  {
    for(int j = head[i] ; j != -1 ; j = e[j].next)
    if(col[e[j].v] != col[i])
    {
      ind[col[i]] ++ ;
      mp[col[e[j].v]][col[i]] = 1 ;
     // printf("%d %d\n",col[e[j].v],col[i]);
    }
  }
}
i64 dfs(int u )
{
  i64 res,tmp;
  res = 1 ;
  for(int i = 1 ; i <  scnt ; i ++ )
    if(mp[u][i] == 1 && i != u  )
    {
      tmp = dfs(i);
      res = (res * tmp) % mod;
    }
  res = (res + 1 ) % mod ;
  return res ;
}
int main()
{
  int u,v;
  //while(

        scanf("%d%d",&n,&m)
        ;//!=EOF)
  {
    init();
    for(int i = 0; i < m; i ++ )
    {
      scanf("%d%d",&u,&v);
      add(u,v);
    }
    base();
    i64 ans ,tmp;
    ans = 1 ;
    for(int i = 1; i < scnt ; i ++ )
    if(ind[i] == 0)
    {
      tmp = dfs(i);
      //printf("tmp = %d\n",tmp);
      ans = (ans * tmp) % mod ;
    }
    ans = ans % mod;
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 16952
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * https://abc061.contest.atcoder.jp/tasks/abc061_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Node[] nodes = new Node[N];
		for(int i=0; i<N; i++) nodes[i] = new Node();
		for(int i=0; i<M; i++){
			Node a = nodes[sc.nextInt()-1];
			Node b = nodes[sc.nextInt()-1];
			a.neighbor.add(b);
			b.neighbor.add(a);
		}
		sc.close();
		
		for(Node n:nodes){
			System.out.println(n.neighbor.size());
		}

	}
	
	static class Node{
		List<Node> neighbor = new ArrayList<>();
	}

}


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

int main() {
    int s, d;
    char c;
    double px = 0.0, py = 0.0;
    double dir = 90.0;

    while(cin >> s >> c >> d) {
        if(s == 0 && d == 0) break;
        px += cos(dir * M_PI / 180.0) * s;
        py += sin(dir * M_PI / 180.0) * s;
        dir -= d;
    }
    cout << static_cast<int>(px) << endl;
    cout << static_cast<int>(py) << endl;
    return 0;
}

Measured memory_bytes: 3332
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    char N[200];
    fgets(N, sizeof(N), stdin);

    char tmp[10];
    fgets(tmp, sizeof(tmp), stdin);
    int K = atoi(tmp);

    int a = 1;

    int b[4] = { 0 };
    b[0] = 1;
    b[1] = N[0] - '1';

    for (int i = 1; i < strlen(N) - 1; i++) {
        int t = N[i] - '0';
        for (int j = K - 1; j > -1; j--) {
            b[j + 1] += b[j] * 9;
        }
        if (t != 0) {
            if (a + 1 <= K) b[a + 1] += t - 1;
            if (a <= K) b[a] += 1;
            a++;
        }
    }

    printf("%d\n", b[K] + (a == K ? 1 : 0));
}


Measured memory_bytes: 256