akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define data_type long long

int main()
{
    data_type n,w;
    cin>>n>>w;
    vector<pair<data_type,data_type>>vc(n);
    for(auto &i:vc)
        cin>>i.first>>i.second;
   vector<vector<data_type> > dp(n+1,vector<data_type>(w+1,0));
   for(int i=1;i<=n;i++)
   {
      for(int j=1;j<=w;j++)
      {
         if(j<vc[i-1].first)
         {
            dp[i][j]=dp[i-1][j];
            continue;
         }
         dp[i][j]=max(dp[i-1][j-vc[i-1].first]+vc[i-1].second,dp[i-1][j]);
      }
   }

    cout<<dp[n][w]<<endl;

    return 0;
}


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


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

    if (N % 2 == 1) {
    	cout << 0 << endl;
    	return 0;
    }

    ll ans = 0;
    ll k = 10;
    while(1) {
    	ans += N / k;
    	k = k * 5;
    	if (k > N) break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
H, N = map(int, input().split())
 
magic = [tuple(map(int, input().split())) for _ in range(N)]
 
DP = [0] * (H+10**4)
 
for h in range(1, H+1):
  DP[h] = min(DP[h - damage] + mp for damage, mp in magic)
print(DP[H])

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e16+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y){
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;    
    y=y/2;
  }
  
  return res%hell;
}
 
ll modinv(ll x){
  return power(x,hell-2);
}

ll gcd(ll a,ll b){
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}    
    
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}    

void solve(){
    int n;
    cin>>n;
    
    string s;
    cin>>s;
    
    int cntr=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')
        cntr++;
    }
    int ans=min(cntr,n-cntr);
    int x=0;
    
    for(int i=0;i<cntr;i++){
        if(s[i]=='R')
        x++;
    }
    ans=min(ans,cntr-x);
    cout<<ans;
}    

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
      
   while(test--)
   solve();
}    

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(void) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string a;
	cin>>a;
	ll res=0;
	for(int i=0;i<a.size()/2;++i)
	{
		if(a[i]!=a[a.size()-1-i])
			++res;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	ll n,m;
	cin>>n>>m;
	multiset<ll> st;
	rep(i,n)
	{
		ll val;
		cin>>val;
		st.insert(val);
	}	
	rep(i,m)
	{
		auto it=st.rbegin();
		ll val=*it;
		st.erase(st.find(val));
		val/=2;
		st.insert(val);
	}
	ll ans=0;
	for(auto it:st) ans+=it;
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 8328
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, 200):
    for j in range(1, 200):
        for k in range(1, 200):
            d[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + i * k] += 1
for i in range(n):
    print(d[i + 1])

Measured memory_bytes: 106560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N,a,ans=0;
  cin>>N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin>>a;
    A.at(i)=a;
    ans^=a;
  }
  for(ll i=0;i<N;i++){
    ll rock=ans^A.at(i);
    cout<<rock<<" ";
  }
}

Measured memory_bytes: 4840
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N;
	cin>>N;
	long long ans=0;
	bool b=false;
	for(int i=1;i<=N;i++){
		long long a;
		cin>>a;
		if(a==i){
			ans++;
			if(b){
				ans--;
				b=false;
			}
			else b=true;
		}else b=false;
	}
	if(ans!=0)cout<<ans<<endl;
	else cout<<0<<endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::collections::VecDeque;

fn main(){
    let mut input = String::new();
    stdin().read_line(&mut input);
    let mut s = input.trim().chars().collect::<VecDeque<char>>();

    let mut input = String::new();
    stdin().read_line(&mut input);
    let q = input.trim().parse::<i32>().unwrap();

    let mut is_rev = false;

    for i in 0..q {
        let mut input = String::new();
        stdin().read_line(&mut input);
        let mut query = input.split_whitespace();
        let t = query.next().unwrap().parse::<i32>().unwrap();
        if t == 1 {
            is_rev = !is_rev;
        } else {
            let f = query.next().unwrap().parse::<i32>().unwrap();
            let mut c = query.next().unwrap().chars().nth(0).unwrap();
            if (!is_rev && f == 1) || (is_rev && f == 2) {
                s.push_front(c);
            } else {
                s.push_back(c);
            }
        }
    }
    if is_rev {
        println!("{}", s.into_iter().rev().collect::<String>());
    } else {
        println!("{}", s.into_iter().collect::<String>());
    }
}


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

