akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int A[3][3], b[100];
  int N, i, j, k;

  scanf("%d %d %d\n", &A[0][0], &A[0][1], &A[0][2]);
  scanf("%d %d %d\n", &A[1][0], &A[1][1], &A[1][2]);
  scanf("%d %d %d\n", &A[2][0], &A[2][1], &A[2][2]);
  scanf("%d", &N);
  for(i=0; i<N; i++){
    scanf("%d", &b[i]);
    for(j=0; j<3; j++){
      for(k=0; k<3; k++){
        if(b[i] == A[j][k]) A[j][k] = 0;
      }
    }
  }

  if(A[0][0] + A[0][1] + A[0][2] == 0) printf("Yes");
  else if(A[1][0] + A[1][1] + A[1][2] == 0) printf("Yes");
  else if(A[2][0] + A[2][1] + A[2][2] == 0) printf("Yes");
  else if(A[0][0] + A[1][0] + A[2][0] == 0) printf("Yes");
  else if(A[0][1] + A[1][1] + A[2][1] == 0) printf("Yes");
  else if(A[0][2] + A[1][2] + A[2][2] == 0) printf("Yes");
  else if(A[0][0] + A[1][1] + A[2][2] == 0) printf("Yes");
  else if(A[0][2] + A[1][1] + A[2][0] == 0) printf("Yes");
  else printf("No");

  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import collections

H, W = map(int, input().split())
a_frq_dict = collections.defaultdict(int)
for _ in range(H):
    for a in input():
        a_frq_dict[a] += 1


n = H%2 + W%2
frq1, frq2, frq4 = 0,0,0

if n == 2:
    frq1 = 1
    frq2 = (H-1)//2 + (W-1)//2
    frq4 = ((H*W) - (frq2*2 + frq1)) // 4

elif n == 1:
    if H%2:
        frq2 = W//2
    else:
        frq2 = H//2

    frq4 = ((H*W) - frq2*2) // 4

else:
    frq4 = (H * W) // 4


# print(frq1, frq2, frq4)


for frq in a_frq_dict.values():
    n = min(frq4, frq//4)
    frq4 -= n
    frq -= n*4

    n = min(frq2, frq//2)
    frq2 -= n
    frq -= n*2

    n = min(frq1, frq)
    frq1 -= n
    frq -= n

    # print(frq)

    if frq:
        print('No')
        exit()


# print(frq1, frq2, frq4)

if all(map(lambda x: x == 0, [frq1, frq2, frq4])):
    print('Yes')
else:
    print('No')






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

using namespace std;
typedef long long ll;

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

    vector<vector<string>> dp(n + 1);
    dp[0].push_back("");
    for (int length = 1; length <= n; length++) {
        vector<vector<string>> after(n + 1);
        for (int prevKind = 0; prevKind < length; prevKind++) {
            for (auto x:dp[prevKind]) {
                for (int nextLetter = 0; nextLetter <= prevKind; nextLetter++) {
                    after[max(prevKind, nextLetter + 1)].push_back(x + (char) ('a' + nextLetter));
                }
            }
        }
        dp = after;
    }

    vector<string> rets;
    for (int i = 0; i <= n; i++) {
        for (auto x:dp[i]) {
            rets.push_back(x);
        }
    }
    sort(rets.begin(), rets.end());

    for (auto ret:rets)cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 10832
#include<stdio.h>

int main(void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if((y-r)>=0&&(y+r)<=H&&(x-r)>=0&&(x+r)<=W)
    puts("Yes");
  else
    puts("No");
  return(0);
}

Measured memory_bytes: 584
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList();
		int n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			int temp = scan.nextInt();
			list.add(temp);
		}
		if (list.get(0) == 2) {
			System.out.println(1);
			return;
		}
		int index = 1;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			index = list.get(index - 1);
			ans++;
			if (list.get(index - 1) == 2) {
				System.out.println(++ans);
				return;
			}
		}
		System.out.println(-1);

	}

}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int a = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(n * n - a);
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

const int N = 100000;

char str[N];

bool isLowerLetter(const char &ch) {
	return ch >= 'a' && ch <= 'z';
}

