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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n, k;
  cin >> n >> k;
  if (k > 1000) k = 1000;
  vector<int> a(n);

  arep(i, a) cin >> i;

  rep(i, 0, k) {
    vector<int> next(n + 1, 0);
    rep(j, 0, n) {
      // cout << j - a[j] << ' ';
      if (a[j] == 0) {
        next[j]++;
        next[j + 1]--;
        // cout << j << ' ';
        // cout << j + 1 << ' ';
      } else {
        if (j - a[j] < 0) {
          next[0]++;
          // cout << 0 << ' ';
        } else {
          next[j - a[j]]++;
          // cout << j - a[j] << ' ';
        }
        // cout << j + 1 + a[j] << ' ';
        if (j + 1 + a[j] < n) next[j + 1 + a[j]]--;
      }
      // cout << '\n';
    }
    rep(j, 0, n) {
      a[j] = next[j];
      next[j + 1] += next[j];
      // cout << next[j] << ' ';
      // cout << a[j] << ' ';
    }
    // cout << '\n';
  }

  rep(i, 0, n) cout << a[i] << ' ';
  cout << '\n';
  return 0;
}

Measured memory_bytes: 6272
N = int(input())
h = list([int(x) for x in input().split()])

result = {0: 0}

for i in range(N-1):
    next_target = i + 1
    while next_target < N and next_target <= i + 2:
        cost = result[i] + abs((h[next_target] - h[i]))
        if not next_target in result:
            result[next_target] = cost
        else:
            if cost < result[next_target]:
                result[next_target] = cost
        next_target += 1

print(result[N-1])


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

int main(){
  int N;
  cin >> N;
  string S;
  set<string> a;
  for(int i = 0; i < N; i++){
    cin >> S;
    a.insert(S);
  }
  cout << a.size() << endl;
  return 0;
}

