akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicLong;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        if (n > 9 || m > 9) {
            out.println(-1);
            return;
        }
        out.println(n * m);
    }

    private static boolean contains(int[] d, int i) {
        for (int i1 : d) {
            if (i1 == i)
                return true;
        }
        return false;
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
long long a[200005];
int main ()
{
    ///without test case
    long long int b,c,d,t,n,i,j;
     set<int>s;
    cin >>n;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       s.insert(a[i]);
    }
    b=s.size();
    if(b<n)
    {
        cout<< "NO"<<"\n";
    }
    else
    {
        cout << "YES"<<"\n";
    }

}



Measured memory_bytes: 11136
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a,b;
    while(1==1){
      a = sc.nextInt();
      b = sc.nextInt();
      if(a==0 && b==0)  break;
      if(a>b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
      }
      System.out.println(a+" "+b);
    }
  }
}


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

int main() {
  int N, n, a, b;
  cin >> N;
  n = N;
  a = 0;
  b = 100000000;
  
  for (int i = 0 ; i < 8; i++) {
    a += n / b;
    n %= b;
    b /= 10;
  }
  
  a += n;
  
  if (N % a == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }

}


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

typedef long long ll;

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

    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if(x-r<0 || y-r<0 || x+r>w || y+r>h) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define print(a) cout<<(a)<<endl;
#define to_ll(b) stoll(b)
#define MOD 1000000007

int main(){
	map<int,int> mp;
	int N,M; cin>>N>>M;
	ll wa=0,ac=0;
	rep(i,0,M){
		int a; cin>>a;
		string s; cin>>s;
		if(s=="WA" && mp[a]!=-1) mp[a]++;
		else if(s=="AC" && mp[a]!=-1){
			wa+=mp[a];
			ac++;
			mp[a]=-1;
		}
	}
	cout<<ac<<" "<<wa;
	
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int square(int a){
  return a*a;
}
double cal_dist(pair<int, int> a, pair<int, int> b){
  return sqrt(square(a.first-b.first)+square(a.second-b.second));
}

int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> xy(N);
  REP(i, N){
    int x, y;
    cin >> x >> y;
    xy[i] = {x, y};
  }
  vector<int> retu(N);
  double ans = 0; 
  REP(i, N){
    retu[i] = i;
  }
  ll cnt = 0;
  do{
    cnt++;
    REP(i, N-1){
      ans += cal_dist(xy[retu[i]], xy[retu[i+1]]);
    }
  }while(next_permutation(retu.begin(), retu.end()));
  ans /= cnt;
  printf("%.9f\n", ans);
  
  return 0;
}


Measured memory_bytes: 3848
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a)


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

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

    int n;
    cin >> n;
    vector<int> a(n - 1), b(n, 0);
    rep(i, n - 1)
    {
        cin >> a.at(i);
        b.at(a.at(i) - 1)++;
    }
    rep(i, n) cout << b.at(i) << endl;

    return 0;
}

Measured memory_bytes: 4796
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> t(n+1);
  vector<int> x(n+1);
  vector<int> y(n+1);
  
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  
  for(int i = 1;i < n+1; i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  
  for(int i = 1;i < n+1; i++){
    if(t[i]%2 != (x[i]+y[i])%2){
      cout << "No";
      return 0;
    }
    
    if(t[i] - t[i-1] < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])){
      cout << "No";
      return 0;
    }
  }
  
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 1408
class UnionFindTree():
    def __init__(self, N):
        self.N = N
        self.__parent_of = [None] * N
        self.__rank_of = [0] * N
        self.__size = [1] * N

    def root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.root(a)
        r2 = self.root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
                self.__size[r2] += self.__size[r1]
            else:
                self.__parent_of[r2] = r1
                self.__size[r1] += self.__size[r2]
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def size(self, a):
        return self.__size[self.root(a)]

    def groups(self):
        groups = {}
        for k in range(self.N):
            r = self.root(k)
            if r not in groups:
                groups[r] = []
            groups[r].append(k)
        return [groups[x] for x in groups]


def main():
    N, M, K = map(int, input().split())
    uft = UnionFindTree(N)
    friends = [0] * N
    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        uft.unite(a, b)
        friends[a] += 1
        friends[b] += 1
    ans = [0] * N
    for g in uft.groups():
        for u in g:
            ans[u] = len(g) - 1 - friends[u]
    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c-1, d-1
        if uft.is_same(c, d):
            ans[c] -= 1
            ans[d] -= 1
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 99416
import heapq
N, M, init_silver = map(int, input().split())
MAX_COST = 2500
init_silver = min(init_silver, MAX_COST)