int main() {
	while (cin.getline(str, N, '\n')) {
		for (int i=0; i<strlen(str); ++i) {
			if (isLowerLetter(str[i])) str[i] = str[i] - 'a' + 'A';
		}
		cout<<str<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int a = Integer.parseInt(in.next());
		int b = Integer.parseInt(in.next());
		int c = a*b;
		in.close();
		
		if(c%2 == 0)
			System.out.println("Even");
		else
			System.out.println("Odd");
	}
}


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

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		String[] W = new String[N];
		for (int i = 0; i < N; ++i) {
			W[i] = sc.next();
		}
		boolean ans = true;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < i; ++j) {
				ans &= !W[i].equals(W[j]);
			}
			if (i > 0)
				ans &= W[i].charAt(0) == W[i - 1].charAt(W[i - 1].length() - 1);
		}
		System.out.println(ans ? "Yes" : "No");
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			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();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 21076
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const long long M=998244353;
long long f[3005][3005];
int a,b,c,d;

int main () {
	
	scanf ("%d%d%d%d",&a,&b,&c,&d);
	for (int i=a;i<=c;i++) {
		for (int j=b;j<=d;j++) {
			if (i==a&&j==b) {f[i][j]=1; continue;}
			f[i][j]=(f[i-1][j]*j+f[i][j-1]*i-f[i-1][j-1]*(i-1)*(j-1))%M;
			if (f[i][j]<0) f[i][j]+=M;
		}
	}
	printf ("%lld\n",f[c][d]);
	
	return 0;
}



Measured memory_bytes: 72160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

