akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Vl = V<ll>;
using Vd = V<ld>;
using VVi = V<Vi>;
using VVl = V<Vl>;
using VVd = V<Vd>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
// const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};


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

  Vi pre(m, -1);
  UnionFind uf(n);

  rep(i, n) {
    int k; cin >> k;
    rep(j, k) {
      int l; cin >> l;
      --l;
      if (pre[l] != -1) uf.unite(pre[l], i);
      pre[l] = i;
    }
  }

  cout << (uf.size(0) == n ? "YES" : "NO") << '\n';
}


Measured memory_bytes: 3928
import numpy as np
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
B=np.array(B)
A=[]
for i in range(n):
  A.append(list(map(int,input().split())))
A=np.array(A)
ans=0
for a in A:
  if sum(a*B)+c>0:
    ans+=1
print(ans)

Measured memory_bytes: 12488
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        int n = int.Parse(input.ReadLine());
        int[] ary = ToIntArray(input.ReadLine(), n);

        double sum = 0;
        foreach(var x in ary) {
            sum += 1.0 / (double)x;
        }
        return 1.0 / sum;
    }
    static int[] ToIntArray(string strs, int n) {
        int[] ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++) ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String[] N = sc.next().split("");

      if (N[0].equals(N[2])){
      System.out.println("Yes") ;
      }
      else {
      System.out.println("No") ;
      }
  }
}


Measured memory_bytes: 23764
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define rep(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int n;
  cin>>n;
  vector<int> ans(n);
  rep(i,n){
    int a;
    cin>>a;
    ans[a-1]=i+1;
  }
  rep(i,n)cout<<ans[i]<<endl;

}


Measured memory_bytes: 1280
N = int(input())

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def lcm(a, b):
  return a * b // gcd (a, b)
  
tmp = 1
for n in range(N):
    tmp = lcm(tmp,int(input()))
print(tmp)



Measured memory_bytes: 2940
import java.io.*;
import java.util.*;
public class Main {

    private static void solver(InputReader sc, PrintWriter out) throws Exception {
        int a = sc.nextInt();
        out.println(a+(a*a)+(a*a*a));
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in, out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
class Pair implements Comparable<Pair> {
    int x, y;

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int compareTo(Pair p) {
        return (this.y - p.y);
    }
}
class Tuple {
    String s;
    int x, y;

    public Tuple(String s, int x, int y) {
        this.s = s;
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Tuple tuple = (Tuple) o;
        return x == tuple.x &&
                y == tuple.y &&
                s.equals(tuple.s);
    }

    @Override
    public int hashCode() {
        return Objects.hash(s, x, y);
    }
}

Measured memory_bytes: 32708
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int negation(int x)
{
    if(x == 0) return 2;
    if(x == 2) return 0;
    return 1;
}

int conjuction(int x, int y)
{
    if(x == 2 && y == 2) return 2;
    else if(x != 0 && y != 0) return 1;
    else return 0; 
}

int disjunction(int x, int y){
    if(x == 2 || y == 2) return 2;
    else if(x == 1 || y == 1) return 1;
    else return 0;
}



int solve(string s, int p, int q, int r)
{
    stack<int> st;
    stack<char> op;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '-' || s[i] == '+' || s[i] == '*'){
            op.push(s[i]);
        } else {
            int tmp1, tmp2;
            if(s[i] == '('){
                i++;
                string news = "";
                int kakkonum = 1;
                while(1){
                    // cout << i << endl;
                    if(s[i] == ')') kakkonum--;
                    else if(s[i] == '(') kakkonum++;
                    if(kakkonum == 0) break;
                    news += s[i];
                    i++;
                }
                // cout << news << endl;
                st.push(solve(news, p, q, r));
            } else if(isdigit(s[i])){
                st.push(s[i] - '0');
            } else {
                if(s[i] == 'P') st.push(p);
                else if(s[i] == 'Q') st.push(q);
                else st.push(r);
            }
            while(!op.empty() && op.top() == '-'){
                op.pop();
                tmp1 = st.top();
                st.pop();
                st.push(negation(tmp1));
            }
            if(!op.empty() && op.top() == '+'){
                op.pop();
                tmp1 = st.top();
                st.pop();
                tmp2 = st.top();
                st.pop();
                st.push(disjunction(tmp1, tmp2));
            } else if(!op.empty() && op.top() == '*'){
                op.pop();
                tmp1 = st.top();
                st.pop();
                tmp2 = st.top();
                st.pop();
                st.push(conjuction(tmp1, tmp2));
            }
        }
    }
    // cout << s  << " " << p << " " << q << " " << r << " " << st.top() << endl;
    return st.top();
}