int main() {
  int count=1;
  string s;
  cin >> s;

 if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'R') 
   count = 3;

  if (s.at(0) == 'S' && s.at(1) == 'S' && s.at(2) == 'S') 
   count = 0;
  
  if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'S') 
   count = 2;
  
  if (s.at(0) == 'S' && s.at(1) == 'R' && s.at(2) == 'R') 
count = 2;
 


  cout << count << endl;
}





Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){

    ll N = 0;
    cin >> N;


    vector <ll > T(N, 0);
    vector <ll > A(N, 0);

    ll max_h_T = 0;
    ll max_h_A = 0;

    for(ll i = 0; i < N; i++){
        cin >> T[i];
        max_h_T = max(max_h_T, T[i]);
    }

    for(ll i = 0; i < N; i++){
        cin >> A[i];
        max_h_A = max(max_h_A, A[i]);
    }

    //そもそも最大値が違うとムリダナ
    if(max_h_T != max_h_A){
        cout << "0" << endl;
        return 0;
    }

    bool flg = false;

    ll ans = 1;
    ll max_continue = 0;
    for(ll i = 0; i < N; i++){

        if(T[i] < A[i]){
            if(T[i] == T[i + 1]){
                //cout << T[i] << endl;
                if(A[i] > A[i + 1] ){
                    ans = 0;
                }else{
                    ans = ans * T[i] % 1000000007;
                }
                
            }
        }else if(T[i] > A[i]){
            if(A[i] == A[i + 1]){
                //cout << A[i] << endl;
                if(T[i - 1] < T[i]){
                    ans = 0;
                }else{
                    ans = ans * A[i] % 1000000007;
                }
                
            }
        }

        if(T[i] == max_h_T && A[i] == max_h_A){
            max_continue++;
            flg = true;
        }

    }

    if(flg == false){
        cout << "0" << endl;
        return 0;
    }

    //cout << max_continue << endl;
    for(ll i = 0; i < max((ll)0, max_continue - 2); i++){
        //cout << ans << endl;
        ans = ans * max_h_T % 1000000007;
    }

    cout << ans << endl;

} 

Measured memory_bytes: 1792
#https://atcoder.jp/contests/abc168
a,b,h,m=gets.split(" ")
a,b,h,m=[a,b,h,m].map{|n| n.to_f}
#A時針12時間一周＝一時間2/12π進行
#B分針一時間一周＝一時間2π進行
#a=3.0;b=4.0;m=0.0;h=9.0#.0つけろ
sitaA=(h+m/60)*2/12*Math::PI
sitaB=(h+m/60)*2*Math::PI
#p sitaA,sitaB

#x^2=a^2+b^2-2ab cos sita
p Math.sqrt(a**2+b**2-2*a*b*Math.cos(sitaA-sitaB) )


Measured memory_bytes: 14668
fun main(args: Array<String>) {
    var (x, y, a, b, c) = readLine()!!.split(" ").map{it.toInt()}
    var p = readLine()!!.split(" ").map{it.toLong()}
    var q = readLine()!!.split(" ").map{it.toLong()}
    var r = readLine()!!.split(" ").map{it.toLong()}
    val aa = p.sortedDescending().take(x).toLongArray()
    val bb = q.sortedDescending().take(y).toLongArray()
    val apple = ( aa + bb + r).sortedDescending().take(x+y)
    var ans = 0L
    repeat(x+y){ans += apple[it]}
    println(ans)
}


Measured memory_bytes: 117280
#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];
    }
}

template <typename T>
class FenwickTree
{
    int n;
    std::vector<T> bit;

  public:
    FenwickTree(int _n) : n(_n), bit(_n, 0) {}