int main(void){ 
    int n;
    cin >> n;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string s;
    cin >> s;
    int flag = 0;
    if(a < b && c < d){
        // a から c, b から dの範囲をみる
        for(int i=a-1; i<c-1; i++){
            if(s[i] == '#' && s[i+1] == '#'){
                flag = 1;
            }
        }
        for(int i=b-1; i<d-1; i++){
            if(s[i] == '#' && s[i+1] == '#'){
                flag = 1;
            }
        }
        if(flag == 1) cout << "No";
        else cout << "Yes";
    }
    else if(a < b && d < c && b < d){
        // 少なくともこれは必要
        for(int i=a-1; i<c-1; i++){
            if(s[i] == '#' && s[i+1] == '#'){
                flag = 1;
            }
        }
        for(int i=b-1; i<d-1; i++){
            if(s[i] == '#' && s[i+1] == '#'){
                flag = 1;
            }
        }
        // さらにb から d まで途中に3つあればいい
        int hantei = 1;
        for(int i=b-2; i<d-1; i++){
            if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
                hantei = 0;
            }
        }
        if(hantei == 1 || flag == 1) cout << "No";
        else cout << "Yes";
    }
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int count_substr(const string& word,const string& q) {
	int count = 0;
	for (string::size_type pos = 0; (pos = word.find(q, pos)) != string::npos; pos += q.size()) {
		++count;
	}
	return count;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int H=in(),W=in();
	int N=in();
	auto A=vecin(N);
	
	vector<vector<int>> M(H,vector<int>(W,-1));
	int X=0,Y=0,C=0;

	while(true){
		M[Y][X] = C+1;
		if(!(--A[C])) C++;
		if(C==N) break;

		if(X<W-1 && M[Y][X+1]==-1) X++;
		else if(Y<H-1 && M[Y+1][X]==-1) Y++;
		else if(X>0 && M[Y][X-1]==-1) X--;
		else if(Y>0 && M[Y-1][X]==-1) Y--;
	}

	for(auto& x:M){
		PRINTALL(x);
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll d;
    cin >> d;
    Vi c(26);
    matrix s(d,Vi(26));
    rp(i,26) cin >> c[i];
    rp(i,d){
        rp(j,26) cin >> s[i][j];
    }
    Vi last(26,-1);
    rp(i,d){
        ll con;
        ll maxi=-INF;
        rp(j,26){
            if(chmax(maxi,s[i][j]+c[i]*(i-last[j]))){
                con=j;
            }
        }
        print(con+1);
        last[con]=i;
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> L(n);
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			for (int k = j+1; k < n; k++) {
				if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
				if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3228
a, b = gets.to_s.split
a = a.to_i
b100 = b.delete(".").to_i
#m = Array.new(n){ gets.to_s.split.map{|e|e.to_i} }
#s = gets.to_s.chomp
ans = (a * b100 / 100).floor
 
puts ans

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

#define fi first
#define se second
#define eb emplace_back
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int) b; i--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

struct SuffixArray {
  const int L;
  vector<int> S;
  vector<int> longestPrefix;
  vector< vector<int> > P;
  vector < pair< pair<int, int> , int > > M;
  SuffixArray (string w) : L ((int)w.length()), S(L), longestPrefix(L), P(1, vi(L)), M(L) {
    for (int i = 0; i < L; i++) {
      P[0][i] = (int) w[i];
    }
    for (int level = 1, match = 1; match < L; level++, match *= 2) {
      P.emplace_back(vi(L));
      for (int i = 0; i < L; i++) {
        M[i] = make_pair (make_pair(P[level - 1][i], i + match < L ? P[level - 1][i + match] : -1), i);
      }
      sort (M.begin(), M.end());
      for (int i = 0; i < L; i++) {
        P[level][M[i].second] = (i > 0 && M[i].first == M[i - 1].first ? P[level][M[i - 1].second]: i);
      }
    }
    for (int i = 0; i < L; i++) {
      S[P.back()[i]] = i;
    }
  }
  int obter (int x, int y) {
    int tot = 0;
    for (int k = (int) P.size() - 1; k >= 0 && x < L && y < L; k--) {
      if (P[k][x] == P[k][y]) {
        x += (1 << k);
        y += (1 << k);
        tot += (1 << k);
      }
    }
    return tot;
  }
  void LCP () {
    longestPrefix[0] = 0;
    for (int i = 1; i < L; i++) {
      int x = S[i];
      int y = S[i - 1];
      int tot = 0;
      for (int k = (int) P.size() - 1; k >= 0 && x < L && y < L; k--) {
        if (P[k][x] == P[k][y]) {
          x += (1 << k);
          y += (1 << k);
          tot += (1 << k);
        }
      }
      longestPrefix[i] = tot;
    }
  }
};
int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, mx = 0;
  string w;
  cin >> n >> w;
  SuffixArray solve (w);
  FOR (i, 0, n) {
    FOR (j, i + 1, n) {
      int ant = solve.S[i];
      int cur = solve.S[j];
      if (abs(ant - cur) >= solve.obter (ant, cur)) {
        mx = max (mx, solve.obter (ant, cur));
      }
    }
  }
  cout << mx << '\n';
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

using namespace std;

constexpr int INF = 1000000000;/* 1e+9a */
constexpr int MODULO = 1000000007;

typedef int64_t ll;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll d, n;
    cin >> d >> n;
    if(n == 100){
        n = 101;
    }
    cout << ll(n * pow(100, d)) << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int kazu = 0;
  cin >> kazu;
  vector<int> henn(kazu);
  for(int i = 0;i <= kazu - 1;i++){
    cin >> henn[i];
  }
  sort(henn.begin(),henn.end());
  int syou = 0;
  int dai = 0;
  int kotae = 0;
  for(int i = kazu - 1;i >= 0;i--){
    for(int j = i - 1;j >= 0;j--){
      syou = -1;
      dai = j;
      while(dai - syou > 1){
        if(henn[(syou + dai) / 2] > henn[i] - henn[j]){
          dai = (syou + dai) / 2;
        }
        else{
          syou = (syou + dai) / 2;
        }
      }
      kotae += j - dai;
    }
  }
  cout << kotae << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, d, value, tmp = 0, ans = 0;
    bool flag = false;
    cin >> n >> d;
    vector<vector<int> > x(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> value;
            x.at(i).push_back(value);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            tmp = 0;
            for(int k = 0; k < d; k++) {
                int t = abs(x.at(i).at(k) - x.at(j).at(k));
                tmp += t * t;
            }
            for (int l = 0; l * l <= tmp; l++) {
                if (l * l == tmp) flag = true;
            }
            if (flag) {
                ans++;
                flag = false;
            }
        }
    }
    cout << ans << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
bool IsPower(int n){
  for( int i = 1; i < 130; i++ ) {
    if( (double)n / (double)i == (double)i ) {
      return true;
    }
  }
  return false;
}

int main() {
  int N, D;
  cin >> N >> D;
  
  vector<vector<int>> X(N, vector<int>(D));
  
  for(int i = 0; i < N; i++ ) {
    for(int j = 0; j < D; j++ ) {
      cin >> X.at(i).at(j);
    }
  }
  
  int distance;
  int pair_count = 0;
  
  for(int i = 0; i < N; i++ ) {
    for(int j = i; j < N; j++ ) {
      distance = 0;
      for(int k = 0; k < D; k++ ) {
        distance += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
      }
      if(IsPower(distance)){
        pair_count++;
      }
    }
  }
  cout << pair_count << endl;
}

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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  vector<int> v(n,0),w(n,0);
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    v[i] = cnt;
    if(s[i] == 'W')cnt++;
  }
  cnt = 0;
  for(int i = n-1; i >= 0; i--){
    w[i] = cnt;
    if(s[i] == 'E')cnt++;
  }
  int ans = 1001001001;
  for(int i = 0 ; i< n; ++i){
    ans = min(ans, v[i]+w[i]);
  }
  cout << ans <<endl;
  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int C, int[][] D, int[][] c)
        {
            var memo = new int[3][];
            for (int i = 0; i < 3; ++i) { memo[i] = new int[C]; }
            for (int i = 0; i < N; ++i)
            {
                for (int j = 0; j < N; ++j)
                {
                    int p = (i + j) % 3;
                    int c1 = c[i][j] - 1;
                    for (int c2 = 0; c2 < C; ++c2)
                    {
                        memo[p][c2] += D[c1][c2];
                    }
                }
            }
            int min = int.MaxValue;
            for (int i = 0; i < C; ++i)
            {
                for (int j = 0; j < C; ++j)
                {
                    if (j == i) { continue; }
                    for (int k = 0; k < C; ++k)
                    {
                        if (k == i || k == j) { continue; }
                        min = Math.Min(memo[0][i] + memo[1][j] + memo[2][k], min);
                    }
                }
            }
            return min;
        }
        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int N = V[0];
            int C = V[1];
            var D = new int[C][];
            for (int i = 0; i < C; ++i) { D[i] = ReadInts(); }
            var c = new int[N][];
            for (int i = 0; i < N; ++i) { c[i] = ReadInts(); }
            Console.WriteLine(Solve(N, C, D, c));
        }
    }
}