G = [[] for _ in range(N)]
for i in range(M):
    u, v, silver_cost, time_cost = map(int, input().split())
    u, v = u - 1, v - 1
    G[u].append([v, silver_cost, time_cost])
    G[v].append([u, silver_cost, time_cost])

change_rate, change_cost = [], []
for i in range(N):
    rate, cost = map(int, input().split())
    G[i].append([i, -rate, cost])  # これを追加！
    change_rate.append(rate)
    change_cost.append(cost)


# dp[i][silver] := 頂点iにいて銀貨をsilver枚持っているような状況を作るために必要な最小時間
dp = [[float('inf')] * (MAX_COST + 1) for _ in range(N)]
dp[0][init_silver] = 0

# 優先度付きキュー: (time, node, silver)
hq = [(0, 0, init_silver)]
while hq:
    time, node, silver = heapq.heappop(hq)

    for to, silver_cost, time_cost in G[node]:
        remain_silver = min(silver - silver_cost, MAX_COST)
        if remain_silver < 0:
            continue

        dp_next_value = time + time_cost
        if dp[to][remain_silver] <= dp_next_value:
            continue

        dp[to][remain_silver] = dp_next_value
        heapq.heappush(hq, (dp_next_value, to, remain_silver))

print(*[min(d) for d in dp[1:]], sep="\n")

Measured memory_bytes: 24172
n = int(input())

dp = [0]*64
#dpの保持変更

#a,g,c =0,1,2
##末尾4文字見る必要がある。3文字ではない

def test(w,x,y,z):
    s = ((0,1,2),(1,0,2),(0,2,1))
    if (x,y,z) not in s and (w,y,z)!=(0,1,2) and (w,x,z)!=(0,1,2):##これ手でノーミスは無理なのだが、処理の実装を思いつく気がしない
        return True
    else:
        return False

for i in range(64):
    x,y,z = i>>4,(i>>2)&3,i&3
    if test(3,x,y,z):
        dp[i]=1

for i in range(3,n):
    dp2 = [0]*64
    for j in range(64):
        w,x,y = j>>4,(j>>2)&3,j&3
        """
        if w not in (0,1,2,3) or x not in (0,1,2,3) or y not in ( 0,1,2,3):
            print(j,w,x,y)
            exit()
        """
        for z in range(4):
            if test(w,x,y,z):
                dp2[(x<<4)+(y<<2)+z]+=dp[j]
    dp = dp2

#for i in range(16):
#    ans+=dp[i][n-1]
ans = sum(dp)
ans%=10**9+7
print(ans)


Measured memory_bytes: 52080
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>

using namespace std;
using ll = long long;

// inf
const ll infl = 1LL << 60;
const int inf = 1 << 30;

int main() {
    int N; cin >> N;
    vector<int> X(N), Y(N), H(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i] >> H[i];
    }

    int rcx, rcy, rH;
    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            int rh = -1, maxh = inf;
            for (int i = 0; i < N; ++i) {
                if (H[i] != 0) {
                    int t = abs(X[i] - cx) + abs(Y[i] - cy) + H[i];
                    if (rh == -1LL) {
                        rh = t;
                    }
                    else if (rh != t){
                        goto fail;
                    }
                }
                else {
                    maxh = min(maxh, abs(X[i] - cx) + abs(Y[i] - cy));
                }
            }
            if (rh != -1 && rh <= maxh) {
                rcx = cx; rcy = cy; rH = rh;
                goto success;
            }

            if (rh == -1 && maxh == 1) {
                rcx = cx; rcy = cy; rH = 1;
                goto success;
            }
            fail:;
        }
    }

    success:;
    cout << rcx << " " << rcy << " " << rH << endl;
    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
h = gets.split.map(&:to_i)

dp = Array.new(n, 100_000_000_000)

dp[0] = 0
(n - 1).times do |i|
  if i < n - 2
    dp[i + 1] = [dp[i + 1], dp[i] + (h[i] - h[i + 1]).abs].min
    dp[i + 2] = [dp[i + 2], dp[i] + (h[i] - h[i + 2]).abs].min
  else
    dp[i + 1] = [dp[i + 1], dp[i] + (h[i] - h[i + 1]).abs].min
  end
end

puts dp[n - 1]


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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (a < b) {
    swap(a, b);
  }
  ans += a;
  a--;
  ans += max(a, b);
  cout << ans;
  return 0;
}




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

