akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
int main(){
ll n; cin>>n;
vector<int> vec ={11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451,};
rep(i,n-1){
cout << vec.at(i) << " ";
}
cout << vec.at(n-1) << endl;}


Measured memory_bytes: 3600
<?php
fscanf(STDIN, '%d', $k);
fscanf(STDIN, '%d %d', $min, $max);
$flag = false;
for ($i=$min; $i <= $max; $i++) { 
    if ($i % $k == 0) {
        $flag = true;
        break;
    }
}
echo $flag ? 'OK' : 'NG';

Measured memory_bytes: 16032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

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

#define ALL(a) (a).begin(),(a).end()
#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 RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll a,b;
	cin >> a >> b;

	if(a <= 0 && b >= 0) cout << "Zero" << endl;
	else if (a > 0) cout << "Positive" << endl;
	else{
		if((a + b) % 2 == 0) cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
}

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

int main(){
    
    cout<<fixed<<setprecision(12);
    
    double r;
    
    cin>>r;
    
    double PI = acos(-1); //cos(π) = -1 -> acos(-1) = π
    double area = r * r * PI;
    double cir = ( r + r) * PI;
    cout<<area<<" "<<cir<<endl;
    
    return 0;
    
}



Measured memory_bytes: 3256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ld a, b, h, m;
  cin >> a >> b >> h >> m;
  complex<ld> x = a, y = b;
  x *= cos((90.l-h*30.l-m/2.l)/180.l*PI)+sin((90.l-h*30.l-m/2.l)/180.l*PI)*1.0il;
  y *= cos((90.l-m*6.l)/180.l*PI)+sin((90.l-m*6.l)/180.l*PI)*1.0il;
  dump(x, y);
  print(abs(x-y));
}


Measured memory_bytes: 4160
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


a, b, c, x, y = LI()
a = min(2 * c, a)
b = min(2 * c, b)

ans = 0
if a + b > c * 2:
    if x < y:
        print(2 * x * c + (y - x) * b)
    else:
        print(2 * y * c + (x - y) * a)
else:
    print(x * a + y * b)

Measured memory_bytes: 39024
N = int(input())
working_list = list(map(int, input().split()))

print(*working_list)

for i in range(1, N):
    v = working_list[i]
    j = i - 1
    while j >= 0 and working_list[j] > v:
        working_list[j+1] = working_list[j]
        j -= 1
    working_list[j+1] = v
    print(*working_list)


Measured memory_bytes: 5980
x, n = map(int, input().split())
x1 = x
x2 = x

if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    if x not in p:
        print(x)
    
    else:
        while True:
            x1 -= 1
            x2 += 1
        
            if x1 not in p:
                print(x1)
                break
        
            if x2 not in p:
                print(x2)
                break

Measured memory_bytes: 61932
#include <iostream>

using namespace std;

int main()
{
  int r, c;
  
  int A[101][101] = {0};
       
       cin >> r >> c;
       
       for(int i = 0; i < r; i++)
       {
            for(int j = 0; j < c; j++)
            {
                cin >> A[i][j];
                A[i][c] += A[i][j];
                A[r][j] += A[i][j];
                
            }
            A[r][c] += A[i][c];
       }
       
        for(int i = 0; i <= r; i++)
       {
            for(int j = 0; j <= c; j++)
            {
                 if(j){cout << " ";}
                cout << A[i][j];
            }
            cout << endl;
       }
   return 0;
}



Measured memory_bytes: 3148
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from functools import lru_cache

PRIME = 10 ** 9 + 7


