akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	string s;
	cin >> s;
	if(s == "ABC"){
		cout << "ARC" << endl;
	}else{
		cout << "ABC" << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
N = int(input())
K = int(input())
sum = 0
x = input().split()

for i in range(N):
  x[i] = int(x[i])
  if(abs(x[i] - 0) < abs(x[i] - K)):
    sum += 2*abs(x[i] - 0) 
  else:
    sum += 2*abs(x[i] - K)
print(sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int x1,x2,y1,y2;
    int sugar=0,total=100*a;
    int water_tp,sugar_tp;
    for (x1=0;x1<=100;x1++)
    {
        for (y1=0;y1<=100;y1++)
        {
            for (x2=0;x2<=100;x2++)
            {
                for (y2=0;y2<=100;y2++)
                {
                    water_tp=(a*x1+b*y1)*100;
                    sugar_tp=x2*c+y2*d;
                    if (sugar_tp+water_tp<=f)
                    {
                        if (sugar_tp*100<=water_tp*e)
                        {
                            if (sugar_tp*total>=sugar*(sugar_tp+water_tp))
                            {
                                sugar=sugar_tp;
                                total=sugar_tp+water_tp;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<total<<" "<<sugar<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  int h, w;
  cin >> h >> w;
  vector<vector<char>> c(h + 2, vector<char>(w + 2, '#'));
  rep (i, h) {
    rep (j, w) {
      cin >> c[i + 1][j + 1];
    }
  }

  vii hyou(h * w, vi(h * w, inf));
  rep (i, h * w) hyou[i][i] = 0;

  rep1 (i, h) {
    rep1 (j, w) {
      int u = (i - 1) * w + (j - 1);
      if (c[i][j] == '#') continue;
      rep (k, 4) {
        int ni = i + dx[k], nj = j + dy[k];
        if (c[ni][nj] == '#') continue;
        int v = (ni - 1) * w + (nj - 1);
        hyou[u][v] = hyou[v][u] = 1;
      }
    }
  }

  //DEBUG_MAT(hyou);

  rep (k, h * w) {
    rep (i, h * w) {
      rep (j, h * w) {
        chmin(hyou[i][j], hyou[i][k] + hyou[k][j]);
      }
    }
  }

  int ans = 0;
  rep (i, h * w) {
    rep (j, h * w) {
      if (hyou[i][j] == inf) continue;
      chmax(ans, hyou[i][j]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 896
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
//97->a 122->z
//65-A
int main()
{
	//freopen("testcase.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		string a;
		cin>>a;
		cout<<"ABC";
		cout<<a<<endl;
		
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


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

int main()
{
    ull N;
    cin >> N;
    vector<vector<ull> > vec(N);
    priority_queue<ull> q;
    ull res = 0;
    for(int i = 0; i < N; i++) {
        int M;
        cin >> M;
        vector<ull> l(M);
        for(int j = 0; j < M; j++) cin >> l.at(j);
        vec.at(i) = l;
    }
    reverse(vec.begin(), vec.end());
    for(int i = 0; i < N; i++) {
        for(int j = 0 ; j < vec.at(i).size(); j++) {
            q.push(vec[i][j]);
        }
        res += q.top();
        q.pop();
    }
    
    cout << res << endl;
}


Measured memory_bytes: 19188
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(void){
    int n,y;
    while(cin>>n){
        int num=0;
        if(n==0) break;
        cin>>y;
        int b[n];
        double r[n],t[n],ans[n]={0},max_a=0;
        for(int i=0;i<n;i++){
            cin>>b[i]>>r[i]>>t[i];
            if(t[i]==2) ans[i]=pow((1+r[i]/100.0),y);
            else ans[i]=1+y*r[i]/100.0;
            if(ans[i]>max_a){
                num=b[i];
                max_a=ans[i];
            }
        }
        cout<<num<<endl;
    }
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int r,d,x; cin >> r >> d >> x;

  for(int i = 0; i < 10; i++){
    x = r * x - d;
    cout << x << endl;
  }
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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 main(){
  rep(i,365) cout << 1 << endl;
  return 0;
}


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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

vi v;

int cmin = 1e9 + 1;

void read() {
  cin >> n;
  for(int i = 0; i <= n; ++i) {
    int x;
    cin >> x;
    v.pb(x);
    cmin = min(cmin, x);
  }
}

int gcd(int a, int b) {
  while(b) {
    int c = a % b;
    a = b;
    b = c;
  }
  return a;
}

void solve() {
  int d = v[0] - cmin;
  for(int i = 1; i <= n; ++i) {
    d = gcd(d, v[i] - cmin);
  }
  cout << d;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 892
n = int(input())
F = [[int(i) for i in input().split()] for i in range(n)]
P = [[int(i) for i in input().split()] for i in range(n)]

ans = - 10 ** 10
for i in range(1, 2 ** 10):
    x = i
    A = []
    while x:
        A.append(x % 2)
        x //= 2
    while len(A) < 10:
        A.append(0)
        
    tmp = 0
    for j in range(n):
        cnt = 0
        for k in range(10):
            if F[j][k] == 1 and A[k] == 1:
                cnt += 1
        tmp += P[j][cnt]
    ans = max(ans, tmp)
    
print(ans)

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<long long> dp(n + 1, 1e18);
    dp[0] = 0;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        dp[i + 1] = dp[0];
        dp[0] += a;
        for (int j = 0; j < i; ++j) {
            if (p[j] < p[i]) dp[i + 1] = min(dp[i + 1], dp[j + 1]);
            dp[j + 1] += p[j] < p[i] ? a : b;
        }
    }
    long long ans = 1e18;
    for (int i = 0; i <= n; ++i) ans = min(ans, dp[i]);
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

bool is_prime(int n) {
  for (int p = 2; p * p <= n; p++) {
    if (n % p == 0) {
      return false;
    }
  }

  return true;
}

int64_t totient(const int64_t n) {
  int64_t s = 0;
  for (int64_t p = 2; p * p <= n; p++) {
    if (is_prime(p) && n % p == 0) {
      for (int64_t d = p; d <= n; d *= p) {
        s += (n - 1) / d;
      }
    }
  }
  return n - 1 - s;
}

const int MOD = 2019;

int64_t dpow(int64_t x, int64_t y) {
  if (y == 0) {
    return 1;
  }
  if (y % 2 == 0) {
    return dpow(x * x % MOD, y / 2);
  } else {
    return x * dpow(x, y - 1) % MOD;
  }
}

int main() {
  string s;
  cin >> s;

  int64_t M = 1344;
  vector<int> dp(2019, 0);
  dp[0]++;
  int shift = 1;
  int r = 0;
  int i10 = dpow(10, M - 1);
  int64_t result = 0;
  rep(i, s.size()) {
    r = r * 10 + (s[i] - '0');
    r %= MOD;
    result += dp[r * shift % MOD]++;
    shift *= i10;
    shift %= MOD;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
#define N 100005 

ll fac[N] , k , n , vis[N] ;
vector<vector<ll> > g(N) ; 

ll power(ll x , ll y){
	ll res = 1 ; 
   while(y > 0){
	if(y&1)
		res = (res*x)%M ; 
	y = y>>1 ; 
	x = (x*x)%M ;
	}
	return res ; 
}

ll dfs(int a , int d){

	vis[a] = 1 ; 
    int child = 0 ; 
    ll res = 1 ; 
    for(int i=0;i<g[a].size();i++){
    	if(!vis[g[a][i]]){
    		child++ ; 
    		res = (res*dfs(g[a][i] , d + 1))%M ; 
    	}
    }
    
    ll ret = 1 ; 

    if(d == 0){
    	if(k - 1 - child < 0)
    		return 0 ; 
        ret = ((fac[k - 1])*(power(fac[k - 1 - child] , M - 2)))%M ; 
    }
    else{
    	if(k - 2 - child < 0)
    		return 0 ; 
    	ll K = k - 2 ; 
    	//cout<<K<<" " ; 
    	ret = (fac[K]*(power(fac[K - child] , M - 2)))%M ; 
    }
    //cout<<a<<" "<<ret<<" "<<res<<endl;
    ret = (ret*res)%M ; 
    return ret ; 
}

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

	for(int i=1;i<=n-1;i++){
		int a , b ; 
		cin>>a>>b ; 
		g[a].push_back(b) ; 
		g[b].push_back(a) ; 
	}
	fac[0] = 1 ; 

	for(ll i=1;i<=100000;i++){
		fac[i] = (fac[i - 1]*i)%M ; 
	}

	ll ans = (k*dfs(1 , 0))%M ; 
	cout<<ans<<"\n" ; 
}

Measured memory_bytes: 13184
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int r = sc.nextInt();
        int c = sc.nextInt();
        int i,j;
        int[][] array = new int[r + 1][c + 1];
        
        for(i = 0; i < r; i++){
            for(j = 0; j < c; j++){
                array[i][j] = sc.nextInt();
            }
        }
        for(i = 0; i < r; i++){
            for(j = 0; j < c; j++){
                array[i][c] += array[i][j];
            }
        }
        for(i=0; i<c+1; i++){
            for(j=0; j<r; j++){
                array[r][i] += array[j][i];
            }
        }
        for(i=0; i<r+1;i++){
            for(j=0; j<c+1; j++){
                if(j==c)System.out.print(array[i][j]);
                else System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 42300
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=1e9+7;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,m,f[N]; ll ans;
void upd(int &x) {x+=x>>31&mod;}
ll power(ll a,ll b=n) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b=b/2;  a=a*a%mod;
	}
	return c;
}

int main() {
	qr(n); qr(m);
	for(int i=m; i;i--) {
		f[i]=power(m/i,n);
		for(int j=i*2;j<=m;j+=i) upd(f[i]-=f[j]);
		ans+=(ll)f[i]*i%mod;
	}
	pr2(ans%mod);return 0;
}


Measured memory_bytes: 3984
N=int(input())
h=[int(i) for i in input().split()]
DP=[1400000 for i in range(N)]
DP[0]=0
DP[1]=abs(h[0]-h[1])
for i in range(2,N):
	DP[i]=min(DP[i-2]+abs(h[i]-h[i-2]),DP[i-1]+abs(h[i]-h[i-1]))
print(DP[N-1])

Measured memory_bytes: 52848
import sys
from collections import deque, Counter, defaultdict
from itertools import permutations
import heapq


def resolve():
    X, Y = map(int, sys.stdin.readline().strip().split())
    ans = 0
    while X <= Y:
        ans += 1
        X <<= 1

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdint.h>

int main(void)
{
    uint32_t N, K, X, Y;
    uint32_t sum = 0;
    uint32_t i;
    scanf("%u %u %u %u", &N, &K, &X, &Y);
    for (i = 0; i < K && i < N; i++) {
        sum += X;
    }
    for (i = K; i < N; i++) {
        sum += Y;
    }
    printf("%u\n", sum);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  int n, y;
  cin >> n >> y;
  
  rep(i, n+1){
    rep(j, n+1-i){
      if(10000*i + 5000*j + 1000*(n-i-j) == y){
        cout << i << " " << j << " " << n-i-j << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <stack>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double PI = 3.14159;

int route[1001][1001];
int dp[1001][1001];

int main(){
	int h, w, n;
	while(cin >> h >> w >> n && (h || w || n)){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> route[i][j];
			}
		}
		memset(dp, 0, sizeof(dp));
		dp[0][0] = n-1;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(dp[i][j] % 2 == 0){
					dp[i+1][j] += dp[i][j] / 2;
					dp[i][j+1] += dp[i][j] / 2;
				}else{
					if(route[i][j] == 1){
						dp[i][j+1] += dp[i][j] / 2 + 1;
						dp[i+1][j] += dp[i][j] / 2;
					}else{
						dp[i][j+1] += dp[i][j] / 2;
						dp[i+1][j] += dp[i][j] / 2 + 1;
					}
				}
			}
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				route[i][j] = (route[i][j] + dp[i][j]) % 2;
			}
		}
		int y = 0, x = 0;
		while(y < h && x < w){
			if(route[y][x] == 1) x++;
			else y++;
		}
		cout << y + 1 << " " << x + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 8696
N = int(input())
ans = [0] * N
for x in range(1, 102):
    for y in range(1, 102):
        for z in range(1, 102):
            t = x*x+y*y+z*z+x*y+y*z+z*x
            if 1 <= t <= N:
                ans[t-1] += 1
print(*ans, sep='\n')


Measured memory_bytes: 74480
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll k;
vector<ll> a;
bool check(ll mid, int type){

    ll now = mid;
    for(int i = 0; i < k; i++){
        now = now - (now % a[i]);
    }

    if(type == 0){
        return now >= 2;
    } else {
        return now <= 2;
    }
    
}
int main(void){
    cin >> k;
    a.resize(k);
    rep(i, k) cin >> a[i];

    ll ok = INF;
    ll ng = 0;

    pair<ll,ll> ans;

    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid, 0)){
            ok = mid;
        } else {
            ng = mid;
        }
    }
    
    ans.first = ok;

    ok = 0;
    ng = INF;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid, 1)){
            ok = mid;
        } else {
            ng = mid;
        }
    }

    ans.second = ok;

    if(ans.first > ans.second){
        cout << -1 << endl;
    } else {
        cout << ans.first << " " << ans.second << endl;
    }


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using ul = unsigned long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
source:
    ll n, a, b;
    cin >> n >> a >> b;

    ll num = a + b;
    ll ans = (n / num) * a + min(n % num, a);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

#define MAX 1000000

typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

int dp1[MAX * 2 + 1], dp2[MAX * 2 + 1];

int main(){
  
  fill_n(dp1, MAX * 2 + 1, INF);
  fill_n(dp2, MAX * 2 + 1, INF);
  vector< int > num;
  for(int i = 1; i <= 185; i++) {
    num.push_back(i * (i + 1) * (i + 2) / 6);
    dp1[num[num.size() - 1]] = 1;
    if((i * (i + 1) * (i + 2) / 6) % 2) 
      dp2[num[num.size() - 1]] = 1;
  }

  for(int i = 1; i <= MAX; i++) {
    for(int j = 0; j < num.size() && i + num[j] <= MAX; j++) {
      dp1[i + num[j]] = min(dp1[i] + 1, dp1[i + num[j]]);
    }
  }
 
  for(int i = 1; i <= MAX; i++) {
    for(int j = 0; j < num.size() && i + num[j] <= MAX; j++) {
      if(num[j] % 2) dp2[i + num[j]] = min(dp2[i] + 1, dp2[i + num[j]]);
    }
  }

  int N;
  while(cin >> N, N) {
    cout << dp1[N] << " " << dp2[N] << endl;
  }
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    lint a[7];
    for(int i=0;i<7;i++) cin >> a[i];
    lint x=a[0]/2*2+a[1]+a[3]/2*2+a[4]/2*2,y=0;
    if(a[0]>0 && a[3]>0 && a[4]>0){
        a[0]--;
        a[3]--;
        a[4]--;
        y=3;
        y+=a[0]/2*2+a[1]+a[3]/2*2+a[4]/2*2;
    }
    cout << (x>y?x:y) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int N = 100;

int main(){
    int A[N][N];
    int a,b,c,d;
    cin >> a;
    for(int i=0;i<a;i++){
        for(int j=0;j<a;j++)A[i][j]=0;

    }

    for(int i=0;i<a;i++){
        cin >> b >> c;
        b--;
        d--;
        for(int j=0;j<c;j++){
            cin>>d;
            d--;
            A[b][d]=1;
        }
    }

    for(int i=0;i<a;i++){
        for(int j=0;j<a;j++){
            if(j)cout<<" ";
            cout<<A[i][j];
        }
        cout <<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long int> A(N);
  for(int i = 0;i < N;i++)cin >> A[i];
  sort(A.begin(),A.end());
  cout << A[A.size()-1] - A[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
 	int N, K, ANSWER;
	cin >> N >>K;
//	vector <int> A[N];
	//for (int i=0; i<N; i++){
		//cin >> A.at(i); //数字の読み込み
	//}
	ANSWER = (N-1)/(K-1);
	if ((N-1)%(K-1) !=0){
		ANSWER +=1;
	}
	cout << ANSWER << endl;
	
	return 0;
}

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

int main(){
  
  int a;
  int b;
  double A;
  double B;
  int d;
  
  cin >> a;
  cin >> b;

  A = a;
  B = b;
  
  d = (a + b) / 2;
  cout << (A + B) - d << endl;
}

Measured memory_bytes: 256
#include <iostream>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

int dp[4001][4001];

int main(){
    std::string a, b;
    while(std::cin >> a >> b, !std::cin.eof()){
        REP(i, 4001){
            REP(j, 4001){
                dp[i][j] = 0;
            }
        }

        int res = 0;
        for(int i=a.size()-1;i>=0;i--){
            for(int j=b.size()-1;j>=0;j--){
                if(a[i] == b[j]){
                    dp[i][j] = std::max(1, dp[i+1][j+1] + 1);
                    res = std::max(dp[i][j], res);
                }else{
                    dp[i][j] = 0;
                }
            }
        }

        std::cout << res << std::endl;
    }

    return 0;
}

Measured memory_bytes: 63740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i(1);i<=n;i++)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define pres(x) cout<<fixed; cout<<setprecision(x);
#define open freopen("input.txt","r",stdin) ; freopen("output.txt","w",stdout);
#define watch(x) cout<<(#x)<<" is "<<x<<"\n";
#define out(x) cout<<x<<"\n";
#define mod 1000000007

int main(){
	int k,x;
	cin >> k >> x;
	int a=x-k+1,b=x+k-1;
	if(a<-1000000) a=-1000000;
	if(b>1000000) b=1000000;
	for(int i(a);i<=b;++i){
		cout << i << " ";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 2510;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
class Dijkstra{
    private:
        struct edge{
            ll to,cost;
        };
        vector<vector<edge>> G;
        vector<ll> d;
        ll siz;
    public:
        Dijkstra(ll n){
            G.resize(n);
            siz = n;
        }
        void add_edge(ll from,ll to,ll cost){
            G[from].push_back(edge{to,cost});
        }
        vector<ll> dijkstra(ll s){
            priority_queue<P,vector<P>,greater<P>> q;
            d.assign(siz,INF);
            d[s] = 0;
            q.push(P(0,s));
            while(!q.empty()){
                P p = q.top();q.pop();
                ll v = p.second;
                if (d[v] < p.first) continue;
                for(edge &e:G[v]){
                    if (chmin(d[e.to],d[v]+e.cost)){
                        q.push(P(d[e.to],e.to));
                    }
                }
            }
            return d;
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,s;
    cin >> n >> m >> s;
    Dijkstra g(2501*n); // u:2500*u+money
    ll u,v,a,b,c,d;
    rep(i,m){
        cin >> u >> v >> a >> b;
        --u;
        --v;
        rep(i,a,2501){
            g.add_edge(2501*u+i,2501*v+i-a,b);
            g.add_edge(2501*v+i,2501*u+i-a,b);
        }
    }
    rep(i,n){
        cin >> c >> d;
        rep(j,2500){
            g.add_edge(2501*i+j,2501*i+min(j+c,(ll)2500),d);
        }
    }
    vector<ll> dist = g.dijkstra(min(s,(ll)2500));
    rep(i,1,n){
        ll ans = INF;
        rep(j,2501){
            chmin(ans,dist[2501*i+j]);
        }
        PRINT(ans);
    }
}


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

int partition( int *, int, int );

int main()
{
  int i, n, k, *A;

  scanf("%d", &n);
  A = malloc( n * sizeof(int));
  for( i=0; i<n; i++ ) scanf("%d", &A[i]);

  k = partition( A, 0, n-1 );

  for( i=0; i<n-1; i++ )
    {
      if( i == k )
	{
	  printf("[%d] ", A[i]);
	  continue;
	}
      printf("%d ", A[i]);
    }
  printf("%d\n", A[n-1]);

  return 0;
}


int partition( int *A, int p, int r )
{
  int i, j, x, temp;

  x = A[r];
  i = p-1;

  for( j=p; j<r; j++ )
    {
      if( A[j] <= x )
	{
	  i = i + 1;
	  temp = A[i];
	  A[i] = A[j];
	  A[j] = temp;
	}
    }

  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;

  return i+1;
}



Measured memory_bytes: 2088
#include<iostream>
#include<algorithm>
#define REP(i,a) for(int i=0;i<a;i++)
using namespace std;

int n,m;
int a[60],b[60],c[60];
int dp[60][60][60];

int main(){
  cin >> n >> m;
  REP(i,n)cin >> a[i] >> b[i] >> c[i];

  REP(i,n+1)REP(j,m+1)REP(k,m+1)dp[i][j][k] = -100000000;

  dp[0][m][0] = 0;

  REP(i,n){
    REP(j,m+1)REP(k,m+1){
      REP(z,j+1){
	int s = c[i];
	for(int x=1;x<=8;x++)
	  for(int y=0;y<=x;y++){
	    if(z<y || k<x-y)continue;
	    s = max(s, a[i]*y + b[i]*(x-y));
	  }
	dp[i+1][j-z][z] = max(dp[i+1][j-z][z],dp[i][j][k] + s);
      }
    }
  }

  int ans = -100000000;
  REP(j,m+1)REP(k,m+1)ans = max(ans,dp[n][j][k]);
  cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}

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


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  
  long long N, A, B, margin=0, Min=0, ans=0;
  cin >> N >> A >> B;
  
  margin = abs(A-B);
  
  if (margin%2==0){
    ans = (margin)/2;
  }
  else{
    Min = min(A-1,N-B);
    ans += Min+1;
    margin=margin-1;
    ans+=(margin)/2;
  }

  
  cout << ans << endl;
}




Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point{
public:
    double x, y;
    Point(double x=0, double y=0):x(x), y(y){}

    Point operator + (Point p){ return Point(x + p.x, y + p.y); }
    Point operator - (Point p){ return Point(x - p.x, y - p.y); }
    Point operator * (double a){ return Point(a * x, a * y); }
    Point operator / (double a){ return Point(x / a, y / a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y;}
    bool operator < (const Point &p) const {
        // first x, second y
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const{
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};

typedef Point Vector;

double dot(Vector a, Vector b){
    //|a||b|cos(theta)
    return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b){
    //|a||b|sin(theta)
    return a.x * b.y - a.y * b.x;
}

int main() {

    int Q;
    cin >> Q;
    rep(i, Q){
        double xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3;
        cin >> xp0 >> yp0 >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3;
        Vector v1(xp0 - xp1, yp0 - yp1);
        Vector v2(xp2 - xp3, yp2 - yp3);

        if(equals(dot(v1, v2), 0.0)){ cout << 1 << endl;}
        else if(equals(cross(v1, v2), 0.0)){ cout << 2 << endl;}
        else {cout << 0 << endl;}
    }

}

Measured memory_bytes: 3232
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int dp[1005][5005];
vi box[1005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	vi a(m + 1), b(m + 1);
	repn(i, 1, m + 1){
		cin >> a[i] >> b[i];
		rep(j, b[i]){
			int x;
			cin >> x;
			x--;
			box[i].pb(x);
		}
	}
	rep(i, 1005) rep(j, 5005) dp[i][j] = 1e9;
	dp[0][0] = 0;
	repn(i, 1, m + 1){
		rep(j, (1 << n)) dp[i][j] = dp[i - 1][j];
		rep(j, (1 << n)){
			int cur = j;
			rep(k, box[i].size()) cur |= (1 << box[i][k]);
			dp[i][cur] = min({dp[i - 1][cur], dp[i - 1][j] + a[i], dp[i][cur]});
		}
	}
	if(dp[m][(1 << n) - 1] == 1e9) cout << -1 << endl;
	else cout << dp[m][(1 << n) - 1] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 20096
#include <bits/stdc++.h>
#define MOD (int)(1e9+7)

using namespace std;

long long mem[2][100005];
int n,k;
int arr[105];

int main()
{
	cin >> n >> k;
	for(int i=0;i<n;i++)
		cin >> arr[i];
	mem[n%2][0]=1;
	for(int i=n-1;i>=0;i--)
	{

		for(int j=1;j<=k;j++){
			mem[1-i%2][j]+=mem[1-i%2][j-1];
			mem[1-i%2][j]%=MOD;
		}
		for(int j=0;j<=k;j++)
		{
			// j-arr[i],j
			mem[i%2][j]=(mem[1-i%2][j]-(j-arr[i]>0?mem[1-i%2][j-arr[i]-1]:0)+MOD)%MOD;
		}
	}
	cout << mem[0][k] << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    int mn = INF, mx = MIN;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
        mn = min(mn, v[i]);
        mx = max(mx, v[i]);
    }

    int res = INF;
    for(int i = mn; i <= mx; ++i) {
        int s = 0;
        for(int j = 0; j < n; ++j) {
            s += (i - v[j]) * (i - v[j]);

        }
        res = min(res, s);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#B
n = int(input())
a = list(map(int,input().split()))
flg = True
a.sort()
if a[0] == 0:
    print(0)
else:
    result = a[0]
    for i in range(1,n):
        result *= a[i]
        if result > 10**18:
            print(-1)
            flg = False
            break
    if flg:
        print(result)

Measured memory_bytes: 21708
#include <iostream>

using namespace std;

int main(){
  int N=0, K=0;
  scanf("%d",&N );
  scanf("%d",&K );

  int h[N];
  int count = 0;

  for(int i=0;i<N;i++){
    scanf("%d",&h[i]);
    if(h[i]>=K){
      count += 1;
    }
    //cout << i;


  }

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


  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int f(int a)
{
    for(int i=0; i<200; i++)
        if(a==i*i)
            return 1;
    return 0;
}
int main()
{
    int n,d;
    int a[15][15];
    cin>>n>>d;
    for(int i=0; i<n; i++)
        for(int j=0; j<d; j++)
            scanf("%d",&a[i][j]);
    int sum=0;
    for(int k=0; k<n; k++)
        for(int i=k+1; i<n; i++)
        {
            int s=0;
            for(int j=0; j<d; j++)
                s=(a[k][j]-a[i][j])*(a[k][j]-a[i][j])+s;
            if(f(s))
                sum++;
        }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int N, K, L;
vector<int> uf1, uf2;

int main()
{
    cin >> N >> K >> L;
    uf1.resize(N+1);
    uf2.resize(N+1);
    for (int i=1; i<=N; i++) uf1[i] = uf2[i] = i;

    for (int i=0; i<K; i++)
    {
        int p, q;
        cin >> p >> q;
        while (p != uf1[p]) p = uf1[p];
        while (q != uf1[q]) q = uf1[q];
        uf1[q] = uf1[p] = min(uf1[p], uf1[q]);
    }
    for (int i=0; i<L; i++)
    {
        int p, q;
        cin >> p >> q;
        while (p != uf2[p]) p = uf2[p];
        while (q != uf2[q]) q = uf2[q];
        uf2[q] = uf2[p] = min(uf2[p], uf2[q]);
    }
    map<P, int> m;
    for (int i=1; i<=N; i++)
    {
        int p = uf1[i], q = uf2[i];
        while (p != uf1[p]) p = uf1[p];
        while (q != uf2[q]) q = uf2[q];
        m[make_pair(p, q)]++;
    }
    for (int i=1; i<=N; i++)
    {
        int p = uf1[i], q = uf2[i];
        while (p != uf1[p]) p = uf1[p];
        while (q != uf2[q]) q = uf2[q];
        cout << m[make_pair(p, q)] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; j < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
    
int main() {
  int n;
  cin >> n;
  int vl[n/2];
  int vr[n/2];
  vi vlPool(100010,0);
  vi vrPool(100010,0);
  rep(i,n/2){
    cin >> vl[i] >> vr[i];
    vlPool[vl[i]]++;
    vrPool[vr[i]]++; 
  }
  
  
  int modeL = distance(vlPool.begin(), max_element(rng(vlPool)));
  int modeR = distance(vrPool.begin(), max_element(rng(vrPool)));

  int ans = 0;

  sort(rng(vlPool));
  sort(rng(vrPool));
  reverse(rng(vlPool));
  reverse(rng(vrPool));

  if(modeL != modeR) {
    ans += n/2 - vlPool[0];
    ans += n/2 - vrPool[0];
    cout << ans << endl;
  } else {
    if(vlPool[0] > vrPool[0]) {
      ans = n - vlPool[0] - vrPool[1];
      cout << ans << endl;
    } else if (vlPool[0] < vrPool[0]) {
      ans = n - vlPool[1] - vrPool[0];
      cout << ans << endl;
    } else {
      ans = n - vlPool[0] - max(vlPool[1],vrPool[1]);
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1408
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<v> a(h, v(w, 0));
    vector<v> b(h, v(w, 0));
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> a[i][j];
        }
    }
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> b[i][j];
        }
    }
    int s = 80 * 2 * 80;
    vector<vector<v>> dp(h, vector<v>(w, v(s + 1)));
    dp[0][0][abs(a[0][0] - b[0][0])] = 1;
    rep(i, h)
    {
        rep(j, w)
        {
            if(i == 0 && j == 0) continue;
            int temp = abs(a[i][j] - b[i][j]);
            rep(k, s)
            {
                int x1 = k + temp;
                int x2 = abs(k - temp);
                if(i != 0){
                    if(x1 <= s && dp[i - 1][j][k] == 1) dp[i][j][x1] = 1;
                    if(x2 <= s && dp[i - 1][j][k] == 1) dp[i][j][x2] = 1;
                }
                if(j != 0){
                    if(x1 <= s && dp[i][j - 1][k] == 1) dp[i][j][x1] = 1;
                    if(x2 <= s && dp[i][j - 1][k] == 1) dp[i][j][x2] = 1;
                }
            }
        }
    }
    rep(i, 80 * 2 + 1)
    {
        if(dp[h - 1][w - 1][i] == 1){
            cout << i << endl;
            break;
        }
    }
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string A,B,C;
  cin >> A >> B >> C;
  if(A[A.size()-1]==B[0]&&C[0]==B[B.size()-1])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

int a, b,c,d,e,k;

int main() { 
	cin >> a >> b >> c >> d >> e >> k;

	if (e - a > k) {
		cout << ":(" << endl;

	}
	else {
		cout << "Yay!"<< endl;

	}
		return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
int main(){
  int N;
  cin>>N;
  long double p[3000];
  for(int i=1;i<=N;i++) cin>>p[i];
  long double q[3000][3000]; //q[k][i] k枚中i枚が表である確率
  q[0][0]=1;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=i;j++){
      if(j==0){
        q[i][j]=q[i-1][0]*(1-p[i]);
      }
      else if(j==i) q[i][j]=q[i-1][i-1]*p[i];
      else q[i][j]=q[i-1][j-1]*p[i]+q[i-1][j]*(1-p[i]);
    }
  }
  long double answer=0;
  for(int i=N/2+1;i<=N;i++) answer+=q[N][i];
  cout<<setprecision(16)<<answer<<endl;
  
return 0;
}

Measured memory_bytes: 85076
#include<iostream>
using namespace std;
int main() {
	int a[8];
	for (int i = 0; i < 8; i++) {
		cin >> a[i];
	}
	if (a[0] + a[1] + a[2] + a[3] > a[4] + a[5] + a[6] + a[7])cout << a[0] + a[1] + a[2] + a[3] << endl;
	else cout << a[4] + a[5] + a[6] + a[7]<<endl;
}

Measured memory_bytes: 3088
A, B = gets.split.map(&:to_i)

base_a = (A / 0.08).to_i
base_a1 = ((A + 1)/ 0.08).ceil - 1

base_b = (B / 0.10).to_i
base_b1 = ((B + 1)/ 0.10).ceil - 1

# p base_a, base_a1, base_b, base_b1

min = [base_a, base_b].max
max = [base_a1, base_b1].min

ans = []
(min..max).to_a.each do |i|
  match_a = (i * 0.08).floor == A
  match_b = (i * 0.1).floor == B

  # p "#{i} 0.08 #{A} -> #{i * 0.08} {B} -> #{i * 0.1}"

  if match_a && match_b
    ans << i
  end
end

if ans.empty?
  puts -1
else
  puts ans.min
end


Measured memory_bytes: 1788