akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}

void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	int ans=0;
	for(int i=a;i<=b;i++)if(i%c==0)ans++;
	cout<<ans<<endl; 
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	while(numberofsubtestcases--){
		solve();
	}
}

Measured memory_bytes: 3656
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int a,b;
    int d,r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
}


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

const int INF = ~(1 << 31);

//articulation_point
vector< vector< int > > edge;
vector< int > dfs, lw;
vector< int > ap;
int v, e, s, t, cnt;
int root = 0;

int rec(int v){
	
	dfs[v] = cnt;
	++cnt;
	
	int lmin = INF;
	int lmax = 0;
	int count = 0;
	
	for(vector< int >::iterator it = edge[v].begin(); it != edge[v].end(); ++it){
		if(dfs[*it] == 0){
			int l = rec(*it);
			lmin = min(lmin, l);
			lmax = max(lmax, l);
			++count;
		}
	}
	
	if(v == root){
		if(count >= 2) ap.push_back(root);
	}else if(lmax >= dfs[v]) ap.push_back(v);
	
	for(vector< int >::iterator it = edge[v].begin(); it != edge[v].end(); ++it){
		lmin = min(lmin, dfs[*it]);
	}
	
	lmin = min(lmin, dfs[v]);
	lw[v] = lmin;
	
	return lw[v];
}

