akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    int s = 0;
    REP(j, N) s = s^a[j];
    REP(i, N) {
        int ans = s^a[i];
        cout << ans << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4012
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int i=0,j=0;

			int n = sc.nextInt();
			if(n == 0) break;
			int s = sc.nextInt();
			int g = sc.nextInt();
			int d = sc.nextInt();

			char[][] map = new char[d][n-1];
			for(i=0;i<d;i++){
				map[i] = sc.next().toCharArray();
			}

			if(reachable(map,s,g)){
				System.out.println(0);
				continue;
			}

			boolean flg = true;
			for(i=0;flg && i<d;i++){
				for(j=0;flg && j<n-1;j++){
					if(map[i][j] == '0' && (j-1<0 || map[i][j-1] == '0') && (j+1>=n-1 || map[i][j+1] == '0')){
						map[i][j] = '1';
						if(reachable(map,s,g)) flg = false;
						map[i][j] = '0';
					}
				}
			}

			if(!flg) System.out.println(i + " " + j);
			else System.out.println(1);
		}
	}

	private static boolean reachable(char[][] map,int s,int g){
		int i = 0, j = s - 1;

		while(i < map.length){
			if(j < map[0].length && map[i][j] == '1')
				j++;
			else if(j - 1 >= 0 && map[i][j-1] == '1')
				j--;

			i++;
		}

		return j == g - 1;
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
  int n;
  cin>>n;
  vector<double> x(n);
  vector<string> u(n);
  rep(i,0,n)cin>>x[i]>>u[i];
  double ans=0;
  rep(i,0,n){
    if(u[i]=="JPY")ans+=x[i];
    else ans+=x[i]*380000;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final PriorityQueue<Integer> goods = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            goods.add(scanner.nextInt());
        }

        for (int i = 0; i < m; i++) {
            final int poll = goods.poll();
            goods.add(poll / 2);
        }

        long answer = 0;
        for (final Integer good : goods) {
            answer += good;
        }

        System.out.println(answer);
    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 45780
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  long long Q,H,S,D;
  long long N;
  scanf("%lld%lld%lld%lld%lld", &Q, &H, &S, &D, &N);
  S=min(S,min(Q*4, H*2));
  long long ans = min(N*S, D* (N/2) + (N%2)*S);
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  char c;
  cin >> c;

  if((c == 'a') || ( c == 'e') || (c == 'i') || (c == 'o') || (c == 'u')){
    cout << "vowel" << endl;
  } else{
    cout << "consonant" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>()> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const lint di[]{0, -1, 0, 1, -1, -1, 1, 1};
const lint dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n, m;
    cin >> n >> m;
    vector<pair<lint, lint>> p(n);
    for (int i=0; i<n; ++i){
        cin >> p[i].fst >> p[i].snd;
    }
    sort(ALL(p));
    lint ans = 0;
    lint count = 0;
    for (int i=0; i<n; ++i){
        if(count + p[i].snd < m){
            ans += p[i].fst * p[i].snd;
            count += p[i].snd;
        }
        else {
            lint rest = m - count;
            ans += rest * p[i].fst;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long int Int;

int main(void)
{
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;

    const int dx = tx - sx;
    const int dy = ty - sy;

    cout<<string(dy,'U')<<string(dx,'R');
    cout<<string(dy,'D')<<string(dx,'L');
    cout<<"L"<<string(dy+1,'U')<<string(dx+1,'R')<<"D";
    cout<<"R"<<string(dy+1,'D')<<string(dx+1,'L')<<"U";
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int month = sc.nextInt();
      int date = sc.nextInt();
      if (date >= month) {
      	System.out.println(month);        
      } else {
      	System.out.println(month - 1);      
      }
    }
}


Measured memory_bytes: 23124
#include <iostream> // cout, endl, cin
#include <string>   // string, to_string, stoi
#include <vector>   // vector
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
#define MAX 500000
#define SENTINEL 2000000000 //番兵

vector<int> L(MAX / 2 + 2), R(MAX / 2 + 2);
int cnt = 0;

void merge(vector<int> &A, int n, int left, int mid, int right)
{
    int n1 = mid - left;  //midから左の個数
    int n2 = right - mid; //midから右の個数
    rep(i, n1) L[i] = A[left + i];
    rep(i, n2) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        cnt++;
        if (L[i] <= R[j])
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(vector<int> &A, int n, int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main()
{
    vector<int> A(MAX);
    int n, i;
    cin >> n;
    rep(i, n) cin >> A[i];

    mergeSort(A, n, 0, n);

    rep(i, n)
    {
        if (i)
            cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6624
#include <stdio.h>


//#define DEBUG

int main(void)
{
    FILE *fpin;
#ifdef DEBUG
    fpin=fopen("input.txt","r");
#else
    fpin=stdin;
#endif

    while(feof(fpin)==0){
        int a[4],b[4];
        fscanf(fpin,"%d %d %d %d\n",
                a+0,a+1,a+2,a+3);
        fscanf(fpin,"%d %d %d %d\n",
                b+0,b+1,b+2,b+3);
       
        int n_hit=0, n_blow=0;
        int i,j;
        for(i=0;i<4;i++){
            //search hit
            n_hit=(a[i]==b[i])?n_hit+1:n_hit;
            //search blow
            for(j=0;j<4;j++){
                if(i==j){ continue; } //exclude case of hit
                n_blow=(a[i]==b[j])?n_blow+1:n_blow;
            }
        }

        printf("%d %d\n",n_hit,n_blow);


    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

bool valid_yymm(string S) {
   int mm = atoi( S.substr(2).c_str() );
   return 1 <= mm && mm <= 12;
}

bool valid_mmyy(string S) {
   int mm = atoi( S.substr(0, 2).c_str() );
   return 1 <= mm && mm <= 12;
}

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

   bool yymm = valid_yymm(S);
   bool mmyy = valid_mmyy(S);
   if (yymm && mmyy) {
      cout << "AMBIGUOUS\n";
   }
   else if (yymm) {
      cout << "YYMM\n";
   }
   else if (mmyy) {
      cout << "MMYY\n";
   }
   else {
      cout << "NA\n";
   }

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

int main() {
    string s; cin >> s;
    cout << s << (s.back() == 's' ? "es" : "s") << endl;
}



Measured memory_bytes: 3640
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF=1e18;
#define PI 3.14159265358979323846

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

    int N;
    cin >> N;
    
    vector<ll> emp(N);
    map<int, ll> soDic;

    for (int i=1; i<N; i++) {
        int bossIndex;
        cin >> bossIndex;
        bossIndex -= 1;
        if (soDic.count(bossIndex) >= 1) {
            soDic[bossIndex] = soDic[bossIndex] + 1;
        } else {
            soDic[bossIndex] = 1;
        }
    }

    for (int i=0; i<N; i++) {
        if (soDic.count(i) >= 1) {
            cout << soDic[i] << '\n';
        } else {
            cout << 0 << '\n';
        }
    }


    return 0;
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,a,b;
  while(cin >> x >> a >> b){
    TSTART();
    string ans;
    if(a >= b)ans = "delicious";
    else if(a+x < b)ans = "dangerous";
    else ans = "safe";
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



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

int main() {
  string S;
  cin >> S;
  int N = S.size(), P = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'p') P++;
  }
  cout << N / 2 - P << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int p[n], q[n];
    REP(i,n){
        cin >> p[i];
        q[i] = p[i];
    }
    int ans1 = 0, ans2 = 0;
    REP(i,n){
        if(p[i] == i + 1){
            int t = p[i];
            p[i] = p[i + 1];
            p[i + 1] = t;
            ans1++;
        }
    }
    for(int i = n - 1; i >= 0; i--){
        if(q[i] == i + 1){
            int t = q[i];
            q[i] = q[i - 1];
            q[i - 1] = t;
            ans2++;
        }
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

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

int main()
{
  int n;
  scanf("%d",&n);
  static int a[100000],b[100000];
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }
  for(int j=0;j<n;j++){
    scanf("%d",b+j);
  }
  sort(a,a+n);
  sort(b,b+n);
  long long ans=1ll;
  const long long mod=1000000007ll;
  int K=0;
  for(int i=0,j=0;i<n||j<n;){
    if(j==n||(i<n&&a[i]<b[j])){
      if(K<0){
	ans*=-K;
	ans%=mod;
      }
      K++;
      i++;
    }
    else{
      if(K>0){
	ans*=K;
	ans%=mod;
      }
      K--;
      j++;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
  ll N; cin>>N;
  set<ll> S;
  rep(i,N) {
    ll x; cin>>x;
    S.insert(x);
  }
  if(S.size()==N) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

int main(void)
{
	int N,sum;
	
	cin >> N;

	if (N != 1 && N % 2 == 0) {
		sum = (1 + N)*N / 2;
		cout << sum << endl;
	}
	else if (N != 1 && N % 2 != 0) {
		sum = N * (N - 1) / 2 + N;
		cout << sum << endl;
	}
	else {
		cout << 1 << endl;
	}
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nm = br.readLine().split(" ");
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);
        int[] ans = new int[n+1];
        String[] road;
        int city1, city2;
        
        for (int i = 0; i < m; i++) {
            road = br.readLine().split(" ");
            city1 = Integer.parseInt(road[0]);
            city2 = Integer.parseInt(road[1]);
            ans[city1]++;
            ans[city2]++;
        }
        
        for (int i = 1; i <= n; i++) {
            System.out.println(ans[i]);
        }
    }
}


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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,m;

    cin >> n >> m;
    
    vector<ll> a1(n);
    vector<ll> a2;
    vector<vector<ll>> bc(m,vector<ll>(2));
    
    
    rep(i,n) cin >> a1[i];
    rep(i,m) cin >> bc[i][1] >> bc[i][0];
    
    sort(bc.begin(), bc.end());
    reverse(bc.begin(), bc.end());
    
    bool isFull = false;
    rep(i,m){
        rep(j,bc[i][1]){
            a2.push_back(bc[i][0]);
            if((int)a2.size() >= n){
                isFull = true;
                break;
            }
        }
        if(isFull) break;
    }
    
    
    sort(a1.begin(), a1.end());
    sort(a2.begin(), a2.end());
    reverse(a2.begin(), a2.end());
    
    for(int i = 0; i < min((int)a2.size(),n); i++){
        a1[i] = max(a1[i],a2[i]);
    }
    
    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += a1[i];
    }
    cout << sum << endl;
    
}


Measured memory_bytes: 7672
#include <iostream>
#include <string>
#include <malloc.h>


using namespace std;

struct Node {
	int key;
	Node *pa, *le, *ri;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node*)malloc(sizeof(Node));

	z->key = k;
	z->le = NIL;
	z->ri = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->le;
		}
		else {
			x = x->ri;
		}
	}

	z->pa = y;

	if (y == NIL) {
		root = z;
	}
	else if(z->key < y->key){
		y->le = z;
	}
	else {
		y->ri = z;
	}
}

void pre(Node *a) {
	if (a == NIL) {
		return;
	}

	int number = a->key;
	
	cout << " " << number;
	pre(a->le);
	pre(a->ri);
}

void ino(Node *a) {
	if (a == NIL) {
		return;
	}

	int number = a->key;

	ino(a->le);
	cout << " " << number;
	ino(a->ri);
}

void find(int k) {
	Node *x = root;

	while (x != NIL) {
		if (k == x->key) {
			cout << "yes" << endl;
			return;
		}

		if (k < x->key) {
			x = x->le;
			continue;
		}
		else if (k > x->key) {
			x = x->ri;
			continue;
		}
	}

	cout << "no" << endl;
	return;
}


int main()
{
	int n, num;
	string order;

	cin >> n;

	for (int i = 0; i < n; ++i) {
		cin >> order;
		if (order == "insert") {
			cin >> num;
			insert(num);
		}
		else if (order == "print") {
			ino(root);
			cout << endl;
			pre(root);
			cout << endl;
		}
		else if (order == "find") {
			cin >> num;
			find(num);
		}
	}

	return 0;
}



Measured memory_bytes: 21912
solve :: Int -> Int -> [(Int, Int, Int)]
solve k s = do x <- [0..k]
               y <- [0..k]
               let z = s-x-y
               if 0 <= z && z <= k then return (x, y, z) else []

main = do
  [k, s] <- map read . words <$> getLine
  putStrLn $ show $ length $ solve k s


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ;
const int N = 2e5 + 100;
const int mod = 1e9 + 7;
int binpow(int a, int b) {
    a %= mod;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

std::vector <int> v[N];
bool visit[N];
int dp[N];
void dfs(int src){
    visit[src] = 1;
    for(auto x : v[src]){
        if(!visit[x]){
          dfs(x);
        }
        dp[src] = max(dp[src] , 1 + dp[x]);
    } 
    return ;
}

int32_t main(){
 L_T_S_K;
    int n , m;
    cin >> n >> m;
    for(int i = 0 ; i < m ;i++){
        int x , y;
        cin >> x >> y;
        v[x].push_back(y);
    }
    int maxo = 0;
    for(int i = 1 ; i <= n ;i++){
        if(!visit[i]){
            dfs(i);
        }
    }
    for(int i = 1 ; i <= n ;i++){
        maxo = max(maxo , dp[i]);
    }
    cout << maxo << "\n";
 return 0;
}

Measured memory_bytes: 11008
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int h,w;

int main(){
    cin >> h >> w;
    vector<vector<char>> c(h+2,vector<char>(w+2,'#'));
    REP(i,h){
        REP(j,w){
            cin >> c[i+1][j+1];
        }
    }
    REP(i,h+2){
        REP(j,w+2){
            cout << c[i][j];
        }
        put("");
    }
    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())

# s = [list(map(str, input().split())) for _ in range(h)]
s = [input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        canPaint = 0
        if s[i][j] == '#':
            if i >= 1 and s[i - 1][j] == '#': # upper middle
                canPaint = 1
            if j >= 1 and s[i][j - 1] == '#': # middle left
                canPaint = 1
            if j <= w - 2 and s[i][j + 1] == '#': # middle right
                canPaint = 1
            if i <= h - 2 and s[i + 1][j] == '#': # lower middle
                canPaint = 1
            if not canPaint:
                print('No')
                quit()

print('Yes')


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }

  // for prime mod
  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;
  }
};

int main()
{
  int n, k;
  cin >> n >> k;
  if(k == 1) {
    cout << 0 << endl;
    return 0;
  }
  n -= k;
  cout << n << endl;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
const int MOD = 998244353;
const int MAX = 200000;

long long inverse[MAX];
long long factorial[MAX];
long long factorial_inverse[MAX];
long long pow_M_minus[MAX];

void calc(int n) {
	inverse[1] = 1;
	factorial[0] = factorial[1] = 1;
	factorial_inverse[0] = factorial_inverse[1] = 1;
	for (int i = 2; i <= n; i++) {
		inverse[i] = MOD - inverse[MOD%i] * (MOD/i) % MOD;
		factorial[i] = i * factorial[i-1] % MOD;
		factorial_inverse[i] = inverse[i] * factorial_inverse[i-1] % MOD;
	}
}

long long comb(int n, int k) {
	return factorial[n] * (factorial_inverse[k] * factorial_inverse[n-k] % MOD) % MOD;
}


int main() {
	long long n, m, k;
	cin >> n >> m >> k;
	calc(n-1);
	pow_M_minus[0] = 1;
	for (int i = 1; i < n; i++) pow_M_minus[i] = pow_M_minus[i-1] * (m-1) % MOD;
	long long ans = 0;
	for (int i = 0; i <= k; i++) {
		ans += m * pow_M_minus[n-1-i] % MOD * comb(n-1, i) % MOD;
		ans %= MOD;
	}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
        ArrayList<ArrayList<Integer>> len = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            graph.add(new ArrayList<>());
            len.add(new ArrayList<>());
        }
        for (int i = 0; i < N-1; i++) {
            int u = ni()-1;
            int v = ni()-1;
            int w = ni();
            graph.get(u).add(v);
            graph.get(v).add(u);
            len.get(u).add(w);
            len.get(v).add(w);
        }
        ArrayDeque<Integer> que = new ArrayDeque<>();
        long[] distance = new long[N];
        Arrays.fill(distance, Long.MAX_VALUE);
        distance[0] = 0;
        que.add(0);
        while(que.size()>0){
            int u = que.poll();
            for (int i = 0; i < graph.get(u).size(); i++) {
                int to = graph.get(u).get(i);
                int ln =   len.get(u).get(i);
                if(distance[to] > distance[u] + ln){
                    distance[to] = distance[u] + ln;
                    que.add(to);
                }
            }
        }
        for (int i = 0; i < distance.length; i++) {
            if(distance[i] % 2 == 0) out.println(0);
            else out.println(1);
        }
    }

    

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 80304
#include <stdio.h>

int A, B, C, X, cnt;

void f() {
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                int tmp = i * 500 + j * 100 + k * 50;
                if (tmp == X) cnt++;
            }
        }
    }
}

int main() {
    scanf("%d %d %d %d", &A, &B, &C, &X);
    f();
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<complex>
#include<cassert>
#include<iostream>
#include<algorithm>
using namespace std;

const double eps = 1e-8;
const double inf = 1e12;

typedef complex<double> P; //Point

namespace std {
  bool operator<(const P &a, const P &b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

struct L {  //Line
  P s,t;
L(const P a,const P b) : s(a), t(b) {;}
};

double cross(const P &a, const P &b) {
  return imag(conj(a)*b);
}

double dot(const P &a, const P &b) {
  return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if( cross(b, c) > 0 ) return +1; // counter clockwise
  if( cross(b, c) < 0 ) return -1; // clockwise
  if( dot(b, c) < 0 ) return +2;   // c--a--b on line
  if( norm(b) < norm(c) ) return -2; // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
    return ccw(s.s,s.t,t.s) * ccw(s.s,s.t,t.t) <= 0 &&
        ccw(t.s,t.t,s.s) * ccw(t.s,t.t,s.t) <= 0;
}

int main() {
    int n,x,y;
    cin>>n;
    while(n--) {
        P tri[3];
        for(int i=0; i<3; ++i) {
            cin>>x>>y;
            tri[i] = P(x,y);
        }
        cin>>x>>y;
        P f(x,y);
        cin>>x>>y;
        P m(x,y);
        L fm(f,m);
        vector<L> tril;
        for(int i=0; i<3; ++i) tril.push_back(L(tri[i],tri[(i+1)%3]));

        int cc = 0;
        for(int i=0; i<3; ++i)
            if(intersectSS(fm, tril[i])) cc++;

        if(cc%2) cout<<"OK"<<endl;
        else cout<<"NG"<<endl;
    }
}

Measured memory_bytes: 932
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    p = [int(i) for i in input().split()]

    s = sorted(p)

    print('YES' if sum(i != j for i, j in zip(p, s)) < 3 else 'NO')


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

void solve() {
    int N, M;
    cin >> N >> M;
    int a[N];
    memset(a, -1, sizeof(a));
    bool ans = true;
    for (int i = 0; i < M; ++i) {
        int s, c;
        cin >> s >> c;
        if (0 <= a[s-1] && a[s-1] != c) {
            ans = false;
            break;
        } else if (1 < N && s == 1 && c == 0) {
            ans = false;
            break;
        } else {
            a[s - 1] = c;
        }
    }
    if (!ans) {
        cout << -1 << endl;
        return;
    }
    if (N == 1 && a[0] == -1) a[0] = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] == -1) {
            cout << (i == 0 ? 1 : 0);
        } else cout << a[i];
    }
    cout << endl;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int q = sc.nextInt();
    
    int ans[] = new int[n];
    for(int i = 0; i < n; i++){
      ans[i] = k - q;
    }
    
    for(int i = 0; i < q; i++){
      int a = sc.nextInt();
      ans[a-1]++;
    }
    
    for(int i = 0; i < n; i++){
      if(ans[i] > 0){
        System.out.println("Yes");
      }
      else{
        System.out.println("No");        
      }
    }
  }
}