    void add(int pos, const T &w)
    {
        assert(0 <= pos && pos < n);
        for (int i = pos; i < n; i |= i + 1)
            bit[i] += w;
    }
    // v[0] + ... + v[pos-1]
    T sum(int pos)
    {
        assert(0 <= pos && pos <= n);
        T res = 0;
        for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1)
        {
            res += bit[i];
        }
        return res;
    }
    T sum(int l, int r)
    {
        assert(0 <= l && l <= r && r <= n);
        return sum(r) + (-sum(l));
    }
};

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

    int x, y;
    while (cin >> x >> y, x || y)
    {
        cout << min(x, y) << " " << max(x, y) << endl;
    }
}


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();

  vector<int> a(n);
  vector<int> v;
  for(int i = 0; i < n; ++i) {
    if(s[i] == 'R') v.push_back(i);
    if(s[i] == 'L' && v.size()) {
      for(int j : v) {
        if((i - j) % 2 == 1) a[i - 1]++;
        else a[i]++;
      }
      v.clear();
    }
  }

  assert(v.size() == 0);
  for(int i = n - 1; i >= 0; --i) {
    if(s[i] == 'L') v.push_back(i);
    if(s[i] == 'R' && v.size()) {
      for(int j : v) {
        if((j - i) % 2 == 1) a[i + 1]++;
        else a[i]++;
      }
      v.clear();
    }
  }

  for(int x : a) cout << x << ' ';
  cout << "\n";
}


Measured memory_bytes: 1480
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


