akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}












const int limit = 51;
int n,m;
bool vec[limit][limit];
bool vis[limit];

void DFS(int x){
    if(vis[x]) return;

    vis[x] = true;

    REP(i,n){
        if(vec[i][x]){
            DFS(i);
        }
    }
}
using namespace std;
int main(){
    ll n,k,cnt=0,ans;
    cin >> n >> k;

    vector <pair<ll,ll>> pv(n);

    REP(i,n){
        cin >> pv[i].first >> pv[i].second;
    }

    SORT(pv);

    REP(i,n){
        cnt += pv[i].second;
        if(cnt >= k){
            cout << pv[i].first <<endl;
            break;
        }
    }
}

Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	string S;
	cin >> S;

	cout << S.insert(4, " ") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n)     for(int i = 0;i < n;i++)
#define REPR(i, n)    for(int i = n;i >= 0;i--)
#define FOR(i, m, n)  for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define ALL(X) (X).begin(),(X).end()
#define INF 99999999
#define M_PI 3.14159265358979323846
#define MOD 1000000007

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) os << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,K;

void input(){
  #ifdef __LOCAL
      fs::path p = __FILE__;
      fs::path input,output;
      input = output = p.parent_path();
      input += string("/input/") + string(p.stem()) + string(".txt");
      output += string("/output/") + string(p.stem()) + string(".txt");
      freopen(input.c_str(), "r", stdin);
      freopen(output.c_str(), "w", stdout);
  #endif

  fast_io();
  cin >> N >> K;
}


int solve(){
  int L = (N-1)*(N-2)/2-K;
  if(L<0) {cout << -1 << endl; return 0;}
  int M=N-1+L;
  vector<int> u(M),v(M);
  u[0]=1;v[0]=2;
  for (int i = 0; i < M-1; i++)
  {
    v[i+1] = v[i]==N ? u[i]+2 : v[i]+1;
    u[i+1] = v[i]==N ? u[i]+1 : u[i];
  }
  cout << M << endl;
  for (int i = 0; i < M; i++)
  {
    cout << u[i] << " " << v[i] << endl;
  } 

  return 0;
}

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


Measured memory_bytes: 384
import math

def isPrime(x):
	if x <= 1:
		return False
	for i in range(2, int(math.sqrt(x) + 1)):
		if x % i == 0: return False
	return True

def solve():
	x = int(input())
	number = x
	while isPrime(number) != True:
		number += 1
	print(number)

solve()

Measured memory_bytes: 3060
# cook your dish here


def compound_interest(principle, rate, time): 
  
    # Calculates compound interest  
    CI = int(principle * (pow((1 + rate / 100), time)))
    return CI
    
x=int(input())
principle=100
res=0
while principle<x:
    principle=compound_interest(principle,1,1)
    res+=1
print(res)
    #m,k=map(int,input().split())
    #arr=list(map(int,input().split()))
  

Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int n,m,a[1000];

map<int,int> c;