@lru_cache(maxsize=None)
def digitmod13(y):
    if y == 0:
        return 1
    elif y == 1:
        return 10 % 13
    elif y % 2 == 0:
        return digitmod13(y // 2) ** 2 % 13
    else:
        return digitmod13(y // 2) ** 2 * 10 % 13


def main():
    S = input()
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(N)]
    S = S[::-1]
    
    # init
    first = S[0]
    if first == '?':
        for k in range(10):
            dp[0][k] = 1
    else:
        first = int(first)
        dp[0][first] = 1
    
    # prepare table
    table = [[[(i + (j * k)) % 13 for k in range(13)] for j in range(10)] for i in range(13)]
    
    # dp
    for i in range(1, N):
        c = S[i]
        if c == '?':
            for d in range(13):
                for k in range(10):
                    mod = table[d][k][digitmod13(i)]
                    dp[i][mod] += dp[i - 1][d]
                    dp[i][mod] %= PRIME
        else:
            c = int(c)
            for d in range(13):
                mod = table[d][c][digitmod13(i)]
                dp[i][mod] += dp[i - 1][d]
                dp[i][mod] %= PRIME
    
    print(dp[N - 1][5] % PRIME)


if __name__ == "__main__":
    main()


Measured memory_bytes: 89436
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    string s;
    cin >> s;
    ll esum = 0;
    ll wsum = 0;
    rep(i, N) {
        if(s[i] == 'E') esum++;
        else
        {
            wsum++;
        }
    }
    ll mi = min(esum, wsum);
    ll ecnt = 0;
    ll wcnt = 0;
    rep(i, N) {
        mi = min(mi, wcnt + esum - ecnt - (s[i] == 'E'));
        if (s[i] == 'E') ecnt++;
        else wcnt++;
    }
    print(mi);
    return 0;
}

Measured memory_bytes: 900
import sys
input = sys.stdin.readline
s = input().rstrip()
 
if s.count("0") != 0 and s.count("1") != 0:
    if s.count("0") > s.count("1"):
        print(2*s.count("1"))
    elif s.count("1") > s.count("0"):
        print(2*s.count("0"))
    else:
        print(len(s))
else:
    print(0)


Measured memory_bytes: 3188
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 1000 + 9;
int n,m,mem[N][N], mod =1e9+7;
char a[N][N];


int dp(int i, int j)
{
    if(i == n && j==m)return 1;
    if(mem[i][j] != -1)return mem[i][j];
    int c1=0,c2=0;
    if(i+1<=n && a[i+1][j] =='.')c1 = dp(i+1, j);
    if(j+1<=m && a[i][j+1] =='.')c2 = dp(i, j+1);
    return mem[i][j] = (c1 + c2) % mod;
}

 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>n>>m;
        forr(i,1,n)forr(j,1,m)cin>>a[i][j];
        memset(mem, -1,sizeof mem);
        cout<<dp(1, 1)<<endl;






return 0;
}


Measured memory_bytes: 8656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int r;
    cin >> r;
    if(r<1200) out("ABC");
    else if(r<2800) out("ARC");
    else out("AGC");

}

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

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

            int x = int.Parse(str);

            if (x == 0)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


Measured memory_bytes: 27528
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
const int N=2e5+100;
ll x[N],t[N];
ll n,s;
pii solve(ll l,ll r){
    if (s<x[l]){
        return {x[r]-s,r};
    }
    if (s>x[r]){
        return {s-x[l],l};
    }
    if (t[l]<t[r]){
        t[r]+=t[l];
        pii p=solve(l+1,r);
        ll ans=p.F,ja=p.S;
        ans+=x[ja]-x[l];
        return {ans,l};
    }
    else{
        t[l]+=t[r];
        pii p=solve(l,r-1);
        ll ans=p.F,ja=p.S;
        ans+=x[r]-x[ja];
        return {ans,r};
    }
}
int32_t main(){
    sync;
    cin >> n >> s;
    for (int i=1;i<=n;i++) cin  >> x[i] >> t[i];
    pii p=solve(1,n);
    cout << p.F << endl;
}


Measured memory_bytes: 7544
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int k;
	cin >> k;
	string s = "";
	for(int i = 0;i < k;++i){
		s += "ACL";
	}
	cout << s << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>

#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue() {
  P x = Q[head];
  head = (head + 1) %LEN;
  return x;
}

int min(int a, int b) {
  return a < b ? a : b;
}


int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  for(i = 1; i <= n; i++) {
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n + 1;
  
  while(head != tail ) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t>0) enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }
  
  return 0;
}

Measured memory_bytes: 10756
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=9000000009;

