akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

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

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        String S = sc.next();
        switch (S) {
            case "Sunny":
                out.println("Cloudy");
                break;
            case "Cloudy":
                out.println("Rainy");
                break;
            case "Rainy":
                out.println("Sunny");
                break;
        }
    }
}

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

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


Measured memory_bytes: 19924
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		while (sc.hasNext()) {
			String s = sc.nextLine();
			
			for (int i=0; i<26; i++) {
				StringBuilder sb = new StringBuilder();
				for (int j=0; j<s.length(); j++) {
					char c = s.charAt(j);
					if ('a'<=c && c<='z') {
						c -= i;
						if (c < 97) {c += 26;}
					}
					sb.append(c);
				}
				if (sb.toString().matches(".*(the|this|that).*")) {System.out.println(sb); break;}
			}
			
		}
	}
}


Measured memory_bytes: 27164
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
 
void solve(){

    return;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    int rs = 0;
    map <int, bool> fr;
    int64 k = 0;
    while (true){
        k = (k * 10 + 7) % n;
        rs++;
        if (k == 0){
            ctn(rs);
            return 0;
        }
        if (fr[k]){
            ctn(-1);
            return 0;
        }
        fr[k] = 1;
    }
    return 0;
}

Measured memory_bytes: 50456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  vector<int> snuke(n, 0);
  while (k--) {
    int d; cin >> d;
    while (d--) {
      int a; cin >> a; --a;
      ++snuke[a];
    }
  }
  cout << count(ALL(snuke), 0) << '\n';
  return 0;
}


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

ll get(ll a, ll b) {
  ll res = 1ll;
  while(b) {
    if(b & 1) res = (res * a) % MOD;
    b >>= 1ll;
    a = (a * a) % MOD;
  }
  return res;
}

int main() {
  int n; cin >> n;
  ll T; cin >> T;
  vector <ll> a(n + 1);
  ll cur = 0;
  for(auto &x: a) cin >> x;
  a[n] = a[n - 1] + T;
  for(int i = 0; i + 1 < n + 1; i++) {
    cur += min(T, a[i + 1] - a[i]);
  }
  cout << cur << '\n';
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const bool DBG = 1;

#define TRACE(x)    x
#define WATCH(x)    TRACE(cout << #x" = " << x << endl)
#define WATCHR(a,b) TRACE(for(auto it=a; it!=b;) cout<<*(it++)<<" ";cout<<endl)
#define WATCHC(V)   TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pair<int,int>> vpii;

const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);
	int N, a;
	cin >> N;
	ll r = 1;
	int p = 1;
	ll ctr = N;
	ll cp = 0;
	for(ll i = 1; i <= N; i++) {
		cin >> a;
		if(a < p) {
			ctr--;
			r *= (i-cp);
			cp++;
			r %= MOD;
			//p -= 1;
		} else {
			p += 2;
		}
		//cout << i << " " << a << " " << p << " " << r << " " << p << endl;
	}
	for(ctr; ctr > 0; ctr--) {
		r *= ctr;
		r %= MOD;
	}

	cout << r << endl;

	return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/