int main() {
	int h,w;
	cin>>h>>w;
	char square[h][w];
	
	for(int i=0;i<h;i++)
		scanf("%s",&square[i]);
	
	bool tmp=1;
	for(int i=0;i<h;i++) {
		tmp=1;
		for(int j=0;j<w;j++)
			if(square[i][j]=='#')
				tmp=0;
		if(tmp==1) {
			square[i][0]='1';
			for(int j=1;j<w;j++)
				square[i][j]=='0';
		}
	}
	
	for(int j=0;j<w;j++) {
		tmp=1;
		for(int i=0;i<h;i++)
			if(square[i][j]=='#')
				tmp=0;
		
		if(tmp==1) for(int i=0;i<h;i++) {
			if(square[i][j]!='1')
				square[i][j]='0';
		}	
	}
	
	for(int i=0;i<h;i++) {
		if(square[i][0]=='1') continue;
		for(int j=0;j<w;j++) {
			if(square[i][j]=='0') continue;
			cout<<square[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    int n,count = 1;
    cin >> n;

    while(1){
        if(n == 4 || n == 2 || n == 1)break;
        if(n % 2 == 0){
            n /= 2;
        }else{
            n = n*3+1;
        }
        count++;
        
    }

    cout << count+3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main(){int h,b,i,j;std::string r,a;while(std::cin>>r>>a,r!="0"&&a!="0"){h=b=i=0;for(;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])i==j?h++:b++;printf("%d %d\n",h,b);}}

Measured memory_bytes: 920
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#define DBL_MIN 0.000000000000001
#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;


unsigned long euclidean_gcd(unsigned long a, unsigned long b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


int main(void){
    unsigned long N;
    cin >> N;
    unsigned long neko;
    cin >> neko;
    for(long i =1;i < N ; i ++){
        unsigned long tmp;
        cin >> tmp;
        if(neko % tmp){
            neko = min (neko , tmp) * ( max (neko , tmp) / euclidean_gcd(neko,tmp));
        }
    }
    cout << neko << endl;
}

Measured memory_bytes: 3616
N,M = map(int,input().split())
C = [0] * (M+1)
for i in range(N):
    K = list(map(int, input().split()))
    for k in range(len(K)):
        if k != 0:
            C[K[k]] += 1
count = 0

for c in C:
    if c == N:
        count += 1

print(count)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
    using namespace std;
    #define ll  unsigned long long
    #define ld  long double
    #define endl '\n'
    #define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    const ll MOD = 998244353;
    const double PI = 3.141592653589793238463;
    const int MAXN = 200005;
    int n,m;
    vector<int>v[MAXN];
    bool vis[MAXN];
    map<int,int> ma;
    vector<int> ans1;
    bool flag=0;
    void bfs(int a)
    {
        memset(vis,0,sizeof vis);
        queue<pair<int,int>> q;
        q.push({a,0});
        ma[a]=0;
        vis[a]=1;
        while(!q.empty())
        {
            int cur=q.front().first;
            int dep=q.front().second;
            q.pop();
            for(int i=0; i<v[cur].size(); i++)
            {
                if(!vis[v[cur][i]])
                {
                    ma[v[cur][i]]=dep+1;
                    vis[v[cur][i]]=1;
                    q.push({v[cur][i],dep+1});
                }
            }
        }


    }
    int main()
    {
        FAST

        cin>>n>>m;
        for(int i=0; i<m; i++)
        {
            int a,b;
            cin>>a>>b;
            v[a].push_back(b);
            v[b].push_back(a);
        }
        for(int i=1;i<=n;i++){
            ma[i]=1e9;
        }
       bfs(1);
       for(int i=2;i<=n;i++){
        int mn=1e8;
        int temp=-1;
        for(int j=0;j<v[i].size();j++){
            if(ma[v[i][j]]<mn){
                mn=ma[v[i][j]];
                temp=v[i][j];
            }
        }
        if(temp==-1)
            return cout<<"No",0;
        else{
            ans1.push_back(temp);
        }
       }
        cout<<"Yes"<<endl;
        for(int i=0; i<ans1.size(); i++)
            cout<<ans1[i]<<endl;


        return 0;
    }


Measured memory_bytes: 17484
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    int c = a + b;

    int x = n / c;
    int ans = a * x;
    int y = n % c;
    ans += min(a,y);
    cout<<ans<<endl;
    return 0;
    
}



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

using namespace std;

typedef long long ll;

int main()
{
  ll a, b, c, d;
  string s;
  cin >> a >> b >> c >> s;
  d = 0;int e = 0;
  for(int i = 0; i < a; i++) {
    if(s[i] == 'a') {
      if(b + c > d) {
	d++;
	cout << "Yes" << endl;
      } else {
	cout << "No" << endl;
      }
    } else if(s[i] == 'b') {
      if(b + c > d && e < c)	{
	d++, e++;
	cout << "Yes" << endl;
      } else {
	cout << "No" << endl;
      }
    } else {
      	cout << "No" << endl;

    }

  }
  return 0;
}


Measured memory_bytes: 896
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 505
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
#define pii pair < int , int >
#define fi first
#define se second
using namespace std;
typedef long long ll;

int N, vl[MAX][MAX], vis[MAX][MAX], rnd, ans;
bool alive[MAX][MAX];
int m[4][2]{{0,1},{1,0},{-1,0},{0,-1}};

void print(){
    for(int i = 0; i < N; i ++)
        for(int j = 0; j < N; j++)
            cout << vl[i][j] << " \n"[j == N-1];
    cout << "\n";
}

void dfs(int x, int y){
    for(int i = 0; i < 4; i ++){
        int nx = x + m[i][0];
        int ny = y + m[i][1];
        if(nx < 0 or ny < 0 or nx == N or ny == N)
            continue;
        if(vl[x][y] + alive[x][y] < vl[nx][ny]) {
            vl[nx][ny] = vl[x][y] + alive[x][y];
            dfs(nx, ny);
        }
    }
}

int main()
{
    optimiza_io
    cin >> N;
    for(int i = 0; i < N; i ++)
        for(int j = 0; j < N; j ++){
            vl[i][j] = min(min(i, N - i - 1), min(j, N - j - 1));
            alive[i][j] = 1;
            //cout << vl[i][j] << " \n"[j == N-1];
        }
    
    for(int t = 0; t < N*N; t ++){
        int x, i, j;
        cin >> x;
        x--;
        i = x / N;
        j = x % N;
        ans += vl[i][j];
        alive[i][j] = 0;
        dfs(i, j);
    }
    cout << ans << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 20296
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	string s; cin >>s;
	int cntn=0;
	int cntw=0;
	int cnts=0;
	int cnte=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='N')cntn++;
		if(s[i]=='W')cntw++;
		if(s[i]=='S')cnts++;
		if(s[i]=='E')cnte++;
	}
	bool a=true;
	if (cntn==0&&cnts>0)a=false;
	if (cnts==0&&cntn>0)a=false;
	if (cntw==0&&cnte>0)a=false;
	if (cnte==0&&cntw>0)a=false;
	if(!a)cout << "No"<< endl;
	else cout << "Yes"<< endl;
}

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

int main(){
  long A, B, K;
  cin >> A >> B >> K;

  if (A >= K)
  {
    A -= K;
  }else if (B >= K - A)
  {
    B = B + A - K;
    A = 0;
  }else
  {
    A = 0;
    B = 0;
  }
  
  cout << A;
  cout << " ";
  cout <<  B;

  return 0;
}

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

int n;
vector<int> a;
int v[100010];
int ans;

template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, a);
	for(int i=0; i<n; ++i){
		++v[a[i]];
		++v[a[i]+1];
		++v[a[i]+2];
	}
	for(int i=0; i<100010; ++i)
		ans = max(ans, v[i]);
	cout << ans << "\n";
}