int main()
{
    string s;
    while(1){
        cin >> s;
        if(s == ".") break;
        int ans = 0;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 3; k++){
                    if(solve(s, i, j, k) == 2) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	char c; cin >> c;
	cout << char(c + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b,a%b)

def lcm(a, b):
    return (a * b) // gcd(a, b)


n = int(input())
ans = 1
for i in range(n):
    tmp = int(input())
    ans = lcm(ans, tmp)
print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define TEST 0
#if TEST
FILE *in = freopen("./Q/question.txt", "r", stdin);
FILE *out = freopen("./A/answer.txt", "w", stdout);
#endif

int main(){
  int n,nm,m;
  vector<int> ans;
  while(1){
    cin >> n;
    if(!n)break;
    cin >> m;
    nm=m;
    int state[n]={0};
    int nx[m],ny[m];
    int x[n][m],y[n][m];
    int dx,dy;
    for(int i=0 ; i<m; ++i)cin >> nx[i] >> ny[i]; //?????¨????????????

    for(int i=0; i<n; ++i){
      cin >> m;
      if(m!=nm)state[i]=2;
      for(int j=0; j<m; ++j){
        cin >> x[i][j] >> y[i][j];
      }
    }

    for(int a=0;a<n ;++a){
      for(int i=0;i<4;++i){
        for(int j=0;j<n;++j){
          for(int k=0; k<m ;++k){
            if(state[j]==1)break;
            dx=nx[0]-x[j][0];
            dy=ny[0]-y[j][0];
            if(x[j][k]+dx!=nx[k]||y[j][k]+dy!=ny[k]) break;
            if(k==m-1&&state[j]!=2)state[j]=1;
          }
        }
        for(int j=0;j<n;++j){
          for(int k=0; k<m ;++k){
            if(state[j]==1)break;
            dx=nx[0]-x[j][m-1];
            dy=ny[0]-y[j][m-1];
            if(x[j][m-k-1]+dx!=nx[k]||y[j][m-k-1]+dy!=ny[k]) break;
            if(k==m-1&&state[j]!=2)state[j]=1;
          }
        }
        for(int i=0;i<m;++i){ //?????¢
          int tmp=nx[i];
          nx[i]=(-ny[i]);
          ny[i]=tmp;
        }
      }
    }
    for(int i=0;i<n;++i){
      if(state[i]==1)cout << i+1 << endl;
    }
    cout << "+++++" << endl;
  }
  #if TEST
  fclose(in);
  fclose(out);
  #endif
  return 0;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    cout << n / 3 << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N;
	cin >> N;
	vi a(N);
	for(int i = 0; i < N; ++i) cin >> a[i];
	int x = 0;
	for(int i = 0; i < N; ++i) x ^= a[i];
	for(int i = 0; i < N; ++i) cout << (x^a[i]) << " \n"[i+1==N];

	return 0;
}

Measured memory_bytes: 3936
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

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

  int a, b, c;
  cin >> a >> b >> c;

  cout << max(0, c-a+b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define rg register
using namespace std;
const int MAXN1=2e5+50,MAXN2=2100,MOD=1e9+7,S=2050;
typedef long long LL;
LL N,a[MAXN1],b[MAXN1],mul[MAXN2<<2],invv[MAXN2<<2],f[MAXN2<<1][MAXN2<<1],ans=0;
inline LL read(){
	char c=getchar();
	LL sign=1,cnt=0;
	while(c<'0'||c>'9'){if(c=='-') sign=-1;c=getchar();}
	while(c>='0'&&c<='9') cnt=(cnt<<1)+(cnt<<3)+(c^48),c=getchar();
	return sign*cnt; 
}
inline LL qpow(LL a,LL b){
	LL res=1;
	while(b){
		if(b&1) res=(res*a)%MOD;
		b>>=1;
		a=(a*a)%MOD;
	}
	return res;
}
inline LL inv(LL x){return qpow(x,MOD-2)%MOD;}
inline LL C(LL n,LL m){return mul[n]*invv[n-m]%MOD*invv[m]%MOD;}
int main()
{
	//freopen("math.in","r",stdin);
	//freopen("math.out","w",stdout);
	memset(f,0,sizeof(f));
	N=read();
	for(rg LL i=1;i<=N;i++) a[i]=read(),b[i]=read(),f[S-a[i]][S-b[i]]++;
	mul[0]=1,invv[0]=inv(mul[0]);
	for(rg LL i=1;i<=8000;i++) mul[i]=mul[i-1]*i%MOD,invv[i]=inv(mul[i]);
	for(rg LL i=1;i<=S*2;i++)
		for(rg LL j=1;j<=S*2;j++)
			f[i][j]=(f[i][j]+(f[i-1][j]+f[i][j-1])%MOD)%MOD;
	for(rg LL i=1;i<=N;i++) ans=(ans+f[S+a[i]][S+b[i]])%MOD,ans=(ans-C(2*a[i]+2*b[i],2*a[i]))%MOD,ans=(ans+MOD)%MOD;
	ans=(ans*500000004)%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 141312
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
char in[5];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a||b){
		int ret=a*a*a;
		set<pair<int,pair<int,int> > >S;
		for(int i=0;i<b;i++){
			int p,q;
			scanf(" %s %d %d ",in,&p,&q);
			p--;q--;
			if(in[0]=='x'&&in[1]=='y'){
				for(int j=0;j<a;j++){
					if(!S.count(make_pair(p,make_pair(q,j)))){
						S.insert(make_pair(p,make_pair(q,j)));
						ret--;
					}
				}
			}else if(in[0]=='x'&&in[1]=='z'){
				for(int j=0;j<a;j++){
					if(!S.count(make_pair(p,make_pair(j,q)))){
						S.insert(make_pair(p,make_pair(j,q)));
						ret--;
					}
				}
			}else if(in[0]=='y'&&in[1]=='z'){
				for(int j=0;j<a;j++){
					if(!S.count(make_pair(j,make_pair(p,q)))){
						S.insert(make_pair(j,make_pair(p,q)));
						ret--;
					}
				}
			}else{
				while(1);
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 4160
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#define INF 10000005

typedef long long ll;

using namespace std;

int n, m;
int main()
{   
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];

    for (int i = 0; i < n; i++) cin >> a[i]>> b[i];
    for (int i = 0; i < m; i++) cin >> c[i] >> d[i];

    int i, j;
    for (i = 0; i < n; i++){
        int min = abs(a[i] - c[0]) + abs(b[i] - d[0]);
        int ans = 1;
        for (j = 1; j < m; j++){
            ll manhattan = fabs(a[i] - c[j]) + fabs(b[i] - d[j]);
            if(min > manhattan){
                min = manhattan;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	printf("%d\n",n-m-1);

	return 0;
}

Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  
  if(v<=w) cout << "NO" << endl;
  else{
    if(a<b){
      if(a+v*t>=b+w*t) cout << "YES" << endl;
      else cout << "NO" << endl;
    }
    else{
      if(a-v*t<=b-w*t) cout << "YES" << endl;
      else cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e5+1)
#define INFL LLONG_MAX
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;


int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FIO;

	// Write your code here


	int t = 1;
	//cin >> t;
	while (t--) {
		ll k, a, b;
		cin >> k >> a >> b;
		if (a % k == 0) {
			cout << "OK\n";
			return 0;
		} else {
			ll x = a - a % k + k;
			if (x >= a && x <= b) {
				cout << "OK\n";
				return 0;
			}
		}

		cout << "NG\n";
	}


	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
 
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[100][100],t[100][100];
bool fl;
struct edge{int to,cost;};
 
//-------------------------↓↓↓↓↓↓------------------------
 
int main(void){
        cin.tie(0);
        cout.tie(0);
    ios::sync_with_stdio(false);
 
    cin>>n>>m;
    rep(i,n)rep(j,n)cin>>s[i][j];
    rep(i,m)rep(j,m)cin>>t[i][j];
    rep(i,n){
        rep(j,n){
            int ok=1;
            rep(ii,m){
                rep(jj,m){
                    if(i+ii>=n||j+jj>=n){
                        ok=0;
                        break;
                    }
                    if(s[i+ii][j+jj]!=t[ii][jj]){
                        ok=0;
                        break;
                    }
                }
                if(!ok)break;
            }
            if(ok){
                Cout("Yes");
                return 0;
            }
        }
    }
    Cout("No");
    return 0;
}

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

const int maxn = 100002;
int n;
long long f[maxn][4];
int a[maxn][4];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=3;j++)
        cin>>a[i][j];
    for (int i=1;i<=3;i++)
        f[1][i] = a[1][i];
    for (int i=1;i<=n;i++){
        for (int j=1;j<=3;j++){
            if (j == 1) f[i][j] = max(f[i-1][2], f[i-1][3]) + a[i][j];
            if (j == 2) f[i][j] = max(f[i-1][1], f[i-1][3]) + a[i][j];
            if (j == 3) f[i][j] = max(f[i-1][1], f[i-1][2]) + a[i][j];
           // cout<<f[i][j]<<" ";
        }
       // cout<<endl;
    }
    long long res = 0;
    for (int i=1;i<=3;i++)
        res = max(res, f[n][i]);
    cout<<res;

}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
#define INF 1000000007
int main(){
  lint i,n;
  cin>>n;
  llint mi;
  mi=INF;
  vint sum(n);
  vector<char> s(n);
  vint ruis(n,0);
  for(i=0;i<n;i++){
   cin>>s[i]; if(s[i] =='W'){ruis[i]++;}//W(<)を向いている
  }
  for(i=1;i<n;i++){
    ruis[i]+=ruis[i-1];//ruis[i]:s[i]までにW(<)を向いている人数
  }
  sum[0]=n-1-ruis[n-1]+ruis[0];
  for(i=1;i<n;i++){
      sum[i]=ruis[i-1]+((n-i-1)-(ruis[n-1]-ruis[i]));//S(>):(range)-(W(<))
  }
  mi = *min_element(sum.begin(),sum.end());
  cout<<mi<<endl;
}

Measured memory_bytes: 2944
N = int(input())
W = list(map(int,input().split()))
S = [0] * N
S[0] = W[0]
sumW = sum(W)
for i in range(1,N):
  S[i] = S[i - 1] + W[i]
ans = max(W)
for i in range(N):
  ans = min(ans, abs(sumW - 2 * S[i]))
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
using namespace std;

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

vector<vector<int>> decompose_to_loops(const vector<int>& P) {
    vector<vector<int>> ret;
    vector<bool> visited(P.size());

    REP(s, P.size()) {
        if (visited[s]) { continue; }

        vector<int> loop;
        int v = s;
        do {
            loop.push_back(v);
            visited[v] = true;
            v = P[v];
        } while (v != s);
        ret.emplace_back(move(loop));
    }

    return ret;
}

template <typename Func>
inline vector<int64_t> make_cumsum(size_t n, Func get_ith_value) {
    vector<int64_t> cumsum(n+1);
    REP(i, cumsum.size()) {
        cumsum[i] = (i == 0) ? 0 : cumsum[i-1] + get_ith_value(i-1);
    }
    return cumsum;
}

// [first, last] の和を返す
int64_t sum_of(const vector<int64_t>& cumsum, int first, int last) {
    return cumsum[last+1] - cumsum[first];
}

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

    int N; cin >> N;
    int64_t K; cin >> K;
    vector<int> P(N);
    REP(i, N) {
        cin >> P[i];
        --P[i];
    }
    vector<int64_t> C(N);
    REP(i, N) {
        cin >> C[i];
    }

    int64_t max_sum = numeric_limits<int64_t>::min();

    for (const auto& loop : decompose_to_loops(P)) {
        int64_t loop_size = loop.size();
        auto cumsum = make_cumsum(loop_size, [&](int i) { return C[loop[i]]; });

        for (int64_t k = 0; k < min(K, loop_size); ++k) {
            int64_t bonus = max<int64_t>(0, ((K-k-1) / loop_size) * cumsum[loop_size]);

            REP(s, loop_size) {
                int64_t sum;
                if (s + k < loop_size) {
                    sum = sum_of(cumsum, s, s + k);
                } else {
                    sum = sum_of(cumsum, s, loop_size-1) + sum_of(cumsum, 0, s+k-loop_size);
                }
                max_sum = max(max_sum, sum + bonus);
            }
        }
    }

    cout << max_sum << '\n';
}


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

typedef long long long64;

long64 inline distance(long64 s, long64 t, long64 p)
{
	long64 d = abs(s - t);
	long64 d1 = abs(p - s);
	long64 d2 = abs(p - t);

	if (d1 < d2)
		return d1 + d;
	else
		return d2 + d;
}

void inline find(long64& l, long64& r, long64 p, std::vector<long64>& array)
{
	auto it_s = std::lower_bound(array.begin(), array.end(), p);
	if (it_s == array.end()) {
		r = l = array.size() - 1;
	}
	else {
		r = std::distance(array.begin(), it_s);
		if (it_s != array.begin()) {
			it_s--;
			if (it_s == array.end()) {
				l = r;
			}
			else {
				l = std::distance(array.begin(), it_s);;
			}
		}
		else {
			l = r = 0;
		}
	}
};

int main()
{
	size_t s_num, t_num, p_num;
	std::cin >> s_num >> t_num >> p_num;

	std::vector<long64> s(s_num);
	std::vector<long64> t(t_num);
	std::vector<long64> p(p_num);

	for (size_t i = 0; i < s_num; i++)
	{
		std::cin >> s[i];
	}

	for (size_t i = 0; i < t_num; i++)
	{
		std::cin >> t[i];
	}

	for (size_t i = 0; i < p_num; i++)
	{
		std::cin >> p[i];
	}

	std::sort(s.begin(), s.end());
	std::sort(t.begin(), t.end());

	for (size_t i = 0; i < p.size(); i++)
	{
		long64 min_s = abs(s[0] - p[i]);
		size_t index_s = 0;
		long64 min_s_l;
		long64 min_s_r;
		long64 min_t_l;
		long64 min_t_r;

		find(min_s_l, min_s_r, p[i], s);
		find(min_t_l, min_t_r, p[i], t);

		long64 mins[4] = {};
		mins[0] = distance(s[min_s_l], t[min_t_l], p[i]);
		mins[1] = distance(s[min_s_l], t[min_t_r], p[i]);
		mins[2] = distance(s[min_s_r], t[min_t_l], p[i]);
		mins[3] = distance(s[min_s_r], t[min_t_r], p[i]);


		long64 min = mins[0];
		for (size_t i = 0; i < 4; i++) {
			if (min > mins[i]) {
				min = mins[i];
			}
		}

		std::cout << min << std::endl;
	}

	return 0;
}

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

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

  vector<int> d(N);
  rep(i,N) cin >> d[i];

  sort(d.begin(), d.end());

  cout << d[N/2] - d[N/2-1] << endl;

  return 0;
}


Measured memory_bytes: 768
n = int(input())
xlist = list(map(int,input().split()))

xlist.sort()
#max_x = xlist[n - 1]
#min_x = xlist[0]

#p = int((max_x - min_x)/2) + min_x

s = sum(xlist)
p = round(s / n)
add_x = 0
for i in range(n):
    add_x = add_x + (xlist[i] - p) ** 2

print(add_x)

Measured memory_bytes: 3060
#include <cstdio>

#define MAX_N 100001

int N, counts, a[MAX_N];
bool checked[MAX_N];

int main()
{
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    scanf("%d", &a[i]);

  for (int i = 1; i <= N; i++)
  {
    if (!checked[i] && i == a[a[i]])
    {
      checked[i] = true;
      checked[a[i]] = true;
      counts++;
    }
  }
  printf("%d\n", counts);
  return 0;
}

Measured memory_bytes: 640
n, m = gets.chomp.split(' ').map(&:to_i)
map = {}
m.times do
  s, c = gets.chomp.split(' ').map(&:to_i)
  if map[s] != c && !map[s].nil?
    puts '-1'
    exit
  end
  map[s] = c
end
result = '-1'
(0..999).each do |i|
  next if i.to_s.size != n
  if map.all? { |s, c| i.to_s[s - 1] == c.to_s }
    result = i.to_s
    break
  end
end
puts result

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()

for i in range(1, 10):
    if N % i == 0 and N // i <= 9:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 3064
import sys
from bisect import bisect_left, bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A.sort()
    B.sort()
    C.sort()

    ans = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 92644
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>

const int MOD = 1000000007;


ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}




int main(int argc, char *argv[])
{
	int n,m;
	cin>>n>>m;
	vector<int> h(n+1),g(n+1,1); 
	
	for (int i=1;i<=n;i++) cin>>h[i];
	for (int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		if (h[a]>=h[b]) g[b]=0;
		if (h[b]>=h[a]) g[a]=0;
	}
	int ret=0;
	for (int i=1;i<=n;i++) ret+=g[i];
		
	cout<<ret<<endl;

	return 0;
}



Measured memory_bytes: 4052
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

import Data.Map.Strict as M

-- import System.IO

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = Data.List.map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = Data.List.map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	ss <- Data.List.map B.unpack . B.lines <$> B.getContents
	mapM_ putStrLn $ solve ss
-- 	hFlush stdout

solve ss = runST $ do
	counts <- newSTRef ( M.empty :: M.Map String Int )
	forM_ ss $ \s -> do
		modifySTRef counts =<< 
			M.insert s . succ . fromMaybe 0 . M.lookup s <$> readSTRef counts
-- 	ma <- snd . M.findMax <$> readSTRef counts
	ma <- maximum . M.elems <$> readSTRef counts
	sort . M.keys . M.filter ( == ma ) <$> readSTRef counts

Measured memory_bytes: 149628
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	static String reverse(String str){
		return new StringBuffer(str).reverse().toString();
	}

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int m = sc.nextInt();
			for(int i=0;i<m;i++) {
				String tomas = sc.next();  // sc.nextInt() と sc.nextLine() は混在しない
				TreeSet<String> pats = new TreeSet<>();
				for(int j=0;j<tomas.length()-1;j++) {
					String head = tomas.substring(0, j+1);
					String tail = tomas.substring(j+1); // tomas.substring(j+1,tomas.length()) と同じ
					pats.add(reverse(head) + tail);
					pats.add(tail + reverse(head));
					pats.add(reverse(tail) + head);
					pats.add(head + reverse(tail));
					pats.add(head + tail);
					pats.add(tail + head);
					pats.add(reverse(head) + reverse(tail));
					pats.add(reverse(tail) + reverse(head));
				}
				System.out.println(pats.size());
			}
		}
	}
}



Measured memory_bytes: 63340
n = int(input())
s_list = list(input())
e_sum = [0]
su = 0
for s in s_list[:-1]:
    if s == "W":
        su += 1
    e_sum.append(su)
w_sum = [0]
su = 0
for s in s_list[::-1][:-1]:
    if s == "E":
        su += 1
    w_sum.append(su)
w_sum = w_sum[::-1]
ans = 10 ** 10
for i in range(n):
    ans = min(ans, e_sum[i] + w_sum[i])
print(ans)

Measured memory_bytes: 90812
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;

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

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

constexpr int MAX_SIZE = 30;
constexpr int MAX_N = MAX_SIZE * MAX_SIZE;
constexpr int INF = (1 << 29);

int bfs_memo[MAX_N][MAX_N];

int get_index(int x, int y, int w) {
	return x + y * w;
}

void add_edge(int a, int b, vector<vector<int>> &G) {
	bool not_door;
	cin >> not_door;

	if(!not_door) {
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
}

int bfs(int s, int no, const vector<vector<int>> &G) {
	if(bfs_memo[s][no] != -1) return bfs_memo[s][no];

	const int n = G.size();
	vector<int> dist(n, INF);
	queue<int> que;
	dist[s] = 0;
	que.push(s);

	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		if(v == n - 1) break;

		for(const auto &to : G[v]) {
			if(v == s && to == no) continue;

			if(dist[to] == INF) {
				dist[to] = dist[v] + 1;
				que.push(to);
			}
		}
	}

	return bfs_memo[s][no] = dist[n - 1];
}

int dfs(int v, int card, vector<vector<int>> &memo, const vector<vector<int>> &G) {
	const int n = G.size();
	if(v == n - 1) return card;
	if(card >= n) return INF;

	int &res = memo[v][card];
	if(res != -1) return res;

	int min_select = INF;
	for(const auto &to : G[v]) {
		chmax(res, bfs(v, to, G) + card);
		chmin(min_select, dfs(to, card + 1, memo, G));
	}

	chmax(res, min_select);
	chmin(res, INF);
	return res;
}

int solve(const vector<vector<int>> &G) {
	const int n = G.size();
	memset(bfs_memo, -1, sizeof(bfs_memo));
	vector<vector<int>> memo(n, vector<int>(n, -1));
	const int ans = dfs(0, 0, memo, G);
	return ans == INF ? -1 : ans;
}

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

	for(int h, w; cin >> h >> w && h;) {
		const int n = h * w;
		vector<vector<int>> G(n);

		rep(y, h) {
			rep(x, w - 1) {
				add_edge(get_index(x, y, w), get_index(x + 1, y, w), G);
			}

			if(y < h - 1) {
				rep(x, w) {
					add_edge(get_index(x, y, w), get_index(x, y + 1, w), G);
				}
			}
		}

		cout << solve(G) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 7476
n, *l = map(int, open(0).read().split())
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if(l[i]==l[j] or l[j]==l[k] or l[k]==l[i]): continue
            if(l[i]+l[j]<=l[k] or l[j]+l[k]<=l[i] or l[k]+l[i]<=l[j]): continue
            ans += 1
print(ans)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
int main() {
    double n;
    cin >> n;
    double sum=0;
    for(int i=1;i<=n;++i) {
        if(i%2==1) ++sum;
    }
    cout << fixed << setprecision(10) << sum/n << endl;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll N;
vector<ll> res;

int main(){
  cin>>N;
  ll sz=min(100LL,N);
  vector<ll> cnt(sz,0);
  N-=sz;
  repl(i,1,sz+1){
    ll sum=0;
    rep(j,i){
      if(j==i-1){
        res.push_back(i);
        N-=sum;
        cnt[i-1]=sum+1;
        break;
      }
      if(sum+cnt[res[j]-1]>N){
        res.insert(res.begin()+j,i);
        N-=sum;
        cnt[i-1]=sum+1;
        break;
      }
      sum+=cnt[res[j]-1];
    }
    //dbg(N);
    //rep(j,sz)dbg(cnt[j]);
    //rep(j,res.size())dbg(res[j]);
  }

  repl(i,1,sz+1)res.push_back(i);
  cout<<res.size()<<endl;
  rep(i,res.size())cout<<res[i]<<" ";
  cout<<endl;
  return 0;
}


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

int main(){
    int n; cin >> n;
    vector <int> C(n - 1), S(n - 1), F(n - 1);

    for (int i = 0; i < n - 1; i ++){
        cin >> C.at(i) >> S.at(i) >> F.at(i);
    }


    for (int start = 0; start < n - 1; start ++){
        int now_t = S.at(start) + C.at(start);

        for (int station = start + 1; station < n - 1; station ++){
            //　始発よりも早く到着した場合
            if (now_t <= S.at(station)){
                now_t = S.at(station) + C.at(station);
                continue;
            }

            //　次に向かう電車がまだきていないとき
            if ((now_t - S.at(station)) % F.at(station)){
                now_t += F.at(station) - ((now_t - S.at(station)) % F.at(station));
            }

            now_t += C.at(station);
        }

        cout << now_t << endl;

    }

    cout << 0 << endl;
}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10 ** 6)

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
A = []
def rec(itr, lst):
    if itr == N:
        res = 0
        for a, b, c, d in abcd:
            if A[b-1] - A[a-1] == c:
                res += d
        return res
    else:
        res = 0
        for i in range(lst, M):
            A.append(i)
            res = max(res, rec(itr + 1, i))
            A.pop()
        return res
print(rec(0, 0))


Measured memory_bytes: 9188
#include <cstdio>
#include <cmath>
#include <algorithm>

int main(){

    int N, K;

    scanf("%d%d", &N, &K);

    int sum = 0;
    for(int i = 0; i < N; ++i){

        int x;

        scanf("%d", &x);

        int tmp;

        if(K - x > 0){
            tmp = K - x;
        }
        else{
            tmp = x - K;
        }

        sum += std::min(x, tmp) * 2;
    }

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

    return 0;
}


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;
use std::collections::LinkedList;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let mut graph: Vec<LinkedList<Path>> = (0..n).map(|_| LinkedList::new()).collect();

    for i in 1..n {
        let a = read::<usize>() - 1;
        let b = read::<usize>() - 1;
        graph[a].push_back(Path{ edge: b, ord: i - 1});
        graph[b].push_back(Path{ edge: a, ord: i - 1});
    }

    let mut ret = (1..n).map(|_| n as u64).collect();

    draw(&mut ret, &graph, n as u64, 0, n as u64);

    let colors = (&ret).into_iter().fold(0, |a, b| std::cmp::max(a, *b));
    println!("{}", colors);

    for i in &ret {
        println!("{}", i);
    }
}

fn draw(color: &mut Vec<u64>, graph: &Vec<LinkedList<Path>>, now: u64, pos: usize, init: u64) {
    let mut now_color = 1;

    for path in &graph[pos] {
        if color[path.ord] != init {
            continue;
        }

        if now_color == now {
            now_color += 1;
        }

        color[path.ord] = now_color;
        draw(color, graph, now_color, path.edge, init);
        now_color += 1;
    }
}

#[derive(Clone)]
struct Path {
    edge: usize,
    ord: usize,
}



Measured memory_bytes: 14716
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		int min = 1 << 20;
		for (int i = -100; i <= 100; i++) {
			int sum = 0;
			for (int j = 0; j < n; j++) {
				sum += (a[j] - i) * (a[j] - i);
			}
			min = Math.min(min, sum);
		}
		System.out.println(min);
	}

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


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

