akhauriyash/Code-Regression huggingface dataset:
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
const ll m = 998244353;

const ll s = 1e7+2;
ll a[s];
int main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();

    /* long long yaad se daal de har jagah*/
    #define int long long
    int n,x;
    cin>>x>>n;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int y;
        cin>>y;
        mp[y]++;
    }
    int ans = 0;
    for(int i=0;i<=1000;i++){
        if(mp.find(x-i)==mp.end()){
            ans = x-i;
            break;
        }else if(mp.find(abs(x+i))==mp.end()){
            ans = x+i;
            break;
        }
    }
    cout<<ans;
    return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7 , mod = 1e9 + 7;
const double eps = 1e-9 , PI = acos(-1);

int n , k;
ll   a[N];
ll   f[N];
ll inv[N];

ll pow_(ll a,ll b,ll mod=1e9+7){
    ll ans=1ll;
    while(b){
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
void init(){
    f[0]=inv[0]=1;
    for(ll i=1; i<N; i++){
            f[i]=1ll*i*f[i-1]%mod,inv[i]=pow_(f[i],mod-2);
    }
}
ll C(ll n,ll m){
    if(n == 0)return 0;
    if(m <= 0)return 0;
    if(m > n) return 0;
    return f[n]*inv[n-m]%mod*inv[m]%mod;
}

void solve(int testCase){

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

    init();
    sort(a + 1 , a + n + 1);

    ll mn = 0 , mx = 0;
    for(int i = 1 ; i <= n ; i ++){
            mn += C(n - i , k - 1) * a[i] % mod;
            mx += C(i-1 , k-1) * a[i] % mod;
            mx %= mod;
            mn %= mod;
    }

    ll ans = (mx%mod - mn%mod + mod) %mod;
    printf("%lld\n" , ans);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

int main(){
	int N;
	cin >> N;
	int a[100], count = 0;
	for(int i = 0; i < N; i++) cin >> a[i];
	for(int i = 0; i < N; i++){
		for(int j = N - 1; j > i; j--){
			if(a[j-1] > a[j]){
				int z = a[j-1]; a[j-1] = a[j]; a[j] = z;
				count++;
			}
		}
	}
	for(int i= 0; i < N - 1; i++)
		cout << a[i] <<" ";
	cout << a[N - 1] << endl;
	cout << count << endl;
}

Measured memory_bytes: 1160
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    vector<ll> nearest(N, INT_MAX);
    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        if (a > b) {
            swap(a, b);
        }

        nearest[a] = min(nearest[a], b);
    }

    ll ans = N;
    ll min_value = INT_MAX / 2;
    for (ll i = N - 1; i >= 0; i--) {
        if (nearest[i] >= min_value) {
            ans--;
            continue;
        }

        min_value = i + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	long long arr[100001], lo, hi;
	cin >> n;
	for(int i=0; i<n; i++) cin >> arr[i];
	lo = hi = 2;
	for(int i=n-1; i>=0; i--){
		if(lo % arr[i]) lo += arr[i] - (lo % arr[i]);
		hi += arr[i] - (hi % arr[i]) - 1;
		if(hi < lo){
			cout << -1;
			return 0;
		}
	}
	cout << lo << ' ' << hi;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


signed main(){
    int m;
    while(cin >> m, m){
        vi a(m), b(m);
        rep(i, 0, m){
            cin >> a[i] >> b[i];
        }
        int dp[100][1001] = {0};
        dp[0][0] = 1;
        rep(i, 1, m + 1) {
            //cout << " " << a[i - 1] << " " << b[i - 1] <<endl;
            rep(k, 0, 1000){
                dp[i][k] = dp[i - 1][k];
            }
            rep(j, 1, b[i - 1] + 1){
                rep(k, 0, 1000){
                    if(k - a[i - 1]*j >= 0){
                        dp[i][k] += dp[i - 1][k - a[i - 1]*j];
                    }
                }
            }
            /*cout << " " << i << " ";
            rep(j, 0, 15){
                cout<<dp[i][j]<<" ";
            }
            cout << endl;*/
        }
        /*rep(i, 0, 15){
            cout<<dp[m][i]<<" ";
        }
        cout<<endl;*/
        int g;
        cin >> g;
        rep(i, 0, g){
            int n;
            cin >> n;
            cout << dp[m][n] <<endl;
        }
    }
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, q;
  std::cin >> n >> q;

  std::vector<std::set<int64_t>> node(n);

  for (int64_t i = 0; i < n - 1; i++) {
    int64_t p, q;
    std::cin >> p >> q;
    p--;
    q--;
    node[p].insert(q);
    node[q].insert(p);
  }

  std::vector<int64_t> count(n, 0);
  for (int64_t i = 0; i < q; i++) {
    int64_t p, x;
    std::cin >> p >> x;
    count[p - 1] += x;
  }

  std::vector<int64_t> ans(n, 0);
  ans[0] = count[0];

  std::vector<bool> flag(n, false);

  std::queue<std::pair<int64_t, int64_t>> que;
  for (const auto i : node[0]) {
    que.push(std::make_pair(0l, i));
  }
  flag[0] = true;

  while (!que.empty()) {
    const auto &v = que.front();
    if (flag[v.second]) {
    } else {
      flag[v.second] = true;
      ans[v.second] = count[v.second] + ans[v.first];

      for (const auto i : node[v.second]) {
        que.push(std::make_pair(v.second, i));
      }
    }
    que.pop();
  }

  for (int64_t i = 0; i < n; i++) {
    std::cout << ans[i];
    if (i != n - 1) {
      std::cout << " ";
    }
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 36864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	ll x;cin>>x;
	if(x<=6) puts("1");
	else if(x<=11) puts("2");
	else {
		ll y=x/11,z=x%11;
		y<<=1;
		if(z>0&&z<=6) y++;
		else if(z>0&&z>6) y+=2;
		cout<<y;
	}
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
   int t,flag=1;
   cin>>t;
   int i,n,r;
   char s[t+5];
   for(i=0;i<t;i++)
   {
       cin>>s[i];
   }

   n=t/2;
   r=t%2;
   if(r!=0)
   {
       flag  = 0;
   }
   else if(r==0)
   {
       for(i=0;i<n;i++)
       {
           if(s[i]!=s[i+n])
           {
               flag=0;
               break;
           }
       }
   }

   if(flag)
   {
       cout<<"Yes"<<'\n';
   }
   else
   {
       cout<<"No"<<'\n';
   }

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  
  for (int i=0; i<n; i++) {
    cin>>a.at(i);
  }
  
 for (int i=0; i<n; i++)
   cin>>b.at(i);
  
 for (int i=0; i<n-1; i++)
   cin>>c.at(i);
  
  int score = 0;
  score += b.at(a.at(0)-1);
  for (int i=1; i<n; i++) {
    score += b.at(a.at(i)-1);
    if (a.at(i)-1 == a.at(i-1))
      score += c.at(a.at(i)-2);
  }
  
  cout<<score<<endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;

#define now dp[st][pos][bits]

const int N = 15, INF = 0x3f3f3f3f;

int n, m, end;
int G[N][N];
int dp[N][N][1 << 16];
//dp i,j,k ??¨??????i????????????????????¨j????????????????????¶??????k??¶????????°?????????????°???????
//??¨??????????????¶??????????????¶????§???????0??????????????¶????????\??¨???????????\

inline int nextInt(void) {
	int res;
	scanf("%d", &res);
	return res;
}

inline void addEdge(int x, int y, int w) {
	G[x][y] = w;
}

inline void makeEnd(void) {
	end = 0;
	for (int i = 0; i < n; i++)
		end |= (1 << i);
}

int DP(int st, int pos, int bits) {
	//cout << "Searching for DP " << st << " " << pos << " " << bits << endl;
	if (~now)	//??°??????????´¢
		return now;
	if (st == pos&&bits == end)	//???????????°??????????????????????????????
		return now = 0;
	now = INF;
	for (int i = 0; i < n; i++)	//????????????
		if (i != pos &&!( (bits >> i) & 1))	//?????????????\??????????
			now = min(now, DP(st, i, bits | (1 << i)) + G[pos][i]);
	//cout << "Found DP " << st << " " << pos << " " << bits << " = " << now << endl;
	return now;
}

signed main(void) {
	memset(G, 0x3f, sizeof(G));
	memset(dp, -1, sizeof(dp));
	n = nextInt();
	m = nextInt();
	for (int i = 0; i < m; i++) {
		int x = nextInt();
		int y = nextInt();
		int w = nextInt();
		addEdge(x, y, w);
	}
	makeEnd();
	int ans = INF;
	for (int i = 0; i < n; i++)
		ans = min(ans, DP(i, i, 0));
	printf("%d\n", ans < INF ? ans : -1);
}

Measured memory_bytes: 58800
from itertools import permutations

n=int(input())
xy=[[0]*2 for i in range(n)]
a=[0]*n
for i in range(n):
    xy[i]=list(map(int,input().split()))
    a[i]=i    

icnt=0
rsum=0
for i in permutations(a):
    icnt+=1
    r=0
    for ii in range(len(i)-1):
        j=i[ii]
        k=i[ii+1]
        r=r+((xy[k][0]-xy[j][0])**2+(xy[k][1]-xy[j][1])**2)**0.5
    rsum=rsum+r

print(rsum/icnt)
    

Measured memory_bytes: 3064
#include <cstdio>

#define min(a, b) ((a) < (b) ? (a) : (b))

int main()
{
  int n;
  int bl, bc;
  scanf("%d %d", &n, &bc);
  int sum = bc;
  for (int i = 1; i < n - 1; ++i)
  {
    bl = bc;
    scanf("%d", &bc);
    sum += min(bl, bc);
  }
  sum += bc;
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		int e=sc.nextInt();
		int ans=0;
  		if(a==0){
        ans=1;
        }else if(b==0){
        ans=2;
        }else if(c==0){
        ans=3;
        }else if(d==0){
        ans=4;
        }else{
        ans=5;
        }
   
    	System.out.println(ans);
    }
}

Measured memory_bytes: 35668
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int n = sc.nextInt();
      boolean[] isPrime = new boolean[n+1];
      for (int i = 2; i <= n; i++) {
        isPrime[i] = true;
      }
      for (int i = 2; i*i <= n; i++) {
        if(isPrime[i]) {
          for (int j = 2*i; j <= n; j += i) {
            isPrime[j] = false;
          }
        }
      }
      int primeMax = 0;
      for (int i = n-1; ; i--) {
        if(isPrime[i]) {
          primeMax = i;
          break;
        }
      }
      int primeMin = n+1;
      searchMin:
      while(true) {
        for (int i = 2; i <= n; i++) {
          if (isPrime[i] && primeMin%i == 0) {
            primeMin++;
            continue searchMin;
          }
        }
        break;
      }
      System.out.println(primeMax+" "+primeMin);
    }
  }
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
const int maxn = 105;
char str[4][maxn];
int sum[4];
int len[4];
int main()
{
    scanf("%s%s%s",str[1],str[2],str[3]);
    int tmp=1;
    len[1]=strlen(str[1]);
    len[2]=strlen(str[2]);
    len[3]=strlen(str[3]);
    while(sum[tmp]!=len[tmp])
    {
        sum[tmp]++;
        tmp=str[tmp][sum[tmp]-1]-'a'+1;
    }
    printf("%c\n",'A'+tmp-1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <complex>
#include <iomanip>
#include <assert.h>
using namespace std;
typedef complex<double> P;
const double EPS = 1e-10;
int n;
double l[10];

struct C {
	P p;
	double r;

	C() {
		p = P(0, 0);
		r = 0;
	}

	C(const P& p, double r) : p(p), r(r) {
	}

	bool in(P t) {
		return norm(p - t) < r * r + EPS;
	}

	bool in(C t) {
		return abs(p - t.p) + t.r < r + EPS;
	}
} c[10];

bool check(double h) {
	for (int i = 0; i < n; i++) {
		if (l[i] * l[i] - h * h < EPS) return false;
		c[i].r = sqrt(l[i] * l[i] - h * h);
	}

	vector<P> cs;
	for (int i = 0; i < n; i++) {
		cs.push_back(c[i].p);
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			C c1 = c[i], c2 = c[j];
			if (abs(c1.p - c2.p) > c1.r + c2.r) return false; // ????????????
			if (c1.in(c2) || c2.in(c1)) continue;

			P v = c2.p - c1.p;
			double t = (c1.r * c1.r + norm(v) - c2.r * c2.r) / (2 * abs(v));
			double theta = acos(t / c1.r);
			//assert(-1.0 <= t / c1.r && t / c1.r <= 1.0);
			P b[2];
			b[0] = c1.p + v / abs(v) * c1.r * polar(1.0, theta);
			b[1] = c1.p + v / abs(v) * c1.r * polar(1.0, -theta);
			cs.push_back(b[0]);
			cs.push_back(b[1]);
		}
	}

	for (int i = 0; i < cs.size(); i++) {
		bool flag = true;
		for (int m = 0; m < n; m++) {
			if (!c[m].in(cs[i])) {
				flag = false;
				break;
			}
		}
		if (flag) return true;
	}
	return false;
}

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

	while (cin >> n , n) {
		for (int i = 0; i < n; i++) {
			double x, y;
			cin >> x >> y >> l[i];
			c[i].p = P(x, y);
		}
		check(0);
		double ok = 1, ng = 300;
		for (int loop = 0; loop < 100; loop++) {
			double h = (ok + ng) / 2;
			if (check(h)) ok = h;
			else ng = h;
		}
		cout << setprecision(15) << ok << endl;
	}
}

Measured memory_bytes: 1400
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  vector<int> a(N);
  for (size_t i = 0; i < N; i++) {
    cin >> a.at(i);
  }

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

  int sum = 0;
  int p = 1;

  for (size_t i = 0; i < N; i++) {
    sum += p * a.at(i);
    p *= -1;
  }
  sum = (sum > 0) ? sum : sum * -1;
  cout << sum;
}

Measured memory_bytes: 3588
n=int(input())
ht=list(map(int,input().split()))
ha=list(map(int,input().split()))
ans=ha[0]==ht[-1] and ha[ht.index(ht[-1])]==ht[-1]
m=10**9+7
cnt=0
for i,(t,a) in enumerate(zip(ht[1:n-1],ha[1:n-1])):
  if t<a and t==ht[i]:ans*=t
  elif t>a and a==ha[i+2]:ans*=a
  cnt+=t==a
  ans%=m
cnt+=(ha[0]==ht[0])+(ha[-1]==ht[-1])
ans*=pow(max(ha),max(cnt-2,0),m)
print(ans%m)

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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, unsigned n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

I r, c;
VI dx = {-1, 0, 0, 1};
VI dy = {0, 1, -1, 0};
vector<vector<int>> f(50, vector<int>(50, -1));
void DFS(I x, I y, I color, I & c0_num, I & c1_num) {
  if (color == 0) ++c0_num;
  else ++c1_num;
  color = 1 - color;
  f[x][y] = -1;
  rep(i, 0, 3) {
    I nx = x + dx[i];
    I ny = y + dy[i];
    if (nx >= 0 && nx < r && ny >= 0 && ny < c && f[nx][ny] != -1) {
      DFS(nx, ny, color, c0_num, c1_num);
    }
  }
}

int main(int argc, char const *argv[]) {
  I n;
  I ans = 0;
  cin >> n;
  VI f1(n + 1, 0);
  VI f2(n + 1, 0);
  I base = 0;
  rep(i, 1, n) {
    I a;
    cin >> a;
    base += a;
    f1[i] = base;
  }
  base = 0;
  rep(i, 1, n) {
    I a;
    cin >> a;
    base += a;
    f2[i] = base;
  }
  rep(i, 1, n) {
    I tans = f1[i] + f2[n] - f2[i - 1];
    if (tans > ans) ans = tans;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;
long long INF = 1000000009;
int main()
{
	int n, k;
	cin >> n >> k;
	int sum = 1;
	for (int i = 0; i < n; i++) {
		if (sum * 2 < sum + k) sum *= 2;
		else sum += k;
	}
	cout << sum << endl;
}

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

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

  int XYH[N + 5][3], ca;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> XYH[i][j];
    }
    if (XYH[i][2] > 0)
      ca = i;
  }

  for (int x = 0; x <= 1000; x++) {
    for (int y = 0; y <= 1000; y++) {
      bool flag = true;
      int H     = XYH[ca][2] + abs(XYH[ca][0] - x) + abs(XYH[ca][1] - y);
      for (int i = 0; i < N; i++) {
        int h = max(H - abs(XYH[i][0] - x) - abs(XYH[i][1] - y), 0);
        if (XYH[i][2] != h) {
          flag = false;
          break;
        }
      }

      if (flag) {
        cout << x << " " << y << " " << H << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> str(N);
  map<string, long long> cnt;
  for (int i = 0; i < N; i++) {
    cin >> str.at(i);
    sort(str[i].begin(), str[i].end());
    cnt[str[i]]++;
  }

  long long count = 0;
  for (auto& x : cnt) {
    long long v = x.second;
    count += v * (v - 1) / 2;
  }
  cout << count << endl;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, M;
  cin >> N >> M;
  vector<vector<pair<long, long>>> data(N, vector<pair<long, long>> (N,make_pair(INT_MAX, 0)));
  long a, b, c;
  for(int i = 0; i < M; i++){
    cin >> a >> b >> c;
    a--;
    b--;
    data.at(a).at(b).first = c;
    data.at(a).at(b).second = 1;
    data.at(b).at(a).first = c;
  }
  for(int i = 0; i < N; i++)data.at(i).at(i).first = 0;
  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        if(data.at(i).at(j).first > data.at(i).at(k).first + data.at(k).at(j).first){
          data.at(i).at(j).first = data.at(i).at(k).first + data.at(k).at(j).first;
          data.at(i).at(j).second = 0;
        }
      }
    }
  }
  long count = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      count += data.at(i).at(j).second;
    }
  }
  cout << M - count << endl;
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define compile 0
typedef unsigned long ULONG; //unsigned long をULONGとして別名宣言
ULONG func_euclides(ULONG num1, ULONG num2);
void func_output(ULONG num1, ULONG num2);
main()
{
	ULONG input1 = 0, input2 = 0, gcd = 0, lcm = 0; //gcd:最大公約数 lcm:最小公倍数
	while(scanf("%ld %ld", &input1, &input2) != EOF)
	{
		//func_prime(input1, input2);
		gcd = func_euclides(input1, input2);
		lcm = input1 * (input2 / gcd);
#if compile == 1
		printf("input1 = %ld input2 = %ld\n", input1, input2);
		printf("lcm = %ld\n", lcm);
#endif
		func_output(gcd, lcm);
	}
	return 0;
}
ULONG func_euclides(ULONG num1, ULONG num2)
{
	ULONG quot = 0, sur = 0; //quot:商 sur:余り
	
	quot = num1 / num2;
	sur = num1 % num2;
	if(sur == 0)
	{
#if compile == 1
		printf("GCD = %ld\n", num2);
#endif
		return num2;
	}
	else if(sur != 0)
	{
#if compile == 1
		printf("num1 = %ld num2 = %ld\n", num2, sur);
#endif
		func_euclides(num2, sur);
	}
}
void func_output(ULONG num1, ULONG num2)
{
	printf("%ld %ld\n", num1, num2);
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

int main(){
  vector<int> line(4);
  cin>>line;
  sort(all(line));
  int sum = line[0] + line[3] - line[1] - line[2];
  cout << abs(sum) << endl;
  return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if ((a <= c && c <= b) || (a >= c && c >= b)) Yes();
  else No();
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        if(i%2==0 && a[i]%2==1)sum++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3528
#include<stdio.h>
#include<math.h>
int main(){
 	int i;
  int n;
  int x,y,z;
  	int ans = 0;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
 	for(x=1;x<=sqrt(i);x++){
      for(y=x;y<=sqrt(i);y++){
        for(z=y;z<=sqrt(i);z++){
      		if(x*x+y*y+z*z+x*y+y*z+z*x == i){
             if(x!=y&&y!=z&&z!=x){
               ans+=6;
             }
              else if(x==y&&y!=z){
                ans+=3;
              
              }
              else if(x!=y&&y==z){
               ans+=3; 
              }
              else if(x==y&&y==z){
               ans+=1; 
              }
              
              
            }
        }
      }
    }
    printf("%d\n",ans);
    ans=0;
  }

  return 0;
}




Measured memory_bytes: 2128
use std::io::*;

fn show(a: u32, b: u32) {
  println!("{:032b}", a & b);
  println!("{:032b}", a | b);
  println!("{:032b}", a ^ b);
}

fn main() {
  let stdin = stdin();
  let line = stdin.lock().lines().next().unwrap().unwrap();

  let mut iter = line.split_whitespace().map(|s| s.parse().unwrap());
  let (a, b) = (iter.next().unwrap(), iter.next().unwrap());

  show(a, b);
}



Measured memory_bytes: 5020
#include<stdio.h>
int main()
{
    int x,y, temp;
    while(1)
    {
        scanf("%d %d", &x, &y);
        if(x==0 && y==0)break;
        else if(x>y)
    {
        temp=x;
        x=y;
        y=temp;
    }
    printf("%d %d\n", x, y);
    }
    return 0;
}


Measured memory_bytes: 2760
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<"0"<<endl;
        return 0;
    }
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i]-i-1;
    }
    sort(b,b+n);
    long long sad1=0,sad2=0;
    for(int i=0;i<n;i++){
        sad1+=abs(a[i]-b[n/2]-i-1);
        sad2+=abs(a[i]-b[n/2+1]-i-1);
    }
    cout<<min(sad1,sad2)<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<unordered_set>
