akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    LL a,b;
    cin>>a>>b;
    string s="Positive";
    if(b<0){
        if((b-a)%2==0)
            s="Negative";
    }else if(a<=0&&0<=b){
        s="Zero";
    }
    cout<<s<<endl;
     return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int ans = 2 * n;
    rep(i, n) {
        if (s.substr(i, n-i) == t.substr(0, n-i)) {
            ans = 2 * n - (n - i);
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

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

  vector<bool> p(n + 2);
  int arg;
  REP(i, n + 2) {
    p[i] = false;
  }
  REP(i, n) {
    scanf("%d", &arg);
    p[arg] = true;
  }
  int diff = 999;
  int ans = x;
  for (int i = 101; i >= 0; --i) {
    if (p[i] == false && abs(x - i) <= diff) {
      diff = abs(x - i);
      ans = i;
    }
  }

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


Measured memory_bytes: 3780
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

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

using namespace std;

typedef pair<int ,int > P;

int n;

int main()
{
	cin>>n;
	rep(i,n)
	{
		vector<int> vec;
		int a,b,c;
		cin>>a>>b>>c;
		vec.pb(a);
		vec.pb(b);
		vec.pb(c);
		sort(all(vec));

		if(vec[0]*vec[0]+vec[1]*vec[1]==vec[2]*vec[2])
			puts("YES");
		else
			puts("NO");


	}
	


	return 0;
}

Measured memory_bytes: 1172
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


signed main(){
  int n;
  cin>>n;
  int h=n/30;
  int m=n%30*2;
  cout<<h<<' '<<m<<endl;
  return 0;
}

Measured memory_bytes: 3112
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int n = in.nextInt(), k = in.nextInt();
		k++;
		int[] a = new int[n], b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
			b[i] = in.nextInt();
		}
		long result = 0;
		for (int bit = 30; bit >= 0; bit--) {
			if ((k & (1 << bit)) != 0) {
				int m = k ^ (1 << bit);
				m >>>= bit;
				long sum = 0;
				for (int i = 0; i < n; i++) {
					if (((a[i] >> bit) | m) == m) {
						sum += b[i];
					}
				}
				result = Math.max(sum, result);
			}
		}
		out.println(result);
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

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

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

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

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

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 47428
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<queue<int>> a;
	int cnt=0;

	REP(i,n){
		queue<int> que;
		REP(j,n-1){
			int num;
			cin>>num;
			num--;
			que.emplace(num);
		}
		a.emplace_back(que);
	}

	bool cont=true;
	bool finish;
	vector<bool> check=vector<bool>(1010,false);
	vector<int> pick;
	REP(i,n)pick.pb(i);
	while(true){
		vector<int> new_pick;
		check = vector<bool>(1010,false);
		cont=false;
		REP(pi,pick.size()){
			int i=pick[pi];
			if(a[i].size()==0)continue;
			if(!check[i]){
				int p=a[i].front();
				if(!check[p] && i==a[p].front()){
					a[i].pop();
					a[p].pop();
					check[i] = true;
					check[p] = true;
					//cout<<i<<" "<<p<<endl;
					cont=true;
					new_pick.pb(i);
					new_pick.pb(p);
				}
			}
		}
		pick = new_pick;
		if(!cont)break;
		cnt++;
		if(cnt>1000*(1000-1)/2){
			cout<<-1<<endl;
			return 0;
		}
	}
	finish=true;
	REP(i,n){
		if(a[i].size()!=0)finish=false;
	}

	if(finish){
		cout<<cnt<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}



Measured memory_bytes: 4736
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename Iterator>
string Join(const Iterator& cbegin, const Iterator& cend, const string& delim = "")
{
    ostringstream os;
    copy(cbegin, cend, ostream_iterator<string>(os, delim.c_str()));
    string str(os.str());
    if (!str.empty()) {
        str.erase(str.size() - delim.size());
    }
    return str;
}

template <typename T>
string Join(const vector<T>& vec, const string& delim = "")
{
    vector<string> strs(vec.size());
    transform(vec.cbegin(), vec.cend(), strs.begin(), [](const T& v) { return to_string(v); });
    return Join(strs.begin(), strs.end(), delim);
}

int main()
{
    const int   K(cin2var<int>());
    const int   X(cin2var<int>());
    vector<int> nums;
    for (int i = X - K + 1; i < X + K; ++i) {
        nums.push_back(i);
    }
    cout << Join(nums, " ") << endl;
    return 0;
}

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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test


constexpr int mod = 1e9 + 7;

struct M {
    unsigned v;
    M(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    M& operator+=(M r) { if ((v += r.v) >= mod) v -= mod; return *this; }
    M& operator-=(M r) { if ((v += mod - r.v) >= mod) v -= mod; return *this; }
    M& operator*=(M r) { v = (uint64_t)v * r.v % mod; return *this; }
};

uint32_t add(M a, M b) { return (a += b).v; }
uint32_t mul(M a, M b) { return (a *= b).v; }
uint32_t sub(M a, M b) { return (a -= b).v; }

const int max_nodes = 1e5 + 3;
using edge = int32_t;
vector<edge> g[max_nodes];
bool vis[max_nodes];
struct graph {
    static void reset(int n) {
        for (int i = 0; i <= n; ++i) {
            g[i].clear();
            vis[i] = false;
        }
    }
    graph(int n) { reset(n); }
    void add_edge(int u, int v) {
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
};

const int maxn = 1e5 + 4;
int dp[maxn][2];

void dfs(int u, int par = -1) {
    for (auto v: g[u]) {
        if (v != par) {
            dfs(v, u);
        }
    }
    int b = 1, w = 1;
    for (int adj: g[u]) {
        if (adj != par) {
            b = mul(b, dp[adj][1]);
            w = mul(w, add(dp[adj][0], dp[adj][1]));
        }
    }
    var(u, par, b, w);
    dp[u][0] = b;
    dp[u][1] = w;

}

void solve() {
    int n;
    cin >> n;
    graph ins(n);
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        ins.add_edge(u, v);
    }
    int ans = 0;
    for (int i = 1; i < 2; ++i) {
        memset(dp, 0, sizeof dp);
        dfs(i, -1);
        ans = add(ans, add(dp[i][0], dp[i][1]));
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 14860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int idx=0;
    int cnt=0;
    while(cnt<1000000){
        idx=a[idx]-1;
        cnt++;
        if(idx==1){
            cout<<cnt<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int c=0;
	string s;
	cin>>s;
if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
cout<<3;
else if(s[0]=='R'&&s[1]=='R'&&s[2]=='S'||s[0]=='S'&&s[1]=='R'&&s[2]=='R')
cout<<2;
else if(s[0]=='R'&&s[1]=='S'&&s[2]=='S'||s[0]=='S'&&s[1]=='S'&&s[2]=='R'||s[0]=='S'&&s[1]=='R'&&s[2]=='S'||s[0]=='R'&&s[1]=='S'&&s[2]=='R')
cout<<1;
else
cout<<0;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int a, b, m;  cin >> a >> b >> m;
    int min_a = INF, min_b = INF, ans = INF;
    V A(a), B(b);  VECCIN(A);  VECCIN(B);

    for(int i = 0 ; i < a ; i++){  min_a = min(min_a, A[i]);  }
    for(int i = 0 ; i < b ; i++){  min_b = min(min_b, B[i]);  }

    ans = min_a + min_b;
    for(int i = 0 ; i < m ; i++){
      int x, y, c;  cin >> x >> y >> c;
      ans = min(ans, A[x-1] + B[y-1] - c);
    }

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

Measured memory_bytes: 1024
n = gets.to_i
a = gets.split.map(&:to_i)
ans = 0
def digi(x)
  count = 0
  loop{
    if x%(2**(count+1))==0
      count+=1
    else
      break
    end
  }
  count
end

n.times{|i|
  ans += digi(a[i])
}

puts ans

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int po[11];

int main(){
  int n;
  cin>>n;
  printf("%d\n",n*(n+1)/2);
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto Q = RD;
	auto S = RD!string;
	auto LR = new long[2][](Q);
	foreach (i; 0..Q)
	{
		LR[i][0] = RD-1;
		LR[i][1] = RD;
	}

	auto dp = new long[](N+1);
	char last = S[0];
	foreach (i; 1..N)
	{
		if ([last, S[i]] == "AC")
		{
			++dp[i+1];
		}
		last = S[i];
	}
	foreach (i; 0..N)
	{
		dp[i+1] += dp[i];
	}

	foreach (i; 0..Q)
	{
		auto l = LR[i][0];
		auto r = LR[i][1];
		auto ans = dp[r] - dp[l];
		if (l != 0)
			if (S[l] == 'C' && S[l-1] == 'A')
				--ans;
		writeln(ans);
	}
	debug writeln(dp);

	stdout.flush();
	debug readln();
}

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

int main() {
    string s, t, u;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    cin >> u;
    if (s == u) a--;
    else b--;
    printf("%d %d", a, b);
    return 0;
}

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

using namespace std;

const int mod = 1'000'000'007;

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int get(int b) {
  return (pw(10, b) - pw(10, b - 1) + mod) % mod;
}

int main() {
  int s;
  scanf("%d", &s);
  long long ans = 0;
  for (int i = 1; i * i <= s; ++i) {
    if (s % i == 0) {
      {
        int cnt = get(i);
        if (i >= 9 || cnt >= s / i) {
          ans += cnt - s / i + 1;
        }
      }
      if (s / i != i) {
        int cnt = get(s / i);
        if (s / i >= 9 || cnt >= i) {
          ans += cnt - i + 1;
        }
      }
      ans %= mod;
      ans += mod;
      ans %= mod;
    }
  }
  for (int i = 1; i <= 8; ++i) {
    int cnt_i = get(i);
    long long v = 0;
    for (int j = i + 1; j <= 9; ++j) {
      int cnt_j = get(j);
      for (int k = 1; k <= cnt_i; ++k) {
        if (v + i * k >= s) {
          break;
        }
        if ((s - v - i * k) % j == 0 && (s - v - i * k) / j <= cnt_j) {
          ans += 1;
        }
      }
      v += j * cnt_j;
      if (v >= s) {
        break;
      }
    }
  }
  ans %= mod;
  for (int i = 9; i < s; ++i) {
    int v = s / (i + 1);
    if (s % (i + 1) == 0) {
      --v;
    }
    int r = s % i;
    if (v >= r) {
      ans += (v - r) / i + (r != 0);
    }
  }
  ans %= mod;
  printf("%d\n", (int)ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int i;
    cin>>s;
    if(s.length()>=3&&s.length()<=20)
    {
        for(i=0;i<3;i++)
            cout<<s[i];
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;

    int s = 0;
    for(int i=1;i<=N;i++){
        s += i;
        if(s >= N){
            int diff = s - N;
            for(int j=1;j<=i;j++){
                if(j == diff) continue;
                cout << j << endl;
            }
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
class Main{
    public static void main(String[] a){
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                System.out.printf("%dx%d=%d\n", i + 1, j + 1, (i + 1) * (j + 1));
            }
        }

    }
}


Measured memory_bytes: 24904
#include <stdio.h>

int main() {
	int a,b;
	scanf("%d%d", &a,&b);
	if((a!=1)&&(b!=1))
		printf("1\n");
	else if((a!=2)&&(b!=2))
		printf("2\n");
	else if((a!=3)&&(b!=3))
		printf("3\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  string a;
  cin>>a;
  if((a[0]==a[1]&&a[1]==a[2])||(a[2]==a[1]&&a[3]==a[2]))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>


using namespace std;

const int N = 1e5 + 5;
int n;
string s;
vector<int> graph[N]; 
int cnt[N];
int dis[N];
int dp[N];
int ans = -1;

void dfs(int v, int par)
{
    cnt[v] = 0;
    dis[v] = 0;
    if (s[v] - '0')
    {
        cnt[v]++;
    }
    for (auto u: graph[v])
    {
        if (u == par)
        {
            continue;
        }
        dfs(u, v);
        cnt[v] += cnt[u];
        dis[v] += dis[u] + cnt[u];
    }
    dp[v] = dis[v] % 2;
    for (int u: graph[v])
    {
        if (u == par)
        {
            continue;
        }
        dp[v] = max(dp[v], (dp[u] + cnt[u]) - (dis[v] - (dis[u] + cnt[u])));
    }
}
 
int main() 
{
    cin >> n >> s;
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        graph[u - 1].push_back(v - 1);
        graph[v - 1].push_back(u - 1);
    }
    for (int i = 0; i < n; i++)
    {
        dfs(i, -1);
        if (dp[i] != 0)
        {
            continue;
        }
        if (ans == -1)
        {
            ans = dis[i] / 2;
        }
        else
        {
            ans = min(ans, dis[i] / 2);
        }
    }
    cout << ans << endl;

}








Measured memory_bytes: 2816
H, W = map(int,input().split())
MAP = []
tx = [1,1,0,-1,-1,-1,0,1]
ty = [0,1,1,1,0,-1,-1,-1]
for _ in range(H):
    MAP.append(list(input()))
for x in range(H):
    for y in range(W):
        if MAP[x][y] == '.':
            cnt = 0
            for i in range(8):
                nx = x + tx[i]
                ny = y + ty[i]
                if 0 <= nx <= H - 1 and 0 <= ny <= W - 1 and MAP[nx][ny] == '#':
                    cnt += 1
            MAP[x][y] = str(cnt)
for i in range(H):
    print(''.join(MAP[i]))

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

int main(){

  int h1, m1, h2, m2, k;

  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int l = h2 * 60 + m2;
  int r = h1 * 60 + m1;

  cout << l-r-k << endl;

}


Measured memory_bytes: 3632
a,b,c,d = map(int,input().split())
B_A = abs(b - a)
C_B = abs(c - b)
C_A = abs(c - a)
if B_A <= d and C_B <=d:
    print('Yes')
elif C_A <= d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,x=0;
    map<int,int>p;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>x;
        p[x]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<p[i]<<endl;
    }
    return 0;
}



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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	ll a[n];
	rep(i, n) cin >> a[i];
	
	ll ans = a[0];
	FOR(i, 1, n) {
		ans = gcd(ans, a[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<vector>
#define N 305
#define oo (1<<30)
using namespace std;
const int mo=1e9+7;
int n,m,f[N][N][N],ans,L[4][N],R[4][N];
void inc(int &x,int y){ x=x+y>=mo ? x+y-mo : x+y;}
bool in(int s,int t,int l,int r){ return s>=l&&t<=r;}
int main()
{
	int i,j,k,l,r,x,y;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		for(j=1;j<=3;j++)
			L[j][i]=oo,R[j][i]=-oo;
	for(i=1;i<=m;i++){
		scanf("%d %d %d",&l,&r,&x);
		R[x][r]=max(R[x][r],l);
		L[x][r]=min(L[x][r],l);
	  }
	f[1][0][0]=3;
	for(i=1;i<n;i++)
		for(j=0;j<i;j++)
			for(k=0;k<i;k++){
				x=max(j,k),y=j+k-x;
				if(!in(L[1][i],R[1][i],x+1,i)) continue;
				if(!in(L[2][i],R[2][i],y+1,x)) continue;
				if(!in(L[3][i],R[3][i],1,y)) continue;
				inc(f[i+1][j][k],f[i][j][k]);
				inc(f[i+1][i][k],f[i][j][k]);
				inc(f[i+1][i][j],f[i][j][k]);
			  }
	for(i=0;i<n;i++)
		for(j=0;j<n;j++){
			x=max(i,j),y=i+j-x;
			if(!in(L[1][n],R[1][n],x+1,n)) continue;
			if(!in(L[2][n],R[2][n],y+1,x)) continue;
			if(!in(L[3][n],R[3][n],1,y)) continue;
			inc(ans,f[n][i][j]);
		  }
	cout<<ans;
	return 0;
}


Measured memory_bytes: 108800
if __name__ == '__main__':
    s = int(input())

    i = 1
    n = s
    prev = set()
    while True:
        prev.add(n)
        i += 1
        if n % 2 == 0:
            n = n // 2
        else:
            n = 3 * n + 1
        if n in prev:
            break
    print(i)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
    int A, B;
    scanf("%d %d", &A, &B);
    long int MAX = A+B;
    if(MAX < A-B) MAX=A-B;
    if(MAX < A*B) MAX=A*B;
    printf("%ld\n", MAX);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    
    string s;
    cin>>s;
    sort(all(s));
    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
A = [list(map(str,list(input()))) for i in range(n)] 
B = [list(map(str,list(input()))) for i in range(m)] 
def move(h,w):
    cnt = 0
    for i in range(m):
        for j in range(m):
            if B[i][j] == A[i+h][j+w]:
                cnt += 1
    return cnt
flg = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        if move(i,j)==m*m:
            flg = 1
            break
if flg == 1:
    print('Yes')
else:
    print('No')

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

int main(void) {
  bool flag=false;
  int n;
  scanf("%d",&n);
  for(int i=0;i<3;i++) {
    if (n%10==7) {
      flag=true;
    }
    n/=10;
  }
  printf("%s",flag?"Yes":"No");
}

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

int main()
{
	vector<int> prime;
	int n;
	
	prime.push_back(2);
	for(int i = 3; prime.size() < 10000; i += 2){
		for (int j = 0; j < prime.size() ;j++){
			if (i%prime[j] == 0){
				break;
			}
			if (j == prime.size()-1){
				prime.push_back(i);
			}
		}
	}
	
	while(scanf("%d", &n), n != 0){
		
		int total=0;
		
		for(int i = 0; i < n; i++){
			total += prime[i];
		}
		
		printf("%d\n", total);
	}
	
	return (0);
}

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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
    int n;
    cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];
    int ans[n];
    REP(i, n){
        int x = n-i;
        int count = 0, cp = 2;
        while(cp*x-1 < n){
            count += ans[cp*x-1];
            cp++;
        }
        if(count%2 == a[x-1]) ans[x-1] = 0;
        else ans[x-1] = 1;
    }
    vector<int> b;
    REP(i, n) if(ans[i] == 1) b.pb(i+1);
    cout << b.size() << endl;
    REP(i, b.size()){
        cout << b[i];
        if(i == b.size()-1) cout << endl;
        else cout << " ";
    }
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll memo[109][100009];
int weights[109];
int values[109];
int n, max_weight_allowed;
ll solve(int idx, int w) {
// 2^n
/** n * max_weight ? n^2 **/
  if(w > max_weight_allowed)
    return -1e14;
  if(idx == n)
    return 0;

  ll & ret = memo[idx][w];
  if(ret != -1)
    return ret;

  ll op1 = solve(idx + 1, w + weights[idx]) + values[idx]; /**take the current item**/
  ll op2 = solve(idx + 1, w);

  return ret = max(op1, op2);

}


int main() {
  // reading input

  cin >> n >> max_weight_allowed;

  for(int i = 0; i < n; i++) {
    cin >> weights[i] >> values[i];
  }

  memset(memo, -1, sizeof(memo));

  cout << solve(0, 0);

}


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

namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] imp = Console.ReadLine().Split(' ');
            int X = Convert.ToInt32(imp[0]);
            int Y = Convert.ToInt32(imp[1]);
            int res = X+Y/2; 
            Console.WriteLine(res);
            
        }
    }
}

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

int n;
int x[10];
int y[10];



double dist(int i, int j)
{
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  
  return pow(dx * dx + dy * dy, 0.5);
}

void solve()
{
  cin >> n;
  for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
  double ans = 0.0;
  for(int i = 0; i < n; i++)
    for(int j = i + 1; j < n; j++ ) ans += dist(i, j) * 2 / n;
      
      cout << fixed << setprecision(10) << ans << endl;
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 256
def check(A,B,C):
  if A==0 or B==0 or C==0:
    return False
  if A%2!=0 or B%2!=0 or C%2!=0:
    return False
  return True

A,B,C=map(int,input().split())
ans=0
if A%2==B%2==C%2==0 and A==B==C:
  print(-1)
  exit()
while check(A,B,C)==True:
  a=B//2+C//2
  b=A//2+C//2
  c=A//2+B//2
  A,B,C=a,b,c
  ans+=1
  if 10**9<ans:
    ans=-1
    break
print(ans)


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n;
    cin >> n;
    string g;
    set<string> s;
    rep(i, n) {
        cin >> g;
        s.insert(g);
    }
    cout << s.size() << endl;
    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n,k;
	cin>>n>>k;
	vector<ll> h(n+1,0);
	repi(i,1,n+1)cin>>h[i];

	if(n==k){
		cout<<0<<endl;
		return 0;
	}

	vector<vector<ll>> dp(n+1,vector<ll>(n+1,1LL<<60));

	dp[0][0]=0;

	repi(i,1,n+1){
		repi(j,1,i+1){
			repi(l,1,i+1){
				dp[i][j] = min(dp[i][j], dp[i-l][j-1]+max(0LL,h[i]-h[i-l]));
			}
		}
	}

	ll ans=1LL<<60;
	repi(i,1,n+1) ans=min(ans, dp[i][n-k]);

	cout<<ans<<endl;

	// rep(i,n+1){
	// 	rep(j,n+1)cout<<dp[i][j]<<" ";
	// 	cout<<endl;
	// }
	
	return 0;
}

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

int main(){
    int n,cnt=0;
    while(cin >> n){
        
        if(n > 36){
        }
        else if(n == 36){
            cnt = 1;
        }
        else{
            for(int i=0;i<10;++i){
                for(int j=0;j<10;++j){
                    for(int k=0;k<10;++k){
                        for(int l=0;l<10;++l){
                            if(i+j+k+l == n){
                                ++cnt;
                                break;
                            }
                        }
                    }
                }
            }
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>v;
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	int total = v[v.size() - 1] - v[0];
	vector<int>dis;
	for (int i = 1; i < v.size(); i++) {
		dis.push_back(v[i] - v[i - 1]);
	}
	sort(dis.rbegin(), dis.rend());
	for (int i = 1; i < n && i <= dis.size(); i++) {
		total -= dis[i - 1];
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 1400
if __name__ == '__main__':

	tmp0 = input().split()
	tmp1 = map(int,input().split())
	tmp2 = input()

	dic = {}

	for x,y in zip(tmp0,tmp1):
		dic[x] = y

	dic[tmp2] = dic[tmp2] - 1

	print(*dic.values())



Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int a[200100];
int max1,max2;
int main(){
	cin>>n;
	REP(i,n)cin>>a[i];
	if(a[0]>a[1]){
		max1=a[0];
		max2=a[1];
	}else{
		max1=a[1];
		max2=a[0];
	}
	for(int i=2;i<n;i++){
		if(a[i]>=max1){
			max2=max1;
			max1=a[i];
		}else if(a[i]>max2){
			max2=a[i];
		}
	}
	REP(i,n){
		if(a[i]==max1){
			cout<<max2<<endl;
		}else{
			cout<<max1<<endl;
		}
	}
	return 0;
}

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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s,t;cin>>s>>t;
	if(t.substr(0,s.size())==s){
		puts("Yes");
	}
	else puts("No");
}

Measured memory_bytes: 3624
import java.math.BigInteger;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt();
        int[] a = new int[n];
        BigInteger big = BigInteger.ONE;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            big = big.multiply(BigInteger.valueOf(a[i]));
        }
        big = big.subtract(BigInteger.ONE);
        BigInteger sum = BigInteger.ZERO;
        for (int i = 0; i < n; i++) {
            sum = sum.add(big.remainder(BigInteger.valueOf(a[i])));
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 46696
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
using pii=std::pair<int,int>;

using namespace std;

int n,d,x[10][10];
double dist[10][10];
class BGoodDistance {
public:
	void solve(std::istream& in, std::ostream& out) {
		int cnt=0;
		in >> n >> d;
		f(i,0,n)
			f(j,0,d)
				in >> x[i][j];
		f(i,0,n)
			f(j,i+1,n)
			{
				dist[i][j]=0;
				f(k,0,d)
					dist[i][j]+=pow(x[i][k]-x[j][k],2);
				dist[i][j]=sqrt(dist[i][j]);
				if(dist[i][j]==ceil(dist[i][j]))
					cnt++;
			}
		out << cnt << "\n";
	}
};


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


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	ll n;cin >> n;
	
	vector<ll> v(n);REP(i,n)cin >> v[i];
	sort(ALL(v),greater<ll>());
	
	multiset<ll> s;
	
	int ans = 0;
	REP(i,n){
		bool flag = false;
		for(int j = 0;j <= 35;j++){
			int now = (1LL << j) - v[i];
			auto it = s.lower_bound(now);
			if(it != s.end() && *it == now){
				ans++;
				s.erase(it);
				flag = true;
				break;
			}
		}
		if(!flag)s.insert(v[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 11136
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
int binomialCoeff(int n, int k) 
{ 
	int C[n + 1][k + 1]; 
	int i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = C[i - 1][j - 1] + 
						C[i - 1][j]; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const pair<pair<int,int>,int>&a , const pair<pair<int,int>,int>&b){
	if(a.fi.fi==b.fi.fi){
		return a.fi.se<b.fi.se ;
	}
	return a.fi.fi<b.fi.fi ;
}
bool isvowel(char c){
	return ((c=='a') || c=='e' || c=='i' || c=='o' || c=='u');
}
void solve()
{
	string s ; 
	cin>>s ;
	int i = 0 ; 
	int n = s.size() ;
	int ans = 0 ;
	while(i<n){
		char c = s[i] ;
		int cou = 0 ;
		while(i<n && c==s[i]){
			cou++;
			i++;
		}
		if(cou%2){
			ans += cou/2 ;
		}
		else{
			i--;
			s[i] = (c=='1' ? '0' : '1') ;
			ans += cou/2 ;
		}
	}
	cout<<ans<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3932
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>

using namespace std;

int main(){
    int N,Y;
    cin>>N>>Y;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            int a=Y-i*10000-j*5000;
            if(a<0) break;
            if(a/1000+i+j==N){
                cout<<i<<" "<<j<<" "<<a/1000<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	long long int n;
	cin >> n;
	cout << (n - 1) * n / 2 << endl;
}

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

int MOVE(int *a, int n){
    int i,j,k=n,cnt,ans,moves=0,s[10]={};
    for(i=1;i<=n;i++){
        cnt=0,ans=1;
        for(j=1;j<=*a;j++) if(s[j]==0) cnt++;
        s[*a]=1;
        for(j=1;j<k;j++) ans*=j;
        ans*=(cnt-1);
        moves+=ans,a++,k--;
    }
    return moves;
}

int main()
{
    int n,p1[10],p2[10];
    cin>>n;
    for(int i=0;i<n;i++) cin>>p1[i];
    for(int i=0;i<n;i++) cin>>p2[i];
    cout<<abs(MOVE(p1,n)-MOVE(p2,n));

}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){
    if(b==0)
    return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;base%=mod;
        pow/=2;
    }return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}

const int M = 2e5 + 5;

vector<int> good[M], bad[M];
int comp[M], nodesIn[M], till = 1, ans[M];

void dfs(int u){
    if(comp[u] != 0) return;
    comp[u] = till;
    nodesIn[till]++;
    for(int i = 0 ; i < good[u].size() ; i++){
        int v = good[u][i];
        dfs(v);
    }
}

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

    for(int i = 1 ; i <= m ; i++){
        int u, v;
        si(u);  si(v);
        good[u].push_back(v);
        good[v].push_back(u);
    }

    for(int i = 1 ; i <= k ; i++){
        int u, v;
        si(u);  si(v);
        bad[u].push_back(v);
        bad[v].push_back(u);
    }

    for(int i = 1 ; i <= n ; i++){
        if(comp[i] == 0){
            dfs(i);
            till++;
        }
    }

    memset(ans , 0 , sizeof(ans));

    /*for(int i = 1 ; i <= n ; i++){
        cout<<i<<"  "<<comp[i]<<endl;
    }*/
    for(int i = 1 ; i <= n ; i++){
        ans[i] += nodesIn[comp[i]] - good[i].size() - 1;
        for(int j = 0 ; j < bad[i].size() ; j++){
            int v = bad[i][j];
            if(comp[v] == comp[i]){
                ans[v]--;
            }
        }
    }

    for(int i = 1 ; i <= n ; i++){
        cout<<ans[i]<<" ";
    }

}



Measured memory_bytes: 18048
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int num[100009];
bool red[100009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin>>N>>M;
    
    red[0]=true;
    rep(i,N) num[i]=1;
    rep(i,M){
        int x,y;cin>>x>>y;
        x--,y--;
        num[x]--;
        num[y]++;
        red[y]|=red[x];
        if(num[x]==0) red[x]=false;
    }
    
    int cnt=0;
    rep(i,N) cnt+=red[i];
    cout1(cnt);
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
int aa(int a)
{
    int n,m;
    scanf("%d",&n);
    scanf("%d",&m);
    printf("%d\n",n+m);
}


int main()
{
  int a;
  while(~scanf("%d",&a))
  {
      if(a==1)
      printf("Hello World\n");
      else
        a==aa(a);
  }
}


Measured memory_bytes: 128