akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Aman
 */


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;


#define pb          push_back
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define rep(i, a, b)    for(ll i=a;i<=b;i++)
#define repr(i, a, b) for(ll i=a;i>=b;i--)
#define pll pair<ll, ll>
#define tp tuple<ll,ll>


template<int D, typename T>
struct vec : public vector<vec<D - 1, T>> {
  static_assert(D >= 1,
                "Vector dimension must be greater than zero!");

  template<typename... Args>
  vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) {
  }
};

template<typename T>
struct vec<1, T> : public vector<T> {
  vec(int n = 0, T val = T()) : vector<T>(n, val) {
  }
};

template<typename T>
inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }

template<typename T>
inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }




template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
  os << "(";
  os << v.first << ", "
     << v.second << ")";
  return os;
}

template<typename T, typename S>
ostream &operator<<(ostream &os, const map<T, S> &v) {

    for (auto it : v)
        os << "[" << it.first << " : "
           << it.second << "]";

    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
  os << "[";
  for (auto it : v) {
    os << it;
    if (it != *v.rbegin())
      os << ", ";
  }
  os << "]\n";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    os << v[i];
    if (i != v.size() - 1)
      os << ", ";
  }
  os << "]\n";
  return os;
}

class ARepeatACL {
public:
void solve(std::istream& cin, std::ostream& cout) {
  ll n;
  cin>>n;
  string s="ACL";
  rep(i,0,n-1) cout<<s;

}
};