#include<cmath>
#include<tuple>
#include<numeric>
#include<iterator>
#include<set>
#include<unordered_map>
#include<map>


#define fastio                      ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lp(i , aa , bb)               for(auto i = aa ; i < bb ; i++)
#define dbg(a)                      cout << "here is " << a << "\n";
#define ain(a , n)                  for(auto i = 0 ; i < n ; i++) cin >> a[i]
#define aout(a , n)                 for(auto i = 0 ; i < n ; i++) cout << a[i] << " "
#define dist(a , b , x , y)         abs(x - a)*abs(x - a) + abs(y - b)*abs(y - b)
#define M                           998244353
#define mp                          make_pair
#define mt                          make_tuple

using namespace std;
typedef unsigned long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <char> vch;
typedef vector <string> vs;

/*----------------------------- # --- MATH ALGORITHMS --- # -----------------------------*/

template <class T> T gcd(T a , T b){ while(a != 0){T temp = a; a = b % a; b = temp;}return b;}
template <class T> T egcd(T a , T b , T &x , T &y){T gcd , xt , yt;if(a == 0){gcd = b;x = 0 , y = 1;}else {gcd = egcd(b % a , a , xt , yt);x = yt - (b/a)*xt; y = xt;}return gcd;}
template <class T> T expo(T base , T exp , T mod){T res = 1;base = base % mod;while (exp > 0){if (exp & 1)res = (res*base) % mod;exp = exp>>1;base = (base*base) % mod;}return res;}
template <class T> T modinv(T a , T mod){T x , y; egcd<T>(a , mod , x , y);while(x < 0) x += mod; while(x >= mod) x -= mod; return x;}
template <class T> T modinvfermat(T a , T mod){return expo<T>(a , mod - 2 , mod);}
template <class T> bool rev(T a , T b){return a > b;}
template <class T> int maxpower(T a , T b){int ans = 0;while(a > 0 && a % b == 0){ans++;a /= b;}return ans;}