Measured memory_bytes: 19184
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,p,a[111];
LL cur[111][2];
int main()
{
	get2(n,p);
	cur[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		cur[i][0]=cur[i-1][0];cur[i][1]=cur[i-1][1];
		get1(a[i]);
		if(a[i]%2)
		{
			cur[i][0]+=cur[i-1][1];
			cur[i][1]+=cur[i-1][0];
		}
		else
		{
			cur[i][0]+=cur[i-1][0];
			cur[i][1]+=cur[i-1][1];
		}
	}
	printendl(cur[n][p]);
	return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = InputNumList();
            var max = abc.Max();
            var k = InputNum();

            for (int i = 0; i < k; i++)
            {
                max *= 2;
            }

            WriteLine(max + abc.Sum() - abc.Max());
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007
int a[2001][2001];
using namespace std;


int main() {
	lli n;
	cin>>n;
	vector<lli> vec(n),ans(n+1);
	rep0(i,n)cin >> vec[i];
	lli temp;
	ans[0]=temp=min(vec[0],vec[n-1])/2;

		int i=0;
		for(;i<n;i++){
			ans[i+1]=vec[i]-ans[i];
		}
		ans[0]=(ans[0]+ans[n])/2;

		for(int i=0;i<n;i++){
			ans[i+1]=vec[i]-ans[i];
		}
	rep0(i,n)cout << ans[i]*2 << '\n';
	
}


Measured memory_bytes: 2816
#include<iostream>
#include<string>

using namespace std;

int main(){
    int N, Q;
    cin >> N >> Q;
    string ans = "kogakubu10gokan";
    while(N--){
        int year;
        string name;
        cin >> year >> name;
        if(!(year > Q)) ans = name;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, H[100000]; cin >> N;
  REP(i, N) cin >> H[i];

  int ans = 0, cnt = 0, hei = H[0];
  for(int i = 1; i < N; i++){
    if(hei < H[i]){
      ans = max(ans, cnt);
      cnt = 0;
    } else {
      cnt++;
    }
    hei = H[i];
  }
  ans = max(ans, cnt);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
pair<double,double> dp[1005][1005];
int main(){
	int r,d,a;
    cin>>r>>d>>a;
    REP(i,10){
        a=r*a-d;
        OUT(a);
    }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
int main(){
	ll n,s,t;
	cin>>n>>s>>t;
	ll out=0;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,n-1){
		ll a=(in[i+1]-in[i])*s;
		out+=min<ll>(a,t);
	}
	cout<<out<<endl;
}
















Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 2e5 + 100;

void nhap()
{


}

void solve()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x & 1) {
            cout << "first";
            return;
        }
    }
    cout << "second";
}
int main()
{
    nhap();
    solve();
}


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;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  vector<int> right(N - 1);
  vector<int> left(N - 1);
  right[0] = A[0];
  for(int i = 0; i < N - 2; i++) {
    right[i + 1] = gcd(right[i], A[i + 1]);
  }

  vector<int> R(N);
  for(int i = 0; i < N; i++) {
    R[N - 1 - i] = A[i];
  }
  left[0] = R[0];
  for(int i = 0; i < N - 2; i++) {
    left[i + 1] = gcd(left[i], R[i + 1]);
  }
  int ans = max(right[N - 2], left[N - 2]);
  // iはぬくやつ
  for(int i = 1; i < N - 1; i++) {
    int tmp = gcd(right[i - 1], left[N - i - 2]);
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=998244353;
int main(){
  ll n;cin>>n;
  ll cnt[5];
  for(int i=0;i<3;i++) cnt[i]=0;
  ll ans=1;
  string s;
  cin>>s;
  for(int L=0;L<3*n;L++){
    char c=s[L];
    int kn;
    if(c=='R') kn=0;
    if(c=='G') kn=1;
    if(c=='B') kn=2;

    vector<P> pv;
    for(int j=0;j<3;j++) pv.push_back(P(cnt[j],j));
    sort(pv.begin(),pv.end());

    if(pv[0].second==kn){
      if(pv[1].first==pv[0].first){
        if(pv[2].first==pv[1].first) {
          cnt[kn]++;
          continue;
        }
        else ans*=pv[2].first-pv[0].first;
      }
      else ans*=pv[1].first-pv[0].first;
    }
    else if(pv[1].second==kn){
      if(pv[1].first==pv[2].first) {
        cnt[kn]++;
        continue;
      }
      else ans*=pv[2].first-pv[1].first;
    }
    ans%=mod;
    cnt[kn]++;
  }
  for(ll i=1;i<=n;i++){
    ans*=i;
    ans%=mod;
  }
  cout<<ans<<endl;
}


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0;
  int m = 0;
  for(int i = 0; i < n; i++){
    if(s.at(i)=='I')x++;
    else x--;
    m = max(x,m);
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

int gcd(int c,int d){
    return d ? gcd(d, c % d) : c;
}



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

    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0;i < n;i ++) cin >> h.at(i);

    if(n == 1){
        cout << h.at(0) << endl;
        return 0;
    }

    int ans = 0;
    ans += h.at(0);
    for(int i = 1;i < n;i ++){
        if(h.at(i) > h.at(i-1)) ans += h.at(i) - h.at(i-1);
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int abs(int a, int b){
    int c;
    if(a <= b){
        c = b - a;
    } else {
        c = a - b;
    }
    return c;
}

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a, b) <= d && abs(b, c) <= d) || abs(a, c) <= d){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#pragma region
typedef long long ll;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define rep(i, begin, end)                              \
    for (__typeof(end) i = (begin) - ((begin) > (end)); \
         i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define REP(i, j) rep(i, 0, j)
#define testcase \
    int _;       \
    cin >> _;    \
    while (_--)
#define io                            \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    if (fopen("./input.txt", "r")) freopen("./input.txt", "r", stdin);
#define en '\n'
#pragma endregion

int main() {
    io;
    string a, b;
    cin >> a >> b;
    int res = 0;
    REP(i, a.length()) if (a[i] != b[i]) res++;
    cout << res;
    return 0;
}

Measured memory_bytes: 3764
using System;

public class ITP1_9_B
{
    static void Main()
    {
        while (true)
        {
            String str = Console.ReadLine();
            if (str == "-") break;
            int m = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
            {
                int h = int.Parse(Console.ReadLine());
                string left = str.Substring(0, h);
                string right = str.Substring(h);
                str = right + left;
            }
            Console.WriteLine(str);
        }
    }
}

Measured memory_bytes: 8968
#include <iostream>
#include <vector>
#include <algorithm>
// #include <string>
// #include <map>
// #include <set>
// #include <cmath>


using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    int x = N * 800;
    int y = (N / 15) * 200;
    cout << x - y << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    int a[2];
    cin >> a[0] >> a[1];

    int ans = 0;
    rep(i, 2) {
        if (a[i] <= 3) ans += (4 - a[i]) * 100000;
    }
    if (a[0] == 1 && a[1] == 1) ans += 400000;
    cout << ans << endl;
}


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

int main()
{
    string S;
    cin >> S;
    
    if (S == "SUN") cout << 7;
    if (S == "MON") cout << 6;
    if (S == "TUE") cout << 5;
    if (S == "WED") cout << 4;
    if (S == "THU") cout << 3;
    if (S == "FRI") cout << 2;
    if (S == "SAT") cout << 1;
    cout << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
signed main()
{
    cin >> N;
    printf("%lld\n", N/3);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }
}

class Program {
   public static void Main(string[] args) {
      var arr = ReadLine().Split(' ').Select(x => x.ToInt()).ToArray();
      var n = arr[0]; 
      var a = arr[1];
      var b = arr[2];

      int sum = 0;
      for (int i = 0; i <= n; i++) {
         var temp = i.ToString().Select(x => x.ToString()).Select(int.Parse).Sum();
         if (a <= temp && temp <= b) {
            sum += i;
         } 
      }
      WriteLine(sum);
   }
}


Measured memory_bytes: 15444
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
const int N = 100005;
vector<int> v[N];
bool visited[N];
int dp[N];
int dfs(int ch, int par)
{
	visited[ch] = true;
	int h = 0;
	if ( dp[ch] != 0)
	return dp[ch];
	for (auto it:v[ch])
	{
		if ( it != ch)
		h = max(h,1 + dfs(it,ch));
	}
	dp[ch] = h;
	return h;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i ++)
	{
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if ( !visited[i])
		{
			ans = max(ans, dfs(i,-1));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8192
// 18:30~

#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
#include <map>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<'='<<(n)<<endl

map<string,int> getstates(string board,int maxturn)
{
	map<string,int> m;
	queue<pair<string,int>> q;
	q.emplace(board,0);
	while(q.size()){
		string cb=q.front().first;
		int cc=q.front().second;
		q.pop();
		if(m.count(cb))
			continue;
		m.insert(make_pair(cb,cc));
		
		if(cc==maxturn)
			continue;
		for(int i=0;i<5;i++)
			for(int j=abs(i-2);j<5-abs(i-2);j++){
				if(cb[i*5+j]!='.')
					continue;
				for(int k=0;k<4;k++){
					int ni=i+"\xff\x1\0\0"[k],nj=j+"\0\0\xff\x1"[k];
					if(ni<0 || 5<=ni || nj<abs(ni-2) || 5-abs(ni-2)<=nj || cb[ni*5+nj]=='.')
						continue;
					swap(cb[i*5+j],cb[ni*5+nj]);
					q.emplace(cb,cc+1);
					swap(cb[i*5+j],cb[ni*5+nj]);
				}
			}
	}
	return m;
}

int main()
{
	for(;;){
		string board(25,'#');
		for(int i=0;i<5;i++)
			for(int j=abs(i-2);j<5-abs(i-2);j++){
				int x; scanf("%d",&x);
				board[i*5+j]=x?x-1+'a':'.';
			}
		if(feof(stdin)) break;
		
		map<string,int> m1=getstates(board,10);
		map<string,int> m2=getstates("##.###abc#defgh#ijk###.##",10);
		
		int res=999;
		for(auto kv:m1)
			if(m2.count(kv.first))
				res=min(res,kv.second+m2[kv.first]);
		
		if(res==999)
			cout<<"NA"<<endl;
		else
			cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5496
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<bool> > name((h), vector<bool>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> A, long long N, std::vector<long long> b){
  V2(bingo, 3, 3);
  REP(i, N) {
    REP(x, 3){
      REP(y, 3) {
        if (A.at(x).at(y) == b.at(i)) bingo.at(x).at(y) = true;
      }
    }
  }

  bool isS = false;
  REP(x, 3) {
    int cnt = 0;
    REP(y, 3) {
      if (bingo.at(x).at(y)) cnt++;
    }
    if (cnt == 3) isS = true;
  }
  REP(y, 3) {
    int cnt = 0;
    REP(x, 3) {
      if (bingo.at(x).at(y)) cnt++;
    }
    if (cnt == 3) isS = true;
  }
  {
    int cnt = 0;
    REP(x, 3) {
      if (bingo.at(x).at(x))  cnt++;
    }
    if (cnt == 3) isS = true;
  }
  {
    int cnt = 0;
    REP(x, 3) {
      if (bingo.at(x).at(2-x))  cnt++;
    }
    if (cnt == 3) isS = true;
  }
  cout << (isS ? YES : NO) << endl;
}

signed main(){
  std::vector<std::vector<long long>> A(3, std::vector<long long>(3));
  for(int i = 0 ; i < 3 ; i++){
    for(int j = 0 ; j < 3 ; j++){
      scanf("%lld",&A[i][j]);
    }
  }
  long long N;
  scanf("%lld",&N);
  std::vector<long long> b(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&b[i]);
  }
  solve(std::move(A), N, std::move(b));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>w>>h>>x>>y;
    long double anss;
    anss=(ld)w*h/2.0;
    cout<<fixed<<setprecision(15)<<anss<<" ";
    if(x*2==w&&y*2==h)cout<<1<<"\n";
    else cout<<0<<"\n";
    return 0;
}


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

int main(){
  
   int N,sum=0;
   cin >> N;
   int data[N];
   for(int i=0;i<N;i++){ cin >> data[i]; sum+= data[i];}
   
   if(sum %10 == 0){
       sort(data,data+N);
   
       for(int i=0;i<N;i++){
           if((sum-data[i]) %10 != 0){sum -= data[i]; break;}
       }
       
       if(sum %10 == 0) sum = 0;
   }
   
   cout << sum << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
#define max 250
int main(){
int n, i;
int H[max];
int pk, lk, rk;//parent key, left key, right key

scanf("%d", &n);
for(i = 1; i <= n; i++){
	scanf("%d", &H[i]);
}

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

}
return 0;
}

Measured memory_bytes: 600
// Created by sz
#include <bits/stdc++.h>
using namespace std;

typedef long long  ll;
int fac[200005], finv[200005];
int mod = 1000000007;

int quick_pow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) res = (ll)res * a % mod;
        a = (ll)a * a % mod;
        b >>= 1;
    }
    return res;
}



int c(int n, int m){
    return (ll)((ll)fac[n] * finv[m] % mod) * finv[n - m] % mod;
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    
    int H,W,A,B;
    cin>>H>>W>>A>>B;
    
    fac[0]=finv[0]=1;
    
    int N = H+W;
//    for(int i=1;i<=n;++i)fac[i]=(ll)fac[i-1]*i%mod;
//    finv[n]=quick_pow(fac[n],mod-2);
//    for(int i=n-1;i;--i)finv[i]=(ll)finv[i+1]*(i+1)%mod;
//

    fac[0] = fac[1] = 1;
    for (int i = 2; i < N; ++i) {
        fac[i] = (ll)fac[i - 1] * i % mod;
    }
    for (int i = 0; i < N; ++i) {
        finv[i] = quick_pow(fac[i], mod - 2);
    }
    
    ll ans = 0ll;
    for(int i = B+1; i<= W;i++){
        ans = (ans + ((ll)c(H+i-A-2,i-1)*c(A+W-i-1,A-1))%mod)%mod;
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fo(int, i, a, b)        for (int i=a; i<(b); i++)
#define forev(int, i, b, a)     for (int i = (b)-1; i >= a; i--)
#define uns                     unsigned
#define lli                     long long int
#define ld                      long double
#define all(x)                  x.begin(), x.end()
#define sortall(x)              sort(all(x))
#define enl                     "\n"
// #define PI 3.1415926535897932384626
// const int MOD = 1000000007; // const ll INF = 1e18; // const int MX = 100001;
//==================================================================================

void solve() {
    lli n; cin >> n;
    lli p[n];
    fo(lli, i, 0, n) {
        cin >> p[i];
    }
    lli ans = 0;
    lli f[1000000];
    forev(lli, i, n, 0) {
        f[p[i]] = f[p[i] + 1] + 1;
        ans = max(ans, f[p[i]]);
    }
    cout << n - ans << enl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // int testcase; cin >> testcase; for (int i = 1; i <= testcase; ++i)
    solve();
    return 0;
}

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int S;
  cin>>S;
  const Int MAX = 1e9;
  Int x1=0,y1=0;
  Int x2=0,y2=0;
  Int x3=0,y3=0;

  Int L=1,R=MAX;
  while(L+1<R){
    Int M=(L+R)>>1;
    if(M*M<S) L=M;
    else R=M;
  }
  x2=y3=R;

  Int D=x2*y3-S;
  if(D==0){
    y2=x3=0;
  }else{
    for(Int i=1;i*i<=D;i++){
      if(D%i) continue;
      y2=i;
      x3=D/i;
      break;
    }
  }

  assert(0<=x1&&x1<=MAX);
  assert(0<=y1&&y1<=MAX);
  assert(0<=x2&&x2<=MAX);
  assert(0<=y2&&y2<=MAX);
  assert(0<=x3&&x3<=MAX);
  assert(0<=y3&&y3<=MAX);
  assert(x2*y3-y2*x3==S);
  cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <iomanip>

const double PI=3.14159265358979323846;

using namespace std;

int main() {
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  
  long double theta_m = M * 6;
  long double theta_h = H * 30 + 30 * (M / 60);
  long double theta = abs(theta_h - theta_m);
  
  long double C = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(theta * PI / 180));
  
  cout << setprecision(11);
  cout << C << endl;
  
  return 0;
}


Measured memory_bytes: 4156
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
    cout << x << ' ' << y << ' ' << z << endl;
}


Measured memory_bytes: 256
A,B,Q = list(map(int, input().split()))
s,t,xx=[],[],[]

for i in range(A):
    s.append(int(input()))
for i in range(B):
    t.append(int(input()))
for i in range(Q):
    xx.append(int(input()))
    
import bisect
M = 10000000000000

for x in xx:
    i = bisect.bisect_left(s,x)
    j = bisect.bisect_left(t,x)
    
    if (i > 0) and (j > 0):
        ll = abs(min(s[i-1]-x, t[j-1]-x))
    else:
        ll = M
        
    if (i > 0) and (j < B):
        lr = abs(s[i-1]-x) * 2 + (t[j]-x)
    else:
        lr = M
        
    if (i < A) and (j > 0):
        lr_2 = abs(t[j-1]-x) * 2 + (s[i]-x)
    else:
        lr_2 = M
        
    if (i < A) and (j > 0):
        rl = (s[i]-x) * 2 + abs(t[j-1] - x)
    else:
        rl = M
        
    if (i > 0) and (j < B):
        rl_2 = (t[j]-x) * 2 + abs(s[i-1] - x)
    else:
        rl_2 = M
        
    if (i < A) and (j < B):
        rr = max(s[i]-x,t[j]-x)
    else:
        rr = M

    print(min(ll,lr,rl,rr,lr_2,rl_2))

Measured memory_bytes: 16164
#include <stdio.h>

typedef struct{
    int id;
    int parent;
    int left;
    int right;
}Tree;

Tree T[25];

void preorder(int);
void inorder(int);
void postorder(int);

int main(){
    int i,j,n;
    int id;
    int data;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        T[i].parent=-1;
    
    for(i=0;i<n;i++){
        scanf("%d",&id);
        T[id].id=id;
        scanf("%d",&data);
        T[id].left=data;
        if(data!=-1)T[data].parent=id;
        scanf("%d",&data);
        T[id].right=data;
        if(data!=-1)T[data].parent=id;
    }
    //
    /*
    printf("\n\n");
    for(i=0;i<n;i++){
        printf("%d %d %d %d\n",i,T[i].parent,T[i].left,T[i].right);
    }
    */
    
    //
    i=0;
    while(T[i].parent!=-1)i++;
    id=i;
    
    printf("Preorder\n");
    preorder(id);
    
    printf("\nInorder\n");
    inorder(id);
    
    printf("\nPostorder\n");
    postorder(id);
    printf("\n");
    
    return 0;
    
}

void preorder(int n){
    printf(" %d",n);
    if(T[n].left!=-1)preorder(T[n].left);
    if(T[n].right!=-1)preorder(T[n].right);
}

void inorder(int n){
    if(T[n].left!=-1)inorder(T[n].left);
    printf(" %d",n);
    if(T[n].right!=-1)inorder(T[n].right);
}

void postorder(int n){
    if(T[n].left!=-1)postorder(T[n].left);
    if(T[n].right!=-1)postorder(T[n].right);
    printf(" %d",n);
    
}

Measured memory_bytes: 616
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
typedef long long llong;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    vector<int> v;
    vector< pair<int, string> > vs;
    string s;
    map<string, int> mp;

    int n;
    cin >> n;
    REP(i, n){
        cin >> s;
        if (mp.find(s) == mp.end()){
            mp[s] = vs.size();
            vs.push_back(make_pair(0, s));
        }else{
            vs[mp[s]].first += 1;
        }
    }

    sort(vs.begin(), vs.end());

    int maxV = vs[vs.size() - 1].first;
    REP(i, vs.size()){
        if (vs[i].first == maxV){
            cout << vs[i].second << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 28652
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vector<int> A, B;
string S, T;
vector<tuple<int, int, int>> tp;
void input() {
  cin >> N >> M;
  tp.resize(M);
  rep(i, 0, M - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    tp[i] = tie(a, b, c);
  }
}

int f[MX] = {}, sum[MX] = {};
int find(int x) {
  if (x == f[x]) return x;
  int y = find(f[x]);
  sum[x] += sum[f[x]];
  f[x] = y;
  return y;
}
bool ans = true;
void solve() {
  rep(i, 0, N + 1) { f[i] = i; }

  int fa, fb;
  for (auto x : tp) {
    int a, b, c;
    tie(a, b, c) = x;

    fa = find(a);
    fb = find(b);
    if (fa == fb) {
      if (abs(sum[b] - sum[a]) != c) {
        ans = false;
        return;
      }
    } else {
      f[fa] = fb;
      sum[fa] = sum[b] + c - sum[a];
    }
  }
}
signed main() {
  input();
  solve();
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    vector<string>s;
    string ss;
    char t[10];
    ll n,i,j,k,m;

    cin>>n;
    SIZE(s,n);
    rep(i,n){
        cin>>ss;
        rep(j,10){
            t[j]=ss[j];
        }
        sort(t,t+10);
        rep(j,10){
            ss[j]=t[j];
        }
        s[i]=ss;
    }
    SORT(s);
    m=0;
    k=1;
    ss=s[0];
    repj(i,1,n){
        if(s[i]==ss){
            k++;
        }
        else{
            m+=k*(k-1)/2;
            ss=s[i];
            k=1;
        }
    }
    m+=k*(k-1)/2;
    cout<<m;

	return 0;
}


Measured memory_bytes: 5760
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	lint a;double b;
	cin>>a>>b;
	lint c=(lint)(b*100.0+0.1);
	cout<<(a*c)/100<<endl;
}


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

int main() {
  int A, B, K;
  cin >> K >> A >> B;
  
  int r = A % K;
  if (r == 0 || (r + B - A) >= K) {
    cout << "OK";
  } else {
    cout << "NG";
  }
    
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>

using namespace std;

int getint()
{
    char ch=getchar();
    int f=1,x=0;
    while(!isdigit(ch)){if(ch=='-') f=-1; ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return f*x;
}

const int N=3030;
const int MOD=1000000007;

int n,m;
char s[N];
int sum[N];
int l[N],r[N];
long long c[N][N],f[N][N];

void init()
{
    n=getint(),m=getint();
    scanf("%s",s+1);
    for(int i=1; i<=n; i++) sum[i]=sum[i-1]+s[i]-'0';
    int tot=0;
    for(int i=1; i<=m; i++){
        int ll=getint(),rr=getint();
        if(ll==l[tot]){
            r[tot]=max(r[tot],rr);
        }else if(rr<=r[tot]){
        }else{
            tot++;
            l[tot]=ll;
            r[tot]=rr;
        }
    }
    m=tot;
    for(int i=0; i<=n; i++){
        c[i][0]=1;
        for(int j=1; j<=i; j++){
            c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
        }
    }
    l[m+1]=n+1;
    r[m+1]=n+1;
}

int main()
{
    init();
    f[0][0]=1;
    for(int i=1; i<=m; i++){
        int nxt=r[i]>=l[i+1]?r[i]-l[i+1]+1:0;
        int pre=r[i-1]>=l[i]?r[i-1]-l[i]+1:0;
        for(int j=0; j<=nxt; j++){
            for(int k=0; k<=pre; k++){
                //if(sum[min(r[i],l[i+1])]-sum[l[i]-1]+k-j<0) continue;
                f[i][j]=(f[i][j]+f[i-1][k]*c[r[i]-l[i]+1-nxt][sum[r[i]]-sum[l[i]-1]-(sum[l[i]+pre-1]-sum[l[i]-1])+k-j])%MOD;
            }
        }
    }
    printf("%lld\n",f[m][0]);
    return 0;
}


Measured memory_bytes: 100864
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#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;
 
int main() {
    ll h, w;
    cin >> h >> w;

    ll cnt = 0;
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '#') {
                cnt++;
            }
        }
    }

    if(cnt == h+w-1) {
        out("Possible");
    }
    else {
        out("Impossible");
    }
    
    re0;
}

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

/*
 * Wrong Answer
 * 2015-06-26 02:00
 */

int main(void)
{
	double a, b, c, d, e, f, x, y;

	while( std::cin >> a >> b >> c >> d >> e >> f ){
		y = ( a * f - c * d ) / ( a * e - b * d );
		x = ( c - b * (( a * f - c * d ) / ( a * e - b * d ))) / a;
		printf("%.3f %.3f\n", x, y );
	}

	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin >>n>>m;
    vector<int> a(n),s(n);
    map<int,ll> ma;

    rep(i,n)cin>>a[i];
    
    s[0] = a[0]%m;ma[s[0]]++;

    rep1(i,1,n){
        s[i]=(s[i-1]+a[i])%m;
        ma[s[i]]++;
    }

    //for(int mi : s)cout<<mi<<" ";
    //ln;

    for(auto p:ma){
        ll add;
        if(p.fi==0)add = p.se*(p.se+1)/2;
        else add = p.se*(p.se-1)/2;

        ans += add;
        //db3(p.fi,p.se,add);ln;
    }


    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;

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

    return 0;
}


Measured memory_bytes: 4992
import numpy as np
import itertools

def calc_distance(p1,p2):
    dis = ((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)**0.5
    return dis

n = int(input())
data =  [list(map(int,input().split())) for _ in range(n)] 


distance_list = []
for route in itertools.permutations(range(n)):
    total = 0
    for j in range(len(route) - 1):
        d = calc_distance(data[route[j]], data[route[j+1]])
        #dis = ((data[route[j]][0] - data[route[j+1]][0])**2 + (data[route[j]][1] - data[route[j+1]][1])**2)**0.5
        total += d
    distance_list.append(total)

print(np.mean(distance_list))

Measured memory_bytes: 22572
#include <iostream>
#define ll long long
using namespace std;
 
int main(){
  int n,q; ll k; cin >> n >> k >> q;
  ll p[n]; for(int i=0; i<n; i++){p[i]=k-q;}
  
  int a;
  for(int i=0; i<q; i++){
    cin >> a;
    p[a-1]++;
  }
  
  for(int i=0; i<n; i++){
    if(p[i]<=0){cout << "No";}
    else{cout << "Yes";}
    if(i!=n-1){cout << endl;}
  }
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<int(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
constexpr int INF = 1000000000;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n) break;
    vector<pair<string, string>> cross;
    vector<string> lines;
    REP(i,n) {
      string l;
      cin>>l;
      int p = l.find('-');
      string left = l.substr(0, p);
      lines.push_back(left);
      string right = l.substr(p+1);
      lines.push_back(right);
      cross.emplace_back(left, right);
    }
    sort(ALL(lines));
    lines.erase(unique(ALL(lines)), end(lines));
    int s = lines.size();
    vector<vector<int>> mat(s, vector<int>(s, INF));
    REP(i,n) {
      string left, right;
      tie(left, right) = cross[i];
      int beg = lower_bound(ALL(lines), left) - begin(lines);
      int ed = lower_bound(ALL(lines), right) - begin(lines);
      mat[beg][ed] = 1;
    }
    REP(i,s)REP(j,s) {
      bool ok = true;
      bool valid = false;
      REP(k,s) {
        if (mat[i][k] < INF && mat[k][j] < INF) ok = false;
        if (mat[j][k] < INF && mat[k][i] < INF) ok = false;
        if (mat[i][k] < INF && mat[j][k] < INF) valid = true;
        if (mat[k][i] < INF && mat[k][j] < INF) valid = true;
      }
      if (valid && ok) {
        mat[i][j] = 0;
        mat[j][i] = 0;
      }
    }
    REP(k,s)REP(i,s)REP(j,s) mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
    int m;
    cin>>m;
    cout << lines.size() << endl;
    REP(i,m) {
      bool ok = true;
      string l;
      cin>>l;
      int p = l.find('-');
      string left = l.substr(0, p);
      string right = l.substr(p+1);
      auto itr = lower_bound(ALL(lines), left);
      int li = itr - begin(lines);
      if (itr == end(lines) || *itr != left) {
        ok = false;
      }
      itr = lower_bound(ALL(lines), right);
      int ri = itr - begin(lines);
      if (itr == end(lines) || *itr != right) {
        ok = false;
      }
      int d1 = mat[li][ri];
      int d2 = mat[ri][li];
      if ((d1 % 2) == 0 && (d2 % 2) == 0) {
        ok = false;
      }
      if (ok && d1 < INF) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3376
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,k,h[200001],ans;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		cin>>h[i];
	}
	sort(h+1,h+1+n);
	for(int i=n-k;i>0;--i)
	{
		ans+=h[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int a,b;

int main(){
    cin >> a >> b;
    if (a==b) {
        cout << "Draw" << endl;
    }
    else if (a==1){
        cout << "Alice" << endl;
    }
    else if (b==1) {
        cout << "Bob" << endl;
    }
    else if (a>b) {
        cout << "Alice" << endl;
    }
    else if (b>a) {
    cout << "Bob" << endl;
}
    return 0;
}

Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 998244353;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

template<typename T>
void cout_mat(vector<vector<T>  > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

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

    vector<vector<vector<ll>>> dp(C-A+1,vector<vector<ll>>(D-B+1,vector<ll>(2,0)));
    dp[0][0][0]=1;
    for(int j=0; j<=D-B; j++){
        for(int i=0; i<=C-A; i++){
            if(i<C-A){
                dp[i+1][j][1]+=(dp[i][j][0]+dp[i][j][1])*(B+j)%MOD;
                dp[i+1][j][1]%=MOD;
            }
            if(j<D-B){
                dp[i][j+1][0]+=(dp[i][j][0]*(A+i)+dp[i][j][1])%MOD;
                dp[i][j+1][0]%=MOD;
            }
        }
    }
    /*
    for(int i=0; i<=C-A; i++){
        cout_mat(dp[i]);
        cout << endl;
    }
    */
    cout << (dp[C-A][D-B][0]+dp[C-A][D-B][1])%MOD << endl;
}

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

int n,m;
int f[111][111];

int rec(int p, vector<int> &used){
    // if(k*(k+1)/2 > m) return 0;
    
    // cout << "A ";
    // for(int u : used) cout << u << ' ' ;
    // cout << endl;

    int res = 0;
    for(int u : used){
        int min_f = 1e9;
        for(int v : used){
            if(u == v) continue;
            min_f = min(min_f, f[u][v]);
            assert(f[u][v] > 0);
        }
        if(min_f == 1e9) min_f = 0;
        res += min_f;
    }
    
    for(int i = p; i < n; ++i){
        int min_f = 1e9;
        for(int v : used){
            min_f = min(min_f, f[i][v]);
        }
        if(min_f == 0) continue;
        used.push_back(i);
        res = max(res, rec(i+1, used));
        used.pop_back();
    }
    return res;
}

int main(){
    while(cin >> n >> m){
        // cout << "####################" << endl;
        memset(f, 0, sizeof f);
        for(int i = 0; i < m; ++i){
            int u,v,f_;
            cin >> u >> v >> f_;
            --u; --v;
            f[u][v] = f[v][u] = f_;
        }
        if(n == 1){
            cout << 0 << endl;
        } else {
            vector<int> used;
            cout << rec(0,used) << endl;
        }
    }
}

Measured memory_bytes: 3144