int main() {
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ARepeatACL solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,k,l;
    string s1,s2;
    cin>>s1;
    cin.ignore();
    cin>>s2;
    if(s1.size()>=s2.size())
    {
        k=s1.size();
    }
    else
    {
        k=s2.size();
    }
    for(i=0;i<k;i++)
    {
        if(i<s1.size())
        {
            cout<<s1[i];
        }
        if(i<s2.size())
        {
            cout<<s2[i];
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
import heapq

N, M = map(int, input().split())
task = []
for i in range(N):
    a, b = map(int, input().split())
    task.append((a, b))

task.sort()

wa = []
ans = 0
j = 0
for i in range(M):
    while j < N and task[j][0] == i + 1:
        heapq.heappush(wa,-task[j][1])
        j += 1
    if wa:
        ans -= heapq.heappop(wa)

print(ans)


Measured memory_bytes: 20796
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =1e5+10;
const long long  mod = 1e14 ;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int a[15][15],c[15];
int main()
{
	int ans=inf;
	int n,m,x;
	scanf("%d %d %d",&n,&m,&x);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
		for(int j=1;j<=m;j++) scanf("%d",&a[i][j]);
	}
	for(int i=1;i<2<<n;i++)
	{
		int num=i;
		int vis[15],index=1;
		while(num)
		{
			vis[index++]=num%2;
			num/=2;
		}
		int need[15]={0},sum=0;
		for(int j=1;j<=n;j++)
		{
			if(vis[j])
			{
				sum+=c[j];
				for(int k=1;k<=m;k++)
				{
					need[k]+=a[j][k];
				}
			}
		}
		int flag=1;
		for(int j=1;j<=m;j++)
		{
			if(need[j]<x)
			{
				flag=0;
				break;
			}
		}
		if(flag) ans=min(ans,sum);
	}
	if(ans==inf) printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3768
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(2);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;

void solve()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int ans=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		{
			ans+=(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	cout << ans << nl;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 5176
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	int n;
	cin >> n;
	
	int s = 0, t = 0;
	for (int i = 0; i < n; i++) {
		string S, T;
		cin >> S >> T;
		if (S < T) t += 3;
		else if (S > T) s += 3;
		else { s++; t++; }
	}
	cout << s << " " << t << endl;

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		// 入力
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int x = scanner.nextInt();
		int[] aArray = new int[m];

		int check = 0;
		for (int i = 0; i < m; i++) {
			aArray[i] = scanner.nextInt();
			if(check(aArray[i], n-1) && check < aArray[i]) {
				check = aArray[i];
			} else {
				
			}
		}


		if(check(n, 100) && check(m, 100) && check(x, n-1)) {
			int point = 0;
			for (int i = 0; i < aArray.length; i++) {
				if(x < aArray[i]) {
					point = i;
					break;
				}
			}
			System.out.println(Math.min(point, m-point));
		} else {
		}



	}

	static boolean check(int input, int max) {
		return (1 <= input && input <=  max);
	}
}

Measured memory_bytes: 21332
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}


ll n, c;
vector<ll> a;
vector<ll> s;
vector<P> b;

#define MAX_N 400001
int bit[MAX_N];

int sum(int i){
	int sum = 0;
	while(i > 0){
		sum += bit[i];
		i -= i & -i;
	}
	return sum;
}

void add(int i, int x){
	while(i <= n+1){
		bit[i] += x;
		i += i & -i;
	}
}

int main(){
	cin>>n>>c;
	a = vector<ll>(n);
	rep(i, n) cin>>a[i];
	rep(i, n) a[i] -= c;
	s = vector<ll>(n+1, 0);
	rep(i, n) s[i+1] = s[i]+a[i];
//	rep(i, n+1) cout<<s[i]<<" "; cout<<endl;
	b = vector<P>(n+1);
	rep(i, n+1) b[i] = P(s[i], i);
	sort(all(b));
	rep(i, n+1) s[b[i].snd] = i+1;

	//rep(i, n+1) cout<<s[i]<<" "; cout<<endl;
	ll r = 0;
	rep(i, n+1){
		r += i-sum(s[i]);
		//cerr<<r<<endl;
		add(s[i], 1);
	}
//	cerr<<r<<endl;
	cout<<n*(n+1)/2-r<<endl;
	return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<iomanip>
#include<algorithm>
using namespace std;

int main() {
	int A,B,C;
	cin >> A >> B >> C;
	int count = 0;
	int Ablock[3] = {};
	int	Bblock[3] = {};
	int Cblock[3] = {};
	Ablock[0] = A; Bblock[0] = B; Cblock[0] = C;
	while(1){

			if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
				break;
			}

			else if (A == B && B == C){
				count = -1;
				break;
			}

			else{
				int A_alt = A;
				int B_alt = B;
				int C_alt = C;
				A = B_alt / 2 + C_alt / 2;
				B = A_alt / 2 + C_alt / 2;
				C = B_alt / 2 + A_alt / 2;
				count++;
			}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n,k;
  cin >> n >> k;
  if(k==1){
    cout << 0 << endl;
    return 0;
  }
  cout << n-k << endl;
return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
    int data;
    struct Node *parent, *left, *right;
}Node;
Node *root;
void insert(int x){
    Node *t = (Node *)malloc(sizeof(Node));
    t->data = x;
    t->left = t->right = t->parent = NULL;

    if(root == NULL){
        root = t;
    }else{
        Node *child = root;
        Node *parent = NULL;
        while(child != NULL){
            parent = child;
            if(x < child->data){
                child = child->left;
            }
            else{
                child = child->right;
            }
        }
        t->parent = parent;
        if(x < parent->data){
            parent->left = t;
        }else{
            parent->right = t;
        }
    }
}
void Preorder(Node *t){
    if(t == NULL) return ;
    printf(" %d", t->data);
    Preorder(t->left);
    Preorder(t->right);
}
void Inorder(Node *t){
    if(t == NULL) return ;
    Inorder(t->left);
    printf(" %d", t->data);
    Inorder(t->right);
}
void find(int b){
    Node *temp = root;
    while(temp != NULL){
        if(temp->data == b){
            printf("yes\n");
            return ;
        }
        if(b < temp->data){
            temp = temp->left;
        }
        else{
            temp = temp->right;
        }
    }
    printf("no\n");
}
int main(){
    root = NULL;
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        char a[10]; int b;
        scanf("%s", a);
        if(a[0] == 'i'){
            scanf("%d", &b);
            insert(b);
        }
        else if(a[0] == 'p'){
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
        else if(a[0] == 'f'){
            int c;
            scanf("%d", &c);
            find(c);
        }
    }
    return 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A<C && C<B) || (B<C && C<A)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

#define ii pair <int, int>
#define ll long long
#define X first
#define Y second

const int N = 3E5 + 10;

int n, m;
ll a[N], Sum[N], d[N];

void Input()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
}

bool check(int mid, int k)
{
    int pos = upper_bound(a + 1, a + 1 + m, mid) - (a + 1);
    if (pos > m) pos = m;
    if (Sum[pos] / mid + (m - pos) >= k) return true;
    return false;
}

void Solve()
{
    for (int i = 1; i <= n; i++) d[a[i]]++;
    for (int i = 1; i <= n; i++) if (d[i] > 0) a[++m] = d[i];
    sort(a + 1, a + 1 + m);
    for (int i = 1; i <= m; i++) Sum[i] = Sum[i - 1] + a[i];

    for (int k = 1; k <= n; k++) {
        int l = 1, r = 1e9;
        int ans = 0;
        while (l <= r) {
            int mid = l + r >> 1;
            if (check(mid, k)) {
                ans = mid;
                l = mid + 1;
            }
            else r = mid - 1;
        }
        cout << ans << "\n";
    }
}

#define task "test"
int main()
{
    if (fopen(task ".inp", "r")) {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    int testcase = 1;
    /// cin >> testcase;
    while (testcase--) {
        Input();
        Solve();
    }
}



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

using namespace std;
#define llint long long

const int N = 200005;
llint p[N], sum[N];

int main() {
    int n,k;
    scanf("%d", &n);
    scanf("%d", &k);
    for(int i = 0; i < n; ++i){
        scanf("%lld", p + i);
    }

    sum[0] = 0;
    for(int i = 1; i < n + 1; ++i){
        sum[i] = sum[i - 1] + p[i - 1];
    }
    llint ans = 0;
    for(int i = 0; i + k - 1 <= n + 1; ++i){
        ans = max(ans, sum[i + k] - sum[i]);
    }
    //for(int i = 0; i < n; ++i) cout << sum[i] << endl;
    //cout << ans << endl;
    //sort(p, p + n, greater<int>());
    /*
    for(int i = 0; i < n; ++i){
        cout << p[i] << " ";
    }
    cout << endl;
    */
    /*
    double ans = accumulate(q, q + k, 0.0);
    for(int i = 1; i < n - (k - 1); ++i){
        if(ans < accumulate(q + i , q + i + k, 0.0)){
            ans = accumulate(q + i , q + i + k, 0.0);
        }
    }
    */

    printf("%.11f\n", (ans + k) * 0.5);

	return 0;
}


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

using ll = long long;
using pii = pair<int, int>;

#define     endl               "\n"
#define     fast_io            ios::sync_with_stdio(false); cin.tie(0);
#define     file_io            freopen("input.txt", "r", stdin);   \
                               freopen("output.txt", "w", stdout);
#define     all(x)             begin(x), end(x)
#define     debug(x)           cerr <<"Line "<< __LINE__ <<" : "<< #x " = "<< x <<endl;
 
template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<"("<<t.first<<", "<<t.second<<")"; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }
 




int main(int argc, char** argv) {
    fast_io
   
	
	int a, b;
	cin >> a >> b;
	
	if(a < b) cout << "a < b" << endl;
	else if(a > b) cout << "a > b" << endl;
	else cout << "a == b" << endl;
	

    return 0;
}























Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

int main(){
    int n, T;
    cin >> n >> T;
    int ans = INT_MAX;
    while(n--){
         int ci, ti;
         cin >> ci >> ti;
         if(ti <= T) ans = min(ci, ans);
    }
    if(ans == INT_MAX) cout << "TLE";
    else cout << ans;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
p = tuple([int(i) for i in input().split()])
q = tuple([int(i) for i in input().split()])

import itertools

lst = list(itertools.permutations(range(1, n+1)))
print(abs(lst.index(p) - lst.index(q)))


Measured memory_bytes: 45168
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll x,a,b;
    cin>>x>>a>>b;
    
    if(a >= b)cout << "delicious" << endl;
    else if (b-a<=x)cout << "safe" << endl;
    else cout << "dangerous" << endl;
    
    return 0;
}



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

int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  if(A+B>C+D){
    cout <<"Left"<<endl;
  }
  else if(A+B==C+D){
	cout <<"Balanced"<<endl;
  }
  else{
	cout <<"Right"<<endl;
  }
}

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

int a[100001];

struct Union_find{
    
    int p[100001];
    int N;
    Union_find(int n) : N(n){
        for(int i=1;i<=N;i++) p[i]=i;
    }
    
public:
    int Find(int x){
        if(p[x]==x) return x;
        return p[x] = Find(p[x]);
    }
    
    void Union(int x,int y){
        x = Find(x);
        y = Find(y);
        p[x] = y;
    }
};

int main(int argc, const char * argv[]) {
    
    int n,m;
    
    scanf("%d %d",&n,&m);
    
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    
    Union_find uf(n);
    
    
    for(int i=0;i<m;i++){
        int x,y;
        
        scanf("%d %d",&x,&y);
        uf.Union(x, y);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(uf.Find(i) == uf.Find(a[i])) ans++;
    }

    printf("%d\n",ans);
    
    
    return 0;
}


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

using int64 = int64_t;

int64 F(int64 n) {
  if (n < 0)
    return 0;

  // Returns f(0, n)                                                                                                                                                                                               
  int64 ret = 0;
  switch (n % 4) {
  case 0: ret = 0; break;
  case 1: ret = 1; break;
  case 2: ret = 3; break;
  case 3: ret = 0; break;
  }
  for (int64 b = 1 << 2; b <= n; b <<= 1) {
    int64 m = n % (b * 2);
    if (m >= b && m % 2 == 0)
      ret ^= b;
  }
  return ret;
}

int main() {
  int64 a, b;
  cin >> a >> b;
  cout << (F(a - 1) ^ F(b)) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#define INF 0x3f3f3f3f

using namespace std;
typedef long long ll;
ll x,k,d;
int main() {
	ios::sync_with_stdio(false);
	scanf("%lld%lld%lld",&x,&k,&d);
	x=abs(x);
	ll t=x/d;
	if(k<=t) {
		printf("%lld",x-d*k);
	}
	else {
		if((k-t)%2==1) {
			printf("%lld",abs(x%d-d));
		}
		else {
			printf("%lld",abs(x%d));
		}
	}
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int n;
    cin >> n;
    ll b, p;
    ll mx = 0;
    ll cnt = 0;
    rep(i, n) {
        scanf("%lld", &p);
        if(p <= b) ++cnt;
        else cnt = 1;
        b = p;
        chmax(mx, cnt);
    }

    ppp(mx-1);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
signed main(){
	string s;
	cin>>s;
	for(int i=0;i<4;i++)cout<<s[i];
	cout<<" ";
	for(int i=4;i<12;i++)cout<<s[i];
	cout<<endl;
}

Measured memory_bytes: 256
#import"bits/stdc++.h"
#define r(n) for(i=0;i<n;i++)
using namespace std;main(int N){cin>>N;int A[2*N],c[N+1]={},n,t,i;r(2*N)cin>>A[i];r(2*N)c[A[i]]++;if(*max_element(c,c+N+1)>N)cout<<"No";else{cout<<"Yes";queue<int>s;r(N)if(A[i]==A[N+i])s.push(i);while(s.size()){n=s.front(),t=N+rand()%N;if(A[n]-A[t]&&A[t-N]-A[n+N])swap(A[n+N],A[t]),s.pop();}r(N)cout<<" "<<A[i+N];}}

Measured memory_bytes: 6368
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int a, b, c;
        int[] prev = new int[3];
        for (int i = 0; i < n; i++) {
            a = ms.nextInt();
            b = ms.nextInt();
            c = ms.nextInt();

            int[] curr = new int[3];

            curr[0] = a + Math.max(prev[1], prev[2]);
            curr[1] = b + Math.max(prev[0], prev[2]);
            curr[2] = c + Math.max(prev[0], prev[1]);
            prev = curr;
        }

        out.println(Math.max(prev[0], Math.max(prev[1], prev[2])));
        out.close();
    }


}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

    public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}


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