signed main(){
  string s;
  cin>>s;
  if(s=="AKIHABARA")cout<<"YES"<<endl;
  else if(s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"||s=="KIHABARA"){
    cout<<"YES"<<endl;
  }else if(s=="AKIHABR"||s=="AKIHBARA"||s=="AKIHBRA"||s=="KIHABAR"||s=="KIHABRA"||s=="KIHBARA"){
    cout<<"YES"<<endl;
  }else if(s=="AKIHBR"||s=="KIHABR"||s=="KIHBAR"||s=="KIHBRA"||s=="KIHBR"){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	for(ll i=1;i<=9;i++)
	{
	    if(n%i==0)
	    {
	        ll j=n/i;
	        if(j<1 || j>9)
	            continue;
            cout<<"Yes\n";
            return 0;
	    }
	}
	cout<<"No\n";
    return 0;
}


//252908XL

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}




int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w;
	cin >>h  >>w;
	vector<string> ba(h);
	rep(i, h) cin >>ba[i];
	const int dr[]={0,1,0,-1,0};
	const int INF= 1<<28;
	auto bfs = [&](int sy, int sx, int gy, int gx) {
		vector<VI> dd(h, VI(w, INF));
		queue< pair<int, int> > que;
		que.emplace(sy, sx); dd[sy][sx]=0;
		while(!que.empty()){
			int cy,cx; tie(cy,cx) = que.front();
			que.pop();
			rep(i,4){
				int ny=cy+dr[i], nx=cx+dr[i+1];
				if(ny<0 || ny>=h || nx<0 || nx>w) continue;
				if(dd[ny][nx] == INF && ba[ny][nx] =='.'){
					que.emplace(ny, nx);
					dd[ny][nx] = dd[cy][cx] + 1;
				}
			}
		}
		return dd[gy][gx];
	};
	int ans = 0;
	rep(y1,h) rep(x1,w) rep(y2,h) rep(x2, w){
		if(ba[y1][x1]=='#' || ba[y2][x2]=='#') continue;
		int rc = bfs(y1,x1,y2,x2);
		ans = max(ans, rc);
	}
	cout << ans <<"\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq              priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
}

int32_t main()
{
	c_p_c();
	int a,b,c,k;
	int diff;
	cin>>a>>b>>c>>k;
	int sum=0;
	if(a>=k)
	{
		sum=k;
		cout<<sum<<endl;
		return 0;
	}
	else if(a<k)
	{
		
		sum+=a;
	}
	if(a+b>=k)
	{
		cout<<sum<<endl;
		return 0;
	}
	else if(a+b<k)
	{
		diff=(k-a-b);
	}
	
	sum=sum-(k-a-b);
	cout<<sum<<endl;
	return 0;
}


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

typedef long long ll;

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

    string n;
    cin >> n;

    for(int i = 0; i < n.length(); i++) {
        if(n[i] == '1')
            n[i] = '9';
        else if(n[i] == '9')
            n[i] = '1';
    }

    cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

int main() {
  int n;
  cin >> n;
  set<string> st;
  REP(i, n) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;

  return 0;
}

Measured memory_bytes: 19228
package main

import "fmt"

func main() {
	var numA, numB, target, count int

	fmt.Scan(&numA)
	fmt.Scan(&numB)
	fmt.Scan(&target)

	count = 0
	for val := numA; val <= numB; val++ {
		if target%val == 0 {
			count++
		}
	}

	fmt.Println(count)
}



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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool findSet(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 size() { return sz; }
};