/*----------------------------- # --- MAIN CODE --- # -----------------------------*/

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
}





















Measured memory_bytes: 256
a= gets.split.map(&:to_i)
b= gets.split.map(&:to_i)
c= gets.split.map(&:to_i)
d = []
n = gets.to_i
for j in 0..n-1 do
num = gets.to_i
  d << num
end
if d.include?(a[0]) && d.include?(a[1]) && d.include?(a[2])
  puts "Yes"
elsif d.include?(b[0]) && d.include?(b[1]) && d.include?(b[2])
  puts "Yes"
elsif d.include?(c[0]) && d.include?(c[1]) && d.include?(c[2])
  puts "Yes"
elsif d.include?(a[0]) && d.include?(b[0]) && d.include?(c[0])
  puts "Yes"
elsif d.include?(a[1]) && d.include?(b[1]) && d.include?(c[1])
  puts "Yes"
elsif d.include?(a[2]) && d.include?(b[2]) && d.include?(c[2])
  puts "Yes"
elsif d.include?(a[0]) && d.include?(b[1]) && d.include?(c[2])
  puts "Yes"
elsif d.include?(a[2]) && d.include?(b[1]) && d.include?(c[0])
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i,n)cin >> x[i];
	int ans = INF;
	for(int i=1;i<=100;i++)
	{
		int now = 0;
		rep(j,n)
		{
			now += (x[j]-i)*(x[j]-i);
		}
		ans = min(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {


    string s; cin >> s;
    ll n = s.length();

    while(s.length() > 0){
        if(s[n-1] == 'e'){
            if(n >= 5 && s.substr(n-5,n) == "erase"){
                s = s.substr(0,n-5);
                n = s.length();
            }else{
                cout << "NO";
                return 0;
            }
        }else if(s[n-1] == 'm'){
            if(n >= 5 && s.substr(n-5,n) == "dream"){
                s = s.substr(0,n-5);
                n = s.length();
            }else{
                cout << "NO";
                return 0;
            }
        }else if(s[n-1] == 'r'){
            if(n >= 7 && s.substr(n-7,n) == "dreamer"){
                s = s.substr(0,n-7);
                n = s.length();
            }else if(n >= 6 && s.substr(n-6,n) == "eraser"){
                s = s.substr(0,n-6);
                n = s.length();
            }else{
                cout << "NO";
                return 0;
            }
        }else{
            cout << "NO";
            return 0;
        }
    }


    cout << "YES";
    return 0;
}


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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int res = 0;
  int c;

  for (int i = 1; i <= N; ++i){
    c = i % 10 + (i % 100) / 10 + (i % 1000) / 100 + (i % 10000) / 1000 + i / 10000;
    if (A <= c && c <= B) res += i;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
def checkPalindrome(str1, str2):
  for i in range(len(str1) // 2):
    if str1[i] != str2[i]:
      return False
  return True
    
s = input()
rs = ''.join(list(reversed(s)))
cri1 = checkPalindrome(s, rs)

s2 = s[:len(s) // 2]
rs2 = ''.join(list(reversed(s2)))
cri2 = checkPalindrome(s2, rs2)

s3 = s[len(s) // 2 + 1:len(s)]
rs3 = ''.join(list(reversed(s3)))
cri3 = checkPalindrome(s3, rs3)

if cri1 and cri2 and cri3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,x,t = map(int, input().split())
    ans = 0
    while True:
        ans += t
        n-=x
        if n<=0:
            break
    print(ans)


if __name__=="__main__":
    main()


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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;

    int arr[n];
    for (int i=0; i<n; i++){
        arr[i]=0;
    }

    for (int i=0; i<k; i++){
        int n1;
        cin >> n1;

        for (int j=0; j<n1; j++){
            int x;
            cin >> x;
            arr[x-1]++;
        }
    }

    int ans=0;

    for (int i=0; i<n; i++){
        if (arr[i]==0){
            ans++;
        }
    }

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

    return 0;
}


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

int main(){
    int64_t n, a, b;
    cin >> n >> a >> b;
    vector<int64_t> H(n);
    copy_n(istream_iterator<int64_t>(cin), n, H.begin());

    auto check = [&](const auto &mid){
        auto c = a - b;
        auto k = mid;
        for (auto h: H){
            h -= mid * b;
            if (h <= 0) continue;
            k -= (h + c - 1) / c;
        }

        return k >= 0;
    };

    int64_t l = -1, r = 1e9;
    while (r - l > 1){
        auto mid = (l + r) / 2;
        (check(mid) ? r : l) = mid;
    }

    cout << r << endl;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int a[100005];

int main() {
    int n,q = -1,count = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int j = 0; j < n-1; j++) {
        if (a[j] <= a[n-1]) {
            q++;
            int v = a[j];
            a[j] = a[q];
            a[q] = v;
        }
    }
    int v = a[q+1];
    a[q+1] = a[n-1];
    a[n-1] = v;

    for (int k = 0; k < n; k++) {
        cout << (k == q+1?"[":"") << a[k] << (k == q+1?"]":"") << (k == n-1?"":" ");
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
int K;
vector<int> D(10);

bool ok(string n) {
  for(int i = 0; i < K; i++) {
    auto pos = n.find(to_string(D[i]));
    if(pos != string::npos) return false;
  }
  return true;
}

int main() {
  int N; cin >> N >> K;
  for(int i = 0; i < K; i++) cin >> D[i];
  for(int i = N; i < 100000; i++) {
    if(ok(to_string(i))) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


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

int main() {
  int n, l;
  cin >> n >> l;

  vector<string> s(n);
  rep(i, n) cin >> s.at(i);

  sort(s.begin(), s.end());
  string ans = "";
  rep(i, n) ans += s.at(i);

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

Measured memory_bytes: 256
D,N = map(int,input().split())
if D==0 and N<=99:
    print(1+N-1)
elif D==0 and N==100:
    print(101)
elif D==1 and N<=99:
    print(100*N)
elif D==1 and N==100:
    print(10100)
elif D==2 and N<=99:
    print(10000*N)
elif D==2 and N==100:
    print(10000*101)

Measured memory_bytes: 9176
#include<iostream>
using namespace std;
typedef long long ll;
ll ryuka(int l) {
	ll a[90];
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i <= l; i++) {
		a[i] = a[i - 2] + a[i - 1];
	}
	if (l == 0) {
		
		return 2;
	}
	if (l == 1) {
		
		return 1;
	}
	else {
		
		
		return a[l];
	}
}
int main() {
	int n;
	cin >> n;
	ll sum = ryuka(n);
	cout << sum << endl;
	return 0;

}

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

#define LL long long
#define mods 1000000009



int main()
{
   // factorila();
    //freopen("amin.txt","w",stdout)
    long long n,i;
    cin>>n;
    i=n/15;
    LL ans=0;
    ans=n*800;
    ans=ans-i*200;
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
d = int(input())
nums = map(int, input().split(' '))
num_dict = {}
for i, n in enumerate(nums):
  num_dict[i+1] = n
sorted_num_dict = sorted(num_dict.items(), key=lambda x:x[1])
l = [str(a[0]) for a in sorted_num_dict]
s = ' '.join(l)
print(s)

Measured memory_bytes: 31192
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    let mut t: Vec<char> = Vec::new();
    let mut i = 0;
    while i < s.len() {
        if s[i] == 'B' && i + 1 < s.len() && s[i + 1] == 'C' {
            t.push('D');
            i += 2;
        } else {
            t.push(s[i]);
            i += 1;
        }
    }

    let mut counts: Vec<usize> = vec![0; t.len()];
    if t[t.len() - 1] == 'D' {
        counts[t.len() - 1] = 1;
    }
    if t.len() < 2 {
        return "0".to_string();
    }
    for i in (0..=(t.len() - 2)).rev() {
        if t[i] == 'D' {
            counts[i] = counts[i + 1] + 1;
        } else if t[i] == 'A' {
            counts[i] = counts[i + 1];
        } else {
            counts[i] = 0;
        }
    }

    let mut ans = 0;
    for i in 0..t.len() {
        if t[i] == 'A' {
            ans += counts[i];
        }
    }
    ans.to_string()
}


Measured memory_bytes: 5224
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
-- templete

list = runSTArray $ do
    arr <- newArray (-2,30) 0 :: ST s (STArray s Int Integer)
    writeArray arr 0 1
    forM_ [1..30] $ \i -> forM_ [1..3] $ \j -> (+) <$> readArray arr i <*> readArray arr (i-j) >>= writeArray arr i
    return arr

main = takeWhile (/=0) . map readInt . lines <$> getContents >>= mapM_ (print . flip divCeil 3650 . (list!))
    



Measured memory_bytes: 3964
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<vector<int> > E(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }

    vector<int> from(N, -1);
    queue<int> Q;
    Q.push(0);
    from[0] = 0;
    while(!Q.empty()) {
        int i = Q.front();
        assert(from[i] != -1);
        Q.pop();
        for (auto j : E[i]) if (from[j] == -1) {
            from[j] = i;
            Q.push(j);
        }
    }

    REP(i, N) if (from[i] == -1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    FOR(i, 1, N)
        cout << from[i]+1 << endl;
    
    return 0;
}

Measured memory_bytes: 10228
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    string s1, s2;
    cin>>s1>>s2;
    bool ok=true;
    rep(i, 3){
        if(s1[i]!=s2[2-i]) ok=false;
    }
    cout<<(ok ? "YES" : "NO")<<endl;
    return 0;
}


Measured memory_bytes: 3600
s,a,b=`dd`.split
z,*s=s.split(?T,-1).map &:size
Y=Z=1<<8e3
X=Y<<z
s.size%2>0&&s<<0
s.map{|t|Y=Y>>t|Y<<t
X,Y=Y,X}
puts X>>a.to_i&Y>>b.to_i&Z>0?:Yes: :No

Measured memory_bytes: 27272
R, G, B, N = map(int, input().split())
     
ans = 0
for r in range(int(N/R)+1):
    for g in range(int(N/G)+1):
        if r*R + g*G <= N:
            if (N - (r*R + g*G))%B == 0:
                ans += 1
     
print(ans)


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

int main() {
  int a, b;
  cin >> a >> b;
  if(a >= b){
    for(int i = 0; i < a; i++){
      cout << b;
    }
    cout << endl;
  }
  else{
    for(int i = 0; i < b; i++){
      cout << a;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 256
import math
N,A,B = map(int,input().split())
v = list(map(int,input().split()))
d = {}
for value in v:
    if value not in d:
        d[value] = 1
    else:
        d[value] += 1
sortedDict = list(reversed(sorted(d.items(), key=lambda x: x[0])))
i = 0
s = 0
number = 0
while True:
    value,count = sortedDict[i]
    if A > count:
        A -= count
        B -= count
        i += 1
        s += count*value
        number += count
    else:
        s += A*value
        number += A
        break
        # A<=countが保証される
ans = 0
def combination(n,k):
    return (math.factorial(n)//math.factorial(k)//math.factorial(n-k))
if i == 0:
    upper = min(count,B)
    for j in range(A,upper+1):
        ans += combination(count,j)
else:
    ans = combination(count,A)
average = s/number
print(average)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const ll inf = INT_MAX;
const double eps = 1e-8;
const double pi = acos(-1.0);

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) {
    cin >> a[i];
  }
  int ans = 0;
  REP(i, n) {
    if (a[a[i] - 1] == i + 1)
      ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<bitset>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int N, M;
bool A[700][700];
int D[700];
bool dame;
int dfs(int v, int d) {
	if (dame) return 0;
	D[v] = d;
	int ret = (d & 2) - 1;
	auto a = A[v];
	for (int to = 0; to < N; to++) if (!a[to]) {
		if (!D[to]) ret += dfs(to, d ^ 2);
		else if (D[to] == d) {
			dame = 1;
			return 0;
		}
	}
	return ret;
}

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


	N = getint();
	M = getint();
	rep(i, M) {
		int a = getint() - 1, b = getint() - 1;
		A[a][b] = true;
		A[b][a] = true;
	}
	rep(i, N) A[i][i] = true;

	int kouho[700];
	int k = 0;
	int mannnaka = 0;
	rep(i, N) if (!D[i]) {
		int tmp = abs(dfs(i, 1));
		if (dame) {
			printf("-1");
			return 0;
		}
		mannnaka += tmp;
		kouho[k++] = tmp;
	}


	bitset<710> BS(0);
	BS[0] = 1;
	rep(i, k) BS |= BS << kouho[i];

	int saishou = 1e9;
	for (int i = 0; i <= mannnaka; i++) {
		if (BS[i]) chmin(saishou, abs(i * 2 - mannnaka));
	}
	int X = (N + saishou) / 2;
	int Y = (N - saishou) / 2;
	int kotae = X * (X - 1) / 2 + Y * (Y - 1) / 2;

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 768