int main(){
   int H,W,h,w;cin >> H >> W >> h >> w;
   cout<<(H-h)*(W-w)<<endl;
}

Measured memory_bytes: 256
//#define MYDEBUG
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> R[i];
	}
	int maxv = -2000000000; //???????°??????????????????????????¨????
	int minv = R[0];
	for (int i = 1; i < n; ++i) { //????????§??????R[i]?????????????????°???????????????
		maxv = max(maxv, R[i] - minv); //?????§????????´??°
		minv = min(minv, R[i]); //???????????§???????°?????????????????????????
	}
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 3832
#include <cstdio>

int main(){
    int w;

    for(;;){
    int cost=0;
    scanf("%d",&w);
    if(w==-1) break;
    if(w<=10)
    {
        cost=1150;
    }

    if(11<=w&&w<=20)
    {
        cost=1150;
        for(int i=10; i<w; i++)
        cost+=125;
    }

    if(21<=w&&w<=30)
    {
        cost=2400;
        for(int i=20; i<w; i++)
        cost+=140;
    }

    if(w>=31)
    {
            cost=3800;
            for(int i=30; i<w; i++)
        cost+=160;

    }
    printf("%d\n",4280-cost);
    }
}



Measured memory_bytes: 2592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const double pi=3.14159265358979323846;

