akhauriyash/Code-Regression huggingface dataset:
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, n) {cin >> a[i];}
#define readmat(a, n, m) int a[(n) + 1][(m) + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int INF = 4e18;
const int mod = 1e9+7; 

vi fact(3e6);

void lol()
{
    fact[0] = 1;
    fori (i, 1, 3e6-1) fact[i] = fact[i-1] * i % mod;
}
 
int power(int x, int y) 
{ 
    int res = 1;
    x = x % mod; 
  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % mod; 
        y = y>>1LL; 
        x = (x*x) % mod;   
    } 
    return res; 
}

int inv(int n) 
{ 
    return power(n, mod-2); 
} 

int ncr (int n, int r)
{
    n++; r++;
    return fact[n] * inv(fact[n-r]) % mod * inv(fact[r]) % mod;
}


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

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    lol();

    readb(r1, c1) readb(r2, c2)

    int ans = 0;

    fori (i, r1, r2)
    {
        int x = ncr(c1-1 + i, i);
        int y = ncr(c2 + i, i);

        ans += (y - x + mod) % mod;
        ans %= mod;
    }

    print(ans)

    return 0;
}




Measured memory_bytes: 26612
import java.util.Scanner;

class Main{
    
    private static int a,b;
public static void main(String[] args){
    
    Scanner s= new Scanner(System.in);
a=s.nextInt();
b=s.nextInt();
System.out.printf("%d %d %.5f\n", (a/b),(a%b),((double)a/b));
    
}
}



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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int func(int x) {
	if (x % 100 != 0) return 0;
	return func(x / 100) + 1;
}

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

	int cnt = 0;
	for (int i = 1; ; i++) {
		if (func(i) == d) {
			cnt++;
			if (cnt == n) {
				cout << i << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            if (line == "AAA" || line == "BBB")
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
        }
    }
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ');
			var a = firstLine[0];
			var b = firstLine[1];
			var c = firstLine[2];

			Console.WriteLine(a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0] ? "YES" : "NO");
		}
	}
}


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