int main() {
    int N, T; cin >> N >> T;
    vector<int> A(N), nums;
    rep(i, N) cin >> A[i];
    int l = A[0];
    int r = A[0];
    rep(i, N) {
        if (l < A[i]) {
            r = max(r, A[i]);
        } else if (l > A[i]) {
            nums.pb(r - l);
            r = A[i];
            l = A[i];
        }
        if (i == N - 1) {
            if (r - l > 0) {
                nums.pb(r - l);
            }
        }
    }
    sort(rall(nums));
    int x = nums[0];
    int cnt = 0;
    while (x == nums[cnt]) cnt++;

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

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll a, b;

vector<ll> store;

ll ans = 0;

/////////////////////////////////////////////////////////////
ll mypow_core(ll x, int n, ll result) {
  if (n == 0) {
    return result;
  }

  if (n % 2 == 0) {
    return mypow_core(x * x, n / 2, result);
  }
  else {
    return mypow_core(x, n - 1, x * result);
  }
}

ll mypow(ll x, int n) {
  return mypow_core(x, n, 1);
}
/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
ll count_one(int k, ll x) {
  ll band = mypow(2, k + 1);

  ll part = (x + 1) / band;

  ll num = mypow(2, k) * part;

  ll cut = (x + 1) % band;

  if (cut == 0) {
    return num;
  }
  else {
    if (cut >= (band / 2) + 1) {
      return num + cut - ((band / 2) + 1) + 1;
    }
    else {
      return num;
    }
  }
}
/////////////////////////////////////////////////////////////

int main(void) {
  // Here your code !
  scanf("%lld %lld", &a, &b);

  int size = log2(b) + 1;

  for (int i = 0; i <= size; ++i) {
    ll bottom = count_one(i, a - 1);
    ll top = count_one(i, b);

    ll num_one = top - bottom;

    if (num_one % 2 == 0) {
      store.push_back(0);
    }
    else {
      store.push_back(1);
    }
  }

  for (int i = 0; i < store.size(); ++i) {
    ans += mypow(2, i) * store[i];
  }

  printf("%lld\n", ans);

  return 0;
}


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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> s(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s.at(i).at(j);
        }
    }

    vector<vector<int>> ans(h, vector<int>(w));
    int num = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s.at(i).at(j) == '#') {
                ans.at(i).at(j) = num;
                
                int l = j - 1;
                while (0 <= l && s.at(i).at(l) == '.') {
                    s.at(i).at(l) = '#';
                    ans.at(i).at(l) = num;
                    l--;
                }

                int r = j + 1;
                while (r < w && s.at(i).at(r) == '.') {
                    s.at(i).at(r) = '#';
                    ans.at(i).at(r) = num;
                    r++;
                }
                j = r - 1;
                num++;
            }
        }
    }
    
    for (int i = 0; i < h; i++) {
        if (0 < ans.at(i).at(0)) continue;
        
        if (i == 0) {
            int a = i;
            while (ans.at(a).at(0) == 0) a++;
            
            a--;
            for (int y = a; y >= i; y--) {
                for (int j = 0; j < w; j++) {
                    ans.at(y).at(j) = ans.at(y + 1).at(j);
                }
            }
        }
        else if (i == h - 1) {
            int a = i;
            while (ans.at(a).at(0) == 0) a--;
            
            a++;
            for (int y = a; y <= i; y++) {
                for (int j = 0; j < w; j++) {
                    ans.at(y).at(j) = ans.at(y - 1).at(j);
                }
            }
        }
        else {
            for (int j = 0; j < w; j++) {
                ans.at(i).at(j) = ans.at(i - 1).at(j);
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ans.at(i).at(j) << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin>>s;
    for (int i=0; i<s.size(); i++) {
        if (s.at(i)=='A' && s.at(i+1)=='C') {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
numZ = ord('Z')

for i in range(len(S)):
    S[i] = chr((ord(S[i])+N)) if ord(S[i])+N<=numZ else chr((ord(S[i])+N)-26)

ans = ''
for i in range(len(S)):
    ans += S[i]

print(ans)

Measured memory_bytes: 3064
import scala.io.StdIn.readInt
import scala.collection.mutable.ArrayBuffer

object Main {
  def getQ(n:Int,b:ArrayBuffer[Int]):String = {
    if(n/4==0) {
      b += n%4
      b.toArray.reverse.mkString
    }
    else {
      b += n%4
      getQ(n/4,b)
    }
  }

  def main(args:Array[String]) = {
    var n = -1
    var s1 = "0"
    while({n=readInt;n} != -1) {
      println(getQ(n,new ArrayBuffer[Int]()))
    }
  }

}

Measured memory_bytes: 44988
program sample
  implicit none

  integer :: N, L, a, b

  read(*,*) N, L

  if (1-N<= L.and.L <=-1) then
     a = 1-L
  else if (0<=L)then
     a = 1
  else
     a = N
  end if

  b=(N*N+(2*L-1)*N)/2-L-a+1

  write(*,*) b

  stop
end program sample


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

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

  string s;
  cin >> s;

  int s_A = -1, s_Z = -1;
  for (int i = 0; i < s.size(); ++i) {
    if (s.at(i) == 'A' && s_A == -1) s_A = i;
    else if (s.at(i) == 'Z') s_Z = i;
  }

  cout << s_Z - s_A + 1 << endl;
  return 0;
}


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

const int N = 1050;
const int mod = 1000000007;
char str[N][N];
int dp[N][N];
int n,m;

int rec(int r,int c)
{
    if(r==n-1 && c==m-1) return 1;
    int &ret=dp[r][c];
    if(ret!=-1) return ret;
    ret=0;
    if(r+1<n && str[r+1][c]=='.') ret+=rec(r+1,c);
    ret%=mod;
    if(c+1<m && str[r][c+1]=='.') ret+=rec(r,c+1);
    ret%=mod;
    return ret;
}

int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0; i<n; i++) scanf("%s",str[i]);
    memset(dp,-1,sizeof dp);
    printf("%d\n",rec(0,0));



}


Measured memory_bytes: 5632
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int s = sc.nextInt();

    sc.close();

    int[] v = new int[1000000];
    int[] a = new int[1000000];

    for (int i = 1; i < 1000000; i++) {
      if (i == 1) {
        v[s] = i;
        a[i] = s;
      } else {
        int v_ = func(a[i-1]);
        if (v[v_] != 0) {
          System.out.println(i);
          break;
        } else {
          v[v_] = i;
          a[i] = v_;
        }
      }
    }

  }

  public static int func(int n){

    if (n % 2 == 0) {
      return n / 2;
    } else {
      return 3 * n + 1;
    }
  }

}