Measured memory_bytes: 1144
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():
    ten = [400,600,800,1000,1200,1400,1600,1800]
    n = getN()
    print(9 - bisect_right(ten,n))
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

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

int fib[50];

int main() {
    int n; cin >> n;
    fib[0] = fib[1] = 1;
    for (int i = 2; i < 50; ++i) {
        fib[i] = fib[i-1]+fib[i-2];
    }
    cout << fib[n] << endl;
}

Measured memory_bytes: 3052
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            int S;
            int h;
            int m;
            int s;

            S = int.Parse(System.Console.ReadLine());

            if(0 <= S || S <= 86400)
            {

            h = S / 3600;

            if(S % 3600 == 0)
            {
                m = 0;
                s = 0;
            }
            else
            {
                m = (S % 3600) / 60;

                s = (S % 3600) % 60;
            }

            System.Console.WriteLine("{0}:{1}:{2}", h, m, s);
            }


        }
    }
}

Measured memory_bytes: 9144
n=int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

ans='No'
for p in range(n-2):

    if x[p] == y[p] and x[p+1] == y[p+1] and x[p+2] == y[p+2] :
        ans='Yes'
        break

print(ans)


Measured memory_bytes: 9208
def bubbleSort( cards ):
    n = len( cards )
    for i in range( 0, n ):
        for j in range( n-1 , i, -1 ):
            if int( cards[j][1] ) < int( cards[ j-1 ][1] ):
                cards[j], cards[ j-1 ] = cards[ j-1 ], cards[j]
 
    print( " ".join( map( str, cards ) ) )
 
