akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      out.println(in.nextInt() ^ 1);
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

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

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

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

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 32948
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin>>N;
  cout<<N*N<<endl;
  ;
}
void solve() {
  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,k;
cin>>n>>k;
long long ans=1;
for(long long i=0;pow(k,i)<=n;i++){
  if(n/pow(k,i)>0){
    ans=i+1;
  }
  else{
    break;
  }
}
cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
strS = list(str(input()))
S = [int(n) for n in strS]
N =len(S)
cnt = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt += 1
        if S[i] == 0:
            S[i+1] = 1
        else:
            S[i+1] = 0

print(cnt)

Measured memory_bytes: 4652
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static System.Console;

namespace D_D2019
{
    class MainClass
    {

        static long[] s;


        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            long n = s[0];
            long ans = 0;


            var dlst = DivisorList(s[0]);
            dlst.Reverse();
            //dlst.ForEach(WriteLine);
            
            //foreach(long item in dlst)WriteLine(item);

            for(int i = 0;i < dlst.Count-1;i++){
                long div = n/(dlst[i]-1);
                long r = n%(dlst[i]-1);
                if(div>r)break;
                if(dlst[i]-1!=dlst[i+1]&&div==r){
                    ans+=dlst[i]-1;
                    //WriteLine(dlst[i]-1);
                }
            }
            WriteLine(ans);

        }


        public static List<long> DivisorList(long p)
        {
            var res = new List<long>();
            var sqp = (long)Sqrt(p);
            long tmp = 0;

            for(long i= 1;i<=sqp;i++){
                if(p%i==0){
                    res.Add(i);
                    tmp = p/i;
                    if(tmp!=i) res.Add(tmp);
                }
            }
            res.Sort();
            return res;
        }
    }
}


Measured memory_bytes: 13524
/*
* じょえチャンネル
* 高評価・チャンネル登録よろしくおねがいします！
* https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
*/

#include <bits/stdc++.h>


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


#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)

#define intt long long
#define P pair<int,int>

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

using namespace std;

//Library
//モッドパウ
int modpow(int x, int y, int m = mod) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
            res %= m;
        }
        x = x * x % mod;
        y /= 2;
    }
    return res;
}

int mypow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
        }
        x = x * x;
        y /= 2;
    }
    return res;
}
//is the number (x) a prime number?
bool prime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (!(x % i)) {
            return false;
        }
    }
    return true;
}


//saidai-kouyakusuu
inline int gcd(int x, int y) {
    if (!y) {
        return x;
    }
    return gcd(y, x % y);
}


//number of keta
int keta(int x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}