Measured memory_bytes: 31060
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
#define MAX_N 300
int cost[MAX_N*MAX_N];
int x[MAX_N*MAX_N];
int y[MAX_N*MAX_N];
int main(){
    int H,W,D;
    cin >> H >> W >> D;
    REP(i,H){
        REP(j,W){
            int A;
            cin >> A;
            x[A-1] = i;
            y[A-1] = j;
        }
    }
    FOR(i,D,H*W){
        cost[i] = cost[i-D] + abs(x[i]-x[i-D]) + abs(y[i]-y[i-D]);
    }
    int Q;
    cin >> Q;
    REP(i,Q){
        int L,R;
        cin >> L >> R;
        cout << cost[R-1] - cost[L-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n,m,a,b;
  cin >> n >> m >> a >> b;
  vector<vector<int> > v(n,vector<int> (m));

  bool boo = true;
  for(int i=0;i<b;i++)
  {
    for(int j=0;j<a;j++)
    {
      v[i][j] = 1;
    }
  }

  for(int i=n-1;i>=b;i--)
  {
    for(int j=m-1;j>=a;j--)
    {
      v[i][j] = 1;
    }
  }

  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++) cout << v[i][j];
    cout << endl;
  }
  return 0;
}



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

int my_gcd(int x, int y) {
    if (x < y) {
        int tmp = x;
        x = y;
        y = tmp;
    }
    int res;
    while (y > 0) {
        res = x % y;
        x = y;
        y = res;
    }
    return x;
}

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

    int sum = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                sum += my_gcd(my_gcd(i, j), l);
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	input := strings.Split(s.Text(), " ")
	slice := sliceAtoi(input)

	sort.Sort(sort.Reverse(sort.IntSlice(slice)))
	var alice, bob int
	for i := 0; i < len(slice); i++ {
		if i%2 == 0 {
			alice += slice[i]
		} else {
			bob += slice[i]
		}
	}
	fmt.Println(alice - bob)

}