def selectionSort( cards ):
	n = len( cards )
	for i in range( 0, n ):
		mini = i
		for j in range( i , n ):
			if int( cards[j][1] ) < int( cards[ mini ][1] ):
				mini = j
		if mini != i:
			cards[i], cards[ mini ] = cards[ mini ], cards[i]

	print( " ".join( map( str, cards ) ) )


n = int( raw_input( ) )
cards = raw_input( ).split( " " )
cards2 = list( cards )
bubbleSort( cards )
print( "Stable" )
selectionSort( cards2 )
if cards2 == cards:
	print( "Stable" )
else:
	print( "Not stable" )

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

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;

    const int A_MAX = 400, INF = 1e9;
    vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(A_MAX + 1, vector<int>(A_MAX + 1, INF)));
    // dp[i][j][k]: i 番目までで a の合計が j, b の合計が k となるときの価格の最小値
    dp[0][0][0] = 0;
    for (int i = 1; i <= n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        for (int j = 0; j <= A_MAX; j++) {
            for (int k = 0; k <= A_MAX; k++) {
                dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]);
                if (j - a >= 0 and k - b >= 0) {
                    dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - a][k - b] + c);
                }
            }
        }
    }

    int ans = INF;
    for (int j = 1; j <= A_MAX; j++) {
        for (int k = 1; k <= A_MAX; k++) {
            if (j * mb == k * ma) {
                ans = min(ans, dp[n][j][k]);
            }
        }
    }
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 27264
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int maxW = sc.nextInt();
		
		int[] w = new int[n + 1];
		int[] v = new int[n + 1];
		int sumV = 0;
		for (int i = 1; i <= n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
			sumV += v[i];
		}
		
		long[][] dp = new long[n + 1][sumV + 1];
		for (int i = 1; i <= sumV; i++)
			dp[0][i] = Integer.MAX_VALUE;
		
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= sumV; j++) {
				dp[i][j] = dp[i - 1][j];
				if (j - v[i] >= 0)
					dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
			}
		}
		
		long ans = 0;
		for (int i = sumV; i >= 0; i--) {
			if (dp[n][i] <= maxW) {
				ans = i;
				break;
			}
		}
		
		System.out.println(ans);
//		for (long[] arr : dp)
//			System.out.println(Arrays.toString(arr));
		
		sc.close();
	}
}



Measured memory_bytes: 129004
#include <stdio.h>