int main(){
	
	cin >> v >> e;
	edge.resize(v);
	dfs.resize(v);
	lw.resize(v);
	ap.clear();
	
	for(int i = 0; i < e; ++i){
		cin >> s >> t;
		edge[s].push_back(t);
		edge[t].push_back(s);
	}
	
	cnt = 1;
	
	rec(root);
	
	sort(ap.begin(), ap.end());
	
	for(vector< int >::iterator it = ap.begin(); it != ap.end(); ++it){
		cout << *it << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  int a,b,c;
  cin >> a >> b >> c;

  if (a+b+c>=22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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



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

	ll n,m; cin >> n >> m;

	cout << (n)*(n-1)/2 + m*(m-1)/2 << endl;
}


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

int n,m,q;
vector<int> a,b,c,d;
int ans=0;

void dfs(vector<int> A){
  if(A.size()==n+1){
    int cal=0;
    for(int i=0;i<q;++i){
      if(A[b[i]]-A[a[i]]==c[i]) cal+=d[i];
    }
    ans=max(ans,cal);

    return;
  }
  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }

}

int main(){
  cin >> n >> m >> q;
  a=b=c=d=vector<int>(q);
  for(int i=0;i<q;++i){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
import sys
inf = 10 ** 20; INF = float("INF"); ans = 0
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

h, w = wi()
s = []
for i in range(h):#h:高さ
    s.append([str(m) for m in list(input())])

numj = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):
        if j == 0:
            if s[i][j] != "#":
                numj[i][j] += 1
        elif s[i][j] != "#":
            numj[i][j] += numj[i][j - 1] + 1
        else:
            numj[i][j] = 0
    for j2 in range(w - 2, -1, -1):
        if s[i][j2] != "#":
            if s[i][j2 + 1] != "#":
                numj[i][j2] = numj[i][j2 + 1]

numi = [[0 for _ in range(w)] for _ in range(h)]
for j in range(w):
    for i in range(h):
        if i == 0:
            if s[i][j] != "#":
                numi[i][j] += 1
        elif s[i][j] != "#":
            numi[i][j] += numi[i - 1][j] + 1
        else:
            numi[i][j] = 0
    for i2 in range(h - 2, -1, -1):
        if s[i2][j] != "#":
            if s[i2 + 1][j] != "#":
                numi[i2][j] = numi[i2 + 1][j]

for i in range(h):
    for j in range(w):
        ans = max(ans, numj[i][j] + numi[i][j])


print(ans - 1)

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

struct Line {
    int m;
    vector<Pair> P, R;
    Line(int _m) : m(_m) {}
    void add(int x, int y) {
        P.emplace_back(x, y);
    }
    void rotate() {
        for(auto &p : P) {
            swap(p.first, p.second);
            p.first = -p.first;
        }
    }
    void start() {
        R.clear();
        for(int i = 0; i < m - 1; ++i) {
            int dx = P[i + 1].first - P[i].first;
            int dy = P[i + 1].second - P[i].second;
            R.emplace_back(dx, dy);
        }
    }
    bool match(Line &a) {
        if(m != a.m) return false;
        for(int i = 0; i < m - 1; ++i) {
            if(R[i] != a.R[i]) return false;
        }
        return true;
    }
    bool matchReverse(Line &a) {
        if(m != a.m) return false;
        for(int i = 0; i < m - 1; ++i) {
            if(R[m - i - 2] != a.R[i]) return false;
        }
        return true;
    }
};

void solve(int n) {
    vector<Line> L;
    rep(i, n) {
        int m; cin >> m;
        Line l(m);
        rep(j, m) {
            int x, y;
            cin >> x >> y;
            l.add(x, y);
        }
        l.start();
        L.push_back(l);
    }
    vector<int> ans;
    rep(_, 4) {
        for(int i = 1; i < n; ++i) {
            if(L[0].match(L[i])) ans.push_back(i);
            if(L[0].matchReverse(L[i])) ans.push_back(i);
        }
        L[0].rotate();
        L[0].start();
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    for(auto &a : ans) cout << a << '\n';
    cout << "+++++" << '\n';
}

int main() {
    int n;
    while(1) {
        cin >> n;
        if(!n) break;
        solve(n + 1);
    }
    return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    vl parent;  //親ノード
    vl Siz;  //集合の大きさ

    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1LL) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {

        x = root(x);
        y = root(y);

        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
    
};

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

    vl p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind Uni(n);
    Uni.init(n);

    rep(i, m) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        Uni.unite(x, y);
    }

    ll ans = 0;
    rep(i, n) {
        if(Uni.same(i, p[i])) {
            ans++;
        }
    }

    out(ans);    
    re0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int a[30],b[30],dp[31][1<<16];

int count(int bits){
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits =(((bits >> 4) + bits) & 0x0f0f0f0f);
  bits += bits >> 8;
  return (bits + (bits >> 16)) & 0xff;
}

int main(void){
  
  int n,c,in;
  
  while(cin >> n >> c,n|c){
    
    fill(a,a+n,0);
    fill(b,b+c,0);

    for(int i=0;i<n;i++){
      for(int j=0;j<16;j++){
	cin >> in;
	a[i] |= in<<(15-j);
      }
    }

    for(int i=0;i<c;i++){
      for(int j=0;j<16;j++){
	cin >> in;
	b[i] |= in<<15-j;
      }
    }

    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;

    for(int i=0;i<n;i++){
      for(int j=0;j<(1<<16);j++){
	if(dp[i][j]<0)continue;

	int now=a[i]|j;
	for(int k=0;k<c;k++){
	  int next=now & ~b[k];
	  dp[i+1][next]=max(dp[i+1][next],dp[i][j]+__builtin_popcount(now & b[k]));
	}
      }
    }

    int ans=0;
    for(int i=0;i<(1<<16);i++){
      ans=max(ans,dp[n][i]);
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 9108
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	long long n;
	scanf("%lld",&n);
	long long minn = 0x3f3f3f3f3f3f3f3f;
	for(int i = 1; i <= sqrt(n); i++){
		if(n%i == 0){
			minn = min(minn,i+(n/i)-2);
//			cout<<i<<" "<<n/i<<endl;
		}
	}
	printf("%lld\n",minn);
	return 0;
}


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

int main(){
	int a, b, c, k;
	int new_max;
	int org_max;
	int sum;
	cin >> a >> b >> c >> k;
	new_max = max(c, max(a, b));
	org_max = new_max;
	sum = a + b + c;
	for(int i = 0; i < k; i++){
		new_max *= 2;
	}
	sum += new_max - org_max;
	cout << sum;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  vector<int> b(n);
  b[n/2] = a[0];
  for(int i=1;2*i<n+1;i++) {
    if(n%2==0) {
      if(2*i==n) b[n/2-i] = a[2*i-1];
      else {
        b[n/2+i] = a[2*i];
        b[n/2-i] = a[2*i-1];
      }
    } else {
      b[n/2-i] = a[2*i];
      b[n/2+i] = a[2*i-1];
    }
  }

  for(int i=0;i<b.size();i++) cout << b[i] << endl;
}

Measured memory_bytes: 3712
#include <stdio.h>
int main(void)


{
	double pi, are, circ, r;
	pi = 3.141592653589;
	scanf("%lf", &r);
	are = r*r*pi;
	circ = r*2*pi;
	printf("%f %f\n", are,circ);

	return 0;
}

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

int main() {
  int n; cin >> n;
  bool flag = false;
  vector<pair<int,int>> vec(n);

  rep(i,n){
    cin >> vec[i].first;
    cin >> vec[i].second;
  }

  /*rep(i,n){
    cout << vec[i].first << " " << vec[i].second << endl;
  }*/

  rep(i,n-2){
    if(vec[i].first != vec[i].second) continue;
    if(vec[i+1].first != vec[i+1].second) continue;
    if(vec[i+2].first != vec[i+2].second) continue;
    flag = true;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <functional>
#include <iostream>

int main(int argc, char *argv[]) {
  int N;
  int A[101];

  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }

  std::sort(A, A + N, std::greater<int>());

  int a_total=0, b_total=0;
  for (int i = 0; i < N; ++i) {
    if (i%2==0) a_total +=A[i];
    else b_total += A[i];
  }

  std::cout << abs(a_total - b_total) << std::endl;
}


Measured memory_bytes: 256
import sys

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

def main():
    n, k = map(int, input().split())
    cst = list(map(int, input().split()))
    arr = [0] * n
    arr[1] = abs(cst[1] - cst[0])
    for i in range(2, n):
        arr[i] = min(abs(cst[j] - cst[i]) + arr[j] for j in range(max(i - k, 0), i))
    print(arr[n - 1])
if __name__ == '__main__':
    main()


Measured memory_bytes: 14052
#include<stdio.h>
#include<string.h>
int cmp(const void* a,const void* b){
	if(strcmp((char*)a,(char*)b)<0)
		return 0;
	return 1;
}
int main(){
	int n,l;
	scanf("%d %d",&n,&l);
	char a[n][l+1];
	int i;
	for(i=0;i<n;i++)
		scanf("%s",a[i]);
	qsort(a,n,sizeof(a[0]),cmp);
	for(i=0;i<n;i++)
		printf("%s",a[i]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,k,ans=0;cin>>n;
  int a[n];
  bool u[n],c[n],q[n];
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  memset(c,0,sizeof(c));
  memset(q,0,sizeof(q));
  for(i=0;i<n;i++){
    if(q[i]) continue;
    j=i;
    memset(u,0,sizeof(u));
    while(!((!u[j]&&q[j])||c[j])){
      if(u[j]) c[j]=1;
      u[j]=1;q[j]=1;     
      j=(j+a[j])%n;
    }
  }
  for(i=0;i<n;i++) ans+=c[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3920
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N;

int main() {
  cin >> N;
  int ans = 0;
  rep(i, 0, N) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{

    int num;
    string word;
    cin>>num;cin>>word;
    for(int i=1;i<word.length();)
    {
        if(word[i]==word[i-1])
            word.erase(word.begin()+i-1,word.begin()+i);
        else
            i++;
    }
    cout<<word.length()<<endl;
    return 0;
}



Measured memory_bytes: 512
n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(int(input()))
a = set(a)
mod = 10**9+7

dp = [0]*(n+10)
dp[0] = 1
for i in range(n):
    if not i+1 in a:
        dp[i+1] = (dp[i+1] + dp[i])%mod
    if not i+2 in a:
        dp[i+2] = (dp[i+2] + dp[i])%mod
print(dp[n])

Measured memory_bytes: 13216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    string S, tmp;
    int t;
    cin >> N >> S;
    for (int i = 0; i < 4; i++) {
        if(i % 2 == 0){
            tmp = 'S';
        }
        else{
            tmp = 'W';
        }
        if((i/2) % 2 == 0){
            tmp += 'S';
        }
        else{
            tmp += 'W';
        }

        for (int j = 2; j < N; j++) {
            t = 0;
            if(tmp[j-2] == 'W') t++;
            if(tmp[j-1] == 'W') t++;
            if(S[j-1] == 'x') t++;
            if(t % 2 == 1){
                tmp += 'W';
            }
            else{
                tmp += 'S';
            }
        }
        t = 0;
        if(tmp[N-2] == 'W') t++;
        if(tmp[N-1] == 'W') t++;
        if(tmp[0] == 'W') t++;
        if(S[N-1] == 'x') t++;
        if(t % 2 == 0){
            t = 0;
            if(tmp[N-1] == 'W') t++;
            if(tmp[0] == 'W') t++;
            if(tmp[1] == 'W') t++;
            if(S[0] == 'x') t++;
            if(t % 2 == 0){
                printf("%s\n", tmp.c_str());
                return 0;
            }
        }

    }
    printf("-1\n");

}

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

void fnInput(int& rnShtHand, int& rnLngHand, int& rnHour, int& rnMinute)
{
  cin >> rnShtHand >> rnLngHand >> rnHour >> rnMinute;
}

double fnClockHandsDist(int nShtHand, int nLngHand, int nHour, int nMinute)
{
  static const double pi = 3.141592653589793;

  double nShtAngl = (nHour + (nMinute / 60.0)) / 12.0 * 360;
  double nLngAngl = (nMinute / 60.0) * 360;
  double nDiffAngl = abs(nShtAngl - nLngAngl);
  if (nDiffAngl > 180)
    nDiffAngl = 360 - nDiffAngl;

  double nHandsDist = nShtHand * nShtHand + nLngHand * nLngHand 
                      - 2 * nShtHand * nLngHand * cos(2 * pi * nDiffAngl / 360);
  return sqrt(nHandsDist);
}
  
int main()
{
  int nShtHand, nLngHand, nHour, nMinute;

  fnInput(nShtHand, nLngHand, nHour, nMinute);
  cout << fixed << setprecision(10) << fnClockHandsDist(nShtHand, nLngHand, nHour, nMinute);
  cout << endl;

  return 0;
}

Measured memory_bytes: 4172
open Batteries
let rec sum lst =
  match lst with
  | [] -> 0
  | first :: rest -> first + sum rest
let get i lst =
  let rec loop l p =
    match l with
    | [] -> []
    | first :: rest ->
      if i = p then [] else first :: loop rest (p+1)
  in loop lst 0
let xyabc = Scanf.sscanf (read_line()) "%d %d %d %d %d" (fun x y a b c ->
  [|x; y; a; b; c|]
)
let p = read_line () |> String.split_on_char ' ' |> List.map int_of_string |> List.sort compare |> List.rev |> get xyabc.(0)
let q = read_line () |> String.split_on_char ' ' |> List.map int_of_string |> List.sort compare |> List.rev |> get xyabc.(1)
let r = read_line () |> String.split_on_char ' ' |> List.map int_of_string |> List.sort compare |> List.rev
let all = List.append p q |> List.append r |> List.sort compare |> List.rev
let _ = Printf.printf "%d\n" @@ sum @@ get (xyabc.(0)+xyabc.(1)) all


Measured memory_bytes: 36896
from collections import defaultdict
import math
prm = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101]
alp = {chr(i):p for i,p in zip(range(97, 97+26),prm)}
n = int(input())
d = defaultdict(int)
nums = set([])
for _ in range(n):
  s = input()
  m = 1
  for l in s:
    m *= alp[l]
  d[m] += 1

def comb(n, r):
  if n<r:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0
for k in d.values():
  ans += comb(k,2)
print(ans)

Measured memory_bytes: 20756
#include<stdio.h>

#define MODN 1000000007

#define modml(lhs,rhs) ((long)((long long)(lhs)*(rhs)%MODN))

static inline long modpow(long num,long ind){
    unsigned long cnt = ind;
    long res = 1;
    while(cnt){
        if(cnt & 1ul)res = modml(res,num);
        num = modml(num,num);
        cnt >>= 1;
    }
    return res;
}

#define modsub(lhs,rhs) (((lhs)+MODN-rhs)%MODN)

int main(void){
    long n;
    scanf("%ld",&n);
    if(n == 1){
        puts("0");
        return 0;
    }
    long a = modpow(10,n);
    printf("%ld",modsub(modml(modsub(a,modpow(9,n)),2),modsub(a,modpow(8,n))));
}

Measured memory_bytes: 1732
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    long T = Long.parseLong(sc.next());
    long[] t = new long[N];
    t[0] = Long.parseLong(sc.next());
    long total =0;
    for (int i =1; i<N; i++) {
      t[i] = Long.parseLong(sc.next());
      if (t[i] - t[i-1] <= T) {
        total += t[i] - t[i-1];
      } else {
        total += T;
      }
    }
    total += T;
    System.out.println(total);
  }
}

Measured memory_bytes: 55244
#
# 

n, m = map(int, input().split())
g    = {}
ori  = []

for _ in range(m):
    u, v = map(int, input().split()) 
    ori.append((u, v))
    
    if u not in g:
        g[u] = []
    g[u].append(v)
    
    if v not in g:
        g[v] = []
    g[v].append(u)    
    
def solve(g, ori):
    p    = {}    
    p[1] = 1
    i    = 0
    S    = [1]

    used = [False] * (n+1)
    cnt  = [0]     * (n+1) 
    edge = []
    
    used[1] = True
    
    while i < len(S):
        cur     = S[i]
        
        for u in g[cur]:
            if used[u] == True: continue
            
            used[u] = True
            p[u] = cur
            S.append(u)
        i+=1
    
    for u, v in ori:
        if p[u] != v and p[v] != u:
            cnt[u] += 1
            edge.append((u, v))
        
    for u in S[::-1][:-1]:
        if cnt[u] % 2 == 0:
            edge.append((p[u], u))
            cnt[p[u]] += 1
        else:
            edge.append((u, p[u]))
            
            
    #print(S)
    #print(g)
    #print(p)
    return edge

s = ''
if m % 2 == 1:
    print('-1')
else:
    edge = solve(g, ori)
    for x, y in edge:
        s += str(x)+ ' '+str(y)+'\n'
    print(s)    

Measured memory_bytes: 54048
N = int(input())
W = list(map(int, input().split()))
sumA = 0
sumB = sum(W)
minD = 99999999
for i in range(0, N):
    sumA += W[i]
    sumB -= W[i]
    D = abs(sumA - sumB)
    minD = D if D < minD else minD
print(minD)

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

using namespace std;

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

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

#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    set<int> st;

    rep(i, m) {
        int a;
        cin >> a;
        st.insert(a);
    }

    int cost1, cost2;
    cost1 = cost2 = 0;

    REP(i, x, n) if (st.count(i)) cost1++;
    REP(i, 0, x) if (st.count(i)) cost2++;

    cout << min(cost1, cost2) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.lang.Math.abs
import java.lang.Math.min

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val hs = readLine()!!.split(" ").map(String::toInt)

    val inf = 10000000000;

    var dp = Array(n) { inf }
    dp[0] = 0

    for (index in 0 until n) {
        for (i in index + 1..index + k) {
            if (i < n)
                dp[i] = min(dp[i], dp[index] + abs(hs[i] - hs[index]));
        }
    }

    println(dp.last())
}


Measured memory_bytes: 120996
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n,m,k,res=0;
string str;
int main() {
	cout << fixed << setprecision(18);
    cin>>str;
    for(int i=0;i<str.length();i++){
        if(str[i]!=str[str.length()-i-1]){res++;str[i]=str[str.length()-i-1];}
        
    }
    cout<<res;
    
} 


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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;
const double PI = acos(-1);

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    int total = 0;
    int s = 1;
    while(total < n) {
        total += s;
        s += 1;
    }

    int dans = total - n;
    for(int i = s-1; i > 0; i--) {
        if(i != dans) cout << i << endl;
    }
}


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

int main(){
	int N;
	string S, T;
	cin >> N >> S >> T;
	for(int i=0;i<2*N;i++){
		if(i%2==0) cout << S[i/2];
		else cout << T[i/2];
	}
	cout << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int[] numbers = new int[3];
		numbers[0] = scanner.nextInt();
		numbers[1] = scanner.nextInt();
		numbers[2] = scanner.nextInt();

		Arrays.sort(numbers);
		
		System.out.println(numbers[0] + " " + numbers[1] + " " + numbers[2]);
	}
}

Measured memory_bytes: 26096
#include<stdio.h>
 
int main(){
    int N;
    int A,B;
    char T[100],H[100];
    int PT=0,PH=0;
    scanf("%d",&N);
    for(A=0;A<N;A++){
        scanf("%s %s",T,H);
        for(B=0;T[B] && H[B] && T[B]==H[B];B++);
        if(T[B]>H[B])
            PT+=3;
        else if(T[B]<H[B])
            PH+=3;
        else{
            PT++;
            PH++;
        }
    }
    printf("%d %d\n",PT,PH);
    return 0;
}


Measured memory_bytes: 2044
import sys
import math
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
a = []
b = []
for i in range(n):
    aa,bb = map(int,input().split())
    a.append(aa)
    b.append(bb)

a.sort()
b.sort()
if n%2==1:
    ans = b[n//2]-a[n//2]+1
    print(ans)
if n%2==0:
    ans = b[n//2]+b[n//2-1]-a[n//2]-a[n//2-1]+1
    print(ans)


Measured memory_bytes: 90968
#include<bits/stdc++.h>
using namespace std;
int cnt(int x){
	int res=0;
	while(x) res+=x%10,x/=10;
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	int ans=10000000;
	for(int i=1;i<n;i++){
		if(cnt(i)+cnt(n-i)<ans)
			ans=cnt(i)+cnt(n-i);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

bool check(int i, int j, int h, int w, const vector<string>& field) {
  if (field[i][j] == '.') return true;
  if (i > 0 && field[i - 1][j] == '#') return true;
  if (i < h - 1 && field[i + 1][j] == '#') return true;
  if (j > 0 && field[i][j - 1] == '#') return true;
  if (j < w - 1 && field[i][j + 1] == '#') return true;
  return false;
}

int main() {
  //
  int h, w;
  cin >> h >> w;
  vector<string> field(h);
  rep(i, h) cin >> field[i];
  rep(i, h) {
    rep(j, w) {
      if (!check(i, j, h, w, field)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
  vector<tuple<string,int,int>> list;
  int N,c = 1;
  cin >> N;
  for(int i=0;i<N;i++){
    string a;
  	int b;
    cin >> a >> b;
    list.push_back(make_tuple(a,-b,c));
    c++;
  }
  sort(list.begin(),list.end());
  for (tuple<string, int, int> t : list) {
    string x;
    int y, z;
    tie(x, y, z) = t;
    cout << z << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

#ifndef INT_MAX
#  define INT_MAX std::numeric_limits<int>().max()
#endif
#ifndef INT_MIN
#  define INT_MIN std::numeric_limits<int>().min()
#endif
#define LL_MAX std::numeric_limits<ll>().max()
#define LL_MIN std::numeric_limits<ll>().min()
#define INF LL_MAX

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
// 配列の初期化
#define ZERO(p) memset(p, 0, sizeof(p))
// 配列の初期化(-1)
#define MINUS(p) memset(p, 1, sizeof(p))

int N;
bool pattern[100][10005];
int S[10005];
int ans;

int dfs(int i, int s) {
    if(i >= N) { return s; }
    if(pattern[i][s]) { return s; }

    if((s + S[i]) % 10 != 0) { ans = max(ans, s + S[i]); }
    pattern[i][s] = true;
    dfs(i+1, s);
    dfs(i+1, s+S[i]);
    return 1;

}

int main()
{
    cin >> N;
    ZERO(pattern);
    REP(i, N) {
        cin >> S[i];
    }
    ans = 0;
    dfs(0, 0);

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

    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var ab = ReadLine().Split().Select(int.Parse).ToArray();
        var a = ab[0];
        var b = ab[1];
        var A = new int[999];
        for (int i = 1; i <= 999; i++)
        {
            A[i - 1] = i * (i + 1) / 2;
        }
        var d = b - a;
        for (int i = 0; i < 998; i++)
        {
            if (A[i + 1] - A[i] == d) WriteLine(A[i] - a);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>

int main(){
  int H,i;
  int A[250+1];
  
  scanf("%d",&H);
  for( i=1 ; i<=H ; i++ )
    scanf("%d",&A[i]);

  for( i=1 ; i<=H ; i++ ){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>0) printf("parent key = %d, ",A[i/2]);
    if(2*i<=H) printf("left key = %d, ",A[2*i]);
    if((2*i+1)<=H) printf("right key = %d, ",A[2*i+1]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
import sys
readline = sys.stdin.readline

INF = 10**30
def calc(k):
    if k in D:
        return D[k]
    if not k:
        return 0
    res = k*d
    if k != k//2 + 1:
        res = min(res, calc(k//2 + 1) + a + d*(2-k%2))
    if k != k//3 + 1:
        res = min(res, calc(k//3 + 1) + b + d*(3-k%3))
    if k != k//5 + 1:
        res = min(res, calc(k//5 + 1) + c + d*(5-k%5))
    
    if k >= 2:
        res = min(res, calc(k//2) + a + d*(k%2))
    if k >= 3:
        res = min(res, calc(k//3) + b + d*(k%3))
    if k >= 5:
        res = min(res, calc(k//5) + c + d*(k%5))
    D[k] = res
    return res
T = int(readline())
Ans = [None]*T
for qu in range(T):
    n, a, b, c, d = map(int, readline().split())
    D = dict()
    Ans[qu] = calc(n)
print('\n'.join(map(str, Ans)))

Measured memory_bytes: 100872
#include <bits/stdc++.h>
using namespace std;
int main()
{	
	int k,a,b;
	cin>>k>>a>>b;
	if(a>b)swap(a,b);
	if(b-(k+a)<=0)puts("0");
	else printf("%d",b-(k+a));
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N];

        for (int i = 0; i < N + 1; i++) A[i] = sc.nextInt();
        for (int i = 0; i < N; i++) B[i] = sc.nextInt();
        int[] AC = A.clone();
        long cnt = 0;

        for (int i = 0; i < N; i++) {
            if (A[i] >= B[i]) {
                A[i] -= B[i];
                B[i] = 0;
            } else {
                B[i] -= A[i];
                A[i] = 0;
            }

            if (A[i + 1] >= B[i]) {
                A[i + 1] -= B[i];
                B[i] = 0;
            } else {
                B[i] -= A[i + 1];
                A[i + 1] = 0;
            }
        }

        for (int i = 0; i < N + 1; i++) {
            cnt += AC[i] - A[i];
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 64844
K = int(input())
r = [[] for _ in range(10)]
r[0] = list(range(1,10))
for i in range(9):
    for a in r[i]:
        s = str(a)
        d = a%10
        for j in range(d-1,d+2):
            if not 0 <= j <= 9: continue
            r[i+1].append(int(s+str(j)))

for i in range(10):
    if K >= len(r[i]):
        K -= len(r[i])
    else:
        print(r[i][K-1])
        break

Measured memory_bytes: 11036
#include <bits/stdc++.h>
#define INF 10000
using namespace std;

int main(){
  int N,M; cin>>N>>M;

  vector<int> c(M+1);
  for(int i=1; i<=M; i++) cin >> c[i];

  vector<int> dp(N+1, INF);
  dp[0] = 0;
  
  for(int i=1; i<=N; i++){
    for(int j=1; j<=M; j++){ 
      if(i>=c[j]){
        dp[i] = min(dp[i], dp[i-c[j]]+1);
      }
    }
  }
  
  cout << dp[N] <<endl; 
}


Measured memory_bytes: 3180
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
    int N,K;
    cin>>N>>K;
    map<int,int> A;

    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        A[a]++;
    }

    vector<int> V;
    for(map<int,int>::iterator it = A.begin();it != A.end();it++) {
        V.push_back(it ->second);
    }

    sort(V.begin(),V.end(),greater<int>());

    long long int sum = 0;
    for(int i = K;i < V.size();i++) {
        sum += V[i];
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long n,temp,sum=0;
    cin>>n;
    temp=n;
    while(temp>0)
    {
        sum+=temp%10;
        temp=temp/10;
    }
    if((n%sum)==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

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;}

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

  reverse(ALL(s));
  rep(i,4) reverse(ALL(divide[i]));

  bool can = true;
  rep(i,s.size()) {
    bool can2 = false;
    rep(j,4) {
      string d = divide[j];
      if (s.substr(i,d.size()) == d) {
        can2 = true;
        i += d.size()-1;
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }

  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(),x=s.nextInt();
        long total=0;
        int arr[] = new int[n];
        for(int i=0;i<n;i++)arr[i]=s.nextInt();
        for(int i=1;i<n;i++){
            int sum = arr[i]+arr[i-1];
            if(sum>x){
                int diff = sum-x;
                total+=diff;

                if(arr[i]-diff>=0){
                    arr[i]-=diff;
                }
                else{
                    arr[i]=0;
                }
            }
        }
        System.out.println(total);
    }


}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

const int MOD = 1e9 + 7;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);

    int dp[n + 2][n + 1][k + 1];
    memset(dp, 0, sizeof(dp));

    auto add = [&] (int &a, int b) {
        a += b;

        if(a >= MOD)
            a -= MOD;
    };

    dp[n + 1][0][k] = 1;
    for(int i = n; i > 0; i--) {
        for(int m = 0; m < i; m++) {
            for(int c = 0; c <= k; c++) {
                if(c + 2 * m <= k)
                    add(dp[i][m][c], dp[i + 1][m][c + 2 * m]);

                if(m > 0 && c + 2 * (m - 1) <= k)
                    add(dp[i][m][c], 1LL * dp[i + 1][m - 1][c + 2 * (m - 1)] * m % MOD * m % MOD);

                if(c + 2 * (m + 1) <= k)
                    add(dp[i][m][c], dp[i + 1][m + 1][c + 2 * (m + 1)]);
                
                if(c + 2 * m <= k)
                    add(dp[i][m][c], 2LL * dp[i + 1][m][c + 2 * m] % MOD * m % MOD);
            }
        }
    }
    
    printf("%d\n", dp[1][0][0]);
    return 0;
}

Measured memory_bytes: 26112
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vstr s(3);
    rep(i, 3) cin >> s[i];

    int ans = 0;
    rep(i, n) {
        map<char, int> mp;
        rep(j, 3) {
            mp[s[j][i]]++;
        }
        ans += mp.size()-1;
    }


    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >>n;
  vector<int> a(n);
  int64_t sum=0;
  rep(i,n) {
    cin >> a[i];
    sum+=ll(a[i]);
  }
  int64_t res=0;
  rep(i,n-1){
    sum-=ll(a[i]);
    res+=int64_t(sum%(1000000007))*int64_t(a[i]);
    res=res%(1000000007);
  }
  cout << res <<endl;
}


Measured memory_bytes: 4044
#include<cstdio>
#include<algorithm>
using namespace std;

int arr[111111];
int main(){
    int n; scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",arr+i);

    int x = *max_element(arr,arr+n);
    int d = x/2, y = -1;
    for(int i=0;i<n;i++){
        if(abs(d-y) > abs(d-arr[i]) && arr[i] != x)
            y = arr[i];
    }

    printf("%d %d\n", x, y);
}


Measured memory_bytes: 512
def toll_gates(N: int, M: int, X: int, A: list) -> int:
    to0 = sum(1 for a in A if a < X)
    toN = sum(1 for a in A if a > X)
    return min(to0, toN)


if __name__ == "__main__":
    N, M, X = map(int, input().split())
    A = list(map(int, input().split()))
    ans = toll_gates(N, M, X, A)
    print(ans)


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    
    cout << a << " " << b << " " << c << "\n";
    
    return 0;
}

// scanf("%d %d", &a, &b)
// printf("%d %d", 123, 456);

// getline(cin, s)
// while (cin >> x) {...} - read unknown data

// vector. vector[i],
// set. insert(), contains == set.find(x) != set.end(), size_t size() or count(x) 
// map. contains == count(x) ?


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 310;
int dp[N][N][N];

int main() {
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();

    string t = s;
    reverse(ALL(t));

    REP(i,n+1) REP(j,n+1) REP(x,k+1){
        dp[i+1][j][x] = max(dp[i+1][j][x], dp[i][j][x]);
        dp[i][j+1][x] = max(dp[i][j+1][x], dp[i][j][x]);
        if (i < n && j < n && s[i] == t[j]) dp[i+1][j+1][x] = max(dp[i+1][j+1][x], dp[i][j][x] + 1);
        dp[i+1][j+1][x+1] = max(dp[i+1][j+1][x+1], dp[i][j][x] + 1);
    }

    int ans = 0;
    REP(i,n+1){
        ans = max(ans, 2 * dp[i][n-i][k]);
    }
    REP(i,n){
        ans = max(ans, 2 * dp[i][n-1-i][k] + 1);
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N;
  cin>>N;
  int A=0;
 for (int i = 0; i < 30; i++) {
  int x;
    
  x = std::pow(10,i);
    int y;
  y=N/x;
   int z;
   z=y%10;
   A+=z;
}
if(N%A==0){cout<<"Yes"<<endl;
          }
  else{cout<<"No"<<endl;}
}



Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OneoutofThree
{
    class OneoutofThree
    {
        static void Main(string[] args)
        {
            string[] strBuf = Console.ReadLine().Split(' ');

            var lst = new List<int>();

            lst.Add(int.Parse(strBuf[0]));
            lst.Add(int.Parse(strBuf[1]));
            lst.Add(int.Parse(strBuf[2]));


            //if (lst[0] == lst[1])
            //{
            //    Console.WriteLine(lst[2]);
            //    return;
            //}

            //if (lst[0] == lst[2])
            //{
            //    Console.WriteLine(lst[1]);
            //}
            //else
            //{
            //    Console.WriteLine(lst[0]);
            //}

            //return;

            var lstSorted = lst.GroupBy(x => x).Where(x => x.Count() == 1).Select(x => x.Key).ToList();

            Console.WriteLine(lstSorted[0]);
            return;
        }
    }
}


Measured memory_bytes: 13524