func sliceAtoi(str []string) []int {
	slice := make([]int, len(str))
	for i, char := range str {
		val, _ := strconv.Atoi(string(char))
		slice[i] = val
	}
	return slice
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=998244353;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //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; cin >> n;
  int s; cin >> s;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<vector<mint>> dp(n+1, vector<mint>(s+1));
  dp[0][0].x = 1;
  rep(i,n) {
    rep(j,s+1) {
      dp[i+1][j] += dp[i][j]*(mint)2;
      if(j + a[i] <= s) dp[i+1][j+a[i]] += dp[i][j];
    }
  }

  cout << dp[n][s].x << "\n";
  
  return 0;
}


Measured memory_bytes: 73736
#include <iostream>

int w,h,n,x[110],y[110],a[110];
int main(){
  std::cin>>w>>h>>n;
  for(int i=0;i<n;++i)
    std::cin>>x[i]>>y[i]>>a[i];
  
  int left=0,right=w,top=h,bottom=0;
  for(int i=0;i<n;++i)
    switch(a[i]){
      case 1:
        if(x[i]>left)
          left=x[i];
        break;
      case 2:
        if(x[i]<right)
          right=x[i];
        break;
      case 3:
        if(y[i]>bottom)
          bottom=y[i];
        break;
      case 4:
        if(y[i]<top)
          top=y[i];
        break;
    }
  if(top<=bottom||right<=left)
    std::cout<<0<<std::endl;
  else
    std::cout<<(right-left)*(top-bottom)<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

class UnionFind {
public:
    vector <int> par;
    vector <int> siz;

    UnionFind(int sz_): par(sz_), siz(sz_, 1LL) {
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    int root(int x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return siz[root(x)];
    }
};

signed main() {
  int N, M, K;
  cin >> N >> M >> K;

  UnionFind uf(N);

  int a, b;
  vector<vector<int>> ok(N);
  vector<vector<int>> ng(N);
  REP(i, M){
    cin >> a >> b;
    a--; b--;
    ok[a].emplace_back(b);
    ok[b].emplace_back(a);
    uf.unite(a, b);
  }
  REP(i, K){
    cin >> a >> b;
    a--; b--;
    ng[a].emplace_back(b);
    ng[b].emplace_back(a);
  }

  vector<int> ans(N);
  REP(i, N){
    ans[i] = uf.size(i)-ok[i].size()-1;
    for(int a : ng[i]){
      if(uf.root(i) == uf.root(a)) ans[i]--;
    }
  }

  REP(i, N){
    cout << ans[i];
    SPBR(i, N);
  }


  return 0;
}

Measured memory_bytes: 15220
def readInt():
    return int(input())
def readList():
    return list(map(int,input().split()))
def readMap():
	return map(int,input().split())
def readStr():
    return input()
inf=float('inf')
mod = 10**9+7
import math
from itertools import permutations
def solve(N):
    count=0
    for i in range(1,N):
        count+=(N-1)//i
    return count

N=readInt()
print(solve(N))

Measured memory_bytes: 9196
//F
#include<stdio.h>
main() {
	int i, n;
	scanf("%d",&n);
	int max=0, x=0;
	char S[n], ch;
	scanf("%c",&ch);
	for(i=0; i<n; i++){
		scanf("%c",&S[i]);
	}
	S[n]='\0';
	for(i=0; i<n; i++) {
		if(S[i]=='I') {
			x++;

		}
		else {
			x--;
		}
		if(x>max) {
			max=x;
		}
	}
	printf("%d", max);
	return 0;
}

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

using namespace std;

int main (void) {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--, Y--;   /* 0 index に変換 */

    vector<int> ans(N); /* index 0 は使わない */
    for ( int i=0; i<N; i++ ) {
        vector<int> dist(N, INT_MAX);
        queue<int> q;

        auto push = [&](int v, int d) {
            if ( dist[v] != INT_MAX)
                return;
            dist[v] = d;
            q.push(v);
        };

        push(i, 0);
        while ( !q.empty() ) {
            int v = q.front(); q.pop();
            int d = dist[v];
            if ( v - 1 >= 0 )
                push(v - 1, d + 1);
            if ( v + 1 < N )
                push(v + 1, d + 1);
            if ( v == X )
                push(Y, d + 1);
            if ( v == Y )
                push(X, d + 1);
        }

        for ( int j=0; j<N; j++ )
            ans[dist[j]]++;
    }

    for ( int i=1; i<=N-1; i++ )
        cout << ans[i] / 2 << endl;

    return 0;
}


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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'


int main()
{
	#ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	
	int h , n , x , tot = 0 ;
	cin >> h >> n ;
	for(int i = 1 ; i <= n ; ++i)
	{
		cin >> x ; 
		tot += x ;
	}
	cout <<(tot >= h ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 256
#create date: 2020-03-28 21:18

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, x, y = na()
    r = y-x
    ans = [0] * (n-1)
    for i in range(1, n):
        for j in range(i+1, n+1):
            l = min(j-i, abs(i-x)+1+abs(j-y))
            ans[l-1] += 1
    for a in ans:
        print(a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
def x(p0, p1):
    d = abs(p0 - p1)
    if d > 2:
        return []
    elif d == 2:
        return [(p0 + p1) / 2]
    else:
        m = (p0 + p1) / 2
        v = m - p0
        w = complex(v.imag, -v.real)
        l = abs(w)
        h = (1 - l ** 2) ** .5 * w / l
        return [m + h, m - h]

for e in iter(input, '0'):
    n = int(e)
    P = [complex(*map(float, input().split(','))) for _ in [0] * n]
    Q = []
    for i in range(n):
        for j in range(i + 1, n):
            Q += x(P[i], P[j])
    print(max(sum(1.01 >= abs(q - p) for p in P) for q in Q) if Q else 1)


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

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		while(stdin.hasNext()){
			String line = stdin.nextLine();
			if (line.equals(".")) break;
			System.out.println(yesOrNo(isBalanced(line)));
		}
		System.exit(0);
	}
	private static String yesOrNo(boolean b){
		return b ? "yes" : "no";
	}
	private static boolean isBalanced(String line){
		bracketStuck bs = new bracketStuck();
		for(int i = 0; i < line.length(); i++){
			char c = line.charAt(i);
			if (c == '(' || c == ')' || c == '[' || c == ']') {
				if (! bs.processBracket(c)) return false;
			}
		}
		return bs.isEmpty();
	}
}

class bracketStuck {
	private ArrayList<Integer> st = new ArrayList<Integer>();
	private void push(int i) {
		st.add(i);
	}
	private int pop(){
		if (this.isEmpty()) return -1;
		int i = st.get(st.size() - 1);
		st.remove(st.size() - 1);
		return i;
	}
	public boolean isEmpty(){
		return st.size() == 0;
	}
	public boolean processBracket(char c) {
		switch (c) {
		case '(':
			this.push(0);
			return true;
		case '[':
			this.push(1);
			return true;
		case ')':
			if (this.pop() == 0) return true;
			else return false;
		case ']':
			if (this.pop() == 1) return true;
			else return false;
		default:
			return false;
		}
	}
}

Measured memory_bytes: 32776
import java.io.*;
import java.util.*;
class Main {
  	public static void main(String args[]) {
      Scanner s = new Scanner(System.in);
      int a = s.nextInt();
      int b = s.nextInt();
      int c = s.nextInt();
     int res = a * b;
      System.out.println(res/2);
    }
}


Measured memory_bytes: 25044
#include<cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
#include <ctime>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;
#define ll long long
#define PLL pair<ll, ll>
#define mp make_pair
const ll maxn = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll N = 300 + 10;

template<class T>
inline void read(T &res) {
    char c;
    T flag = 1;
    while ((c = getchar()) < '0' || c > '9')if (c == '-')flag = -1;
    res = c - '0';
    while ((c = getchar()) >= '0' && c <= '9')res = res * 10 + c - '0';
    res *= flag;
}

ll min(ll x, ll y) { return x < y ? x : y; }

ll max(ll x, ll y) { return x > y ? x : y; }

int n, k, a[2 * N], b[2 * N], pd[2 * N];
ll cnt[2 * N][2 * N], dp[2 * N][2 * N], g[4*N], ans;

int main() {
    read(n);read(k);
    for (int i = 1; i <= k; ++i) {
        read(a[i]);read(b[i]);
        pd[a[i]] = b[i];
        pd[b[i]] = a[i];
    }
    n <<= 1;
    g[0] = 1;
    for (int i = 2; i <= n; i += 2)
        g[i] = (g[i - 2] * (i - 1)) % mod;
    for (int i = 1; i <= n; i++)
        for (int j = i; j <= n; ++j)
            cnt[i][j] = cnt[i][j - 1] + (!pd[j]);
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            int ff = 0;
            for (int kk = i; kk <= j; kk++)
                if (pd[kk] && (pd[kk] > j || pd[kk] < i)){
                    ff = 1;
                    break;
                }
            if (ff == 1)
                continue;
            dp[i][j] = g[cnt[i][j]];
            for (int kk = i + 1; kk < j; kk++)
                dp[i][j] = (dp[i][j]*1ll%mod - 1ll * dp[i][kk] * g[cnt[kk+ 1][j]] % mod + mod) % mod;
        }
    }
    for (int i = 1; i <= n; ++i)
        for (int j = i; j <= n; ++j)
            ans = (ans%mod + dp[i][j] * g[(n / 2 - k) * 2 - cnt[i][j]] % mod+mod) % mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	long double x[10],y[10];
	for(ll i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	long double kai=1;
	for(ll i=1;i<=n-1;i++){
		kai*=i;
	}
	long double cnt=0;
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			cnt+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))*2*kai;
		}
	}
	printf("%.9Lf",cnt/(kai*n));
	return 0;
}