int main()
{
  int x,i;
  int A[50];

  scanf("%d",&x);

  A[0]=A[1]=1;

  for(i=2;i<=x;i++)
  {
    A[i]=A[i-1]+A[i-2];
  }
  printf("%d\n",A[x]);
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define m 998244353
#define MAXN 50000 + 5
#define BLK_SIZE 225
using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int ll 
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define con continue
#define endl "\n"
 
//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
int modexpo(int a , int b)
{
    int res = 1;
    while(b)
    {
        if (b & 1)
            res = (res * a) % m;
        b = b / 2;
        a = (a * a) % m;
    }
    return res;
}

signed main()
{
    int n;
    cin >> n;
    string str;
    cin >> str;
    int ans = 0;
    for (int i = 0 ; i <= n - 3 ; i++)
    {
        if (str.substr(i , 3) == "ABC")
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int n,m,ans=0,tmp[200005];
struct Student{
    int l,r;
    bool operator<(const Student &b)const{
        return l!=b.l?l<b.l:r>b.r;
    }
}s[200005];
priority_queue<int,vector<int>,greater<int> > q;

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&s[i].l,&s[i].r);
    sort(s+1,s+n+1);
    int h=1,t=m;
    for(int i=1;i<=n;i++){
        q.push(s[i].r);
        if(h<=t&&h<=s[i].l)h++;
        else{
            tmp[++tmp[0]]=q.top();
            q.pop();
        }
    }
    sort(tmp+1,tmp+tmp[0]+1);
    for(int i=tmp[0];i>=1;i--){
        if(h<=t&&tmp[i]<=t)t--;
        else ans++;
    }
    printf("%d",ans);
}

Measured memory_bytes: 3192
n,x,y = map(int,input().split())
ans = [0]*(n+1)
for i in range(1,n):
  for j in range(i+1,n+1):
    if j <= x or i >= y:
      k = j-i
    elif i <= x and j >= y:
      k = x-i+j-y+1
    elif i <= x and j <= y:
      k = min(j-i,x-i+1+y-j)
    elif i >= x and j >= y:
      k = min(j-i,j-y+1+i-x)
    else:
      k = min(j-i,y-j+1+i-x)
    ans[k] += 1
for i in range(1,n):
  print(ans[i])

Measured memory_bytes: 3444
// Problem : A - Poisonous Cookies
// Contest : AtCoder Grand Contest 030
// URL : https://atcoder.jp/contests/agc030/tasks/agc030_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   ll c;
   cin>>a>>b>>c;
   cout<<b+min(c,a+b+1);
	
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var T = cin.ReadInt;
            var A = cin.ReadInt;
            var H = cin.ReadIntArray(N);

            double minDiff = 10000000;
            var ansIndex = 0;
            for(var i=0; i<N; i++)
            {
                double temp = T - H[i] * 0.006;
                double diff = Abs(temp-A);
                if(diff < minDiff)
                {
                    minDiff = diff;
                    ansIndex = i + 1;
                }
            }

            WriteLine(ansIndex);
        }

        static long GcdArray(long[] array)
        {
            var ans = array[0];
            for(var i=1; i<array.Length; i++)
            {
                ans = Gcd(ans, array[i]);
            }
            return ans;
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13320
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    string s;
    cin >> n >> s;
    string p = "ABC";
    int ans = 0;
    for (int i = 0; i < n - 2; i++) {
        //cout << s.substr(i, 3) << endl;
        if (s.substr(i, 3) == p) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 200010;
ll a[maxN]; 
ll b[maxN];
map<ll,int> k;
int main()
{
	int n;
	ll ans = 0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	b[1] = a[1];
	for(int i=2;i<=n;i++)
	{
		b[i] = b[i-1] + a[i];
	}
	k[0] = 1;
	for(int i=1;i<=n;i++)
	{
		ans += k[b[i]];
		k[b[i]]++; 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15872
N,M = map(int,input().split(" "))
h_list = list(map(int,input().split(" ")))
road = [[] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split(" "))
    road[a-1].append(b-1)
    road[b-1].append(a-1)
good_obs = [0 for i in range(N)]
for i in range(N):
    if len(road[i]) == 0:
        good_obs[i] = 1
    else:
        h_max = 0
        for j in road[i]:
            h_max = max(h_max,h_list[j])
        if h_max < h_list[i]:
            good_obs[i] = 1
print(good_obs.count(1))


Measured memory_bytes: 30128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

int main(){
    int n; cin >> n;
    vint l(n); rep(i,n) cin >> l[i];
    if(accumulate(all(l),0)-*max_element(all(l))>*max_element(all(l))){
        cout << "Yes\n";
    }
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >>n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  sort(v.begin(),v.end());
  double a=v[0];
  
  for(int i=1; i<n; i++){
  	a=(a+v[i])/2.0;
  }
  
  cout << a << endl;
  
  
}

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

typedef long long ll;

priority_queue<pair<ll, int> > a, b;
ll l[100005], r[100005];
bool used[100005];
ll ans;
int n;

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++) scanf("%lld%lld", l+i, r+i);
	for (int i = 0;i < n;i++) used[i] = false;
	{
		ll alt = 0;
		for (int i = 0;i < n;i++) a.emplace(l[i], i), b.emplace(-r[i], i);
		ll pos = 0;
		for (int i = 0;i < n;i++)
			if (i&1)
			{
				while (used[a.top().second]) a.pop();
				used[a.top().second] = true;
				if (pos < l[a.top().second])
				{
					alt += l[a.top().second]-pos;
					pos = l[a.top().second];
				} else if (pos > r[a.top().second])
				{
					alt += pos-r[a.top().second];
					pos = r[a.top().second];
				}
			} else
			{
				while (used[b.top().second]) b.pop();
				used[b.top().second] = true;
				if (pos < l[b.top().second])
				{
					alt += l[b.top().second]-pos;
					pos = l[b.top().second];
				} else if (pos > r[b.top().second])
				{
					alt += pos-r[b.top().second];
					pos = r[b.top().second];
				}
			}
		alt += abs(pos);
		ans = max(ans, alt);
	}
	while (!a.empty()) a.pop();
	while (!b.empty()) b.pop();
	for (int i = 0;i < n;i++) used[i] = false;
	{
		ll alt = 0;
		for (int i = 0;i < n;i++) a.emplace(l[i], i), b.emplace(-r[i], i);
		ll pos = 0;
		for (int i = 1;i <= n;i++)
			if (i&1)
			{
				while (used[a.top().second]) a.pop();
				used[a.top().second] = true;
				if (pos < l[a.top().second])
				{
					alt += l[a.top().second]-pos;
					pos = l[a.top().second];
				} else if (pos > r[a.top().second])
				{
					alt += pos-r[a.top().second];
					pos = r[a.top().second];
				}
			} else
			{
				while (used[b.top().second]) b.pop();
				used[b.top().second] = true;
				if (pos < l[b.top().second])
				{
					alt += l[b.top().second]-pos;
					pos = l[b.top().second];
				} else if (pos > r[b.top().second])
				{
					alt += pos-r[b.top().second];
					pos = r[b.top().second];
				}
			}
		alt += abs(pos);
		ans = max(ans, alt);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5228
import sys
input = sys.stdin.readline

class SegmentTree():
    def __init__(self,arr,func=min,ie=2**63-1):
        self.n = 2**(len(arr)-1).bit_length()
        self.ie = ie
        self.func = func
        self.tree = [ie for _ in range(2*self.n)]
        for i in range(len(arr)):
            self.tree[self.n+i-1] = arr[i]
        for i in range(self.n-1)[::-1]:
            self.tree[i] = func(self.tree[2*i+1],self.tree[2*i+2])
    def update(self,index,x): #0-index！
        index += self.n-1
        self.tree[index] = x
        while index>0:
            index = (index-1)//2
            self.tree[index] = self.func(self.tree[2*index+1],self.tree[2*index+2])
    def query(self,left,right): #開区間！
        if right <= left:
            return self.ie
        left += self.n-1
        right += self.n-2
        res = self.ie
        while right-left > 1:
            if left & 1 == 0:
                res = self.func(res,self.tree[left])
            if right & 1 == 1:
                res = self.func(res,self.tree[right])
                right -= 1
            left = left//2
            right = (right-1)//2
        if left == right:
            res = self.func(res,self.tree[left])
        else:
            res = self.func(self.func(res,self.tree[left]),self.tree[right])
        return res

N,Q = map(int,input().split())
ans = []
A = [2**31-1 for _ in range(N)]
sg = SegmentTree(A)
for _ in range(Q):
    c,x,y = map(int,input().split())
    if c==0:
        sg.update(x,y)
    else:
        ans.append(sg.query(x,y+1))
print(*ans,sep='\n')


Measured memory_bytes: 11228
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;

const int MAXN = 110;
struct pt {
    int id, x, y;
    inline bool operator<(pt rhs) const {
        return (x == rhs.x) ? (y < rhs.y) : (x < rhs.x);
    }
    inline pt operator-(pt rhs) const { return (pt){0, x - rhs.x, y - rhs.y}; }
} A[MAXN], CH[MAXN];
int N;

inline ll cross(pt v, pt w) { return (ll)v.x * w.y - (ll)w.x * v.y; }
inline ll dot(pt v, pt w) { return (ll)v.x * w.x + (ll)v.y * w.y; }

double Ans[MAXN];
const double pi = acos(-1.0);

int main() {
    int i;
    scanf("%d", &N);
    for(i = 0; i < N; i++) scanf("%d%d", &A[i].x, &A[i].y), A[i].id = i;

    //CH2D
    sort(A, A + N);
    int m = 0;
    for(i = 0; i < N; i++) {
        while(m > 1 && cross(CH[m - 1] - CH[m - 2], A[i] - CH[m - 2]) <= 0) m--;
        CH[m++] = A[i];
    }
    int k = m;
    for(i = N - 2; i >= 0; i--) {
        while(m > k && cross(CH[m - 1] - CH[m - 2], A[i] - CH[m - 2]) <= 0) m--;
        CH[m++] = A[i];
    }
    m--;

    //Calc Prob
    if(m == 2) Ans[CH[0].id] = Ans[CH[1].id] = 0.5;
    else for(i = 0; i < m; i++) {
        int pre = (i + m - 1) % m, nxt = (i + 1) % m;
        pt v1 = CH[pre] - CH[i], v2 = CH[nxt] - CH[i];
        Ans[ CH[i].id ] = (pi - acos( dot( v1, v2 ) / (sqrt( dot(v1,v1) ) * sqrt( dot(v2,v2) )) )) / (2 * pi);
    }
    
    for(i = 0; i < N; i++) printf("%.12lf\n", Ans[i]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define QS ios_base::sync_with_stdio(false);
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9+7;
using namespace std;

int main(){
//freopen("output.txt", "w", stdout);
    QS
    string s;
    cin >> s;
    if(s == "SAT"){
        cout << 1;
    }
    else if(s == "SUN"){
        cout << 7;
    }
    else if(s == "MON"){
        cout << 6;
    }
    else if(s == "TUE"){
        cout << 5;
    }
    else if(s == "WED"){
        cout << 4;
    }
    else if(s == "THU"){
        cout << 3;
    }
    else cout << 2;
}


Measured memory_bytes: 256
import itertools
import numpy as np
N, M, X = map(int,input().split())
CA = np.array([tuple(map(int, input().split())) for _ in range(N)])
ans = 10**7
for i in itertools.product([0,1], repeat = N):
    cost = 0
    und = np.array([[0]*M])
    for x in range(N):
        if i[x]:
            cost += CA[x,0]
            und += CA[x,1::]
    if np.all(und >= X):
        ans = min(ans, cost)

print(-1 if ans == 10**7 else ans)      

Measured memory_bytes: 27348
#include <bits/stdc++.h>
using namespace std;
string a;
void solve()
{
    for (int i=0;i<3;i++)
        if (a[i]=='1') a[i]='9';
        else a[i]='1';
    cout<<a<<endl;
}
int main()
{
    while(cin>>a)
        solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] ch = s.toCharArray();
		int i = s.length();
		System.out.print(ch[0]);
		System.out.print(i-2);
		System.out.println(ch[s.length()-1]);
 	}
}

Measured memory_bytes: 22868
x, y = map(int, input().split())
dd = {}
c = 0 #間違い数
p = 0 #AC数
for i in range(x):
    dd[i+1] = 0
for _ in range(y):
    a, b = map(str, input().split())
    a = int(a)
    if b == 'WA':
        if dd[a] == 'o':
            continue
        else:
            dd[a] += 1
    else:
        if dd[a] == 'o':
            continue
        else:
            c += dd[a]
            p += 1
            dd[a] = 'o'
            
print(p, c)

Measured memory_bytes: 15084
local ior = io.input()
local n = ior:read("*n")
local t = {}
for i = 1, 2 * n do t[i] = ior:read("*n") end
table.sort(t)
local sum = 0
for i = 1, 2 * n, 2 do
  sum = sum + t[i]
end
print(sum)


Measured memory_bytes: 508
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static long[] dp = new long[100010];
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		Arrays.fill(dp, Long.MAX_VALUE);
		
		dp[0] = 0;
		
		int n = sc.nextInt();
		int[] h = new int[n];
		
		for(int i = 0; i < n; i++) h[i] = sc.nextInt();
		
		dp[1] = Math.abs(h[0]-h[1]);
		
		for(int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-2]+Math.abs(h[i]-h[i-2]), dp[i-1]+Math.abs(h[i]-h[i-1]));
		}
		
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 61932
#!/usr/bin/env fsharpi

open System;

let readIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let readInt1 ( str : string ) =
    readIntN str |> fun arr -> arr.[0]

let readInt2 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1])

let readInt3 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

Console.ReadLine() |> String.map ( fun c -> if c <> ',' then c else ' ' ) |> Console.WriteLine;

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

int main() {
  int N; cin >> N;
  for (int i = 1; i <= N; i++) {
    if (i * 108 / 100 == N) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
import queue
import sys
def input(): return sys.stdin.readline().rstrip()

def m():
    n, q = map(int, input().split())
    tree = [[] for _ in range(n + 1)]
    for i in range(1, n):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    counter = [0] * (n + 1)
    for _ in range(q):
        p, x = map(int, input().split())
        counter[p] += x

    que = queue.Queue()
    visited = [False] * (n+1)

    def bfs(root, base):
        base += counter[root]
        visited[root] = True
        for e in tree[root]:
            if visited[e]:
                continue
            que.put(e)
            counter[e] += base

        while not que.empty():
            x = que.get()
            point = counter[x]
            visited[x] = True
            for e in tree[x]:
                if visited[e]:
                    continue
                que.put(e)
                counter[e] += point

    bfs(1, 0)
    print(*counter[1:])
    return


m()


Measured memory_bytes: 103624