bool is_prime(long long n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else if (n % 2 == 0) {
        return false;
    }
 
    for (long long i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    for (int i = 4; i <= 55555; i += 5) {
        if (is_prime(i)) {
            cout << i;
            n--;
            if (n > 0) {
                cout << " ";
            } else {
                cout << endl;
                break;
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int n,m;
vector<vector<int>> v(100100);
vector<ll> seen(100100,-1);

ll dfs(int now){
  if(seen[now] != -1)return seen[now];
  ll sum = 0;
  for(auto nv : v[now])sum = max(dfs(nv)+1,sum);
  return seen[now] = sum;
}


int main(){
  
  cin >> n >> m;
  rep(i,m){
    int fr,to;cin >> fr >> to;
    fr--,to--;
    v[fr].push_back(to);
  }
  ll res = 0;
  rep(i,n)res = max(res,dfs(i));
  cout << res << endl;





  

  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++) cin >> p.at(i);
  int ans=0;
  for(int i=0; i<n-2; i++){
    if(p.at(i)<p.at(i+1) && p.at(i+1)<p.at(i+2)) ans++;
    if(p.at(i)>p.at(i+1) && p.at(i+1)>p.at(i+2)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var (
        n     int
        cnt int
    )
    fmt.Scan(&n)
    num := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&num[i])
    }

    flg := true
    for flg {
        for i := 0; i < n; i++ {
            if num[i]%2 == 0 {
                num[i] /= 2
            } else {
                flg = false
            }
        }
        if flg {
            cnt++
        }
    }
    fmt.Println(cnt)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 55,mod = 1e9+7;
it add(int x,int y){ return x+y>=mod?x+y-mod:x+y; }
it mul(int x,int y){ return 1ll*x*y%mod; }
il inc(int &x,int y){ x=add(x,y); }
int n,fac[N],ifac[N],f[N][N][N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),f[n][0][0]=1,fac[0]=1;
	for(ri i=1;i<=n;++i) fac[i]=mul(fac[i-1],i);
	ifac[n]=qpow(fac[n],mod-2,mod);
	for(ri i=n-1;i>=0;--i) ifac[i]=mul(ifac[i+1],i+1);
	for(ri i=n-1;i>=0;--i) for(ri x=0;x<=n-i;++x) for(ri y=0;y<=n-i-x;++y)
		for(ri a=0;a<=n-i-x-y;++a) for(ri b=0;b<=n-i-x-y-a;++b)
			if(x-a+b>=0&&y+a-b>=0) inc(f[i][x][y],mul(mul(ifac[x-a+b],ifac[y+a-b]),f[i+x+y][a][b]));
	print(mul(f[0][1][0],fac[n]));
	return 0;
}

Measured memory_bytes: 640
from math import *

X,K,D = list(map(int,input().split()))

A = (K*D + X) / (2 * D)

if K <= A:
    print(abs(X-K*D))
elif A <= 0:
    print(abs(X+K*D))
else:
    print(min(abs(X-2*ceil(A)*D+K*D) ,abs(X-2*floor(A)*D+K*D)) )

Measured memory_bytes: 9188