Measured memory_bytes: 18248
n, q = map(int,input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i: i+2] == "AC" else 0)
for i in range(q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
string a="CODEFESTIVAL2016";
int main()
{
	string n;
	cin>>n;
	int ans=0;
	for(int i=0;i<a.size();i++)
	{
		if(n[i]!=a[i])
			ans++;
	}
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: putc;
using io :: print;
const int N=5005,mod=1e9+7;
int tot,head[N],nxt[N<<1],adj[N<<1],f[N][N],sz[N],dp[N],g[N];
inline void addedge(ri x,ri y){
	nxt[++tot]=head[x];
	adj[head[x]=tot]=y;
}
inline void dfs(ri x,ri fa){
	f[x][1]=1;
	sz[x]=1;
	ri y,i,j,k;
	for(i=head[x];i;i=nxt[i])
		if((y=adj[i])!=fa){
			dfs(y,x);
			for(j=sz[x]+sz[y];j>=0;--j)
				dp[j]=0;
			for(j=1;j<=sz[x];++j)
				for(k=0;k<=sz[y];++k)
					dp[j+k]=(dp[j+k]+(ll)f[x][j]*f[y][k])%mod;
			sz[x]+=sz[y];
			for(j=0;j<=sz[x];++j)
				f[x][j]=dp[j];
		}
	if(x==1)
		for(i=2;i<=sz[x];i+=2)
			f[x][0]=(f[x][0]+(ll)g[i]*f[x][i])%mod;
	else
		for(i=2;i<=sz[x];i+=2)
			f[x][0]=(f[x][0]+(ll)(mod-g[i])*f[x][i])%mod;
//	for(i=0;i<=sz[x];++i)
//		if(f[x][i])
//			printf("f %d %d %d\n",x,i,f[x][i]);
}
int main(){
//	freopen("ribbons.in","r",stdin);
//	freopen("ribbons.out","w",stdout);
	ri n,i,x,y;
	gi(n);
	g[0]=1;
	for(i=2;i<=n;++i) g[i]=(ll)(i-1)*g[i-2]%mod;
	for(i=1;i^n;++i) gi(x),gi(y),addedge(x,y),addedge(y,x);
	dfs(1,0);
	printf("%d\n",f[1][0]);
	return 0;
}

Measured memory_bytes: 58248
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main()
{
  int n, l;
  cin >> n >> l;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    v.at(i) = l + i;
  }
  int total = 0;
  for (int x : v) {
    total += x;
  }
  int res = 1e9;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int k = 0; k < n; k++) {
      if (k == i) {
        continue;
      }
      sum += v.at(k);
    }
    if (abs(total - sum) < abs(total - res)) {
      res = sum;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdtr1c++.h>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
const int N = 100005;
const int MOD = 1000000007;
int mi(int a,int b){
    if(a<b) return a;
    return b;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;cin >> n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=1;i<=n;i++) cin >> a[i] >> b[i] >> c[i];
    int dp[n+1][4];
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    for(int i=2;i<=n;i++){
        dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
        dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
        dp[i][3]=c[i]+max(dp[i-1][2],dp[i-1][1]);
    }
    cout << max(dp[n][1],max(dp[n][2],dp[n][3]));


    
    return 0;
}


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

using namespace std;

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

const int MAX_N = 305;

int dp[MAX_N][MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = len(s);
    int K;
    cin >> K;
    rep(i,n){
        rep(j,K+1){
            dp[i][i+1][j] = 1;
        }
    }
    srep(l,1,n){
        rep(i,n-l+1){
            int j = i+l;
            rep(k,K+1){
                if(i) cmx(dp[i-1][j][k],dp[i][j][k]);
                if(j < n){
                    if(k) cmx(dp[i][j+1][k],dp[i][j+1][k-1]);
                    cmx(dp[i][j+1][k],dp[i][j][k]);
                    if(s[i] == s[j]) cmx(dp[i][j+1][k],dp[i+1][j][k]+2);
                    if(k < K) cmx(dp[i][j+1][k+1],dp[i+1][j][k]+2);
                }
            }
        }
    }
    cout << dp[0][n][K] << "\n";
    return 0;
}


Measured memory_bytes: 110848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();


			 System.out.println(in.equals("A")?"T"
					 		   :in.equals("C")?"G"
					 		   :in.equals("G")?"C"
					 		   :"A");
		}
	}
}