int main() {
	int n;
	cin >> n;
	vector<int>h(n);
	vector<int>ng(n);
	for (int i = 0; i < n; i++)cin >> h[i];

	int ok = 1;
	for (int i = 0; i < n - 1; i++) {
		if (h[i + 1] < h[i]) {
			if (h[i] - h[i + 1] > 1)ok = 0;
			else if (ng[i])ok = 0;
			else ng[i + 1] = 1;
		}
		else if (h[i + 1] == h[i]){
          if(ng[i] == 1){
          	ng[i + 1] = 1;
          }
        }
	}
	if (ok)puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//#define DEBUG 1
#define D_LENGTH 600
 
int get_area(int d, int input);

main()
{
	
	int input;
	while(scanf("%d", &input) != EOF)
	{
		int i;
		int sum = 0;
		
		for(i = input; i < D_LENGTH; i += input)
		{
			sum += get_area(i, input);
		}	
		printf("%d\n", sum);
	}

	return 0;
}

int get_area(int d, int input)
{
	d = d * d;
	d = d * input;
#ifdef DEBUG
	printf("%d\n", d);
#endif
	return d;
	
}

Measured memory_bytes: 596
//16D8104020F 関根匠海 takumi13 C++
//キュー

#include <iostream>
#include <string>
#include <sstream>
#define MAX 100000
using namespace std;

struct Queue{
    int head;
    int tail;
    int q[MAX];

    void initialize(){
        head = 0;
        tail = 0;
    }
    bool isEmpty(){
        return (head == tail);
    }
    bool isFull(){
        return (head == (tail+1)%MAX);
    }
    void enqueue(int x){
        if(isFull()){
            cout << "queue overflow\n";
            //exit(0);
        }
        q[tail] = x;
        if(tail == MAX-1){
            tail = 0;
        }
        else{
            tail += 1;
        }
    }
    int dequeue(){
        if(isEmpty()){
            cout << "queue underflow\n";
            //exit(0);
        }
        int x = q[head];
        if(head == MAX-1){
            head = 0;
        }
        else{
            head += 1;
        }
        return x;
    }
};

void calc(Queue q_name, string name[], Queue q_time, int quantum){
    int t_sum = 0;
    while(q_name.head != q_name.tail){
        if(q_time.q[q_time.head] <= quantum){
            t_sum += q_time.dequeue();
            cout << name[q_name.dequeue()] << " " << t_sum << '\n';
        }
        else{
            t_sum += quantum;
            q_name.enqueue(q_name.q[q_name.head]);
            q_time.enqueue(q_time.q[q_time.head]-quantum);

            if(q_name.head == MAX-1){
                q_name.head = 0;
                q_time.head = 0;
            }
            else{
                q_name.head += 1;
                q_time.head += 1;
            }
        }
    }
}

int main(){
    Queue q_name, q_time;
    int num, quantum;
    string name[MAX];
    int t;

    q_name.initialize();
    q_time.initialize();

    cin >> num >> quantum;
    for(int i=0; i<num; i++){
        cin >> name[i] >> t;
        q_name.enqueue(i);
        q_time.enqueue(t);
    }

    calc(q_name, name, q_time, quantum);

    return 0;
}

/*
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
*/


Measured memory_bytes: 7476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void xin(){
	#ifndef ONLINE_JUDGE 
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}



int main()
{
  	xin();
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    
    int x;
    cin>>x;
    if(x <= 599)
    	cout<<8<<endl;
    else if(x <= 799)
    	cout<<7<<endl;
    else if(x <= 999)
    	cout<<6<<endl;
    else if(x <= 1199)
    	cout<<5<<endl;
    else if(x <= 1399)
    	cout<<4<<endl;
    else if(x <= 1599)
    	cout<<3<<endl;
    else if(x <= 1799)
    	cout<<2<<endl;
    else if(x <= 1999)
    	cout<<1<<endl;
    
    return 0;
} 

Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>

int main(){
  
  long long x,y;

  scanf("%lld%lld",&x,&y);

  if(x==y){
    printf("0\n");
  }
  
  else if(x==0){
    if(y>0){
      printf("%lld\n",y);
    }
    else{
      printf("%lld\n",1-y);
    }
  }

  else if(y==0){
    if(x>=0){
      printf("%lld\n",x+1);
    }
    else{
      printf("%lld\n",-1*x);
    }
  }

  else if(y>=x){
    if(x>=0||y<=0){
      printf("%lld\n",y-x);
    }
    else{
      if(-1*x<=y){
	printf("%lld\n",y+x+1);
      }
      else{
	printf("%lld\n",-y-x+1);
      }
    }
  }
  
  else{
    if(y>=0||x<=0){
      printf("%lld\n",x-y+2);
    }
    else{
      if(x+y>=0){
	printf("%lld\n",x+y+1);
      }
      else{
	printf("%lld\n",-x-y+1);
      }
    }
  }
  return 0;
}
  

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

int main() {
    long long l, r; cin >> l >> r;
    long long ans = 1e18;
    if (r-l>2019) ans = 0;
    else {
        for (long long i = l; i <= r; i++) {
            for (long long j = i+1; j <= r; j++) {
                long long current = i*j%2019;
                ans = min(ans, current);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

vector<int> X[30];

int main(){
    string S, T;
    cin >> S >> T;

    ll NS, NT;
    NS = S.size();
    NT = T.size();

    REP(i,NS){
        int c = S[i] - 'a';
        X[c].push_back(i);
    }

    REP(i,NT){
        int c = T[i] - 'a';
        if(X[c].size() == 0){
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = 0;
    int pos = -1;
    REP(i,NT){
        int c = T[i] - 'a';
        auto iter = upper_bound(X[c].begin(), X[c].end(), pos);
        if(iter == X[c].end()){
            ans += NS;
            pos = X[c][0];
        }
        else{
            pos = *iter;
        }
    }

    ans += pos+1;
    cout << ans << endl;

    return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long ans = -1;
		
		Pair[] P = null;
		
		P = new Pair[N];
		for(int i=0;i<N;i++){
			P[i] = new Pair(X[i], Y[i], Z[i]);
		}
		int[] sig = new int[]{1, -1};
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					Array.Sort(P, (p, q) => ((q.X * sig[i] + q.Y * sig[j] + q.Z * sig[k]).CompareTo((p.X * sig[i] + p.Y * sig[j] + p.Z * sig[k]))));
					//Array.Reverse(P);
					ans = Math.Max(ans, calc(P));
				}
			}
		}
		
		
		
		Console.WriteLine(ans);
	}
	
	long calc(Pair[] P){
		long xx = 0, yy = 0, zz = 0;
		for(int i=0;i<M;i++){
			xx += P[i].X;
			yy += P[i].Y;
			zz += P[i].Z;
		}
		return Math.Abs(xx) + Math.Abs(yy) + Math.Abs(zz);
	}
	
	
	
	class Pair{
		public long X,Y,Z;
		public Pair(long x, long y, long z){
			X = x; Y = y; Z = z;
		}
	}
	int N, M;
	long[] X,Y,Z;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		X = new long[N];
		Y = new long[N];
		Z = new long[N];
		for(int i=0;i<N;i++){
			var dd = rla();
			X[i] = dd[0]; Y[i] = dd[1]; Z[i] = dd[2];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11220
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    while (cin>>a>>op>>b) {
        if(op == '?') break;
        switch (op) {
            case '+':
                cout << a+b<<endl;
                break;
            case '-':
                cout<< a-b<<endl;
                break;
            case '*':
                cout<< a*b<<endl;
                break;
            case '/':
                cout<<a/b<<endl;
                break;
        }
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define int long long
signed  main(){
  double N,K;
  char dif='A'-'a';
  str S1,S2,S3;
  cin>>N>>K;
  cout<<N/K<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll hell=pow(10,9)+7;
void solve(){
	ll n,sum=0,res=0;
	cin>>n;
	vector<ll> v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
		sum+=v[i];
	}
	sum%=hell;
	for(ll i=0;i<n;i++){
		sum=(sum-v[i])%hell;
		res+=(v[i]*sum)%hell;
		res%=hell;
	}
	if(res<0)
		res+=hell;
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
        solve();
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 4840
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

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

  i64 ans = 0;

  if (a + 2 >= b) {
    ans = 1 + k;
  } else {
    i64 rem = k - (a - 1);

    if (rem & 1) {
      i64 toMoney = rem / 2;
      i64 toBiscket = rem / 2;
      ans = (b * toBiscket) - (a * (toMoney - 1)) + 1;
    } else {
      i64 toMoney = rem / 2 - 1;
      i64 toBiscket = rem / 2;
      ans = (b * toBiscket) - (a * toMoney);
    }
  }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

vector<int> inttovec(int bit,int size)
{
   vector<int> res;
   rep(i,size)
   {
      res.push_back(bit&1);
      bit/=2;
   }
   return res;
}

int main()
{
   int n;
   cin >> n;
   vector<vector<pair<int,int>>> xy(n);
   rep(i,n)
   {
      int a;
      cin >> a;
      rep(j,a)
      {
         int foo,fooo;
         cin >> foo >> fooo;
         foo--;
         xy[i].push_back(make_pair(foo,fooo));
      }
   }
   int ans = 0;
   for(int i = 0;i<(1<<n);i++)
   {
      vector<int> bit = inttovec(i,n);
      bool mujun = false;
      int cnt = 0;
      rep(j,n)cnt += bit[j];
      rep(j,n)
      {
         if(bit[j]==0)continue;
         rep(k,xy[j].size())
         {
            if(bit[xy[j][k].first]!=xy[j][k].second)mujun = true;
         }
      }
      //cout<<cnt<<endl;
      if(mujun==false)ans = max(ans,cnt);
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
def T(n):
    return n * (n + 1) // 2

def rsq(L, R):
    return T(R) - T(L - 1)

n, k = [int(x) for x in input().split()]
ans = 0
for i in range(k, n + 2):
    ans += rsq(n - i + 1, n) - rsq(0, i - 1) + 1
    ans %= 10**9 + 7
print(ans)

Measured memory_bytes: 9192
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N;
    cin >> N;
    vi A(1 << N);
    rep(i, 1 << N)cin >> A[i];
    sort(A.rbegin(), A.rend());
    deque<int> dq;
    vector<bool> flag(1 << N);
    flag[0] = true;
    rep(i, N) {
        rep(j, 1 << N) if (flag[j])dq.push_back(A[j]);
        rep(j, 1 << N) {
            if (!flag[j] && dq.front()>A[j]) {
                flag[j] = true;
                dq.pop_front();
            }
        }
    }
    bool ans = count(all(flag), true) == 1 << N;
    cout << (ans ? "Yes" : "No") << endl;
}

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

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;

//#define DEBUG_MODE
//#define FILE_INPUT

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */

	int n;
	cin >> n;
	vector<int> a(n, 0);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int minus = 0;
	int zero = 0;
	int min = abs(a[0]);
	long long int sum = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] < 0) {
			++minus;
		}
		else if (a[i] == 0) {
			++zero;
		}
		a[i] = abs(a[i]);
		sum += a[i];
		if (a[i] < min) {
			min = a[i];
		}
	}
	if (zero == 0 && minus % 2 != 0) {
		sum -= 2 * min;
	}
	cout << sum << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

const int N = (int) 2e5 + 5;
const int mod = (int) 1e9 + 7;

int n, V, a[N], dpl[1 << 18], dpr[1 << 18], l[18][N], r[18][N], get_right[N];
vector<int> v;

inline void solve () {
        scanf ("%d%d", &n, &V);
        for (int i = 1; i <= n; i++) {
                scanf ("%d", &a[i]);
        }
        a[0] = a[1]; a[n + 1] = a[n];
        v.emplace_back (V >> 1);
        while (v.back () >> 1) {
                v.emplace_back (v.back () >> 1);
        }
        v.emplace_back (0);
        for (int i = 0; i < v.size (); i++) {
                r[i][n] = n;
                for (int j = n - 1; j >= 1; j--) {
                        if (a[j + 1] - a[j] > v[i]) {
                                r[i][j] = j;
                        } else {
                                r[i][j] = r[i][j + 1];
                        }
                }
                l[i][1] = 1;
                for (int j = 2; j <= n; j++) {
                        if (a[j] - a[j - 1] > v[i]) {
                                l[i][j] = j;
                        } else {
                                l[i][j] = l[i][j - 1];
                        }
                }
        }
        dpr[0] = n + 1;
        for (int i = 1; i < (1 << v.size ()); i++) {
                dpr[i] = n + 1;
                for (int j = 0; j < v.size (); j++) {
                        if ((i >> j) & 1) {
                                dpl[i] = max (dpl[i], r[j][dpl[i ^ (1 << j)] + 1]);
                                dpr[i] = min (dpr[i], l[j][dpr[i ^ (1 << j)] - 1]);
                        }
                }
        }
//        for (int i = 0; i < (1 << v.size ()); i++) {
//                printf ("%d %d %d\n", i, dpl[i], dpr[i]);
//        }
        memset (get_right, 63, sizeof get_right);
        for (int i = 0; i < (1 << v.size ()); i++) {
                int rev = ((1 << v.size ()) - 1) ^ i;
                get_right[dpl[i]] = min (get_right[dpl[i]], dpr[rev]);
        }
        for (int i = n; i >= 0; i--) {
                get_right[i] = min (get_right[i], get_right[i + 1]);
        }
//        for (int i = 0; i <= n + 1; i++) {
//                printf ("%d ", get_right[i]);
//        }
//        puts ("");
        int l = 0, r = 2;
        for (int i = 1; i <= n; i++) {
                r = max (r, i + 1);
                while (r <= n && a[r] - a[r - 1] <= V) {
                        r++;
                }
                if (a[i] - a[i - 1] > V) {
                        l = i - 1;
                }
//                printf ("%d %d\n", l, r);
                puts (get_right[l] <= r ? "Possible" : "Impossible");
        }
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 34176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=1000005;
int f[N],n,mn,sum,mx;
char s[N];

int solve(){
	n=strlen(s+1);
	per(i,n,1){
		f[i]=f[i+1];
		if(s[i]=='0') f[i]--;
		else f[i]++;
		f[i]=min(f[i],0);
	}
	mn=f[1];
	sum=mx=0;
	rep(i,1,n){
		if(s[i]=='0') sum--;
		else if(s[i]=='1') sum++;
		else{
			if(sum-1+f[i+1]<mn) sum++;
			else sum--;
		}
		mx=max(mx,sum);
	}
	return mx-mn;
}

int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	int ans=solve();
	reverse(s+1,s+n+1);
	ans=min(ans,solve());
	rep(i,1,n){
		if(s[i]=='1') s[i]='0';
		else if(s[i]=='0') s[i]='1';
	}
	ans=min(ans,solve());
	reverse(s+1,s+n+1);
	ans=min(ans,solve());
	cout<<ans<<endl;
	return 0;
}

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

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

    if(a > b) {
        cout << 0 << endl;
        return 0;
    } else if(a < b && n == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll l = b*(n-1) + a, m = a*(n-1) + b;
    if(l < m) swap(l, m);
    cout << (l - m + 1) << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define pii pair<int,int>
#define x first
#define y second

const int N=25;
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
int cur,d[N][N],ans,n,m;
char s[N][N];

void bfs(int x,int y){
	queue<pii> q;
	q.push(pii(x,y));
	while(!q.empty()){
		pii x=q.front();
		cur=max(cur,d[x.x][x.y]);
		q.pop();
		for(int i=0;i<4;i++){
			int nx=x.x+dx[i],ny=x.y+dy[i];
			if(nx<0||ny<0||nx>n||ny>m) continue;
			if(d[nx][ny]!=-1) continue;
			if(s[nx][ny]=='#') continue;
			d[nx][ny]=d[x.x][x.y]+1;
			q.push(pii(nx,ny));
		}
	}
}

signed main(){
	read(n);read(m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) if(s[i][j]=='.'){
			for(int i=1;i<=n;i++)
				for(int j=1;j<=m;j++)
					d[i][j]=-1;
			d[i][j]=cur=0;
			bfs(i,j);
			ans=max(ans,cur);
		}
	write(ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
    
    int n;
    int d[99];
    int ans=0;
    
    scanf("%d", &n);
    
    for(int i=1; i<=n; i++){
        
        scanf("%d", &d[i]);
        
    }
    
    for(int j=1; j<=n-1; j++){
        
        for(int k=j+1; k<=n; k++){
            
            ans += d[k] * d[j];
            
        }
        
    }
    
    printf("%d", ans);
    
    return 0;
    
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
	cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];

  ll ans = 0;
  rep(i,n){
    if(a[i] <= 0) continue;

    if(i > 0){
      int p = min(a[i-1],a[i]);;
      ans += p;
      a[i-1] -= p;
      a[i] -= p;
    }
    if(a[i] <= 0) continue;

    ans += a[i]/2;
    if(a[i] % 2 != 0) a[i] = 1;
    else a[i] = 0;
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  int A[N];
  for (int i=0 ; i<N ; i++) {
    scanf("%d", &A[i]);
  }
  int res = 0;
  for (int i=0 ; i<N ; i++) {
    for (int j=0 ; j<N ; j++) {
      if (i != j) res = max(abs(A[i] - A[j]), res);
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 128
loop do
  n,m = gets.split.map(&:to_i)
  break if n|m==0
  bor=[0]
  n.times do
    bor<<gets.to_i
  end
  pos = 1
  m.times do |i|
    num = gets.to_i
    pos +=num
    if pos >=n
      puts i+1
      (m-i-1).times {gets}
      break
    end
    pos +=bor[pos]
    if pos >=n
      puts i+1
      (m-i-1).times {gets}
      break
    end
  end
end

Measured memory_bytes: 2724
/**
 *    Author:  Oak_limy
 *    Created: 2020-09-19 21:24:30
**/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define up upper_bound
using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    char c = getchar(); int w = 1; int x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
inline ll readll() {
    char c = getchar(); ll w = 1; ll x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=(n-1)/i;
    }cout<<ans<<endl;
    return 0;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3720
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
	S[++top]=x;
}
int pop(){
	top--;
	return S[top+1];
}

int main(){
	int a,b;
	char s[100];
	top=0;
	
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}
		else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}
		else{
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n,d;cin >> n >> d;
    vector<vector<int>> x(n,vector<int>(d));
    rep(i,n)rep(j,d)cin >> x[i][j];
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int sum = 0;
            for(int k=0;k<d;k++){
                int diff = abs(x[i][k] - x[j][k]);
                sum += diff*diff;
            }
            for(int n=0;n<=sum;n++){
                if(n*n == sum)ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int N,A[100010];

int abst(int a,int b){
    if(a>b)return a-b;
    else return b-a;
}

int main(){
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>A[i];
    }
    int S=0;
    for(int i=0;i<=N;i++){
        S+=abst(A[i],A[i+1]);
    }
    for(int i=1;i<=N;i++){
        cout<<S-abst(A[i-1],A[i])-abst(A[i],A[i+1])+abst(A[i-1],A[i+1])<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
  A=500*i
  if A>x:
    break
  for j in range(b+1):
    B=100*j
    k = (x - A - B)/50
    if 0<=k<=c and k%1==0:
      ans+=1
print(ans)

Measured memory_bytes: 9132
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

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


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

    ll count=1;
    ll sizeS = S.size();
    string checkS="",s="",temp="";
    checkS.push_back(S[0]);
    // cout << checkS << endl;
    for(ll i=1;i<sizeS;){
        do{
            if(i == sizeS) break;
            s.push_back(S[i++]);
        }while(checkS == s);
        // cout << s << endl;
        count++;
        if(checkS == s) count--;
        checkS = s;
        s = temp;
    }

    cout << count << endl;

}




Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	long N,i,sum=0;
	string str;
	long ans=0;
	cin>>N;
	str=to_string(N);
	for(i=0;i<str.size();i++){
		sum+=str.at(i)-48;
	}
	if(N%sum==0){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
Array1 = int(input())
Array2 = input().split()
 
Number = 0
times = 0
 
while True:
    if int(Array2[Number ]) % 2 == 0:
        Array2[Number] = int(Array2[Number]) // 2
        Number += 1
        if Number == Array1:
            Number = 0
            times += 1
    else:
        print(times)
        break

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n), z(n);
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] == 0) {
            z[i] = (i + 1 < n ? z[i + 1] : 0) + 1;
        }
    }
    for (int i = 0; i < n; i++) {
        long long last = i, sum = 0, x = 0;
        for (int j = i; j < n; j++) {
            if (z[j]) {
                j += z[j] - 1;
            }
            if ((sum + a[j]) == (x ^ a[j])) {
                x ^= a[j];
                sum += a[j];
                last = j;
            } else {
                break;
            }
        }
        ans += last - i + 1;
    }
    cout << ans << endl;

}



Measured memory_bytes: 1792
A,B = list(map(int,input().split()))
l_n = list(input().split())
sw = 0
for i in range(A,A*10+1):
    sw=0
    C = str(i)
    for j in C:
        if j in l_n:
            sw=1
            break
    if sw == 0:
        print(i)
        exit()

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

int main() {
  ll n;
  cin >> n;
  vector<int> v(n);
  rep(i,n){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  bool ok = true;
  for (int i=0;i<n-1;i++){
    if (v.at(i) == v.at(i+1)){
      ok = false;
      break;
    }
  }
  if (ok){
    cout <<"YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod


using ld = long double;
using Point = complex<ld>;
using Set = vector<Point>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

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

    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0; i < n; ++i)  cin >> s[i];
    sort(s.begin(), s.end());
    string res = "";
    for(int i = 0; i < n; ++i)  res += s[i];
    cout << res << endl;
}

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

namespace debug
{

    
    //2つを関連付けてソートする例
    class ProgramA
    { 

        static void Main(string[] args)
        {
            string[] z = Console.ReadLine().Split(' ');
            long a = long.Parse(z[0]);
            long b = long.Parse(z[1]);
            long n = long.Parse(z[2]);

            long temp = Math.Min(b - 1, n)/b;

            Console.WriteLine(a * Math.Min(b - 1, n) / b - a * temp);






        }

        
    }



}


Measured memory_bytes: 17896