using namespace std;
long gcd(long a, long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

int main(int argc, char const *argv[]) {
  int N, X;
  cin >> N >> X;
  vector<long> x(N + 1);

  for (int i = 1; i < N + 1; i++) {
    long point;
    cin >> point;
    x[i] = abs(point - X);
  }

  long ans = x[1];
  for (int i = 2; i < N + 1; i++) {
    ans = gcd(ans, x[i]);
  }

  cout << ans << "\n";

  return 0;
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int r;
int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> r;
	cout << r*r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char S[105];

int main() {

	int N;

	scanf("%d",&N);

	int i;

	int flag=0;

	for(i=0;i<N;i++){
		scanf(" %c",&S[i]);
		if(S[i]=='Y'){flag=1;}
	}
	if(flag==0){
		printf("Three\n");
	}
	else{
		printf("Four\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    vector<int> root(n);
    vector<vector<int>> subset(n);
    vector<int> dist(n);

    for (int i = 0; i < n; ++i) {
        root[i] = i;
        subset[i] = {i};
        dist[i] = 0;
    }

    for (int i = 0; i < m; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;

        if (root[l] == root[r]) {
            if (dist[r] - dist[l] != d) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            int src, dst, diff;
            if (subset[root[l]].size() < subset[root[r]].size()) {
                src = root[l];
                dst = root[r];
                diff = -d + dist[r] - dist[l];
            } else {
                src = root[r];
                dst = root[l];
                diff = d + dist[l] - dist[r];
            }
            for (auto &&idx  : subset[src]) {
                root[idx] = dst;
                subset[dst].push_back(idx);
                dist[idx] += diff;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 10236
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

ll res[MAX][2];
vii adj[MAX];

void dfs(int curr = 0, int prev = -1) {
    res[curr][0] = res[curr][1] = 1;
    for (int node : adj[curr]) {
        if (node == prev) continue;
        dfs(node, curr);
        res[curr][0] = (res[curr][0] * (res[node][0] + res[node][1])) % MOD;
        res[curr][1] = (res[curr][1] * res[node][0]) % MOD;
    }
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs();
    cout << (res[0][0] + res[0][1]) % MOD << '\n';
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
	  if(k<u->key) u=u->left;
	  else u=u->right;
	  }
	  return u;
}

Node treeSuccessor(Node x){
 
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
	  y=x;
	  if(z->key < x->key) x=x->left;
	  else x=x->right;
	  }
  z->parent=y;
  if(y==NIL) root=z;
  else if(z->key < y->key) y->left=z;
  else y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
	  inorder(u->left);
	  printf(" %d",u->key);
	  inorder(u->right);
	  }
}
void preorder(Node u){
  if(u!=NIL){
	  printf(" %d",u->key);
	  preorder(u->left);
	  preorder(u->right);
	  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

typedef long long ll;
using namespace std;
int main()
{

  ll n,d[110][2];
  ll cnt=0;

  cin>>n;
  rep(i,n){
    rep(j,2){
      cin>>d[i][j];
    }
  }

  rep(i,n){
    if(d[i][0]==d[i][1]){
      cnt++;
      if(cnt==3){
        cout<<"Yes"<<endl;
        return 0;
      }
    }else{
      cnt=0;
    }
  }


  cout<<"No"<<endl;
  return 0;
}


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

// １からNまでの総和を求める関数
int sumN(int N){
	if(N == 1){
		return 1;
	}
	return sumN(N - 1) + N;
}

int main() {
	int a, b;
	cin >> a >> b;
	int x;
	for(int n = 2; n <= 999; n++){
		if(sumN(n) - b == sumN(n - 1) - a){
			x = sumN(n) - b;
			break;
		}
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof a)
#define  For(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define rFor(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
using namespace std;
typedef long long LL;
const int N=200010;
template<typename T>inline T chkmax(T _A,T _B){return _A>_B?_A:_B;}
template<typename T>inline T chkmin(T _A,T _B){return _A<_B?_A:_B;}
template<typename T>void read(T&x)
{
    x=0;int _f(0);char ch=getchar();
    while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
    while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}
int n,dep[N],fa[N],sz[N];
int bgn[N],nxt[N],to[N],E;
inline void add_edge(int u,int v){nxt[++E]=bgn[u],bgn[u]=E,to[E]=v;}
inline void dfs(int u,int f)
{
	dep[u]=dep[f]+1;
	fa[u]=f;
	sz[u]=1;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		if((v=to[i])==f)continue;
		dfs(v,u);
		sz[u]+=sz[v];
	}
}
inline void solve()
{
	int dis=dep[n]-dep[1];
	int x=n;
	if(dis&1)
	{
		dis=dis/2;
		For(i,1,dis)
			x=fa[x];
		int a=sz[x]-dis-1;
		int b=sz[1]-sz[x]-dis-1;
		if(a>=b)
			puts("Snuke");
		else
			puts("Fennec");
	}
	else
	{
		dis=dis/2-1;
		For(i,1,dis)
			x=fa[x];
		int a=sz[x]-dis-1;
		int b=sz[1]-sz[x]-dis-2;
		if(a>b)
			puts("Snuke");
		else
			puts("Fennec");
	}
}
int main()
{
	int x,y;
	read(n);
	For(i,2,n)
	{
		read(x),read(y);
		add_edge(x,y),add_edge(y,x);
	}
	dfs(1,0);
	solve();
	return 0;
}


Measured memory_bytes: 6912
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
s = input()

ans = "Good"
for i in range(1,len(s)):
    if s[i-1] == s[i]:
        ans = "Bad"
    else:
        continue

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
vi v[50][50];
int h, w, m;
int a[50][50], b[50][50], c[50][50], dir[50][50][50][50];
char in[50][51];

void rec(int y, int x, int sy, int sx, int py, int px){
	rep(d, 4){
		int ny = y + dy[d], nx = x + dx[d];
		if(ny == py && nx == px) continue;
		if(ny < 0 || nx < 0 || ny >= h || nx >= w || in[ny][nx] == '#') continue;
		dir[ny][nx][sy][sx] = d;
		rec(ny, nx, sy, sx, y, x);
	}
}
int dp[2000][2];
int calc(const vi &v, int y, int x){
	int n = v.size();
	if(n == 1) return b[y][x] + c[y][x];
	rep(i, n) rep(j, 2) dp[i][j] = inf;
	dp[0][0] = b[y][x] + c[y][x];
	dp[0][1] = b[y][x];
	
	rep(i, n - 1) rep(j, 2) if(dp[i][j] < inf) rep(k, 2){
		int nxt = dp[i][j];
		nxt += j ? (v[i + 1] - v[i]) * a[y][x] : b[y][x];
		if(!k) nxt += c[y][x];
		
		dp[i + 1][k] = min(dp[i + 1][k], nxt);
	}
	return dp[n - 1][0];
}
int main(){
	cin >> h >> w >> m;
	rep(i, h) cin >> in[i];
	rep(i, h) rep(j, w) cin >> a[i][j];
	rep(i, h) rep(j, w) cin >> b[i][j];
	rep(i, h) rep(j, w) cin >> c[i][j];
	rep(i, h) rep(j, w) if(in[i][j] == '.') rec(i, j, i, j, i, j);
	
	int ny, nx, y, x, t = 0;
	cin >> y >> x;
	v[y][x].pb(t);
	rep(i, m - 1){
		cin >> ny >> nx;
		do{
			int d = dir[y][x][ny][nx];
			y -= dy[d]; x -= dx[d];
			v[y][x].pb(++t);
		}while(ny != y || nx != x);
	}
	int ans = 0;
	rep(i, h) rep(j, w) if(v[i][j].size()) ans += calc(v[i][j], i, j);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 29096
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).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 INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N,M;
pii data[114514];
vi G[114514];
int main(){
	cin>>N>>M;
	rep(i,N)data[i]=mp(0,0);
	rep(i,M){
		int x,y;
		cin>>x>>y;x--;y--;
		G[y].pb(x);
		data[x].second++;
	}
	
	queue<int> hoge;
	rep(i,N){
		if(data[i].second==0){
			hoge.push(i);
			//cout<<i<<endl;
		}
	}
	while(!hoge.empty()){
		int now=hoge.front();
		hoge.pop();
		rep(i,G[now].size()){
			int nex=G[now][i];
			data[nex].first = max(data[now].first+1,data[nex].first);
			data[nex].second--;
			if(data[nex].second==0)hoge.push(nex);
		}
		
	}
	int ma=0;
	rep(i,N){
		ma=max(ma,data[i].first);
	}
	cout<<ma<<endl;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll p = 1e9+7;

int main(){
  ll s;
  cin>>s;
  vector<int> dp(s+1,0);
  dp[0]=1;
  for(int i=3;i<=s;i++){
    dp[i]=dp[i-3]+dp[i-1];
    dp[i]%=p;
  }
  cout<<dp[s]%p<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const long long mod=1e9+7; //10^9+7



int main() {
    int n,d;
    double x[20][20];

    cin >> n >> d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1;j<n;j++){
            double distance = 0;
            for(int k=0;k<d; k++){
                distance += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            distance = sqrt(distance);
            if(ceil(distance) == floor(distance))ans++;
        }
    }
    cout << ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int N=1e4+5;
ll dp[N][150][2],sum,ans;
int n;string s;
int main()
{
	cin>>s>>n;
	sum=s[0]-'0';
	dp[0][sum%n][1]=1;
	for(int i=0;i<s[0]-'0';i++)dp[0][i%n][0]+=1;
	for(int i=1;i<s.size();i++)//位数 
	{
		sum+=s[i]-'0';
		for(int j=0;j<n;j++)//上一次 
		{
			for(int k=0;k<10;k++)//canadd
			{
				dp[i][(j+k)%n][0]+=dp[i-1][j][0];
				dp[i][(j+k)%n][0]%=mod;
				if(k<s[i]-'0')
				{
					dp[i][(j+k)%n][0]+=dp[i-1][j][1];
					dp[i][(j+k)%n][0]%=mod;
				}
			}
		}
		dp[i][sum%n][1]=1;
	}
	cout<<(dp[s.size()-1][0][0]+dp[s.size()-1][0][1]-1+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 23680
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc159
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc159B();
        }

        public static void solve_abc159B()
        {
            string s = Console.ReadLine();
            bool ok = true;

            int l = 0;
            int r = s.Length - 1;
            ok = isPalindrom(s, l, r);
            if (ok)
            {
                ok = isPalindrom(s, 0, ((s.Length - 1) / 2) - 1);
            }
            if (ok)
            {
                ok = isPalindrom(s, ((s.Length + 3) / 2) - 1, s.Length - 1);
            }
            if (ok)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        public static bool isPalindrom(string s, int l, int r)
        {
            bool ok = true;
            while (l < r)
            {
                if (s[l] != s[r])
                {
                    ok = false;
                    break;
                }
                l++;
                r--;
            }
            return ok;
        }

        public static void solve_abc159A()
        {
            int[] nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            long even = 0;
            if (nm[0] > 1)
            {
                even = combs(nm[0], 2);
            }
            long odd = 0;
            if (nm[1] > 1)
            {
                odd = combs(nm[1], 2);
            }
            Console.WriteLine(even + odd);
        }
        public static long combs(int n, int k)
        {
	        int res = 1;
	        for (int i = n - k + 1; i <= n; i++)
            {
		        res *= i;
            }
	        for (int i = 2; i <= k; i++)
            {
		        res /= i;
            }
            return res;
            /*double res = 1;
	        for (int i = 1; i <= k; i++)
            {
		        res = res * (n - k + i) / i;
            }
	        return (long) (res + 0.01);
            */
        }
    }
}


Measured memory_bytes: 13140
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A+1):
    if 500*a > X:
        continue
    for b in range(B+1):
        if 100*b > X-500*a:
            break
        for c in range(C+1):
            if 50*c > X-500*a-100*b:
                break
            if 50*c == X-500*a-100*b:
                count+=1
print(count)

Measured memory_bytes: 3064
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n = read1::<usize>();
    let mut ans = 0;
    let mut c = vec![vec![0; 10]; 10];

    for i in 1..n+1 {
        let k2 = i % 10;
        let mut k1 = i;
        while k1 >= 10 {
            k1 /= 10;
        }
        c[k1][k2] += 1;
    }
    for i in 1..10 {
        for j in 1..10 {
            ans += c[i][j] * c[j][i];
        }
    }

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

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF /*1000000007*/ 1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;

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

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

int main() {

	int N, K, L;
	cin >> N >> K >> L;

	UnionFind uf1(N), uf2(N);
	for (int i = 0; i < K;++i) {
		int p, q;
		cin >> p >> q; --p; --q;
		uf1.merge(p, q);
	}
	for (int i = 0; i < L; ++i) {
		int r, s;
		cin >> r >> s; --r; --s;
		uf2.merge(r, s);
	}

	map<P, int>m;
	for (int i = 0; i < N;++i) {
		m[make_pair(uf1.root(i), uf2.root(i))]++;
	}

	for (int i = 0; i < N;++i) {
		cout << m[make_pair(uf1.root(i), uf2.root(i))] << ' ';
	}
}

Measured memory_bytes: 13568
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char s[101],t[101],wk;
	int i,j,flg,len;
	scanf("%s",s);
	scanf("%s",t);
	len=strlen(s);
	flg=0;
	for(i=0;i<len;i++)	{
		if(strcmp(s,t)==0)	{
			flg=1;
			break;
		}
		wk=s[0];
		for(j=1;j<len;j++)	{
			s[j-1]=s[j];
		}
		s[len-1]=wk;
	}
	if(flg==0)	printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    int h, w, n; cin >> h >> w >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int m[h][w];
    int index = 0;
    for (int i = 0; i < h; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; j++) {
                m[i][j] = index + 1;
                a[index]--;
                if (a[index] == 0)
                    index++;
            }
        } else {
            for (int j = w-1; j >= 0; j--) {
                m[i][j] = index + 1;
                a[index]--;
                if (a[index] == 0)
                    index++;
            }
        }
    }
    rep(i,h) {
        rep(j,w) {
            cout << m[i][j] << " ";
        }
        cout << endl;
    }

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,int> P;
const double DINF=100000000000000.0;



struct edge {int to;double cost;};

const int M_N=10000;

vector<edge> G[M_N+1];
double d[M_N+1];

struct Dijkstra{

    void dijkstra(int s){
        priority_queue<P,vector<P>,greater<P>> que;
        que.push(P(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first) continue;
            for(int i=0;i<G[v].size();i++){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(P(d[e.to],e.to));
                }
            }
        }
    }

};

int main(){
    Dijkstra Ds;
    fill(d,d+M_N+1,DINF);
    d[0]=0.0;
    double a,b,c,t;
    cin >> a >> b >> c >> t;
    int N;
    cin >> N;
    vector<double> x,y,l;
    x.pb(a);
    y.pb(b);
    l.pb(0);
    for(int i=0;i<N;i++){
        LL u,v,k;
        cin >> u >> v >> k;
        x.pb(u);
        y.pb(v);
        l.pb(k);
    }
    x.pb(c);
    y.pb(t);
    l.pb(0);
    for(int i=0;i<N+2;i++){
        for(int j=0;j<N+2;j++){
            if(i==j) continue;
            G[i].pb({j,max(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-l[i]-l[j])});
        }
    }
    Ds.dijkstra(0);
    cout << setprecision(30) << d[N+1] << endl;
    return 0;
}

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

signed main(){
    int n , k , kind=0 , a , ans = 0;
    int num[200005];
    
    cin >> n >> k;
    for(int i=0 ;i<=n ;i++ ){
        num[i] = n+1;
    }
    
    for(int i=0 ;i<n ;i++ ){
        cin >> a;
        if(num[a] == n+1){
            kind++;
            num[a] = 1;
        } else {
            num[a] ++;
        }
    }
    
    sort(num , num+(n+1));
    for(int i=0 ;i<kind-k ;i++ ){
        ans += num[i];
    }
    
    cout << ans << endl;
    
    return(0);
}

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

int f(int n){
  int ans = 0;
  while(n > 0){
    ans += n % 10;
    n /= 10;
  }
  return ans;
}

int main(void){
  int n;
  cin >> n;
  int ans = 100000;
  int temp;
  for(int i = 1; i < n; i++){
    temp = f(i) + f(n - i);
    if(ans > temp) ans = temp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

int main() {
	long  long a,b,k;
	cin >> a >> b >> k;
	if (a + b <= k) {
		cout << 0 << " " << 0 << endl;
	}
	else if (a + b > k && a <= k) {
		cout << 0 << " " << a + b - k << endl;
	}
	else {
		cout << a - k << " " << b << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

initial = sum(A)
for i in range(1,N+1):
  diff1 = B[-i] - A[-i]
  if (diff1 >= 0):
    A[-i] = 0
    B[-i] = diff1
  else:
    A[-i] = - diff1
    B[-i] = 0
    
  diff2 = B[-i] - A[-i-1]
  if (diff2 >= 0):
    A[-i-1] = 0
    B[-i] = diff2
  else:
    A[-i-1] = - diff2
    B[-i] = 0
    
print(initial - sum(A))

Measured memory_bytes: 18624
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.nextLine();
    String T = sc.nextLine();
    int sl = S.length();
    int tl = T.length();
    int miss = 1000;
    int m = 0;
    
    if(S.contains(T)){
      miss = 0;
    }else{
        for(int i = 0; i <= sl - tl; i++){
            for(int j = 0; j < tl; j++){
                if((S.substring(i + j, i + j + 1)).equals(T.substring(j, j + 1)) == false){
                    m += 1;
                }
            }
            if(miss > m){
                miss = m;
            }
            m = 0;
        }
    }
    System.out.println(miss);
  }
}

Measured memory_bytes: 52796
/*
                                                                           __                _________
                                                                          /  \              /  ______/
                                                                         /    \            /  /
                                                                        /  __  \          /  /
                                                                       /  /  \  \         |  |
                                                                      /  /____\  \        \  \
                                                                     /  ________  \        \  \______
                                                                    /__/        \__\        \________\
	
	I_love_Hacked;
	I_hate_pretest past;
	
    coder:xxjAc
    date:2018/3/3 
    
    I_love_Ac;
    I_hate_WA;
    I_hate_Tle;
    I_hate_RE;
    I_hate_CE;
    I_hate_Mle;
    
    I love Accepts very much;
*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
const int inf=1000000007;
int main(){
	string s;
	cin>>s;
	int ans=0;
	int mx=0;
	for (int i=0;i<s.size();i++){
		if (s[i]!='0'){
			int k=int(s[i]-'0')-1+(s.size()-i-1)*9;
			mx=max(mx,ans+k);
		}
		ans+=int(s[i]-'0');
	}
	mx=max(mx,ans);
	cout<<mx<<endl;
} 

Measured memory_bytes: 256
K = int(input())

ans = 1
num = 0
seven = 7

if not K%2:
    print(-1)
else:
    for i in range(K):
        num = num + seven
        seven = seven*10%K
        num = num%K
        if num == 0:
            print(ans)
            break
        ans += 1
    else:
        print(-1)

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

using namespace std;
using ll = long long;

const int INF = 1001001001;
vector<int> to[100001];

int main(void){
	int n,m;
  	cin >> n >> m;
	int a,b;
	rep(i,m){
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	queue<int> q;
	vector<int> dist(n,INF);
	vector<int> pre(n,-1);
	dist[0]=0;
	q.push(0);
	while(!q.empty()){
		int v = q.front();
		q.pop();
		for(int u: to[v]){
			if(dist[u] != INF) continue;
			dist[u] = dist[v]+1;
			pre[u] = v;
			q.push(u);
		}
	}

	cout << "Yes" << endl;
	rep(i,n){
		if(i==0) continue;
		int ans = pre[i];
		ans++;
		cout << ans << endl;
	}
	return 0;
}



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

using namespace std;
int n;
long long dp[81], a[81];
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[0] = 1000;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < i; j++){
            dp[i] = max(dp[j], (j != 0 ? (dp[j] / a[j]) * a[i] + (dp[j] % a[j]) : 0));
        }
    }
    cout << dp[n];
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
  int a=0,b=0,c=0,d=0,e=0,i=0;
  int sum=0;
  int a1[999999],a2[999999];
  string s1,s2,s3;
  cin>>a;
  for(i=0;i<a;i++){
    cin>>s1>>a1[i];
    sum+=a1[i];
    s2+=s1;
    a2[i]=s1.size();
  }
  cin>>s3;
  i=0;
  b=s2.find(s3)+s3.size();
  while(1){
    if(b>c){
      c+=a2[i];
      d+=a1[i];
      i++;
    }else{
      break;
    }
  }
  cout<<sum-d<<endl;
}

Measured memory_bytes: 2304
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		String A = sc.next();
		int count0 = 0, count1 = 0;
		for (int i = 0; i < A.length(); i++) {
			if (A.charAt(i) == '0')
				count0++;
			if (A.charAt(i) == '1')
				count1++;
		}
		System.out.println(2*Math.min(count0, count1));

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(0, c - (a - b)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum[3],l=10000;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	sum[1]=a+b;
	sum[2]=b+c;
	sum[3]=a+c;
	for(int i=1;i<=3;i++){
		if(l>=sum[i])
		    l=sum[i];
	}
	cout<<l<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, n, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        while (x % 2 == 0 && x > 1) {
            x /= 2;
            cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<map<int, int>> mod(M);
        rep(i, N) {
            int x; cin >> x;
            mod[x % M][x]++;
        }        
        int ans = 0;
        // 端数を使う
        vector<int> available1(M), available2(M);        
        rep(i, M) {
            for(auto &p : mod[i]) {
                available1[i] += p.second % 2;
                p.second = p.second / 2 * 2;
                available2[i] += p.second;
            }
        }

        //cerr << available1 << endl;
        //cerr << available2 << endl;
        
        for(int i = 1; i <= (M % 2 == 0 ? M / 2 - 1 : M / 2); i++) {            
            int j = M - i;
            { // 端数使う
                int use = min(available1[i], available1[j]);
                available1[i] -= use;
                available1[j] -= use;

                ans += use;

                int a = min(available1[i], available2[j]);
                int b = min(available1[j], available2[i]);
                ans += a + b;
                available2[j] -= a;
                available2[i] -= b;

                ans += available2[i] / 2;
                ans += available2[j] / 2;
            }
            // cerr << i << " " << ans << endl;
        }

        ans += (available1[0] + available2[0]) / 2;
        if(M % 2 == 0) {
            ans += (available1[M / 2] + available2[M / 2]) / 2;
        }
        
        cout << ans << endl;
        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 10368
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

// ref: https://www.geeksforgeeks.org/find-maximum-subset-xor-given-set/

fn main() {
    let N = read!(usize);
    let mut A = read![[i64]];
    A.sort();

    let mut odd = 0;
    for i in 0..N {
        odd ^= A[i];
    }

    for i in 0..N {
        A[i] &= !odd;
    }

    let mut even = 0;
    for &a in &A {
        even ^= a;
    }

    let mut index = 0;

    for i in (0..60).rev() {
        let mut max_index = index;
        let mut max_elem = std::i64::MIN;
        for j in index..N {
            if A[j] & (1 << i) != 0 && A[j] > max_elem {
                max_index = j;
                max_elem = A[j];
            }
        }

        if max_elem == std::i64::MIN {
            continue;
        }

        A.swap(index, max_index);

        max_index = index;

        for j in 0..N {
            if j != max_index && (A[j] & (1 << i) != 0) {
                A[j] ^= A[max_index];
            }
        }

        index += 1;
    }

    let mut red = 0;
    for &a in &A {
        red ^= a;
    }

    let blue = even ^ red;

    println!("{}", odd + red + blue)
}


Measured memory_bytes: 8444
n = int(input())
a = [int(input()) for i in range(n)]
ans = False
used = set()
i = 1
count = 0
while ans == False:
    count += 1
    if a[i-1] == 2:
        ans = True
    elif i-1 in used:
        break
    else:
        used.add(i-1)
        i = a[i-1]
if ans == True:
    print(count)
else:
    print("-1")
        

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;

int arr[maxr];
vector<int> adj[maxr];
int32_t main()
{
	GO;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i ++)
		cin >> arr[i];

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		bool flag = false;
		for (auto x : adj[i]) {
			if (arr[x] >= arr[i])
				flag = true;
		}
		if (flag == false)
			ans ++;
	}
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 10224