Measured memory_bytes: 73844
/** @Date    : 2017-07-09 09:34:35
  * @FileName: A.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoungEarlf@gmail.com)
  * @Link    : https://github.com/
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;


int check(string a)
{
	int x = a.length();
	for(int i = 0; i < x / 2; i++)
		if(a[i] != a[x - i - 1])
			return 0;
	if(x % 2)
		return (a[x / 2] == a[0]);
	return 1;
}
int main()
{
	string s;
	while(cin >> s)
    {
    	int len = s.length();
    	int mi = INF;
    	for(int i = 0; i < 26; i++)
    	{
    		string t = s;
    		int cnt = 0;
    		while(!check(t))
    		{
    			string tmp="";
    			for(int j = 0; j < t.length() - 1; j++)
    			{
    				if(t[j] == ('a' + i))
    				{
    					tmp += t[j];
    					continue;
    				}
    				if(('a' + i) == t[j + 1])
    					tmp += t[j + 1];
    				else tmp += t[j];
    				//cout << tmp << endl;
    			}
    			//cout << tmp << "~" << cnt + 1 << endl;
    			t = tmp;
    			cnt++;
    		}
    		mi = min(mi, cnt);
    	}
    	printf("%d\n", mi);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main(){
    int n,r;
    cin>>n>>r;
    cout<<r+100*max(10-n,0);
    cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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

	char bef=s[0];
	long long cnt=0;
	int tmpcnt=0;
	vector<int> tmpcntvec;
	for(int i=0;i<s.size();i++)
	{
		if(bef==s[i])
		{
			tmpcnt++;
		}
		else
		{
			cnt+=(tmpcnt/2);
			tmpcntvec.push_back(tmpcnt);
			tmpcnt=1;
		}
		bef=s[i];
	}
	cnt+=(tmpcnt/2);
	tmpcntvec.push_back(tmpcnt);

	long long ans=cnt*k;

	//for(int i=0;i<tmpcntvec.size();i++)
	//	cerr << tmpcntvec[i] << endl;
	if(s[0]==s[s.size()-1])
	{
		if(tmpcntvec.size()==1)
		{
			if(tmpcntvec[0]%2==0)	
			{
			}
			else
			{
				ans+=k/2;
			}
		}
		else if(tmpcntvec[0]%2==1 and tmpcntvec[tmpcntvec.size()-1]%2==1)
		{
			ans+=(k-1);
		}
	}


	cout << ans << endl;





}


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

int main(){
    int n;
    cin >> n;
    vector<int> ans(n);
    for(int x = 1; x*x<= n;x++){
        for(int y = 1; y*y<=n;y++){
            for(int z = 1; z*z<= n;z++){
                int s = x*x+y*y+z*z+x*y+y*z+z*x;
                if(s <= n)ans.at(s-1)++;
            }
        }
    }
    rep(i,n) cout << ans.at(i) << endl;
}

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

using namespace std;

int main() {
    string str;
    cin >> str;
    int len = str.length();

    int nums[len];
    for(int i = 0; i < len; i++) {
        nums[i] = str[i] - '0';
    }

    int current = 0;
    int coeff = 1;
    map<int, int> mem;
    mem[0] = 1;
    for(int i = len - 1; i >= 0; i--) {
        current = (current + coeff * nums[i]) % 2019;
        mem[current]++;
        coeff *= 10;
        coeff %= 2019;
    }

    long long counter = 0;
    for(int i = 0; i < 2019; i++) {
        counter += mem[i] * (mem[i] - 1) / 2;
    }

    cout << counter << endl;
}

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

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		String s1 = sc.next();
		String s2 = sc.next();
		
		int[][] dp = new int[s1.length()+1][s2.length()+1];
		
		for(int i = 0; i <= s1.length(); i++)
			dp[i][0] = i;
		for(int j = 0; j <= s2.length(); j++)
			dp[0][j] = j;
		
		for(int i = 1; i <= s1.length(); i++){
			for(int j = 1; j <= s2.length(); j++){
				if(s1.charAt(i-1) == s2.charAt(j-1))
					dp[i][j] = dp[i-1][j-1];
				else
					dp[i][j] = dp[i-1][j-1] + 1;
				dp[i][j] = Math.min(dp[i][j], dp[i-1][j] + 1);
				dp[i][j] = Math.min(dp[i][j], dp[i][j-1] + 1);
			}
		}
		
		System.out.println(dp[s1.length()][s2.length()]);
		
	}//end main
}//end Main

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



Measured memory_bytes: 29296
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a * 100 + b * 10 + c) % 4 == 0)
		YES();
	else
		NO();

	return 0;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Run(args));
        }
        private static int Run(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var RH = H.Reverse();

            var befhi = RH.First();
            var befret = 0;
            var ret = 0;
            foreach (var hi in RH.Skip(1))
            {
                if (hi >= befhi)
                {
                    befret++;
                }
                else
                {
                    if (ret < befret)
                    {
                        ret = befret;
                    }
                    befret = 0;
                }
                befhi = hi;
            }
            if (ret < befret)
            {
                ret = befret;
            }

            return ret;
        }
    }
}


Measured memory_bytes: 29148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;
 
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator
 
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 

int32_t main()
{
    fast;
    int n,d;cin>>n>>d;
    vector<vi> v;
    for(int i=0;i<n;i++)
    {
        vector<int> tmp;
        for(int j=0;j<d;j++)
        {
            int x;cin>>x;
            tmp.pb(x);
        }
        v.pb(tmp);
    }

    int cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int dis=0;
            for(int k=0;k<d;k++)
                dis+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);

            int val=sqrt(dis);
            float chk=sqrt(dis);
            if(val==chk)
                cnt++;
        }
    }
    cout<<cnt;

}

Measured memory_bytes: 256