int main() {
    int n, k, l; cin >> n >> l >> k;
    UnionFind uf1(n), uf2(n);
    while (l--) {
        int p, q; cin >> p >> q; p--, q--;
        uf1.unionSet(p, q);
    }
    while (k--) {
        int r, s; cin >> r >> s; r--, s--;
        uf2.unionSet(r, s);
    }
    map<pair<int, int>, int> cnt;
    for (int i = 0; i < n; i++) cnt[{uf1.root(i), uf2.root(i)}]++;
    for (int i = 0; i < n; i++) {
        cout << cnt[{uf1.root(i), uf2.root(i)}] << " \n"[i == n - 1];
    }
    return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    ll answer = 1;
    for(ll i = 1; i * i <= M; i++)
    {
        if(M % i == 0)
        {
            if(M / i >= N)
            {
                answer = max(answer, i);
            }
            if(i >= N)
            {
                answer = max(answer, M / i);
            }
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,i,j,k,cnt,x;

	while(1)	{
		scanf("%d %d",&n,&x);
		if(n==0 && x==0)	break;
		cnt=0;
		for(i=1;i<=n-2;i++)	{
			for(j=i+1;j<=n-1;j++)	{
				for(k=j+1;k<=n;k++)	{
					if(x==i+j+k)	cnt++;
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
using namespace std;
int main(void) {
  int V, C, sum;
  int coin[6] = {1, 5, 10, 50, 100, 500};
  while(cin >> V, V != 0) {
    sum = 0;
    C = 1000 - V;
    for(int i = 5 ; i >= 0 ; i--) {
      int t = C / coin[i];
      C -= t * coin[i];
      sum += t;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

  int main(){
  int i,j,n,q,k=0;
  int right,left,mid;
  int s[100000];
  int t[50000];

   scanf("%d",&n);

        for(i = 0; i < n; i++){
          scanf("%d",&s[i]);
        }

        scanf("%d",&q);

        for(i = 0; i < q; i++){
          scanf("%d",&t[i]);
        }

        for(i=0; i<q; i++){
                left = 0;
                right = n;
            while(left < right){
            mid = (left + right)/2;
            if(t[i] == s[mid]){
                k=k+1;
                break;
            }
            else if(t[i] > s[mid]){
              left = mid+1;
            }
            else right = mid;
                     }
                }

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

            return 0;
        }



Measured memory_bytes: 2280
#include <bits/stdc++.h>
using namespace std;
//#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
#define unsort(vec); sort(vec);reverse(vec);
#define int long long
#define inf 1000000007

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x/gcd(x,y)*y;
}

int v[150],w[114514],dp[150][114514];

signed main(){
	int n,W;
	cin>>n>>W;
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<=W;j++){
			if(j<w[i]){
				dp[i][j]=dp[i+1][j];
			}
			else{
				dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	cout<<dp[0][W]<<endl;
}

Measured memory_bytes: 90112
epsilon = 1e-10
while n = gets.to_i
  break if n == 0
  cross = []
  circle = []
  n.times{|i|
    x, y = gets.split(",").map(&:to_f)
    circle.each_with_index{|it, j|
      if (it[0]-x)**2 + (it[1]-y)**2 <= 4.0 + epsilon
        x1 = it[0]-x
        y1 = it[1]-y
        x2y2 = x1**2+y1**2
        a = x2y2*0.5
        b = Math.sqrt(x2y2 - a**2)
        x0 = (a*x1 + y1 * b) / x2y2
        y0 = (a*y1 - x1 * b) / x2y2
        cross << [x0+x, y0+y]
        x0 = (a*x1 - y1 * b) / x2y2
        y0 = (a*y1 + x1 * b) / x2y2
        cross << [x0+x, y0+y]
      end
    }
    circle[i] = [x, y]
  }
  max = 1
  cross.each{|x0, y0|
    cnt = 0
    circle.each{|x1, y1|
      cnt += 1 if (x1-x0)**2 + (y1-y0)**2 <= 1.0 + epsilon
#      puts "#{x0} #{y0} #{x1} #{y1} #{(x1-x0)**2 + (y1-y0)**2}"
    }
    max = cnt if max < cnt
  }
  puts max
end

Measured memory_bytes: 8820
#include <stdio.h>

int main() {
	int n;
	scanf("%d",&n);
	if(n%10==7)
	{
	    printf("Yes");
	    return 0;
	}
	n=n/10;
	if(n%10==7)
	{
	    printf("Yes");
	    return 0;
	}
	n=n/10;
	if(n%10==7)
	{
	    printf("Yes");
	    return 0;
	}
	printf("No");
	return 0;
}

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

using namespace std;

int n, k;
vector <int> x;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

int main(void) {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        x.push_back(a);
    }

    int res;
    res = 999999999;
    for (int i = 0; i <= n - k; i++) {
        int mi, ma, ti;
        mi = x[i];
        ma = x[i + k - 1];
        ti = min(abs(mi) + abs(ma - mi), abs(ma) + abs(mi - ma));
        res = min(res, ti);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 892
k = int(input())
if k < 10:
    print(k)
else:
    cnt = 9
    prev_lun = [[i] for i in range(10)]
    new_lun = [[] for _ in range(10)]
    size = 1  # digitnum-1
    continflag = True
    while True:
        new_lun[0] = prev_lun[0] + prev_lun[1]
        for i in range(1, 9):
            new_lun[i] = [i*10**size+x for x in (prev_lun[i - 1] + prev_lun[i] + prev_lun[i + 1])]
            cnt += len(new_lun[i])
            if cnt >= k:
                print(new_lun[i][k-cnt-1])
                continflag = False
                break
        if not continflag:
            break
        new_lun[9] = [9*10**size+x for x in (prev_lun[8] + prev_lun[9])]
        cnt += len(new_lun[9])
        if cnt >= k:
            print(new_lun[9][k-cnt-1])
            break
        size += 1
        prev_lun = new_lun
        new_lun = [[] for _ in range(10)]

Measured memory_bytes: 39280
#pragma GCC optimize("Ofast")

//#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x % N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % N;
		y = y >> 1;
		x = (x * x) % N;
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll r;
	cin >> r;
	ll ans = r * r;
	cout << ans;
	return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<pair<ll, ll>> xy(N);
	rep(i, N)cin >> xy[i].first >> xy[i].second;

	sort(xy.begin(), xy.end(), [](const pair<ll, ll>& l, const pair<ll, ll>& r) {
		return atan2l(l.second, l.first) < atan2l(r.second, r.first);
	});
	rep(i, N)xy.push_back(xy[i]);


	ll res = 0;
	rep(i, N) {
		ll x = 0, y = 0;
		REP(j, i, i + N) {
			x += xy[j].first;
			y += xy[j].second;
			res = max(res, x*x + y * y);
		}
	}


	cout << fixed << setprecision(15) << sqrtl(res) << endl;

	return 0;
}


Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  ll ans = (n-1)/2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int X = 0;
  int Y = 0;
  int sum = 0;

  cin >> X;
  
  Y = X % 500;
  sum += X / 500 * 1000;
  sum += Y /5 * 5;

  cout << sum << endl;

  return 0;

 }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int alpha[] = new int[26];

        while (scanner.hasNext())
            sb.append(scanner.nextLine());

        String a = sb.toString();
        a = a.toLowerCase();

        for (int i = 0; i < a.length(); i++) {
            if ((97 <= a.charAt(i) && a.charAt(i) <= 122) == false)
                continue;

            alpha[a.charAt(i) - 97]++;
        }

        for (int i = 0; i < 26; i++) {
            System.out.printf("%c : %d\n", (char) (i + 97), alpha[i]);
        }
    }
}


Measured memory_bytes: 26420
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;
    int k;
    cin>>n>>k;
    int arr[n];
    rep(i,0,n)cin>>arr[i];
    bool dp[k+1];
    dp[0]=0;
    rep(i,1,k+1)
    {
        dp[i]=0;
        int flag=0;
        rep(j,0,n)
        {
            if(arr[j]<=i && dp[i-arr[j]]==0)
            {
                flag=1;break;
            }
        }
        if(flag)dp[i]=1;
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";
    return 0;
}



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

const int mod = 998244353;

struct mint {
    ll x;

    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator-=(const mint a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }

    mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
    }

    mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
    }

    mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
    }

    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
    }

    mint inv() const {
      return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
      return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
    }
};

const int N = 300030;
mint table[N];

void init() {
  table[0] = table[1] = 1;
  for (ll i = 2; i < N; i++) {
    table[i] = table[i - 1] * i;
  }
}

mint nCr(int n, int r) {
  return table[n] / table[r] / table[n - r];
}

signed main() {
  ll n,a,b,k;
  cin >> n >> a >> b >> k;

  init();

  mint answer = 0;
  for (int i = 0; i <= n; i++) {
    ll tmp = k - a * i;
    if (tmp % b != 0) continue;

    ll a_cnt = i;
    ll b_cnt = tmp / b;

    if(b_cnt > n || b_cnt < 0) continue;

    answer = answer + nCr(n, a_cnt) * nCr(n, b_cnt);
  }

  cout << answer.x << '\n';
  return 0;
}



Measured memory_bytes: 5992
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 2000
#define INF 10000005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
ll K;

struct edge{int to,cap,rev;};

vector<edge> G[SIZE];
bool used[SIZE];

//グラフ追加: from -> to (cap)
void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to,cap,(int)G[to].size()});
	G[to].push_back((edge){from,0,(int)G[from].size()-1});
}