//sum of keta
int ketasum(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

inline int lcm(int x, int y) {
    int ans = x / gcd(x, y) * y;
    return ans;
}
int twobeki(int x) {
    int ans = 0;
    while (1) {
        if (!(x & 1)) {
            ans++;
            x /= 2;
        }
        else {
            break;
        }
    }
    return ans;
}


template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
    if (lhs < rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
    if (lhs > rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
void Yes(){
    cout<<"Yes"<<endl;
}
void No(){
    cout<<"No"<<endl;
}
void YES(){
    cout<<"YES"<<endl;
}
void NO(){
    cout<<"NO"<<endl;
}


#define fin(i) scanf("%lld",&i)
#define fout(i) printf("%lld\n",i)
#define fendl printf("\n")
//Library-End

int n,m,q;
string s;
set<int> basho[50];
signed main() {
    cin>>n;
    cin>>s;
    cin>>q;
    rep(i,n){
        basho[s[i]-'a'].insert(i);
//        cout<<s[i]-'a'<<' '<<i<<endl;
    }
    rep(i,q){
        int w;
        fin(w);
        if (w==1) {
            int f;
            char c;
            scanf("%lld %c",&f,&c);
            f--;
            if (s[f]!=c) {
                basho[s[f]-'a'].erase(f);
                s[f]=c;
                basho[c-'a'].insert(f);
            }
        }else{
            int l,r;
            fin(l);fin(r);
            l--;
            r--;
            int ans=0;
            rep(j,30){
                auto ba=basho[j].lower_bound(l);
                if(ba!=basho[j].end()){
                    if(*ba<=r)ans++;
                }
            }
            fout(ans);
        }
    }
}


Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int k; cin >> k;
    int ans = -1;
    int mod = 0;
    int plus = 7%k;
    for (int i=1; i <= k; ++i) {
        mod = mod + plus;
        mod %= k;
        plus = 10 % k * plus;
        plus %= k;
        if (mod == 0) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
n = int(input())
x = list(map(int, input().split()))
x_s = sorted(x)

le = len(x)
m_idx = le // 2 - 1
m0 = (x_s[m_idx]+x_s[m_idx+1]) / 2

for i in range(len(x)):
    if x[i] == m0:
        print(x[i])

    elif x[i] < m0:
        print(x_s[m_idx+1])

    elif x[i] > m0:
        print(x_s[m_idx])


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

int main(){
  string s,t;
  int cnt=0;
  
  cin>>s>>t;
  rep(i,3)
    if(s[i]==t[i])
      cnt++;
  cout<<cnt<<endl;
    
  return 0;
}

Measured memory_bytes: 3520
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

s = gets.chomp
ans = 0
k = s.size/2
tail = s.size - 1
k.times do |i|
  ans += 1 if(s[i] != s[tail-i])
end
p ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
//int a[100005],b[i][30];
int32_t main() {
	/*int t;
	cin>>t;
	while(t--)
	{
		int n,i,j,k;
		cin>>n;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			for(j=0;j<=26;j++)
				b[i][j]=b[i][j-1];
			b[i][a[i]]++;
		}*/
	int a,b,c,x,i,j,k;
	cin>>a>>b>>c>>x;
	int ans=0;
	for(i=0; i<=a;i++)
	{
		int p=500*i;
		for(j=0; j<=b;j++)
		{	
			int q=100*j;
			for(k=0;k<=c;k++)
			{
				int r=50*k;
				if(p+q+r==x)
					ans++;
			
			}
		}
	}
	cout<<ans<<"\n";
		
		
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <cassert>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define ALL(a) (a).begin(),(a).end()

#define pb push_back

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

int main() {
    int n;
    cin >> n;
    vi a(n);
    map<int, bool> mp;
    REP(i,n) {
        int b;
        cin >> b;
        a[i] = b-1;
    }
    int cnt = 0;
    REP(i,n) {
        if (a[a[i]] == i && !mp[i]) {
            cnt++;
            mp[i] = mp[a[i]] = true;
        }
    }
    cout << cnt << endl;
}


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

double rad2deg(double rad){
  return rad/atan(1.0)* 45.0;
}

int main(){
  double a,b,V;
  cin >> a >> b >> V;

  double tan_ans= (2*V >= a*a*b) ? 2*(b/a - V/(a*a*a))
                                 : a*b*b/(2*V);
  
  cout << fixed;
  cout << setprecision(9) << rad2deg(atan(tan_ans)) << endl;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<int> W(N);
    rep(i, N) {
        cin >> W[i];
    }

    ll ans = INF;
    rep(i, N - 1) {
        ll left = 0, right = 0;
        rep(k, i + 1) {
            left += W[k];
        }
        repd(j, i + 1, N) {
            right += W[j];
        }
        ans = min(ans, abs(left - right));
    }

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

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

typedef long long ll;

const int MOD = (int)(1e+9) + 7;
int N;
ll K;
vector<ll> fac;
vector<ll> ifac;

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)
			res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

void comb_init(void) {
	fac.resize(N + 1);
	ifac.resize(N + 1);
	fac[0] = 1;
	ifac[0] = 1;
	for(int i = 0; i < N; ++i) {
		fac[i + 1] = fac[i] * (i + 1) % MOD;
		ifac[i + 1] = ifac[i] * mod_pow(i + 1, MOD - 2, MOD) % MOD;
	}
}

ll comb(ll a, ll b) {
	if(a == 0 && b == 0)
		return 1;
	if(a < b || a < 0)
		return 0;
	ll tmp = fac[(int)a] * ifac[(int)b] % MOD;
	tmp = tmp * ifac[(int)(a - b)] % MOD;
	return tmp;
}
int main(void) {
	cin >> N >> K;

	comb_init();
	ll ans = (ll)0;
	int t = min((int)K, N - 1);
	for(int i = 0; i <= t; ++i) {
		ll tmp = comb(N, i);
		tmp *= comb(N - 1, N - i - 1);
		tmp %= MOD;
		ans = (ans + tmp) % MOD;
	}

	cout << ans << '\n';
	return 0;
}


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

using namespace std;

int main()
{
    int x,y;
    cin >> x >> y;

    for(int i=0;i<=x;i++){
        int check=0;
        check+=2*i;
        check+=4*(x-i);
        if(check==y){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <sstream>
using namespace std;
typedef pair<int, int> Pii;

int goal[4][4];
string team_name[4];
double f[9];
double prob[9];

struct result {
	int point, goal_diff, goal_score, id;
};
int comp(const result& r1, const result& r2) {
	if(r1.point != r2.point) return r1.point - r2.point;
	if(r1.goal_diff != r2.goal_diff) return r1.goal_diff - r2.goal_diff;
	if(r1.goal_score != r2.goal_score) return r1.goal_score - r2.goal_score;
	return 0;
}

double win(int T) {
	vector<result> res(4, result{ 0, 0, 0, 0 });
	vector<int> w, l;

	int bit = 15;
	while(1) {
		res.assign(4, result{ 0, 0, 0, 0 });
		for(int i = 0; i < 4; i++) {
			res[i].id = i;
			if(((bit >> i) & 1) == 0) continue;
			for(int j = 0; j < 4; j++) {
				if(i == j) continue;
				if(((bit >> j) & 1) == 0) continue;
				if(goal[i][j] > goal[j][i]) res[i].point += 3;
				else if(goal[i][j] == goal[j][i]) res[i].point += 1;
				res[i].goal_diff += goal[i][j] - goal[j][i];
				res[i].goal_score += goal[i][j];
			}
		}

		int nbit = 0;
		for(int i = 0; i < 4; i++) {
			if(bit >> i & 1) {
				int c = comp(res[T], res[i]);
				if(c > 0) w.push_back(i);
				if(c < 0) l.push_back(i);
				if(c == 0) nbit |= 1 << i;
			}
		}
		if(w.size() >= 2) return 1;
		if(l.size() >= 2) return 0;
		if(nbit == bit) break;
		bit = nbit;
	}

	int m = 2 - l.size();
	int n = 0;
	for(int i = 0; i < 4; i++) {
		if(bit >> i & 1) n++;
	}
	return (double)m / n;
}

void solve() {
	int T = -1;

	string s;
	getline(cin, s);
	replace(s.begin(), s.end(), '_', ' ');

	stringstream ss(s);
	for(int i = 0; i < 4; i++) {
		ss >> team_name[i];
		if(team_name[i][0] == '*') T = i;
	}

	vector<Pii> match;
	for(int i = 0; i < 4; i++) {
		string t;
		getline(cin, s);
		replace(s.begin(), s.end(), '_', ' ');
		ss = stringstream(s);
		ss >> t;
		for(int j = i + 1; j < 4; j++) {
			ss >> t;
			if(t == "-") {
				goal[i][j] = goal[j][i] = -1;
				match.push_back(Pii(i, j));
			}
			else {
				goal[i][j] = t[0] - '0';
				goal[j][i] = t[2] - '0';
			}
		}
	}

	double ans = 0;
	for(int m1i = 0; m1i <= 8; m1i++) {
		for(int m1j = 0; m1j <= 8; m1j++) {
			for(int m2i = 0; m2i <= 8; m2i++) {
				for(int m2j = 0; m2j <= 8; m2j++) {
					double p = prob[m1i] * prob[m1j] * prob[m2i] * prob[m2j];
					goal[match[0].first][match[0].second] = m1i;
					goal[match[0].second][match[0].first] = m1j;
					goal[match[1].first][match[1].second] = m2i;
					goal[match[1].second][match[1].first] = m2j;
					ans += win(T) * p;
				}
			}
		}
	}

	cout << fixed << setprecision(7) << ans << endl;
}

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

	f[0] = 1;
	for(int i = 1; i <= 8; i++) {
		f[i] = f[i - 1] * i;
	}
	for(int p = 0; p <= 8; p++) {
		prob[p] = f[8] / f[p] / f[8 - p] * pow(0.25, p) * pow(0.75, 8 - p);
	}

	int N;
	cin >> N;
	cin.ignore();
	while(N--) {
		solve();
	}
}

Measured memory_bytes: 3428
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	string b[10];
	b[1] = ".,!? ";
	b[2] = "abc";
	b[3] = "def";
	b[4] = "ghi";
	b[5] = "jkl";
	b[6] = "mno";
	b[7] = "pqrs";
	b[8] = "tuv";
	b[9] = "wxyz";
/*
	b[1][] = { '.', ',', '!', '?', ' ' };
	b[2][] = { 'a', 'b', 'c' };
	b[3][] = { 'd', 'e', 'f' };
	b[4][] = { 'g', 'h', 'i' };
	b[5][] = { 'j', 'k', 'l' };
	b[6][] = { 'm', 'n', 'o' };
	b[7][] = { 'p', 'q', 'r', 's' };
	b[8][] = { 't', 'u', 'v' };
	b[9][] = { 'w', 'x', 'y', 'z' };
*/
//	cut here before submit 
//	freopen ("testcase.KM", "r", stdin );
	int n;
	scanf ("%d", &n );
	while (n-- ){
		string mesg = "";
		cin >> mesg;
		int m = mesg.length();
		int c = -1, cnt = -1;
		string ans = "";
		rep (i, m ){
			if (mesg[i] != '0' ){
				c = (char)(mesg[i] - '0');
				cnt++;
			}else{
				if (c != -1 ){
//					if (cnt == 1 ) cnt--;
					ans += b[c][(cnt) % b[c].length() ];
				} // end if
				c = -1;
				cnt = -1;
			} // end if
		} // end rep
		cout << ans << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1240
n,q = map(int, raw_input().split())
que = [map(str, raw_input().split()) for i in range(n)]
for i in range(n):que[i][1] = int(que[i][1])
mxt = sum([y for x,y in que])
t = 0
i = 0
while t < mxt:
	i %= n
	if que[i][1] <= q:
		t += que[i][1]
		print que[i][0],t
		que.pop(i)
		n -= 1
	else:
		t += q
		que[i][1] -= q
		i += 1

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

long iabs(long a){
    if( a<0 ){
        return -a;
    }else{
        return a;
    }
}

int main(){
    int N, M;

    cin >> N >> M;
    
    long a[N], b[N], c[M], d[M];
    long distance, dmin;
    int ans[N];

    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0; i<M; i++){
        cin >> c[i] >> d[i];
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            distance= iabs( a[i]-c[j] )+iabs( b[i]-d[j] );
            if( j==0 ){
                dmin= distance;
                ans[i]=j;
            }else if( dmin > distance ){
                dmin=distance;
                ans[i]=j;
            }
        }
    }

    for(int i=0; i<N; i++){
        cout << ans[i]+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main() {
   double A,B,H,M;
   double distance,HH;
   double theta,phi;
   double CC;
   distance = 1000;
   scanf("%lf %lf %lf %lf", &A, &B, &H, &M);

    //HH = H/12;  
    //printf("%lf\n",H);
    //printf("2*M_PI = %lf\n",2*M_PI);
    //printf("(H/12) = %lf\n",HH);
    theta = 2*M_PI*((H/12) + (M/(60*12)));
    
    //printf("theta = %f\n",theta);
    phi = 2*M_PI*(M/60);
    //printf("sin(theta) = %lf\n",sin(theta));
    //CC = sqrt(sin(theta)*sin(theta) + cos(phi)*cos(phi));
    //printf("CC = %lf\n",CC);
    distance = sqrt(pow((A*sin(theta)-B*sin(phi)),2.0) + pow((A*cos(theta)-B*cos(phi)),2.0));
    printf("%10.10f",distance);

  return 0;
}

Measured memory_bytes: 2476
from sys import stdin
from itertools import accumulate


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline().rstrip()
    r_sum, g_sum, b_sum = [list(accumulate(1 if c == x else 0 for c in S)) for x in 'RGB']

    ans = 0
    sums = {'R': r_sum, 'G': g_sum, 'B': b_sum}
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            if S[i] == S[j]:
                continue
            other = 'RGB'.replace(S[i], '').replace(S[j], '')
            ans += sums[other][-1] - sums[other][j]
            k = j + (j - i)
            if k < N and S[k] == other:
                ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 79296
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<pair<int,int>> solve(int K, const vector<pair<int,int>>& target){
  vector<pair<int,int>> ret;
  int x = 0, y = 0;
  int ti = 0;
  int cango = K;
  rep(i,target.size()){
    int gx = target[i].first, gy = target[i].second;
    while(true){
      int d = abs(gx-x) + abs(gy-y);
      if(d == 0) break;
      if(cango <= d){
        if(gx != x){
          x += (gx-x>=0?1:-1) * cango;
        }else{
          y += (gy-y>=0?1:-1) * cango;
        }
        cango = K;
        ret.emplace_back(x,y);
      }else{
        cango = K-d;
        x = gx;
        y = gy;
        break;
      }
    }
  }

  
  return ret;
}


int main(){
  int K;
  cin >> K;
  int X, Y;
  cin >> X >> Y;

  bool flipX = false, flipY = false;
  if(X<0){
    X *= -1;
    flipX = true;
  }
  if(Y<0){
    Y *= -1;
    flipY = true;
  }

  if(K%2==0 && (X+Y)%2==1){
    cout << -1 << endl;
    return 0;
  }

  bool flip = false;
  if(X < Y){
    swap(X, Y);
    flip = true;
  }
  
  int c = (K-((X+Y)%K))%K;

  vector<pair<int,int>> ret;
  if(X+Y<K && (X+Y)%2 == 1){
    vector<pair<int,int>> target;
    target.emplace_back(0,-(K-X));
    target.emplace_back(X+((K+X-Y)/2),-(K-X));
    target.emplace_back(X+((K+X-Y)/2),Y);
    target.emplace_back(X,Y);

    ret = solve(K, target);
  }else{
    int n = 1;
    if(X+Y<K && (X+Y)%2==0) n = 2;
    else if(X+Y>=K && c%2==0) n = (X+Y+K-1)/K;
    else if(X+Y>=K && c%2==1) n = (X+Y+K-1)/K + 1;

    vector<pair<int,int>> target;
    target.emplace_back(0,-(K*n-X-Y)/2);
    target.emplace_back(X,-(K*n-X-Y)/2);
    target.emplace_back(X,Y);
    
    ret = solve(K, target);
  }

  cout << ret.size() << endl;
  rep(i,ret.size()){
    int x = ret[i].first;
    int y = ret[i].second;
    if(flip) swap(x,y);
    if(flipX) x *= -1;
    if(flipY) y *= -1;
    
    cout << x << " " << y << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3952
N=list(range(int(input())))
S=list(input())
S=sorted(S)
answer=0

prev=S[0]
counts = []
counter=0

for k in S:
    if k==prev:
        counter+=1
    else:
        prev=k
        if counter!=0:
            counts.append(1+counter)
        counter=1
if counter!=0:
    counts.append(1+counter)

def soujou(li):
    atai=1
    for j in li:
        atai=j*atai
    return atai

answer=soujou(counts)-1
print(answer%(7+10**9))

Measured memory_bytes: 51824
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
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()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int head = 0;
  REP(i, 4) {
    if (s[i] == '+') ++head;
    else --head;
  }
  cout << head << '\n';
  return 0;
}


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

using namespace std;

int main(void){
    
    int n;
    char ten;
    string blood;
    int a,b,ab,o;
    a = b = ab = o = 0;
    while( cin >> n >> ten >> blood ){
        if( blood == "A" )a++;
        if( blood == "B" )b++;
        if( blood == "AB")ab++;
        if( blood == "O" )o++;
    }
    cout << a << endl;
    cout << b << endl;
    cout  <<  ab << endl;
    cout  << o << endl;
    return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int n,m;cin>>n>>m;
    vector<int> x(n,-1);
    int s,c;

    bool flag=true;
    for(int i=0;i<m;i++){
        cin>>s>>c;
        
        if(n!=1&&s==1&&c==0){
            flag=false;break;
        }
        if(x[s-1]!=-1&&x[s-1]!=c){
            flag=false;break;
        }
        x[s-1]=c;
    }

    if(flag){
        for(int i=0;i<n;i++){
            if(i==0&&x[i]==-1){
              if(n!=1) x[i]=1;
              else x[i]=0;
            }  
            if(i!=0&&x[i]==-1) x[i]=0;
            cout<<x[i];
        }
        cout<<endl;
        return 0;
    }
    else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 504
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine

getIntArray :: IO [Int]
getIntArray = ((map (\a -> read a :: Int)) . words) <$> getLine

getStrArray :: Int -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

to2018 :: String -> String
to2018 (_:_:_:_:rst) = "2018" ++ rst

main = do
    putStrLn =<< to2018 <$> getLine


Measured memory_bytes: 380
#!/usr/bin/env python3
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;


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

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

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

			int a = sc.nextInt();

			if (a%2 == 0) {

				if (a%3 != 0 && a%5 != 0) {
					System.out.print("DENIED");
					
					return;
					}

				}
			}
		
		
			System.out.print("APPROVED");
		
		
		
		}

	}





Measured memory_bytes: 21972
#include <cstdio>
#include <cstring>
#define MAXN 100010
#define LL long long

int n,m;
LL v[MAXN];
LL d[MAXN][2];

void add(int l,int r,LL x1,LL x2){
	d[l][0]+=x1;
	d[l][1]+=x2;
	d[r+1][0]-=x1;
	d[r+1][1]-=x2;
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",v+i);
	LL s0=0;
	for(int i=1;i<n;i++){
		LL a=v[i],b=v[i+1];
		if(a<b){
			add(a+1,b,-1,a+1);
			s0+=b-a;
		}else{
			if(a<m) add(a+1,m,-1,a+1);
			add(1,b,-1,a-m+1);
			s0+=b+m-a;
		}
	}
	LL t0=0,t1=0;
	LL ans=1LL<<60;
	for(int i=1;i<=m;i++){
		t0+=d[i][0]; t1+=d[i][1];
		LL s=s0+t0*i+t1;
		if(s<ans) ans=s;
	}
	printf("%lld\n",ans);
}


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

#define ll long long int

int N;
int dias[3];
ll memo[2][3];



ll solve(){
	cin>>memo[0][0]>>memo[0][1]>>memo[0][2];
	for(int i = 1; i<N; i++){
		cin>>dias[0]>>dias[1]>>dias[2];
		for(int j = 0; j<3;j++)
			memo[i&1][j]=dias[j]+max(memo[((i&1)+1)%2][(j+1)%3],memo[((i&1)+1)%2][(j+2)%3]);
	}
	ll maxi = 0;
	for(int j = 0; j<3;j++)
		maxi = max(memo[(N-1)&1][j], maxi);
	return maxi;
}

int main() {
	cin>>N;
	cout<<solve()<<"\n";
	return 0;
}

Measured memory_bytes: 3596
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
flag = [False]*(2000*n+1)

bit = 2**n-1
for i in range(bit, -1, -1):
    tmp = 0
    tmpbit = i
    for j in range(n):
        if (tmpbit & 1) == 1:
            tmp += A[j]
        tmpbit >>= 1
    flag[tmp] = True

for i in m:
    if flag[i] is True:
        print("yes")
    else:
        print("no")


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


int main() {
    ll A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    ll bunsi = -1, bunbo = -1;
    REP(a, 101) REP(b, 101) REP(cc, 3001) {
        if (a + b == 0)
            continue;
        ll ab = 100 * A * a + 100 * B * b;
        ll c = cc * C;
        if (ab + c > F)
            continue;
        if (ab / 100 * E < c)
            continue;
        ll dd = min(F - ab - c, ab / 100 * E - c);
        ll d = dd / D * D;
        ll cd = c + d;
        if (bunsi == -1 || bunbo * 100 * cd >= bunsi * (ab + cd))
            bunsi = 100 * cd, bunbo = ab + cd;
    }

    if (bunsi == -1)
        cout << A * 100 << " " << 0 << endl;
    else
        cout << bunbo << " " << bunsi / 100 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <numeric>
#include <cmath>
#include <set>
#include <functional>

using namespace std;

#define ll long long;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl;

int a[100010];

int main() {
    int n;
    cin >> n;
    int ma = 0;
    rep(i, n) {
        cin >> a[i];
        ma = max(ma, a[i]);
    }
    double hma = ma / 2.0;
    double submi = 2000000000.0;
    int ans;
    rep(i, n) {
        submi = min(submi, abs(hma - a[i]));
        if (submi == abs(hma-a[i])) {
            ans = a[i];
        }
    }
    cout << ma << ' ' << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll n;

    cin >> n;

    vector<double> p(n+1);
    for (ll i=1; i<=n; i++) {
        cin >> p[i];
    }

    vector<vector<double>> sol(n+1, vector<double>(n+1, 0));
    sol[1][0] = 1 - p[1];
    sol[1][1] = p[1];

    for (ll i=2; i<=n; i++) {
        sol[i][0] = sol[i-1][0] * (1-p[i]);
        for (ll j=1; j<=i; j++) {
            sol[i][j] = (p[i]*sol[i-1][j-1]) + ((1-p[i])*sol[i-1][j]);
        }
    }


    double ans = 0;
    for (ll i=ceil(n/2.0); i<=n; i++) {
        ans += sol[n][i];
    }

    cout.precision(10);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 70784
#pragma GCC optimize("O3")
#include <bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
    int h,w,m;
    cin>>h>>w>>m;
    V<P> a(h,P(0,0)),b(w,P(0,0));
    V<V<int>> g(h);
    int c,d;
    for(int i=0;i<m;i++){
        cin>>c>>d;
        c--;d--;
        g[c].push_back(d);
        a[c].fi++;
        a[c].se=c;
        b[d].fi++;
        b[d].se=d;
    }
    sort(all(a),greater<P>());
    ll ma=a[0].fi;
    sort(all(b),greater<P>());
    ll mb=b[0].fi;
    ll ans=a[0].fi+b[0].fi-1;
    set<int> s;
    for(int i=0;i<w;i++){
        if(mb>b[i].fi)break;
        s.insert(b[i].se);
    }
    int cnt=0;
    for(int i=0;i<h;i++){
       int cnt=0;
        if(a[i].fi<ma)break;
        if(g[a[i].se].size()<s.size()){
            cout<<ans+1<<"\n";
            return 0;
        }
        for(int v:g[a[i].se]){
            if(s.find(v)!=s.end())cnt++;
        }
        if(cnt!=s.size()){
            cout<<ans+1<<"\n";
            return 0;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 43004
#include <stdio.h>
int main(){
    int n=0,t=0,c[2000],time[2000],i=0,min=10000;
    scanf("%d",&n);
    scanf("%d",&t);
    for(i=0;i<n;i++){
        scanf("%d",&c[i]);
        scanf("%d",&time[i]);
    }

    for(i=0;i<n;i++){
        if(time[i]<=t){
            if(c[i]<min){
                min=c[i];
            }
        }
    }
    
    if(min==10000){
        printf("TLE");
    }else{
        printf("%d",min);
    }

    return 0;
}    

Measured memory_bytes: 128
# C
# 4進数
N,A,B,C = map(int, input().split())
L = [int(input()) for _ in range(N)]

ans = float('inf')
for i in range(4**N):
    a,b,c = [],[],[]
    cost = 0
    for keta in range(N):
        v = (i//(4**keta))%4
        if v==0:   a.append(L[keta])
        elif v==1: b.append(L[keta])
        elif v==2: c.append(L[keta])
        else: pass
    
    if len(a)*len(b)*len(c)==0: continue
    cost += 10*(len(a)+len(b)+len(c)-3)
    cost += abs(sum(a)-A) + abs(sum(b)-B) + abs(sum(c)-C)
    ans = min(ans, cost)

print(ans)
                

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e9;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b >= c)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3576
#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)(1e6 +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;

ll binpow(ll a, ll b) {
	ll x = 1;
	while (b) {
		if (b & 1) x = x * a;
		a = a * a;
		b >>= 1;
	}
	return x;
}

ll mult(ll a, ll b) {
	ll x = 0;
	while (b) {
		if (b & 1) x = (x + a);
		a = (a + a);
		b >>= 1;
	}
	return x;
}



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--) {
		vl v(5);
		int ans;
		for (int i = 0; i < 5; i++) {
			cin >> v[i];
			if (v[i] == 0) ans = i;
		}
		cout << ans + 1 << "\n";
	}


	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

const int MAX = 1000001; 

 int n, q;
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(vector<int>& arr, vector<Query>& queries) {
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
int main() 
{ 
    cin>>n>>q;
    vector<int> a(n);
    for(int i = 0; i<n; ++i)
        cin>>a[i];
  
    vector<Query> queries(q); 

    for(int i = 0; i<q; ++i) {
        int l, r;
        cin>>l>>r;
        l -= 1;
        r -= 1;
        queries[i].l = l;
        queries[i].r = r;
        queries[i].idx = i;
    }
    
    sort(all(queries), cmp); 
    answeringQueries(a, queries); 
    return 0; 
} 

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

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  int count = 0;
  for(int i = 0; i <= s.size() - 3; i++){
    if(s.at(i) == 'A'){
      if(s.at(i + 1) == 'B' && s.at(i + 2) == 'C'){
        count++;
      }
    }
  }
  cout << count << endl;
}


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

using namespace std;

const int maxn = 1e5 + 5;
char s[maxn];
int n;
int d;
typedef long long LL;
LL dp[10005][105];
int a[maxn];

const LL mod = 1e9 + 7; 

LL DP(int pos, int m, bool lead, bool limit){
    //cout << pos << " " << m << " " << lead << " " << limit << endl;
    if(pos == n + 1){
        if(!lead and m == 0)
            return 1;
        else
            return 0;
    }
    if(!lead and !limit and dp[pos][m] != -1)
        return dp[pos][m];
    int mx = limit ? a[pos] : 9;
    LL ans = 0;
    for(int i = 0;i <= mx;i++){
        int m1 = (m + i) % d;
        ans += DP(pos + 1, m1, lead && (i == 0), limit && i == a[pos]);
        if(ans >= mod)
            ans -= mod;
    }
    //cout << pos << " " << m << " " << ans << endl;
    if(!limit and !lead) dp[pos][m] = ans;
    return ans;
}

int main(){
    scanf("%s", s + 1);
    n = strlen(s + 1);
    for(int i = 1;i <= n;i++){
        a[i] = s[i] - '0';
    }
    cin >> d;
    memset(dp, -1, sizeof(dp));
    cout << DP(1, 0, true, true) << endl;
    for(int i = 1;i <= 2;i++){
        for(int j = 0;j < 4;j++){
            //cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 9472
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int n, m;
	cin>>n>>m;
	vector<int> v(n);
	for(int &x:v)
		cin>>x;
	vector<vector<int>> g(n+1);
	for(int i=0;i<m;i++){
		int a, b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int ma=0;
		for(int x:g[i])
			ma=max(v[x-1],ma);
		if(ma<v[i-1])
			ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 8744
#include <stdio.h>
#include<string.h>
int main()
{
long int a[100000],b[100000],c=0,d=0,w=0,i,str1=0,str2=0,flag,j,count=0,k,n,sum=0;
char s;
scanf("%c",&s);
if(s=='a' || s=='i' || s=='u' || s== 'e' || s=='o')
{
    printf("vowel");
}else{
    printf("consonant");
}
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,q;cin >> n >> m >> q;
	vector<vector<int>> a(n+1,vector<int>(n+1));
	rep(i,m){
		int l,r;cin >> l >> r;
		a[l][r]++;
	}
	rep(i,n+1){
		rep(j,n){
			a[i][j+1]+=a[i][j];
		}
	}
	rep(i,n+1){
		rep(j,n){
			a[j+1][i]+=a[j][i];
		}
	}
	rep(i,q){
		int l,r;cin >> l >> r;
		cout << a[r][r]-a[l-1][r]-a[r][l-1]+a[l-1][l-1] << endl;
	}
}

Measured memory_bytes: 1920
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1e5 + 7;
int n, c[3][N], dp[3][N];

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[j][i];
        }
    }
    for (int i = 0; i < 3; i++) {
        dp[i][1] = c[i][1];
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            dp[j][i] = max({dp[j][i], dp[(j + 1) % 3][i - 1], dp[(j + 2) % 3][i - 1]}) + c[j][i];
        }
    }
    int res = 0;
    for (int i = 0; i < 3; i++) {
        res = max(res, dp[i][n]);
    }
    cout << res;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  cin >> n >> t;
  int ans = 1010;
  for (int i = 0; i < n; i ++) {
    int c, t1;
    cin >> c >> t1;
    if (ans > c && t1 <= t) ans = c;
  }
  if (ans == 1010) cout << "TLE" << endl;
  else cout << ans << endl;
  return 0;
}

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

int main() {
    ll n,h[100001],k;
    std::cin >> n>>k;
    ll dp[100001];
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }
    dp[0] = 0;
    
    dp[1] = abs(h[1]-h[0]);
    
    for (int i = 2; i < n; i++) {
        // どうせ上書きされる
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        
        for (int j = 2; j <= k && 0 <= i-j; j++) {
            dp[i] = min(dp[i],dp[i-j] + abs(h[i]-h[i-j]) );
        }
    }
    std::cout << dp[n-1] << std::endl;
    
}



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	for(int i=0; i<s.length(); i++){
		if((i%2==0 && s[i]=='L') || (i%2==1 && s[i]=='R')){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		int maxAB = Math.max(A, B);
		int minAB = Math.min(A, B);

		if (maxAB > minAB + 1) {
			System.out.println(maxAB + maxAB - 1);
		} else {
			System.out.println(maxAB + minAB);
		}
	}

}

Measured memory_bytes: 21716
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

ll gcd(ll a, ll b){
	if(b==0) return a;
	
	return gcd(b, a%b);
}

vector<pair<ll, ll>> prime_factorize(ll n){
	vector<pair<ll, ll>> prime;
	
	for(ll i=2; i*i<=n; ++i){
		if(n%i!=0) continue;
		pair<ll,ll> p = make_pair(i,0);
		while(n%i==0){
			p.second++;
			n /= i;
		}
		prime.push_back(p);
	}
	
	if(n != 1) prime.push_back(make_pair(n,1));
	
	return prime;
}

int main(){
	ll a,b;
	cin >> a >> b;
	
	ll d = gcd(a,b);
	
	vector<pair<ll,ll>> prime = prime_factorize(d);
	
	bool primehas1 = false;
	for(auto x: prime){
		if(x.first==1) primehas1=true;
	}
	if(!primehas1) prime.push_back(make_pair(1,1));
	
	cout << prime.size() << endl;
	
	return 0;
}

Measured memory_bytes: 3608
h, w = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))

GRID = [[0] * w for _ in range(h)]

PATH = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            PATH.append((i, j))
    else:
        for j in range(w)[::-1]:
            PATH.append((i, j))

color = 1
count = 0
for i, j in PATH:
    GRID[i][j] = color
    count += 1
    if count == A[color - 1]:
        color += 1
        count = 0

for ROW in GRID:
    print(*ROW)


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  bool ans = false;
  for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N - M + 1; j++) {
      bool ok = true;
      for (int x = 0; x < M; x++) {
        for (int y = 0; y < M; y++) {
          if (A[i + x][j + y] != B[x][y]) {
            ok = false;
            break;
          }
        }
      }
      if (ok) {
        ans = true;
        break;
      }
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int a;
        double b;
        
        if(n % 2 == 0){
            a = n / 2;
            b = (double) a / n;
            System.out.println(b);
        }else{
            a = n / 2 + 1;
            b = (double) a / n;
            System.out.println(b);
        }
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n,m;
  cin >> n >> m;
  
  int h[n];
  rep(i,n){
    cin >> h[i];
  }
  
  unordered_map<int,int> good;
  
  int a,b;
  rep(i,m){
    cin >> a >> b;
    a--;b--;
    
    if(h[a]==h[b]){
      good[a]=1;
      good[b]=1;
    }
    else if(h[a]>h[b]){
      good[b]=1;
    }
    else good[a]=1;
    
  }
  
  int ans = n-good.size();
  
  cout << ans << endl;
}



Measured memory_bytes: 5976
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

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

  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());

  cout << S.size() << endl;
}

Measured memory_bytes: 9544