Measured memory_bytes: 25100
N = int(input())
A = [int(input()) for _ in range(N)]

i = 1
ans = 0
while i!=2 and i>0:
    i_next = A[i-1]
    A[i-1] = -A[i-1]
    i = i_next
    ans += 1
print(ans if i>0 else -1)

Measured memory_bytes: 7084
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int x; cin >> x;
  vector<bool> expo(x+1);

  expo[1] = true;
  for(int b=2;b<=x;b++){
    int v=b*b;
    while(v<=x){
      expo[v]=true;
      v *=b;
    }
  }
  for(int i=x;i>=1;i--) if(expo[i]){
    cout << i << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	for(i=0;i*100<=n;i++){
		if(n-i*100<=i*5){
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}

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

typedef long long ll;

const int MOD = 1e9 + 7;

ll fast_pow(ll a, ll b, ll p){
    ll ans = 1;
    ll base = a % p;
    b = b % (p - 1);
    
    while(b){
        if (b & 1)
            ans = (ans * base) % p;
        
        base = (base * base) % p;
        b >>= 1;
    }

    return ans;
}

ll inv(ll a, ll p){
    return fast_pow(a, p - 2, p);
}

ll C(ll n, ll m, ll p){
    if (n < m)
        return 0;

    m = min(m, n - m);
    
    ll nom = 1, den = 1;
    for (ll i = 1; i <= m; i++){
        nom = (nom * (n - i + 1)) % p;
        den = (den * i) % p;
    }

    return (nom * inv(den, p)) % p;
}

ll lucas(ll n, ll m, ll p){
    if (m == 0)
        return 1;
    return C(n % p, m % p, p) * lucas(n / p, m / p, p) % p;
}

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

    ll ans = 0;
    for (ll i = 1; i < n; i++){
        ans += ((((((n - i) * i) % MOD) * m) % MOD) * m) % MOD;
        ans %= MOD;
    }

    for (ll i = 1; i < m; i++){
        ans += ((((((m - i) * i) % MOD) * n) % MOD) * n) % MOD;
        ans %= MOD;
    }
    
    cout << (ans * lucas(n * m - 2, k - 2, MOD)) % MOD << '\n';

    return 0;
}


Measured memory_bytes: 256
p=998244353
def getinv(n):
  inv = [0]*(n+1)
  #フェルマーの小定理より、i=1の時は1であることが分かる
  inv[1] = 1
  for i in range(2,n+1):
    #そのまま計算すると負になってしまうので、最後にmod pを取ることで正に戻す
    inv[i] = (-(p//i)*inv[p%i])%p
  return inv

def getCmb(n):
  #逆元を取得
  inv = getinv(n)
  #0 <= r <= n に対してnCrを求める
  nCr = [0]*(n+1)
  #r=0の時は、r-1が存在しないので与えておく
  nCr[0] = 1
  for i in range(1,n+1):
    #iで割る代わりにinv[i]をかけ、mod pを求める
    nCr[i] = (nCr[i-1]*(n-i+1)*inv[i])%p
  return nCr

def solve(n,a,b,k):
  nCr = getCmb(n)
  ans=0
  for i in range(n+1):
    #割り切れない時もあるが、その時は次の条件a*i+b*j==kで弾かれるので問題ない
    j = (k-a*i)//b
    #条件に一致するものを選ぶ。jの範囲に注意
    if a*i + b*j == k and 0<=j<=n:
      ans+= (nCr[i]*nCr[j])%p
      ans%= p
  return ans

n,a,b,k=map(int,input().split())
print(solve(n,a,b,k))

Measured memory_bytes: 26720
/*input
4
2 3 4
1 3 4
4 1 2
3 1 2
*/

#include <bits/stdc++.h>
 
using namespace std;

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
 	
	int n;
	cin >> n;

	vector<vector<int>> v(n, vector<int>(n-1));

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n-1; j++) {
			cin >> v[i][j];
			v[i][j]--;
		}
	}

	vector<pair<int, int>> cur;

	vector<int> mt(n);

	for(int i = 0; i < n; i++) {
		int x = v[i][mt[i]];
		if(v[x][mt[x]] == i and x > i) {
			cur.push_back({i, x});
		}
	}

	int ans = 0;

	while(!cur.empty()) {
		ans++;
		map<int, bool> mp;
		vector<pair<int, int>> temp;
		for(auto i : cur) {
			mt[i.first]++;
			mt[i.second]++;
		}

		for(auto i : cur) {
			if(mt[i.first] < n-1) {
				int x = v[i.first][mt[i.first]];
				if(v[x][mt[x]] == i.first and !mp[i.first]) {
					temp.push_back({i.first, x});
					mp[i.first] = true;
					mp[x] = true;
				}
			}
			if(mt[i.second] < n-1) {
				int x = v[i.second][mt[i.second]];
				if(v[x][mt[x]] == i.second and !mp[i.second]) {
					temp.push_back({i.second, x});
					mp[i.second] =  true;
					mp[x] = true;
				}
			}
		}
		//cout << temp.size() <<  ' ';
		cur = temp;

		
		
	}

	bool flag = true;

	for(int i = 0; i < n; i++) {
		if(mt[i] < n - 1){
			flag = false;
			break;
		}
	}

	if(flag) {
		cout << ans << '\n';
	}
	else {
		cout << -1 << '\n';
	}

	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using   namespace std;
int main(){
    int n;
    cin>>n;
    
    vector<int> a(n,0);
    vector<int> mp(n+1,0);
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        
        mp[a[i]]++;
    }
    
    for(int i=1;i<=n;i++){
        cout<<mp[i]<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 4792
from  math import sqrt
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
p1=0;p2=0;p3=0;p=[]
for i in range(n):
    a=abs(x[i]-y[i])
    p1+=a
    p2+=a**2
    p3+=a**3
    p.append(a)
print(p1)
print(sqrt(p2))
print(p3**(1/3))
print(max(p))


Measured memory_bytes: 5692
# Problem C - Peaks

# input
N, M = map(int, input().split())
h_list = list(map(int, input().split()))

# initialization
ans_list = [1]*N
ans = 0

# count
for m in range(M):
    a, b = map(int, input().split())
    if h_list[a-1]>h_list[b-1]:
        ans_list[b-1] = -1
    elif h_list[a-1]<h_list[b-1]:
        ans_list[a-1] = -1
    else:
        ans_list[a-1] = -1
        ans_list[b-1] = -1

# check
for a in ans_list:
    if a>0:
        ans += 1

# output
print(ans)


Measured memory_bytes: 20116
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <utility>
using namespace std;

long l[51];
long p[51];

long f(long n, long x){
    if(n == 0){
        if(x == 0) return 0;
        else return 1;
    }
    if(x == 0) return 0;
    else if(x <= l[n-1]+1) return f(n-1, x-1);
    else if(x == (l[n]-1)/2 + 1) return p[n-1] + 1;
    else if(x >= (l[n]-1)/2 + 1) return p[n-1] + 1 + f(n-1, x - 2 - l[n-1]);
    else return p[n];
}

int main(){
    long n, x;
    cin >> n >> x;
    
    l[0] = 1;
    p[0] = 1;
    for(int i=1;i<=n;i++){
        l[i] = l[i-1] * 2 + 3;
        p[i] = p[i-1] * 2 + 1;
    }
    cout << f(n, x) << endl;
    return 0;
}


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

const int N = 1e5+20;

int n, Piedras[N], dp[N];

int Recursion(int Piedra = 0){
	if (Piedra == n- 1) return 0;
	if(dp[Piedra] != -1) return dp[Piedra];
	dp[Piedra] = INT_MAX;
	if(Piedra+1 <= n-1) dp[Piedra] = min(dp[Piedra], Recursion(Piedra+1) + abs(Piedras[Piedra] - Piedras[Piedra+1]));
	if(Piedra+2 <= n-1) dp[Piedra] = min(dp[Piedra], Recursion(Piedra+2) + abs(Piedras[Piedra] - Piedras[Piedra+2]));	
	return dp[Piedra];
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> Piedras[i];	
	}
	memset(dp, -1, sizeof dp);
	cout << Recursion();
	
}
 

Measured memory_bytes: 4096
n=int(input())
a=[int(x) for x in input().split()]
def arrange(a0_is_plus):
    r=0 if a0_is_plus==True else 1
    sumNum=0
    ans=0
    for i,an in enumerate(a):
        sumNum+=an
        if i%2==r and sumNum<=0:
            ans+=1-sumNum
            sumNum=1
        elif i%2!=r and sumNum>=0:
            ans+=sumNum+1
            sumNum=-1
    return ans
print(min(arrange(True),arrange(False)))

Measured memory_bytes: 63216
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
typedef long long ll;
int n;
ll a[maxn];
map<ll, ll> mp;
int main()
{
    scanf("%d", &n);
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        if(i - a[i] >= 0) ans += mp[i - a[i]];
        mp[i + a[i]]++;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 19112
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, a;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> a;
  cout << n*n-a << endl;
}

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();
		for(int ds=0;ds<n;ds++){
			int h = sc.nextInt();
			int w = sc.nextInt();
			char[][] map = new char[h][w];
			for(int i=0;i<h;i++) map[i] = sc.next().toCharArray();
			
			int[] maxx = new int[7];
			int[] minx = new int[7];
			int[] maxy = new int[7];
			int[] miny = new int[7];
			Arrays.fill(minx, 51);
			Arrays.fill(miny, 51);
			ArrayList<Character> list = new ArrayList<Character>();
			
			int p, q;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(map[i][j]!='.'){
						if(list.contains(map[i][j])==false) list.add(map[i][j]);
						p = list.indexOf(map[i][j]);
						maxx[p] = Math.max(maxx[p], j);
						minx[p] = Math.min(minx[p], j);
						maxy[p] = Math.max(maxy[p], i);
						miny[p] = Math.min(miny[p], i);
					}
				}
			}
			
			boolean flag = true;
			ArrayList<Integer> z = new ArrayList<Integer>();
			p = list.size();
			for(int k=0;k<p;k++){
				for(int i=miny[k];i<=maxy[k];i++){
					for(int j=minx[k];j<=maxx[k];j++){
						if(map[i][j]=='.'){
							flag = false;
							i = maxy[k]+1;
							j = maxx[k]+1;
							k = p;
						}else if(map[i][j]!=list.get(k)){
							q = 10*k + list.indexOf(map[i][j]);
							if(z.contains(q)==false) z.add(q);
						}
					}
				}
			}
			
			if(flag==true){
				q = z.size();
				int[] a = new int[q];
				int[] b = new int[q];
				int[] c = new int[p];
				for(int i=0;i<q;i++){
					a[i] = z.get(i)/10;
					b[i] = z.get(i)%10;
				}
				for(int i=0;i<p;i++) c[i] = i;
				z.clear();
				
				boolean check;
				int rec;
				int temp;
				while(true){
					temp = 1;
					rec = 0;
					for(int i=0;i<p;i++){
						rec += c[i]*temp;
						temp *= 10;
					}
					if(z.contains(rec)==true){
						flag = false;
						break;
					}else{
						z.add(rec);
						flag = true;
						for(int i=0;i<q;i++){
							check = false;
							for(int j=0;j<p;j++){
								if(c[j]==b[i]){
									check = true;
									rec = j;
								}else if(c[j]==a[i]){
									if(check==true){
										temp = c[rec];
										c[rec] = c[j];
										c[j] = temp;
										flag = false;
									}
									break;
								}
							}
						}
						if(flag==true) break;
					}
				}
			}
			
			if(flag==true) System.out.println("SAFE");
			else System.out.println("SUSPICIOUS");
		}	
	}	
}

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