int main(){
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	double time=M+H*60;
	double hdeg=time/2, mdeg=time*6;
	double deg=mdeg-hdeg;
	double ans=B*B+A*A-2*B*A*cos(deg/180*pi);
	cout << setprecision(15) << sqrt(ans) << endl;

	return 0;
}

Measured memory_bytes: 4228
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,Q;
  cin >> N;
  vector<int> cnt(100010,0);
  long long sum = 0;
  int i,a;
  for(i=0;i<N;i++) {
    cin >> a;
    cnt[a]++;
    sum += a;
  }
  cin >> Q;
  int b,c;
  for(i=0;i<Q;i++) {
    cin >> b >> c;
    sum -= (long long)b*cnt[b];
    sum += (long long)c*cnt[b];
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << sum << endl;
  }
}

Measured memory_bytes: 3720
#include <stdio.h>

int main(void)
{
  long int N;
  long int f, b, fb;
  long int sum;
  long int sumf, sumb, sumfb;

  scanf("%ld", &N);

  f = N/3;
  b = N/5;
  fb = N/15;

  sumf = f*(f+1)/2*3;
  sumb = b*(b+1)/2*5;
  sumfb = fb*(fb+1)/2*15;
  
  sum = N*(N+1)/2 - sumf - sumb + sumfb;
  printf("%ld\n", sum);

  return 0;
}