int main() {
    while(true) {
        cin >> n >> m;
        if(n == 0)break;
        rep(i,n){
            cin >> a[i];
            c[a[i]] = 0;
        }
        rep(i,n) {
            c[a[i]]++;
        }
        sort(a,a+n);//aをソート

        int ans = -1;
        rep(i,n) {
            auto itr = upper_bound(a,a+n,m - a[i]);//m-a[i]<a[j] となる最小のjのa[j]へのポインタを取得
            if(itr - a == 0) {//m - a[i]>=a[j]を満たすjが存在しない時
                continue;
            }
            itr--;//ポインタを一つ減算してm-a[i]>=a[j]となる最大のjのa[j]へのポインタを取得
            if(*itr == a[i] && c[a[i]] < 2) {//境界のものがa[i]だった時
                if(itr - a == 0) {//a[i]未満のものがない時
                    continue;
                }
                itr--;//さらに一つ前に
            }
            ans = max(ans,*itr + a[i]);
        }
        if(ans == -1)cout << "NONE" << endl;
        else cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
s = input()
n = len(s)
c = 1
for i in range((n-1)//2):
    c = -c if s[i]==s[n-i-1] else 0

for j in range((n-1)//4):
    c = -c if s[j]==s[(n-1)//2-j-1] else 0

print('No' if c == 0 else 'Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a, b;
    cin >> a >> b;
    ll root_a = sqrt(a);
    vector<ll> primes;
    for(ll i = 2; i*i <= a; i++)
    {
        if(a%i == 0)
        {
            primes.push_back(i);
            while(a%i == 0)
                a = a/i;
        }
    }
    if(a!=1) primes.push_back(a);
    ll cntr = 0;
    for(auto i : primes)
        if(b%i == 0)
            cntr++;
    cout << cntr + 1 << '\n';
    return 0;
 }


Measured memory_bytes: 384
from itertools import accumulate
import sys
input = sys.stdin.readline

def solve():
    N, X = map(int, input().split())
    tests = []
    D0 = 0
    for _ in range(N):
        B, L, U = map(int, input().split())
        v = L*B + U*(X-B)
        tests.append((v, B, L, U))
        D0 -= L*B
    tests.sort(reverse=True)

    accV = 0
    accVs = [0]
    for v, B, L, U in tests:
        accV += v
        accVs.append(accV)

    def isOK(k):
        q = k // X
        r = k % X
        accV = accVs[q+1]
        for v, B, L, U in tests[:q]:
            d = D0 + accV - v
            if r <= B:
                d += L*r
            else:
                d += L*B + U*(r-B)
            if d >= 0:
                return True
        accV = accVs[q]
        for v, B, L, U in tests[q:]:
            d = D0 + accV
            if r <= B:
                d += L*r
            else:
                d += L*B + U*(r-B)
            if d >= 0:
                return True
        return False

    ng, ok = -1, N*X
    while abs(ok-ng) > 1:
        mid = (ng+ok) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    return ok


print(solve())


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  int a, b, c, ans = 0;
  bool ok = true;
  cin >> a >> b >> c;
  if (a == b && c == b && a == c && a % 2 == 0) {
    ok = false;
    cout << "-1";
  }
  if (a == b && c == b && a == c && a % 2 == 1) {
    ok = false;
    cout << "0";
  }

  if (ok) {
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
      int A = a, B = b, C = c;
      a = (A + B) / 2;
      b = (B + C) / 2;
      c = (C + A) / 2;
      ++ans;
    }
    cout << ans;
  }
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main() {
	int N;
	cin >> N;
	string W[101];
	bool ans = true;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}
	for (int i = 0; i < N-1; i++) {
		if (W[i][W[i].size() - 1] != W[i + 1][0])
			ans = false;
		for (int j = i + 1; j < N; j++) {
			if (W[i] == W[j])
				ans = false;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    A,B,M = list(map(int,input().split()))
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    x = [list(map(int,input().split())) for _ in range(M)]

    ans = min(a)+min(b)
    for i1,i2,discount in x:
        sum = a[i1-1]+b[i2-1]-discount
        ans = min(ans,sum)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38564
#include <cmath>  /* M_PI */
#include <cstdio> /* printf */
#include<iostream>
using namespace std;

int main(void)
{
	double r;
	cin >> r;
	printf("%f\n", acos(-1)*r*r);
	printf("%f\n", acos(-1)*r*2);
	
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

class UnionFind
{
    std::vector<int> data;

public:
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (data[y] < data[x])
                std::swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y)
    {
        return root(x) == root(y);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x)
    {
        return -data[root(x)];
    }
};

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

    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        uf.unite(x, y);
    }
    set<int> st;
    for (int i = 0; i < n; i++)
        st.insert(uf.root(i));
    cout << st.size() << endl;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
bool isp[1000005];
ll prime[100005];
ll n;
vector<ll> vec;
bool ok(ll c)
{
	ll n1=n;
	while(n1%c==0) n1/=c;
	if((n1-1)%c==0) return true;
	return false;
}
int main()
{
	scanf("%lld",&n);
	ll n1=n-1;
	ll ans=2;
	for(ll i=2;i*i<=n1;i++)
	{
		if(n1%i==0)
		{
			ans+=2;
			if(i==n1/i) ans--;
		}
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ll c=n/i;
			if(ok(c)) ans++;
			if(ok(i)) ans++;
			if(ok(c)&&i==c) ans--;
		}
	}
	if(n==2) ans=1;
	printf("%lld",ans);
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var vs = new double[n];
        var us = new string[n];
        for (int i = 0; i < vs.Length; i++)
        {
            var vu = Console.ReadLine().Split();
            vs[i] = double.Parse(vu[0]);
            us[i] = vu[1];
        }

        Array.Sort(vs, us);

        var total = 0.0;
        for (int i = 0; i < vs.Length; i++)
        {
            total += us[i] == "JPY"
                ? vs[i]
                : vs[i] * 380000.0;
        }
        Console.WriteLine(total);
    }
}


Measured memory_bytes: 11476
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#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 all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>
void print(T x)
{
	std::cout << x << " ";
}
template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}
int main() {
	int K;
	cin >> K;
	int int_arr1[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	print(int_arr1[K-1]);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define N 100010
typedef long long ll;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
long long ans=0;
int n,cnt;
char s[N][13];
string z[N];
bool cmp(char *a,char *b){
	
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		sort(s[i]+1,s[i]+10+1);
		for(int j=1;j<=10;j++){
			z[i]+=s[i][j];
		}
	}
	sort(z+1,z+n+1);
	for(int i=1;i<=n;i++){
		if(z[i]==z[i-1]){
			cnt++;
		}
		else{
			ans+=(ll)cnt*(cnt+1)/2;
			cnt=0;
		}
	}
	ans+=(ll)(cnt+1)*cnt/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8576
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
int h,w,tugi=1;
struct Point{
    int x;
    int y;
    vector<Point> next;
    void get_next(vector<string> const&s){
        Point buf;
        buf.x=x+1;buf.y=y;
        if(x+1<w&&y<h)if(s[buf.y][buf.x]!=s[y][x])next.push_back(buf);
        buf.x=x-1;buf.y=y;
        if(x-1>=0&&y<h)if(s[buf.y][buf.x]!=s[y][x])next.push_back(buf);
        buf.x=x;buf.y=y+1;
        if(x<w&&y+1<h)if(s[buf.y][buf.x]!=s[y][x])next.push_back(buf);
        buf.x=x;buf.y=y-1;
        if(x<w&&y-1>=0)if(s[buf.y][buf.x]!=s[y][x])next.push_back(buf);
    }
};
void bfs(vector<string> const& s,vector<bool>& memo,vector<vector<int>>&map,int sy,int sx){
    Point S;S.x=sx;S.y=sy;
    queue<Point> que;
    que.push(S);
    while(!que.empty()){
        Point buf=que.front();
        que.pop();
        buf.get_next(s);
        int num=buf.next.size();
        map[buf.y][buf.x]=tugi;
        rep(i,num){
            if(map[buf.next[i].y][buf.next[i].x]==0){
                map[buf.next[i].y][buf.next[i].x]=tugi;
                que.push(buf.next[i]);
            }
        }
    }
    tugi++;
}
signed main(){
    cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    vector<vector<int>> map(h,vector<int> (w,0));
    vector<bool> memo(h*w+1,true);
    rep(i,h){
        rep(j,w){
            if(map[i][j]==0){
                bfs(s,memo,map,i,j);
            }
        }
    }
    vector<int> black(h*w+1,0);
    vector<int> white(black);
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#')black[map[i][j]]++;
            else white[map[i][j]]++;
        }
    }
    int res=0;
    rep(i,h*w+1){
        res+=white[i]*black[i];
    }/*
    rep(i,h){
        rep(j,w){
            cout<<map[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<res<<endl;
    return 0;
}

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

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  P a[n];
  for(int i=0; i<n; i++) cin >> a[i].first;
  for(int i=0; i<n; i++) cin >> a[i].second;
  sort(a,a+n,greater<P>());
  int ans=0;
  for(int t=0; t<(1<<n); t++) {
    if(__builtin_popcount(t)>k) continue;
    int sum=0,x=m;
    for(int i=0; i<n; i++) {
      if(!(t&(1<<i))) continue;
      sum+=min(x,a[i].second)*a[i].first;
      x-=min(x,a[i].second);
    }
    ans=max(ans,sum+x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstring>

using namespace std;

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

int n;
int default_state[10][10];
int state[10][10];
int ans[10][10];

void pass(int y, int x) {
    for (int i=0; i<5; ++i) {
        if (0 <= y + dy[i] && y + dy[i] < 10 && 0 <= x + dx[i] && x + dx[i] < 10) {
            state[y + dy[i]][x + dx[i]] = 1 - state[y + dy[i]][x + dx[i]];
        }
    }
    ans[y][x] = 1 - ans[y][x];
}

void solve() {
    for (int bt=0; bt<(1<<10); ++bt) {
        memcpy(state, default_state, sizeof(default_state));
        memset(ans, 0, sizeof(ans));
        for (int j=0; j<10; ++j) {
            if ((bt>>j) & 1) {
                pass(0, j);
            }
        }
        for (int i=1; i<10; ++i) {
            for (int j=0; j<10; ++j) {
                if (state[i-1][j] == 1) {
                    pass(i, j);
                }
            }
        }
        bool ok = true;
        for (int i=0; i<10; ++i) {
            for (int j=0; j<10; ++j) {
                if (state[i][j] == 1) ok = false;
            }
        }
        if (ok) return ;
    }
}

int main() {
    cin >> n;
    while (n --) {
        for (int i=0; i<10; ++i) {
            for (int j=0; j<10; ++j) {
                cin >> default_state[i][j];
            }
        }
        solve();
        for (int i=0; i<10; ++i) {
            for (int j=0; j<10; ++j) {
                cout << (j == 0 ? "" : " ") << ans[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1000000+5;
const ll mod = 1e9+7;

int main(){
    int A, B, ans = 0;
    scanf("%d%d",&A,&B);
    for(int i=A;i<=B;i++){
        int l = 0,j=i;
        int tl[10];
        while(j){
            tl[l++] = j%10;
            j /= 10;
        }
        int fl = 1;
        for(int k=0;k<l;k++){
            if(tl[k] != tl[l-k-1]){
                fl = 0;break;
            }
        }
        ans += fl;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

const int MAX_SIZE = 52;

int LCS(const char* a, const char* b){
    int n = 0, m = 0;
    vector<int> x,y;
    for(;a[n] != '\0';n++){
        int s = a[n]-'a';
        if(s < 0){
            s = a[n]-'A'+26;
        }
        x.pb(s);
    }
    for(;b[m] != '\0';m++){
        int s = b[m]-'a';
        if(s < 0){
            s = b[m]-'A'+26;
        }
        y.pb(s);
    }
    vector<vector<int> > vec(MAX_SIZE);
    for(int j = m-1; j >= 0; --j){
        vec[y[j]].push_back(j);
    }
    vector<int> xs(n+1, INF);
    xs[0] = -INF;
    vector<P> nx(n+1,P(-INF,-INF));
    rep(i,n){
        vector<int>& ys = vec[x[i]];
        rep(j,(int)ys.size()){
            int k = lower_bound(xs.begin(),xs.end(),ys[j]) - xs.begin();
            xs[k] = ys[j];
            nx[k] = P(y[ys[j]], k-1);
        }
    }
    return lower_bound(xs.begin(),xs.end(),INF-1) - xs.begin() - 1;
}


int main()
{
    int q;
    scanf("%d",&q);
    rep(i,q){
        char x[1000], y[1000];
        scanf("%s%s",x,y);
        cout << LCS(x,y) << "\n";
    }
    return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int64_t sum=0;
  for(int i=0;i<N;i++){
    sum+=A[i];
  }
  int64_t l=0,MIN=sum;
  for(int i=0;i<N;i++){
    l+=A[i];
    int64_t r=sum-l;
    MIN=min(MIN,abs(r-l));
  }
  cout<<MIN<<endl;
  return 0;  
}


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

int main()
{
    int a, b;
    cin >> a >>b;

    for(int i=1; i<=1250; i++){
        if((int)(i*0.08) == a && (int)(i*0.10)== b)
            { cout << i << endl; return 0;}
    }

    cout << -1 << endl;

    return 0;
}

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

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

	vector<string> vec(N);

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

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

	string output;

	for (int j = 0; j < N; j++) {
		output += vec.at(j);
	}

	cout << output << endl;

	return 0;
}


Measured memory_bytes: 256
"use strict";

function main(input) {
  input = input.split(/\n|\s/);
  const n = ~~input[0];
  const blue = input.slice(1, n + 1);
  const red = input.slice(n + 2);

  let obj = new Object();
  for (let i in blue) {
    obj[blue[i]] = obj[blue[i]] + 1 || 1;
  }

  for (let i in red) {
    obj[red[i]] = obj[red[i]] - 1 || -1;
  }

  let max = 0;
  for (let v in obj) {
    max = Math.max(max, obj[v]);
  }
  max = max >= 0 ? max : 0;

  console.log(max);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

signed main() {
  int64_t a,b,k;
  cin >> a >> b >> k;
  if(a <= k){
	k -= a;
    a = 0;
  }else{
    a -= k;
    goto end;
  }

  if(b <= k){
    k -= b;
    b = 0;
  }
  else{
    b -= k;
    k -= b;
  }
end:
  cout << a << " " << b << endl;
  return 0;
}

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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int,int>;

int main(){
    int H,W,M; cin>>H>>W>>M;
    set<pint> Bomb;
    vector<int> h(M),w(M),hcnt(H,0),wcnt(W,0);
    rep(i,M){
        cin>>h.at(i)>>w.at(i);
        h.at(i)--;
        w.at(i)--;
        hcnt.at(h.at(i))++;
        wcnt.at(w.at(i))++;
        Bomb.insert(pint(h.at(i),w.at(i)));        
    }
    vector<pint> hv,wv;
    rep(i,H)hv.push_back(pint(hcnt.at(i),i));
    rep(i,W)wv.push_back(pint(wcnt.at(i),i));
    sort(hv.rbegin(),hv.rend());
    sort(wv.rbegin(),wv.rend());
    int hmax = hv.at(0).first, wmax = wv.at(0).first;

    // cout<<hmax<<endl;
    // cout<<wmax<<endl;
    vector<int> hind,wind;
    // rep(i,M){
    //     if(hcnt.at(i)==hmax)hind.push_back(i),cout<<"h is "<<i<<endl;
    //     if(wcnt.at(i)==wmax)wind.push_back(i),cout<<"w is "<<i<<endl;
    // }

    rep(i,H)if(hcnt.at(i)==hmax)hind.push_back(i);
    rep(i,W)if(wcnt.at(i)==wmax)wind.push_back(i);

    // for(auto p : Bomb) cout<<"("<<p.first<<","<<p.second<<endl;

    
    
    rep(h,hind.size()){
        rep(w,wind.size()){
            // cout<<hind.at(h)<<" "<<wind.at(w)<<endl;
            if(Bomb.find(pint(hind.at(h),wind.at(w)))==Bomb.end()){
                cout<<hmax+wmax<<endl;
                return 0;
            }
        }
    }
    cout<<hmax+wmax-1<<endl;
}


Measured memory_bytes: 31076
#include<cstdio>
#include<algorithm>
using namespace std;

int n,dp[100005],h[100005],k;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	for(int i=2;i<=n;i++)
	{
		dp[i]=2E9;
		for(int j=1;j<=k&&j<i;j++)
			dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
	}
	printf("%d",dp[n]);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,k,a[100010],b[100010],ans;
map<int,int>mp;
int bit[100010];//[1,N+1]
int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}
void add(int i,int x){
    while(i<=n){
        bit[i]+=x;
        i+=i&-i;
    }
}
signed main(){
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    rep(j,n+1){
        b[j]=b[j-1]+a[j-1]-k;
    }
    rep(i,n+1)mp[b[i]]=1;
    int now=0;
    for(P p:mp){
        if(p.se){
            mp[p.fi]=now;
            now++;
        }
    }
    rep(i,n+1){
        b[i]=mp[b[i]];
    }
    n++;
    rep(i,n){
        ans+=sum(b[i]+1);
        add(b[i]+1,1);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 11700
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datK, datS) = readLine.split(" ").map(_.toInt)
    var count = 0
    for (x <- 0 to datK; y <- 0 to datK) {
      if((datS >= x + y) && (datS - (x + y) <= datK)) count += 1
    }
    println(count)
  }
}


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

int main() {
	int N; cin >> N;
	int d[N];
	for (int i = 0; i < N; ++i)
    	cin >> d[i];
  
  	sort(d,d+N);
	cout << d[N/2] - d[N/2-1] << endl;
}

Measured memory_bytes: 640
#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() {
    int N, X, tmp;
    cin >> N >> X;
    vector<int> x(N);
    rep(i,N) {
        cin >> tmp;
        x.at(i) = abs(tmp - X);
    }
    int ans = x.at(0);
    rep(i,N) ans = gcd(ans, x.at(i));
    cout << ans << endl;
}


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

int main() {
    string str;
    cin >> str;
    if (str.size() < 6) {
        cout << "INVALID" << endl;
    } else {
        bool num = false, big= false, small = false;
        for (auto s : str) {
            if ('0' <= s && s <= '9') num = true;
            if ('a' <= s && s <= 'z') small = true;
            if ('A' <= s && s <= 'Z') big = true;
        }

        if (num && big && small) {
            cout << "VALID" << endl;
        } else {
            cout << "INVALID" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3200
inp = []
ii = input().split()
if int(ii[0]) > int(ii[1]):
    re = int(ii[0])  * 2 -1
elif int(ii[0]) < int(ii[1]):
    re = int(ii[1])  * 2 -1
else:
    re = int(ii[0])  * 2
print(re)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T>
inline bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template <class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) { return (a * b) / GCD(a, b);}

int main(){
    //以下TLE解法
   /*  ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i,m){
        ll k = a.back() / 2;
        a.pop_back();
        a.insert(upper_bound(a.begin(), a.end(), k), k);
    }
    ll sum = 0;
    rep(i, n) sum += a[i];
    cout << sum << endl; */
    //以上TLE解法
    ll n, m;
    cin >> n >> m;
    int a;
    priority_queue<ll> q;
    rep(i,n) {
        cin >> a;
        q.push(a);
    }
    rep(i, m) {
        ll k = q.top() / 2;
        q.pop();
        q.push(k);
    }
    ll sum = 0;
    rep(i, n){
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 1528
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int result = 0;
        int[] h = new int[n];
        if(n==1){
            System.out.println(0);
            return;
        }
        for(int i = 0;i<n;i++){
            h[i] = sc.nextInt();
        }
        int now = h[n-1];
        int nowResult = 0;
        for(int i = (n-2);i>-1;i--){
            int tugi = h[i];
            if(tugi >= now){
                nowResult++;
                if(result<nowResult){
                    result = nowResult;
                }
            }else{
                nowResult = 0;
            }
            now = tugi;
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 50160
#include<iostream>
#include<vector>
#include<algorithm>

int main(void){
    long long n, k;
    std::cin >> n >> k;
    std::vector<int> a(n), f(n);
    for(int i = 0; i < n; i++){
	std::cin >> a[i];
    }
    for(int i = 0; i < n; i++){
	std::cin >> f[i];
    }
    std::sort(a.begin(), a.end());
    std::sort(f.rbegin(), f.rend());
    long long l = 0, r = 1e12+1;
    long long mid;
    while(l < r){
	mid = (l + r) / 2;
	long long sum = 0;
	// std::cout << mid << std::endl;
	for(int i = 0; i < n; i++){
	    // std::cout << sum << std::endl;
	    // std::cout << a[i] << std::endl;
	    // std::cout << mid << std::endl;
	    // std::cout << "f[i]:" << f[i] << std::endl;
	    // std::cout << "mid / f[i]:" << mid / f[i] << std::endl;
	    // std::cout << a[i] - mid / f[i] << std::endl;
	    sum += std::max(0ll, a[i] - mid / f[i]);
	}
	// std::cout << mid << std::endl;
	if(sum <= k){
	    r = mid;
	}else{
	    l = mid + 1;
	}
	// std::cout << mid << std::endl;
    }
    std::cout << r << std::endl;


    return 0;
}



Measured memory_bytes: 4800
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    ll x;
    cin >> x;

    ll time = 0;
    ll now_x = 0;
    while(1) {
//        cout << now_x << endl;
        if ( now_x >= x ) break;
        ++time;
        now_x += time;
    }

    cout << time << endl;

    return 0;
}


Measured memory_bytes: 256
while True:
    s1 = input()
    if s1 == ".":
        break
    s2 = input()

    listed_s1 = [[]]
    listed_s2 = [[]]
    start = 0
    now = 0
    for i in range(len(s1)):
        if s1[i] == "\"" and not start:
            listed_s1.append([])
            now += 1
            start = 1
            listed_s1[now].append(s1[i])
        elif s1[i] == "\"" and start:
            listed_s1[now].append(s1[i])
            listed_s1.append([])
            now += 1
            start = 0
        else:
            listed_s1[now].append(s1[i])

    now = 0
    for i in range(len(s2)):
        if s2[i] == "\"" and not start:
            listed_s2.append([])
            now += 1
            start = 1
            listed_s2[now].append(s2[i])
        elif s2[i] == "\"" and start:
            listed_s2[now].append(s2[i])
            listed_s2.append([])
            now += 1
            start = 0
        else:
            listed_s2[now].append(s2[i])

    fist_wrong = 0
    ans = "IDENTICAL"
    if len(listed_s1) != len(listed_s2):
        ans = "DIFFERENT"

    for i in range(min(len(listed_s1), len(listed_s2))):
        if ans == "DIFFERENT":
            break
        if listed_s1[i] != listed_s2[i]:
            if listed_s1[i][0] == "\"" and listed_s2[i][-1] == "\"" and listed_s2[i][0] == "\"" and listed_s2[i][-1] == "\"":
                if fist_wrong:
                    ans = "DIFFERENT"
                else:
                    fist_wrong = 1
                    ans = "CLOSE"

            else:
                ans = "DIFFERENT"


    print(ans)


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

int main() {
    string str;
    cin >> str;
    if (str == "SUN") cout << 7 << endl;
    else if (str == "MON") cout << 6 << endl;
    else if (str == "TUE") cout << 5 << endl;
    else if (str == "WED") cout << 4 << endl;
    else if (str == "THU") cout << 3 << endl;
    else if (str == "FRI") cout << 2 << endl;
    else if (str == "SAT") cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
int cards[4][14]={{0},{0},{0},{0}};
char type[4]={'S','H','C','D'};

void pp(int n){
    for(int i=1;i<14;i++)
        if(!cards[n][i]) 
            cout<<type[n]<<" "<<i<<endl;
}

int main()
{   
    map<char,int> t;
    for(int i=0;i<4;i++)
        t[type[i]] = i;
    
    char c; int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>c>>m;
        cards[t[c]][m] = 1;
    }
    
    for(int i=0;i<4;i++)
        pp(i);

}


Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <utility>
using namespace std;

typedef struct{
	int num;
	int pr[11]; //waの数，acしたら-1
	int ac;
	long time;
}team;

int main(){
	while(1){
		int M, T, P, R;
		team a[51];
		
		scanf(" %d %d %d %d", &M, &T, &P, &R);
		if(M==0) break;
		
		//初期化
		for(int i=1; i<=50; ++i){
			a[i].num=i;	
			for(int j=1; j<=10; ++j) a[i].pr[j]=0;
			a[i].ac=0;
			a[i].time=0;
		}
		
		
		for(int i=0; i<R; ++i){
			int m, t, p, j;
			scanf(" %d %d %d %d", &m, &t, &p, &j);
			
			if(j!=0){ //不正解
				a[t].pr[p]++;
			}
			else{ //正解
				if(a[t].pr[p]==-1) continue;
				
				a[t].ac++;
				a[t].time+=m+20*a[t].pr[p];	
				a[t].pr[p]=-1;
			}
		}	
		
		//sort
		for(int i=1; i<=T; ++i){
			for(int j=i; j<=T; ++j){
				if(a[i].ac < a[j].ac) swap(a[i], a[j]);
				else if(a[i].ac == a[j].ac){
					
					if(a[i].time > a[j].time) swap(a[i], a[j]);
					else if(a[i].time == a[j].time){
						
						if(a[i].num < a[j].num) swap(a[i], a[j]);
					}					
				}
				
			}
		}
			
		//for(int i=1; i<=T; ++i) printf("%d :ac%d, tine%ld\n", a[i].num, a[i].ac, a[i].time);
		
		for(int i=1; i<=T; ++i){
			printf("%d", a[i].num);
			if(i<T){
				if(a[i].ac==a[i+1].ac && a[i].time==a[i+1].time) printf("=");
				else printf(",");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
    int A,B,C,D,X,Y,N,L,M,P,Q;
    int ans = 0;
    cin>>N>>D;
    int arr[N][D];
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin >> arr[i][j];
        }
    }

    for(int a=0;a<N;a++){
        for(int b=a+1;b<N;b++){
            double sum = 0;
            for(int d=0;d<D;d++){
                sum+= (arr[a][d]-arr[b][d])*(arr[a][d]-arr[b][d]);
            }
            double sq = sqrt(sum);
            if( sq - (int)sq < 0.0001){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
int main(void){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    
    ll ans = N;
    sort(A.begin(), A.end());
    vector<bool> count(A[N-1]+1, false);
    for (int i = 0; i < N; i++) {
        if (i != N-1 && A[i] == A[i+1])
            ans--;
        else if (count[A[i]])
            ans--;
        for (int j = A[i]; j <= A[N-1]; j += A[i])
            count[j] = true;
    }
    cout << ans;
}

Measured memory_bytes: 4784
#include  <bits/stdc++.h>
using namespace std; 
int a,b,c,x,y,z;
int main()
{
	cin>>x>>y>>z;
	a=x;
	b=y;
	c=z;
	swap(a,b);
	swap(a,c);
	cout<<a<<' ';
	cout<<b<<' ';
	cout<<c;
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        Strategy strategy = new MyStrategy();
        strategy.solve(out, sc);
        out.flush();
    }
}

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        int x1 = sc.nextInt();
        int x2 = sc.nextInt();
        int x3 = sc.nextInt();
        int x4 = sc.nextInt();
        int x5 = sc.nextInt();

        if (x1 == 0) {
            out.println(1);
        } else if (x2 == 0) {
            out.println(2);

        } else if (x3 == 0) {
            out.println(3);

        } else if (x4 == 0) {
            out.println(4);

        } else {
            out.println(5);

        }
    }
}

interface Strategy {
    void solve(PrintWriter out, FastScanner sc);
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 25508
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int w,s,c=0,o;
	scanf("%d%d",&w,&s);
		for(int x=0;x<=w;x++)
		{
            for(int y=0;y<=w;y++)
            {
                int o=s-(x+y);
                if(o>=0&&o<=w)
                    c++;
            }
	   }
	   printf("%d",c);
}

Measured memory_bytes: 256
# ABC 061 D
# Bellman-Ford

N, M = map(int, input().split())
INF = float("inf")

G = []
# from a to b cost c
for k in range(M):
    a, b, c = map(int, input().split())
    G.append([a-1,b-1,-c])

dist = [INF for k in range(N)]
dist[0] = 0

for k in range(N-1):
    for l in range(M):
        a, b, c = G[l][0], G[l][1], G[l][2]
        if dist[a] != INF and dist[b] > dist[a] + c:
            dist[b] = dist[a] + c

# find a negative loop
negative = [0 for k in range(N)]
for k in range(N):
    for l in range(M):
        a, b, c = G[l][0], G[l][1], G[l][2]
        if dist[a] != INF and dist[b] > dist[a] + c:
            dist[b] = dist[a] + c
            negative[b] = 1
        if negative[a] == 1:
            negative[b] = 1

print("inf" if negative[N-1] else -dist[N-1])


Measured memory_bytes: 46808
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

    map<int, int> counter;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        counter[a]++;
    }

    int ans = 0;
    for (auto x: counter) {
        if (x.second > x.first) {
            ans += x.second - x.first;
        } else if (x.second < x.first) {
            ans += x.second - 0;
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    bool hamming[1000001]={};
    for(int i=1;i<1000001;i*=2){
        for(int j=i;j<1000001;j*=3){
            for(int k=j;k<1000001;k*=5)hamming[k]=1;
        }
    }
    int m;
    while(cin>>m,m){
        int n,co=0;
        cin>>n;
        for(int i=m;i<=n;i++)if(hamming[i])co++;
        cout<<co<<endl;
    }
}

Measured memory_bytes: 2144
#include <iostream>
#include <cstdio>
#include <map>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	cout << 6-(a+b);
	return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

ll gcd(ll x, ll y) {
  while (y != 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

ll dist[100000] = {};

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

  ll N, X;
  cin >> N >> X;
  REP(i, N) {
    ll x;
    cin >> x;
    dist[i] = abs(X - x);
  }

  ll g = gcd(dist[0], dist[1]);
  for (int i = 2; i < N; i++) {
    g = gcd(g, dist[i]);
  }

  cout << g << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
#define REP(i,a,b) for(int i = (int)(a); (i) < (int)(b); i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int n;
	cin >> n;
	int a[n+2];
	a[0] = 0;
	a[n+1] = 0;
	REP(i,1,n+1){ cin >> a[i]; }

	int dist_sum = 0;
	REP(j,1,n+2){ dist_sum += abs(a[j] - a[j-1]); }

	REP(k,1,n+1){
		if ((a[k-1] <= a[k] && a[k] <= a[k+1]) || (a[k+1] < a[k] & a[k] < a[k-1])){
			cout << dist_sum << endl;
		}else{
			if (abs(a[k+1] - a[k]) >= abs(a[k] - a[k-1])){
				cout << dist_sum - 2*abs(a[k] - a[k-1]) << endl;
			}else{
				cout << dist_sum - 2*abs(a[k+1] - a[k]) << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1664