using namespace std;
using ll = long long;


int main(){
  ll N;
  cin >> N;
  
  vector<ll> H(N);
  for(ll i=0; i<N; i++) cin >> H[i];
  
  
  for(ll i=N-2; i>=0; --i){
    if(H[i]>H[i+1]){
      if((H[i]-H[i+1])>=2){
        cout << "No" << endl;
        return 0;
      }
      H[i] -= 1;
    }
  }
  
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 3940
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N, K;
	cin >> N >> K;

	vector<pair<lint,lint>> num(N);
	for (int i = 0; i < N; i++) cin >> num[i].first >> num[i].second;
	sort(num.begin(), num.end());

	lint ptr = 0, idx = 0;
	while (ptr < K) {
	
		ptr += num[idx].second;
		idx++;
	}

	cout << num[idx - 1].first;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
unsigned long long gcd (unsigned long long a, unsigned long long b) {
	return b ? gcd (b, a % b) : a;
}
unsigned long long lcm (unsigned long long a, unsigned long long b) {
	return a / gcd (a, b) * b;
}
int main(){
	int n;
	cin>>n;
	unsigned long long ans=1;
	unsigned long long a[n];
	for (int i=0; i<n; i++){
		cin>>a[i];
		ans=lcm(a[i],ans);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  int n = in();
  vector<int> c(n), a(n);
  cin >> c;
  int q = in();
  while (q--) {
    int t, x, d;
    cin >> t >> x >> d;
    --x;
    if (t == 1) {
      if ((a[x] += d) > c[x]) return cout << ++x << endl, 0;
    } else {
      if ((a[x] -= d) < 0) return cout << ++x << endl, 0;
    }
  }
  cout << 0 << endl;
}



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

int main()
{
  int N;
  cin >> N;
  if (N < 10)
  {
    cout << N << endl;
  }
  else if (N < 100)
  {
    cout << 9 << endl;
  }
  else if (N < 1000)
  {
    cout << 9 + N - 100 + 1 << endl;
  }
  else if (N < 10000)
  {
    cout << 9 + 999 - 100 + 1 << endl;
  }
  else if (N < 100000)
  {
    cout << 9 + 999 - 100 + 1 + N - 10000 + 1 << endl;
  }
  else
  {
    cout << 9 + 999 - 100 + 1 + 99999 - 10000 + 1 << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a == b && b != c || b == c && c != a || c == a && a != b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main (void){
  long long int n = 0,k = 0,q = 0,b = 0;

  cin >> n >> k >> q;
  vector<long long int> a(n,k);

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

  for(int i = 0;i < n;i++){
    if(a[i] - q <= 0){
      cout << "No\n";
    }else{
      cout << "Yes\n";
    }
  }

  return 0;
}

Measured memory_bytes: 1408
from sys import stdin                                                                                                                                                                                       
s = stdin.readline().rstrip()                                                                                                                                                                               
a = s[2:-1]                                                                                                                                                                                                 
cnt = a.count("C")                                                                                                                                                                                          
index = s.find("C")                                                                                                                                                                                         
b = s[1:index]                                                                                                                                                                                              
c = s[index + 1:]                                                                                                                                                                                           
if s[0] == "A" and cnt == 1 and (b.islower() and c.islower()):                                                                                                                                              
    print("AC")                                                                                                                                                                                             
else:                                                                                                                                                                                                       
    print("WA")

Measured memory_bytes: 3060