Measured memory_bytes: 3844
n = int(input())
s = list(map(int,input().split()))

M = 0
for i in range(n-1):
    if s[i] >= s[i+1] and s[i] > M:
        s[i] -= 1
    if s[i] < M:
        print("No")
        exit() 
    M = s[i]
    
if M <= s[-1]:
    print("Yes")
else:
    print("No")

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#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 rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int N,R;
    cin>>N>>R;
    if(N<10){
        cout<<R+100*(10-N)<<endl;
    }else{
        cout<<R<<endl;
    }

    return 0;
}

//a=97,z=122

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> r(N, 0);
  int a, b;
  rep(i, M) {
    cin >> a >> b;
    a--;
    b--;
    r[a]++;
    r[b]++;
  }

  rep(i, N) {
    cout << r[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int INF = (int)1e9 + 7;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x <<
//cin,coutより遅いので注意
template <class T = int>
void in() //in<string>();とか書く intのときはそのままin();
{
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T &x) { cout << x << "\n"; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    {
        cout << "Possible"
             << "\n";
    }
    else
    {
        cout << "Impossible\n";
    }
}

Measured memory_bytes: 256
a,b,c,d,e,f = map(int,input().split())
w = set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s = set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)
ans = -1
sugerwater = 0
suger = 0
for x in w:
    for y in s:
        if  0<x+y<=f and y <= x*e/100:
            if ans < y/(x+y):
                ans = y/(x+y)
                sugerwater = x+y
                suger = y
print(sugerwater,suger)


Measured memory_bytes: 3188
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


#隣接リスト 1-order
def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res


#nCr
def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def main():
    N = NI()
    A = NLI()
    all_xor = 0
    for a in A:
        all_xor ^= a
    L = list(map(lambda x: x^all_xor, A))
    print(" ".join(map(str, L)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 42052
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second

using namespace std;

int main(){

    string n;
    cin >> n;
    int ans1,ans2=0;
    if(n[0] == '9'){
        ans1 = n.size()*9 -1;
    }else{
        int a = n[0] - '0';
        ans1 = n.size()*9 - 9 + a-1;
    }
    for(int i=0;i<n.size();i++){
        ans2 += n[i] -'0';
    }
    
    cout << max(ans1,ans2);

    return 0;
}

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

struct T{int h, q, p;};


int main(){
	int i, n, m, a, h;
	 struct T  t[1100] = {};
	while(1){
		cin>>n>>m>>a;
		if(n == 0 && m == 0 && a == 0) break;
		for(i = 0; i < m; i++){
			cin>>t[i].h>>t[i].q>>t[i].p;
		}
		for(int h = 1000; h > 0; h--){
			for(i = 0; i < m; i++){
				if(a == t[i].q && t[i].h == h) {
					a= t[i].p;
				
				}
				else if(a == t[i].p && t[i].h == h) {
					a= t[i].q;
					
				}
			}
		}
	
		cout<<a<<endl;

	}
	return 0;
}



Measured memory_bytes: 3088
import java.util.Scanner;

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

    int a = scanner.nextInt();
    int b = scanner.nextInt();

    String sign = null;

    if (a < b) {
      sign = "<";
    } else if (a > b) {
      sign = ">";
    } else {
      sign = "==";
    }

    System.out.println("a " + sign  +  " b");
  }
}

Measured memory_bytes: 17324
from collections import deque
import bisect
import sys
input = sys.stdin.readline


n = int(input())
color_box = deque([-1])

for _ in range(n):
    num = int(input())
    idx = bisect.bisect_left(color_box, num)
    if idx == 0:
        color_box.appendleft(num)
    else:
        color_box[idx-1] = num

print(len(color_box))

Measured memory_bytes: 7284
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    V vec4;
    V vec2;
    V vec1;
    V vec3(c);
    rep(i,a){
        ll a;
        cin>>a;
        vec4.push_back(a);
    }
    rep(i,b){
        ll a;
        cin>>a;
        vec2.push_back(a);
    }
    sort(all(vec4),greater<ll>());
    sort(all(vec2),greater<ll>());
    rep(i,x)vec1.push_back(vec4[i]);
    rep(i,y)vec1.push_back(vec2[i]);
    rep(i,c)cin>>vec3[i];
    sort(all(vec1));
    sort(all(vec3));
    vec1.push_back(0);
    vec3.push_back(0);
    reverse(all(vec1));
    reverse(all(vec3));
    rep3(i,1,x+y+1){
        vec1[i]+=vec1[i-1];
    }
    rep3(i,1,c+1){
        vec3[i]+=vec3[i-1];
    }
  /*  for(auto i:vec1){
        cout<<i<<" ";
    }
    cout<<endl;
    for(auto i:vec3){
        cout<<i<<" ";
    }
    cout<<endl;*/
    ll sum=0;
    rep(i,min(x+y,c)+1){
        chmax(sum,vec3[i]+vec1[x+y-i]);
   //     cout<<vec3[i]<<" "<<vec1[x+y-i]<<endl;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 4976
import math
N, D = map(int, input().split())
x=[]
for j in range(N):
    x.append([int(i) for i in input().split()])

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        d = 0
        for k in range(D):
            d += (x[i][k] - x[j][k])**2
        if math.sqrt(d).is_integer():
            cnt += 1

print(cnt)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<pair<int, int>> AB(N - 1);
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    AB[i] = make_pair(a, b);
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  int K = 0;
  map<pair<int, int>, int> color;

  vector<int> pc(N, 0);
  vector<bool> used(N, false);
  deque<int> dq;
  used[0] = true;
  dq.emplace_back(0);
  while (!dq.empty()) {
    int x = dq.front();
    dq.pop_front();
    K = max(K, (int)G[x].size());
    int c = 1;
    for (int y : G[x]) {
      if (used[y]) continue;
      if (c == pc[x]) c++;
      pc[y] = color[make_pair(x, y)] = color[make_pair(y, x)] = c++;
      used[y] = true;
      dq.emplace_back(y);
    }
  }
  cout << K << '\n';
  for (auto ab : AB) {
    cout << color[ab] << '\n';
  }
  return 0;
}


Measured memory_bytes: 19712
n,k=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
kouho=Array.new
for i in 0..n-k
    y=x[i...i+k]
    if y[0]>=0
        kouho.push(y[k-1])
    elsif y[k-1]<=0
        kouho.push(y[0].abs)
    elsif y[0].abs<y[k-1]
        kouho.push(y[k-1]-2*y[0])
    else
        kouho.push(2*y[k-1]-y[0])
    end
end
p kouho.min

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
int X[101010],L[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	vector<pair<ll,ll>> V;
	
	FOR(i,N) {
		cin>>x>>y;
		V.push_back({x-y,x+y});
	}
	set<pair<ll,int>> M;
	sort(ALL(V));
	int ma=0;
	int ret=0;
	FORR(v,V) {
		int num=0;
		while(M.size()&&M.begin()->first<=v.first) {
			ma=max(ma,M.begin()->second);
			M.erase(M.begin());
		}
		int x=ma+1;
		ret=max(x,ret);
		M.insert({v.second,x});
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6512
#include <stdio.h>

int main(){
  int x, y, n;

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

  n = x % y;
    while(n != 0){
      x = y;
      y = n;
      n = x % y;
    }

  printf("%d\n", y);
  return 0;
}



Measured memory_bytes: 2144
n, a, b = map(int, input().split())

if b == a and n > 0:
    print(1)
elif b < a or n == 1 and not b == a:
    print(0)
else:
    ans = (b * (n - 1) + a) - (a * (n - 1) + b) + 1
    print(ans)


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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

const int MAX_N = 100;
const int MAX_W = 100000;
int N, W;
ll dp[MAX_N+1][MAX_W+1];

void solve() {
    cin >> N >> W;
    vector<pair<ll, ll>> D(N);
    REP(i, N) cin >> D[i].first >> D[i].second; // weight, value

    for (int i = 0; i < MAX_N+1; i++) {
        for (int w = 0; w < MAX_W+1; w++) {
            dp[i][w] = 0LL;
        }
    }

    for (int i = 0; i < N; i++) {
        ll weight = D[i].first;
        ll value = D[i].second;
        for (int w = 0; w <= W; w++) {
            if (w < weight) {
                dp[i+1][w] = dp[i][w];
            } else {
                dp[i+1][w] = max(dp[i][w-weight] + value, dp[i][w]);
            }
        }
    }

    cout << dp[N][W] << endl;;


}

signed main() {
    solve();
}


Measured memory_bytes: 79104
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, X = MAP()
A = LIST()

cost = [0]*(N+1)

for i in range(M):
	cost[A[i]] = 1

print(min(sum(cost[:X]), sum(cost[X:])))

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

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

  for (int i = 0; i < (int)(q); ++i) {
    string X, Y;
    cin >> X >> Y;

    int M = X.size(), N = Y.size();
    vector<vector<int>> dp(M + 1, vector<int>(N + 1, 0));
    for (int i = 0; i < (int)(M); ++i) for (int j = 0; j < (int)(N); ++j) {
      if (X[i] == Y[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
      chmax(dp[i + 1][j + 1], max(dp[i][j + 1], dp[i + 1][j]));
    }
    cout << dp[M][N] << endl;
  }

  return 0;
}



Measured memory_bytes: 6792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;  using i64 = int64_t;  using str = string;
using u32 = uint32_t; using u64 = uint64_t; using usize = size_t;
using f64 = double_t; template <typename T> using vec = vector<T>;
#define times(n, i) for (i64 i = 0; i < (n); ++i)
#define range(n, m, i) for (i64 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i64 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i64 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n, k;
vec<i32> d;

i32 main()
{
    cin >> n >> k;
    d.resize(k);
    times(k, i) {
        cin >> d[i];
    }

    i32 v = n;
    while (true) {
        i32 t = v;
        bool ok = true;
        while (t > 0) {
            if (binary_search(all(d), t % 10)) {
                ok = false;
                break;
            }
            t /= 10;
        }
        if (ok) {
            cout << v << endl;
            break;
        }
        v++;
    }

    return 0;
}

Measured memory_bytes: 256