Measured memory_bytes: 1736
def distance(A, B):
    d = 0
    for a, b in zip(A, B):
        d += (a - b) ** 2
    return d ** 0.5


n, d = map(int, input().split())
X = [tuple(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        d = distance(X[i], X[j])
        if d == round(d):
            ans += 1
print(ans)


Measured memory_bytes: 3188
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5;
int n;
int a[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

map<int, int> s;

bool check(int sigma) {
  s.clear();
  int len = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] <= len) {
      if (sigma == 1) {
        return false;
      }
      while (!s.empty()) {
        auto it = s.end();
        it--;
        if (it->first >= a[i]) {
          s.erase(it);
        } else {
          break;
        }
      }
      int pos = a[i] - 1;
      while (true) {
        if (pos < 0) {
          return false;
        }
        if (s.empty()) {
          s[pos]++;
          break;
        }
        auto it = s.end();
        it--;
        if (it->first < pos) {
          s[pos]++;
          break;
        } else {
          if (it->second + 1 >= sigma) {
            s.erase(it);
            pos--;
          } else {
            it->second++;
            break;
          }
        }
      }
    }
    len = a[i];
  }
  return true;
}

void solve() {
  int l = 0, r = n;
  while (l < r - 1) {
    int m = (l + r) / 2;
    if (check(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  printf("%d\n", r);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        int a1, a2, a3, b1, b2, b3;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[][] grid = new int[3][3];
        String ans = "No";
        
        for (int i = 0; i < 3; i++) {
            String[] line = br.readLine().split(" ");
            for (int j = 0; j < 3; j++) {
                grid[i][j] = Integer.parseInt(line[j]);
            }
        }
        
        for (a1 = 0; a1 <= grid[0][0]; a1++) {
            b1 = grid[0][0] - a1;
            b2 = grid[0][1] - a1;
            b3 = grid[0][2] - a1;
            a2 = grid[1][0] - b1;
            a3 = grid[2][0] - b1;
            if (a2 + b2 == grid[1][1] && a2 + b3 == grid[1][2] && a3 + b2 == grid[2][1] && a3 + b3 == grid[2][2]) ans = "Yes";
        }
        
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rvs(vec) reverse(vec.begin(),vec.end())

int main(){
	
	int n;
	cin>>n;
	vector<int> x (n);
	rep(i,n){
		cin>>x.at(i);
	}
	int sum=0;
	rep(i,n){
		sum +=x.at(i);
	}
	int p=round((double)sum/n);
	
	vector <int> sqx(n);
	rep(i,n){
		sqx.at(i)=pow(p-x.at(i),2);
	}
	int ans=0;
	rep(i,n){
		ans +=sqx.at(i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
import java.util.*;


import java.io.*;



public class Main 
{   
	static int dp[];
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int k=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0]=0;
		
		for(int i=1;i<n;i++) {
			for(int j=1;j<=k;j++) {
				if(i-j>=0)
				dp[i]=Math.min(dp[i],dp[i-j]+Math.abs(ar[i]-ar[i-j]));
				
			}
			
		}
		System.out.println(dp[n-1]);

	}
}

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

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

   vector<int> p(n);
   for (int i = 0; i < n; i++){
      cin >> p.at(i);
   }
   int m = p.at(0);
   int cnt = 0;
   for (int i = 0; i < n;i++){
      if(m<p.at(i))
         continue;
      else{
         cnt++;
         m = p.at(i);
      }
   }
   cout << cnt << endl;
   return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n; cin >> n;
    ll k; cin >> k;
    map<int, int> tere;
    for(int i=1; i<=n; i++){
        int a; cin >> a;
        tere[i] = a;
    }
    
    ll len_roop = 0;

    map<ll, ll> order;
    map<ll, ll> city;
    ll tmp_city = 1;
    ll cnt_city = 1;
    ll len_line = 0;
    order[tmp_city] = cnt_city;
    city[cnt_city] = tmp_city;

    for(int i=1; i<=n; i++){
        if(order[tere[tmp_city]] != 0){
            len_roop = order[tmp_city] - order[tere[tmp_city]] + 1;
            len_line = order[tere[tmp_city]] - 1;
            break;
        }
        tmp_city = tere[tmp_city];
        cnt_city++;
        len_line++;
        order[tmp_city] = cnt_city;
        city[cnt_city] = tmp_city;
    }


    if(k <= len_line){
        cout << city[k + 1] << endl;
    }
    else{
        k -= len_line;
        k %= len_roop;
        cout << city[k + len_line + 1] << endl;
    }


    return 0;
}

Measured memory_bytes: 37612
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

const MODULO: usize = 1_000_000_007;

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    let mut ans: usize = 0;
    for mut x in 1..=k {
        let c = power(k / x, n);
        let mut a = 1;
        let mut d = 2;
        while d * d <= x {
            if x % d == 0 {
                a = a * (d - 1) % MODULO;
                x /= d;
                while x % d == 0 {
                    a = a * d % MODULO;
                    x /= d;
                }
            }
            d += 1;
        }
        if x != 1 {
            a = a * (x - 1) % MODULO;
        }
        ans = (ans + a * c) % MODULO;
    }
    println!("{}", ans);
}

fn power(mut b: usize, mut e: usize) -> usize {
    let mut a = 1;
    while e != 0 {
        if e & 1 != 0 {
            a = a * b % MODULO;
        }
        b = b * b % MODULO;
        e >>= 1;
    }
    a
}


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

int main()
{
    string s ;
    while(cin >> s)
    {
        if(s == "-") break ;
        int T ;
        cin >> T ;
        while(T--)
        {
            int G ;
            cin >> G ;
            string S = s.substr(0 , G) ;
            s += S ;
            s.erase(0 , G) ;
        }
        cout << s << endl ;
    }
}


Measured memory_bytes: 3184
#include  <bits/stdc++.h>
using namespace std;
 int main ( )
 {
 	int n;
 	cin>>n;
 	if(n==1){
	cout<<"Hello World";
	}
 	else{
	int a,b;
 	cin>>a>>b;
 	cout<<a+b;
 	}
 	return 0;
 }

Measured memory_bytes: 764
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int h, w; cin >> h >> w;
  V<string> s(h); rep(i,h) cin >> s[i];
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

  rep(i,h) {
    string ans = "";
    rep(j,w) {
      if (s[i][j] == '#') {
        ans += "#";
        continue;
      }
      int count = 0;
      rep(k,8) {
        int x = j + dx[k];
        int y = i + dy[k];
        if (x < 0 || x >= w) continue;
        if (y < 0 || y >= h) continue;
        if (s[y][x] == '#') ++count;
      }
      ans += to_string(count);
    }
    pl(ans)
  }
  return 0;
}


Measured memory_bytes: 3692
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        long n = int.Parse(Console.ReadLine());
        Console.WriteLine(n * (n - 1) / 2);
    }

    static readonly TextReader In = Console.In;
    static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0;
            int next = In.Read();
            int rev = 1;
            while (45 > next || next > 57) next = In.Read();
            if (next == 45) { next = In.Read(); rev = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = In.Read();
            }
            return res * rev;
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int judge(int n)
{
	if(1<=n&&n<=9)
      return 1;
    else
      return -1;
}
int main()
{
	int a,b;
    scanf("%d%d",&a,&b);
    if(judge(a)==1&&judge(b)==1)
      printf("%d",a*b);
    else
      printf("-1");
    return 0;
}

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

int main()
{
    int n;
    unsigned long long ans = 0LL;
    cin >> n;
    vector<string> s(n);
    map<string, int> mp;
    for (auto i : s)
    {
        cin >> i;
        sort(i.begin(), i.end());
        mp[i]++;
    }
    for (auto x : mp)
    {
        long long cnt = x.second;
        ans += cnt * (cnt - 1) / 2LL;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 11904
#include <stdio.h>

int main(void){
  int N, M, C, i, j, code, condition;

  scanf("%d %d %d", &N, &M, &C);
  int B[M];
  for(i=0;i<M;i++){
    scanf("%d", &B[i]);
  }
  int A[N][M];
  for(i=0;i<N;i++){
    for(j=0;j<M;j++){
      scanf("%d", &A[i][j]);
    }
  }
  code=0;
  for(i=0;i<N;i++){
    condition=C;
    for(j=0;j<M;j++){
      condition+=A[i][j]*B[j];
    }
    if(condition>0){
      code+=1;
    }
  }
  printf("%d\n", code);
  return 0;
}


Measured memory_bytes: 128
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function gcd(a,b){return b?gcd(b,a%b):a;}
function segTree(n){
  var l = n.length, u = l-1, x = 2;
  while(u)u >>= 1, x <<= 1;
  var v = this.seg = Array(x-1).fill(0);
  this.l = x >> 1;
  x = this.l - 1;
  for(var i = 0; i < l; i++)v[i+x] = n[i];
  for(var i = x-1; i >= 0; i--)v[i] = segSolve(v[i+i+1],v[i+1<<1]);
}
function segSolve(a,b){
  return gcd(a,b);
}
segTree.prototype={
  get:function(l,r){
    if(l >= r)return 0;
    var v = this.seg;
    return q(l,r,0,this.l,0);
    function q(l,r,x,y,i){
      if(l === x && r === y)return v[i];
      var m = x+y >> 1;
      if(m < r)if(l < m)return segSolve(q(l,m,x,m,i+i+1),q(m,r,m,y,i+1<<1));
      else return q(l,r,m,y,i+1<<1);
      return q(l,r,x,m,i+i+1);
    }
  },
  update:function(x,i){
    var v = this.seg;
    i += this.l;
    v[i] = x;
    for(i >>= 1; i; i = i-1>>1){
      v[i] = segSolve(v[i+i+1],v[i+1<<1]);
    }
    v[0] = segSolve(v[1],v[2]);
  },
}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var seg = new segTree(a);
  var ans = 1;
  for(var i = 0; i < n; i++){
    ans = Math.max(ans, gcd(seg.get(0,i),seg.get(i+1,n)));
  }
  return ans;
}

Measured memory_bytes: 31980
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for(int i=0; i<N; ++i) cin >> A[i] >> B[i];
	long long ans = 0;
	for(int i=N-1; i>=0; --i) {
		int dif = (B[i] - (A[i]+ans)%B[i])%B[i];
		ans+=dif;
	}
	cout<<ans;
}

Measured memory_bytes: 1024
from subprocess import *
call(('pypy3','-c',"""
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    h,w=map(int,input().split())
    B=[[-1]*w for _ in range(h)]
    ans=0
    que=deque()
    for i in range(h):
        s=input()
        for j,ss in enumerate(s):
            if ss=="#":
                que.append((i,j))
                B[i][j]=0
    while que:
        qr,qc=que.popleft()
        for r,c in ((qr+1,qc),(qr-1,qc),(qr,qc+1),(qr,qc-1)):
            if r>=0 and r<=h-1 and c>=0 and c<=w-1 and B[r][c]==-1:
                B[r][c]=B[qr][qc]+1
                que.append((r,c))
    print(max([max(b) for b in B]))

if __name__=='__main__':
    main()
"""))

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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int main(){
ll N; cin>>N;
vi vec(N);
REP(i,N-1){
    int tmp=0; cin>>tmp;
    vec.at(tmp-1)++;
}
REP(i,N){
    cout<<vec.at(i)<<endl;
}
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int D;cin >> D;
    LL G;cin >> G;
    vector<int> p(D);
    vector<int> c(D);

    rep(i,D){
        cin >> p[i] >> c[i];
    }

    vector<int> bit_flag(11);
    rep(i,10){
        bit_flag[i] = (1 << i);
    }

    LL res = INF;

    for (int bit = 0; bit < (1<<D); ++bit){
        LL sum = 0;
        LL num = 0;
        rep(i,D){
            if(bit & bit_flag[i]){
                sum += c[i] + 100*(i+1)*p[i];
                num += p[i];
            }
        }
        if(sum >= G) res = min(res,num);
        else{
            for(int i = D-1;i>=0;i--){
                if(bit & bit_flag[i])continue;
                rep(j,p[i]){
                    if(sum >= G)break;
                    sum += 100*(i+1);
                    num++;
                }
            }
        }
        res = min(res,num);
    }
    cout << res << endl;
}

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



int main() {
    long int n, k;
    cin >> n >> k;
    
    n %= k;
    
    cout << min(n, abs(n-k)) << endl;
    
    return 0;
}


Measured memory_bytes: 3604