int dfs(int v, int t, int f){
	if(v==t)return f;
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

//s->tのmaxフロー
int max_flow(int s,int t){
	int flow = 0;
	for(;;){
		memset(used,0,sizeof(used));
		int f = dfs(s,t,INF);
		if(f==0)return flow;
		flow += f;
	}
}


int main()
{
	int V,E;
	scanf("%d%d",&V,&E);
	int u,v,c;
	for(int i=0;i<E;i++){
		scanf("%d%d%d",&u,&v,&c);
		add_edge(u,v,c);
	}
	int ans = max_flow(0,V-1);
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 2884
n=int(input())
l=list(map(int,input().split()))
d=dict()
for i in range(n):
    if l[i] not in d:
        d.update({l[i]:1})
    else:
        d[l[i]]+=1
ans=0
for j in d:
   ans+=(d[j]*(d[j]-1))//2
for i in range(n):
    k=l[i]
    tot=ans+1-d[k]
    print(tot)


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

int main()
{
  int n, d;
  cin >> n >> d;
  int a[n][d];
  rep(i,n){
    rep(j,d){
      cin >> a[i][j];
    }
  }
  
  double che;
  int ans = 0;
  rep(i,n){
    for(int j = i + 1; j < n; j++){
      che = 0;
      rep(k,d){
        che += pow(abs(a[i][k] - a[j][k]), 2);
      }
      che = sqrt(che);
      if(ceil(che == floor(che))) ans++;
    }
  }
         
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int n, q;
	cin >> n >> q;
	ll sol = (n - 2) * 1LL * (n - 2);
	
	int rows[n + 1], cols[n + 1];
	int topRow = n, topCol = n;

	for (int i = 1; i <= n; i++) {
		rows[i] = n;
		cols[i] = n;
	}

	while (q--) {
		int t, x;
		cin >> t >> x;
		if (t == 1) {
			if (x < topCol) {
				for (int i = x; i < topCol; i++) {
					cols[i] = topRow;
				}
				topCol = x;
			}
			sol -= cols[x] - 2;
		} else {
			if (x < topRow) {
				for (int i = x; i < topRow; i++) {
					rows[i] = topCol;
				}
				topRow = x;
			}
			sol -= rows[x] - 2;
		}	
	}

	cout << sol << '\n';
}


Measured memory_bytes: 5164
import sys

S = input()
S_ = S[::-1]

# words = 'dream dreamer erase eraser'.split()
# words_ = {w[::-1] for w in words}

index = 0
index_max = len(S)

while True:
    if index == index_max:
        print('YES')
        sys.exit()
    elif S_[index:].startswith('maerd'):
        index += 5
        continue
    elif S_[index:].startswith('remaerd'):
        index += 7
        continue
    elif S_[index:].startswith('esare'):
        index += 5
        continue
    elif S_[index:].startswith('resare'):
        index += 6
        continue
    else:
        print('NO')
        sys.exit()


Measured memory_bytes: 3316
#include <iostream>
using namespace std;
//B - 1 Dimensional World's Tale
int main(void){
    int n,m,x,y;
    std::cin >> n >> m >> x >>y;
    int maxX=x,minY=y;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        if(x>maxX){
            maxX=x;
        }
    }
    for (int i = 0; i < m; i++) {
        int y;
        std::cin >> y;
        if(y<minY){
            minY=y;
        }
    }
    if(maxX+1>minY){
        std::cout << "War" << std::endl;
    }else{
        std::cout << "No War" << std::endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=2e5+50;
const ll mod=1e9+7;
using namespace std;
int n,s[nmax],p[nmax],rs,i,l[nmax];
char c[nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)cin>>c[i];
    for(i=1;i<=n;i++)
    {
        p[i]=p[i-1]+(c[i]=='W');
        l[i]=l[i-1];
        if(c[i]=='R')l[i]=i;
    }
    for(i=n;i>=1;i--)s[i]=s[i+1]+(c[i]=='R');
    rs=n;
    for(i=0;i<=n;i++)
    {
        rs=min(rs,p[i]+s[i+1]);
        if(s[i+1]>=p[l[i]])rs=min(rs,s[i+1]);
    }
    cout<<rs<<'\n';
	return 0;
}


Measured memory_bytes: 6168
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s;
	while (s != ".") {
		cin >> t;
		int flag = 0;
		vector<string>ss(100);
		vector<string>tt(100);
		string box, bag;
		for (auto i : s) {
			if (i == '"') {
				box += i;
				flag++;
			}
			else if (flag%2==0)box += i;
			else ss[flag/2] += i;
		}
		ss.resize(flag/2);
		flag = 0;
		for (auto i : t) {
			if (i == '"') {
				flag++;
				bag += i;
			}
			else if (flag%2==0)bag += i;
			else tt[flag/2] += i;
		}
		tt.resize(flag / 2);
		//cout << box << endl;
		//cout << bag << endl;
		if (box != bag)cout << "DIFFERENT\n";
		else {
			if (ss.size() != tt.size())cout << "DIFFERENT\n";
			else {
				int dis = 0;
				for (int i = 0; i < ss.size(); i++) {
					//cout << ss[i] << endl;
					//cout << tt[i] << endl;
					if (ss[i] != tt[i])dis++;
				}
				//cout << dis << endl;
				if (dis > 1)cout << "DIFFERENT\n";
				else if (dis)cout << "CLOSE\n";
				else cout << "IDENTICAL\n";
			}
		}
		cin >> s;
	}
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N;
    cin >> N;
    Vec<Vec<pair<i32, bool>>> A(N, Vec<pair<i32, bool>>());
    for (i32 i = 0; i < N; i++) {
        i32 c;
        cin >> c;
        for (i32 j = 0; j < c; j++) {
            i32 x;
            bool y;
            cin >> x >> y;
            A[i].push_back(make_pair(x - 1, y));
        }
    }
    i32 max = 0;
    for (i32 bit = 0; bit < (1 << N); bit++) {
        Vec<bool> t(N, false);
        for (i32 i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                t[i] = true;
            }
        }
        bool ok = true;
        for (i32 i = 0; i < N; i++) {
            if (!ok) break;
            if (!t[i]) continue;
            for (i32 j = 0; j < A[i].size(); j++) {
                i32 x = A[i][j].first;
                bool y = A[i][j].second;
                if (t[x] != y) {
                    ok = false;
                    break;
                }
            }
        }
        if (ok) {
            i32 count = 0;
            for (i32 i = 0; i < N; i++) if (t[i]) count++;
            if (max < count) max = count;
        }
    }
    cout << max << endl;

}


Measured memory_bytes: 3636
#include<stdio.h>
#include<cmath>
using namespace std;

double aa[1100];
int main()
{
    int i, j, n, t, a, lo;
    double mi = 2000000;;
    scanf("%d", &n);
    scanf("%d%d", &t, &a);
    for (i = 1; i <= n; ++i)
    {
        scanf("%lf", &aa[i]);
        aa[i] = t - 0.006 * aa[i];
    }
    
    for (i = 1; i <= n; ++i)
    {
        if (abs(aa[i] - a) < mi) mi = abs(aa[i] - a), lo = i;
    }
    printf("%d\n", lo);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

int main(){
    ll Aflag = 0,Bflag=0;
    string S;
    cin >> S;
    for(ll i =0;i<3;i++){
        if(S[i]=='A'){
            Aflag = 1;
        }
        if(S[i]=='B'){
            Bflag = 1;
        }
    }
    if(Aflag==1&&Bflag==1){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256